]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALLoader.cxx
Fixing the correct syntax for AliEn spooler
[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 ---
88cb7938 43#include "TTree.h"
88cb7938 44
45// --- Standard library ---
88cb7938 46
47// --- AliRoot header files ---
a9bbb414 48#include "AliEMCALLoader.h"
49#include "AliLog.h"
f565d89d 50#include "AliCDBLocal.h"
51#include "AliCDBStorage.h"
52#include "AliCDBManager.h"
825fa573 53#include "AliEMCALHit.h"
88cb7938 54
55ClassImp(AliEMCALLoader)
d64c959b 56
88cb7938 57const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
14ce0a6e 58AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibation data
d64c959b 59
88cb7938 60//____________________________________________________________________________
61AliEMCALLoader::AliEMCALLoader()
18a21c7c 62 : fDebug(0),
63 fHits(0),
64 fDigits(0),
65 fSDigits(0),
66 fRecPoints(0)
d64c959b 67{
14ce0a6e 68 //Default constructor for EMCAL Loader Class
69
88cb7938 70 fDebug = 0;
5dee926e 71 fHits = new TClonesArray("AliEMCALHit");
72 fDigits = new TClonesArray("AliEMCALDigit");
73 fSDigits = new TClonesArray("AliEMCALDigit");
74 fRecPoints = new TObjArray();
d64c959b 75}
76
88cb7938 77//____________________________________________________________________________
18a21c7c 78AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername)
79 : AliLoader(detname,eventfoldername),
80 fDebug(0),
81 fHits(0),
82 fDigits(0),
83 fSDigits(0),
84 fRecPoints(0)
88cb7938 85{
14ce0a6e 86 //Specific constructor for EMCAL Loader class
87
88cb7938 88 fDebug=0;
5dee926e 89 fHits = new TClonesArray("AliEMCALHit");
90 fDigits = new TClonesArray("AliEMCALDigit");
91 fSDigits = new TClonesArray("AliEMCALDigit");
92 fRecPoints = new TObjArray();
88cb7938 93}
88cb7938 94
0a4cb131 95//____________________________________________________________________________
18a21c7c 96AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
97 : AliLoader(obj),
98 fDebug(obj.fDebug),
99 fHits(obj.fHits),
100 fDigits(obj.fDigits),
101 fSDigits(obj.fSDigits),
102 fRecPoints(obj.fRecPoints)
0a4cb131 103{
104 //copy ctor
0a4cb131 105}
106
d64c959b 107//____________________________________________________________________________
88cb7938 108AliEMCALLoader::~AliEMCALLoader()
109{
5dee926e 110 // Disconnect trees and remove arrays
111 if (TreeH())
112 TreeH()->SetBranchAddress(fDetectorName,0);
113 if (TreeD())
114 TreeD()->SetBranchAddress(fDetectorName,0);
115 if (TreeS())
116 TreeS()->SetBranchAddress(fDetectorName,0);
117 if (TreeR())
118 TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
ac169647 119 if (fHits) {
120 fHits->Delete();
121 delete fHits;
122 }
5dee926e 123 delete fDigits;
124 delete fSDigits;
125 delete fRecPoints;
126}
127
f565d89d 128//____________________________________________________________________________
129AliEMCALCalibData* AliEMCALLoader::CalibData()
130{
bcdecbbe 131 // Check if the instance of AliEMCALCalibData exists, and return it
f565d89d 132
78cbbabb 133 if( !(AliCDBManager::Instance()->IsDefaultStorageSet()) )
14ce0a6e 134 fgCalibData=0x0;
78cbbabb 135
14ce0a6e 136 return fgCalibData;
78cbbabb 137
f565d89d 138}
139
140//____________________________________________________________________________
141Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
142 Int_t column, Int_t row)
143{
144 // Convert energy into digitized amplitude for a cell relId
145 // It is a user responsilibity to open CDB and set
146 // AliEMCALCalibData object by the following operators:
147 //
148 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
149 // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
150 // ->Get(path_to_calibdata,run_number);
151 // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
152 // gime->SetCalibData(clb);
153
154 if (CalibData() == 0)
155 Warning("CalibrateRaw","Calibration DB is not initiated!");
156
78cbbabb 157 Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
158 Float_t pedestal = 0.009;//0.005; // pedestals
f565d89d 159
160 if(CalibData()) {
161 gainFactor = CalibData()->GetADCchannel (module,column,row);
162 pedestal = CalibData()->GetADCpedestal(module,column,row);
163 }
164
165 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
166 return amp;
167}
168
ea6ddc2c 169//____________________________________________________________________________
14ce0a6e 170Int_t AliEMCALLoader::GetEvent()
171{
172 //Method to load all of the data
173 //members of the EMCAL for a given
174 //event from the Trees
175
ea6ddc2c 176 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
177
178 // Now connect and fill TClonesArray
179
180 // Hits
181 TTree *treeH = TreeH();
182
183 if (treeH) {
825fa573 184 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
185 fHits->Clear();
186 Int_t index = 0;
ac169647 187 TClonesArray *tempArr = 0x0;
188 TBranch * branchH = treeH->GetBranch(fDetectorName);
189 branchH->SetAddress(&tempArr);
825fa573 190 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
191 treeH->GetEntry(iEnt);
ac169647 192 Int_t nHit = tempArr->GetEntriesFast();
825fa573 193 for (Int_t iHit = 0; iHit < nHit; iHit++) {
ac169647 194 new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
825fa573 195 index++;
196 }
197 }
ac169647 198 branchH->ResetAddress();
199 if (tempArr) {
200 tempArr->Delete();
201 delete tempArr;
202 }
ea6ddc2c 203 }
825fa573 204
ea6ddc2c 205 // SDigits
206 TTree *treeS = TreeS();
207 if (treeS) {
ac169647 208 TBranch * branchS = treeS->GetBranch(fDetectorName);
209 branchS->ResetAddress();
210 if (fSDigits) {
211 fSDigits->Delete();
212 delete fSDigits;
213 fSDigits = 0x0;
214 }
215 branchS->SetAddress(&fSDigits);
ea6ddc2c 216 treeS->GetEvent(0);
217 }
218
219 // Digits
220 TTree *treeD = TreeD();
221 if (treeD) {
ac169647 222 TBranch * branchD = treeD->GetBranch(fDetectorName);
223 branchD->ResetAddress();
224 if (fDigits) {
225 fDigits->Delete();
226 delete fDigits;
227 fDigits = 0x0;
228 }
229 branchD->SetAddress(&fDigits);
ea6ddc2c 230 treeD->GetEvent(0);
231 }
232
233 // RecPoints
234 TTree *treeR = TreeR();
235 if (treeR) {
ac169647 236 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
237 branchR->ResetAddress();
238 if (fRecPoints) {
239 fRecPoints->Delete();
240 delete fRecPoints;
241 fRecPoints = 0x0;
242 }
243 branchR->SetAddress(&fRecPoints);
ea6ddc2c 244 treeR->GetEvent(0);
245 }
246
247 return 0;
88cb7938 248}