[2317] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[2331] | 5 | // $Id: toi2ring.cc,v 1.4 2003-02-24 14:47:10 cecile Exp $
|
---|
[2317] | 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;
|
---|
[2319] | 34 | declareInput("Theta"); // input index 0
|
---|
[2331] | 35 | declareInput("Phi"); // input index 1
|
---|
| 36 | declareInput("Phase"); // input index 2
|
---|
| 37 | declareInput("Value"); // input index 3
|
---|
[2319] | 38 | declareOutput("CircTheta"); // output index 0
|
---|
[2331] | 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
|
---|
[2317] | 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.;
|
---|
| 64 | double* r = new double[Nsamples];
|
---|
| 65 | double* wr = new double[Nsamples];
|
---|
| 66 | for(i=0;i<Nsamples;i++) {
|
---|
| 67 | wr[i]=0;
|
---|
| 68 | r[i]=0;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 |
|
---|
[2329] | 72 | cout << "loop " << snb << " " << sne << endl;
|
---|
[2319] | 73 |
|
---|
[2317] | 74 | for(int k=snb;k<=sne;k++) {
|
---|
| 75 |
|
---|
| 76 | uint_8 flg = 0;
|
---|
[2319] | 77 | double ctheta = getData(0,k);
|
---|
| 78 | double cphi = getData(1,k);
|
---|
| 79 | double phi = getData(2,k);
|
---|
| 80 | double val = getData(3,k);
|
---|
[2317] | 81 | mSnRead++;
|
---|
| 82 |
|
---|
| 83 | i=(int)(phi*Nsamples/360.);
|
---|
| 84 | r[i]+= val;
|
---|
| 85 | wr[i]++;
|
---|
| 86 |
|
---|
[2329] | 87 | cout << k << " " << phi << " " << phi_prec << " " << Nrings <<endl;
|
---|
[2319] | 88 |
|
---|
[2329] | 89 | if(phi < phi_prec || k == sne){
|
---|
[2317] | 90 |
|
---|
| 91 | for(i=0;i<Nsamples;i++) {
|
---|
| 92 | if(wr[i] == 0) r[i] = -999999.;
|
---|
[2329] | 93 | else r[i] /= wr[i];
|
---|
| 94 | cout << "PUT " << i << " " << Nrings << " " << Nsamples << " " << ctheta << " " << cphi << " " << r[i]<< endl;
|
---|
| 95 | putData(0,Nrings*Nsamples+i,ctheta);
|
---|
| 96 | putData(1,Nrings*Nsamples+i,cphi);
|
---|
[2319] | 97 | putData(2,Nrings*Nsamples+i,r[i]);
|
---|
[2331] | 98 | putData(3,Nrings*Nsamples+i,ctheta);
|
---|
| 99 | putData(4,Nrings*Nsamples+i,cphi);
|
---|
| 100 | putData(5,Nrings*Nsamples+i,wr[i]);
|
---|
[2317] | 101 | wr[i]=0;
|
---|
[2319] | 102 | r[i]=0.;
|
---|
[2317] | 103 | }
|
---|
| 104 |
|
---|
| 105 | Nrings++;
|
---|
[2329] | 106 | return;
|
---|
| 107 |
|
---|
[2317] | 108 | }
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | phi_prec=phi;
|
---|
| 112 | totnscount++;
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | cout<<"RING2Toi::run: Samples Read "<<mSnRead
|
---|
| 116 | <<" Filled "<<mSnFilled
|
---|
| 117 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
| 118 |
|
---|
| 119 | //---------------------------------------------------------
|
---|
| 120 | } catch (PException & exc) {
|
---|
| 121 | cout<<"Toi2RING: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 122 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | return;
|
---|
| 126 | }
|
---|