1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
2 | // Eric Aubourg
|
---|
3 | // Christophe Magneville
|
---|
4 | // Reza Ansari
|
---|
5 | // $Id: toi2ring.cc,v 1.5 2003-03-28 16:06:17 cecile Exp $
|
---|
6 |
|
---|
7 | #include "toimanager.h"
|
---|
8 | #include "pexceptions.h"
|
---|
9 | #include "ctimer.h"
|
---|
10 | #include "toi2ring.h"
|
---|
11 | // La valeur "Pi" doit etre celle de smathconst.h a cause du test sur theta
|
---|
12 | #include "smathconst.h"
|
---|
13 |
|
---|
14 | ////////////////////////////////////////////////////////////////////////
|
---|
15 | Toi2RING::Toi2RING(long n)
|
---|
16 | :totnscount(0), nRings(0)
|
---|
17 | {
|
---|
18 | setNSamples(n);
|
---|
19 | }
|
---|
20 |
|
---|
21 | Toi2RING::~Toi2RING()
|
---|
22 | {
|
---|
23 | }
|
---|
24 |
|
---|
25 |
|
---|
26 | ////////////////////////////////////////////////////////////////////////
|
---|
27 | void Toi2RING::Print(::ostream & os)
|
---|
28 | {
|
---|
29 | }
|
---|
30 |
|
---|
31 | ////////////////////////////////////////////////////////////////////////
|
---|
32 | void Toi2RING::init() {
|
---|
33 | cout << "Toi2RING::init" << endl;
|
---|
34 | declareInput("Theta"); // input index 0
|
---|
35 | declareInput("Phi"); // input index 1
|
---|
36 | declareInput("Phase"); // input index 2
|
---|
37 | declareInput("Value"); // input index 3
|
---|
38 | declareOutput("CircTheta"); // output index 0
|
---|
39 | declareOutput("CircPhi"); // output index 1
|
---|
40 | declareOutput("Rvalue"); // output index 2
|
---|
41 | declareOutput("WCircTheta"); // output index 3
|
---|
42 | declareOutput("WCircPhi"); // output index 4
|
---|
43 | declareOutput("WRvalue"); // output index 5
|
---|
44 | }
|
---|
45 |
|
---|
46 | ////////////////////////////////////////////////////////////////////////
|
---|
47 | void Toi2RING::run() {
|
---|
48 |
|
---|
49 | long snb = getMinIn();
|
---|
50 | long sne = getMaxIn();
|
---|
51 | if(snb>sne) {
|
---|
52 | cout<<"Toi2RING::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
53 | throw ParmError("Toi2RING::run() - Bad sample interval");
|
---|
54 | }
|
---|
55 |
|
---|
56 | //---------------------------------------------------------
|
---|
57 | try {
|
---|
58 |
|
---|
59 |
|
---|
60 | uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
|
---|
61 | int_8 Nrings=0,i;
|
---|
62 |
|
---|
63 | double phi_prec=-1.,ctheta_prec,cphi_prec;
|
---|
64 | double phi,val,ctheta,cphi;
|
---|
65 |
|
---|
66 | double* r = new double[Nsamples];
|
---|
67 | double* wr = new double[Nsamples];
|
---|
68 | for(i=0;i<Nsamples;i++) {
|
---|
69 | wr[i]=0;
|
---|
70 | r[i]=0;
|
---|
71 | }
|
---|
72 |
|
---|
73 | cout << "loop " << snb << " " << sne << endl;
|
---|
74 |
|
---|
75 | for(int k=snb;k<=sne;k++) {
|
---|
76 |
|
---|
77 | uint_8 flg = 0;
|
---|
78 | ctheta = getData(0,k);
|
---|
79 | cphi = getData(1,k);
|
---|
80 | phi = getData(2,k);
|
---|
81 | val = getData(3,k);
|
---|
82 | mSnRead++;
|
---|
83 |
|
---|
84 | i=(int)(phi*Nsamples/360.);
|
---|
85 | r[i]+= val;
|
---|
86 | wr[i]++;
|
---|
87 |
|
---|
88 |
|
---|
89 | if(phi < phi_prec || k == sne){
|
---|
90 |
|
---|
91 | // if (k==sne) { wfits.setNRings(Nrings); wwfits.setNRings(Nrings);}
|
---|
92 |
|
---|
93 | for(i=0;i<Nsamples;i++) {
|
---|
94 | if(wr[i] == 0) r[i] = -999999.;
|
---|
95 | else r[i] /= wr[i];
|
---|
96 |
|
---|
97 | putData(0,Nrings*Nsamples+i,ctheta_prec);
|
---|
98 | putData(1,Nrings*Nsamples+i,cphi_prec);
|
---|
99 | putData(2,Nrings*Nsamples+i,r[i]);
|
---|
100 | putData(3,Nrings*Nsamples+i,ctheta_prec);
|
---|
101 | putData(4,Nrings*Nsamples+i,cphi_prec);
|
---|
102 | putData(5,Nrings*Nsamples+i,wr[i]);
|
---|
103 | wr[i]=0;
|
---|
104 | r[i]=0.;
|
---|
105 |
|
---|
106 | }
|
---|
107 |
|
---|
108 | Nrings++;
|
---|
109 | cout <<" Ring "<< Nrings << " written " << endl;
|
---|
110 | }
|
---|
111 | phi_prec=phi;
|
---|
112 | ctheta_prec=ctheta;
|
---|
113 | cphi_prec=cphi;
|
---|
114 | totnscount++;
|
---|
115 | }
|
---|
116 |
|
---|
117 | cout<<"RING2Toi::run: Samples Read "<<mSnRead
|
---|
118 | <<" Filled "<<mSnFilled
|
---|
119 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
120 |
|
---|
121 | //---------------------------------------------------------
|
---|
122 | } catch (PException & exc) {
|
---|
123 | cout<<"Toi2RING: Catched Exception "<<(string)typeid(exc).name()
|
---|
124 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
125 | }
|
---|
126 |
|
---|
127 | return;
|
---|
128 | }
|
---|