/[PAMELA software]/DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp
ViewVC logotype

Diff of /DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp

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

revision 1.7 by mocchiut, Thu Nov 9 17:05:44 2006 UTC revision 1.11 by pam-fi, Tue Jan 16 10:09:45 2007 UTC
# Line 5  Line 5 
5  **/  **/
6  #include <TObject.h>  #include <TObject.h>
7  #include <CaloLevel2.h>  #include <CaloLevel2.h>
8    
9    //
10  ClassImp(CaloTrkVar);  ClassImp(CaloTrkVar);
11  ClassImp(CaloLevel2);  ClassImp(CaloLevel2);
12    
# Line 84  CaloTrkVar::CaloTrkVar(const CaloTrkVar Line 86  CaloTrkVar::CaloTrkVar(const CaloTrkVar
86  **/  **/
87  CaloLevel2::CaloLevel2() {      CaloLevel2::CaloLevel2() {    
88    //    //
89    CaloTrk = new TClonesArray("CaloTrkVar",1);  //  CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA
90    estrip = TArrayF(0,NULL);    CaloTrk = 0; //ELENA
91    //    //
92    this->Clear();    this->Clear();
93    //    //
94  };  };
95    /**
96     * Create the TClonesArray
97    **/
98    void CaloLevel2::Set(){//ELENA
99        if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA
100    }//ELENA
101    
102    /**
103     * Clear the CaloLevel2 object
104     **/
105  void CaloLevel2::Clear() {      void CaloLevel2::Clear() {    
106    //    //
107    CaloTrk->Clear();  //  CaloTrk->Clear(); //ELENA
108      if(CaloTrk)CaloTrk->Delete(); //ELENA
109    //    //
110    nstrip = 0;    nstrip = 0;
111    qtot = 0.;    qtot = 0.;
# Line 117  void CaloLevel2::Clear() {     Line 129  void CaloLevel2::Clear() {    
129    memset(cbar, 0, 2*22*sizeof(Float_t));    memset(cbar, 0, 2*22*sizeof(Float_t));
130    good = 0;    good = 0;
131    selftrigger = 0;    selftrigger = 0;
132    estrip.Reset();    //
133  };  };
134    
135    /**
136     * Delete the CaloLevel2 object
137     **/
138    void CaloLevel2::Delete() {     //ELENA
139      if(CaloTrk){ //ELENA
140          CaloTrk->Delete(); //ELENA
141          delete CaloTrk; //ELENA
142      }     //ELENA
143    } //ELENA
144    
145  /**  /**
146   * Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common).   * Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common).
# Line 152  void CaloLevel2::GetLevel2Struct(cCaloLe Line 173  void CaloLevel2::GetLevel2Struct(cCaloLe
173      l2->qq[i] = qq[i];        l2->qq[i] = qq[i];  
174    }    }
175    
176    l2->calntrk = CaloTrk->GetEntries();    if(CaloTrk){ //ELENA
177            l2->calntrk = CaloTrk->GetEntries();  
178    for(Int_t i=0;i<l2->calntrk;i++){        for(Int_t i=0;i<l2->calntrk;i++){
179      l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno;              l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno;  
180      l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore;                l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore;    
181      l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint;                l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint;    
182      l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl;                  l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl;      
183      l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast;                l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast;    
184      l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre;                  l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre;      
185      l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh;                l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh;    
186      l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr;                  l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr;      
187      l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot;              l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot;  
188      l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow;                  l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow;      
189      l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ;              l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ;  
190      l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl;                l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl;    
191      l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast;              l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast;  
192      l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre;                l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre;    
193      l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh;              l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh;  
194      l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr;                l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr;    
195      l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack;              l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack;  
196      l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx;            l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx;
197      l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky;            l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky;
198      l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack;            l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack;
199      l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack;            l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack;
200      l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean;              l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean;  
201      l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow;                l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow;    
202      l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l;              l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l;  
203      for (Int_t j=0; j<2; j++){            for (Int_t j=0; j<2; j++){
204        for (Int_t k=0; k<22; k++){                for (Int_t k=0; k<22; k++){
205          l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j];                    l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j];
206        };                };
207      };            };
208    }          }  
209      } //ELENA
210  }  }
211    
212  /**  /**
213   * Gives the detected energy for the given strip once loaded the event   * Should return the energy in GeV if the particle would be an electron
214  **/   * using a parametrization taken from Monte Carlo simulation
 Float_t CaloLevel2::GetEstrip(Int_t view, Int_t plane, Int_t strip){  
   Int_t splane = 0;  
   Int_t sstrip = 0;  
   //  
   if ( nstrip == 0 ) return(0.);  
   //  
   for (Int_t i = 0; i<nstrip; i++ ){  
     if ( view == 0 ){  
       if ( estrip.At(i) > 0. ){  
         splane = (Int_t)trunc(estrip.At(i)/1000000.);  
         sstrip = (Int_t)trunc((estrip.At(i)-((Float_t)splane*1000000.))/10000.);  
         if ( splane == plane && sstrip == strip ) return(estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);  
       };          
     } else {  
       if ( estrip.At(i) < 0. ){  
         splane = (Int_t)trunc(-estrip.At(i)/1000000.);  
         sstrip = (Int_t)trunc((-estrip.At(i)-((Float_t)splane*1000000.))/10000.);  
         if ( splane == plane && sstrip == strip ) return(-estrip.At(i)-(Float_t)splane*1000000.-(Float_t)sstrip*10000.);          
       };          
     };  
   };  
   return(0.);  
 };  
   
 /**  
  * Given estrip entry returns energy and strip  
215  **/  **/
 Float_t CaloLevel2::DecodeEstrip(Int_t entry, Int_t &view, Int_t &plane, Int_t &strip){  
   if ( entry>nstrip ) return(0.);  
   //  
   if ( estrip.At(entry) > 0. ){  
     view = 0;  
     plane = (Int_t)trunc(estrip.At(entry)/1000000.);  
     strip = (Int_t)trunc((estrip.At(entry)-((Float_t)plane*1000000.))/10000.);  
     return(estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);  
   };  
   if ( estrip.At(entry) < 0. ){  
     view = 1;  
     plane = (Int_t)trunc(-estrip.At(entry)/1000000.);  
     strip = (Int_t)trunc((-estrip.At(entry)-((Float_t)plane*1000000.))/10000.);  
     return(-estrip.At(entry)-(Float_t)plane*1000000.-(Float_t)strip*10000.);      
   };      
   //  
   printf(" WARNING: problems decoding value %f at entry %i \n",estrip.At(entry),entry);  
   //  
   view = -1;  
   plane = -1;  
   strip = -1;  
   return(0.);    
 }  
   
216  void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){  void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){
217    if ( nstrip == 0 ) return;    if ( nstrip == 0 ) return;
218    energy = qtot * 40.82 * 0.000106;    energy = qtot * 40.82 * 0.000106;
# Line 260  CaloTrkVar *CaloLevel2::GetCaloTrkVar(In Line 231  CaloTrkVar *CaloLevel2::GetCaloTrkVar(In
231      printf("                   stored track related variables = %i \n",ntrk());      printf("                   stored track related variables = %i \n",ntrk());
232      return(NULL);      return(NULL);
233    }    }
234      if(!CaloTrk)return 0; //ELENA
235    TClonesArray &t = *(CaloTrk);    TClonesArray &t = *(CaloTrk);
236    CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk];    CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk];
237    return calotrack;    return calotrack;

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

  ViewVC Help
Powered by ViewVC 1.1.23