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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mocchiut, Thu Apr 5 13:38:32 2007 UTC revision 1.5 by mocchiut, Thu May 24 07:50:48 2007 UTC
# Line 23  CaloNuclei::CaloNuclei(PamLevel2 *l2p){ Line 23  CaloNuclei::CaloNuclei(PamLevel2 *l2p){
23    R = 3;    R = 3;
24    //    //
25    debug = false;    debug = false;
26      usetrack = true;
27    //    //
28  };  };
29    
30  void CaloNuclei::Clear(){  void CaloNuclei::Clear(){
31    //    //
32    tr = 0;    tr = 0;
33      sntr = 0;
34    interplane = 0;    interplane = 0;
35    preq = 0.;    preq = 0.;
36    postq = 0.;    postq = 0.;
# Line 47  void CaloNuclei::Print(){ Line 49  void CaloNuclei::Print(){
49    Process();    Process();
50    //    //
51    printf("========================================================================\n");    printf("========================================================================\n");
52    printf(" OBT: %u PKT: %u ATIME: %u Track %i \n",OBT,PKT,atime,tr);    printf(" OBT: %u PKT: %u ATIME: %u Track %i Use track %i \n",OBT,PKT,atime,tr,usetrack);
53    printf(" interplane [number of available dE/dx before interaction]: %i\n",interplane);    printf(" interplane [number of available dE/dx before interaction]:.. %i\n",interplane);
54    printf(" ethr [threshold used to determine interplane]:............ %f \n",ethr);    printf(" ethr [threshold used to determine interplane]:.............. %f \n",ethr);
55    printf(" dedx1 [dE/dx from the first calorimeter plane]:........... %f \n",dedx1);    printf(" dedx1 [dE/dx from the first calorimeter plane]:............. %f \n",dedx1);
56    printf(" dedx3 [dE/dx (average) if the first 3 Si planes]:......... %f \n",dedx3);    printf(" stdedx1 [dE/dx from the first calorimeter plane standalone]: %f \n",stdedx1);
57    printf(" multhit [true if interplane determined by multiple hits]:. %i \n",multhit);    printf(" dedx3 [dE/dx (average) if the first 3 Si planes]:........... %f \n",dedx3);
58    printf(" gap [true if interplane determined by a gap]:............. %i \n",gap);    printf(" multhit [true if interplane determined by multiple hits]:... %i \n",multhit);
59    printf(" preq [total energy in MIP before the interaction plane]:.. %f \n",preq);    printf(" gap [true if interplane determined by a gap]:............... %i \n",gap);
60    printf(" postq [total energy in MIP after the interaction plane]:.. %f \n",postq);    printf(" preq [total energy in MIP before the interaction plane]:.... %f \n",preq);
61    printf(" qpremean [truncated mean using 3 planes and 3 strips]:.... %f \n",qpremean);    printf(" postq [total energy in MIP after the interaction plane]:.... %f \n",postq);
62    printf(" N [no of used plane]:..................................... %i \n",N);    printf(" qpremean [truncated mean using 3 planes and 3 strips]:...... %f \n",qpremean);
63    printf(" R [no strip used per plane ]:............................. %i \n",R);    printf(" N [no of used plane]:....................................... %i \n",N);
64    printf(" qpremeanN [truncated mean using N planes and R strips]:... %f \n",qpremeanN);    printf(" R [no strip used per plane ]:............................... %i \n",R);
65      printf(" qpremeanN [truncated mean using N planes and R strips]:..... %f \n",qpremeanN);
66    printf("========================================================================\n");    printf("========================================================================\n");
67    //    //
68  };  };
# Line 85  void CaloNuclei::Process(Int_t ntr){ Line 88  void CaloNuclei::Process(Int_t ntr){
88    Bool_t newentry = false;    Bool_t newentry = false;
89    //    //
90    if ( L2->IsORB() ){    if ( L2->IsORB() ){
91      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime ){      if ( L2->GetOrbitalInfo()->pkt_num != PKT || L2->GetOrbitalInfo()->OBT != OBT || L2->GetOrbitalInfo()->absTime != atime || ntr != sntr ){
92        newentry = true;        newentry = true;
93        OBT = L2->GetOrbitalInfo()->OBT;        OBT = L2->GetOrbitalInfo()->OBT;
94        PKT = L2->GetOrbitalInfo()->pkt_num;        PKT = L2->GetOrbitalInfo()->pkt_num;
95        atime = L2->GetOrbitalInfo()->absTime;        atime = L2->GetOrbitalInfo()->absTime;
96          sntr = ntr;
97      };      };
98    } else {    } else {
99      newentry = true;      newentry = true;
# Line 103  void CaloNuclei::Process(Int_t ntr){ Line 107  void CaloNuclei::Process(Int_t ntr){
107    //    //
108    Clear();    Clear();
109    //    //
110    PamTrack *track = 0;    // Always calculate stdedx1
   track = L2->GetTrack(ntr);  
111    //    //
112    Int_t view = 0;    Int_t view = 0;
113    Int_t plane = 0;    Int_t plane = 0;
114    Int_t strip = 0;    Int_t strip = 0;
115      Int_t indx = 0;
116      Float_t vfpl[96];
117      Int_t stfpl[96];
118      memset(vfpl, 0, 96*sizeof(Float_t));
119      memset(stfpl, 0, 96*sizeof(Int_t));
120    Float_t mip = 0.;    Float_t mip = 0.;
121      for ( Int_t i=0; i<L2->GetCaloLevel1()->istrip; i++ ){
122        //
123        mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
124        //
125        // put in vfpl vector the energy release on the first plane
126        //
127        if ( strip != -1 && view == 1 && plane == 0 ) {
128          stfpl[indx] = strip;
129          vfpl[indx] = mip;
130          indx++;
131        };
132        //
133      };
134      //
135      // find energy released along the strip of maximum on the first plane and on the two neighbour strips
136      //
137      if ( indx > 0 ){
138        Int_t mindx = (Int_t)TMath::LocMax(indx,stfpl);
139        for (Int_t ii=0; ii<indx; ii++){
140          if ( stfpl[ii] == stfpl[mindx] ) stdedx1 += vfpl[ii];
141          if ( (mindx-1)>=0 && stfpl[ii] == stfpl[mindx-1] ) stdedx1 += vfpl[ii];
142          if ( (mindx+1)<96 && stfpl[ii] == stfpl[mindx+1] ) stdedx1 += vfpl[ii];
143        };
144      } else {
145        stdedx1 = 0.;
146      };
147      //
148      //
149      //
150      if ( !usetrack ) return;
151      //
152      PamTrack *ptrack = 0;
153      CaloTrkVar *track = 0;
154      if ( ntr >= 0 ){
155        ptrack = L2->GetTrack(ntr);
156        track = ptrack->GetCaloTrack();
157      } else {
158        track = L2->GetCaloStoredTrack(ntr);
159      };
160      //
161      if ( !track && ntr >= 0 ){
162        printf(" ERROR: cannot find any track!\n");
163        printf(" ERROR: CaloNuclei variables not completely filled \n");
164        return;  
165      };
166      //
167    //  Float_t defethr = 6. * 0.90;    //  Float_t defethr = 6. * 0.90;
168    Float_t defethr = 6.25; // = (sqrt(9) - 0.5) ** 2.;    Float_t defethr = 6.25; // = (sqrt(9) - 0.5) ** 2.;
169    //    //
# Line 119  void CaloNuclei::Process(Int_t ntr){ Line 173  void CaloNuclei::Process(Int_t ntr){
173      //      //
174      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);      mip = L2->GetCaloLevel1()->DecodeEstrip(i,view,plane,strip);
175      //      //
176      if ( strip != -1 &&      if ( ntr >= 0 ){
177           view == 1   &&        //
178           plane == 0  &&        if ( strip != -1 &&
179           ( strip == (track->GetCaloTrack()->tibar[0][1]-1) || strip == (track->GetCaloTrack()->tibar[0][1]-2) || strip == (track->GetCaloTrack()->tibar[0][1]) )             view == 1   &&
180           && true ){                   plane == 0  &&
181        dedx1 += mip;             ( strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) || strip == (track->tibar[0][1]) )
182      };             && true ){      
183      if ( strip != -1 &&          dedx1 += mip;
184           (( view == 1 && ( plane == 0 || plane == 1 ) ) ||        };
185           ( view == 0 && plane == 0 )) &&        if ( strip != -1 &&
186           (( view == 0 && ( strip == track->GetCaloTrack()->tibar[0][0] || strip == (track->GetCaloTrack()->tibar[0][0]-1) || strip == (track->GetCaloTrack()->tibar[0][0]-2) )) ||             (( view == 1 && ( plane == 0 || plane == 1 ) ) ||
187            ( view == 1 && ( strip == track->GetCaloTrack()->tibar[0][1] || strip == (track->GetCaloTrack()->tibar[0][1]-1) || strip == (track->GetCaloTrack()->tibar[0][1]-2) )) ||              ( view == 0 && plane == 0 )) &&
188            ( view == 1 && ( strip == track->GetCaloTrack()->tibar[1][1] || strip == (track->GetCaloTrack()->tibar[1][1]-1) || strip == (track->GetCaloTrack()->tibar[1][1]-2) ))) &&             (( view == 0 && ( strip == track->tibar[0][0] || strip == (track->tibar[0][0]-1) || strip == (track->tibar[0][0]-2) )) ||
189           true ){              ( view == 1 && ( strip == track->tibar[0][1] || strip == (track->tibar[0][1]-1) || strip == (track->tibar[0][1]-2) )) ||
190        dedx3 += mip;              ( view == 1 && ( strip == track->tibar[1][1] || strip == (track->tibar[1][1]-1) || strip == (track->tibar[1][1]-2) ))) &&
191               true ){
192            dedx3 += mip;
193          };
194        } else {
195          //
196          if ( strip != -1 &&
197               view == 1   &&
198               plane == 0  &&
199               ( strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) || strip == (L2->GetCaloLevel2()->cibar[0][1]) )
200               && true ){      
201            dedx1 += mip;
202          };
203          if ( strip != -1 &&
204               (( view == 1 && ( plane == 0 || plane == 1 ) ) ||
205                ( view == 0 && plane == 0 )) &&
206               (( view == 0 && ( strip == L2->GetCaloLevel2()->cibar[0][0] || strip == (L2->GetCaloLevel2()->cibar[0][0]-1) || strip == (L2->GetCaloLevel2()->cibar[0][0]-2) )) ||
207                ( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[0][1] || strip == (L2->GetCaloLevel2()->cibar[0][1]-1) || strip == (L2->GetCaloLevel2()->cibar[0][1]-2) )) ||
208                ( view == 1 && ( strip == L2->GetCaloLevel2()->cibar[1][1] || strip == (L2->GetCaloLevel2()->cibar[1][1]-1) || strip == (L2->GetCaloLevel2()->cibar[1][1]-2) ))) &&
209               true ){
210            dedx3 += mip;
211          };
212      };      };
213      //          //    
214    };    };
# Line 167  void CaloNuclei::Process(Int_t ntr){ Line 242  void CaloNuclei::Process(Int_t ntr){
242      //      //
243      mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip);          mip = L2->GetCaloLevel1()->DecodeEstrip(ii,view,plane,strip);    
244      //      //
245      if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] &&      if ( ntr >= 0 ){
246           ( strip == (track->GetCaloTrack()->tibar[plane][view]-1) || strip == (track->GetCaloTrack()->tibar[plane][view]-2) || strip == (track->GetCaloTrack()->tibar[plane][view]) )        if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] &&
247           && true ){                   ( strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) )
248        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->GetCaloTrack()->tibar[plane][view]-1,nhit[view],splane[view],sview[view]);             && true ){      
249        interpl[view] = plane;          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]);
250        interv[view] = view;          interpl[view] = plane;
251        if ( splane[view] != plane || sview[view] != view ){          interv[view] = view;
252          if ( nhit[view] > 1 ){          if ( splane[view] != plane || sview[view] != view ){
253            wmulthit[view] = true;            if ( nhit[view] > 1 ){
254            //      if ( splane[view] == -1 ) splane[view] = 0; //              wmulthit[view] = true;
255            //      if ( sview[view] == -1 ) sview[view] = view; //              //    if ( splane[view] == -1 ) splane[view] = 0; //
256            interpl[view] = splane[view];              //    if ( sview[view] == -1 ) sview[view] = view; //
257            interv[view] = sview[view];                  interpl[view] = splane[view];
258                interv[view] = sview[view];  
259          };          };
260          if ( plane > splane[view]+gapth ){            if ( plane > splane[view]+gapth ){
261            wgap[view] = true;              wgap[view] = true;
262            //      if ( splane[view] == -1 ) splane[view] = 0;//              //    if ( splane[view] == -1 ) splane[view] = 0;//
263            //      if ( sview[view] == -1 ) sview[view] = view; //              //    if ( sview[view] == -1 ) sview[view] = view; //
264            interpl[view] = splane[view];              interpl[view] = splane[view];
265            interv[view] = sview[view];              interv[view] = sview[view];
266              };
267              splane[view] = plane;
268              sview[view] = view;
269              nhit[view] = 1;
270            } else {
271              nhit[view]++;
272            };
273          };
274        } else {
275          if ( strip != -1 && mip > ethr && !wmulthit[view] && !wgap[view] &&
276               ( strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) )
277               && true ){      
278            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]);
279            interpl[view] = plane;
280            interv[view] = view;
281            if ( splane[view] != plane || sview[view] != view ){
282              if ( nhit[view] > 1 ){
283                wmulthit[view] = true;
284                //    if ( splane[view] == -1 ) splane[view] = 0; //
285                //    if ( sview[view] == -1 ) sview[view] = view; //
286                interpl[view] = splane[view];
287                interv[view] = sview[view];  
288            };
289              if ( plane > splane[view]+gapth ){
290                wgap[view] = true;
291                //    if ( splane[view] == -1 ) splane[view] = 0;//
292                //    if ( sview[view] == -1 ) sview[view] = view; //
293                interpl[view] = splane[view];
294                interv[view] = sview[view];
295              };
296              splane[view] = plane;
297              sview[view] = view;
298              nhit[view] = 1;
299            } else {
300              nhit[view]++;
301          };          };
         splane[view] = plane;  
         sview[view] = view;  
         nhit[view] = 1;  
       } else {  
         nhit[view]++;  
302        };        };
303      };      };
304      //      //
# Line 273  void CaloNuclei::Process(Int_t ntr){ Line 379  void CaloNuclei::Process(Int_t ntr){
379            postq += mip;            postq += mip;
380          } else {          } else {
381            preq += mip;            preq += mip;
382            if (  strip == (track->GetCaloTrack()->tibar[plane][view]-1) || strip == (track->GetCaloTrack()->tibar[plane][view]-2) || strip == (track->GetCaloTrack()->tibar[plane][view]) ){            if ( ntr >= 0 ){
383              if ( qsplane != plane || qsview != view ){              if (  strip == (track->tibar[plane][view]-1) || strip == (track->tibar[plane][view]-2) || strip == (track->tibar[plane][view]) ){
384                qsplane = plane;                if ( qsplane != plane || qsview != view ){
385                qsview = view;                  qsplane = plane;
386                ind++;                  qsview = view;
387                if ( debug && ind > 199 ) printf(" AAAGH!! \n");                  ind++;
388                qme[ind] = 0.;                  if ( debug && ind > 199 ) printf(" AAAGH!! \n");
389                    qme[ind] = 0.;
390                  };
391                  qme[ind] += mip;
392              };              };
393              qme[ind] += mip;              for ( Int_t ns = 0; ns < R ; ns++){
394            };                Int_t ms =  track->tibar[plane][view] - 1 - ns + (R - 1)/2;
395            for ( Int_t ns = 0; ns < R ; ns++){                if ( strip == ms ){
396              Int_t ms =  track->GetCaloTrack()->tibar[plane][view] - 1 - ns + (R - 1)/2;                  if ( qsplane2 != plane || qsview2 != view ){
397              if ( strip == ms ){                    qsplane2 = plane;
398                if ( qsplane2 != plane || qsview2 != view ){                    qsview2 = view;
399                  qsplane2 = plane;                    ind2++;
400                  qsview2 = view;                    if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n");
401                  ind2++;                    qme2[ind2] = 0.;
402                  if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n");                  };
403                  qme2[ind2] = 0.;                  qme2[ind2] += mip;
404                };                };
405                qme2[ind2] += mip;              };  
406              } else {
407                if (  strip == (L2->GetCaloLevel2()->cibar[plane][view]-1) || strip == (L2->GetCaloLevel2()->cibar[plane][view]-2) || strip == (L2->GetCaloLevel2()->cibar[plane][view]) ){
408                  if ( qsplane != plane || qsview != view ){
409                    qsplane = plane;
410                    qsview = view;
411                    ind++;
412                    if ( debug && ind > 199 ) printf(" AAAGH!! \n");
413                    qme[ind] = 0.;
414                  };
415                  qme[ind] += mip;
416              };              };
417            };                  for ( Int_t ns = 0; ns < R ; ns++){
418                  Int_t ms =  L2->GetCaloLevel2()->cibar[plane][view] - 1 - ns + (R - 1)/2;
419                  if ( strip == ms ){
420                    if ( qsplane2 != plane || qsview2 != view ){
421                      qsplane2 = plane;
422                      qsview2 = view;
423                      ind2++;
424                      if ( debug && ind2 > 2112 ) printf(" AAAGH!! \n");
425                      qme2[ind2] = 0.;
426                    };
427                    qme2[ind2] += mip;
428                  };
429                };  
430              };
431          };                };      
432          //          //
433        };        };
# Line 315  void CaloNuclei::Process(Int_t ntr){ Line 447  void CaloNuclei::Process(Int_t ntr){
447      Long64_t work[200];      Long64_t work[200];
448      ind = 0;      ind = 0;
449      Int_t l = 0;      Int_t l = 0;
450        Int_t RN = 0;
451      Float_t qm = 0.;      Float_t qm = 0.;
452      Float_t qm2 = 0.;      Float_t qm2 = 0.;
453      //      //
# Line 325  void CaloNuclei::Process(Int_t ntr){ Line 458  void CaloNuclei::Process(Int_t ntr){
458      while ( l < uplim && ind < interplane ){      while ( l < uplim && ind < interplane ){
459        qm = TMath::KOrdStat(interplane,qme,ind,work);        qm = TMath::KOrdStat(interplane,qme,ind,work);
460        if ( qm >= qmt ){        if ( qm >= qmt ){
461          if ( l < 3 ) qpremean += qm;          if ( l < 3 ){
462              qpremean += qm;
463              RN++;
464            };
465          l++;          l++;
466          if ( debug ) printf(" value no %i qm %f qmt %f \n",l,qm,qmt);          if ( debug ) printf(" value no %i qm %f qmt %f \n",l,qm,qmt);
467        };        };
468        ind++;        ind++;
469      };      };
470      //      //
471      qpremean /= l;      qpremean /= (Float_t)RN;
472      //      //
473      ind = 0;      ind = 0;
474      l = 0;      l = 0;
475        RN = 0;
476      while ( l < uplim && ind < interplane ){      while ( l < uplim && ind < interplane ){
477        qm2 = TMath::KOrdStat(interplane,qme2,ind,work);        qm2 = TMath::KOrdStat(interplane,qme2,ind,work);
478        if ( qm2 >= qmt ){                if ( qm2 >= qmt ){        
479          if ( l < N ) qpremeanN += qm2;          if ( l < N ){
480              qpremeanN += qm2;
481              RN++;
482            };
483          l++;          l++;
484          if ( debug ) printf(" qm2 value no %i qm %f qmt %f \n",l,qm2,qmt);          if ( debug ) printf(" qm2 value no %i qm %f qmt %f RN %i \n",l,qm2,qmt,RN);
485        };        };
486        ind++;        ind++;
487      };      };
488      //      //
489      qpremeanN /= l;      qpremeanN /= (Float_t)RN;
490      //      //
491      if ( debug ) printf(" charge is %f \n",sqrt(qpremean));      if ( debug ) printf(" charge is %f \n",sqrt(qpremean));
492      //      //
# Line 362  void CaloNuclei::Process(Int_t ntr){ Line 502  void CaloNuclei::Process(Int_t ntr){
502      };      };
503    };    };
504    //    //
505      if ( debug ) this->Print();
506    if ( debug ) printf(" esci \n");    if ( debug ) printf(" esci \n");
507    //    //
508  };  };

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23