1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
2 | // Eric Aubourg
|
---|
3 | // Christophe Magneville
|
---|
4 | // Reza Ansari
|
---|
5 | // $Id: toi2ring.cc,v 1.3 2003-02-24 14:14:51 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 0
|
---|
36 | declareInput("Phase"); // input index 0
|
---|
37 | declareInput("Value"); // input index 1
|
---|
38 | declareOutput("CircTheta"); // output index 0
|
---|
39 | declareOutput("CircPhi"); // output index 0
|
---|
40 | declareOutput("Rvalue"); // output index 0
|
---|
41 | // declareOutput("WRvalue"); // output index 1
|
---|
42 | }
|
---|
43 |
|
---|
44 | ////////////////////////////////////////////////////////////////////////
|
---|
45 | void Toi2RING::run() {
|
---|
46 |
|
---|
47 | long snb = getMinIn();
|
---|
48 | long sne = getMaxIn();
|
---|
49 | if(snb>sne) {
|
---|
50 | cout<<"Toi2RING::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
|
---|
51 | throw ParmError("Toi2RING::run() - Bad sample interval");
|
---|
52 | }
|
---|
53 |
|
---|
54 | //---------------------------------------------------------
|
---|
55 | try {
|
---|
56 |
|
---|
57 |
|
---|
58 | uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
|
---|
59 | int_8 Nrings=0,i;
|
---|
60 |
|
---|
61 | double phi_prec=-1.;
|
---|
62 | double* r = new double[Nsamples];
|
---|
63 | double* wr = new double[Nsamples];
|
---|
64 | for(i=0;i<Nsamples;i++) {
|
---|
65 | wr[i]=0;
|
---|
66 | r[i]=0;
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | cout << "loop " << snb << " " << sne << endl;
|
---|
71 |
|
---|
72 | for(int k=snb;k<=sne;k++) {
|
---|
73 |
|
---|
74 | uint_8 flg = 0;
|
---|
75 | double ctheta = getData(0,k);
|
---|
76 | double cphi = getData(1,k);
|
---|
77 | double phi = getData(2,k);
|
---|
78 | double val = getData(3,k);
|
---|
79 | mSnRead++;
|
---|
80 |
|
---|
81 | i=(int)(phi*Nsamples/360.);
|
---|
82 | r[i]+= val;
|
---|
83 | wr[i]++;
|
---|
84 |
|
---|
85 | cout << k << " " << phi << " " << phi_prec << " " << Nrings <<endl;
|
---|
86 |
|
---|
87 | if(phi < phi_prec || k == sne){
|
---|
88 |
|
---|
89 | for(i=0;i<Nsamples;i++) {
|
---|
90 | if(wr[i] == 0) r[i] = -999999.;
|
---|
91 | else r[i] /= wr[i];
|
---|
92 | cout << "PUT " << i << " " << Nrings << " " << Nsamples << " " << ctheta << " " << cphi << " " << r[i]<< endl;
|
---|
93 | putData(0,Nrings*Nsamples+i,ctheta);
|
---|
94 | putData(1,Nrings*Nsamples+i,cphi);
|
---|
95 | putData(2,Nrings*Nsamples+i,r[i]);
|
---|
96 | wr[i]=0;
|
---|
97 | r[i]=0.;
|
---|
98 | }
|
---|
99 |
|
---|
100 | Nrings++;
|
---|
101 | return;
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|
106 | phi_prec=phi;
|
---|
107 | totnscount++;
|
---|
108 | }
|
---|
109 |
|
---|
110 | cout<<"RING2Toi::run: Samples Read "<<mSnRead
|
---|
111 | <<" Filled "<<mSnFilled
|
---|
112 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
113 |
|
---|
114 | //---------------------------------------------------------
|
---|
115 | } catch (PException & exc) {
|
---|
116 | cout<<"Toi2RING: Catched Exception "<<(string)typeid(exc).name()
|
---|
117 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
118 | }
|
---|
119 |
|
---|
120 | return;
|
---|
121 | }
|
---|