]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Extending to beam test analysis
authorschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Oct 2002 16:38:44 +0000 (16:38 +0000)
committerschutz <schutz@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 21 Oct 2002 16:38:44 +0000 (16:38 +0000)
PHOS/AliPHOSClusterizerv1.cxx
PHOS/AliPHOSClusterizerv1.h
PHOS/AliPHOSDigitizer.cxx
PHOS/AliPHOSGetter.cxx
PHOS/AliPHOSGetter.h

index e7dc51b0fc3a63e4887f35f9e98ea2a2f03bb93a..7b46e720d4af94dafeb4e456accc88204e8f8d27 100644 (file)
@@ -72,7 +72,7 @@
 #include <iomanip.h>
 
 // --- AliRoot header files ---
-
+#include "AliPHOSCalibrationDB.h"
 #include "AliPHOSClusterizerv1.h"
 #include "AliPHOSCpvRecPoint.h"
 #include "AliPHOSDigit.h"
@@ -124,12 +124,14 @@ const TString AliPHOSClusterizerv1::BranchName() const
 //____________________________________________________________________________
 Float_t  AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId) const
 { //To be replased later by the method, reading individual parameters from the database
-
-  if(absId <= fEmcCrystals) //calibrate as EMC 
-    return fADCpedestalEmc + amp*fADCchanelEmc ;    
-   
-  else //Digitize as CPV
-    return fADCpedestalCpv+ amp*fADCchanelCpv ;       
+  if(fCalibrationDB)
+    return fCalibrationDB->Calibrate(amp,absId) ;
+  else{ //simulation
+    if(absId <= fEmcCrystals) //calibrate as EMC 
+      return fADCpedestalEmc + amp*fADCchanelEmc ;        
+    else //calibrate as CPV
+      return fADCpedestalCpv+ amp*fADCchanelCpv ;       
+  }
 }
 
 //____________________________________________________________________________
@@ -283,14 +285,20 @@ Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, AliPHOSDigit **
 void AliPHOSClusterizerv1::GetCalibrationParameters() 
 {
   AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
-  const AliPHOSDigitizer * dig = gime->Digitizer(BranchName()) ;
 
-  fADCchanelEmc   = dig->GetEMCchannel() ;
-  fADCpedestalEmc = dig->GetEMCpedestal();
-  
-  fADCchanelCpv   = dig->GetCPVchannel() ;
-  fADCpedestalCpv = dig->GetCPVpedestal() ; 
-  
+  const TTask * task = gime->Digitizer(BranchName()) ;
+  if(strcmp(task->IsA()->GetName(),"AliPHOSDigitizer")==0){
+    const AliPHOSDigitizer * dig = static_cast<const AliPHOSDigitizer *>(task) ;
+
+    fADCchanelEmc   = dig->GetEMCchannel() ;
+    fADCpedestalEmc = dig->GetEMCpedestal();
+    
+    fADCchanelCpv   = dig->GetCPVchannel() ;
+    fADCpedestalCpv = dig->GetCPVpedestal() ; 
+  }
+  else{
+    fCalibrationDB = gime->CalibrationDB();
+  }
 }
 
 //____________________________________________________________________________
@@ -374,6 +382,8 @@ void AliPHOSClusterizerv1::InitParameters()
   clusterizerName.Append(Version()) ; 
   SetName(clusterizerName) ;
   fRecPointsInRun          = 0 ;
+  fCalibrationDB = 0 ;
+
 
 }
 
@@ -479,7 +489,10 @@ void AliPHOSClusterizerv1::WriteRecPoints(Int_t event)
   }
   
   if(!treeR){
-    gAlice->MakeTree("R", fSplitFile);
+    if(fSplitFile)
+      gAlice->MakeTree("R", fSplitFile);
+    else
+      gAlice->MakeTree("R", gROOT->GetFile(GetTitle()));
     treeR = gAlice->TreeR() ;
   }
 
@@ -567,7 +580,6 @@ void AliPHOSClusterizerv1::MakeClusters()
 
     if (( IsInEmc (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fEmcClusteringThreshold  ) || 
         ( IsInCpv (digit) && Calibrate(digit->GetAmp(),digit->GetId()) > fCpvClusteringThreshold  ) ) {
-         
       Int_t iDigitInCluster = 0 ; 
       
       if  ( IsInEmc(digit) ) {   
index 489c40d44dd5607d96e21c706cb26fb09ae53444..dfb260ecaa95532457b1098df27d80a42db57eb2 100644 (file)
@@ -25,7 +25,7 @@ class AliPHOSEmcRecPoint ;
 class AliPHOSDigit ;
 class AliPHOSDigitizer ;
 class AliPHOSGeometry ;
-
+class AliPHOSCalibrationDB ;
 
 class AliPHOSClusterizerv1 : public AliPHOSClusterizer {
   
@@ -105,7 +105,8 @@ private:
   Int_t   fNumberOfEmcClusters ;     // number of EMC clusters found 
   Int_t   fNumberOfCpvClusters ;     // number of CPV clusters found
  
-  //Calibration parameters... to be replaced by database 
+  //Calibration parameters
+  AliPHOSCalibrationDB * fCalibrationDB ; //! Calibration database if aval
   Float_t fADCchanelEmc ;           // width of one ADC channel in GeV
   Float_t fADCpedestalEmc ;         //
   Float_t fADCchanelCpv ;           // width of one ADC channel in CPV 'popugais'
index c65aa7674aa2f4213c5e69c7ab9a67121de3c013..43b9a6342aed118c45c471f1aca9e88fd9b11c71 100644 (file)
@@ -767,7 +767,7 @@ void AliPHOSDigitizer::WriteDigits(Int_t event)
   
   // -- Create Digitizer branch
   Int_t splitlevel = 0 ;
-  const AliPHOSDigitizer * d = gime->Digitizer(GetName()) ;
+  const AliPHOSDigitizer * d = dynamic_cast<const AliPHOSDigitizer *>(gime->Digitizer()) ;
   TBranch * digitizerBranch = treeD->Branch("AliPHOSDigitizer", "AliPHOSDigitizer", &d,bufferSize,splitlevel); 
   digitizerBranch->SetTitle(GetName());
 
index 4c7992600bab3fbee53f3d075af85022408ffeaa..0f1f8403d2531debe1a9d709a80a6d501e81c3b8 100644 (file)
@@ -71,7 +71,8 @@
 #include "AliPHOSTrackSegment.h"
 #include "AliPHOSPIDv1.h" 
 #include "AliPHOSGeometry.h"
-
+#include "AliPHOSRaw2Digits.h"
+#include "AliPHOSCalibrationDB.h"
 ClassImp(AliPHOSGetter)
   
   AliPHOSGetter * AliPHOSGetter::fgObjGetter = 0 ; 
@@ -91,6 +92,7 @@ AliPHOSGetter::AliPHOSGetter(const char* headerFile, const char* branchTitle, co
 
   fFailed = kFALSE ;   
   fDebug  = 0 ; 
+  fAlice  = 0 ; 
 
   fToSplit    = toSplit ;
   fHeaderFile = headerFile ; 
@@ -173,6 +175,8 @@ void AliPHOSGetter::CloseFile()
 {
   delete gAlice ;  
   gAlice = 0 ; 
+  delete fAlice ; 
+  fAlice = 0 ; 
 }
 
 //____________________________________________________________________________ 
@@ -824,12 +828,20 @@ const Bool_t AliPHOSGetter::PostDigitizer(const char * name) const
     d->Add(phos) ; 
 } 
 
-  AliPHOSDigitizer * phosd = dynamic_cast<AliPHOSDigitizer*>(phos->GetListOfTasks()->FindObject(name)) ; 
+  TTask * phosd = dynamic_cast<TTask*>(phos->GetListOfTasks()->FindObject(fDigitsTitle)) ; 
   if (!phosd) { 
-    phosd = new AliPHOSDigitizer() ;
-    phosd->SetName(fDigitsTitle) ;
-    phosd->SetTitle(fHeaderFile) ;
-    phos->Add(phosd) ;
+    if(strcmp(name, "Digitizer")==0){
+      phosd = new AliPHOSDigitizer() ;
+      phosd->SetName(fDigitsTitle) ;
+      phosd->SetTitle(fHeaderFile) ;
+      phos->Add(phosd) ;
+    } 
+    else{
+      phosd = new AliPHOSRaw2Digits() ;
+      phosd->SetName(fDigitsTitle) ;
+      phosd->SetTitle(fHeaderFile) ;
+      phos->Add(phosd) ;
+    }      
   }
   return kTRUE;  
 }
@@ -1476,9 +1488,12 @@ TTree * AliPHOSGetter::TreeK(TString filename)
 
   TFile * file = 0 ; 
   file = static_cast<TFile*>(gROOT->GetFile(filename.Data() ) ) ;
-  if (!file) {  // file not yet open 
-    file = TFile::Open(filename.Data(), "read") ;    
+  if (file && (filename != fHeaderFile) ) {  // file already open 
+    file->Close() ; 
+    delete fAlice ; 
   }    
+  file = TFile::Open(filename.Data(), "read") ; 
+  fAlice = static_cast<AliRun *>(file->Get("gAlice")) ; 
   TString treeName("TreeK") ; 
   treeName += EventNumber()  ; 
   TTree * tree = static_cast<TTree *>(file->Get(treeName.Data())) ;
@@ -1568,8 +1583,10 @@ const TParticle * AliPHOSGetter::Primary(Int_t index) const
   if(index < 0) 
     return 0 ;
   TParticle *  p = 0 ;
-
-  p = gAlice->Particle(index) ; 
+  if (fAlice) 
+    p = fAlice->Particle(index) ; 
+  else 
+    p = gAlice->Particle(index) ; 
   
   return p ; 
     
@@ -1628,19 +1645,21 @@ Int_t AliPHOSGetter::ReadTreeD(const Int_t event)
       digitsbranch = branch ; 
       phosfound = kTRUE ;
     }
-    else if ( (strcmp(branch->GetName(), "AliPHOSDigitizer")==0) && (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
+    else if ( ((strcmp(branch->GetName(), "AliPHOSDigitizer")==0)||
+              (strcmp(branch->GetName(), "AliPHOSRaw2Digits")==0)) &&
+             (strcmp(branch->GetTitle(), fDigitsTitle)==0) ) {
       digitizerbranch = branch ; 
       digitizerfound = kTRUE ; 
     }
   }
-
+  
   if ( !phosfound || !digitizerfound ) {
     if (fDebug)
       cout << "WARNING: AliPHOSGetter::ReadTreeD -> Cannot find Digits and/or Digitizer with name " 
           << fDigitsTitle << endl ;
     return 2; 
   }   
+  
   //read digits
   if(!Digits(fDigitsTitle) ) 
     PostDigits(fDigitsTitle);
@@ -1649,17 +1668,54 @@ Int_t AliPHOSGetter::ReadTreeD(const Int_t event)
   
   
   // read  the Digitizer
-  RemoveTask("D", fDigitsTitle) ; // I do not understand why I need that 
-  if(!Digitizer(fDigitsTitle))
-    PostDigitizer(fDigitsTitle) ;
+  if(Digitizer()){
+    if(strcmp(Digitizer()->IsA()->GetName(),digitizerbranch->GetName())!=0){
+      RemoveTask("D", fDigitsTitle) ;
+      if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
+       PostDigitizer("Digitizer") ;
+      else
+       PostDigitizer("Raw2Digits") ;
+    }
+  }
+  else{
+    if(strcmp(digitizerbranch->GetName(), "AliPHOSDigitizer")==0)
+      PostDigitizer("Digitizer") ;
+    else
+      PostDigitizer("Raw2Digits") ;
+  }
+    
+
   digitizerbranch->SetAddress(DigitizerRef(fDigitsTitle)) ;
   digitizerbranch->GetEntry(0) ;
-  //  lob  ->Delete();
+  
+
+  if((!fcdb)&&(strcmp(digitizerbranch->GetName(), "AliPHOSRaw2Digits")==0))
+    ReadCalibrationDB("Primordial","beamtest.root") ;
+  
   if(gAlice->TreeD()!=treeD)
     treeD->Delete();
+
   return 0 ; 
 }
+//____________________________________________________________________________ 
+void AliPHOSGetter::ReadCalibrationDB(const char * database,const char * filename){
+
+  if(fcdb && (strcmp(database,fcdb->GetTitle())==0))
+    return ;
+
+  TFile * file = gROOT->GetFile(filename) ;
+  if(!file)
+    file = TFile::Open(filename);
+  if(!file){
+    cout << "Can not open file " << filename << endl ;
+    return ;
+  }
+  if(fcdb)
+    fcdb->Delete() ;
+  fcdb = dynamic_cast<AliPHOSCalibrationDB *>(file->Get("AliPHOSCalibrationDB")) ;
+  if(!fcdb)
+    cout << "No database " << database << " in file " << filename << endl ;
+}
 
 //____________________________________________________________________________ 
 Int_t AliPHOSGetter::ReadTreeH()
@@ -1726,7 +1782,7 @@ Int_t AliPHOSGetter::ReadTreeH()
 }
 
 //____________________________________________________________________________ 
-void AliPHOSGetter::Track(const Int_t itrack) 
+void AliPHOSGetter::Track(Int_t itrack) 
 {
   // Read the first entry of PHOS branch in hit tree gAlice->TreeH()
 
@@ -2099,6 +2155,7 @@ void AliPHOSGetter::ReadPrimaries()
     if (fDebug) 
       cout << "INFO: AliPHOSGetter::ReadPrimaries -> TreeK found in " << fHeaderFile.Data() << endl ; 
     fNPrimaries = gAlice->GetNtrack() ; 
+    fAlice = 0 ; 
   
   } else { // treeK not found in header file
     
@@ -2143,7 +2200,7 @@ void AliPHOSGetter::Event(const Int_t event, const char* opt)
   if( strstr(opt,"Q") )
     ReadTreeQA() ;
  
-  if( strstr(opt,"P"))
+  if( strstr(opt,"P") || (strcmp(opt,"")==0) )
     ReadPrimaries() ;
   
 }
index 88bc1101003f41fbb0f3fc9cf4492c3790260652..e15f6d6aca628a384f1842c80de00a7ad5fd125e 100644 (file)
@@ -45,6 +45,7 @@ class AliPHOSSDigitizer ;
 class AliPHOSClusterizer ;
 class AliPHOSTrackSegmentMaker ;
 class AliPHOSPID ;
+class AliPHOSCalibrationDB ;
 
 class AliPHOSGetter : public TObject {
   
@@ -86,7 +87,7 @@ class AliPHOSGetter : public TObject {
   void   Event(const Int_t event, const char * opt = "HSDRP") ;    
   void   Track(const Int_t itrack) ;
   void   ReadTreeS(TTree * treeS,Int_t input) ; //Method to be used when 
-                                                //digitizing is under the control ofAliRunDigitizer, 
+                                                //digitizing is under the control ofAliRunDigizer, 
                                                 //which opens all files etc.
   //========== Alarms ======================
   TFolder * Alarms() const { return dynamic_cast<TFolder*>(ReturnO("Alarms", 0)) ; }
@@ -121,8 +122,10 @@ class AliPHOSGetter : public TObject {
   TClonesArray *            Digits(const char * name = 0)const  { 
     return dynamic_cast<TClonesArray*>(ReturnO("Digits", name)) ;   }
   //const AliPHOSDigit *  Digit(Int_t index) { return static_cast<const AliPHOSDigit *>(Digits()->At(index)) ;} !!! why no such method ?
-  const AliPHOSDigitizer *  Digitizer(const char * name = 0) const { 
-    return (const AliPHOSDigitizer*)(ReturnT("Digitizer", name)) ;   }
+  const TTask *           Digitizer(const char * name = 0) const { 
+    return ReturnT("Digitizer", name) ;   }
+  AliPHOSCalibrationDB * CalibrationDB(){return  fcdb; }
+  void ReadCalibrationDB(const char * name, const char * filename) ;
   
   //========== RecPoints =============
   TObjArray *                EmcRecPoints(const char * name = 0) {
@@ -232,6 +235,7 @@ private:
   TString        fSDigitsFileName ;      //!
   Bool_t         fFailed ;            //! set if file not opend or galice not found
   Int_t          fDebug ;             //! Debug level
+  AliRun *       fAlice ;             //! needed to read TreeK if in an other file than fHeaderFile
   Int_t          fNPrimaries ;        //! # of primaries  
   TObjArray *    fPrimaries ;         //! list of lists of primaries-for the case of mixing
   TFolder *      fModuleFolder ;      //!Folder that contains the modules 
@@ -242,6 +246,8 @@ private:
   TFolder *      fRecoFolder ;        //!Folder that contains the reconstructed objects (RecPoints, TrackSegments, RecParticles) 
   TFolder *      fQAFolder ;          //!Folder that contains the QA objects  
   TFolder *      fTasksFolder ;       //!Folder that contains the Tasks (sdigitizer, digitizer, reconstructioner)
+
+  AliPHOSCalibrationDB * fcdb ;       //!
    
   static AliPHOSGetter * fgObjGetter; // pointer to the unique instance of the singleton