LCOV - code coverage report
Current view: top level - EMCAL/EMCALbase - AliEMCALLoader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 90 114 78.9 %
Date: 2016-06-14 17:26:59 Functions: 21 22 95.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : //_________________________________________________________________________
      17             : //  The AliEMCALLoader gets the TClonesArray and TObjArray for reading
      18             : //  Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
      19             : //  method.
      20             : //  It also provides acces methods to the calibration and simulation OCDB parameters 
      21             : //
      22             : //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
      23             : //*--         Completely redesigned by Dmitri Peressounko March 2001  
      24             : //
      25             : //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
      26             : //*--         systematic usage of TFolders without changing the interface
      27             : // 
      28             : //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
      29             : //*--         and fit better in general ALICE scheme
      30             : //*-- GCB: Remove TClonesArrays and TObjArrays data members, they are created elsewhere.
      31             : //*--      Provide access to OCDB calibration and simulation parameters.          
      32             : //
      33             : //////////////////////////////////////////////////////////////////////////////
      34             : 
      35             : // --- ROOT system ---
      36             : #include "TMath.h"
      37             : #include "TTree.h"
      38             : // --- Standard library ---
      39             : 
      40             : // --- AliRoot header files ---
      41             : #include "AliEMCALLoader.h"
      42             : #include "AliLog.h"
      43             : #include "AliCDBLocal.h"
      44             : #include "AliCDBStorage.h"
      45             : #include "AliCDBManager.h"
      46             : #include "AliCDBEntry.h"
      47             : 
      48          42 :  ClassImp(AliEMCALLoader)
      49             :   
      50          42 : const TString         AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
      51          42 : const TString         AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
      52          42 : const TString         AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
      53             : 
      54             : AliEMCALCalibData*    AliEMCALLoader::fgCalibData = 0; //energy calibration data
      55             : AliEMCALCalibTime*    AliEMCALLoader::fgCalibTime = 0; //time calibration data
      56             : AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed   = 0; //dead map data
      57             : AliEMCALSimParam*     AliEMCALLoader::fgSimParam  = 0; //simulation parameters
      58             : AliEMCALRecParam*     AliEMCALLoader::fgRecParam  = 0; //reconstruction parameters
      59             : 
      60             : //____________________________________________________________________________ 
      61          13 : AliEMCALLoader::AliEMCALLoader()
      62          13 : : fDebug(0)
      63          65 : {
      64             :   //Default constructor for EMCAL Loader Class
      65             : 
      66          26 : }
      67             : 
      68             : //____________________________________________________________________________ 
      69             : AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
      70           2 :   : AliLoader(detname,eventfoldername), fDebug(0)
      71           5 : {
      72             :   //Specific constructor for EMCAL Loader class
      73             : 
      74           2 : }
      75             : 
      76             : //____________________________________________________________________________
      77             : AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
      78           2 :   : AliLoader(name,topfolder), fDebug(0)
      79           5 : {
      80             :   //Specific constructor for EMCAL Loader class
      81             : 
      82           2 : }
      83             : 
      84             : //____________________________________________________________________________ 
      85             : AliEMCALLoader::~AliEMCALLoader()
      86          90 : {
      87             :   // Disconnect trees and remove arrays
      88          30 :   if (TreeH())
      89           6 :     TreeH()->SetBranchAddress(fDetectorName,0);
      90             : //  if (TreeD())
      91             : //    TreeD()->SetBranchAddress(fDetectorName,0);
      92             : //  if (TreeS())
      93             : //    TreeS()->SetBranchAddress(fDetectorName,0);
      94             : //  if (TreeR())
      95             : //    TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
      96             :         
      97          15 :         Clean(fgkECASDigitsBranchName);
      98          15 :         Clean(fgkECADigitsBranchName);
      99          15 :         Clean(fgkECARecPointsBranchName);
     100             :         
     101          15 :         AliLoader::CleanFolders();
     102             :                 
     103          45 : }
     104             : 
     105             : //____________________________________________________________________________ 
     106             : AliEMCALCalibData* AliEMCALLoader::CalibData()
     107             : { 
     108             :   // Check if the instance of AliEMCALCalibData exists, if not, create it if 
     109             :   // the OCDB is available, and finally return it.
     110             :   
     111           3 :   if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     112             :     {
     113           1 :       AliCDBEntry *entry = (AliCDBEntry*) 
     114           1 :         AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
     115           2 :       if (entry) fgCalibData =  (AliEMCALCalibData*) entry->GetObject();
     116           1 :     }
     117             :   
     118           1 :   if(!fgCalibData)
     119           0 :     AliFatal("Calibration parameters not found in CDB!");
     120             :   
     121           1 :   return fgCalibData;
     122             :   
     123           0 : }
     124             : 
     125             : //____________________________________________________________________________ 
     126             : AliEMCALCalibTime* AliEMCALLoader::CalibTime()
     127             : { 
     128             :   // Check if the instance of AliEMCALCalibTime exists, if not, create it if 
     129             :   // the OCDB is available, and finally return it.
     130             :   
     131           3 :   if(!fgCalibTime && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     132             :   {
     133           1 :     AliCDBEntry *entry = (AliCDBEntry*) 
     134           1 :     AliCDBManager::Instance()->Get("EMCAL/Calib/Time");
     135           2 :     if (entry) fgCalibTime =  (AliEMCALCalibTime*) entry->GetObject();
     136           1 :   }
     137             :   
     138           1 :   if(!fgCalibTime)
     139           0 :     AliFatal("Calibration parameters not found in CDB!");
     140             :   
     141           1 :   return fgCalibTime;
     142             :   
     143           0 : }
     144             : 
     145             : 
     146             : //____________________________________________________________________________ 
     147             : AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
     148             : { 
     149             :         // Check if the instance of AliCaloCalibPedestal exists, if not, create it if 
     150             :         // the OCDB is available, and finally return it.
     151             :         
     152         653 :         if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     153             :     {
     154           1 :                 AliCDBEntry *entry = (AliCDBEntry*) 
     155           1 :                 AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
     156           2 :                 if (entry) fgCaloPed =  (AliCaloCalibPedestal*) entry->GetObject();
     157           1 :     }
     158             :         
     159         326 :         if(!fgCaloPed)
     160           0 :                 AliFatal("Pedestal info not found in CDB!");
     161             :         
     162         326 :         return fgCaloPed;
     163             :         
     164           0 : }
     165             : 
     166             : //____________________________________________________________________________ 
     167             : AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
     168             : { 
     169             :   // Check if the instance of AliEMCALSimParam exists, if not, create it if 
     170             :   // the OCDB is available, and finally return it.
     171             :   
     172          15 :   if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     173             :     {
     174           1 :       AliCDBEntry *entry = (AliCDBEntry*) 
     175           1 :       AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
     176           2 :       if (entry) fgSimParam =  (AliEMCALSimParam*) entry->GetObject();
     177             :       
     178           1 :     }
     179             :   
     180           7 :   if(!fgSimParam)
     181           0 :     AliFatal("Simulations parameters not found in CDB!");
     182             :   
     183           7 :   return fgSimParam;
     184             :   
     185           0 : }
     186             : 
     187             : 
     188             : //____________________________________________________________________________ 
     189             : AliEMCALRecParam* AliEMCALLoader::ReconstructionParameters(Int_t eventType = 0)
     190             : { 
     191             :   // Check if the instance of AliEMCALRecParam exists, if not, create it if 
     192             :   // the OCDB is available, and finally return it. 
     193             :   // The event type must be provided.
     194             :   
     195           0 :   if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
     196             :   {
     197           0 :     AliCDBEntry *entry = (AliCDBEntry*) 
     198           0 :     AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam");
     199           0 :     if (entry) fgRecParam =  (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(eventType);
     200             :     
     201           0 :   }
     202             :   
     203           0 :   if(!fgRecParam)
     204           0 :     AliFatal("Reconstruction parameters not found in CDB!");
     205             :   
     206           0 :   return fgRecParam;
     207             :   
     208           0 : }
     209             : 
     210             : 
     211             : //____________________________________________________________________________ 
     212             : Int_t AliEMCALLoader::GetEvent() 
     213             : {
     214             :   //Method to load all of the data
     215             :   //members of the EMCAL for a given
     216             :   //event from the Trees
     217             : 
     218         216 :   AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
     219             :   
     220             :   // *** Hits ***
     221             :   // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested.
     222             :   // together with AliEveEMCALData
     223             :         
     224             :   // *** SDigits ***
     225             :   // Initialize the SDigits TClonesArray, only if it did not existed before
     226         108 :   MakeSDigitsArray();
     227             :   
     228         108 :   TTree *treeS = TreeS();
     229         108 :   if (treeS) {
     230          21 :     TBranch * branchS = treeS->GetBranch(fDetectorName);
     231             :     
     232             :     // Reset SDigits array and branch
     233          21 :     branchS->ResetAddress();
     234          21 :     TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits();
     235          42 :     if (sdigits) sdigits->Clear("C");
     236             :     
     237          21 :     branchS->SetAddress(&sdigits);
     238          21 :     branchS->GetEntry(0);
     239          21 :   }
     240             :   
     241             :   // *** Digits ***
     242             :   // Initialize the Digits TClonesArray, only if it did not existed before
     243         108 :   MakeDigitsArray();
     244             :   
     245         108 :   TTree *treeD = TreeD();
     246         108 :   if (treeD) {
     247           7 :     TBranch * branchD = treeD->GetBranch(fDetectorName);
     248             :     
     249             :     // Reset Digits array and branch
     250           7 :     branchD->ResetAddress();
     251           7 :     TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits();
     252          14 :     if (digits) digits->Clear("C");
     253             :     
     254           7 :     branchD->SetAddress(&digits);
     255           7 :     branchD->GetEntry(0);
     256           7 :   }
     257             :   
     258             :   // *** RecPoints ***  
     259             :   // Initialize the RecPoints TObjArray, only if it did not existed before
     260         108 :   MakeRecPointsArray();
     261             :   
     262         108 :   TTree *treeR = TreeR();
     263         108 :   if (treeR) {
     264           0 :     TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
     265             :     
     266             :     // Reset RecPoints array and branch
     267           0 :     branchR->ResetAddress();
     268           0 :     TObjArray* rp = const_cast<AliEMCALLoader *>(this)->RecPoints();
     269           0 :     if (rp) rp->Clear();
     270             :     
     271           0 :     branchR->SetAddress(&rp);
     272           0 :     branchR->GetEntry(0);
     273           0 :   }
     274             :   
     275         108 :   return 0;
     276             : }
     277             : 
     278             : //____________________________________________________________________________
     279             : void AliEMCALLoader::MakeSDigitsArray(){
     280             :   // Add SDigits array to the data folder
     281         216 :   if (SDigits()) return;
     282           9 :   TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0);
     283           9 :   sdigits->SetName(fgkECASDigitsBranchName);
     284           9 :   GetDetectorDataFolder()->Add(sdigits);
     285         117 : }
     286             : 
     287             : //____________________________________________________________________________
     288             : void AliEMCALLoader::MakeDigitsArray(){
     289             :   // Add Digits array to the data folder
     290         216 :   if (Digits()) return;
     291           9 :   TClonesArray* digits = new TClonesArray("AliEMCALDigit",0);
     292           9 :   digits->SetName(fgkECADigitsBranchName);
     293           9 :   GetDetectorDataFolder()->Add(digits);
     294         117 : }
     295             : 
     296             : //____________________________________________________________________________
     297             : void AliEMCALLoader::MakeRecPointsArray(){
     298             :   // Add RecPoints array to the data folder
     299         216 :   if (RecPoints()) return;
     300           9 :   TObjArray* rp = new TObjArray(0);
     301           9 :   rp->SetName(fgkECARecPointsBranchName);
     302           9 :   GetDetectorDataFolder()->Add(rp);
     303         117 : }

Generated by: LCOV version 1.11