/[PAMELA software]/DarthVader/ToFLevel2/src/ToFLevel2.cpp
ViewVC logotype

Diff of /DarthVader/ToFLevel2/src/ToFLevel2.cpp

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

revision 1.9 by mocchiut, Thu Nov 30 15:44:55 2006 UTC revision 1.11 by pam-fi, Tue Jan 16 10:12:31 2007 UTC
# Line 79  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t) Line 79  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t)
79    
80  ToFLevel2::ToFLevel2() {      ToFLevel2::ToFLevel2() {    
81    //    //
82    PMT = new TClonesArray("ToFPMT",12);  //  PMT = new TClonesArray("ToFPMT",12); //ELENA
83    ToFTrk = new TClonesArray("ToFTrkVar",2);  //  ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
84      PMT = 0; //ELENA
85      ToFTrk = 0; //ELENA
86    //    //
87    this->Clear();    this->Clear();
88    //    //
89  };  };
90    
91    void ToFLevel2::Set(){//ELENA
92        if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA
93        if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
94    }//ELENA
95    
96  void ToFLevel2::Clear(){  void ToFLevel2::Clear(){
97    //    //
98    ToFTrk->Clear();    if(ToFTrk)ToFTrk->Delete(); //ELENA
99    PMT->Clear();    if(PMT)PMT->Delete(); //ELENA
100    memset(tof_j_flag, 0, 6*sizeof(Int_t));    memset(tof_j_flag, 0, 6*sizeof(Int_t));
101    unpackError = 0;    unpackError = 0;
102    //    //
103  };  };
104    
105    void ToFLevel2::Delete(){ //ELENA
106      //
107      if(ToFTrk){
108          ToFTrk->Delete(); //ELENA
109          delete ToFTrk;  //ELENA
110      }
111      if(PMT){
112          PMT->Delete(); //ELENA
113          delete PMT; //ELENA
114      } //ELENA
115      //
116    }; //ELENA
117    
118  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){
119    //        //    
120    if(itrk >= ntrk()){    if(itrk >= ntrk()){
# Line 103  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t Line 123  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t
123      return(NULL);      return(NULL);
124    }      }  
125    //    //
126      if(!ToFTrk)return 0; //ELENA
127    TClonesArray &t = *(ToFTrk);    TClonesArray &t = *(ToFTrk);
128    ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk];    ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk];
129    return toftrack;    return toftrack;
# Line 116  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 137  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
137      return(NULL);      return(NULL);
138    }      }  
139    //    //
140      if(!PMT)return 0; //ELENA
141    TClonesArray &t = *(PMT);    TClonesArray &t = *(PMT);
142    ToFPMT *tofpmt = (ToFPMT*)t[ihit];    ToFPMT *tofpmt = (ToFPMT*)t[ihit];
143    return tofpmt;    return tofpmt;
# Line 146  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 168  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
168        else return -1;        else return -1;
169    };    };
170  /**  /**
171   * Method to know if a given ToF paddle was hit, that is there is a TDC signal from both PMTs   * Method to know if a given ToF paddle was hit, that is there is a TDC signal
172     * from both PMTs
173   * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).   * @param plane Plane ID (11, 12, 21, 22, 31, 32) or Plane index (0,1,2,3,4,5).
174   * @param paddle_id Paddle ID.   * @param paddle_id Paddle ID.
175   * @return 1 if the paddle was hit.   * @return 1 if the paddle was hit.
# Line 179  Int_t ToFLevel2::GetNHitPaddles(Int_t pl Line 202  Int_t ToFLevel2::GetNHitPaddles(Int_t pl
202    
203    
204  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){
205    
206    Float_t dedx = 0.;    Float_t dedx = 0.;
207    Int_t ip = 0;    Int_t ip = 0;
208    Int_t pmt_id = 0;    Int_t pmt_id = 0;
# Line 190  Float_t ToFLevel2::GetdEdx(Int_t notrack Line 214  Float_t ToFLevel2::GetdEdx(Int_t notrack
214    };    };
215    //    //
216    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = GetToFTrkVar(notrack);
217      if(!trk) return 0; //ELENA
218    //    //
219    for (Int_t i=0; i<trk->npmtadc; i++){    for (Int_t i=0; i<trk->npmtadc; i++){
220      //      //
# Line 197  Float_t ToFLevel2::GetdEdx(Int_t notrack Line 222  Float_t ToFLevel2::GetdEdx(Int_t notrack
222      //      //
223      pl = GetPlaneIndex(pmt_id);      pl = GetPlaneIndex(pmt_id);
224      //      //
225      if ( pl == ip ) dedx += (trk->dedx).At(i);        if ( pl == ip ){
226    //      // --- patch ---
227    //      bool ISNULL=false;
228    //      for(Int_t im=0; im< this->npmt(); im++){            
229    //          if(this->GetToFPMT(im)->pmt_id == pmt_id && this->GetToFPMT(im)->adc == 4095){
230    //              cout << " ToFLevel2::GetdEdx(Int_t,Int_t) --> **warning** ADC(PMT="<<pmt_id<<") = 4095"<<endl;
231    //              ISNULL=true;
232    //          }
233    //      }
234    //      // --- patch ---
235    //      dedx += (trk->dedx).At(i)*(Int_t)(!ISNULL);
236            dedx += (trk->dedx).At(i);
237        }
238      //      //
239    };    };
240    //    //
# Line 219  void ToFLevel2::GetMatrix(Int_t notrack, Line 256  void ToFLevel2::GetMatrix(Int_t notrack,
256    Int_t kk = 0;    Int_t kk = 0;
257    //    //
258    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = GetToFTrkVar(notrack);
259      if(!trk)return; //ELENA
260    //    //
261    for (Int_t i=0; i<trk->npmtadc; i++){    for (Int_t i=0; i<trk->npmtadc; i++){
262      //      //
# Line 232  void ToFLevel2::GetMatrix(Int_t notrack, Line 270  void ToFLevel2::GetMatrix(Int_t notrack,
270    for (Int_t i=0; i<npmt(); i++){    for (Int_t i=0; i<npmt(); i++){
271      //      //
272      ToFPMT *pmt = GetToFPMT(i);      ToFPMT *pmt = GetToFPMT(i);
273        if(!pmt)break; //ELENA
274      //      //
275      GetPMTIndex(pmt->pmt_id,hh,kk);      GetPMTIndex(pmt->pmt_id,hh,kk);
276      //      //
# Line 340  void ToFLevel2::GetLevel2Struct(cToFLeve Line 379  void ToFLevel2::GetLevel2Struct(cToFLeve
379    for(Int_t i=0;i<6;i++)    for(Int_t i=0;i<6;i++)
380      l2->tof_j_flag[i]=tof_j_flag[i];      l2->tof_j_flag[i]=tof_j_flag[i];
381    
382    l2->ntoftrk = ToFTrk->GetEntries();    if(ToFTrk){ //ELENA
383    for(Int_t j=0;j<l2->ntoftrk;j++){        l2->ntoftrk = ToFTrk->GetEntries();
384      l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno;        for(Int_t j=0;j<l2->ntoftrk;j++){
385      l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc;            l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno;
386      for(Int_t i=0;i<l2->npmttdc[j];i++){            l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc;
387        l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i);            for(Int_t i=0;i<l2->npmttdc[j];i++){
388        l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006                l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i);
389      }                l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006
390      for(Int_t i=0;i<13;i++)            }
391        l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];            for(Int_t i=0;i<13;i++)
392                      l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];
393      l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;            
394      for(Int_t i=0;i<l2->npmtadc[j];i++){            l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;
395        l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i);            for(Int_t i=0;i<l2->npmtadc[j];i++){
396        l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006                l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i);
397        l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i);                l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006
398      }                l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i);
399      for(Int_t i=0;i<3;i++){            }
400        l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];            for(Int_t i=0;i<3;i++){
401        l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];                l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];
402      }                l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];
403    }            }
404          }
405      } //ELENA
406            
407    l2->npmt = PMT->GetEntries();    if(PMT){ //ELENA
408     for(Int_t j=0;j<l2->npmt;j++){        l2->npmt = PMT->GetEntries();
409       l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id;        for(Int_t j=0;j<l2->npmt;j++){
410       l2->adc[j] =((ToFPMT*)PMT->At(j))->adc;            l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id;
411       l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw;            l2->adc[j] =((ToFPMT*)PMT->At(j))->adc;
412     }            l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw;
413          }
414      } //ELENA
415  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23