1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
19 // The AliEMCALLoader gets the TClonesArray and TObjArray for reading
20 // Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
22 // It also provides acces methods to the calibration and simulation OCDB parameters
24 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
25 //*-- Completely redesigned by Dmitri Peressounko March 2001
27 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
28 //*-- systematic usage of TFolders without changing the interface
30 //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
31 //*-- and fit better in general ALICE scheme
32 //*-- GCB: Remove TClonesArrays and TObjArrays data members, they are created elsewhere.
33 //*-- Provide access to OCDB calibration and simulation parameters.
35 //////////////////////////////////////////////////////////////////////////////
37 // --- ROOT system ---
40 // --- Standard library ---
42 // --- AliRoot header files ---
43 #include "AliEMCALLoader.h"
45 #include "AliCDBLocal.h"
46 #include "AliCDBStorage.h"
47 #include "AliCDBManager.h"
48 #include "AliCDBEntry.h"
49 #include "AliEMCALHit.h"
51 ClassImp(AliEMCALLoader)
53 const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
54 const TString AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
55 const TString AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
56 const TString AliEMCALLoader::fgkECAHitsBranchName("HITS");//Name for branch with ECA Hits
58 AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibration data
59 //AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data
60 AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters
62 //____________________________________________________________________________
63 AliEMCALLoader::AliEMCALLoader()
64 : fDebug(0), fTempArr(0x0)
66 //Default constructor for EMCAL Loader Class
67 fTempArr = new TClonesArray("AliEMCALHit",0);
71 //____________________________________________________________________________
72 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
73 : AliLoader(detname,eventfoldername), fDebug(0), fTempArr(0x0)
75 //Specific constructor for EMCAL Loader class
76 fTempArr = new TClonesArray("AliEMCALHit",0);
80 //____________________________________________________________________________
81 AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
82 : AliLoader(name,topfolder), fDebug(0), fTempArr(0x0)
84 //Specific constructor for EMCAL Loader class
85 fTempArr = new TClonesArray("AliEMCALHit",0);
89 //____________________________________________________________________________
90 AliEMCALLoader::~AliEMCALLoader()
92 // Disconnect trees and remove arrays
94 // TreeH()->SetBranchAddress(fDetectorName,0);
96 // TreeD()->SetBranchAddress(fDetectorName,0);
98 // TreeS()->SetBranchAddress(fDetectorName,0);
100 // TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
102 Clean(fgkECAHitsBranchName);
103 Clean(fgkECASDigitsBranchName);
104 Clean(fgkECADigitsBranchName);
105 Clean(fgkECARecPointsBranchName);
107 AliLoader::CleanFolders();
116 //____________________________________________________________________________
117 AliEMCALCalibData* AliEMCALLoader::CalibData()
119 // Check if the instance of AliEMCALCalibData exists, if not, create it if
120 // the OCDB is available, and finally return it.
122 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
124 AliCDBEntry *entry = (AliCDBEntry*)
125 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
126 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
130 AliFatal("Calibration parameters not found in CDB!");
136 //____________________________________________________________________________
137 //AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
139 // // Check if the instance of AliCaloCalibPedestal exists, if not, create it if
140 // // the OCDB is available, and finally return it.
142 // if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
144 // AliCDBEntry *entry = (AliCDBEntry*)
145 // AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
146 // if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
150 // AliFatal("Pedestal info not found in CDB!");
156 //____________________________________________________________________________
157 AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
159 // Check if the instance of AliEMCALSimParam exists, if not, create it if
160 // the OCDB is available, and finally return it.
162 if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
164 AliCDBEntry *entry = (AliCDBEntry*)
165 AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
166 if (entry) fgSimParam = (AliEMCALSimParam*) entry->GetObject();
171 AliFatal("Simulations parameters not found in CDB!");
177 //____________________________________________________________________________
178 Int_t AliEMCALLoader::GetEvent()
180 //Method to load all of the data
181 //members of the EMCAL for a given
182 //event from the Trees
184 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
187 // Initialize the Hits TClonesArray, only if it did not existed before
190 TTree *treeH = TreeH();
192 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
194 TBranch * branchH = treeH->GetBranch(fDetectorName);
195 branchH->SetAddress(&fTempArr);
196 TClonesArray* hits = const_cast<AliEMCALLoader *>(this)->Hits();
197 if (hits) hits->Clear();
198 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
199 branchH->GetEntry(iEnt);
200 Int_t nHit = fTempArr->GetEntriesFast();
201 for (Int_t iHit = 0; iHit < nHit; iHit++) {
202 new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)fTempArr->At(iHit)));
206 branchH->ResetAddress();
213 // Initialize the SDigits TClonesArray, only if it did not existed before
216 TTree *treeS = TreeS();
218 TBranch * branchS = treeS->GetBranch(fDetectorName);
220 // Reset SDigits array and branch
221 branchS->ResetAddress();
222 TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits();
223 if (sdigits) sdigits->Clear();
225 branchS->SetAddress(&sdigits);
226 branchS->GetEntry(0);
230 // Initialize the Digits TClonesArray, only if it did not existed before
233 TTree *treeD = TreeD();
235 TBranch * branchD = treeD->GetBranch(fDetectorName);
237 // Reset Digits array and branch
238 branchD->ResetAddress();
239 TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits();
240 if (digits) digits->Clear();
242 branchD->SetAddress(&digits);
243 branchD->GetEntry(0);
247 // Initialize the RecPoints TObjArray, only if it did not existed before
248 MakeRecPointsArray();
250 TTree *treeR = TreeR();
252 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
254 // Reset RecPoints array and branch
255 branchR->ResetAddress();
256 TObjArray* rp = const_cast<AliEMCALLoader *>(this)->RecPoints();
259 branchR->SetAddress(&rp);
260 branchR->GetEntry(0);
266 //____________________________________________________________________________
267 void AliEMCALLoader::MakeHitsArray(){
268 // Add Hits array to the data folder
270 TClonesArray* hits = new TClonesArray("AliEMCALHit",0);
271 hits->SetName(fgkECAHitsBranchName);
272 GetDetectorDataFolder()->Add(hits);
275 //____________________________________________________________________________
276 void AliEMCALLoader::MakeSDigitsArray(){
277 // Add SDigits array to the data folder
278 if (SDigits()) return;
279 TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0);
280 sdigits->SetName(fgkECASDigitsBranchName);
281 GetDetectorDataFolder()->Add(sdigits);
284 //____________________________________________________________________________
285 void AliEMCALLoader::MakeDigitsArray(){
286 // Add Digits array to the data folder
287 if (Digits()) return;
288 TClonesArray* digits = new TClonesArray("AliEMCALDigit",0);
289 digits->SetName(fgkECADigitsBranchName);
290 GetDetectorDataFolder()->Add(digits);
293 //____________________________________________________________________________
294 void AliEMCALLoader::MakeRecPointsArray(){
295 // Add RecPoints array to the data folder
296 if (RecPoints()) return;
297 TObjArray* rp = new TObjArray(0);
298 rp->SetName(fgkECARecPointsBranchName);
299 GetDetectorDataFolder()->Add(rp);