/[PAMELA software]/calo/flight/CaloEnergy/src/CaloEnergy.cpp
ViewVC logotype

Annotation of /calo/flight/CaloEnergy/src/CaloEnergy.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Mon Jul 13 16:10:23 2009 UTC (15 years, 5 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +165 -126 lines
New features added

1 mocchiut 1.1 #include <CaloEnergy.h>
2     #include <PamLevel2.h>
3    
4     //--------------------------------------
5     /**
6     * Default constructor
7     */
8     CaloEnergy::CaloEnergy(){
9     Clear();
10     }
11    
12     CaloEnergy::CaloEnergy(PamLevel2 *l2p){
13     //
14     Clear();
15     //
16     L2 = l2p;
17     //
18     if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");
19     //
20     fSimu = false;
21 mocchiut 1.3 this->Set();
22 mocchiut 1.1 //
23     }
24    
25     CaloEnergy::CaloEnergy(PamLevel2 *l2p, Bool_t simulation){
26     //
27     Clear();
28     //
29     L2 = l2p;
30     //
31     if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");
32     //
33 mocchiut 1.3 fSimu = simulation;
34     this->Set();
35     //
36     }
37    
38     void CaloEnergy::Set(){
39 mocchiut 1.1 OBT = 0;
40     PKT = 0;
41     atime = 0;
42     sntr = "start";
43     //
44     AOBT = 0;
45     APKT = 0;
46     aatime = 0;
47     asntr = "start";
48     //
49     debug = false;
50     //
51     fLong = false;
52     fPl = 1;
53 mocchiut 1.2 fRad = -1;
54 mocchiut 1.1 //
55     this->DefineGeometry();
56     fXosel =true;
57     fXesel = true;
58     fYosel = true;
59     fYesel = true;
60 mocchiut 1.2 fConv_rxe = 44.4;
61     fConv_rxo = 44.4;
62     fConv_ryo = 44.4;
63     fConv_rye = 44.4;
64 mocchiut 1.3 fXomin = 1000;
65     fXemin = 1000;
66     fYomin = 1000;
67     fYemin = 1000;
68     }
69    
70     void CaloEnergy::SetMinimumContainment(TString section, Int_t plane){
71     section.ToUpper();
72     if ( section.Contains("XO") ) fXomin = plane;
73     if ( section.Contains("XE") ) fXemin = plane;
74     if ( section.Contains("YO") ) fYomin = plane;
75     if ( section.Contains("YE") ) fYemin = plane;
76     }
77    
78     Int_t CaloEnergy::GetMinimumContainment(TString section){
79     section.ToUpper();
80     if ( section.Contains("XO") ) return(fXomin);
81     if ( section.Contains("XE") ) return(fXemin);
82     if ( section.Contains("YE") ) return(fYemin);
83     if ( section.Contains("YO") ) return(fYomin);
84     printf(" ERROR: section not recognized \n");
85     return(-1000);
86 mocchiut 1.1 }
87    
88 mocchiut 1.2 void CaloEnergy::SetConversionFactor(TString section, Float_t conv){
89     section.ToUpper();
90     if ( section.Contains("XO") ) fConv_rxo = conv;
91     if ( section.Contains("XE") ) fConv_rxe = conv;
92     if ( section.Contains("YO") ) fConv_ryo = conv;
93     if ( section.Contains("YE") ) fConv_rye = conv;
94     }
95    
96     Float_t CaloEnergy::GetConversionFactor(TString section){
97     section.ToUpper();
98     if ( section.Contains("XO") ) return(fConv_rxo);
99     if ( section.Contains("XE") ) return(fConv_rxe);
100     if ( section.Contains("YO") ) return(fConv_ryo);
101     if ( section.Contains("YE") ) return(fConv_rye);
102     printf(" ERROR: section not recognized \n");
103     return(-1000.);
104     }
105    
106     Int_t CaloEnergy::GetMaxplane(TString section){
107     section.ToUpper();
108     if ( section.Contains("XO") ) return fMax_planexo;
109     if ( section.Contains("XE") ) return fMax_planexe;
110     if ( section.Contains("YO") ) return fMax_planeyo;
111     if ( section.Contains("YE") ) return fMax_planeye;
112     return(-1);
113     }
114    
115 mocchiut 1.1 void CaloEnergy::DefineGeometry(){
116     //
117 mocchiut 1.2 fM = 2. + 0.096; // real position from cbar
118     fM1 = 2. - 0.122 - 0.096; // due to calculation of xe1 etc.
119 mocchiut 1.1 if ( fM1 < 0. ) fM1 = 0.;
120     //
121     CaloStrip *cs = new CaloStrip(fSimu);
122    
123     // vista y piano 0 striscia 0
124     cs->Set(1,0,0);
125     xe1= cs->GetY();
126     z1= cs->GetZ();
127     // vista y piano 0 striscia 31
128     cs->Set(1,0,31);
129     xe2= cs->GetY();
130     // vista y piano 0 striscia 32
131     cs->Set(1,0,32);
132     xe3= cs->GetY();
133     // vista y piano 0 striscia 63
134     cs->Set(1,0,63);
135     xe4= cs->GetY();
136     // vista y piano 0 striscia 64
137     cs->Set(1,0,64);
138     xe5= cs->GetY();
139     // vista y piano 0 striscia 95
140     cs->Set(1,0,95);
141     xe6= cs->GetY();
142    
143     // vista x piano 0 striscia 0
144     cs->Set(0,0,0);
145     yo1= cs->GetX();
146     z2= cs->GetZ();
147     // vista x piano 0 striscia 31
148     cs->Set(0,0,31);
149     yo2= cs->GetX();
150     // vista x piano 0 striscia 32
151     cs->Set(0,0,32);
152     yo3= cs->GetX();
153     // vista x piano 0 striscia 63
154     cs->Set(0,0,63);
155     yo4= cs->GetX();
156     // vista x piano 0 striscia 64
157     cs->Set(0,0,64);
158     yo5= cs->GetX();
159     // vista x piano 0 striscia 95
160     cs->Set(0,0,95);
161     yo6= cs->GetX();
162    
163    
164     // vista y piano 1 striscia 0
165     cs->Set(1,1,0);
166     xo1= cs->GetY();
167     z3= cs->GetZ();
168     // vista y piano 1 striscia 31
169     cs->Set(1,1,31);
170     xo2= cs->GetY();
171     // vista y piano 1 striscia 32
172     cs->Set(1,1,32);
173     xo3= cs->GetY();
174     // vista y piano 1 striscia 63
175     cs->Set(1,1,63);
176     xo4= cs->GetY();
177     // vista y piano 1 striscia 64
178     cs->Set(1,1,64);
179     xo5= cs->GetY();
180     // vista y piano 1 striscia 95
181     cs->Set(1,1,95);
182     xo6= cs->GetY();
183    
184     // vista x piano 1 striscia 0
185     cs->Set(0,1,0);
186     ye1= cs->GetX();
187     z4= cs->GetZ();
188     // vista x piano 1 striscia 31
189     cs->Set(0,1,31);
190     ye2= cs->GetX();
191     // vista x piano 1 striscia 32
192     cs->Set(0,1,32);
193     ye3= cs->GetX();
194     // vista x piano 1 striscia 63
195     cs->Set(0,1,63);
196     ye4= cs->GetX();
197     // vista x piano 1 striscia 64
198     cs->Set(0,1,64);
199     ye5= cs->GetX();
200     // vista x piano 1 striscia 95
201     cs->Set(0,1,95);
202     ye6= cs->GetX();
203    
204     //
205     for (Int_t p = 0; p<22; p ++){
206     for (Int_t v = 0; v<2; v++ ){
207     cs->Set(v,p,0);
208     trk_z[p][v]= cs->GetZ(); // << cooordinata Z piano
209     };
210     };
211     //
212     delete cs;
213     //
214     }
215    
216     void CaloEnergy::Clear(){
217     //
218 mocchiut 1.3 fPartsel = false;
219     fSel = false;
220     fXosel = false;
221     fXesel = false;
222     fYosel = false;
223     fYesel = false;
224     fCount = 0.;
225 mocchiut 1.1 fEnergy = 0.;
226 mocchiut 1.2 fEnergyxe = 0.;
227     fEnergyxo = 0.;
228     fEnergyye = 0.;
229     fEnergyyo = 0.;
230 mocchiut 1.3 fMax_plane = 0;
231     fMax_planexo = 0;
232     fMax_planexe = 0;
233     fMax_planeyo = 0;
234     fMax_planeye = 0;
235 mocchiut 1.1 memset(enstrip,0,2*22*96*(sizeof(Float_t)));
236     en = 0.;
237     view = 0;
238     plane = 0;
239     strip = 0;
240     energyxe = 0.;
241     energyyo = 0.;
242     energyxo = 0.;
243     energyye = 0.;
244 mocchiut 1.3 fYoout = 0;
245     fYeout = 0;
246     fXoout = 0;
247     fXeout = 0;
248 mocchiut 1.1 memset(en_xep,0,11*sizeof(Float_t));
249     memset(en_yep,0,11*sizeof(Float_t));
250     memset(en_xop,0,11*sizeof(Float_t));
251     memset(en_yop,0,11*sizeof(Float_t));
252     //
253     }
254    
255     void CaloEnergy::Print(){
256     //
257     printf("========================================================================\n");
258     printf(" OBT: %u PKT: %u ATIME: %u \n",OBT,PKT,atime);
259     printf(" fEnergy :.............. %f \n",fEnergy);
260 mocchiut 1.2 printf(" fMax_plane :........... %f \n",fMax_plane);
261     printf(" fMax_planexo :......... %i \n",fMax_planexo);
262     printf(" fMax_planexe :......... %i \n",fMax_planexe);
263     printf(" fMax_planeyo :......... %i \n",fMax_planeyo);
264     printf(" fMax_planeye :......... %i \n",fMax_planeye);
265 mocchiut 1.1 printf(" fCount :.............. %f \n",fCount);
266 mocchiut 1.3 printf(" fSel :.............. %i \n",fSel);
267     printf(" fPartsel:.............. %i \n",fPartsel);
268 mocchiut 1.1 printf(" fXesel :.............. %i \n",fXesel);
269     printf(" fXosel :.............. %i \n",fXosel);
270     printf(" fYesel :.............. %i \n",fYesel);
271     printf(" fYosel :.............. %i \n",fYosel);
272 mocchiut 1.3 printf(" fXemin :.............. %i \n",fXemin);
273     printf(" fXomin :.............. %i \n",fXomin);
274     printf(" fYemin :.............. %i \n",fYemin);
275     printf(" fYomin :.............. %i \n",fYomin);
276     printf(" fXeout :.............. %i \n",fXeout);
277     printf(" fXoout :.............. %i \n",fXoout);
278     printf(" fYeout :.............. %i \n",fYeout);
279     printf(" fYoout :.............. %i \n",fYoout);
280 mocchiut 1.1 printf(" fSimu :.............. %i \n",fSimu);
281     printf(" fM :.............. %f \n",fM);
282     printf(" fM1 :.............. %f \n",fM1);
283 mocchiut 1.2 printf(" fRad :.............. %i \n",fRad);
284     printf(" fPl :.............. %i \n",fPl);
285     printf(" fConv_rxe ............. %f \n",fConv_rxe);
286     printf(" fConv_rxo ............. %f \n",fConv_rxo);
287     printf(" fConv_ryo ............. %f \n",fConv_ryo);
288     printf(" fConv_rye ............. %f \n",fConv_rye);
289 mocchiut 1.1 printf(" fLong :.............. %i \n",fLong);
290     printf(" energyxe:.............. %f \n",energyxe);
291     printf(" energyxo:.............. %f \n",energyxo);
292     printf(" energyye:.............. %f \n",energyye);
293     printf(" energyyo:.............. %f \n",energyyo);
294     printf(" debug :.............. %i \n",debug);
295    
296     printf("========================================================================\n");
297     //
298     }
299    
300     void CaloEnergy::Delete(){
301     Clear();
302     }
303    
304    
305     Bool_t CaloEnergy::IsInsideAcceptance(TString section){
306     //
307     //
308     TString ntr = section;
309     if ( !L2 ){
310     printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n");
311     printf(" ERROR: CaloEnergy variables not filled \n");
312     return false;
313     };
314     //
315     Bool_t newentry = false;
316     //
317     if ( L2->IsORB() ){
318     if ( L2->GetOrbitalInfo()->pkt_num != APKT || L2->GetOrbitalInfo()->OBT != AOBT || L2->GetOrbitalInfo()->absTime != aatime || strcmp(ntr.Data(),asntr.Data()) ){
319     newentry = true;
320     AOBT = L2->GetOrbitalInfo()->OBT;
321     APKT = L2->GetOrbitalInfo()->pkt_num;
322     aatime = L2->GetOrbitalInfo()->absTime;
323     asntr = ntr;
324     };
325     } else {
326     newentry = true;
327     };
328     //
329     if ( !newentry ) return fSel;
330     //
331     if ( debug ) printf(" ########## IsInsideAcceptance ######### \n");
332     //
333 mocchiut 1.3 this->Clear();
334     //
335 mocchiut 1.1 section.ToUpper();
336     //
337     Int_t ss = Int_t(section.Contains("XO"))+Int_t(section.Contains("XE"))+Int_t(section.Contains("YO"))+Int_t(section.Contains("YE"));
338     if ( !ss ){
339     printf(" ERROR: section must be XO or XE or YO or YE while it is %s \n",section.Data());
340 mocchiut 1.3 return false;
341     };
342     //
343     //
344     for (Int_t ch=0; ch< L2->GetCaloLevel1()->istrip; ch++){
345     en = L2->GetCaloLevel1()->DecodeEstrip(ch,view,plane,strip);
346     enstrip[view][plane][strip]=en;
347     };
348     for (Int_t i=0;i<11;i++){
349     for(strip=0; strip<96; strip++) {
350     if ( fRad < 0 ){
351     en_xep[i] += enstrip[1][2*i][strip];
352     en_yop[i] += enstrip[0][2*i][strip];
353     en_xop[i] += enstrip[1][2*i+1][strip];
354     en_yep[i] += enstrip[0][2*i+1][strip];
355     } else {
356     if ( strip >= L2->GetCaloLevel2()->cibar[2*i][1]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i][1]-1+fRad ) en_xep[i] += enstrip[1][2*i][strip];
357     if ( strip >= L2->GetCaloLevel2()->cibar[2*i][0]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i][0]-1+fRad ) en_yop[i] += enstrip[0][2*i][strip];
358     if ( strip >= L2->GetCaloLevel2()->cibar[2*i+1][1]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i+1][1]-1+fRad ) en_xop[i] += enstrip[1][2*i+1][strip];
359     if ( strip >= L2->GetCaloLevel2()->cibar[2*i+1][0]-1-fRad && strip <= L2->GetCaloLevel2()->cibar[2*i+1][0]-1+fRad ) en_yep[i] += enstrip[0][2*i+1][strip];
360     };
361     };
362     energyxe += en_xep[i];
363     energyyo += en_yop[i];
364     energyxo += en_xop[i];
365     energyye += en_yep[i];
366     };
367     Float_t en_maxplane = 0.;
368     Float_t max_en= 0.;
369     //
370     for (Int_t ipl =0; ipl < 11; ipl ++) {
371     if(en_xop[ipl] > max_en) {
372     max_en = en_xop[ipl];
373     fMax_planexo = ipl;
374     };
375     };
376     //
377     max_en = 0.;
378     for (Int_t ipl =0; ipl < 11; ipl ++) {
379     if(en_xep[ipl] > max_en) {
380     max_en = en_xep[ipl];
381     fMax_planexe = ipl;
382     };
383     };
384     //
385     max_en = 0.;
386     for (Int_t ipl =0; ipl < 11; ipl ++) {
387     if(en_yop[ipl] > max_en) {
388     max_en = en_yop[ipl];
389     fMax_planeyo = ipl;
390     };
391     };
392     //
393     max_en = 0.;
394     for (Int_t ipl =0; ipl < 11; ipl ++) {
395     if(en_yep[ipl] > max_en) {
396     max_en = en_yep[ipl];
397     fMax_planeye = ipl;
398     };
399 mocchiut 1.1 };
400     //
401     Float_t track_coordx[22][2];
402     Float_t track_coordy[22][2];
403     //
404     Float_t tgx_cl2;
405     Float_t tgy_cl2;
406     tgx_cl2 = L2->GetCaloLevel2()->tanx[0];
407     tgy_cl2 = L2->GetCaloLevel2()->tany[0];
408     //
409     for (Int_t p=0; p<22; p++){
410     track_coordy[p][1] = L2->GetCaloLevel2()->cbar[p][1];
411     track_coordx[p][1] = L2->GetCaloLevel2()->cbar[p][0] - fabs(trk_z[p][1]-trk_z[p][0])*tgx_cl2;
412     track_coordx[p][0] = L2->GetCaloLevel2()->cbar[p][0];
413     track_coordy[p][0] = L2->GetCaloLevel2()->cbar[p][1] - fabs(trk_z[p][1]-trk_z[p][0])*tgy_cl2;
414     if ( debug ) printf(" p %i track_coordy[p][1] %f track_coordx[p][1] %f track_coordx[p][0] %f track_coordy[p][0] %f \n",p,track_coordy[p][1],track_coordx[p][1],track_coordx[p][0],track_coordy[p][0]);
415     };
416     //
417 mocchiut 1.3 if ( debug ) printf(" acceptance ss %i tgx %f tgy %f\n",ss,tgx_cl2,tgy_cl2);
418 mocchiut 1.1 //
419     if ( section.Contains("XO") ){
420     for (Int_t i=0; i<11; i++) {
421     if
422     (
423     (((track_coordx[2*i+1][1]>=(-12.054+fM))&&
424     (track_coordx[2*i+1][1]<=(-4.246-fM)))&&
425     (((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&&
426     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1 ))||
427     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&&
428     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1 ))||
429     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&&
430     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 ))))||
431    
432     (((track_coordx[2*i+1][1]>=(-4.004+fM))&&
433     (track_coordx[2*i+1][1]<=(3.804-fM)))&&
434     (((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&&
435     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1 ))||
436     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&&
437     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1))||
438     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&&
439     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 ))))||
440    
441     (((track_coordx[2*i+1][1]>=(4.046+fM))&&
442     (track_coordx[2*i+1][1]<=(11.854-fM)))&&
443     (((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo1 + fM1)&&
444     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo2 - fM1))||
445     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo3 + fM1)&&
446     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo4 - fM1 ))||
447     ((L2->GetCaloLevel2()->cbar[2*i+1][1]>=xo5 + fM1)&&
448     (L2->GetCaloLevel2()->cbar[2*i+1][1]<=xo6 - fM1 ))))
449     ){
450     fXosel = true;
451 mocchiut 1.3 fXoout = i;
452 mocchiut 1.1 } else {
453     fXosel = false;
454     break;
455     };
456     };
457 mocchiut 1.3 if ( !fXosel && fXoout >= fXomin && fXoout >= (Int_t)(fMax_planexo+fPl) ){
458     if ( debug ) printf(" XO: this event is only partially contained: fXoout %i fXomin %i fMax_planexo + fPl %i \n",fXoout,fXomin,(Int_t)(fMax_planexo+fPl));
459     fPartsel = true;
460     fXosel = true;
461     };
462     if ( fXosel ){
463     en_maxplane = 0.;
464     for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexo+fPl)) ;iplm++) en_maxplane += en_xop[iplm];
465     fEnergyxo = en_maxplane/fConv_rxo;
466     };
467 mocchiut 1.1 };
468     //
469     if ( section.Contains("XE") ){
470     for (Int_t i=0; i<11; i++) {
471     if
472     (
473     (((track_coordx[2*i][1]>=(-11.854+fM))&&
474     (track_coordx[2*i][1]<=(-4.046-fM)))&&
475     (((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&&
476     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1 ))||
477     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&&
478     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1 ))||
479     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&&
480     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 ))))||
481    
482     (((track_coordx[2*i][1]>=(-3.804+fM))&&
483     (track_coordx[2*i][1]<=(4.004-fM)))&&
484     (((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&&
485     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1 ))||
486     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&&
487     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1))||
488     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&&
489     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 ))))||
490    
491     (((track_coordx[2*i][1]>=(4.246+fM))&&
492     (track_coordx[2*i][1]<=(12.054-fM)))&&
493     (((L2->GetCaloLevel2()->cbar[2*i][1]>=xe1 + fM1)&&
494     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe2 - fM1))||
495     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe3 + fM1)&&
496     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe4 - fM1 ))||
497     ((L2->GetCaloLevel2()->cbar[2*i][1]>=xe5 + fM1)&&
498     (L2->GetCaloLevel2()->cbar[2*i][1]<=xe6 - fM1 ))))
499     ){
500     fXesel = true;
501 mocchiut 1.3 fXeout = i;
502 mocchiut 1.1 } else {
503     fXesel = false;
504     break;
505     };
506     };
507 mocchiut 1.3 if ( !fXesel && fXeout >= fXemin && fXeout >= (Int_t)(fMax_planexe+fPl) ){
508     if ( debug ) printf(" XE: this event is only partially contained: fXeout %i fXemin %i fMax_planexe + fPl %i \n",fXeout,fXemin,(Int_t)(fMax_planexe+fPl));
509     fPartsel = true;
510     fXesel = true;
511     };
512     if ( fXesel ){
513     en_maxplane = 0.;
514     for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planexe+fPl)) ;iplm++) en_maxplane += en_xep[iplm];
515     fEnergyxe = en_maxplane/fConv_rxe;
516     };
517 mocchiut 1.1 };
518     //
519     if ( section.Contains("YE") ){
520     for (Int_t i=0; i<11; i++) {
521     if
522     (
523     (((track_coordy[2*i+1][0]>=(-12.154+fM))&&
524     (track_coordy[2*i+1][0]<=(-4.346-fM)))&&
525     (((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&&
526     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1 ))||
527     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&&
528     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1 ))||
529     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&&
530     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 ))))||
531    
532     (((track_coordy[2*i+1][0]>=(-4.104+fM))&&
533     (track_coordy[2*i+1][0]<=(3.704-fM)))&&
534     (((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&&
535     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1 ))||
536     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&&
537     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1))||
538     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&&
539     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 ))))||
540    
541     (((track_coordy[2*i+1][0]>=(3.946+fM))&&
542     (track_coordy[2*i+1][0]<=(11.754-fM)))&&
543     (((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye1 + fM1)&&
544     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye2 - fM1))||
545     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye3 + fM1)&&
546     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye4 - fM1 ))||
547     ((L2->GetCaloLevel2()->cbar[2*i+1][0]>=ye5 + fM1)&&
548     (L2->GetCaloLevel2()->cbar[2*i+1][0]<=ye6 - fM1 ))))
549     ){
550     fYesel = true;
551 mocchiut 1.3 fYeout = i;
552 mocchiut 1.1 } else {
553     fYesel = false;
554     break;
555     };
556     };
557 mocchiut 1.3 if ( !fYesel && fYeout >= fYemin && fYeout >= (Int_t)(fMax_planeye+fPl) ){
558     if ( debug ) printf(" YE: this event is only partially contained: fYeout %i fYemin %i fMax_planeye + fPl %i \n",fYeout,fYemin,(Int_t)(fMax_planeye+fPl));
559     fPartsel = true;
560     fYesel = true;
561     };
562     if ( fYesel ){
563     en_maxplane = 0.;
564     for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeye+fPl)) ;iplm++) en_maxplane += en_yep[iplm];
565     fEnergyye = en_maxplane/fConv_rye;
566     };
567 mocchiut 1.1 };
568     //
569     if ( section.Contains("YO") ){
570     for (Int_t i=0; i<11; i++) {
571     if ( debug ) printf(" i %i track_coordy[2*i][0] %f L2->GetCaloLevel2()->cbar[2*i][0] %f \n",i,track_coordy[2*i][0],L2->GetCaloLevel2()->cbar[2*i][0]);
572     if ( debug ) printf(" i %i fm %f fm1 %f yo1 %g yo2 %f yo3 %f yo4 %f yo5 %f yo6 %f \n",i,fM,fM1,yo1,yo2,yo3,yo4,yo5,yo6);
573     if
574     (
575     (((track_coordy[2*i][0]>=(-11.954+fM))&&
576     (track_coordy[2*i][0]<=(-4.146-fM)))&&
577     (((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&&
578     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1 ))||
579     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&&
580     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1 ))||
581     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&&
582     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 ))))||
583    
584     (((track_coordy[2*i][0]>=(-3.904+fM))&&
585     (track_coordy[2*i][0]<=(+3.904-fM)))&&
586     (((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&&
587     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1 ))||
588     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&&
589     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1))||
590     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&&
591     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 ))))||
592    
593     (((track_coordy[2*i][0]>=(4.146+fM))&&
594     (track_coordy[2*i][0]<=(11.954-fM)))&&
595     (((L2->GetCaloLevel2()->cbar[2*i][0]>=yo1 + fM1)&&
596     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo2 - fM1))||
597     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo3 + fM1)&&
598     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo4 - fM1 ))||
599     ((L2->GetCaloLevel2()->cbar[2*i][0]>=yo5 + fM1)&&
600     (L2->GetCaloLevel2()->cbar[2*i][0]<=yo6 - fM1 ))))
601     ){
602     fYosel = true;
603 mocchiut 1.3 fYoout = i;
604 mocchiut 1.1 } else {
605     fYosel = false;
606     break;
607     };
608     };
609 mocchiut 1.3 if ( !fYosel && fYoout >= fYomin && fYoout >= (Int_t)(fMax_planeyo+fPl) ){
610     if ( debug ) printf(" YO: this event is only partially contained: fYoout %i fYomin %i fMax_planeyo + fPl %i \n",fYoout,fYomin,(Int_t)(fMax_planeyo+fPl));
611     fPartsel = true;
612     fYosel = true;
613     };
614     if ( fYosel ){
615     en_maxplane = 0.;
616     for (Int_t iplm=0;iplm<=TMath::Min(10,(Int_t)(fMax_planeyo+fPl)) ;iplm++) en_maxplane += en_yop[iplm];
617     fEnergyyo = en_maxplane/fConv_ryo;
618     };
619 mocchiut 1.1 };
620     //
621     fSel = ( fXesel || fYesel || fXosel || fYosel );
622     fCount = (Float_t)((Int_t)fXesel+(Int_t)fXosel+(Int_t)fYesel+(Int_t)fYosel);
623     if ( debug ) printf(" IsInside XE %i XO %i YE %i YO %i => SEL %i \n",fXesel,fXosel,fYesel,fYosel,fSel);
624 mocchiut 1.3 fMax_plane = (Float_t)(fMax_planeyo+fMax_planeye+fMax_planexo+fMax_planexe)/fCount;
625     fEnergy = (fEnergyxe+fEnergyyo+fEnergyye+fEnergyxo)/fCount;
626     if ( debug ) printf(" fMax_plane %f conv_r %f en_maxplane %f encalo %f \n",fMax_plane,fConv_rxo,en_maxplane,fEnergy);
627 mocchiut 1.1 //
628     return fSel;
629     //
630     }
631    
632     void CaloEnergy::Process(){
633     TString xo = "XO";
634     this->Process(xo);
635     }
636    
637    
638     void CaloEnergy::Process(TString section){
639     //
640     TString ntr = section;
641     if ( !L2 ){
642     printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n");
643     printf(" ERROR: CaloEnergy variables not filled \n");
644     return;
645     };
646     //
647     Bool_t newentry = false;
648     //
649     if ( L2->IsORB() ){
650     if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || strcmp(ntr.Data(),sntr.Data()) ){
651     newentry = true;
652     OBT = L2->GetOrbitalInfo()->OBT;
653     PKT = L2->GetOrbitalInfo()->pkt_num;
654     atime = L2->GetOrbitalInfo()->absTime;
655     sntr = ntr;
656     };
657     } else {
658     newentry = true;
659     };
660     //
661     if ( !newentry ) return;
662     //
663     if ( debug ) printf(" Processing event at OBT %u PKT %u time %u section %s\n",OBT,PKT,atime,section.Data());
664     //
665 mocchiut 1.3 // this->Clear();
666 mocchiut 1.1 //
667 mocchiut 1.2 if ( (fM1+0.122-0.244*(Float_t)fRad) < 0. ) printf("Error: (fM1+0.122-0.244*(Float_t)fRad) < 0. fM1 %f fRad %i %f \n",fM1,fRad,(fM1+0.122-0.244*(Float_t)fRad));
668     //
669 mocchiut 1.1 if ( fLong ){
670     // use long fit to measure energy
671     } else {
672     //
673     if ( this->IsInsideAcceptance(section) ){
674     //
675     if ( debug ) printf(" XE %i XO %i YE %i YO %i \n",fXesel,fXosel,fYesel,fYosel);
676     //
677     } else {
678     if ( debug ) printf(" Outside acceptance \n");
679     fEnergy = -1.;
680     };
681     };
682     //
683     }

  ViewVC Help
Powered by ViewVC 1.1.23