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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (hide annotations) (download)
Mon Dec 14 14:42:53 2009 UTC (15 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.18: +12 -0 lines
Do not use plane 18x by default

1 mocchiut 1.1 #include <CaloNuclei.h>
2 malvezzi 1.14 #include <TGraph.h>
3     #include <TSpline.h>
4     #include <TMVA/TSpline1.h>
5 mocchiut 1.1
6     //--------------------------------------
7     /**
8     * Default constructor
9     */
10     CaloNuclei::CaloNuclei(){
11     Clear();
12     };
13    
14     CaloNuclei::CaloNuclei(PamLevel2 *l2p){
15     //
16     Clear();
17     //
18     L2 = l2p;
19     //
20     if ( !L2->IsORB() ) printf(" WARNING: OrbitalInfo Tree is needed, the plugin could not work properly without it \n");
21     //
22     OBT = 0;
23     PKT = 0;
24     atime = 0;
25     N = 5;
26 mocchiut 1.2 R = 3;
27 mocchiut 1.1 //
28 mocchiut 1.4 debug = false;
29 malvezzi 1.14 // debug = true;
30 mocchiut 1.5 usetrack = true;
31 mocchiut 1.19 usepl18x = false;
32 mocchiut 1.4 //
33 mocchiut 1.1 };
34    
35     void CaloNuclei::Clear(){
36     //
37 mocchiut 1.11 UN = 0;
38 mocchiut 1.3 tr = 0;
39 mocchiut 1.5 sntr = 0;
40 mocchiut 1.1 interplane = 0;
41     preq = 0.;
42     postq = 0.;
43 mocchiut 1.10 stdedx1 = 0.;
44     ethr = 0.;
45 mocchiut 1.1 dedx1 = 0.;
46     dedx3 = 0.;
47     qpremean = 0.;
48     qpremeanN = 0.;
49 malvezzi 1.14 maxrel = 0;
50     qNmin1 = 0;
51     qNmin1_w = 0;
52     charge_siegen1 = 0;
53     ZCalo_maxrel_b = 0;
54     ZCalo_dedx_b = 0;
55     ZCalo_dedx_defl= 0;
56     ZCalo_Nmin1_defl= 0;
57 mocchiut 1.1 //
58     multhit = false;
59     gap = false;
60     //
61     };
62    
63     void CaloNuclei::Print(){
64     //
65 mocchiut 1.2 Process();
66     //
67 mocchiut 1.3 printf("========================================================================\n");
68 mocchiut 1.5 printf(" OBT: %u PKT: %u ATIME: %u Track %i Use track %i \n",OBT,PKT,atime,tr,usetrack);
69 malvezzi 1.14 printf(" interplane [number of available dE/dx before interaction]:....... %i\n",interplane);
70     printf(" ethr [threshold used to determine interplane]:................... %f \n",ethr);
71     printf(" dedx1 [dE/dx from the first calorimeter plane]:.................. %f \n",dedx1);
72     printf(" stdedx1 [dE/dx from the first calorimeter plane standalone]:..... %f \n",stdedx1);
73     printf(" dedx3 [dE/dx (average) if the first 3 Si planes]:................ %f \n",dedx3);
74     printf(" multhit [true if interplane determined by multiple hits]:........ %i \n",multhit);
75     printf(" gap [true if interplane determined by a gap]:.................... %i \n",gap);
76     printf(" preq [total energy in MIP before the interaction plane]:......... %f \n",preq);
77     printf(" postq [total energy in MIP after the interaction plane]:......... %f \n",postq);
78     printf(" qpremean [truncated mean using 3 planes and 3 strips]:........... %f \n",qpremean);
79     printf(" N [no of used plane]:............................................ %i \n",N);
80     printf(" R [no strip used per plane ]:.................................... %i \n",R);
81     printf(" qpremeanN [truncated mean using N planes and R strips]:.......... %f \n",qpremeanN);
82     printf(" qNmin1 [truncated mean using N-1 planes and R strips]: .......... %f \n",qNmin1);
83     printf(" maxrel [dE/dx of strip with maximum release (I plane)]:.......... %f \n",maxrel);
84     printf(" ZCalo_maxrel_b [Z from maximum release in I Calo plane vs beta].. %f \n",ZCalo_maxrel_b);
85     printf(" ZCalo_dedx_b [Z from dedx in I Calo plane vs beta].. ............ %f \n",ZCalo_dedx_b);
86     printf(" ZCalo_dedx_defl [Z from dedx in I Calo plane vs deflection....... %f \n",ZCalo_dedx_defl);
87     printf(" ZCalo_Nmin1_defl [Z from truncated mean (N-1 pl) vs deflection].. %f \n",ZCalo_Nmin1_defl);
88 mocchiut 1.3 printf("========================================================================\n");
89 mocchiut 1.1 //
90     };
91    
92     void CaloNuclei::Delete(){
93     Clear();
94     //delete this;
95     };
96    
97    
98     void CaloNuclei::Process(){
99 mocchiut 1.3 Process(0);
100     };
101    
102     void CaloNuclei::Process(Int_t ntr){
103     //
104 mocchiut 1.1 if ( !L2 ){
105     printf(" ERROR: cannot find PamLevel2 object, use the correct constructor or check your program!\n");
106     printf(" ERROR: CaloNuclei variables not filled \n");
107     return;
108     };
109     //
110     Bool_t newentry = false;
111     //
112     if ( L2->IsORB() ){
113 mocchiut 1.5 if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr ){
114 mocchiut 1.1 newentry = true;
115     OBT = L2->GetOrbitalInfo()->OBT;
116     PKT = L2->GetOrbitalInfo()->pkt_num;
117     atime = L2->GetOrbitalInfo()->absTime;
118 mocchiut 1.5 sntr = ntr;
119 mocchiut 1.1 };
120     } else {
121     newentry = true;
122     };
123     //
124     if ( !newentry ) return;
125     //
126 mocchiut 1.3 tr = ntr;
127     //
128 mocchiut 1.4 if ( debug ) printf(" Processing event at OBT %u PKT %u time %u \n",OBT,PKT,atime);
129 mocchiut 1.1 //
130     Clear();
131 mocchiut 1.11 //
132 mocchiut 1.6 if ( debug ) printf(" Always calculate stdedx1 \n");
133 mocchiut 1.1 //
134 malvezzi 1.14 // Always calculate stdedx1 and maxrel
135 mocchiut 1.1 //
136 malvezzi 1.14 Int_t cont=0;
137 mocchiut 1.1 Int_t view = 0;
138     Int_t plane = 0;
139     Int_t strip = 0;
140 mocchiut 1.5 Int_t indx = 0;
141     Float_t vfpl[96];
142     Int_t stfpl[96];
143     memset(vfpl, 0, 96*sizeof(Float_t));
144     memset(stfpl, 0, 96*sizeof(Int_t));
145 mocchiut 1.1 Float_t mip = 0.;
146 mocchiut 1.5 for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){
147     //
148     mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
149     //
150 mocchiut 1.19 if ( !usepl18x && view==0 && plane==18 ) mip = 0.;
151     //
152     //
153 mocchiut 1.5 // put in vfpl vector the energy release on the first plane
154     //
155     if ( strip != -1 && view == 1 && plane == 0 ) {
156     stfpl[indx] = strip;
157     vfpl[indx] = mip;
158     indx++;
159     };
160     //
161     };
162     //
163 mocchiut 1.6 if ( debug ) printf(" find energy released along the strip of maximum on the first plane and on the two neighbour strips \n");
164     //
165 mocchiut 1.5 // find energy released along the strip of maximum on the first plane and on the two neighbour strips
166     //
167     if ( indx > 0 ){
168 mocchiut 1.12 Int_t mindx = (Int_t)TMath::LocMax(indx,vfpl);
169 mocchiut 1.5 for (Int_t ii=0; ii<indx; ii++){
170     if ( stfpl[ii] == stfpl[mindx] ) stdedx1 += vfpl[ii];
171 mocchiut 1.13 if ( (mindx-1)>=0 && stfpl[ii] == (stfpl[mindx]-1) ) stdedx1 += vfpl[ii];
172     if ( (mindx+1)<96 && stfpl[ii] == (stfpl[mindx]+1) ) stdedx1 += vfpl[ii];
173     // if ( (mindx-1)>=0 && stfpl[ii] == stfpl[mindx-1] ) stdedx1 += vfpl[ii];
174     // if ( (mindx+1)<96 && stfpl[ii] == stfpl[mindx+1] ) stdedx1 += vfpl[ii];
175 mocchiut 1.5 };
176 malvezzi 1.14 maxrel = vfpl[mindx];
177 mocchiut 1.5 } else {
178     stdedx1 = 0.;
179 malvezzi 1.14 maxrel = 0.;
180 mocchiut 1.5 };
181 malvezzi 1.14 // cout<<stdedx1<<" "<<maxrel<<"\n";
182 mocchiut 1.5 //
183 mocchiut 1.6 if ( debug ) printf(" if ( !usetrack ) return: usetrack %i ntr %i \n",usetrack,ntr);
184 mocchiut 1.5 //
185     //
186 mocchiut 1.8 // if ( !usetrack ) return;
187 mocchiut 1.5 //
188     PamTrack *ptrack = 0;
189     CaloTrkVar *track = 0;
190 mocchiut 1.8 //
191     if ( usetrack ){
192     if ( ntr >= 0 ){
193     ptrack = L2->GetTrack(ntr);
194     if ( ptrack ) track = ptrack->GetCaloTrack();
195     } else {
196     track = L2->GetCaloStoredTrack(ntr);
197     };
198     //
199     if ( !track && ntr >= 0 ){
200     printf(" ERROR: cannot find any track!\n");
201     printf(" ERROR: CaloNuclei variables not completely filled \n");
202     return;
203     };
204 mocchiut 1.5 } else {
205 mocchiut 1.8 if ( ntr >= 0 ){
206 mocchiut 1.9 if ( debug ) printf(" ERROR: you asked not to use a track but you are looking for track number %i !\n",ntr);
207     if ( debug ) printf(" ERROR: CaloNuclei variables not completely filled \n");
208 mocchiut 1.8 return;
209     };
210 mocchiut 1.5 };
211     //
212 mocchiut 1.1 // Float_t defethr = 6. * 0.90;
213     Float_t defethr = 6.25; // = (sqrt(9) - 0.5) ** 2.;
214     //
215     // Calculate dedx1 and dedx3
216     //
217     for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){
218     //
219     mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
220     //
221 mocchiut 1.19 if ( !usepl18x && view==0 && plane==18 ) mip = 0.;
222     //
223 mocchiut 1.5 if ( ntr >= 0 ){
224     //
225     if ( strip != -1 &&
226     view == 1 &&
227     plane == 0 &&
228     ( strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) || strip == (track->tibar[0][1]) )
229     && true ){
230     dedx1 += mip;
231     };
232     if ( strip != -1 &&
233     (( view == 1 && ( plane == 0 || plane == 1 ) ) ||
234     ( view == 0 && plane == 0 )) &&
235     (( view == 0 && ( strip == track->tibar[0][0] || strip == (track->tibar[0][0]-1) || strip == (track->tibar[0][0]-2) )) ||
236     ( view == 1 && ( strip == track->tibar[0][1] || strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) )) ||
237     ( view == 1 && ( strip == track->tibar[1][1] || strip == (track->tibar[1][1]-1) || strip == (track->tibar[1][1]-2) ))) &&
238     true ){
239     dedx3 += mip;
240     };
241     } else {
242     //
243     if ( strip != -1 &&
244     view == 1 &&
245     plane == 0 &&
246     ( strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) || strip == (L2->GetCaloLevel2()->cibar[0][1]) )
247     && true ){
248     dedx1 += mip;
249     };
250     if ( strip != -1 &&
251     (( view == 1 && ( plane == 0 || plane == 1 ) ) ||
252     ( view == 0 && plane == 0 )) &&
253     (( view == 0 && ( strip == L2->GetCaloLevel2()->cibar[0][0] || strip == (L2->GetCaloLevel2()->cibar[0][0]-1) || strip == (L2->GetCaloLevel2()->cibar[0][0]-2) )) ||
254     ( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[0][1] || strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) )) ||
255     ( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[1][1] || strip == (L2->GetCaloLevel2()->cibar[1][1]-1) || strip == (L2->GetCaloLevel2()->cibar[1][1]-2) ))) &&
256     true ){
257     dedx3 += mip;
258     };
259 mocchiut 1.1 };
260     //
261     };
262     //
263     dedx3 /= 3.;
264     // Float_t mesethr = dedx1 * 0.90;
265     Float_t mesethr = 0.;
266     if ( dedx1 > 0. ) mesethr = (sqrt(dedx1) - 0.50)*(sqrt(dedx1) - 0.50);
267     Bool_t aldone = false;
268     //
269     retry:
270     //
271 mocchiut 1.4 if ( debug ) printf("retry\n");
272 mocchiut 1.1 //
273     interplane = 0;
274     //
275     ethr = TMath::Max(defethr,mesethr);
276     //
277     // Find the interaction plane "interplane"
278     //
279     Int_t gapth = 3;
280     Int_t nhit[2] = {0,0};
281     Int_t splane[2] = {-1,-1};
282     Int_t sview[2] = {-1,-1};
283     Int_t interpl[2] = {-1,-1};
284     Int_t interv[2] = {-1,-1};
285     Bool_t wmulthit[2] = {false,false};
286     Bool_t wgap[2] = {false,false};
287     Int_t ii = 0;
288     while ( ii<L2->GetCaloLevel1()->istrip ){
289     //
290     mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip);
291     //
292 mocchiut 1.19 if ( !usepl18x && view==0 && plane==18 ) mip = 0.;
293     //
294     //
295 mocchiut 1.5 if ( ntr >= 0 ){
296     if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] &&
297     ( strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) )
298     && true ){
299     if ( debug ) printf(" inside loop: ii %i mip %f view %i plane %i strip %i tibar %i nhit %i splane %i sview %i \n",ii,mip,view,plane,strip,track->tibar[plane][view]-1,nhit[view],splane[view],sview[view]);
300     interpl[view] = plane;
301     interv[view] = view;
302     if ( splane[view] != plane || sview[view] != view ){
303     if ( nhit[view] > 1 ){
304     wmulthit[view] = true;
305     // if ( splane[view] == -1 ) splane[view] = 0; //
306     // if ( sview[view] == -1 ) sview[view] = view; //
307     interpl[view] = splane[view];
308     interv[view] = sview[view];
309     };
310     if ( plane > splane[view]+gapth ){
311     wgap[view] = true;
312     // if ( splane[view] == -1 ) splane[view] = 0;//
313     // if ( sview[view] == -1 ) sview[view] = view; //
314     interpl[view] = splane[view];
315     interv[view] = sview[view];
316     };
317     splane[view] = plane;
318     sview[view] = view;
319     nhit[view] = 1;
320     } else {
321     nhit[view]++;
322     };
323     };
324     } else {
325     if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] &&
326     ( strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) )
327     && true ){
328     if ( debug ) printf(" inside loop: ii %i mip %f view %i plane %i strip %i cibar %i nhit %i splane %i sview %i \n",ii,mip,view,plane,strip,L2->GetCaloLevel2()->cibar[plane][view]-1,nhit[view],splane[view],sview[view]);
329     interpl[view] = plane;
330     interv[view] = view;
331     if ( splane[view] != plane || sview[view] != view ){
332     if ( nhit[view] > 1 ){
333     wmulthit[view] = true;
334     // if ( splane[view] == -1 ) splane[view] = 0; //
335     // if ( sview[view] == -1 ) sview[view] = view; //
336     interpl[view] = splane[view];
337     interv[view] = sview[view];
338 mocchiut 1.1 };
339 mocchiut 1.5 if ( plane > splane[view]+gapth ){
340     wgap[view] = true;
341     // if ( splane[view] == -1 ) splane[view] = 0;//
342     // if ( sview[view] == -1 ) sview[view] = view; //
343     interpl[view] = splane[view];
344     interv[view] = sview[view];
345     };
346     splane[view] = plane;
347     sview[view] = view;
348     nhit[view] = 1;
349     } else {
350     nhit[view]++;
351 mocchiut 1.1 };
352     };
353     };
354     //
355     ii++;
356     //
357     };
358     //
359 mocchiut 1.4 if (debug ) printf("conversion interpl %i interv %i multhit %i interplane %i \n",interpl[0],interv[0],multhit,interplane);
360 mocchiut 1.1 Int_t winterplane[2] = {-1,-1};
361     //
362     for ( Int_t view = 0; view < 2; view++){
363     //
364     if ( nhit[view] > 1 && !wmulthit[view] && !wgap[view] ){
365     wmulthit[view] = true;
366     interpl[view] = splane[view];
367     interv[view] = sview[view];
368     };
369     //
370     if ( wmulthit[view] ) multhit = true;
371     if ( wgap[view] ) gap = true;
372     //
373     // convert view and plane number of interaction plane into number of available dE/dx measurements before the interaction plane
374     //
375     if ( interpl[view] >= 0 ) {
376     if ( interv[view] == 0 ){
377     winterplane[view] = (1 + interpl[view]) * 2;
378     } else {
379     winterplane[view] = (1 + interpl[view]) + (1 + interpl[view] - 1);
380     };
381     if ( wmulthit[view] ) winterplane[view]--;
382     };
383     };
384     if ( winterplane[0] > 0 && winterplane[1] > 0 ){
385     if ( multhit ){
386     interplane = TMath::Min(winterplane[0],winterplane[1]);
387     } else {
388     interplane = TMath::Max(winterplane[0],winterplane[1]);
389     };
390     } else {
391     if ( !winterplane[0] || !winterplane[1] ){
392     interplane = 0;
393     } else {
394     interplane = TMath::Max(winterplane[0],winterplane[1]);
395     };
396     };
397     //
398 mocchiut 1.4 if ( debug ) printf("2conversion interpl %i interv %i multhit %i interplane %i \n",interpl[1],interv[1],multhit,interplane);
399     if ( debug ) printf("3conversion winterpl0 %i winterpl1 %i \n",winterplane[0],winterplane[1]);
400 mocchiut 1.1 //
401     Int_t ipl = 0;
402     if ( interplane > 0 ){
403     //
404     // Calculate preq, postq, qpremean
405     //
406 malvezzi 1.14 cont++;
407 mocchiut 1.1 ii = 0;
408     Int_t ind = -1;
409     Int_t qsplane = -1;
410     Int_t qsview = -1;
411 mocchiut 1.2 Int_t ind2 = -1;
412     Int_t qsplane2 = -1;
413     Int_t qsview2 = -1;
414 mocchiut 1.1 Float_t qme[200];
415     memset(qme,0,200*sizeof(Float_t));
416 mocchiut 1.2 Float_t qme2[2112];
417     memset(qme2,0,2112*sizeof(Float_t));
418 mocchiut 1.1 //
419     while ( ii<L2->GetCaloLevel1()->istrip ){
420     //
421     mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip);
422     //
423 mocchiut 1.19 if ( !usepl18x && view==0 && plane==18 ) mip = 0.;
424     //
425     //
426 mocchiut 1.1 if ( strip != -1 ){
427     if ( view == 0 ){
428     ipl = (1 + plane) * 2;
429     } else {
430     ipl = (1 + plane) + (1 + plane - 1 );
431     };
432     if ( ipl > interplane ){
433     postq += mip;
434     } else {
435     preq += mip;
436 mocchiut 1.5 if ( ntr >= 0 ){
437     if ( strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) ){
438     if ( qsplane != plane || qsview != view ){
439     qsplane = plane;
440     qsview = view;
441     ind++;
442     if ( debug && ind > 199 ) printf(" AAAGH!! \n");
443     qme[ind] = 0.;
444     };
445     qme[ind] += mip;
446 mocchiut 1.1 };
447 mocchiut 1.5 for ( Int_t ns = 0; ns < R ; ns++){
448     Int_t ms = track->tibar[plane][view] - 1 - ns + (R - 1)/2;
449     if ( strip == ms ){
450     if ( qsplane2 != plane || qsview2 != view ){
451     qsplane2 = plane;
452     qsview2 = view;
453     ind2++;
454     if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n");
455     qme2[ind2] = 0.;
456     };
457     qme2[ind2] += mip;
458     };
459     };
460     } else {
461     if ( strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) ){
462     if ( qsplane != plane || qsview != view ){
463     qsplane = plane;
464     qsview = view;
465     ind++;
466     if ( debug && ind > 199 ) printf(" AAAGH!! \n");
467     qme[ind] = 0.;
468 mocchiut 1.2 };
469 mocchiut 1.5 qme[ind] += mip;
470 mocchiut 1.2 };
471 mocchiut 1.5 for ( Int_t ns = 0; ns < R ; ns++){
472     Int_t ms = L2->GetCaloLevel2()->cibar[plane][view] - 1 - ns + (R - 1)/2;
473     if ( strip == ms ){
474     if ( qsplane2 != plane || qsview2 != view ){
475     qsplane2 = plane;
476     qsview2 = view;
477     ind2++;
478     if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n");
479     qme2[ind2] = 0.;
480     };
481     qme2[ind2] += mip;
482     };
483     };
484     };
485 mocchiut 1.1 };
486     //
487     };
488     //
489     ii++;
490     //
491     };
492 malvezzi 1.14
493    
494     //
495 mocchiut 1.1 // here we must calculate qpremean, order vector qme, select 3 lowest measurements and caculate the mean...
496     //
497 mocchiut 1.4 if ( debug ){
498     for (Int_t l=0; l < interplane; l++){
499     printf(" qme[%i] = %f \n",l,qme[l]);
500     };
501     };
502     //
503 mocchiut 1.1 Long64_t work[200];
504     ind = 0;
505     Int_t l = 0;
506 mocchiut 1.5 Int_t RN = 0;
507 mocchiut 1.1 Float_t qm = 0.;
508 mocchiut 1.2 Float_t qm2 = 0.;
509     //
510     Float_t qmt = ethr*0.8; // *0.9
511     //
512 mocchiut 1.1 Int_t uplim = TMath::Max(3,N);
513 malvezzi 1.14 Int_t uplim2 = interplane-1;
514 mocchiut 1.2 //
515 mocchiut 1.1 while ( l < uplim && ind < interplane ){
516 mocchiut 1.18 qm = TMath::KOrdStat((Long64_t)interplane,qme,(Long64_t)ind,work);
517 mocchiut 1.2 if ( qm >= qmt ){
518 mocchiut 1.5 if ( l < 3 ){
519     qpremean += qm;
520     RN++;
521     };
522 mocchiut 1.1 l++;
523 mocchiut 1.4 if ( debug ) printf(" value no %i qm %f qmt %f \n",l,qm,qmt);
524 mocchiut 1.2 };
525     ind++;
526     };
527     //
528 mocchiut 1.5 qpremean /= (Float_t)RN;
529 mocchiut 1.2 ind = 0;
530     l = 0;
531 mocchiut 1.5 RN = 0;
532 mocchiut 1.2 while ( l < uplim && ind < interplane ){
533 mocchiut 1.18 qm2 = TMath::KOrdStat((Long64_t)interplane,qme2,(Long64_t)ind,work);
534 mocchiut 1.2 if ( qm2 >= qmt ){
535 mocchiut 1.5 if ( l < N ){
536     qpremeanN += qm2;
537     RN++;
538     };
539 mocchiut 1.2 l++;
540 mocchiut 1.5 if ( debug ) printf(" qm2 value no %i qm %f qmt %f RN %i \n",l,qm2,qmt,RN);
541 mocchiut 1.1 };
542     ind++;
543     };
544 malvezzi 1.14 ////////////////////////////////////
545     //to calculate qNmin1///////////////
546     ///////////////////////////////////
547     //values under threshold
548     qm2=0;
549     ind = 0;
550     l = 0;
551     RN = 0;
552     S2=0;
553     while ( l < uplim2 && ind<interplane){
554 mocchiut 1.18 qm2 = TMath::KOrdStat((Long64_t)interplane,qme2,(Long64_t)ind,work);
555 malvezzi 1.14 if ( qm2 < qmt ) S2++;
556     ind++;
557     }
558     qm2=0;
559     ind = 0;
560     l = 0;
561     RN = 0;
562     while ( l < uplim2 && ind < interplane ){
563 mocchiut 1.18 qm2 = TMath::KOrdStat((Long64_t)interplane,qme2,(Long64_t)ind,work);
564 malvezzi 1.14 if ( qm2 >= qmt ){
565     if ( l < (interplane - 1 - S2)){
566     qNmin1_w += qm2;
567     RN++;
568     };
569     l++;
570     if ( debug ) printf(" qm2 value no %i qm %f qmt %f RN %i \n",l,qm2,qmt,RN);
571     };
572     ind++;
573     };
574 mocchiut 1.5 qpremeanN /= (Float_t)RN;
575 malvezzi 1.14 qNmin1_w /= (Float_t)RN;
576 mocchiut 1.11 UN = RN;
577 malvezzi 1.14 ///////set qNmin1 definition///////////
578     if (interplane==1 || interplane==2){
579     if (dedx1>0) qNmin1=dedx1;
580     else if (stdedx1>0) qNmin1=stdedx1;
581     }
582     else if (interplane > 2){
583     qNmin1 = qNmin1_w;
584     }
585     ////////////////////////////////////
586     //////////////////////////////////
587 mocchiut 1.1 //
588 mocchiut 1.4 if ( debug ) printf(" charge is %f \n",sqrt(qpremean));
589 mocchiut 1.1 //
590     if ( mesethr != ethr && interplane >= 3 && !aldone ){
591     Float_t mesethr2 = (sqrt(qpremean) - 0.50)*(sqrt(qpremean) - 0.50);
592     if ( mesethr2 < mesethr*0.90 ){
593     mesethr = (sqrt(dedx1) - 0.25)*(sqrt(dedx1) - 0.25);
594     } else {
595     mesethr = mesethr2;
596     };
597     aldone = true;
598 mocchiut 1.7 if ( mesethr > defethr ){
599     interplane = 0;
600     preq = 0.;
601     postq = 0.;
602     qpremean = 0.;
603     qpremeanN = 0.;
604 malvezzi 1.14 qNmin1 = 0;
605 mocchiut 1.7 multhit = false;
606     gap = false;
607     goto retry;
608     };
609 mocchiut 1.1 };
610     };
611 malvezzi 1.14
612    
613    
614     //=======================================================================
615     //=========== charge determination stdedx1 vs. beta ===============
616     //====================== Siegen method ===========================
617     //=======================================================================
618    
619     // Data from file Calo_Bands_New_7.dat
620     Float_t C0[9] = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 8 , 90 };
621     Float_t B0[9] = {0 , -2.03769 , 7.61781 , 19.7098 , 60.5598 , 57.9226 , 14.8368 , -1358.83 , 8200 };
622     Float_t B1[9] = {0 , 0.0211274 , 9.32057e-010 , 4.47241e-07 , 1.44826e-06 , 2.6189e-05 , 0.00278178 , 55.5445 , 0 };
623     Float_t B2[9] = {0 , -3.91742 , -20.0359 , -16.3043 , -16.9471 , -14.4622 , -10.9594 , -2.38014 , 0 };
624     Float_t B3[9] = {0 , 11.1469 , -6.63105 , -27.8834 , -132.044 , -55.341 , 173.25 , 4115 , 0 };
625     Float_t B4[9] = {0 , -14.3465 , -0.485215 , 18.8122 , 117.533 , -14.0898 , -325.269 , -4388.89 , 0 };
626     Float_t B5[9] = {0 , 6.24281 , 3.96018 , 0 , -26.1881 , 42.9731 , 182.697 , 1661.01 , 0 };
627    
628     Float_t x1[9],y1[9];
629     Int_t n1 = 9;
630    
631     Float_t charge = 1000.;
632     Float_t beta = 100.;
633    
634     //------- First try track dependent beta
635     if( L2->GetTrkLevel2()->GetNTracks()>=1 ){
636     PamTrack *TRKtrack = L2->GetTrack(0);
637     if (fabs(TRKtrack->GetToFTrack()->beta[12]) < 100.) beta = fabs(TRKtrack->GetToFTrack()->beta[12]);
638     }
639     //------- If no beta found, try standalone beta
640     if (beta == 100.) {
641     ToFTrkVar *ttrack = L2->GetToFStoredTrack(-1);
642     beta = fabs(ttrack->beta[12]);
643     }
644    
645     if (beta<2.) { // it makes no sense to allow beta=5 or so...
646    
647     Float_t mip=0;
648     mip=stdedx1 ;
649    
650     if (mip>0) {
651    
652     Float_t betahelp = pow(beta, 1.8);
653     Float_t ym = mip*betahelp;
654     Float_t xb = beta;
655    
656     for ( Int_t jj=0; jj<9; jj++ ){
657     x1[jj] = B0[jj]+B1[jj]*pow(xb,B2[jj])+B3[jj]*xb+B4[jj]*xb*xb+B5[jj]*xb*xb*xb;
658     y1[jj] = C0[jj]*C0[jj] ;
659     }
660    
661     TGraph *gr1 = new TGraph(n1,x1,y1);
662     TSpline3 *spl1 = new TSpline3("grs",gr1); // use a cubic spline
663     Float_t chelp = spl1->Eval(ym);
664     charge = TMath::Sqrt(chelp);
665     gr1->Delete();
666     spl1->Delete();
667    
668     } // if (mip1>0)
669     } // beta < 100
670    
671    
672     charge_siegen1 = charge;
673    
674     //======================= end charge Siegen ===========================
675    
676    
677     // //=======================================================================
678     // //=========== charge determination Maximum release vs. beta ===============
679     // //====================== Rome method ===========================
680 marcelli 1.17 // //=======================================================================
681    
682     Float_t D0[9] = {0, 1, 2, 3 , 4 , 5 , 6, 8, 90};
683     Float_t E1[9] = {0, 500, 500, 923.553 , 659.842, 1113.97, 3037.25, 3034.84, 0};
684     Float_t E2[9] = {0, 11.0, 7.5, 6.92574 , 5.08865, 5.29349, 6.41442, 5.52969, 0};
685     Float_t E3[9] = {0, 1.2, 4, 9.7227 , 13.18, 23.5444, 38.2057, 63.6784, 80000};
686 malvezzi 1.14
687 marcelli 1.17 Float_t xx1[9],yy1[9];
688     n1 = 9;
689 malvezzi 1.14
690     charge = 1000.;
691     mip=0;
692    
693    
694     if (beta<2.) { // it makes no sense to allow beta=5 or so...
695    
696    
697     mip=maxrel;
698    
699     if (mip>0) {
700     Float_t ym = mip;
701     Float_t xb = beta;
702    
703     for ( Int_t jj=0; jj<n1; jj++ ){
704     xx1[jj] = E1[jj]*exp(-E2[jj]*xb)+E3[jj];
705     yy1[jj] = D0[jj]*D0[jj] ;
706     }
707    
708     TGraph *gr1 = new TGraph(n1,xx1,yy1);
709     TSpline3 *spl1 = new TSpline3("grs",gr1); // use a cubic spline
710     Float_t chelp = spl1->Eval(ym);
711     charge = TMath::Sqrt(chelp);
712     gr1->Delete();
713     spl1->Delete();
714    
715    
716     } // if (mip1>0)
717     } // beta < 100
718    
719    
720     ZCalo_maxrel_b = charge;
721    
722     //======================= end charge Rome: maxril vs beta ===========================
723    
724    
725    
726     // =======================================================================
727     // =========== charge determination dedx vs. beta ===============
728     // ====================== Rome method ===========================
729 marcelli 1.17 // =======================================================================
730    
731     Float_t F0[9] = {0., 1., 2., 3. ,4., 5. , 6., 8, 90};
732     Float_t G1[9] = {0, 500, 500, 642.935 , 848.684, 1346.05, 3238.82, 3468.6, 0};
733     Float_t G2[9] = {0, 11, 7.5, 6.2038 , 5.51723, 5.65265, 6.54089, 5.72723, 0};
734     Float_t G3[9] = {0, 1.2, 4, 9.2421 , 13.9858, 25.3912, 39.6332, 64.5674, 80000};
735 malvezzi 1.14
736    
737     charge = 1000.;
738     mip=0;
739    
740    
741     if (beta<2.) { // it makes no sense to allow beta=5 or so...
742    
743    
744     if( L2->GetTrkLevel2()->GetNTracks()>=1 ){
745     mip=dedx1;
746     }
747     if (mip==0) mip=stdedx1;
748    
749    
750     if (mip>0) {
751    
752     Float_t ym = mip;
753     Float_t xb = beta;
754    
755     for ( Int_t jj=0; jj<n1; jj++ ){
756     xx1[jj] = G1[jj]*exp(-G2[jj]*xb)+G3[jj];
757     yy1[jj] = F0[jj]*F0[jj] ;
758     }
759    
760     TGraph *gr1 = new TGraph(n1,xx1,yy1);
761     TSpline3 *spl1 = new TSpline3("grs",gr1); // use a cubic spline
762     Float_t chelp = spl1->Eval(ym);
763     charge = TMath::Sqrt(chelp);
764     gr1->Delete();
765     spl1->Delete();
766    
767     } //if (mip1>0)
768     } //beta < 100
769    
770     ZCalo_dedx_b = charge;
771    
772     //======================= end charge Rome: dedx vs beta ===========================
773    
774    
775     //=======================================================================
776     //=========== charge determination dedx vs. defl ===============
777     //====================== Rome method ===========================
778 marcelli 1.17 //=======================================================================
779 malvezzi 1.14
780 marcelli 1.17 Float_t H0[9] = {0, 1, 2, 3 , 4 , 5 , 6, 8, 90 };
781     Float_t I1[9] = {0, 3.5, 40, 56.1019, 101.673, 109.225, 150.599, 388.531, 0};
782     Float_t I2[9] = {0, -1, -13.6, -12.5581, -22.5543, -15.9823, -28.2207, -93.6871, 0};
783     Float_t I3[9] = {0, 1, 5.3, 11.6218, 19.664, 32.1817, 45.7527, 84.5992, 80000};
784 malvezzi 1.14
785    
786     charge = 1000.;
787     mip=0;
788     Float_t defl=0;
789    
790    
791     if (beta<2.) { // it makes no sense to allow beta=5 or so...
792    
793     if( L2->GetTrkLevel2()->GetNTracks()>=1 ){
794     PamTrack *TRKtrack = L2->GetTrack(0);
795     mip=dedx1;
796     if (mip==0) mip=stdedx1;
797     defl=TRKtrack->GetTrkTrack()->al[4];
798    
799    
800     if (mip>0 && defl<0.7 && defl>0) {
801    
802     Float_t ym = mip;
803     Float_t xb = defl;
804    
805     for ( Int_t jj=0; jj<n1; jj++ ){
806     xx1[jj] = I1[jj]*xb*xb+I2[jj]*xb+I3[jj];
807     yy1[jj] = H0[jj]*H0[jj] ;
808     }
809    
810     TGraph *gr1 = new TGraph(n1,xx1,yy1);
811     TSpline3 *spl1 = new TSpline3("grs",gr1); // use a cubic spline
812     Float_t chelp = spl1->Eval(ym);
813     charge = TMath::Sqrt(chelp);
814     gr1->Delete();
815     spl1->Delete();
816    
817     } // if (mip1>0 && defl<0.5 && defl>0)
818     }//Ntrack>=1
819     } //beta < 100
820    
821     ZCalo_dedx_defl = charge;
822    
823     //======================= end charge Rome: dedx vs defl ===========================
824    
825    
826     //============================================================================================
827     //=========== charge determination Truncated mean (N-1 planes) vs. defl ===================
828     //================================ Rome method ========================================
829 marcelli 1.17 //============================================================================================
830    
831     Float_t L0[9] = {0, 1, 2, 3 , 4 , 5 , 6, 8, 90};
832     Float_t M1[9] = {0, 3.5, 27, 63.0145, 120.504, 173.663, 245.33, 236.517, 0};
833     Float_t M2[9] = {0, -1, -10.6, -15.005, -31.0635, -39.4988, -60.5011, -46.3992, 0};
834     Float_t M3[9] = {0, 1, 7, 12.5037, 22.8652, 35.2907, 51.4678, 86.4155, 80000};
835 malvezzi 1.14
836     charge = 1000.;
837     mip=0;
838    
839    
840     if (beta<2.) { // it makes no sense to allow beta=5 or so...
841    
842     if( L2->GetTrkLevel2()->GetNTracks()>=1 ){
843     mip=qNmin1;
844    
845     if (mip>0 && defl<0.7 && defl>0) {
846    
847     Float_t ym = mip;
848     Float_t xb = defl;
849    
850     for ( Int_t jj=0; jj<n1; jj++ ){
851     xx1[jj] = M1[jj]*xb*xb+M2[jj]*xb+M3[jj];
852     yy1[jj] = L0[jj]*L0[jj] ;
853     }
854    
855     TGraph *gr1 = new TGraph(n1,xx1,yy1);
856     TSpline3 *spl1 = new TSpline3("grs",gr1); // use a cubic spline
857     Float_t chelp = spl1->Eval(ym);
858     charge = TMath::Sqrt(chelp);
859     gr1->Delete();
860     spl1->Delete();
861    
862     } // if (mip1>0 && defl<0.5 && defl>0)
863     }//Ntrack>=1
864     } //beta < 100
865    
866     ZCalo_Nmin1_defl = charge;
867    
868     //======================= end charge Rome: Nmin1 vs defl ===========================
869    
870    
871    
872    
873    
874 mocchiut 1.1 //
875 mocchiut 1.5 if ( debug ) this->Print();
876 mocchiut 1.4 if ( debug ) printf(" esci \n");
877 mocchiut 1.1 //
878     };

  ViewVC Help
Powered by ViewVC 1.1.23