/[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.15 by pam-de, Wed Apr 4 07:23:27 2007 UTC
# Line 1  Line 1 
1    /**
2     * \file ToFLevel2.cpp
3     * \author Gianfranca DeRosa, Wolfgang Menn
4     */
5    
6  #include <TObject.h>  #include <TObject.h>
7  #include <ToFLevel2.h>  #include <ToFLevel2.h>
8  #include <iostream>  #include <iostream>
# Line 79  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t) Line 84  ToFTrkVar::ToFTrkVar(const ToFTrkVar &t)
84    
85  ToFLevel2::ToFLevel2() {      ToFLevel2::ToFLevel2() {    
86    //    //
87    PMT = new TClonesArray("ToFPMT",12);  //  PMT = new TClonesArray("ToFPMT",12); //ELENA
88    ToFTrk = new TClonesArray("ToFTrkVar",2);  //  ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
89      PMT = 0; //ELENA
90      ToFTrk = 0; //ELENA
91    //    //
92    this->Clear();    this->Clear();
93    //    //
94  };  };
95    
96    void ToFLevel2::Set(){//ELENA
97        if(!PMT)PMT = new TClonesArray("ToFPMT",12); //ELENA
98        if(!ToFTrk)ToFTrk = new TClonesArray("ToFTrkVar",2); //ELENA
99    }//ELENA
100    
101  void ToFLevel2::Clear(){  void ToFLevel2::Clear(){
102    //    //
103    ToFTrk->Clear();    if(ToFTrk)ToFTrk->Delete(); //ELENA
104    PMT->Clear();    if(PMT)PMT->Delete(); //ELENA
105    memset(tof_j_flag, 0, 6*sizeof(Int_t));    memset(tof_j_flag, 0, 6*sizeof(Int_t));
106    unpackError = 0;    unpackError = 0;
107    //    //
108  };  };
109    
110    void ToFLevel2::Delete(){ //ELENA
111      //
112      if(ToFTrk){
113          ToFTrk->Delete(); //ELENA
114          delete ToFTrk;  //ELENA
115      }
116      if(PMT){
117          PMT->Delete(); //ELENA
118          delete PMT; //ELENA
119      } //ELENA
120      //
121    }; //ELENA
122    
123  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t itrk){
124    //        //    
125    if(itrk >= ntrk()){    if(itrk >= ntrk()){
# Line 103  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t Line 128  ToFTrkVar *ToFLevel2::GetToFTrkVar(Int_t
128      return(NULL);      return(NULL);
129    }      }  
130    //    //
131      if(!ToFTrk)return 0; //ELENA
132    TClonesArray &t = *(ToFTrk);    TClonesArray &t = *(ToFTrk);
133    ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk];    ToFTrkVar *toftrack = (ToFTrkVar*)t[itrk];
134    return toftrack;    return toftrack;
# Line 116  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 142  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
142      return(NULL);      return(NULL);
143    }      }  
144    //    //
145      if(!PMT)return 0; //ELENA
146    TClonesArray &t = *(PMT);    TClonesArray &t = *(PMT);
147    ToFPMT *tofpmt = (ToFPMT*)t[ihit];    ToFPMT *tofpmt = (ToFPMT*)t[ihit];
148    return tofpmt;    return tofpmt;
# Line 126  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 153  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
153  //--------------------------------------  //--------------------------------------
154  /**  /**
155   * Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5)   * Method to get the plane ID (11 12 21 22 31 32) from the plane index (0 1 2 3 4 5)
156     * @param Plane index (0,1,2,3,4,5)
157   */   */
158    Int_t  ToFLevel2::GetToFPlaneID(Int_t ip){    Int_t  ToFLevel2::GetToFPlaneID(Int_t ip){
159        if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1;        if(ip>=0 && ip<6)return 10*((int)(ip/2+1.1))+(ip%2)+1;
# Line 133  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 161  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
161    };    };
162  /**  /**
163   * Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32)   * Method to get the plane index (0 1 2 3 4 5) from the plane ID (11 12 21 22 31 32)
164     * @param plane Plane ID (11, 12, 21, 22, 31, 32)
165   */   */
166    Int_t  ToFLevel2::GetToFPlaneIndex(Int_t plane_id){    Int_t  ToFLevel2::GetToFPlaneIndex(Int_t plane_id){
167        if(        if(
# Line 146  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit) Line 175  ToFPMT *ToFLevel2::GetToFPMT(Int_t ihit)
175        else return -1;        else return -1;
176    };    };
177  /**  /**
178   * 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
179     * from both PMTs. The method uses the "tof_j_flag" variable.
180   * @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).
181   * @param paddle_id Paddle ID.   * @param paddle_id Paddle ID.
182   * @return 1 if the paddle was hit.   * @return 1 if the paddle was hit.
# Line 178  Int_t ToFLevel2::GetNHitPaddles(Int_t pl Line 208  Int_t ToFLevel2::GetNHitPaddles(Int_t pl
208  };  };
209    
210    
211    /**
212     * Method to get the mean dEdx from a given ToF plane. This current version
213     * is just summing up all PMT signals, which will not give proper results,
214     * and needs a revision.
215     * @param notrack Track Number
216     * @param plane Plane index (0,1,2,3,4,5).
217     */
218  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){  Float_t ToFLevel2::GetdEdx(Int_t notrack, Int_t plane){
219    
220    Float_t dedx = 0.;    Float_t dedx = 0.;
221    Int_t ip = 0;    Int_t ip = 0;
222    Int_t pmt_id = 0;    Int_t pmt_id = 0;
# Line 190  Float_t ToFLevel2::GetdEdx(Int_t notrack Line 228  Float_t ToFLevel2::GetdEdx(Int_t notrack
228    };    };
229    //    //
230    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = GetToFTrkVar(notrack);
231      if(!trk) return 0; //ELENA
232    //    //
233    for (Int_t i=0; i<trk->npmtadc; i++){    for (Int_t i=0; i<trk->npmtadc; i++){
234      //      //
# Line 197  Float_t ToFLevel2::GetdEdx(Int_t notrack Line 236  Float_t ToFLevel2::GetdEdx(Int_t notrack
236      //      //
237      pl = GetPlaneIndex(pmt_id);      pl = GetPlaneIndex(pmt_id);
238      //      //
239      if ( pl == ip ) dedx += (trk->dedx).At(i);        if ( pl == ip ) dedx += (trk->dedx).At(i);
240      //      //
241    };    };
242    //    //
# Line 205  Float_t ToFLevel2::GetdEdx(Int_t notrack Line 244  Float_t ToFLevel2::GetdEdx(Int_t notrack
244  };  };
245    
246    
247    /**
248     * Method to fill the ADC_C 4x12 matrix with the dEdx values and the TDC 4x12 matrix
249     * with the time-walk corrected TDC values.
250     * @param notrack Track Number
251     * @param adc  ADC_C matrix with dEdx values
252     * @param tdc  TDC matrix
253     */
254  void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){  void ToFLevel2::GetMatrix(Int_t notrack, Float_t adc[4][12], Float_t tdc[4][12]){
255    //    //
256    for (Int_t aa=0; aa<4;aa++){    for (Int_t aa=0; aa<4;aa++){
# Line 219  void ToFLevel2::GetMatrix(Int_t notrack, Line 265  void ToFLevel2::GetMatrix(Int_t notrack,
265    Int_t kk = 0;    Int_t kk = 0;
266    //    //
267    ToFTrkVar *trk = GetToFTrkVar(notrack);    ToFTrkVar *trk = GetToFTrkVar(notrack);
268      if(!trk)return; //ELENA
269    //    //
270    for (Int_t i=0; i<trk->npmtadc; i++){    for (Int_t i=0; i<trk->npmtadc; i++){
271      //      //
# Line 232  void ToFLevel2::GetMatrix(Int_t notrack, Line 279  void ToFLevel2::GetMatrix(Int_t notrack,
279    for (Int_t i=0; i<npmt(); i++){    for (Int_t i=0; i<npmt(); i++){
280      //      //
281      ToFPMT *pmt = GetToFPMT(i);      ToFPMT *pmt = GetToFPMT(i);
282        if(!pmt)break; //ELENA
283      //      //
284      GetPMTIndex(pmt->pmt_id,hh,kk);      GetPMTIndex(pmt->pmt_id,hh,kk);
285      //      //
# Line 243  void ToFLevel2::GetMatrix(Int_t notrack, Line 291  void ToFLevel2::GetMatrix(Int_t notrack,
291  };  };
292    
293    
294    /**
295     * Method to get the plane index (0 - 5) for the PMT_ID as input
296     * @param pmt_id  PMT_ID (0 - 47)
297     */
298  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt_id){
299    TString pmtname = GetPMTName(pmt_id);    TString pmtname = GetPMTName(pmt_id);
300    pmtname.Resize(3);    pmtname.Resize(3);
# Line 256  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt Line 307  Int_t ToFLevel2::GetPlaneIndex(Int_t pmt
307    return(-1);    return(-1);
308  };  };
309    
310    /**
311     * Method to get the PMT_ID if the index (4,12) is given. We have 4 channels on
312     * each of the 12 half-boards, this method decodes which PMT is cables to which
313     * channel.
314     * @param hh Channel
315     * @param kk HalfBoard
316     */
317  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_t kk){
318    //    //
319    short tof[4][24] = {    short tof[4][24] = {
# Line 285  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_ Line 342  Int_t ToFLevel2::GetPMTid(Int_t hh, Int_
342    return ind;    return ind;
343  };  };
344    
345    /**
346     * Method to get the PMT name (like "S11_1A") if the PMT_ID is given. The first
347     * PMT=0 is S11_1A, then S11_1B, then S11_2A, and so on, up to S32_3B which is PMT=47
348     * @param ind  PMT_ID (0 - 47)
349     */
350  TString ToFLevel2::GetPMTName(Int_t ind){  TString ToFLevel2::GetPMTName(Int_t ind){
351        
352    TString pmtname = " ";    TString pmtname = " ";
# Line 305  TString ToFLevel2::GetPMTName(Int_t ind) Line 367  TString ToFLevel2::GetPMTName(Int_t ind)
367    return pmtname;    return pmtname;
368  };  };
369    
370    /**
371     * Method to get the PMT index if the PMT ID is given. This method is the
372     * "reverse" of method "GetPMTid"
373     * @param ind  PMT_ID (0 - 47)
374     * @param hb   HalfBoard
375     * @param ch   Channel
376     */
377  void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){  void ToFLevel2::GetPMTIndex(Int_t ind, Int_t &hb, Int_t &ch){
378    //    //
379    short tof[4][24] = {    short tof[4][24] = {
# Line 340  void ToFLevel2::GetLevel2Struct(cToFLeve Line 408  void ToFLevel2::GetLevel2Struct(cToFLeve
408    for(Int_t i=0;i<6;i++)    for(Int_t i=0;i<6;i++)
409      l2->tof_j_flag[i]=tof_j_flag[i];      l2->tof_j_flag[i]=tof_j_flag[i];
410    
411    l2->ntoftrk = ToFTrk->GetEntries();    if(ToFTrk){ //ELENA
412    for(Int_t j=0;j<l2->ntoftrk;j++){        l2->ntoftrk = ToFTrk->GetEntries();
413      l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno;        for(Int_t j=0;j<l2->ntoftrk;j++){
414      l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc;            l2->toftrkseqno[j]= ((ToFTrkVar*)ToFTrk->At(j))->trkseqno;
415      for(Int_t i=0;i<l2->npmttdc[j];i++){            l2->npmttdc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmttdc;
416        l2->pmttdc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmttdc.At(i);            for(Int_t i=0;i<l2->npmttdc[j];i++){
417        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);
418      }                l2->tdcflag[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->tdcflag.At(i); // gf: 30 Nov 2006
419      for(Int_t i=0;i<13;i++)            }
420        l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];            for(Int_t i=0;i<13;i++)
421                      l2->beta[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->beta[i];
422      l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;            
423      for(Int_t i=0;i<l2->npmtadc[j];i++){            l2->npmtadc[j]= ((ToFTrkVar*)ToFTrk->At(j))->npmtadc;
424        l2->pmtadc[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->pmtadc.At(i);            for(Int_t i=0;i<l2->npmtadc[j];i++){
425        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);
426        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
427      }                l2->dedx[i][j] = ((ToFTrkVar*)ToFTrk->At(j))->dedx.At(i);
428      for(Int_t i=0;i<3;i++){            }
429        l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];            for(Int_t i=0;i<3;i++){
430        l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];                l2->xtofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->xtofpos[i];
431      }                l2->ytofpos[i][j]=((ToFTrkVar*)ToFTrk->At(j))->ytofpos[i];
432    }            }
433          }
434      } //ELENA
435            
436    l2->npmt = PMT->GetEntries();    if(PMT){ //ELENA
437     for(Int_t j=0;j<l2->npmt;j++){        l2->npmt = PMT->GetEntries();
438       l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id;        for(Int_t j=0;j<l2->npmt;j++){
439       l2->adc[j] =((ToFPMT*)PMT->At(j))->adc;            l2->pmt_id[j] = ((ToFPMT*)PMT->At(j))->pmt_id;
440       l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw;            l2->adc[j] =((ToFPMT*)PMT->At(j))->adc;
441     }            l2->tdc_tw[j] =((ToFPMT*)PMT->At(j))->tdc_tw;
442          }
443      } //ELENA
444  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23