]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALLoader.cxx
New calibration data member with AliEMCALCalibData instance. Initialized in Init...
[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),
83 fHits(0),
84 fDigits(0),
85 fSDigits(0),
86 fRecPoints(0)
88cb7938 87{
14ce0a6e 88 //Specific constructor for EMCAL Loader class
89
88cb7938 90 fDebug=0;
5dee926e 91 fHits = new TClonesArray("AliEMCALHit");
92 fDigits = new TClonesArray("AliEMCALDigit");
93 fSDigits = new TClonesArray("AliEMCALDigit");
94 fRecPoints = new TObjArray();
88cb7938 95}
88cb7938 96
0a4cb131 97//____________________________________________________________________________
18a21c7c 98AliEMCALLoader::AliEMCALLoader(const AliEMCALLoader & obj)
99 : AliLoader(obj),
100 fDebug(obj.fDebug),
101 fHits(obj.fHits),
102 fDigits(obj.fDigits),
103 fSDigits(obj.fSDigits),
104 fRecPoints(obj.fRecPoints)
0a4cb131 105{
106 //copy ctor
0a4cb131 107}
108
d64c959b 109//____________________________________________________________________________
88cb7938 110AliEMCALLoader::~AliEMCALLoader()
111{
5dee926e 112 // Disconnect trees and remove arrays
113 if (TreeH())
114 TreeH()->SetBranchAddress(fDetectorName,0);
115 if (TreeD())
116 TreeD()->SetBranchAddress(fDetectorName,0);
117 if (TreeS())
118 TreeS()->SetBranchAddress(fDetectorName,0);
119 if (TreeR())
120 TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
ac169647 121 if (fHits) {
122 fHits->Delete();
123 delete fHits;
124 }
5dee926e 125 delete fDigits;
126 delete fSDigits;
127 delete fRecPoints;
128}
129
f565d89d 130//____________________________________________________________________________
131AliEMCALCalibData* AliEMCALLoader::CalibData()
132{
1f337798 133 // Check if the instance of AliEMCALCalibData exists, if not, create it if
134 // the OCDB is available, and finally return it.
f565d89d 135
1f337798 136 if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet()))
137 {
138 AliCDBEntry *entry = (AliCDBEntry*)
139 AliCDBManager::Instance()->Get("EMCAL/Calib/Data");
140 if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject();
141 }
142
143 if(!fgCalibData)
144 AliFatal("Calibration parameters not found in CDB!");
78cbbabb 145
14ce0a6e 146 return fgCalibData;
78cbbabb 147
f565d89d 148}
149
150//____________________________________________________________________________
151Int_t AliEMCALLoader::CalibrateRaw(Double_t energy, Int_t module,
152 Int_t column, Int_t row)
153{
154 // Convert energy into digitized amplitude for a cell relId
155 // It is a user responsilibity to open CDB and set
156 // AliEMCALCalibData object by the following operators:
157 //
158 // AliCDBLocal *loc = new AliCDBLocal("deCalibDB");
159 // AliEMCALCalibData* clb = (AliEMCALCalibData*)AliCDBStorage::Instance()
160 // ->Get(path_to_calibdata,run_number);
161 // AliEMCALGetter* gime = AliEMCALGetter::Instance("galice.root");
162 // gime->SetCalibData(clb);
163
164 if (CalibData() == 0)
165 Warning("CalibrateRaw","Calibration DB is not initiated!");
166
78cbbabb 167 Float_t gainFactor = 0.00305;//0.0015; // width of one ADC channel in GeV
168 Float_t pedestal = 0.009;//0.005; // pedestals
f565d89d 169
170 if(CalibData()) {
171 gainFactor = CalibData()->GetADCchannel (module,column,row);
172 pedestal = CalibData()->GetADCpedestal(module,column,row);
173 }
174
175 Int_t amp = static_cast<Int_t>( (energy - pedestal) / gainFactor + 0.5 ) ;
176 return amp;
177}
178
ea6ddc2c 179//____________________________________________________________________________
14ce0a6e 180Int_t AliEMCALLoader::GetEvent()
181{
182 //Method to load all of the data
183 //members of the EMCAL for a given
184 //event from the Trees
185
ea6ddc2c 186 AliLoader::GetEvent(); // First call AliLoader to do all the groundwork
187
188 // Now connect and fill TClonesArray
189
190 // Hits
191 TTree *treeH = TreeH();
192
193 if (treeH) {
825fa573 194 Int_t nEnt = treeH->GetEntries(); // TreeH has array of hits for every primary
195 fHits->Clear();
196 Int_t index = 0;
ac169647 197 TClonesArray *tempArr = 0x0;
198 TBranch * branchH = treeH->GetBranch(fDetectorName);
199 branchH->SetAddress(&tempArr);
825fa573 200 for (Int_t iEnt = 0; iEnt < nEnt; iEnt++) {
201 treeH->GetEntry(iEnt);
ac169647 202 Int_t nHit = tempArr->GetEntriesFast();
825fa573 203 for (Int_t iHit = 0; iHit < nHit; iHit++) {
ac169647 204 new ((*fHits)[index]) AliEMCALHit(*((AliEMCALHit*)tempArr->At(iHit)));
825fa573 205 index++;
206 }
207 }
ac169647 208 branchH->ResetAddress();
209 if (tempArr) {
210 tempArr->Delete();
211 delete tempArr;
212 }
ea6ddc2c 213 }
825fa573 214
ea6ddc2c 215 // SDigits
216 TTree *treeS = TreeS();
217 if (treeS) {
ac169647 218 TBranch * branchS = treeS->GetBranch(fDetectorName);
219 branchS->ResetAddress();
220 if (fSDigits) {
221 fSDigits->Delete();
222 delete fSDigits;
223 fSDigits = 0x0;
224 }
225 branchS->SetAddress(&fSDigits);
ea6ddc2c 226 treeS->GetEvent(0);
227 }
228
229 // Digits
230 TTree *treeD = TreeD();
231 if (treeD) {
ac169647 232 TBranch * branchD = treeD->GetBranch(fDetectorName);
233 branchD->ResetAddress();
234 if (fDigits) {
235 fDigits->Delete();
236 delete fDigits;
237 fDigits = 0x0;
238 }
239 branchD->SetAddress(&fDigits);
ea6ddc2c 240 treeD->GetEvent(0);
241 }
242
243 // RecPoints
244 TTree *treeR = TreeR();
245 if (treeR) {
ac169647 246 TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName);
247 branchR->ResetAddress();
248 if (fRecPoints) {
249 fRecPoints->Delete();
250 delete fRecPoints;
251 fRecPoints = 0x0;
252 }
253 branchR->SetAddress(&fRecPoints);
ea6ddc2c 254 treeR->GetEvent(0);
255 }
256
257 return 0;
88cb7938 258}