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