]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // The AliEMCALLoader gets the TClonesArray and TObjArray for reading | |
20 | // Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent() | |
21 | // method. | |
22 | // It also provides acces methods to the calibration and simulation OCDB parameters | |
23 | // | |
24 | //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH) | |
25 | //*-- Completely redesigned by Dmitri Peressounko March 2001 | |
26 | // | |
27 | //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make | |
28 | //*-- systematic usage of TFolders without changing the interface | |
29 | // | |
30 | //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading | |
31 | //*-- and fit better in general ALICE scheme | |
32 | //*-- GCB: Remove TClonesArrays and TObjArrays data members, they are created elsewhere. | |
33 | //*-- Provide access to OCDB calibration and simulation parameters. | |
34 | // | |
35 | ////////////////////////////////////////////////////////////////////////////// | |
36 | ||
37 | // --- ROOT system --- | |
38 | #include "TMath.h" | |
39 | #include "TTree.h" | |
40 | // --- Standard library --- | |
41 | ||
42 | // --- AliRoot header files --- | |
43 | #include "AliEMCALLoader.h" | |
44 | #include "AliLog.h" | |
45 | #include "AliCDBLocal.h" | |
46 | #include "AliCDBStorage.h" | |
47 | #include "AliCDBManager.h" | |
48 | #include "AliCDBEntry.h" | |
49 | ||
50 | ClassImp(AliEMCALLoader) | |
51 | ||
52 | const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points | |
53 | const TString AliEMCALLoader::fgkECADigitsBranchName("DIGITS");//Name for branch with ECA Digits | |
54 | const TString AliEMCALLoader::fgkECASDigitsBranchName("SDIGITS");//Name for branch with ECA SDigits | |
55 | ||
56 | AliEMCALCalibData* AliEMCALLoader::fgCalibData = 0; //calibration data | |
57 | AliCaloCalibPedestal* AliEMCALLoader::fgCaloPed = 0; //dead map data | |
58 | AliEMCALSimParam* AliEMCALLoader::fgSimParam = 0; //simulation parameters | |
59 | AliEMCALRecParam* AliEMCALLoader::fgRecParam = 0; //reconstruction parameters | |
60 | ||
61 | //____________________________________________________________________________ | |
62 | AliEMCALLoader::AliEMCALLoader() | |
63 | : fDebug(0) | |
64 | { | |
65 | //Default constructor for EMCAL Loader Class | |
66 | ||
67 | } | |
68 | ||
69 | //____________________________________________________________________________ | |
70 | AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername) | |
71 | : AliLoader(detname,eventfoldername), fDebug(0) | |
72 | { | |
73 | //Specific constructor for EMCAL Loader class | |
74 | ||
75 | } | |
76 | ||
77 | //____________________________________________________________________________ | |
78 | AliEMCALLoader::AliEMCALLoader(const Char_t *name, TFolder *topfolder) | |
79 | : AliLoader(name,topfolder), fDebug(0) | |
80 | { | |
81 | //Specific constructor for EMCAL Loader class | |
82 | ||
83 | } | |
84 | ||
85 | //____________________________________________________________________________ | |
86 | AliEMCALLoader::~AliEMCALLoader() | |
87 | { | |
88 | // Disconnect trees and remove arrays | |
89 | if (TreeH()) | |
90 | TreeH()->SetBranchAddress(fDetectorName,0); | |
91 | // if (TreeD()) | |
92 | // TreeD()->SetBranchAddress(fDetectorName,0); | |
93 | // if (TreeS()) | |
94 | // TreeS()->SetBranchAddress(fDetectorName,0); | |
95 | // if (TreeR()) | |
96 | // TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0); | |
97 | ||
98 | Clean(fgkECASDigitsBranchName); | |
99 | Clean(fgkECADigitsBranchName); | |
100 | Clean(fgkECARecPointsBranchName); | |
101 | ||
102 | AliLoader::CleanFolders(); | |
103 | ||
104 | } | |
105 | ||
106 | //____________________________________________________________________________ | |
107 | AliEMCALCalibData* AliEMCALLoader::CalibData() | |
108 | { | |
109 | // Check if the instance of AliEMCALCalibData exists, if not, create it if | |
110 | // the OCDB is available, and finally return it. | |
111 | ||
112 | if(!fgCalibData && (AliCDBManager::Instance()->IsDefaultStorageSet())) | |
113 | { | |
114 | AliCDBEntry *entry = (AliCDBEntry*) | |
115 | AliCDBManager::Instance()->Get("EMCAL/Calib/Data"); | |
116 | if (entry) fgCalibData = (AliEMCALCalibData*) entry->GetObject(); | |
117 | } | |
118 | ||
119 | if(!fgCalibData) | |
120 | AliFatal("Calibration parameters not found in CDB!"); | |
121 | ||
122 | return fgCalibData; | |
123 | ||
124 | } | |
125 | ||
126 | //____________________________________________________________________________ | |
127 | AliCaloCalibPedestal* AliEMCALLoader::PedestalData() | |
128 | { | |
129 | // Check if the instance of AliCaloCalibPedestal exists, if not, create it if | |
130 | // the OCDB is available, and finally return it. | |
131 | ||
132 | if(!fgCaloPed && (AliCDBManager::Instance()->IsDefaultStorageSet())) | |
133 | { | |
134 | AliCDBEntry *entry = (AliCDBEntry*) | |
135 | AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); | |
136 | if (entry) fgCaloPed = (AliCaloCalibPedestal*) entry->GetObject(); | |
137 | } | |
138 | ||
139 | if(!fgCaloPed) | |
140 | AliFatal("Pedestal info not found in CDB!"); | |
141 | ||
142 | return fgCaloPed; | |
143 | ||
144 | } | |
145 | ||
146 | //____________________________________________________________________________ | |
147 | AliEMCALSimParam* AliEMCALLoader::SimulationParameters() | |
148 | { | |
149 | // Check if the instance of AliEMCALSimParam exists, if not, create it if | |
150 | // the OCDB is available, and finally return it. | |
151 | ||
152 | if(!fgSimParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) | |
153 | { | |
154 | AliCDBEntry *entry = (AliCDBEntry*) | |
155 | AliCDBManager::Instance()->Get("EMCAL/Calib/SimParam"); | |
156 | if (entry) fgSimParam = (AliEMCALSimParam*) entry->GetObject(); | |
157 | ||
158 | } | |
159 | ||
160 | if(!fgSimParam) | |
161 | AliFatal("Simulations parameters not found in CDB!"); | |
162 | ||
163 | return fgSimParam; | |
164 | ||
165 | } | |
166 | ||
167 | ||
168 | //____________________________________________________________________________ | |
169 | AliEMCALRecParam* AliEMCALLoader::ReconstructionParameters(Int_t eventType = 0) | |
170 | { | |
171 | // Check if the instance of AliEMCALRecParam exists, if not, create it if | |
172 | // the OCDB is available, and finally return it. | |
173 | // The event type must be provided. | |
174 | ||
175 | if(!fgRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) | |
176 | { | |
177 | AliCDBEntry *entry = (AliCDBEntry*) | |
178 | AliCDBManager::Instance()->Get("EMCAL/Calib/RecoParam"); | |
179 | if (entry) fgRecParam = (AliEMCALRecParam*)((TObjArray *) entry->GetObject())->At(eventType); | |
180 | ||
181 | } | |
182 | ||
183 | if(!fgRecParam) | |
184 | AliFatal("Reconstruction parameters not found in CDB!"); | |
185 | ||
186 | return fgRecParam; | |
187 | ||
188 | } | |
189 | ||
190 | ||
191 | //____________________________________________________________________________ | |
192 | Int_t AliEMCALLoader::GetEvent() | |
193 | { | |
194 | //Method to load all of the data | |
195 | //members of the EMCAL for a given | |
196 | //event from the Trees | |
197 | ||
198 | AliLoader::GetEvent(); // First call AliLoader to do all the groundwork | |
199 | ||
200 | // *** Hits *** | |
201 | // Hits are now handled directly on the AliEMCALSDigitizer, the only place it is requested. | |
202 | // together with AliEveEMCALData | |
203 | ||
204 | // *** SDigits *** | |
205 | // Initialize the SDigits TClonesArray, only if it did not existed before | |
206 | MakeSDigitsArray(); | |
207 | ||
208 | TTree *treeS = TreeS(); | |
209 | if (treeS) { | |
210 | TBranch * branchS = treeS->GetBranch(fDetectorName); | |
211 | ||
212 | // Reset SDigits array and branch | |
213 | branchS->ResetAddress(); | |
214 | TClonesArray* sdigits = const_cast<AliEMCALLoader *>(this)->SDigits(); | |
215 | if (sdigits) sdigits->Clear("C"); | |
216 | ||
217 | branchS->SetAddress(&sdigits); | |
218 | branchS->GetEntry(0); | |
219 | } | |
220 | ||
221 | // *** Digits *** | |
222 | // Initialize the Digits TClonesArray, only if it did not existed before | |
223 | MakeDigitsArray(); | |
224 | ||
225 | TTree *treeD = TreeD(); | |
226 | if (treeD) { | |
227 | TBranch * branchD = treeD->GetBranch(fDetectorName); | |
228 | ||
229 | // Reset Digits array and branch | |
230 | branchD->ResetAddress(); | |
231 | TClonesArray* digits = const_cast<AliEMCALLoader *>(this)->Digits(); | |
232 | if (digits) digits->Clear("C"); | |
233 | ||
234 | branchD->SetAddress(&digits); | |
235 | branchD->GetEntry(0); | |
236 | } | |
237 | ||
238 | // *** RecPoints *** | |
239 | // Initialize the RecPoints TObjArray, only if it did not existed before | |
240 | MakeRecPointsArray(); | |
241 | ||
242 | TTree *treeR = TreeR(); | |
243 | if (treeR) { | |
244 | TBranch * branchR = treeR->GetBranch(fgkECARecPointsBranchName); | |
245 | ||
246 | // Reset RecPoints array and branch | |
247 | branchR->ResetAddress(); | |
248 | TObjArray* rp = const_cast<AliEMCALLoader *>(this)->RecPoints(); | |
249 | if (rp) rp->Clear(); | |
250 | ||
251 | branchR->SetAddress(&rp); | |
252 | branchR->GetEntry(0); | |
253 | } | |
254 | ||
255 | return 0; | |
256 | } | |
257 | ||
258 | //____________________________________________________________________________ | |
259 | void AliEMCALLoader::MakeSDigitsArray(){ | |
260 | // Add SDigits array to the data folder | |
261 | if (SDigits()) return; | |
262 | TClonesArray* sdigits = new TClonesArray("AliEMCALDigit",0); | |
263 | sdigits->SetName(fgkECASDigitsBranchName); | |
264 | GetDetectorDataFolder()->Add(sdigits); | |
265 | } | |
266 | ||
267 | //____________________________________________________________________________ | |
268 | void AliEMCALLoader::MakeDigitsArray(){ | |
269 | // Add Digits array to the data folder | |
270 | if (Digits()) return; | |
271 | TClonesArray* digits = new TClonesArray("AliEMCALDigit",0); | |
272 | digits->SetName(fgkECADigitsBranchName); | |
273 | GetDetectorDataFolder()->Add(digits); | |
274 | } | |
275 | ||
276 | //____________________________________________________________________________ | |
277 | void AliEMCALLoader::MakeRecPointsArray(){ | |
278 | // Add RecPoints array to the data folder | |
279 | if (RecPoints()) return; | |
280 | TObjArray* rp = new TObjArray(0); | |
281 | rp->SetName(fgkECARecPointsBranchName); | |
282 | GetDetectorDataFolder()->Add(rp); | |
283 | } |