/[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.7 by mocchiut, Fri Jul 21 12:00:22 2006 UTC revision 1.11 by pam-fi, Tue Jan 16 10:12:31 2007 UTC
# Line 32  ToFTrkVar::ToFTrkVar() { Line 32  ToFTrkVar::ToFTrkVar() {
32    npmtadc = 0;    npmtadc = 0;
33    pmttdc = TArrayI(48);    pmttdc = TArrayI(48);
34    pmtadc = TArrayI(48);    pmtadc = TArrayI(48);
35      tdcflag = TArrayI(48); // gf: 30 Nov 2006
36      adcflag = TArrayI(48); // gf: 30 Nov 2006
37    dedx = TArrayF(48);    dedx = TArrayF(48);
38    //    //
39    //    //
# Line 47  void ToFTrkVar::Clear() { Line 49  void ToFTrkVar::Clear() {
49    npmtadc = 0;    npmtadc = 0;
50    pmttdc.Reset();    pmttdc.Reset();
51    pmtadc.Reset();    pmtadc.Reset();
52      tdcflag.Reset(); // gf: 30 Nov 2006
53      adcflag.Reset(); // gf: 30 Nov 2006
54    dedx.Reset();    dedx.Reset();
55    //    //
56    memset(beta,  0, 13*sizeof(Float_t));    memset(beta,  0, 13*sizeof(Float_t));
# Line 63  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t) Line 67  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t)
67    npmtadc = t.npmtadc;    npmtadc = t.npmtadc;
68    (t.pmttdc).Copy(pmttdc);    (t.pmttdc).Copy(pmttdc);
69    (t.pmtadc).Copy(pmtadc);    (t.pmtadc).Copy(pmtadc);
70      (t.tdcflag).Copy(tdcflag); // gf: 30 Nov 2006
71      (t.adcflag).Copy(adcflag); // gf: 30 Nov 2006
72    (t.dedx).Copy(dedx);    (t.dedx).Copy(dedx);
73    //    //
74    memcpy(beta,t.beta,sizeof(beta));    memcpy(beta,t.beta,sizeof(beta));
# Line 73  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();
88    //    //
   memset(tof_j_flag, 0, 6*sizeof(Int_t));  
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;
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 95  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 108  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 138  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 171  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 182  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 189  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 211  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 224  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 332  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      for(Int_t i=0;i<13;i++)                l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i);
389        l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];                l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006
390              }
391      l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;            for(Int_t i=0;i<13;i++)
392      for(Int_t i=0;i<l2->npmtadc[j];i++){                l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];
393        l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i);            
394        l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i);            l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;
395      }            for(Int_t i=0;i<l2->npmtadc[j];i++){
396      for(Int_t i=0;i<3;i++){                l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i);
397        l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];                l2->adcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->adcflag.At(i); // gf: 30 Nov 2006
398        l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];                l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i);
399      }            }
400    }            for(Int_t i=0;i<3;i++){
401                  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.7  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.23