]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALLoader.cxx
avoid compilation warnings when adding selection macros
[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//_________________________________________________________________________
19// A singleton. This class should be used in the analysis stage to get
20// reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
5dee926e 21// instead of directly reading them from galice.root file.
88cb7938 22//
5dee926e 23// MvL Feb 2006:
24// The AliEMCALLoader now holds the TClonesArray and TObjArray for reading
25// Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
26// method.
27//
28// Creation/writing of files is managed by the relevant parts of the
29// reconstruction software (AliEMCALDigitiser etx)
30//
88cb7938 31//*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
32//*-- Completely redesigned by Dmitri Peressounko March 2001
33//
34//*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
5dee926e 35//*-- systematic usage of TFolders without changing the interface
36//
37//*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
38//*-- and fit better in general ALICE scheme
39//
88cb7938 40//////////////////////////////////////////////////////////////////////////////
41
88cb7938 42// --- ROOT system ---
090026bf 43#include "TMath.h"
88cb7938 44#include "TTree.h"
88cb7938 45
46// --- Standard library ---
88cb7938 47
48// --- AliRoot header files ---
a9bbb414 49#include "AliEMCALLoader.h"
50#include "AliLog.h"
f565d89d 51#include "AliCDBLocal.h"
52#include "AliCDBStorage.h"
53#include "AliCDBManager.h"
1f337798 54#include "AliCDBEntry.h"
825fa573 55#include "AliEMCALHit.h"
88cb7938 56
57ClassImp(AliEMCALLoader)
d64c959b 58
88cb7938 59const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
14ce0a6e 60AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
d64c959b 61
88cb7938 62//____________________________________________________________________________
63AliEMCALLoader::AliEMCALLoader()
18a21c7c 64 : fDebug(0),
65 fHits(0),
66 fDigits(0),
67 fSDigits(0),
68 fRecPoints(0)
d64c959b 69{
14ce0a6e 70 //Default constructor for EMCAL Loader Class
71
88cb7938 72 fDebug = 0;
5dee926e 73 fHits = new TClonesArray("AliEMCALHit");
74 fDigits = new TClonesArray("AliEMCALDigit");
75 fSDigits = new TClonesArray("AliEMCALDigit");
76 fRecPoints = new TObjArray();
d64c959b 77}
78
88cb7938 79//____________________________________________________________________________
18a21c7c 80AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
81 : AliLoader(detname,eventfoldername),
82 fDebug(0),
0dc91659 83 fHits(new TClonesArray("AliEMCALHit")),
84 fDigits(new TClonesArray("AliEMCALDigit")),
85 fSDigits(new TClonesArray("AliEMCALDigit")),
86 fRecPoints(new TObjArray())
88cb7938 87{
14ce0a6e 88 //Specific constructor for EMCAL Loader class
88cb7938 89}
88cb7938 90
6b299d9e 91//____________________________________________________________________________
92AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder)
93 : AliLoader(name,topfolder),
94 fDebug(0),
0dc91659 95 fHits(new TClonesArray("AliEMCALHit")),
96 fDigits(new TClonesArray("AliEMCALDigit")),
97 fSDigits(new TClonesArray("AliEMCALDigit")),
98 fRecPoints(new TObjArray())
6b299d9e 99{
100 //Specific constructor for EMCAL Loader class
6b299d9e 101}
102
d64c959b 103//____________________________________________________________________________
88cb7938 104AliEMCALLoader::~AliEMCALLoader()
105{
5dee926e 106 // Disconnect trees and remove arrays
107 if (TreeH())
108 TreeH()->SetBranchAddress(fDetectorName,0);
109 if (TreeD())
110 TreeD()->SetBranchAddress(fDetectorName,0);
111 if (TreeS())
112 TreeS()->SetBranchAddress(fDetectorName,0);
113 if (TreeR())
114 TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
ac169647 115 if (fHits) {
116 fHits->Delete();
117 delete fHits;
118 }
5dee926e 119 delete fDigits;
120 delete fSDigits;
121 delete fRecPoints;
122}
123
f565d89d 124//____________________________________________________________________________
125AliEMCALCalibData* AliEMCALLoader::CalibData()
126{
1f337798 127 // Check if the instance of AliEMCALCalibData exists, if not, create it if
128 // the OCDB is available, and finally return it.
f565d89d 129
1f337798 130 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
131 {
132 AliCDBEntry *entry = (AliCDBEntry*)
133 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
134 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
135 }
136
137 if(!fgCalibData)
138 AliFatal("Calibration parameters not found in CDB!");
78cbbabb 139
14ce0a6e 140 return fgCalibData;
78cbbabb 141
f565d89d 142}
143
3a8be91c 144
145//____________________________________________________________________________
f565d89d 146Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
147 Int_t column, Int_t row)
148{
149 // Convert energy into digitized amplitude for a cell relId
150 // It is a user responsilibity to open CDB and set
151 // AliEMCALCalibData object by the following operators:
152 //
153 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
154 // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
155 // ->Get(path_to_calibdata,run_number);
156 // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
157 // gime->SetCalibData(clb);
158
159 if (CalibData() == 0)
160 Warning("CalibrateRaw","Calibration DB is not initiated!");
161
78cbbabb 162 Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
163 Float_t pedestal = 0.009;//0.005; // pedestals
f565d89d 164
165 if(CalibData()) {
166 gainFactor = CalibData()->GetADCchannel (module,column,row);
167 pedestal = CalibData()->GetADCpedestal(module,column,row);
168 }
169
170 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
171 return amp;
172}
173
ea6ddc2c 174//____________________________________________________________________________
14ce0a6e 175Int_t AliEMCALLoader::GetEvent()
176{
177 //Method to load all of the data
178 //members of the EMCAL for a given
179 //event from the Trees
180
ea6ddc2c 181 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
182
183 // Now connect and fill TClonesArray
184
185 // Hits
186 TTree *treeH = TreeH();
187
188 if (treeH) {
825fa573 189 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
190 fHits->Clear();
191 Int_t index = 0;
ac169647 192 TClonesArray *tempArr = 0x0;
193 TBranch * branchH = treeH->GetBranch(fDetectorName);
194 branchH->SetAddress(&tempArr);
825fa573 195 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
196 treeH->GetEntry(iEnt);
ac169647 197 Int_t nHit = tempArr->GetEntriesFast();
825fa573 198 for (Int_t iHit = 0; iHit < nHit; iHit++) {
ac169647 199 new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
825fa573 200 index++;
201 }
202 }
ac169647 203 branchH->ResetAddress();
204 if (tempArr) {
205 tempArr->Delete();
206 delete tempArr;
207 }
ea6ddc2c 208 }
825fa573 209
ea6ddc2c 210 // SDigits
211 TTree *treeS = TreeS();
212 if (treeS) {
ac169647 213 TBranch * branchS = treeS->GetBranch(fDetectorName);
214 branchS->ResetAddress();
215 if (fSDigits) {
9517d886 216 fSDigits->Clear();
ac169647 217 }
218 branchS->SetAddress(&fSDigits);
ea6ddc2c 219 treeS->GetEvent(0);
220 }
221
222 // Digits
223 TTree *treeD = TreeD();
224 if (treeD) {
ac169647 225 TBranch * branchD = treeD->GetBranch(fDetectorName);
226 branchD->ResetAddress();
227 if (fDigits) {
9517d886 228 fDigits->Clear();
ac169647 229 }
230 branchD->SetAddress(&fDigits);
ea6ddc2c 231 treeD->GetEvent(0);
232 }
233
234 // RecPoints
235 TTree *treeR = TreeR();
236 if (treeR) {
ac169647 237 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
238 branchR->ResetAddress();
239 if (fRecPoints) {
9517d886 240 fRecPoints->Clear();
ac169647 241 }
242 branchR->SetAddress(&fRecPoints);
ea6ddc2c 243 treeR->GetEvent(0);
244 }
245
246 return 0;
88cb7938 247}