added detector acceptance effect in AliFlowEventSimple + removed AliFlowEventSimpleMa...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.cxx
CommitLineData
88cb7938 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
803d1ab0 16/* $Id$ */
88cb7938 17
18//_________________________________________________________________________
64c98165 19// The AliEMCALLoader gets the TClonesArray and TObjArray for reading
5dee926e 20// Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
21// method.
64c98165 22// It also provides acces methods to the calibration and simulation OCDB parameters
5dee926e 23//
88cb7938 24//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
25//*-- Completely redesigned by Dmitri Peressounko March 2001
26//
27//*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
5dee926e 28//*-- systematic usage of TFolders without changing the interface
29//
30//*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
31//*-- and fit better in general ALICE scheme
64c98165 32//*-- GCB: Remove TClonesArrays and TObjArrays data members, they are created elsewhere.
33//*-- Provide access to OCDB calibration and simulation parameters.
5dee926e 34//
88cb7938 35//////////////////////////////////////////////////////////////////////////////
36
88cb7938 37// --- ROOT system ---
090026bf 38#include "TMath.h"
88cb7938 39#include "TTree.h"
88cb7938 40// --- Standard library ---
88cb7938 41
42// --- AliRoot header files ---
a9bbb414 43#include "AliEMCALLoader.h"
44#include "AliLog.h"
f565d89d 45#include "AliCDBLocal.h"
46#include "AliCDBStorage.h"
47#include "AliCDBManager.h"
1f337798 48#include "AliCDBEntry.h"
825fa573 49#include "AliEMCALHit.h"
88cb7938 50
64c98165 51 ClassImp(AliEMCALLoader)
d64c959b 52
6569f329 53const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
64c98165 54const TString AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
55const TString AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
56const TString AliEMCALLoader::fgkECAHitsBranchName("HITS");//Name for branch with ECA Hits
57
6569f329 58AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibration data
64c98165 59//AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data
6569f329 60AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters
d64c959b 61
88cb7938 62//____________________________________________________________________________
63AliEMCALLoader::AliEMCALLoader()
64c98165 64 : fDebug(0)
d64c959b 65{
14ce0a6e 66 //Default constructor for EMCAL Loader Class
64c98165 67
d64c959b 68}
69
88cb7938 70//____________________________________________________________________________
18a21c7c 71AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
64c98165 72 : AliLoader(detname,eventfoldername), fDebug(0)
88cb7938 73{
14ce0a6e 74 //Specific constructor for EMCAL Loader class
88cb7938 75}
88cb7938 76
0a4cb131 77//____________________________________________________________________________
6b299d9e 78AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
64c98165 79 : AliLoader(name,topfolder), fDebug(0)
6b299d9e 80{
81 //Specific constructor for EMCAL Loader class
6b299d9e 82}
83
d64c959b 84//____________________________________________________________________________
88cb7938 85AliEMCALLoader::~AliEMCALLoader()
86{
5dee926e 87 // Disconnect trees and remove arrays
88 if (TreeH())
89 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);
5dee926e 96}
97
98//____________________________________________________________________________
f565d89d 99AliEMCALCalibData* AliEMCALLoader::CalibData()
100{
1f337798 101 // Check if the instance of AliEMCALCalibData exists, if not, create it if
102 // the OCDB is available, and finally return it.
64c98165 103
1f337798 104 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
105 {
106 AliCDBEntry *entry = (AliCDBEntry*)
107 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
108 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
109 }
110
111 if(!fgCalibData)
112 AliFatal("Calibration parameters not found in CDB!");
78cbbabb 113
14ce0a6e 114 return fgCalibData;
78cbbabb 115
f565d89d 116}
117
40164976 118//____________________________________________________________________________
64c98165 119//AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
120//{
121// // Check if the instance of AliCaloCalibPedestal exists, if not, create it if
122// // the OCDB is available, and finally return it.
123//
124// if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
125// {
126// AliCDBEntry *entry = (AliCDBEntry*)
127// AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
128// if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
129// }
130//
131// if(!fgCaloPed)
132// AliFatal("Pedestal info not found in CDB!");
133//
134// return fgCaloPed;
135//
136//}
40164976 137
6569f329 138//____________________________________________________________________________
139AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
140{
64c98165 141 // Check if the instance of AliEMCALSimParam exists, if not, create it if
142 // the OCDB is available, and finally return it.
143
144 if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
6569f329 145 {
64c98165 146 AliCDBEntry *entry = (AliCDBEntry*)
147 AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
148 if (entry) fgSimParam = (AliEMCALSimParam*) entry->GetObject();
149
6569f329 150 }
f565d89d 151
64c98165 152 if(!fgSimParam)
153 AliFatal("Simulations parameters not found in CDB!");
154
155 return fgSimParam;
156
f565d89d 157}
158
f565d89d 159//____________________________________________________________________________
14ce0a6e 160Int_t AliEMCALLoader::GetEvent()
161{
162 //Method to load all of the data
163 //members of the EMCAL for a given
164 //event from the Trees
64c98165 165
ea6ddc2c 166 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
167
64c98165 168 // *** Hits ***
169 // Initialize the Hits TClonesArray, only if it did not existed before
170 MakeHitsArray();
171
172 TTree *treeH = TreeH();
173 if (treeH) {
174 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
175 Int_t index = 0;
176 TClonesArray *tempArr = 0x0;
177 TBranch * branchH = treeH->GetBranch(fDetectorName);
178 branchH->SetAddress(&tempArr);
179 TClonesArray* hits = const_cast<AliEMCALLoader *>(this)->Hits();
180 if (hits) hits->Clear();
181 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
182 branchH->GetEntry(iEnt);
183 Int_t nHit = tempArr->GetEntriesFast();
184 for (Int_t iHit = 0; iHit < nHit; iHit++) {
185 new ((*hits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
186 index++;
187 }
188 }
189 branchH->ResetAddress();
190 if (tempArr) {
191 tempArr->Delete();
192 delete tempArr;
193 }
194 }
195
196 // *** SDigits ***
197 // Initialize the SDigits TClonesArray, only if it did not existed before
198 MakeSDigitsArray();
199
200 TTree *treeS = TreeS();
201 if (treeS) {
202 TBranch * branchS = treeS->GetBranch(fDetectorName);
203
204 // Reset SDigits array and branch
205 branchS->ResetAddress();
206 TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits();
207 if (sdigits) sdigits->Clear();
208
209 branchS->SetAddress(&sdigits);
210 branchS->GetEntry(0);
211 }
212
213 // *** Digits ***
214 // Initialize the Digits TClonesArray, only if it did not existed before
215 MakeDigitsArray();
216
217 TTree *treeD = TreeD();
218 if (treeD) {
219 TBranch * branchD = treeD->GetBranch(fDetectorName);
220
221 // Reset Digits array and branch
222 branchD->ResetAddress();
223 TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits();
224 if (digits) digits->Clear();
225
226 branchD->SetAddress(&digits);
227 branchD->GetEntry(0);
228 }
229
230 // *** RecPoints ***
231 // Initialize the RecPoints TObjArray, only if it did not existed before
232 MakeRecPointsArray();
825fa573 233
64c98165 234 TTree *treeR = TreeR();
235 if (treeR) {
236 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
237
238 // Reset RecPoints array and branch
239 branchR->ResetAddress();
240 TObjArray* rp = const_cast<AliEMCALLoader *>(this)->RecPoints();
241 if (rp) rp->Clear();
242
243 branchR->SetAddress(&rp);
244 branchR->GetEntry(0);
245 }
246
247 return 0;
248}
ea6ddc2c 249
64c98165 250//____________________________________________________________________________
251void AliEMCALLoader::MakeHitsArray(){
252 // Add Hits array to the data folder
253 if (Hits()) return;
254 TClonesArray* hits = new TClonesArray("AliEMCALHit",0);
255 hits->SetName(fgkECAHitsBranchName);
256 GetDetectorDataFolder()->Add(hits);
257}
258
259//____________________________________________________________________________
260void AliEMCALLoader::MakeSDigitsArray(){
261 // Add SDigits array to the data folder
262 if (SDigits()) return;
263 TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0);
264 sdigits->SetName(fgkECASDigitsBranchName);
265 GetDetectorDataFolder()->Add(sdigits);
266}
267
268//____________________________________________________________________________
269void AliEMCALLoader::MakeDigitsArray(){
270 // Add Digits array to the data folder
271 if (Digits()) return;
272 TClonesArray* digits = new TClonesArray("AliEMCALDigit",0);
273 digits->SetName(fgkECADigitsBranchName);
274 GetDetectorDataFolder()->Add(digits);
275}
276
277//____________________________________________________________________________
278void AliEMCALLoader::MakeRecPointsArray(){
279 // Add RecPoints array to the data folder
280 if (RecPoints()) return;
281 TObjArray* rp = new TObjArray(0);
282 rp->SetName(fgkECARecPointsBranchName);
283 GetDetectorDataFolder()->Add(rp);
88cb7938 284}