]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSClusterizerv1.cxx
Reading calibration from CDB (Boris Polichtchouk)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizerv1.cxx
index 858912357280e4d51827ba268588d63879ebab0f..d47ad3855f02189cf804e4caedc1bf246dad3203 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.82  2005/09/02 15:43:13  kharlov
+ * Add comments in GetCalibrationParameters and Calibrate
+ *
+ * Revision 1.81  2005/09/02 14:32:07  kharlov
+ * Calibration of raw data
+ *
+ * Revision 1.80  2005/08/24 15:31:36  kharlov
+ * Setting raw digits flag
+ *
+ * Revision 1.79  2005/07/25 15:53:53  kharlov
+ * Read raw data
+ *
+ * Revision 1.78  2005/05/28 14:19:04  schutz
+ * Compilation warnings fixed by T.P.
+ *
  */
 
 //*-- Author: Yves Schutz (SUBATECH)  & Dmitri Peressounko (SUBATECH & Kurchatov Institute)
@@ -67,6 +82,8 @@
 #include "AliPHOSDigit.h"
 #include "AliPHOSDigitizer.h"
 #include "AliPHOSCalibrationDB.h"
+#include "AliCDBStorage.h"
+#include "AliCDBLocal.h"
 
 ClassImp(AliPHOSClusterizerv1)
   
@@ -103,11 +120,26 @@ const TString AliPHOSClusterizerv1::BranchName() const
 }
  
 //____________________________________________________________________________
-Float_t  AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId) const
+Float_t  AliPHOSClusterizerv1::Calibrate(Int_t amp, Int_t absId)
 {  
-  //To be replaced later by the method, reading individual parameters from the database
-  if(fCalibrationDB){
-    return fCalibrationDB->Calibrate(amp,absId) ;
+  // Convert digitized amplitude into energy.
+  // Calibration parameters are taken from calibration data base for raw data,
+  // or from digitizer parameters for simulated data.
+
+  if(fCalibData){
+    Int_t relId[4];
+    AliPHOSGetter *gime = AliPHOSGetter::Instance();
+    gime->PHOSGeometry()->AbsToRelNumbering(absId,relId) ;
+    Int_t   module = relId[0];
+    Int_t   column = relId[3];
+    Int_t   row    = relId[2];
+    if(absId <= fEmcCrystals) { //calibrate as EMC 
+      fADCchanelEmc   = fCalibData->GetADCchannelEmc (module,column,row);
+      fADCpedestalEmc = fCalibData->GetADCpedestalEmc(module,column,row);
+      return fADCpedestalEmc + amp*fADCchanelEmc ;        
+    }
+    else //calibrate as CPV, not implemented yet
+      return 0;
   }
   else{ //simulation
     if(absId <= fEmcCrystals) //calibrate as EMC 
@@ -133,8 +165,13 @@ void AliPHOSClusterizerv1::Exec(Option_t *option)
     return ;
   }
 
-  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
   GetCalibrationParameters() ;
+
+  AliPHOSGetter * gime = AliPHOSGetter::Instance() ; 
+  if (fRawReader == 0)
+    gime->SetRawDigits(kFALSE);
+  else
+    gime->SetRawDigits(kTRUE);
   
   if (fLastEvent == -1) 
     fLastEvent = gime->MaxEvent() - 1 ;
@@ -144,7 +181,10 @@ void AliPHOSClusterizerv1::Exec(Option_t *option)
 
   Int_t ievent ;
   for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
-    gime->Event(ievent, "D");
+    if (fRawReader == 0)
+      gime->Event(ievent    ,"D"); // Read digits from simulated data
+    else
+      gime->Event(fRawReader,"W"); // Read digits from raw data
     
     fNumberOfEmcClusters  = fNumberOfCpvClusters  = 0 ;
     
@@ -271,21 +311,30 @@ Bool_t AliPHOSClusterizerv1::FindFit(AliPHOSEmcRecPoint * emcRP, AliPHOSDigit **
 //____________________________________________________________________________
 void AliPHOSClusterizerv1::GetCalibrationParameters() 
 {
+  // Set calibration parameters:
+  // if calibration database exists, they are read from database,
+  // otherwise, they are taken from digitizer.
+  //
+  // It is a user responsilibity to open CDB before reconstruction:
+  // AliCDBLocal *loc = new AliCDBLocal("CalibDB");
 
   AliPHOSGetter * gime = AliPHOSGetter::Instance();
-  if(gime->IsRawDigits()){
-    fCalibrationDB = gime->CalibrationDB();    
-  }
-  else{
-    if ( !gime->Digitizer() ) 
-      gime->LoadDigitizer();
-    AliPHOSDigitizer * dig = gime->Digitizer(); 
-    fADCchanelEmc   = dig->GetEMCchannel() ;
-    fADCpedestalEmc = dig->GetEMCpedestal();
+
+  if(AliCDBStorage::Instance())
+    fCalibData = (AliPHOSCalibData*)AliCDBStorage::Instance()
+      ->Get("PHOS/Calib/GainFactors_and_Pedestals",gAlice->GetRunNumber());
+
+  if(!fCalibData)
+    {
+      if ( !gime->Digitizer() ) 
+       gime->LoadDigitizer();
+      AliPHOSDigitizer * dig = gime->Digitizer(); 
+      fADCchanelEmc   = dig->GetEMCchannel() ;
+      fADCpedestalEmc = dig->GetEMCpedestal();
     
-    fADCchanelCpv   = dig->GetCPVchannel() ;
-    fADCpedestalCpv = dig->GetCPVpedestal() ; 
-  }  
+      fADCchanelCpv   = dig->GetCPVchannel() ;
+      fADCpedestalCpv = dig->GetCPVpedestal() ; 
+    }
 }
 
 //____________________________________________________________________________
@@ -337,7 +386,7 @@ void AliPHOSClusterizerv1::InitParameters()
 
   fWrite                   = kTRUE ;
 
-  fCalibrationDB           = 0 ;
+  fCalibData               = 0 ;
 
   SetEventRange(0,-1) ;
 }