]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALLoader.cxx
Added fit macro from M. Putis
[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"
88cb7938 49
64c98165 50 ClassImp(AliEMCALLoader)
d64c959b 51
6569f329 52const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
64c98165 53const TString AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits
54const TString AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits
64c98165 55
6569f329 56AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibration data
64c98165 57//AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data
6569f329 58AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters
d64c959b 59
88cb7938 60//____________________________________________________________________________
61AliEMCALLoader::AliEMCALLoader()
e44d51bd 62: fDebug(0)
d64c959b 63{
14ce0a6e 64 //Default constructor for EMCAL Loader Class
0c978ad5 65
d64c959b 66}
67
88cb7938 68//____________________________________________________________________________
18a21c7c 69AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
e44d51bd 70 : AliLoader(detname,eventfoldername), fDebug(0)
88cb7938 71{
14ce0a6e 72 //Specific constructor for EMCAL Loader class
0c978ad5 73
88cb7938 74}
88cb7938 75
6b299d9e 76//____________________________________________________________________________
77AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
e44d51bd 78 : AliLoader(name,topfolder), fDebug(0)
6b299d9e 79{
80 //Specific constructor for EMCAL Loader class
0c978ad5 81
6b299d9e 82}
83
d64c959b 84//____________________________________________________________________________
88cb7938 85AliEMCALLoader::~AliEMCALLoader()
86{
5dee926e 87 // Disconnect trees and remove arrays
e44d51bd 88 if (TreeH())
89 TreeH()->SetBranchAddress(fDetectorName,0);
0c978ad5 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
0c978ad5 97 Clean(fgkECASDigitsBranchName);
98 Clean(fgkECADigitsBranchName);
99 Clean(fgkECARecPointsBranchName);
100
101 AliLoader::CleanFolders();
e44d51bd 102
5dee926e 103}
104
f565d89d 105//____________________________________________________________________________
106AliEMCALCalibData* AliEMCALLoader::CalibData()
107{
1f337798 108 // Check if the instance of AliEMCALCalibData exists, if not, create it if
109 // the OCDB is available, and finally return it.
64c98165 110
1f337798 111 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
112 {
113 AliCDBEntry *entry = (AliCDBEntry*)
114 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
115 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
116 }
117
118 if(!fgCalibData)
119 AliFatal("Calibration parameters not found in CDB!");
78cbbabb 120
14ce0a6e 121 return fgCalibData;
78cbbabb 122
f565d89d 123}
124
40164976 125//____________________________________________________________________________
64c98165 126//AliCaloCalibPedestal* AliEMCALLoader::PedestalData()
127//{
128// // Check if the instance of AliCaloCalibPedestal exists, if not, create it if
129// // the OCDB is available, and finally return it.
130//
131// if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet()))
132// {
133// AliCDBEntry *entry = (AliCDBEntry*)
134// AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals");
135// if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject();
136// }
137//
138// if(!fgCaloPed)
139// AliFatal("Pedestal info not found in CDB!");
140//
141// return fgCaloPed;
142//
143//}
40164976 144
6569f329 145//____________________________________________________________________________
146AliEMCALSimParam* AliEMCALLoader::SimulationParameters()
147{
64c98165 148 // Check if the instance of AliEMCALSimParam exists, if not, create it if
149 // the OCDB is available, and finally return it.
150
151 if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet()))
6569f329 152 {
64c98165 153 AliCDBEntry *entry = (AliCDBEntry*)
154 AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam");
155 if (entry) fgSimParam = (AliEMCALSimParam*) entry->GetObject();
156
6569f329 157 }
f565d89d 158
64c98165 159 if(!fgSimParam)
160 AliFatal("Simulations parameters not found in CDB!");
161
162 return fgSimParam;
163
f565d89d 164}
165
ea6ddc2c 166//____________________________________________________________________________
14ce0a6e 167Int_t AliEMCALLoader::GetEvent()
168{
169 //Method to load all of the data
170 //members of the EMCAL for a given
171 //event from the Trees
64c98165 172
ea6ddc2c 173 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
174
64c98165 175 // *** Hits ***
e44d51bd 176 // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested.
177 // together with AliEveEMCALData
178
64c98165 179 // *** SDigits ***
180 // Initialize the SDigits TClonesArray, only if it did not existed before
181 MakeSDigitsArray();
182
183 TTree *treeS = TreeS();
184 if (treeS) {
185 TBranch * branchS = treeS->GetBranch(fDetectorName);
186
187 // Reset SDigits array and branch
188 branchS->ResetAddress();
189 TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits();
e0dc3f7d 190 if (sdigits) sdigits->Clear("C");
64c98165 191
192 branchS->SetAddress(&sdigits);
193 branchS->GetEntry(0);
194 }
195
196 // *** Digits ***
197 // Initialize the Digits TClonesArray, only if it did not existed before
198 MakeDigitsArray();
199
200 TTree *treeD = TreeD();
201 if (treeD) {
202 TBranch * branchD = treeD->GetBranch(fDetectorName);
203
204 // Reset Digits array and branch
205 branchD->ResetAddress();
206 TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits();
e0dc3f7d 207 if (digits) digits->Clear("C");
64c98165 208
209 branchD->SetAddress(&digits);
210 branchD->GetEntry(0);
211 }
212
213 // *** RecPoints ***
214 // Initialize the RecPoints TObjArray, only if it did not existed before
215 MakeRecPointsArray();
825fa573 216
64c98165 217 TTree *treeR = TreeR();
218 if (treeR) {
219 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
220
221 // Reset RecPoints array and branch
222 branchR->ResetAddress();
223 TObjArray* rp = const_cast<AliEMCALLoader *>(this)->RecPoints();
224 if (rp) rp->Clear();
225
226 branchR->SetAddress(&rp);
227 branchR->GetEntry(0);
228 }
229
230 return 0;
231}
ea6ddc2c 232
64c98165 233//____________________________________________________________________________
234void AliEMCALLoader::MakeSDigitsArray(){
235 // Add SDigits array to the data folder
236 if (SDigits()) return;
237 TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0);
238 sdigits->SetName(fgkECASDigitsBranchName);
239 GetDetectorDataFolder()->Add(sdigits);
240}
241
242//____________________________________________________________________________
243void AliEMCALLoader::MakeDigitsArray(){
244 // Add Digits array to the data folder
245 if (Digits()) return;
246 TClonesArray* digits = new TClonesArray("AliEMCALDigit",0);
247 digits->SetName(fgkECADigitsBranchName);
248 GetDetectorDataFolder()->Add(digits);
249}
250
251//____________________________________________________________________________
252void AliEMCALLoader::MakeRecPointsArray(){
253 // Add RecPoints array to the data folder
254 if (RecPoints()) return;
255 TObjArray* rp = new TObjArray(0);
256 rp->SetName(fgkECARecPointsBranchName);
257 GetDetectorDataFolder()->Add(rp);
88cb7938 258}