]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALLoader.cxx
adding first sketch of a DCS publisher component for global HLT data points
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
index 3d4320bed1be8c5a7fd6b34f831987561fdca2e5..672a78889891d9aca0fc808afe30bf23ed4e175c 100644 (file)
@@ -39,9 +39,8 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 
-
 // --- ROOT system ---
-
+#include "TMath.h"
 #include "TTree.h"
 
 // --- Standard library ---
 #include "AliCDBLocal.h"
 #include "AliCDBStorage.h"
 #include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliEMCALHit.h"
 
 ClassImp(AliEMCALLoader)
   
-const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
-AliEMCALCalibData* AliEMCALLoader::fCalibData = 0; //calibation data
+const TString         AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
+AliEMCALCalibData*    AliEMCALLoader::fgCalibData = 0; //calibration data
+AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
+AliEMCALSimParam*     AliEMCALLoader::fgSimParam  = 0; //simulation parameters
 
 //____________________________________________________________________________ 
 AliEMCALLoader::AliEMCALLoader()
+  : fDebug(0),
+    fHits(0),
+    fDigits(0),
+    fSDigits(0),
+    fRecPoints(0)
 {
+  //Default constructor for EMCAL Loader Class
+
   fDebug = 0;
   fHits = new TClonesArray("AliEMCALHit");
   fDigits = new TClonesArray("AliEMCALDigit");
@@ -69,14 +79,27 @@ AliEMCALLoader::AliEMCALLoader()
 }
 
 //____________________________________________________________________________ 
-AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername):
-  AliLoader(detname,eventfoldername)
+AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
+  : AliLoader(detname,eventfoldername),
+    fDebug(0),
+    fHits(new TClonesArray("AliEMCALHit")),
+    fDigits(new TClonesArray("AliEMCALDigit")),
+    fSDigits(new TClonesArray("AliEMCALDigit")),
+    fRecPoints(new TObjArray())
 {
-  fDebug=0;
-  fHits = new TClonesArray("AliEMCALHit");
-  fDigits = new TClonesArray("AliEMCALDigit");
-  fSDigits = new TClonesArray("AliEMCALDigit");
-  fRecPoints = new TObjArray();
+  //Specific constructor for EMCAL Loader class
+}
+
+//____________________________________________________________________________
+AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
+  : AliLoader(name,topfolder),
+    fDebug(0),
+    fHits(new TClonesArray("AliEMCALHit")),
+    fDigits(new TClonesArray("AliEMCALDigit")),
+    fSDigits(new TClonesArray("AliEMCALDigit")),
+    fRecPoints(new TObjArray())
+{
+  //Specific constructor for EMCAL Loader class
 }
 
 //____________________________________________________________________________ 
@@ -91,7 +114,10 @@ AliEMCALLoader::~AliEMCALLoader()
     TreeS()->SetBranchAddress(fDetectorName,0);
   if (TreeR())
     TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
-  delete fHits;
+  if (fHits) {
+    fHits->Delete();
+    delete fHits;
+  }
   delete fDigits;
   delete fSDigits;
   delete fRecPoints;
@@ -100,16 +126,62 @@ AliEMCALLoader::~AliEMCALLoader()
 //____________________________________________________________________________ 
 AliEMCALCalibData* AliEMCALLoader::CalibData()
 { 
-  //Get the Calibration data list
+  // Check if the instance of AliEMCALCalibData exists, if not, create it if 
+  // the OCDB is available, and finally return it.
 
-  if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) ) {
-    fCalibData=0x0;
-    Warning("CalibData","Calibration DB is not initiated!");
-    return fCalibData;
-  }
+  if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+      AliCDBEntry *entry = (AliCDBEntry*) 
+       AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
+      if (entry) fgCalibData =  (AliEMCALCalibData*) entry->GetObject();
+    }
+  
+  if(!fgCalibData)
+    AliFatal("Calibration parameters not found in CDB!");
+  
+  return fgCalibData;
+  
+}
 
- return fCalibData;
+//____________________________________________________________________________ 
+AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
+{ 
+       // Check if the instance of AliCaloCalibPedestal exists, if not, create it if 
+       // the OCDB is available, and finally return it.
+       
+       if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
+               if (entry) fgCaloPed =  (AliCaloCalibPedestal*) entry->GetObject();
+    }
+       
+       if(!fgCaloPed)
+               AliFatal("Pedestal info not found in CDB!");
+       
+       return fgCaloPed;
+       
+}
 
+//____________________________________________________________________________ 
+AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
+{ 
+       // Check if the instance of AliEMCALSimParam exists, if not, create it if 
+       // the OCDB is available, and finally return it.
+       
+       if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
+    {
+               AliCDBEntry *entry = (AliCDBEntry*) 
+               AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
+               if (entry) fgSimParam =  (AliEMCALSimParam*) entry->GetObject();
+       
+    }
+       
+       if(!fgSimParam)
+               AliFatal("Simulations parameters not found in CDB!");
+
+       return fgSimParam;
+       
 }
 
 //____________________________________________________________________________ 
@@ -129,8 +201,8 @@ Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
   if (CalibData() == 0)
     Warning("CalibrateRaw","Calibration DB is not initiated!");
 
-  Float_t gainFactor = 0.0015; // width of one ADC channel in GeV
-  Float_t pedestal   = 0.005;  // pedestals
+  Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
+  Float_t pedestal   = 0.009;//0.005;  // pedestals
 
   if(CalibData()) {
     gainFactor = CalibData()->GetADCchannel (module,column,row);
@@ -141,42 +213,77 @@ Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
   return amp;
 }
 
-
 //____________________________________________________________________________ 
-Int_t AliEMCALLoader::GetEvent() {
-  AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
+Int_t AliEMCALLoader::GetEvent() 
+{
+  //Method to load all of the data
+  //members of the EMCAL for a given
+  //event from the Trees
 
+  AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
+  
   // Now connect and fill TClonesArray
 
   // Hits
-  TTree *treeH = TreeH();
-  if (treeH) {
-    treeH->SetBranchAddress(fDetectorName,&fHits);
-    if (treeH->GetEntries() > 1)
-      AliWarning("Multiple arrays in treeH no longer supported");
-    treeH->GetEvent(0);
-  }
-
-  // SDigits
-  TTree *treeS = TreeS();
-  if (treeS) {
-    treeS->SetBranchAddress(fDetectorName,&fSDigits);
-    treeS->GetEvent(0);
-  }
-
-  // Digits
-  TTree *treeD = TreeD();
-  if (treeD) {
-    treeD->SetBranchAddress(fDetectorName,&fDigits);
-    treeD->GetEvent(0);
-  }
-
-  // RecPoints
-  TTree *treeR = TreeR();
-  if (treeR) {
-    treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints);
-    treeR->GetEvent(0);
-  }
+   TTree *treeH = TreeH();
+   
+   if (treeH) {
+     Int_t nEnt = treeH->GetEntries();  // TreeH has array of hits for every primary
+     fHits->Clear();
+     Int_t index = 0;
+     TClonesArray *tempArr = 0x0;
+     TBranch * branchH = treeH->GetBranch(fDetectorName);
+     branchH->SetAddress(&tempArr);
+     for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
+       treeH->GetEntry(iEnt);
+       Int_t nHit = tempArr->GetEntriesFast();
+       for (Int_t iHit = 0; iHit < nHit; iHit++) {
+        new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
+        index++;
+       }
+     }
+     branchH->ResetAddress();
+     if (tempArr) {
+       tempArr->Delete();
+       delete tempArr;
+     }
+   }
+  
+   // SDigits
+   TTree *treeS = TreeS();
+   if (treeS) {
+     TBranch * branchS = treeS->GetBranch(fDetectorName);
+     branchS->ResetAddress();
+     if (fSDigits) {
+       fSDigits->Clear();
+     }
+     branchS->SetAddress(&fSDigits);
+     treeS->GetEvent(0);
+   }
+   
+   // Digits
+   TTree *treeD = TreeD();
+   if (treeD) {
+     TBranch * branchD = treeD->GetBranch(fDetectorName);
+     branchD->ResetAddress();
+     if (fDigits) {
+       fDigits->Clear();
+     }
+     branchD->SetAddress(&fDigits);
+     treeD->GetEvent(0);
+   }
 
-  return 0;
+   // RecPoints
+   TTree *treeR = TreeR();
+   if (treeR) {
+     TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
+     branchR->ResetAddress();
+     if (fRecPoints) {
+       fRecPoints->Clear();
+     }
+     branchR->SetAddress(&fRecPoints);
+     treeR->GetEvent(0);
+   }
+   
+   return 0;
 }