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