]>
Commit | Line | Data |
---|---|---|
a1f80595 | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, 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 | **************************************************************************/ | |
a1f80595 | 15 | /* $Id$ */ |
c2fc1258 | 16 | /** @file AliFMDInput.cxx |
17 | @author Christian Holm Christensen <cholm@nbi.dk> | |
18 | @date Mon Mar 27 12:42:40 2006 | |
19 | @brief FMD utility classes for reading FMD data | |
20 | */ | |
a1f80595 | 21 | //___________________________________________________________________ |
22 | // | |
23 | // The classes defined here, are utility classes for reading in data | |
24 | // for the FMD. They are put in a seperate library to not polute the | |
25 | // normal libraries. The classes are intended to be used as base | |
26 | // classes for customized class that do some sort of analysis on the | |
27 | // various types of data produced by the FMD. | |
28 | // | |
29 | // Latest changes by Christian Holm Christensen | |
30 | // | |
31 | #include "AliFMDInput.h" // ALIFMDHIT_H | |
69893a66 | 32 | #include "AliFMDDebug.h" // ALIFMDDEBUG_H ALILOG_H |
8f6ee336 | 33 | #include "AliLoader.h" // ALILOADER_H |
34 | #include "AliRunLoader.h" // ALIRUNLOADER_H | |
35 | #include "AliRun.h" // ALIRUN_H | |
36 | #include "AliStack.h" // ALISTACK_H | |
d760ea03 | 37 | #include "AliRawReaderFile.h" // ALIRAWREADERFILE_H |
8f6ee336 | 38 | #include "AliFMD.h" // ALIFMD_H |
a1f80595 | 39 | #include "AliFMDHit.h" // ALIFMDHIT_H |
8f6ee336 | 40 | #include "AliFMDDigit.h" // ALIFMDDigit_H |
02a27b50 | 41 | #include "AliFMDSDigit.h" // ALIFMDDigit_H |
bf000c32 | 42 | #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H |
d760ea03 | 43 | #include "AliFMDRawReader.h" // ALIFMDRAWREADER_H |
bf000c32 | 44 | #include <AliESD.h> |
45 | #include <AliESDFMD.h> | |
df137876 | 46 | #include <AliESDEvent.h> |
1e8f773e | 47 | #include <AliCDBManager.h> |
48 | #include <AliCDBEntry.h> | |
90dbf5fb | 49 | #include <AliAlignObjParams.h> |
8f6ee336 | 50 | #include <TTree.h> // ROOT_TTree |
bf000c32 | 51 | #include <TChain.h> // ROOT_TChain |
8f6ee336 | 52 | #include <TParticle.h> // ROOT_TParticle |
53 | #include <TString.h> // ROOT_TString | |
54 | #include <TDatabasePDG.h> // ROOT_TDatabasePDG | |
55 | #include <TMath.h> // ROOT_TMath | |
56 | #include <TGeoManager.h> // ROOT_TGeoManager | |
bf000c32 | 57 | #include <TSystemDirectory.h> // ROOT_TSystemDirectory |
8f6ee336 | 58 | #include <Riostream.h> // ROOT_Riostream |
97b4001e | 59 | #include <TFile.h> // ROOT_TFile |
a1e17193 | 60 | #include <TStreamerInfo.h> |
7003fbd0 | 61 | #include <TArrayF.h> |
62 | ||
a1f80595 | 63 | //____________________________________________________________________ |
64 | ClassImp(AliFMDInput) | |
65 | #if 0 | |
66 | ; // This is here to keep Emacs for indenting the next line | |
67 | #endif | |
68 | ||
69 | ||
70 | //____________________________________________________________________ | |
71 | AliFMDInput::AliFMDInput() | |
72 | : fGAliceFile(""), | |
73 | fLoader(0), | |
74 | fRun(0), | |
75 | fStack(0), | |
76 | fFMDLoader(0), | |
d760ea03 | 77 | fReader(0), |
a1f80595 | 78 | fFMD(0), |
bf000c32 | 79 | fESD(0), |
df137876 | 80 | fESDEvent(0), |
a1f80595 | 81 | fTreeE(0), |
82 | fTreeH(0), | |
83 | fTreeD(0), | |
84 | fTreeS(0), | |
85 | fTreeR(0), | |
b5ee4425 | 86 | fTreeA(0), |
bf000c32 | 87 | fChainE(0), |
a1f80595 | 88 | fArrayE(0), |
89 | fArrayH(0), | |
90 | fArrayD(0), | |
91 | fArrayS(0), | |
bf000c32 | 92 | fArrayR(0), |
d760ea03 | 93 | fArrayA(0), |
17e542eb | 94 | fHeader(0), |
b5ee4425 | 95 | fGeoManager(0), |
a1f80595 | 96 | fTreeMask(0), |
17e542eb | 97 | fIsInit(kFALSE), |
98 | fEventCount(0) | |
a1f80595 | 99 | { |
df137876 | 100 | |
a1f80595 | 101 | // Constructor of an FMD input object. Specify what data to read in |
102 | // using the AddLoad member function. Sub-classes should at a | |
103 | // minimum overload the member function Event. A full job can be | |
104 | // executed using the member function Run. | |
105 | } | |
106 | ||
107 | ||
108 | ||
109 | //____________________________________________________________________ | |
110 | AliFMDInput::AliFMDInput(const char* gAliceFile) | |
111 | : fGAliceFile(gAliceFile), | |
112 | fLoader(0), | |
113 | fRun(0), | |
114 | fStack(0), | |
115 | fFMDLoader(0), | |
d760ea03 | 116 | fReader(0), |
a1f80595 | 117 | fFMD(0), |
bf000c32 | 118 | fESD(0), |
df137876 | 119 | fESDEvent(0), |
a1f80595 | 120 | fTreeE(0), |
121 | fTreeH(0), | |
122 | fTreeD(0), | |
123 | fTreeS(0), | |
124 | fTreeR(0), | |
b5ee4425 | 125 | fTreeA(0), |
bf000c32 | 126 | fChainE(0), |
a1f80595 | 127 | fArrayE(0), |
128 | fArrayH(0), | |
129 | fArrayD(0), | |
130 | fArrayS(0), | |
bf000c32 | 131 | fArrayR(0), |
d760ea03 | 132 | fArrayA(0), |
17e542eb | 133 | fHeader(0), |
b5ee4425 | 134 | fGeoManager(0), |
a1f80595 | 135 | fTreeMask(0), |
17e542eb | 136 | fIsInit(kFALSE), |
137 | fEventCount(0) | |
a1f80595 | 138 | { |
df137876 | 139 | |
a1f80595 | 140 | // Constructor of an FMD input object. Specify what data to read in |
141 | // using the AddLoad member function. Sub-classes should at a | |
142 | // minimum overload the member function Event. A full job can be | |
143 | // executed using the member function Run. | |
144 | } | |
145 | ||
146 | //____________________________________________________________________ | |
147 | Int_t | |
148 | AliFMDInput::NEvents() const | |
149 | { | |
150 | // Get number of events | |
151 | if (fTreeE) return fTreeE->GetEntries(); | |
152 | return -1; | |
153 | } | |
154 | ||
155 | //____________________________________________________________________ | |
156 | Bool_t | |
157 | AliFMDInput::Init() | |
158 | { | |
159 | // Initialize the object. Get the needed loaders, and such. | |
160 | ||
161 | // Check if we have been initialized | |
162 | if (fIsInit) { | |
163 | AliWarning("Already initialized"); | |
164 | return fIsInit; | |
165 | } | |
166 | if (fGAliceFile.IsNull()) fGAliceFile = "galice.root"; | |
167 | // Get the loader | |
168 | fLoader = AliRunLoader::Open(fGAliceFile.Data(), "Alice", "read"); | |
169 | if (!fLoader) { | |
170 | AliError(Form("Coulnd't read the file %s", fGAliceFile.Data())); | |
171 | return kFALSE; | |
172 | } | |
173 | ||
174 | // Get the run | |
175 | if (fLoader->LoadgAlice()) return kFALSE; | |
176 | fRun = fLoader->GetAliRun(); | |
177 | ||
178 | // Get the FMD | |
179 | fFMD = static_cast<AliFMD*>(fRun->GetDetector("FMD")); | |
180 | if (!fFMD) { | |
181 | AliError("Failed to get detector FMD from loader"); | |
182 | return kFALSE; | |
183 | } | |
184 | ||
185 | // Get the FMD loader | |
186 | fFMDLoader = fLoader->GetLoader("FMDLoader"); | |
187 | if (!fFMDLoader) { | |
188 | AliError("Failed to get detector FMD loader from loader"); | |
189 | return kFALSE; | |
190 | } | |
191 | if (fLoader->LoadHeader()) { | |
192 | AliError("Failed to get event header information from loader"); | |
193 | return kFALSE; | |
194 | } | |
195 | fTreeE = fLoader->TreeE(); | |
8f6ee336 | 196 | |
bf000c32 | 197 | // Optionally, get the ESD files |
198 | if (TESTBIT(fTreeMask, kESD)) { | |
199 | fChainE = new TChain("esdTree"); | |
c2fc1258 | 200 | TSystemDirectory dir(".","."); |
bf000c32 | 201 | TList* files = dir.GetListOfFiles(); |
c2fc1258 | 202 | TSystemFile* file = 0; |
203 | if (!files) { | |
204 | AliError("No files"); | |
205 | return kFALSE; | |
206 | } | |
bf000c32 | 207 | files->Sort(); |
208 | TIter next(files); | |
209 | while ((file = static_cast<TSystemFile*>(next()))) { | |
210 | TString fname(file->GetName()); | |
211 | if (fname.Contains("AliESDs")) fChainE->AddFile(fname.Data()); | |
212 | } | |
df137876 | 213 | fESDEvent = new AliESDEvent(); |
214 | fESDEvent->ReadFromTree(fChainE); | |
215 | // fChainE->SetBranchAddress("ESD", &fMainESD); | |
216 | ||
bf000c32 | 217 | } |
218 | ||
d760ea03 | 219 | if (TESTBIT(fTreeMask, kRaw)) { |
220 | AliInfo("Getting FMD raw data digits"); | |
221 | fArrayA = new TClonesArray("AliFMDDigit"); | |
222 | fReader = new AliRawReaderFile(-1); | |
223 | } | |
224 | ||
8f6ee336 | 225 | // Optionally, get the geometry |
226 | if (TESTBIT(fTreeMask, kGeometry)) { | |
227 | TString fname(fRun->GetGeometryFileName()); | |
228 | if (fname.IsNull()) { | |
229 | Warning("Init", "No file name for the geometry from AliRun"); | |
230 | fname = gSystem->DirName(fGAliceFile); | |
231 | fname.Append("/geometry.root"); | |
232 | } | |
233 | fGeoManager = TGeoManager::Import(fname.Data()); | |
234 | if (!fGeoManager) { | |
235 | Fatal("Init", "No geometry manager found"); | |
236 | return kFALSE; | |
237 | } | |
1e8f773e | 238 | AliCDBManager* cdb = AliCDBManager::Instance(); |
239 | AliCDBEntry* align = cdb->Get("FMD/Align/Data"); | |
240 | if (align) { | |
241 | AliInfo("Got alignment data from CDB"); | |
242 | TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject()); | |
243 | if (!array) { | |
244 | AliWarning("Invalid align data from CDB"); | |
245 | } | |
246 | else { | |
247 | Int_t nAlign = array->GetEntries(); | |
248 | for (Int_t i = 0; i < nAlign; i++) { | |
90dbf5fb | 249 | AliAlignObjParams* a = static_cast<AliAlignObjParams*>(array->At(i)); |
1e8f773e | 250 | if (!a->ApplyToGeometry()) { |
251 | AliWarning(Form("Failed to apply alignment to %s", | |
b760c02e | 252 | a->GetSymName())); |
1e8f773e | 253 | } |
254 | } | |
255 | } | |
256 | } | |
8f6ee336 | 257 | } |
bf000c32 | 258 | |
69893a66 | 259 | fEventCount = 0; |
a1f80595 | 260 | fIsInit = kTRUE; |
261 | return fIsInit; | |
262 | } | |
263 | ||
264 | //____________________________________________________________________ | |
265 | Bool_t | |
266 | AliFMDInput::Begin(Int_t event) | |
267 | { | |
268 | // Called at the begining of each event. Per default, it gets the | |
269 | // data trees and gets pointers to the output arrays. Users can | |
270 | // overload this, but should call this member function in the | |
271 | // overloaded member function of the derived class. | |
272 | ||
273 | // Check if we have been initialized | |
274 | if (!fIsInit) { | |
275 | AliError("Not initialized"); | |
276 | return fIsInit; | |
277 | } | |
7003fbd0 | 278 | |
a1f80595 | 279 | // Get the event |
280 | if (fLoader->GetEvent(event)) return kFALSE; | |
69893a66 | 281 | AliInfo(Form("Now in event %8d/%8d", event, NEvents())); |
a1f80595 | 282 | |
283 | // Possibly load global kinematics information | |
f95a63c4 | 284 | if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) { |
69893a66 | 285 | // AliInfo("Getting kinematics"); |
a1f80595 | 286 | if (fLoader->LoadKinematics()) return kFALSE; |
287 | fStack = fLoader->Stack(); | |
288 | } | |
7003fbd0 | 289 | |
a1f80595 | 290 | // Possibly load FMD Hit information |
f95a63c4 | 291 | if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) { |
69893a66 | 292 | // AliInfo("Getting FMD hits"); |
293 | if (!fFMDLoader || fFMDLoader->LoadHits()) return kFALSE; | |
a1f80595 | 294 | fTreeH = fFMDLoader->TreeH(); |
295 | if (!fArrayH) fArrayH = fFMD->Hits(); | |
296 | } | |
7003fbd0 | 297 | |
9b98d361 | 298 | // Possibly load heaedr information |
299 | if (TESTBIT(fTreeMask, kHeader)) { | |
300 | // AliInfo("Getting FMD hits"); | |
301 | if (!fLoader /* || fLoader->LoadHeader()*/) return kFALSE; | |
302 | fHeader = fLoader->GetHeader(); | |
303 | } | |
304 | ||
a1f80595 | 305 | // Possibly load FMD Digit information |
306 | if (TESTBIT(fTreeMask, kDigits)) { | |
69893a66 | 307 | // AliInfo("Getting FMD digits"); |
308 | if (!fFMDLoader || fFMDLoader->LoadDigits()) return kFALSE; | |
a1f80595 | 309 | fTreeD = fFMDLoader->TreeD(); |
a9579262 | 310 | if (fTreeD) { |
311 | if (!fArrayD) fArrayD = fFMD->Digits(); | |
312 | } | |
313 | else { | |
314 | fArrayD = 0; | |
315 | AliWarning(Form("Failed to load FMD Digits")); | |
316 | } | |
a1f80595 | 317 | } |
7003fbd0 | 318 | |
a1f80595 | 319 | // Possibly load FMD Sdigit information |
320 | if (TESTBIT(fTreeMask, kSDigits)) { | |
69893a66 | 321 | // AliInfo("Getting FMD summable digits"); |
322 | if (!fFMDLoader || fFMDLoader->LoadSDigits()) return kFALSE; | |
a1f80595 | 323 | fTreeS = fFMDLoader->TreeS(); |
324 | if (!fArrayS) fArrayS = fFMD->SDigits(); | |
325 | } | |
7003fbd0 | 326 | |
a1f80595 | 327 | // Possibly load FMD RecPoints information |
328 | if (TESTBIT(fTreeMask, kRecPoints)) { | |
69893a66 | 329 | // AliInfo("Getting FMD reconstructed points"); |
330 | if (!fFMDLoader || fFMDLoader->LoadRecPoints()) return kFALSE; | |
a1f80595 | 331 | fTreeR = fFMDLoader->TreeR(); |
bf000c32 | 332 | if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint"); |
333 | fTreeR->SetBranchAddress("FMD", &fArrayR); | |
7003fbd0 | 334 | } |
335 | ||
336 | // Possibly load FMD ESD information | |
bf000c32 | 337 | if (TESTBIT(fTreeMask, kESD)) { |
69893a66 | 338 | // AliInfo("Getting FMD event summary data"); |
bf000c32 | 339 | Int_t read = fChainE->GetEntry(event); |
340 | if (read <= 0) return kFALSE; | |
df137876 | 341 | fESD = fESDEvent->GetFMDData(); |
bf000c32 | 342 | if (!fESD) return kFALSE; |
7003fbd0 | 343 | #if 0 |
97b4001e | 344 | TFile* f = fChainE->GetFile(); |
345 | if (f) { | |
346 | TObject* o = f->GetStreamerInfoList()->FindObject("AliFMDMap"); | |
347 | if (o) { | |
348 | TStreamerInfo* info = static_cast<TStreamerInfo*>(o); | |
349 | std::cout << "AliFMDMap class version read is " | |
350 | << info->GetClassVersion() << std::endl; | |
351 | } | |
352 | } | |
353 | // fESD->CheckNeedUShort(fChainE->GetFile()); | |
7003fbd0 | 354 | #endif |
bf000c32 | 355 | } |
7003fbd0 | 356 | |
d760ea03 | 357 | // Possibly load FMD Digit information |
358 | if (TESTBIT(fTreeMask, kRaw)) { | |
69893a66 | 359 | // AliInfo("Getting FMD raw data digits"); |
d760ea03 | 360 | if (!fReader->NextEvent()) return kFALSE; |
361 | AliFMDRawReader r(fReader, 0); | |
362 | fArrayA->Clear(); | |
363 | r.ReadAdcs(fArrayA); | |
364 | } | |
69893a66 | 365 | fEventCount++; |
bf000c32 | 366 | return kTRUE; |
367 | } | |
368 | ||
369 | ||
370 | //____________________________________________________________________ | |
371 | Bool_t | |
372 | AliFMDInput::Event() | |
373 | { | |
374 | // Process one event. The default implementation one or more of | |
375 | // | |
376 | // - ProcessHits if the hits are loaded. | |
377 | // - ProcessDigits if the digits are loaded. | |
378 | // - ProcessSDigits if the sumbable digits are loaded. | |
379 | // - ProcessRecPoints if the reconstructed points are loaded. | |
380 | // - ProcessESD if the event summary data is loaded | |
381 | // | |
382 | if (TESTBIT(fTreeMask, kHits)) | |
383 | if (!ProcessHits()) return kFALSE; | |
f95a63c4 | 384 | if (TESTBIT(fTreeMask, kTracks)) |
385 | if (!ProcessTracks()) return kFALSE; | |
bf000c32 | 386 | if (TESTBIT(fTreeMask, kDigits)) |
387 | if (!ProcessDigits()) return kFALSE; | |
388 | if (TESTBIT(fTreeMask, kSDigits)) | |
389 | if (!ProcessSDigits()) return kFALSE; | |
d760ea03 | 390 | if (TESTBIT(fTreeMask, kRaw)) |
391 | if (!ProcessRawDigits()) return kFALSE; | |
bf000c32 | 392 | if (TESTBIT(fTreeMask, kRecPoints)) |
393 | if (!ProcessRecPoints()) return kFALSE; | |
394 | if (TESTBIT(fTreeMask, kESD)) | |
a9579262 | 395 | if (!ProcessESDs()) return kFALSE; |
bf000c32 | 396 | |
397 | return kTRUE; | |
398 | } | |
399 | ||
400 | //____________________________________________________________________ | |
401 | Bool_t | |
402 | AliFMDInput::ProcessHits() | |
403 | { | |
02a27b50 | 404 | // Read the hit tree, and pass each hit to the member function |
405 | // ProcessHit. | |
bf000c32 | 406 | if (!fTreeH) { |
407 | AliError("No hit tree defined"); | |
408 | return kFALSE; | |
409 | } | |
ddaa8027 | 410 | if (!fArrayH) { |
411 | AliError("No hit array defined"); | |
412 | return kFALSE; | |
413 | } | |
414 | ||
bf000c32 | 415 | Int_t nTracks = fTreeH->GetEntries(); |
416 | for (Int_t i = 0; i < nTracks; i++) { | |
417 | Int_t hitRead = fTreeH->GetEntry(i); | |
418 | if (hitRead <= 0) continue; | |
ddaa8027 | 419 | |
bf000c32 | 420 | Int_t nHit = fArrayH->GetEntries(); |
421 | if (nHit <= 0) continue; | |
ddaa8027 | 422 | |
bf000c32 | 423 | for (Int_t j = 0; j < nHit; j++) { |
424 | AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j)); | |
425 | if (!hit) continue; | |
ddaa8027 | 426 | |
bf000c32 | 427 | TParticle* track = 0; |
428 | if (TESTBIT(fTreeMask, kKinematics) && fStack) { | |
429 | Int_t trackno = hit->Track(); | |
430 | track = fStack->Particle(trackno); | |
431 | } | |
432 | if (!ProcessHit(hit, track)) return kFALSE; | |
433 | } | |
434 | } | |
435 | return kTRUE; | |
436 | } | |
437 | ||
f95a63c4 | 438 | //____________________________________________________________________ |
439 | Bool_t | |
440 | AliFMDInput::ProcessTracks() | |
441 | { | |
442 | // Read the hit tree, and pass each hit to the member function | |
ddaa8027 | 443 | // ProcessTrack. |
f95a63c4 | 444 | if (!fStack) { |
445 | AliError("No track tree defined"); | |
446 | return kFALSE; | |
447 | } | |
448 | if (!fTreeH) { | |
449 | AliError("No hit tree defined"); | |
450 | return kFALSE; | |
451 | } | |
ddaa8027 | 452 | if (!fArrayH) { |
453 | AliError("No hit array defined"); | |
454 | return kFALSE; | |
455 | } | |
456 | ||
457 | // Int_t nTracks = fStack->GetNtrack(); | |
f95a63c4 | 458 | Int_t nTracks = fTreeH->GetEntries(); |
459 | for (Int_t i = 0; i < nTracks; i++) { | |
ddaa8027 | 460 | Int_t trackno = nTracks - i - 1; |
461 | TParticle* track = fStack->Particle(trackno); | |
f95a63c4 | 462 | if (!track) continue; |
ddaa8027 | 463 | |
464 | // Get the hits for this track. | |
f95a63c4 | 465 | Int_t hitRead = fTreeH->GetEntry(i); |
ddaa8027 | 466 | Int_t nHit = fArrayH->GetEntries(); |
467 | if (nHit == 0 || hitRead <= 0) { | |
468 | // Let user code see the track, even if there's no hits. | |
469 | if (!ProcessTrack(trackno, track, 0)) return kFALSE; | |
470 | continue; | |
f95a63c4 | 471 | } |
f95a63c4 | 472 | |
ddaa8027 | 473 | // Loop over the hits corresponding to this track. |
f95a63c4 | 474 | for (Int_t j = 0; j < nHit; j++) { |
475 | AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j)); | |
ddaa8027 | 476 | if (!ProcessTrack(trackno, track, hit)) return kFALSE; |
477 | } | |
f95a63c4 | 478 | } |
479 | return kTRUE; | |
480 | } | |
481 | ||
bf000c32 | 482 | //____________________________________________________________________ |
483 | Bool_t | |
484 | AliFMDInput::ProcessDigits() | |
485 | { | |
486 | // Read the digit tree, and pass each digit to the member function | |
487 | // ProcessDigit. | |
488 | Int_t nEv = fTreeD->GetEntries(); | |
489 | for (Int_t i = 0; i < nEv; i++) { | |
490 | Int_t digitRead = fTreeD->GetEntry(i); | |
491 | if (digitRead <= 0) continue; | |
492 | Int_t nDigit = fArrayD->GetEntries(); | |
493 | if (nDigit <= 0) continue; | |
494 | for (Int_t j = 0; j < nDigit; j++) { | |
495 | AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j)); | |
496 | if (!digit) continue; | |
497 | if (!ProcessDigit(digit)) return kFALSE; | |
498 | } | |
499 | } | |
500 | return kTRUE; | |
501 | } | |
502 | ||
503 | //____________________________________________________________________ | |
504 | Bool_t | |
505 | AliFMDInput::ProcessSDigits() | |
506 | { | |
507 | // Read the summable digit tree, and pass each sumable digit to the | |
508 | // member function ProcessSdigit. | |
509 | Int_t nEv = fTreeD->GetEntries(); | |
510 | for (Int_t i = 0; i < nEv; i++) { | |
511 | Int_t sdigitRead = fTreeS->GetEntry(i); | |
512 | if (sdigitRead <= 0) continue; | |
513 | Int_t nSdigit = fArrayS->GetEntries(); | |
514 | if (nSdigit <= 0) continue; | |
515 | for (Int_t j = 0; j < nSdigit; j++) { | |
516 | AliFMDSDigit* sdigit = static_cast<AliFMDSDigit*>(fArrayS->At(j)); | |
517 | if (!sdigit) continue; | |
518 | if (!ProcessSDigit(sdigit)) return kFALSE; | |
519 | } | |
520 | } | |
521 | return kTRUE; | |
522 | } | |
523 | ||
d760ea03 | 524 | //____________________________________________________________________ |
525 | Bool_t | |
526 | AliFMDInput::ProcessRawDigits() | |
527 | { | |
528 | // Read the digit tree, and pass each digit to the member function | |
529 | // ProcessDigit. | |
530 | Int_t nDigit = fArrayA->GetEntries(); | |
531 | if (nDigit <= 0) return kTRUE; | |
532 | for (Int_t j = 0; j < nDigit; j++) { | |
533 | AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j)); | |
534 | if (!digit) continue; | |
535 | if (!ProcessRawDigit(digit)) return kFALSE; | |
536 | } | |
537 | return kTRUE; | |
538 | } | |
539 | ||
bf000c32 | 540 | //____________________________________________________________________ |
541 | Bool_t | |
542 | AliFMDInput::ProcessRecPoints() | |
543 | { | |
544 | // Read the reconstrcted points tree, and pass each reconstruction | |
545 | // object (AliFMDRecPoint) to either ProcessRecPoint. | |
546 | Int_t nEv = fTreeR->GetEntries(); | |
547 | for (Int_t i = 0; i < nEv; i++) { | |
548 | Int_t recRead = fTreeR->GetEntry(i); | |
549 | if (recRead <= 0) continue; | |
550 | Int_t nRecPoint = fArrayR->GetEntries(); | |
551 | for (Int_t j = 0; j < nRecPoint; j++) { | |
552 | AliFMDRecPoint* recPoint = static_cast<AliFMDRecPoint*>(fArrayR->At(j)); | |
553 | if (!recPoint) continue; | |
554 | if (!ProcessRecPoint(recPoint)) return kFALSE; | |
555 | } | |
a1f80595 | 556 | } |
557 | return kTRUE; | |
558 | } | |
559 | ||
a9579262 | 560 | //____________________________________________________________________ |
561 | Bool_t | |
562 | AliFMDInput::ProcessESDs() | |
563 | { | |
564 | // Process event summary data | |
565 | if (!fESD) return kFALSE; | |
566 | for (UShort_t det = 1; det <= 3; det++) { | |
567 | Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' }; | |
568 | for (Char_t* rng = rings; *rng != '\0'; rng++) { | |
569 | UShort_t nsec = (*rng == 'I' ? 20 : 40); | |
570 | UShort_t nstr = (*rng == 'I' ? 512 : 256); | |
571 | for (UShort_t sec = 0; sec < nsec; sec++) { | |
572 | for (UShort_t str = 0; str < nstr; str++) { | |
573 | Float_t eta = fESD->Eta(det,*rng,sec,str); | |
574 | Float_t mult = fESD->Multiplicity(det,*rng,sec,str); | |
97b4001e | 575 | if (!fESD->IsAngleCorrected()) |
576 | mult *= TMath::Abs(TMath::Cos(2.*TMath::ATan(TMath::Exp(-eta)))); | |
a9579262 | 577 | if (!ProcessESD(det, *rng, sec, str, eta, mult)) continue; |
578 | } | |
579 | } | |
580 | } | |
581 | } | |
582 | return kTRUE; | |
583 | } | |
584 | ||
a1f80595 | 585 | //____________________________________________________________________ |
586 | Bool_t | |
587 | AliFMDInput::End() | |
588 | { | |
589 | // Called at the end of each event. Per default, it unloads the | |
590 | // data trees and resets the pointers to the output arrays. Users | |
591 | // can overload this, but should call this member function in the | |
592 | // overloaded member function of the derived class. | |
593 | ||
594 | // Check if we have been initialized | |
595 | if (!fIsInit) { | |
596 | AliError("Not initialized"); | |
597 | return fIsInit; | |
598 | } | |
599 | // Possibly unload global kinematics information | |
f95a63c4 | 600 | if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) { |
a1f80595 | 601 | fLoader->UnloadKinematics(); |
602 | // fTreeK = 0; | |
603 | fStack = 0; | |
604 | } | |
605 | // Possibly unload FMD Hit information | |
f95a63c4 | 606 | if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) { |
a1f80595 | 607 | fFMDLoader->UnloadHits(); |
608 | fTreeH = 0; | |
609 | } | |
610 | // Possibly unload FMD Digit information | |
611 | if (TESTBIT(fTreeMask, kDigits)) { | |
612 | fFMDLoader->UnloadDigits(); | |
613 | fTreeD = 0; | |
614 | } | |
615 | // Possibly unload FMD Sdigit information | |
616 | if (TESTBIT(fTreeMask, kSDigits)) { | |
617 | fFMDLoader->UnloadSDigits(); | |
618 | fTreeS = 0; | |
619 | } | |
620 | // Possibly unload FMD RecPoints information | |
621 | if (TESTBIT(fTreeMask, kRecPoints)) { | |
622 | fFMDLoader->UnloadRecPoints(); | |
623 | fTreeR = 0; | |
624 | } | |
f48d9b11 | 625 | // AliInfo("Now out event"); |
a1f80595 | 626 | return kTRUE; |
627 | } | |
628 | ||
629 | //____________________________________________________________________ | |
630 | Bool_t | |
631 | AliFMDInput::Run() | |
632 | { | |
633 | // Run over all events and files references in galice.root | |
634 | ||
635 | Bool_t retval; | |
636 | if (!(retval = Init())) return retval; | |
637 | ||
638 | Int_t nEvents = NEvents(); | |
639 | for (Int_t event = 0; event < nEvents; event++) { | |
640 | if (!(retval = Begin(event))) break; | |
641 | if (!(retval = Event())) break; | |
642 | if (!(retval = End())) break; | |
643 | } | |
644 | if (!retval) return retval; | |
645 | retval = Finish(); | |
646 | return retval; | |
647 | } | |
648 | ||
69893a66 | 649 | //__________________________________________________________________ |
650 | TArrayF | |
651 | AliFMDInput::MakeLogScale(Int_t n, Double_t min, Double_t max) | |
652 | { | |
653 | // Service function to define a logarithmic axis. | |
654 | // Parameters: | |
655 | // n Number of bins | |
656 | // min Minimum of axis | |
657 | // max Maximum of axis | |
658 | TArrayF bins(n+1); | |
659 | bins[0] = min; | |
660 | if (n <= 20) { | |
661 | for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n; | |
662 | return bins; | |
663 | } | |
664 | Float_t dp = n / TMath::Log10(max / min); | |
665 | Float_t pmin = TMath::Log10(min); | |
666 | for (Int_t i = 1; i < n+1; i++) { | |
667 | Float_t p = pmin + i / dp; | |
668 | bins[i] = TMath::Power(10, p); | |
669 | } | |
670 | return bins; | |
671 | } | |
672 | ||
673 | ||
a1f80595 | 674 | |
a1f80595 | 675 | //____________________________________________________________________ |
676 | // | |
677 | // EOF | |
678 | // |