source: Sophya/trunk/ArchTOIPipe/ProcWSophya/toi2ring.cc@ 2356

Last change on this file since 2356 was 2355, checked in by cecile, 23 years ago

ok

File size: 3.3 KB
RevLine 
[2317]1// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
2// Eric Aubourg
3// Christophe Magneville
4// Reza Ansari
[2355]5// $Id: toi2ring.cc,v 1.5 2003-03-28 16:06:17 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////////////////////////////////////////////////////////////////////////
15Toi2RING::Toi2RING(long n)
16 :totnscount(0), nRings(0)
17{
18 setNSamples(n);
19}
20
21Toi2RING::~Toi2RING()
22{
23}
24
25
26////////////////////////////////////////////////////////////////////////
27void Toi2RING::Print(::ostream & os)
28{
29}
30
31////////////////////////////////////////////////////////////////////////
32void 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////////////////////////////////////////////////////////////////////////
47void Toi2RING::run() {
48
49long snb = getMinIn();
50long sne = getMaxIn();
51if(snb>sne) {
52 cout<<"Toi2RING::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
53 throw ParmError("Toi2RING::run() - Bad sample interval");
54}
55
56//---------------------------------------------------------
57try {
58
59
60uint_4 mSnRead=0, mSnFilled=0, BadCoorRange=0;
61 int_8 Nrings=0,i;
62
[2355]63 double phi_prec=-1.,ctheta_prec,cphi_prec;
64 double phi,val,ctheta,cphi;
65
[2317]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
[2329]73 cout << "loop " << snb << " " << sne << endl;
[2319]74
[2317]75for(int k=snb;k<=sne;k++) {
76
77 uint_8 flg = 0;
[2355]78 ctheta = getData(0,k);
79 cphi = getData(1,k);
80 phi = getData(2,k);
81 val = getData(3,k);
[2317]82 mSnRead++;
83
84 i=(int)(phi*Nsamples/360.);
85 r[i]+= val;
86 wr[i]++;
87
[2319]88
[2329]89 if(phi < phi_prec || k == sne){
[2317]90
[2355]91 // if (k==sne) { wfits.setNRings(Nrings); wwfits.setNRings(Nrings);}
92
[2317]93 for(i=0;i<Nsamples;i++) {
94 if(wr[i] == 0) r[i] = -999999.;
[2329]95 else r[i] /= wr[i];
[2355]96
97 putData(0,Nrings*Nsamples+i,ctheta_prec);
98 putData(1,Nrings*Nsamples+i,cphi_prec);
[2319]99 putData(2,Nrings*Nsamples+i,r[i]);
[2355]100 putData(3,Nrings*Nsamples+i,ctheta_prec);
101 putData(4,Nrings*Nsamples+i,cphi_prec);
[2331]102 putData(5,Nrings*Nsamples+i,wr[i]);
[2317]103 wr[i]=0;
[2319]104 r[i]=0.;
[2355]105
[2317]106 }
107
[2355]108 Nrings++;
109 cout <<" Ring "<< Nrings << " written " << endl;
[2317]110 }
111 phi_prec=phi;
[2355]112 ctheta_prec=ctheta;
113 cphi_prec=cphi;
[2317]114 totnscount++;
[2355]115}
[2317]116
117cout<<"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
127return;
128}
Note: See TracBrowser for help on using the repository browser.