[2317] | 1 | // ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
|
---|
| 2 | // Eric Aubourg
|
---|
| 3 | // Christophe Magneville
|
---|
| 4 | // Reza Ansari
|
---|
[2319] | 5 | // $Id: toi2ring.cc,v 1.2 2003-01-30 17:19:25 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
|
---|
| 35 | declareInput("Phi"); // input index 0
|
---|
[2317] | 36 | declareInput("Phase"); // input index 0
|
---|
| 37 | declareInput("Value"); // input index 1
|
---|
[2319] | 38 | declareOutput("CircTheta"); // output index 0
|
---|
| 39 | declareOutput("CircPhi"); // output index 0
|
---|
[2317] | 40 | declareOutput("Rvalue"); // output index 0
|
---|
[2319] | 41 | // declareOutput("WRvalue"); // output index 1
|
---|
[2317] | 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 |
|
---|
[2319] | 70 |
|
---|
[2317] | 71 | for(int k=snb;k<=sne;k++) {
|
---|
| 72 |
|
---|
| 73 | uint_8 flg = 0;
|
---|
[2319] | 74 | double ctheta = getData(0,k);
|
---|
| 75 | double cphi = getData(1,k);
|
---|
| 76 | double phi = getData(2,k);
|
---|
| 77 | double val = getData(3,k);
|
---|
[2317] | 78 | mSnRead++;
|
---|
| 79 |
|
---|
| 80 | i=(int)(phi*Nsamples/360.);
|
---|
| 81 | r[i]+= val;
|
---|
| 82 | wr[i]++;
|
---|
| 83 |
|
---|
[2319] | 84 | cout << phi << " " << phi_prec << " " << Nrings <<endl;
|
---|
| 85 |
|
---|
[2317] | 86 | if(phi < phi_prec){
|
---|
| 87 |
|
---|
[2319] | 88 | putData(0,Nrings,ctheta);
|
---|
| 89 | putData(1,Nrings,cphi);
|
---|
| 90 |
|
---|
[2317] | 91 | for(i=0;i<Nsamples;i++) {
|
---|
| 92 | if(wr[i] == 0) r[i] = -999999.;
|
---|
[2319] | 93 | cout << i << " " << Nrings << " " << Nsamples << " " << ctheta << " " << cphi << " " << r[i]<< endl;
|
---|
| 94 | putData(2,Nrings*Nsamples+i,r[i]);
|
---|
| 95 | // putData(1,Nrings*Nsamples+i,wr[i]);
|
---|
[2317] | 96 | wr[i]=0;
|
---|
[2319] | 97 | r[i]=0.;
|
---|
[2317] | 98 | }
|
---|
| 99 |
|
---|
| 100 | Nrings++;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | phi_prec=phi;
|
---|
| 105 | totnscount++;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | cout<<"RING2Toi::run: Samples Read "<<mSnRead
|
---|
| 109 | <<" Filled "<<mSnFilled
|
---|
| 110 | <<" BadCoorRange="<<BadCoorRange<<endl;
|
---|
| 111 |
|
---|
| 112 | //---------------------------------------------------------
|
---|
| 113 | } catch (PException & exc) {
|
---|
| 114 | cout<<"Toi2RING: Catched Exception "<<(string)typeid(exc).name()
|
---|
| 115 | <<"\n .... Msg= "<<exc.Msg()<<endl;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | return;
|
---|
| 119 | }
|
---|