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