]>
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 |
039842fe | 38 | #include "AliRawReaderRoot.h" // ALIRAWREADERROOT_H |
39 | #include "AliRawReaderDate.h" // ALIRAWREADERDATE_H | |
e1a9aea4 | 40 | #include "AliRawEventHeaderBase.h" |
8f6ee336 | 41 | #include "AliFMD.h" // ALIFMD_H |
a1f80595 | 42 | #include "AliFMDHit.h" // ALIFMDHIT_H |
8f6ee336 | 43 | #include "AliFMDDigit.h" // ALIFMDDigit_H |
02a27b50 | 44 | #include "AliFMDSDigit.h" // ALIFMDDigit_H |
bf000c32 | 45 | #include "AliFMDRecPoint.h" // ALIFMDRECPOINT_H |
d760ea03 | 46 | #include "AliFMDRawReader.h" // ALIFMDRAWREADER_H |
bf000c32 | 47 | #include <AliESD.h> |
48 | #include <AliESDFMD.h> | |
df137876 | 49 | #include <AliESDEvent.h> |
1e8f773e | 50 | #include <AliCDBManager.h> |
51 | #include <AliCDBEntry.h> | |
90dbf5fb | 52 | #include <AliAlignObjParams.h> |
08d168d9 | 53 | #include <AliTrackReference.h> |
8f6ee336 | 54 | #include <TTree.h> // ROOT_TTree |
bf000c32 | 55 | #include <TChain.h> // ROOT_TChain |
8f6ee336 | 56 | #include <TParticle.h> // ROOT_TParticle |
57 | #include <TString.h> // ROOT_TString | |
58 | #include <TDatabasePDG.h> // ROOT_TDatabasePDG | |
59 | #include <TMath.h> // ROOT_TMath | |
60 | #include <TGeoManager.h> // ROOT_TGeoManager | |
bf000c32 | 61 | #include <TSystemDirectory.h> // ROOT_TSystemDirectory |
8f6ee336 | 62 | #include <Riostream.h> // ROOT_Riostream |
97b4001e | 63 | #include <TFile.h> // ROOT_TFile |
a1e17193 | 64 | #include <TStreamerInfo.h> |
7003fbd0 | 65 | #include <TArrayF.h> |
66 | ||
a1f80595 | 67 | //____________________________________________________________________ |
68 | ClassImp(AliFMDInput) | |
69 | #if 0 | |
70 | ; // This is here to keep Emacs for indenting the next line | |
71 | #endif | |
72 | ||
73 | ||
74 | //____________________________________________________________________ | |
75 | AliFMDInput::AliFMDInput() | |
42f1b2f5 | 76 | : TNamed("AliFMDInput", "Input handler for various FMD data"), |
77 | fGAliceFile(""), | |
a1f80595 | 78 | fLoader(0), |
79 | fRun(0), | |
80 | fStack(0), | |
81 | fFMDLoader(0), | |
d760ea03 | 82 | fReader(0), |
5cf05dbb | 83 | fFMDReader(0), |
a1f80595 | 84 | fFMD(0), |
bf000c32 | 85 | fESD(0), |
df137876 | 86 | fESDEvent(0), |
a1f80595 | 87 | fTreeE(0), |
88 | fTreeH(0), | |
08d168d9 | 89 | fTreeTR(0), |
a1f80595 | 90 | fTreeD(0), |
91 | fTreeS(0), | |
92 | fTreeR(0), | |
b5ee4425 | 93 | fTreeA(0), |
bf000c32 | 94 | fChainE(0), |
a1f80595 | 95 | fArrayE(0), |
96 | fArrayH(0), | |
faf80567 | 97 | fArrayTR(0), |
a1f80595 | 98 | fArrayD(0), |
99 | fArrayS(0), | |
bf000c32 | 100 | fArrayR(0), |
d760ea03 | 101 | fArrayA(0), |
17e542eb | 102 | fHeader(0), |
b5ee4425 | 103 | fGeoManager(0), |
a1f80595 | 104 | fTreeMask(0), |
039842fe | 105 | fRawFile(""), |
17e542eb | 106 | fIsInit(kFALSE), |
107 | fEventCount(0) | |
a1f80595 | 108 | { |
df137876 | 109 | |
a1f80595 | 110 | // Constructor of an FMD input object. Specify what data to read in |
111 | // using the AddLoad member function. Sub-classes should at a | |
112 | // minimum overload the member function Event. A full job can be | |
113 | // executed using the member function Run. | |
114 | } | |
115 | ||
116 | ||
117 | ||
118 | //____________________________________________________________________ | |
119 | AliFMDInput::AliFMDInput(const char* gAliceFile) | |
42f1b2f5 | 120 | : TNamed("AliFMDInput", "Input handler for various FMD data"), |
121 | fGAliceFile(gAliceFile), | |
a1f80595 | 122 | fLoader(0), |
123 | fRun(0), | |
124 | fStack(0), | |
125 | fFMDLoader(0), | |
d760ea03 | 126 | fReader(0), |
5cf05dbb | 127 | fFMDReader(0), |
a1f80595 | 128 | fFMD(0), |
bf000c32 | 129 | fESD(0), |
df137876 | 130 | fESDEvent(0), |
a1f80595 | 131 | fTreeE(0), |
132 | fTreeH(0), | |
08d168d9 | 133 | fTreeTR(0), |
a1f80595 | 134 | fTreeD(0), |
135 | fTreeS(0), | |
136 | fTreeR(0), | |
b5ee4425 | 137 | fTreeA(0), |
bf000c32 | 138 | fChainE(0), |
a1f80595 | 139 | fArrayE(0), |
140 | fArrayH(0), | |
faf80567 | 141 | fArrayTR(0), |
a1f80595 | 142 | fArrayD(0), |
143 | fArrayS(0), | |
bf000c32 | 144 | fArrayR(0), |
d760ea03 | 145 | fArrayA(0), |
17e542eb | 146 | fHeader(0), |
b5ee4425 | 147 | fGeoManager(0), |
a1f80595 | 148 | fTreeMask(0), |
039842fe | 149 | fRawFile(""), |
17e542eb | 150 | fIsInit(kFALSE), |
151 | fEventCount(0) | |
a1f80595 | 152 | { |
df137876 | 153 | |
a1f80595 | 154 | // Constructor of an FMD input object. Specify what data to read in |
155 | // using the AddLoad member function. Sub-classes should at a | |
156 | // minimum overload the member function Event. A full job can be | |
157 | // executed using the member function Run. | |
158 | } | |
159 | ||
160 | //____________________________________________________________________ | |
161 | Int_t | |
162 | AliFMDInput::NEvents() const | |
163 | { | |
164 | // Get number of events | |
e064ab4a | 165 | if (TESTBIT(fTreeMask, kRaw) || |
166 | TESTBIT(fTreeMask, kRawCalib)) return fReader->GetNumberOfEvents(); | |
faf80567 | 167 | if (fChainE) return fChainE->GetEntriesFast(); |
a1f80595 | 168 | if (fTreeE) return fTreeE->GetEntries(); |
169 | return -1; | |
170 | } | |
171 | ||
172 | //____________________________________________________________________ | |
173 | Bool_t | |
174 | AliFMDInput::Init() | |
175 | { | |
176 | // Initialize the object. Get the needed loaders, and such. | |
177 | ||
178 | // Check if we have been initialized | |
179 | if (fIsInit) { | |
180 | AliWarning("Already initialized"); | |
181 | return fIsInit; | |
182 | } | |
faf80567 | 183 | Info("Init","Initialising w/mask 0x%04x\n" |
184 | "\tHits: %d\n" | |
185 | "\tKinematics: %d\n" | |
186 | "\tDigits: %d\n" | |
187 | "\tSDigits: %d\n" | |
188 | "\tHeader: %d\n" | |
189 | "\tRecPoints: %d\n" | |
190 | "\tESD: %d\n" | |
191 | "\tRaw: %d\n" | |
e064ab4a | 192 | "\tRawCalib: %d\n" |
faf80567 | 193 | "\tGeometry: %d\n" |
194 | "\tTracks: %d\n" | |
195 | "\tTracksRefs: %d", | |
196 | fTreeMask, | |
197 | TESTBIT(fTreeMask, kHits), | |
198 | TESTBIT(fTreeMask, kKinematics), | |
199 | TESTBIT(fTreeMask, kDigits), | |
200 | TESTBIT(fTreeMask, kSDigits), | |
201 | TESTBIT(fTreeMask, kHeader), | |
202 | TESTBIT(fTreeMask, kRecPoints), | |
203 | TESTBIT(fTreeMask, kESD), | |
204 | TESTBIT(fTreeMask, kRaw), | |
e064ab4a | 205 | TESTBIT(fTreeMask, kRawCalib), |
faf80567 | 206 | TESTBIT(fTreeMask, kGeometry), |
207 | TESTBIT(fTreeMask, kTracks), | |
208 | TESTBIT(fTreeMask, kTrackRefs)); | |
a1f80595 | 209 | // Get the run |
faf80567 | 210 | if (TESTBIT(fTreeMask, kDigits) || |
211 | TESTBIT(fTreeMask, kSDigits) || | |
212 | TESTBIT(fTreeMask, kKinematics) || | |
213 | TESTBIT(fTreeMask, kTrackRefs) || | |
214 | TESTBIT(fTreeMask, kTracks) || | |
215 | TESTBIT(fTreeMask, kHeader)) { | |
216 | if (!gSystem->FindFile(".:/", fGAliceFile)) { | |
217 | AliWarning(Form("Cannot find file %s in .:/", fGAliceFile.Data())); | |
59194467 | 218 | } |
faf80567 | 219 | else { |
220 | fLoader = AliRunLoader::Open(fGAliceFile.Data(), "Alice", "read"); | |
221 | if (!fLoader) { | |
222 | AliError(Form("Coulnd't read the file %s", fGAliceFile.Data())); | |
223 | return kFALSE; | |
224 | } | |
225 | AliInfo(Form("Opened GAlice file %s", fGAliceFile.Data())); | |
226 | ||
227 | if (fLoader->LoadgAlice()) return kFALSE; | |
228 | ||
229 | fRun = fLoader->GetAliRun(); | |
230 | ||
231 | // Get the FMD | |
232 | fFMD = static_cast<AliFMD*>(fRun->GetDetector("FMD")); | |
233 | if (!fFMD) { | |
234 | AliError("Failed to get detector FMD from loader"); | |
235 | return kFALSE; | |
236 | } | |
237 | ||
238 | // Get the FMD loader | |
239 | fFMDLoader = fLoader->GetLoader("FMDLoader"); | |
240 | if (!fFMDLoader) { | |
241 | AliError("Failed to get detector FMD loader from loader"); | |
242 | return kFALSE; | |
243 | } | |
244 | if (fLoader->LoadHeader()) { | |
245 | AliError("Failed to get event header information from loader"); | |
246 | return kFALSE; | |
247 | } | |
248 | fTreeE = fLoader->TreeE(); | |
59194467 | 249 | } |
a1f80595 | 250 | } |
8f6ee336 | 251 | |
bf000c32 | 252 | // Optionally, get the ESD files |
253 | if (TESTBIT(fTreeMask, kESD)) { | |
254 | fChainE = new TChain("esdTree"); | |
c2fc1258 | 255 | TSystemDirectory dir(".","."); |
bf000c32 | 256 | TList* files = dir.GetListOfFiles(); |
c2fc1258 | 257 | TSystemFile* file = 0; |
258 | if (!files) { | |
259 | AliError("No files"); | |
260 | return kFALSE; | |
261 | } | |
bf000c32 | 262 | files->Sort(); |
263 | TIter next(files); | |
264 | while ((file = static_cast<TSystemFile*>(next()))) { | |
265 | TString fname(file->GetName()); | |
266 | if (fname.Contains("AliESDs")) fChainE->AddFile(fname.Data()); | |
267 | } | |
df137876 | 268 | fESDEvent = new AliESDEvent(); |
269 | fESDEvent->ReadFromTree(fChainE); | |
270 | // fChainE->SetBranchAddress("ESD", &fMainESD); | |
271 | ||
bf000c32 | 272 | } |
273 | ||
e064ab4a | 274 | if (TESTBIT(fTreeMask, kRaw) || |
275 | TESTBIT(fTreeMask, kRawCalib)) { | |
d760ea03 | 276 | AliInfo("Getting FMD raw data digits"); |
277 | fArrayA = new TClonesArray("AliFMDDigit"); | |
0b1b2076 | 278 | #if 0 |
279 | if (!fRawFile.IsNull() && fRawFile.EndsWith(".root")) | |
039842fe | 280 | fReader = new AliRawReaderRoot(fRawFile.Data()); |
281 | else if (!fRawFile.IsNull() && fRawFile.EndsWith(".raw")) | |
282 | fReader = new AliRawReaderDate(fRawFile.Data()); | |
283 | else | |
284 | fReader = new AliRawReaderFile(-1); | |
0b1b2076 | 285 | #else |
286 | if(!fRawFile.IsNull()) | |
287 | fReader = AliRawReader::Create(fRawFile.Data()); | |
288 | else | |
289 | fReader = new AliRawReaderFile(-1); | |
290 | #endif | |
5cf05dbb | 291 | fFMDReader = new AliFMDRawReader(fReader, 0); |
d760ea03 | 292 | } |
293 | ||
8f6ee336 | 294 | // Optionally, get the geometry |
295 | if (TESTBIT(fTreeMask, kGeometry)) { | |
59194467 | 296 | if (fRun) { |
297 | TString fname(fRun->GetGeometryFileName()); | |
298 | if (fname.IsNull()) { | |
299 | Warning("Init", "No file name for the geometry from AliRun"); | |
300 | fname = gSystem->DirName(fGAliceFile); | |
301 | fname.Append("/geometry.root"); | |
302 | } | |
303 | fGeoManager = TGeoManager::Import(fname.Data()); | |
304 | if (!fGeoManager) { | |
305 | Fatal("Init", "No geometry manager found"); | |
306 | return kFALSE; | |
307 | } | |
8f6ee336 | 308 | } |
59194467 | 309 | else { |
310 | AliGeomManager::LoadGeometry(); | |
8f6ee336 | 311 | } |
1e8f773e | 312 | AliCDBManager* cdb = AliCDBManager::Instance(); |
313 | AliCDBEntry* align = cdb->Get("FMD/Align/Data"); | |
314 | if (align) { | |
315 | AliInfo("Got alignment data from CDB"); | |
316 | TClonesArray* array = dynamic_cast<TClonesArray*>(align->GetObject()); | |
317 | if (!array) { | |
318 | AliWarning("Invalid align data from CDB"); | |
319 | } | |
320 | else { | |
321 | Int_t nAlign = array->GetEntries(); | |
322 | for (Int_t i = 0; i < nAlign; i++) { | |
90dbf5fb | 323 | AliAlignObjParams* a = static_cast<AliAlignObjParams*>(array->At(i)); |
1e8f773e | 324 | if (!a->ApplyToGeometry()) { |
325 | AliWarning(Form("Failed to apply alignment to %s", | |
b760c02e | 326 | a->GetSymName())); |
1e8f773e | 327 | } |
328 | } | |
329 | } | |
330 | } | |
8f6ee336 | 331 | } |
bf000c32 | 332 | |
69893a66 | 333 | fEventCount = 0; |
a1f80595 | 334 | fIsInit = kTRUE; |
335 | return fIsInit; | |
336 | } | |
337 | ||
338 | //____________________________________________________________________ | |
339 | Bool_t | |
340 | AliFMDInput::Begin(Int_t event) | |
341 | { | |
342 | // Called at the begining of each event. Per default, it gets the | |
343 | // data trees and gets pointers to the output arrays. Users can | |
344 | // overload this, but should call this member function in the | |
345 | // overloaded member function of the derived class. | |
346 | ||
347 | // Check if we have been initialized | |
348 | if (!fIsInit) { | |
349 | AliError("Not initialized"); | |
350 | return fIsInit; | |
351 | } | |
7003fbd0 | 352 | |
a1f80595 | 353 | // Get the event |
59194467 | 354 | if (fLoader && fLoader->GetEvent(event)) return kFALSE; |
69893a66 | 355 | AliInfo(Form("Now in event %8d/%8d", event, NEvents())); |
a1f80595 | 356 | |
357 | // Possibly load global kinematics information | |
f95a63c4 | 358 | if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) { |
69893a66 | 359 | // AliInfo("Getting kinematics"); |
42f1b2f5 | 360 | if (fLoader->LoadKinematics("READ")) return kFALSE; |
a1f80595 | 361 | fStack = fLoader->Stack(); |
362 | } | |
7003fbd0 | 363 | |
a1f80595 | 364 | // Possibly load FMD Hit information |
f95a63c4 | 365 | if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) { |
69893a66 | 366 | // AliInfo("Getting FMD hits"); |
42f1b2f5 | 367 | if (!fFMDLoader || fFMDLoader->LoadHits("READ")) return kFALSE; |
a1f80595 | 368 | fTreeH = fFMDLoader->TreeH(); |
369 | if (!fArrayH) fArrayH = fFMD->Hits(); | |
370 | } | |
08d168d9 | 371 | |
372 | // Possibly load FMD TrackReference information | |
373 | if (TESTBIT(fTreeMask, kTrackRefs) || TESTBIT(fTreeMask, kTracks)) { | |
374 | // AliInfo("Getting FMD hits"); | |
375 | if (!fLoader || fLoader->LoadTrackRefs("READ")) return kFALSE; | |
376 | fTreeTR = fLoader->TreeTR(); | |
377 | if (!fArrayTR) fArrayTR = new TClonesArray("AliTrackReference"); | |
378 | fTreeTR->SetBranchAddress("TrackReferences", &fArrayTR); | |
379 | } | |
380 | ||
9b98d361 | 381 | // Possibly load heaedr information |
382 | if (TESTBIT(fTreeMask, kHeader)) { | |
383 | // AliInfo("Getting FMD hits"); | |
384 | if (!fLoader /* || fLoader->LoadHeader()*/) return kFALSE; | |
385 | fHeader = fLoader->GetHeader(); | |
386 | } | |
387 | ||
a1f80595 | 388 | // Possibly load FMD Digit information |
389 | if (TESTBIT(fTreeMask, kDigits)) { | |
69893a66 | 390 | // AliInfo("Getting FMD digits"); |
42f1b2f5 | 391 | if (!fFMDLoader || fFMDLoader->LoadDigits("READ")) return kFALSE; |
a1f80595 | 392 | fTreeD = fFMDLoader->TreeD(); |
a9579262 | 393 | if (fTreeD) { |
394 | if (!fArrayD) fArrayD = fFMD->Digits(); | |
395 | } | |
396 | else { | |
397 | fArrayD = 0; | |
398 | AliWarning(Form("Failed to load FMD Digits")); | |
399 | } | |
a1f80595 | 400 | } |
7003fbd0 | 401 | |
a1f80595 | 402 | // Possibly load FMD Sdigit information |
403 | if (TESTBIT(fTreeMask, kSDigits)) { | |
69893a66 | 404 | // AliInfo("Getting FMD summable digits"); |
faf80567 | 405 | if (!fFMDLoader || fFMDLoader->LoadSDigits("READ")) { |
406 | AliWarning("Failed to load SDigits!"); | |
407 | return kFALSE; | |
408 | } | |
a1f80595 | 409 | fTreeS = fFMDLoader->TreeS(); |
410 | if (!fArrayS) fArrayS = fFMD->SDigits(); | |
411 | } | |
7003fbd0 | 412 | |
a1f80595 | 413 | // Possibly load FMD RecPoints information |
414 | if (TESTBIT(fTreeMask, kRecPoints)) { | |
69893a66 | 415 | // AliInfo("Getting FMD reconstructed points"); |
42f1b2f5 | 416 | if (!fFMDLoader || fFMDLoader->LoadRecPoints("READ")) return kFALSE; |
a1f80595 | 417 | fTreeR = fFMDLoader->TreeR(); |
bf000c32 | 418 | if (!fArrayR) fArrayR = new TClonesArray("AliFMDRecPoint"); |
419 | fTreeR->SetBranchAddress("FMD", &fArrayR); | |
7003fbd0 | 420 | } |
421 | ||
422 | // Possibly load FMD ESD information | |
bf000c32 | 423 | if (TESTBIT(fTreeMask, kESD)) { |
69893a66 | 424 | // AliInfo("Getting FMD event summary data"); |
bf000c32 | 425 | Int_t read = fChainE->GetEntry(event); |
426 | if (read <= 0) return kFALSE; | |
df137876 | 427 | fESD = fESDEvent->GetFMDData(); |
bf000c32 | 428 | if (!fESD) return kFALSE; |
7003fbd0 | 429 | #if 0 |
97b4001e | 430 | TFile* f = fChainE->GetFile(); |
431 | if (f) { | |
432 | TObject* o = f->GetStreamerInfoList()->FindObject("AliFMDMap"); | |
433 | if (o) { | |
434 | TStreamerInfo* info = static_cast<TStreamerInfo*>(o); | |
435 | std::cout << "AliFMDMap class version read is " | |
436 | << info->GetClassVersion() << std::endl; | |
437 | } | |
438 | } | |
439 | // fESD->CheckNeedUShort(fChainE->GetFile()); | |
7003fbd0 | 440 | #endif |
bf000c32 | 441 | } |
7003fbd0 | 442 | |
d760ea03 | 443 | // Possibly load FMD Digit information |
e064ab4a | 444 | if (TESTBIT(fTreeMask, kRaw) || TESTBIT(fTreeMask, kRawCalib)) { |
5cf05dbb | 445 | // AliInfo("Getting FMD raw data digits"); |
e064ab4a | 446 | std::cout << "Waiting for event ..." << std::endl; |
e1a9aea4 | 447 | do { |
448 | if (!fReader->NextEvent()) { | |
449 | if (fRawFile.Contains("mem://")) { | |
450 | gSystem->Sleep(3); | |
451 | continue; | |
452 | } | |
453 | return kFALSE; | |
454 | } | |
455 | UInt_t eventType = fReader->GetType(); | |
456 | if(eventType == AliRawEventHeaderBase::kPhysicsEvent || | |
457 | eventType == AliRawEventHeaderBase::kCalibrationEvent) | |
458 | break; | |
459 | } while (true); | |
5cf05dbb | 460 | // AliFMDRawReader r(fReader, 0); |
d760ea03 | 461 | fArrayA->Clear(); |
5cf05dbb | 462 | fFMDReader->ReadAdcs(fArrayA); |
59194467 | 463 | AliFMDDebug(1, ("Got a total of %d digits", fArrayA->GetEntriesFast())); |
d760ea03 | 464 | } |
69893a66 | 465 | fEventCount++; |
bf000c32 | 466 | return kTRUE; |
467 | } | |
468 | ||
469 | ||
470 | //____________________________________________________________________ | |
471 | Bool_t | |
472 | AliFMDInput::Event() | |
473 | { | |
474 | // Process one event. The default implementation one or more of | |
475 | // | |
476 | // - ProcessHits if the hits are loaded. | |
477 | // - ProcessDigits if the digits are loaded. | |
478 | // - ProcessSDigits if the sumbable digits are loaded. | |
479 | // - ProcessRecPoints if the reconstructed points are loaded. | |
480 | // - ProcessESD if the event summary data is loaded | |
481 | // | |
482 | if (TESTBIT(fTreeMask, kHits)) | |
483 | if (!ProcessHits()) return kFALSE; | |
08d168d9 | 484 | if (TESTBIT(fTreeMask, kTrackRefs)) |
485 | if (!ProcessTrackRefs()) return kFALSE; | |
f95a63c4 | 486 | if (TESTBIT(fTreeMask, kTracks)) |
487 | if (!ProcessTracks()) return kFALSE; | |
bf000c32 | 488 | if (TESTBIT(fTreeMask, kSDigits)) |
489 | if (!ProcessSDigits()) return kFALSE; | |
faf80567 | 490 | if (TESTBIT(fTreeMask, kDigits)) |
491 | if (!ProcessDigits()) return kFALSE; | |
d760ea03 | 492 | if (TESTBIT(fTreeMask, kRaw)) |
493 | if (!ProcessRawDigits()) return kFALSE; | |
e064ab4a | 494 | if (TESTBIT(fTreeMask, kRawCalib)) |
495 | if (!ProcessRawCalibDigits()) return kFALSE; | |
bf000c32 | 496 | if (TESTBIT(fTreeMask, kRecPoints)) |
497 | if (!ProcessRecPoints()) return kFALSE; | |
498 | if (TESTBIT(fTreeMask, kESD)) | |
a9579262 | 499 | if (!ProcessESDs()) return kFALSE; |
bf000c32 | 500 | |
501 | return kTRUE; | |
502 | } | |
503 | ||
504 | //____________________________________________________________________ | |
505 | Bool_t | |
506 | AliFMDInput::ProcessHits() | |
507 | { | |
02a27b50 | 508 | // Read the hit tree, and pass each hit to the member function |
509 | // ProcessHit. | |
bf000c32 | 510 | if (!fTreeH) { |
511 | AliError("No hit tree defined"); | |
512 | return kFALSE; | |
513 | } | |
ddaa8027 | 514 | if (!fArrayH) { |
515 | AliError("No hit array defined"); | |
516 | return kFALSE; | |
517 | } | |
518 | ||
bf000c32 | 519 | Int_t nTracks = fTreeH->GetEntries(); |
520 | for (Int_t i = 0; i < nTracks; i++) { | |
521 | Int_t hitRead = fTreeH->GetEntry(i); | |
522 | if (hitRead <= 0) continue; | |
ddaa8027 | 523 | |
bf000c32 | 524 | Int_t nHit = fArrayH->GetEntries(); |
525 | if (nHit <= 0) continue; | |
ddaa8027 | 526 | |
bf000c32 | 527 | for (Int_t j = 0; j < nHit; j++) { |
528 | AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j)); | |
529 | if (!hit) continue; | |
ddaa8027 | 530 | |
bf000c32 | 531 | TParticle* track = 0; |
532 | if (TESTBIT(fTreeMask, kKinematics) && fStack) { | |
533 | Int_t trackno = hit->Track(); | |
534 | track = fStack->Particle(trackno); | |
535 | } | |
536 | if (!ProcessHit(hit, track)) return kFALSE; | |
537 | } | |
538 | } | |
539 | return kTRUE; | |
540 | } | |
08d168d9 | 541 | //____________________________________________________________________ |
542 | Bool_t | |
543 | AliFMDInput::ProcessTrackRefs() | |
544 | { | |
545 | // Read the reconstrcted points tree, and pass each reconstruction | |
546 | // object (AliFMDRecPoint) to either ProcessRecPoint. | |
547 | if (!fTreeTR) { | |
548 | AliError("No track reference tree defined"); | |
549 | return kFALSE; | |
550 | } | |
551 | if (!fArrayTR) { | |
552 | AliError("No track reference array defined"); | |
553 | return kFALSE; | |
554 | } | |
bf000c32 | 555 | |
08d168d9 | 556 | Int_t nEv = fTreeTR->GetEntries(); |
557 | for (Int_t i = 0; i < nEv; i++) { | |
558 | Int_t trRead = fTreeTR->GetEntry(i); | |
559 | if (trRead <= 0) continue; | |
560 | Int_t nTrackRefs = fArrayTR->GetEntries(); | |
561 | for (Int_t j = 0; j < nTrackRefs; j++) { | |
562 | AliTrackReference* trackRef = static_cast<AliTrackReference*>(fArrayTR->At(j)); | |
563 | if (!trackRef) continue; | |
564 | if (trackRef->DetectorId() != AliTrackReference::kFMD) continue; | |
565 | TParticle* track = 0; | |
566 | if (TESTBIT(fTreeMask, kKinematics) && fStack) { | |
567 | Int_t trackno = trackRef->GetTrack(); | |
568 | track = fStack->Particle(trackno); | |
569 | } | |
570 | if (!ProcessTrackRef(trackRef,track)) return kFALSE; | |
571 | } | |
572 | } | |
573 | return kTRUE; | |
574 | } | |
f95a63c4 | 575 | //____________________________________________________________________ |
576 | Bool_t | |
577 | AliFMDInput::ProcessTracks() | |
578 | { | |
579 | // Read the hit tree, and pass each hit to the member function | |
ddaa8027 | 580 | // ProcessTrack. |
f95a63c4 | 581 | if (!fStack) { |
582 | AliError("No track tree defined"); | |
583 | return kFALSE; | |
584 | } | |
585 | if (!fTreeH) { | |
586 | AliError("No hit tree defined"); | |
587 | return kFALSE; | |
588 | } | |
ddaa8027 | 589 | if (!fArrayH) { |
590 | AliError("No hit array defined"); | |
591 | return kFALSE; | |
592 | } | |
593 | ||
594 | // Int_t nTracks = fStack->GetNtrack(); | |
f95a63c4 | 595 | Int_t nTracks = fTreeH->GetEntries(); |
596 | for (Int_t i = 0; i < nTracks; i++) { | |
ddaa8027 | 597 | Int_t trackno = nTracks - i - 1; |
598 | TParticle* track = fStack->Particle(trackno); | |
f95a63c4 | 599 | if (!track) continue; |
ddaa8027 | 600 | |
601 | // Get the hits for this track. | |
f95a63c4 | 602 | Int_t hitRead = fTreeH->GetEntry(i); |
ddaa8027 | 603 | Int_t nHit = fArrayH->GetEntries(); |
604 | if (nHit == 0 || hitRead <= 0) { | |
605 | // Let user code see the track, even if there's no hits. | |
606 | if (!ProcessTrack(trackno, track, 0)) return kFALSE; | |
607 | continue; | |
f95a63c4 | 608 | } |
f95a63c4 | 609 | |
ddaa8027 | 610 | // Loop over the hits corresponding to this track. |
f95a63c4 | 611 | for (Int_t j = 0; j < nHit; j++) { |
612 | AliFMDHit* hit = static_cast<AliFMDHit*>(fArrayH->At(j)); | |
ddaa8027 | 613 | if (!ProcessTrack(trackno, track, hit)) return kFALSE; |
614 | } | |
f95a63c4 | 615 | } |
616 | return kTRUE; | |
617 | } | |
618 | ||
bf000c32 | 619 | //____________________________________________________________________ |
620 | Bool_t | |
621 | AliFMDInput::ProcessDigits() | |
622 | { | |
623 | // Read the digit tree, and pass each digit to the member function | |
624 | // ProcessDigit. | |
42f1b2f5 | 625 | if (!fTreeD) { |
626 | AliError("No digit tree defined"); | |
627 | return kFALSE; | |
628 | } | |
629 | if (!fArrayD) { | |
630 | AliError("No digit array defined"); | |
631 | return kFALSE; | |
632 | } | |
633 | ||
bf000c32 | 634 | Int_t nEv = fTreeD->GetEntries(); |
635 | for (Int_t i = 0; i < nEv; i++) { | |
636 | Int_t digitRead = fTreeD->GetEntry(i); | |
637 | if (digitRead <= 0) continue; | |
638 | Int_t nDigit = fArrayD->GetEntries(); | |
42f1b2f5 | 639 | AliFMDDebug(0, ("Got %5d digits for this event", nDigit)); |
bf000c32 | 640 | if (nDigit <= 0) continue; |
641 | for (Int_t j = 0; j < nDigit; j++) { | |
642 | AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayD->At(j)); | |
643 | if (!digit) continue; | |
644 | if (!ProcessDigit(digit)) return kFALSE; | |
645 | } | |
646 | } | |
647 | return kTRUE; | |
648 | } | |
649 | ||
650 | //____________________________________________________________________ | |
651 | Bool_t | |
652 | AliFMDInput::ProcessSDigits() | |
653 | { | |
654 | // Read the summable digit tree, and pass each sumable digit to the | |
655 | // member function ProcessSdigit. | |
42f1b2f5 | 656 | if (!fTreeS) { |
657 | AliWarning("No sdigit tree defined"); | |
658 | return kTRUE; // Empty SDigits is fine | |
659 | } | |
660 | if (!fArrayS) { | |
661 | AliWarning("No sdigit array defined"); | |
662 | return kTRUE; // Empty SDigits is fine | |
663 | } | |
664 | ||
665 | Int_t nEv = fTreeS->GetEntries(); | |
bf000c32 | 666 | for (Int_t i = 0; i < nEv; i++) { |
667 | Int_t sdigitRead = fTreeS->GetEntry(i); | |
faf80567 | 668 | if (sdigitRead <= 0) { |
669 | AliInfo(Form("Read nothing from tree")); | |
670 | continue; | |
671 | } | |
672 | Int_t nSdigit = fArrayS->GetEntriesFast(); | |
42f1b2f5 | 673 | AliFMDDebug(0, ("Got %5d digits for this event", nSdigit)); |
faf80567 | 674 | AliInfo(Form("Got %5d digits for this event", nSdigit)); |
bf000c32 | 675 | if (nSdigit <= 0) continue; |
676 | for (Int_t j = 0; j < nSdigit; j++) { | |
677 | AliFMDSDigit* sdigit = static_cast<AliFMDSDigit*>(fArrayS->At(j)); | |
678 | if (!sdigit) continue; | |
679 | if (!ProcessSDigit(sdigit)) return kFALSE; | |
680 | } | |
681 | } | |
682 | return kTRUE; | |
683 | } | |
684 | ||
d760ea03 | 685 | //____________________________________________________________________ |
686 | Bool_t | |
687 | AliFMDInput::ProcessRawDigits() | |
688 | { | |
689 | // Read the digit tree, and pass each digit to the member function | |
690 | // ProcessDigit. | |
42f1b2f5 | 691 | if (!fArrayA) { |
692 | AliError("No raw digit array defined"); | |
693 | return kFALSE; | |
694 | } | |
695 | ||
d760ea03 | 696 | Int_t nDigit = fArrayA->GetEntries(); |
697 | if (nDigit <= 0) return kTRUE; | |
698 | for (Int_t j = 0; j < nDigit; j++) { | |
699 | AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j)); | |
700 | if (!digit) continue; | |
59194467 | 701 | if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30) |
702 | digit->Print(); | |
d760ea03 | 703 | if (!ProcessRawDigit(digit)) return kFALSE; |
704 | } | |
705 | return kTRUE; | |
706 | } | |
707 | ||
e064ab4a | 708 | //____________________________________________________________________ |
709 | Bool_t | |
710 | AliFMDInput::ProcessRawCalibDigits() | |
711 | { | |
712 | // Read the digit tree, and pass each digit to the member function | |
713 | // ProcessDigit. | |
714 | if (!fArrayA) { | |
715 | AliError("No raw digit array defined"); | |
716 | return kFALSE; | |
717 | } | |
718 | ||
719 | Int_t nDigit = fArrayA->GetEntries(); | |
720 | if (nDigit <= 0) return kTRUE; | |
721 | for (Int_t j = 0; j < nDigit; j++) { | |
722 | AliFMDDigit* digit = static_cast<AliFMDDigit*>(fArrayA->At(j)); | |
723 | if (!digit) continue; | |
724 | if (AliLog::GetDebugLevel("FMD","") >= 40 && j < 30) | |
725 | digit->Print(); | |
726 | if (!ProcessRawCalibDigit(digit)) return kFALSE; | |
727 | } | |
728 | return kTRUE; | |
729 | } | |
730 | ||
bf000c32 | 731 | //____________________________________________________________________ |
732 | Bool_t | |
733 | AliFMDInput::ProcessRecPoints() | |
734 | { | |
735 | // Read the reconstrcted points tree, and pass each reconstruction | |
736 | // object (AliFMDRecPoint) to either ProcessRecPoint. | |
42f1b2f5 | 737 | if (!fTreeR) { |
738 | AliError("No recpoint tree defined"); | |
739 | return kFALSE; | |
740 | } | |
741 | if (!fArrayR) { | |
742 | AliError("No recpoints array defined"); | |
743 | return kFALSE; | |
744 | } | |
745 | ||
bf000c32 | 746 | Int_t nEv = fTreeR->GetEntries(); |
747 | for (Int_t i = 0; i < nEv; i++) { | |
748 | Int_t recRead = fTreeR->GetEntry(i); | |
749 | if (recRead <= 0) continue; | |
750 | Int_t nRecPoint = fArrayR->GetEntries(); | |
751 | for (Int_t j = 0; j < nRecPoint; j++) { | |
752 | AliFMDRecPoint* recPoint = static_cast<AliFMDRecPoint*>(fArrayR->At(j)); | |
753 | if (!recPoint) continue; | |
754 | if (!ProcessRecPoint(recPoint)) return kFALSE; | |
755 | } | |
a1f80595 | 756 | } |
757 | return kTRUE; | |
758 | } | |
759 | ||
a9579262 | 760 | //____________________________________________________________________ |
761 | Bool_t | |
762 | AliFMDInput::ProcessESDs() | |
763 | { | |
764 | // Process event summary data | |
765 | if (!fESD) return kFALSE; | |
766 | for (UShort_t det = 1; det <= 3; det++) { | |
767 | Char_t rings[] = { 'I', (det == 1 ? '\0' : 'O'), '\0' }; | |
768 | for (Char_t* rng = rings; *rng != '\0'; rng++) { | |
769 | UShort_t nsec = (*rng == 'I' ? 20 : 40); | |
770 | UShort_t nstr = (*rng == 'I' ? 512 : 256); | |
771 | for (UShort_t sec = 0; sec < nsec; sec++) { | |
772 | for (UShort_t str = 0; str < nstr; str++) { | |
773 | Float_t eta = fESD->Eta(det,*rng,sec,str); | |
774 | Float_t mult = fESD->Multiplicity(det,*rng,sec,str); | |
97b4001e | 775 | if (!fESD->IsAngleCorrected()) |
776 | mult *= TMath::Abs(TMath::Cos(2.*TMath::ATan(TMath::Exp(-eta)))); | |
a9579262 | 777 | if (!ProcessESD(det, *rng, sec, str, eta, mult)) continue; |
778 | } | |
779 | } | |
780 | } | |
781 | } | |
782 | return kTRUE; | |
783 | } | |
784 | ||
a1f80595 | 785 | //____________________________________________________________________ |
786 | Bool_t | |
787 | AliFMDInput::End() | |
788 | { | |
789 | // Called at the end of each event. Per default, it unloads the | |
790 | // data trees and resets the pointers to the output arrays. Users | |
791 | // can overload this, but should call this member function in the | |
792 | // overloaded member function of the derived class. | |
793 | ||
794 | // Check if we have been initialized | |
795 | if (!fIsInit) { | |
796 | AliError("Not initialized"); | |
797 | return fIsInit; | |
798 | } | |
799 | // Possibly unload global kinematics information | |
f95a63c4 | 800 | if (TESTBIT(fTreeMask, kKinematics) || TESTBIT(fTreeMask, kTracks)) { |
a1f80595 | 801 | fLoader->UnloadKinematics(); |
802 | // fTreeK = 0; | |
803 | fStack = 0; | |
804 | } | |
805 | // Possibly unload FMD Hit information | |
f95a63c4 | 806 | if (TESTBIT(fTreeMask, kHits) || TESTBIT(fTreeMask, kTracks)) { |
a1f80595 | 807 | fFMDLoader->UnloadHits(); |
808 | fTreeH = 0; | |
809 | } | |
810 | // Possibly unload FMD Digit information | |
811 | if (TESTBIT(fTreeMask, kDigits)) { | |
812 | fFMDLoader->UnloadDigits(); | |
813 | fTreeD = 0; | |
814 | } | |
815 | // Possibly unload FMD Sdigit information | |
816 | if (TESTBIT(fTreeMask, kSDigits)) { | |
817 | fFMDLoader->UnloadSDigits(); | |
818 | fTreeS = 0; | |
819 | } | |
820 | // Possibly unload FMD RecPoints information | |
821 | if (TESTBIT(fTreeMask, kRecPoints)) { | |
822 | fFMDLoader->UnloadRecPoints(); | |
823 | fTreeR = 0; | |
824 | } | |
f48d9b11 | 825 | // AliInfo("Now out event"); |
a1f80595 | 826 | return kTRUE; |
827 | } | |
828 | ||
829 | //____________________________________________________________________ | |
830 | Bool_t | |
831 | AliFMDInput::Run() | |
832 | { | |
833 | // Run over all events and files references in galice.root | |
834 | ||
835 | Bool_t retval; | |
836 | if (!(retval = Init())) return retval; | |
837 | ||
838 | Int_t nEvents = NEvents(); | |
59194467 | 839 | for (Int_t event = 0; nEvents < 0 || event < nEvents; event++) { |
a1f80595 | 840 | if (!(retval = Begin(event))) break; |
841 | if (!(retval = Event())) break; | |
842 | if (!(retval = End())) break; | |
843 | } | |
844 | if (!retval) return retval; | |
845 | retval = Finish(); | |
846 | return retval; | |
847 | } | |
848 | ||
69893a66 | 849 | //__________________________________________________________________ |
850 | TArrayF | |
851 | AliFMDInput::MakeLogScale(Int_t n, Double_t min, Double_t max) | |
852 | { | |
853 | // Service function to define a logarithmic axis. | |
854 | // Parameters: | |
855 | // n Number of bins | |
856 | // min Minimum of axis | |
857 | // max Maximum of axis | |
858 | TArrayF bins(n+1); | |
859 | bins[0] = min; | |
860 | if (n <= 20) { | |
861 | for (Int_t i = 1; i < n+1; i++) bins[i] = bins[i-1] + (max-min)/n; | |
862 | return bins; | |
863 | } | |
864 | Float_t dp = n / TMath::Log10(max / min); | |
865 | Float_t pmin = TMath::Log10(min); | |
866 | for (Int_t i = 1; i < n+1; i++) { | |
867 | Float_t p = pmin + i / dp; | |
868 | bins[i] = TMath::Power(10, p); | |
869 | } | |
870 | return bins; | |
871 | } | |
872 | ||
873 | ||
a1f80595 | 874 | |
a1f80595 | 875 | //____________________________________________________________________ |
876 | // | |
877 | // EOF | |
878 | // |