]>
Commit | Line | Data |
---|---|---|
48b32e42 | 1 | |
2 | // Author: Artur Szostak | |
3 | // email: artur@alice.phy.uct.ac.za | |
4 | ||
5 | #include <TError.h> | |
30178c30 | 6 | #include <TParticle.h> |
48b32e42 | 7 | |
8 | #include "AliRunLoader.h" | |
9 | #include "AliLoader.h" | |
10 | ||
11 | #include "AliMUONDataInterface.h" | |
30178c30 | 12 | #include "AliMUONLocalTrigger.h" |
13 | #include "AliMUONHit.h" | |
14 | #include "AliMUONDigit.h" | |
15 | #include "AliMUONRawCluster.h" | |
8c343c7c | 16 | #include "AliLog.h" |
48b32e42 | 17 | |
18 | ||
19 | ClassImp(AliMUONDataInterface) | |
20 | ||
21 | ||
22 | AliMUONDataInterface::AliMUONDataInterface() | |
23 | : TObject(), fData(NULL, "MUON", "MUON") | |
24 | { | |
25 | // Set all internal pointers to NULL and indices to -1. | |
26 | ||
27 | Reset(); | |
925e6570 | 28 | } |
48b32e42 | 29 | |
11ca64ac | 30 | AliMUONDataInterface::AliMUONDataInterface(const AliMUONDataInterface& rhs) |
31 | : TObject(rhs) | |
32 | { | |
33 | // Protected copy constructor | |
34 | ||
8c343c7c | 35 | AliFatal("Not implemented."); |
11ca64ac | 36 | } |
48b32e42 | 37 | |
38 | AliMUONDataInterface::~AliMUONDataInterface() | |
39 | { | |
40 | // Delete the runloader when done. | |
41 | // If the runloader is not to be deleted then call Reset just before | |
42 | // the destructor is called. | |
43 | ||
44 | if (fRunloader != NULL) | |
45 | delete fRunloader; | |
925e6570 | 46 | } |
48b32e42 | 47 | |
11ca64ac | 48 | AliMUONDataInterface& |
49 | AliMUONDataInterface::operator=(const AliMUONDataInterface& rhs) | |
50 | { | |
51 | // Protected assignement operator | |
52 | ||
53 | if (this == &rhs) return *this; | |
54 | ||
8c343c7c | 55 | AliFatal("Not implemented."); |
11ca64ac | 56 | |
57 | return *this; | |
58 | } | |
59 | ||
48b32e42 | 60 | |
61 | void AliMUONDataInterface::Reset() | |
62 | { | |
63 | // Sets all internal pointers to NULL and indices to -1. | |
64 | // Note: No resources are released! | |
65 | // Specificaly AliRunLoader is not deleted. | |
66 | ||
67 | fRunloader = NULL; | |
68 | fMuonloader = NULL; | |
69 | fEventnumber = -1; | |
70 | fTrack = -1; | |
71 | fSCathode = -1; | |
72 | fCathode = -1; | |
73 | fHitAddressSet = kFALSE; | |
74 | fSDigitAddressSet = kFALSE; | |
75 | fDigitAddressSet = kFALSE; | |
76 | fClusterAddressSet = kFALSE; | |
77 | fTriggerAddressSet = kFALSE; | |
925e6570 | 78 | } |
48b32e42 | 79 | |
80 | ||
81 | Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername) | |
82 | { | |
83 | // Load the run and muon loaders from the specified file and folder. | |
84 | // kTRUE is returned on success and kFALSE on failure. | |
85 | ||
86 | fRunloader = AliRunLoader::Open(filename, foldername, "READ"); | |
87 | if (fRunloader == NULL) | |
88 | { | |
8c343c7c | 89 | AliError(Form("Could not find or load the run loader for the file: %s and folder: %s", |
90 | (const char*)filename, (const char*)foldername)); | |
48b32e42 | 91 | return kFALSE; |
925e6570 | 92 | } |
48b32e42 | 93 | fMuonloader = fRunloader->GetLoader("MUONLoader"); |
94 | if (fMuonloader == NULL) | |
95 | { | |
8c343c7c | 96 | AliError(Form("Could not find the MUON loader in file: %s and folder: %s", |
97 | (const char*)filename, (const char*)foldername)); | |
48b32e42 | 98 | fRunloader = NULL; |
99 | return kFALSE; | |
925e6570 | 100 | } |
48b32e42 | 101 | |
102 | // Need to connect the muon loader to the AliMUONData object, | |
103 | // else class to fData will return NULL. | |
104 | fData.SetLoader(fMuonloader); | |
105 | ||
106 | fFilename = filename; | |
107 | fFoldername = foldername; | |
108 | fEventnumber = -1; // Reset the event number to force the event to be loaded. | |
109 | return kTRUE; | |
925e6570 | 110 | } |
48b32e42 | 111 | |
112 | ||
113 | Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername) | |
114 | { | |
115 | // Fetch the run loader and muon loader objects from memory if they already exist, | |
116 | // or from memory if they do not. | |
117 | // If the currently loaded run loader (if any) is not refering to the file and folder | |
118 | // we are interested in then it is deleted and reopened with the required file and | |
119 | // folder names. | |
120 | ||
121 | if (fRunloader == NULL) | |
122 | { | |
123 | fRunloader = AliRunLoader::GetRunLoader(); | |
124 | if (fRunloader == NULL) | |
125 | return LoadLoaders(filename, foldername); | |
126 | ||
127 | // Fetch the current file and folder names. | |
128 | fFilename = fRunloader->GetFileName(); | |
129 | fFoldername = fRunloader->GetEventFolder()->GetName(); | |
925e6570 | 130 | } |
48b32e42 | 131 | |
132 | // If filename or foldername are not the same as the ones currently selected then | |
133 | // reopen the file. | |
134 | if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 ) | |
135 | { | |
136 | delete fRunloader; | |
137 | return LoadLoaders(filename, foldername); | |
925e6570 | 138 | } |
48b32e42 | 139 | return kTRUE; |
925e6570 | 140 | } |
48b32e42 | 141 | |
142 | ||
143 | Bool_t AliMUONDataInterface::FetchEvent(Int_t event) | |
144 | { | |
145 | // Fetch the specified event from the runloader and reset all the track, cathode | |
146 | // and address flags to force them to be reloaded. | |
147 | ||
148 | if (fEventnumber < 0) | |
149 | { | |
150 | fEventnumber = fRunloader->GetEventNumber(); | |
151 | fTrack = -1; | |
152 | fSCathode = -1; | |
153 | fCathode = -1; | |
154 | fHitAddressSet = kFALSE; | |
155 | fSDigitAddressSet = kFALSE; | |
156 | fDigitAddressSet = kFALSE; | |
157 | fClusterAddressSet = kFALSE; | |
158 | fTriggerAddressSet = kFALSE; | |
925e6570 | 159 | } |
48b32e42 | 160 | if ( event != fEventnumber ) |
161 | { | |
162 | if ( fRunloader->GetEvent(event) < 0 ) return kFALSE; | |
163 | fEventnumber = event; | |
164 | fTrack = -1; | |
165 | fSCathode = -1; | |
166 | fCathode = -1; | |
167 | fHitAddressSet = kFALSE; | |
168 | fSDigitAddressSet = kFALSE; | |
169 | fDigitAddressSet = kFALSE; | |
170 | fClusterAddressSet = kFALSE; | |
171 | fTriggerAddressSet = kFALSE; | |
925e6570 | 172 | } |
48b32e42 | 173 | return kTRUE; |
925e6570 | 174 | } |
48b32e42 | 175 | |
176 | ||
177 | Bool_t AliMUONDataInterface::FetchTreeK() | |
178 | { | |
179 | // Fetch the Kine tree from the current run loader. | |
180 | ||
181 | if (fRunloader->TreeK() == NULL) | |
182 | { | |
183 | fRunloader->LoadKinematics("READ"); | |
184 | if (fRunloader->TreeK() == NULL) | |
185 | { | |
8c343c7c | 186 | AliError("Could not load TreeK."); |
48b32e42 | 187 | return kFALSE; |
925e6570 | 188 | } |
189 | } | |
48b32e42 | 190 | return kTRUE; |
925e6570 | 191 | } |
48b32e42 | 192 | |
193 | ||
194 | Bool_t AliMUONDataInterface::FetchTreeH() | |
195 | { | |
196 | // Fetch the Hits tree from the current muon loader. | |
197 | // Set all the required addresses etc... | |
198 | ||
199 | if (fMuonloader->TreeH() == NULL) | |
200 | { | |
201 | fMuonloader->LoadHits("READ"); | |
202 | if (fMuonloader->TreeH() == NULL) | |
203 | { | |
8c343c7c | 204 | AliError("Could not load TreeH."); |
48b32e42 | 205 | return kFALSE; |
925e6570 | 206 | } |
48b32e42 | 207 | fData.SetTreeAddress("H"); |
208 | fHitAddressSet = kTRUE; | |
209 | } | |
210 | else if ( ! fHitAddressSet ) | |
211 | { | |
212 | fData.SetTreeAddress("H"); | |
213 | fHitAddressSet = kTRUE; | |
925e6570 | 214 | } |
48b32e42 | 215 | return kTRUE; |
925e6570 | 216 | } |
48b32e42 | 217 | |
218 | ||
219 | Bool_t AliMUONDataInterface::FetchTreeS() | |
220 | { | |
221 | // Fetch the S-Digits tree from the current muon loader. | |
222 | // Set all the required addresses etc... | |
223 | ||
224 | if (fMuonloader->TreeS() == NULL) | |
225 | { | |
226 | fMuonloader->LoadSDigits("READ"); | |
227 | if (fMuonloader->TreeS() == NULL) | |
228 | { | |
8c343c7c | 229 | AliError("Could not load TreeS."); |
48b32e42 | 230 | return kFALSE; |
925e6570 | 231 | } |
48b32e42 | 232 | fData.SetTreeAddress("S"); |
233 | fSDigitAddressSet = kTRUE; | |
234 | } | |
235 | else if ( ! fSDigitAddressSet ) | |
236 | { | |
237 | fData.SetTreeAddress("S"); | |
238 | fSDigitAddressSet = kTRUE; | |
925e6570 | 239 | } |
48b32e42 | 240 | return kTRUE; |
925e6570 | 241 | } |
48b32e42 | 242 | |
243 | ||
244 | Bool_t AliMUONDataInterface::FetchTreeD() | |
245 | { | |
246 | // Fetch the digits tree from the current muon loader. | |
247 | // Set all the required addresses etc... | |
248 | ||
249 | if (fMuonloader->TreeD() == NULL) | |
250 | { | |
251 | fMuonloader->LoadDigits("READ"); | |
252 | if (fMuonloader->TreeD() == NULL) | |
253 | { | |
8c343c7c | 254 | AliError("Could not load TreeD."); |
48b32e42 | 255 | return kFALSE; |
925e6570 | 256 | } |
48b32e42 | 257 | fData.SetTreeAddress("D"); |
258 | fDigitAddressSet = kTRUE; | |
259 | } | |
260 | else if ( ! fDigitAddressSet ) | |
261 | { | |
262 | fData.SetTreeAddress("D"); | |
263 | fDigitAddressSet = kTRUE; | |
925e6570 | 264 | } |
48b32e42 | 265 | return kTRUE; |
925e6570 | 266 | } |
48b32e42 | 267 | |
268 | ||
269 | Bool_t AliMUONDataInterface::FetchTreeR() | |
270 | { | |
271 | // Fetch the reconstructed objects tree from the current muon loader. | |
272 | // Nore: The addresses must still be set. | |
273 | ||
274 | if (fMuonloader->TreeR() == NULL) | |
275 | { | |
276 | fMuonloader->LoadRecPoints("READ"); | |
277 | if (fMuonloader->TreeR() == NULL) | |
278 | { | |
8c343c7c | 279 | AliError("Could not load TreeR."); |
48b32e42 | 280 | return kFALSE; |
925e6570 | 281 | } |
48b32e42 | 282 | |
283 | // Need to reset these flags so that the cluster and trigger address | |
284 | // gets reset after this method. | |
285 | fClusterAddressSet = kFALSE; | |
286 | fTriggerAddressSet = kFALSE; | |
925e6570 | 287 | } |
48b32e42 | 288 | return kTRUE; |
925e6570 | 289 | } |
48b32e42 | 290 | |
291 | ||
292 | Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername) | |
293 | { | |
294 | // Returns the number of events in the specified file/folder, and -1 on error. | |
295 | ||
296 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
297 | return fRunloader->GetNumberOfEvents(); | |
925e6570 | 298 | } |
48b32e42 | 299 | |
300 | ||
301 | Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event) | |
302 | { | |
303 | // Returns the number of events in the specified file/folder, and -1 on error. | |
304 | ||
305 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
306 | if ( ! FetchEvent(event) ) return -1; | |
307 | if ( ! FetchTreeK() ) return -1; | |
308 | return (Int_t) fRunloader->TreeK()->GetEntriesFast(); | |
925e6570 | 309 | } |
48b32e42 | 310 | |
311 | ||
312 | TParticle* AliMUONDataInterface::Particle( | |
313 | TString filename, TString foldername, Int_t event, Int_t particle | |
314 | ) | |
315 | { | |
316 | // Returns the specified particle in the given file, folder and event. | |
317 | // NULL is returned on error. | |
318 | ||
319 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
320 | if ( ! FetchEvent(event) ) return NULL; | |
321 | if ( ! FetchTreeK() ) return NULL; | |
322 | ||
323 | TTree* treeK = fRunloader->TreeK(); | |
324 | TParticle* p = NULL; | |
325 | treeK->GetBranch("Particles")->SetAddress(&p); | |
326 | treeK->GetEvent(particle); | |
327 | return p; | |
925e6570 | 328 | } |
48b32e42 | 329 | |
330 | ||
331 | Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event) | |
332 | { | |
333 | // Returns the number of tracks in the specified file/folder and event. | |
334 | // -1 is returned on error. | |
335 | ||
336 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
337 | if ( ! FetchEvent(event) ) return -1; | |
338 | if ( ! FetchTreeH() ) return -1; | |
339 | return fData.GetNtracks(); | |
925e6570 | 340 | } |
48b32e42 | 341 | |
342 | ||
343 | Int_t AliMUONDataInterface::NumberOfHits( | |
344 | TString filename, TString foldername, Int_t event, Int_t track | |
345 | ) | |
346 | { | |
347 | // Returns the number of hits in the specified file/folder, event and track. | |
348 | // -1 is returned on error. | |
349 | ||
350 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
351 | if ( ! FetchEvent(event) ) return -1; | |
352 | if ( ! FetchTreeH() ) return -1; | |
353 | ||
354 | if (fTrack < 0 || fTrack != track) | |
355 | { | |
356 | fData.ResetHits(); | |
357 | fData.GetTrack(track); | |
358 | fTrack = track; | |
925e6570 | 359 | } |
48b32e42 | 360 | return fData.Hits()->GetEntriesFast(); |
925e6570 | 361 | } |
48b32e42 | 362 | |
363 | ||
364 | AliMUONHit* AliMUONDataInterface::Hit( | |
365 | TString filename, TString foldername, Int_t event, | |
366 | Int_t track, Int_t hit | |
367 | ) | |
368 | { | |
369 | // Returns the specified hit in the given file, folder, event and track. | |
370 | // NULL is returned on error. | |
371 | ||
372 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
373 | if ( ! FetchEvent(event) ) return NULL; | |
374 | if ( ! FetchTreeH() ) return NULL; | |
375 | ||
376 | if (fTrack < 0 || fTrack != track) | |
377 | { | |
378 | fData.ResetHits(); | |
379 | fData.GetTrack(track); | |
380 | fTrack = track; | |
925e6570 | 381 | } |
48b32e42 | 382 | return static_cast<AliMUONHit*>( fData.Hits()->At(hit) ); |
925e6570 | 383 | } |
48b32e42 | 384 | |
385 | ||
386 | Int_t AliMUONDataInterface::NumberOfSDigits( | |
387 | TString filename, TString foldername, Int_t event, | |
388 | Int_t chamber, Int_t cathode | |
389 | ) | |
390 | { | |
391 | // Returns the number of s-digits in the given file, folder, event, | |
392 | // chamber and cathode. -1 is returned on error. | |
393 | ||
394 | Assert( 0 <= chamber && chamber <= 13 ); | |
395 | Assert( 0 <= cathode && cathode <= 1 ); | |
396 | ||
397 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
398 | if ( ! FetchEvent(event) ) return -1; | |
399 | if ( ! FetchTreeS() ) return -1; | |
400 | ||
401 | if ( fSCathode != cathode ) | |
402 | { | |
403 | fData.ResetSDigits(); | |
404 | fData.GetCathodeS(cathode); | |
405 | fSCathode = cathode; | |
925e6570 | 406 | } |
48b32e42 | 407 | return fData.SDigits(chamber)->GetEntriesFast(); |
925e6570 | 408 | } |
48b32e42 | 409 | |
410 | ||
411 | AliMUONDigit* AliMUONDataInterface::SDigit( | |
412 | TString filename, TString foldername, Int_t event, | |
413 | Int_t chamber, Int_t cathode, Int_t sdigit | |
414 | ) | |
415 | { | |
416 | // Returns the specified s-digit in the given file, folder, event, | |
417 | // chamber and cathode. NULL is returned on error. | |
418 | ||
419 | Assert( 0 <= chamber && chamber <= 13 ); | |
420 | Assert( 0 <= cathode && cathode <= 1 ); | |
421 | ||
422 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
423 | if ( ! FetchEvent(event) ) return NULL; | |
424 | if ( ! FetchTreeS() ) return NULL; | |
425 | ||
426 | if ( fSCathode != cathode ) | |
427 | { | |
428 | fData.ResetSDigits(); | |
429 | fData.GetCathodeS(cathode); | |
430 | fSCathode = cathode; | |
925e6570 | 431 | } |
48b32e42 | 432 | return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) ); |
925e6570 | 433 | } |
48b32e42 | 434 | |
435 | ||
436 | Int_t AliMUONDataInterface::NumberOfDigits( | |
437 | TString filename, TString foldername, Int_t event, | |
438 | Int_t chamber, Int_t cathode | |
439 | ) | |
440 | { | |
441 | // Returns the number of digits in the given file, folder, event, | |
442 | // chamber and cathode. -1 is returned on error. | |
443 | Assert( 0 <= chamber && chamber <= 13 ); | |
444 | Assert( 0 <= cathode && cathode <= 1 ); | |
445 | ||
446 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
447 | if ( ! FetchEvent(event) ) return -1; | |
448 | if ( ! FetchTreeD() ) return -1; | |
449 | ||
450 | if ( fCathode != cathode ) | |
451 | { | |
452 | fData.ResetDigits(); | |
453 | fData.GetCathode(cathode); | |
454 | fCathode = cathode; | |
925e6570 | 455 | } |
48b32e42 | 456 | return fData.Digits(chamber)->GetEntriesFast(); |
925e6570 | 457 | } |
48b32e42 | 458 | |
459 | ||
460 | AliMUONDigit* AliMUONDataInterface::Digit( | |
461 | TString filename, TString foldername, Int_t event, | |
462 | Int_t chamber, Int_t cathode, Int_t digit | |
463 | ) | |
464 | { | |
465 | // Returns the specified digit in the given file, folder, event, | |
466 | // chamber and cathode. NULL is returned on error. | |
467 | ||
468 | Assert( 0 <= chamber && chamber <= 13 ); | |
469 | Assert( 0 <= cathode && cathode <= 1 ); | |
470 | ||
471 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
472 | if ( ! FetchEvent(event) ) return NULL; | |
473 | if ( ! FetchTreeD() ) return NULL; | |
474 | ||
475 | if ( fCathode != cathode ) | |
476 | { | |
477 | fData.ResetDigits(); | |
478 | fData.GetCathode(cathode); | |
479 | fCathode = cathode; | |
925e6570 | 480 | } |
48b32e42 | 481 | return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) ); |
925e6570 | 482 | } |
48b32e42 | 483 | |
484 | ||
485 | Int_t AliMUONDataInterface::NumberOfRawClusters( | |
486 | TString filename, TString foldername, Int_t event, Int_t chamber | |
487 | ) | |
488 | { | |
489 | // Returns the number of raw clusters in the specified file, folder, event and chamber. | |
490 | // -1 is returned or error. | |
491 | ||
492 | Assert( 0 <= chamber && chamber <= 13 ); | |
493 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
494 | if ( ! FetchEvent(event) ) return -1; | |
495 | if ( ! FetchTreeR() ) return -1; | |
496 | if ( ! fClusterAddressSet ) | |
497 | { | |
498 | // If the raw cluster address in TreeR is not set yet then set it now. | |
499 | fData.SetTreeAddress("RC"); | |
500 | fData.ResetRawClusters(); | |
501 | fData.GetRawClusters(); | |
502 | fClusterAddressSet = kTRUE; | |
925e6570 | 503 | } |
48b32e42 | 504 | return fData.RawClusters(chamber)->GetEntriesFast(); |
925e6570 | 505 | } |
48b32e42 | 506 | |
507 | ||
508 | AliMUONRawCluster* AliMUONDataInterface::RawCluster( | |
509 | TString filename, TString foldername, Int_t event, | |
510 | Int_t chamber, Int_t cluster | |
511 | ) | |
512 | { | |
513 | // Fetch the specified raw cluster from the given file, folder, event and chamber number. | |
514 | // NULL is returned on error. | |
515 | ||
516 | Assert( 0 <= chamber && chamber <= 13 ); | |
517 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
518 | if ( ! FetchEvent(event) ) return NULL; | |
519 | if ( ! FetchTreeR() ) return NULL; | |
520 | if ( ! fClusterAddressSet ) | |
521 | { | |
522 | // If the raw cluster address in TreeR is not set yet then set it now. | |
523 | fData.SetTreeAddress("RC"); | |
524 | fData.ResetRawClusters(); | |
525 | fData.GetRawClusters(); | |
526 | fClusterAddressSet = kTRUE; | |
925e6570 | 527 | } |
48b32e42 | 528 | return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) ); |
925e6570 | 529 | } |
48b32e42 | 530 | |
531 | ||
532 | Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event) | |
533 | { | |
534 | // Return the number of local trigger objects in the specified file, folder and | |
535 | // event number. -1 is returned on error. | |
536 | ||
537 | if ( ! FetchLoaders(filename, foldername) ) return -1; | |
538 | if ( ! FetchEvent(event) ) return -1; | |
539 | if ( ! FetchTreeR() ) return -1; | |
540 | if ( ! fTriggerAddressSet ) | |
541 | { | |
542 | // If the local trigger address in TreeR is not set yet then set it now. | |
543 | fData.SetTreeAddress("GLT"); | |
544 | fData.ResetTrigger(); | |
545 | fData.GetTrigger(); | |
546 | fTriggerAddressSet = kTRUE; | |
925e6570 | 547 | } |
48b32e42 | 548 | return fData.LocalTrigger()->GetEntriesFast(); |
925e6570 | 549 | } |
48b32e42 | 550 | |
551 | ||
552 | AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger( | |
553 | TString filename, TString foldername, Int_t event, Int_t trigger | |
554 | ) | |
555 | { | |
556 | // Fetch the specified local trigger object from the given file, folder and event number. | |
557 | // NULL is returned on error. | |
558 | ||
559 | if ( ! FetchLoaders(filename, foldername) ) return NULL; | |
560 | if ( ! FetchEvent(event) ) return NULL; | |
561 | if ( ! FetchTreeR() ) return NULL; | |
562 | if ( ! fTriggerAddressSet ) | |
563 | { | |
564 | // If the local trigger address in TreeR is not set yet then set it now. | |
565 | fData.SetTreeAddress("GLT"); | |
566 | fData.ResetTrigger(); | |
567 | fData.GetTrigger(); | |
568 | fTriggerAddressSet = kTRUE; | |
925e6570 | 569 | } |
48b32e42 | 570 | return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) ); |
925e6570 | 571 | } |
48b32e42 | 572 | |
573 | ||
574 | Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername) | |
575 | { | |
576 | // Set the current file and folder from which to fetch data. | |
577 | // kTRUE is returned if the run and muon loaders were found, else kFALSE. | |
578 | ||
579 | return FetchLoaders(filename, foldername); | |
925e6570 | 580 | } |
48b32e42 | 581 | |
582 | ||
583 | Bool_t AliMUONDataInterface::GetEvent(Int_t event) | |
584 | { | |
585 | // Select the current event from which to fetch data. | |
586 | // kTRUE is returned if the event was found, else kFALSE is returned. | |
587 | ||
588 | return FetchEvent(event); | |
925e6570 | 589 | } |
48b32e42 | 590 | |
591 | ||
592 | Int_t AliMUONDataInterface::NumberOfEvents() | |
593 | { | |
594 | // Get the number of events in the currently selected file. | |
595 | // -1 is returned on error. | |
596 | ||
597 | if (fRunloader == NULL) | |
598 | { | |
8c343c7c | 599 | AliError("File not set."); |
48b32e42 | 600 | return -1; |
925e6570 | 601 | } |
48b32e42 | 602 | return fRunloader->GetNumberOfEvents(); |
925e6570 | 603 | } |
48b32e42 | 604 | |
605 | ||
606 | Int_t AliMUONDataInterface::NumberOfParticles() | |
607 | { | |
608 | // Get the number of particles in the current event. | |
609 | // -1 is returned on error. | |
610 | ||
611 | if (fRunloader == NULL) | |
612 | { | |
8c343c7c | 613 | AliError("File not set."); |
48b32e42 | 614 | return -1; |
925e6570 | 615 | } |
48b32e42 | 616 | if ( ! FetchTreeK() ) return -1; |
617 | return (Int_t) fRunloader->TreeK()->GetEntriesFast(); | |
925e6570 | 618 | } |
48b32e42 | 619 | |
620 | ||
621 | TParticle* AliMUONDataInterface::Particle(Int_t particle) | |
622 | { | |
623 | // Fetch the specified particle from the current event. | |
624 | // NULL is returned on error. | |
625 | ||
626 | if (fRunloader == NULL) | |
627 | { | |
8c343c7c | 628 | AliError("File not set."); |
48b32e42 | 629 | return NULL; |
925e6570 | 630 | } |
48b32e42 | 631 | if (fEventnumber < 0) |
632 | { | |
8c343c7c | 633 | AliError("Event not chosen."); |
48b32e42 | 634 | return NULL; |
925e6570 | 635 | } |
48b32e42 | 636 | if ( ! FetchTreeK() ) return NULL; |
637 | TTree* treeK = fRunloader->TreeK(); | |
638 | TParticle* p = NULL; | |
639 | treeK->GetBranch("Particles")->SetAddress(&p); | |
640 | treeK->GetEvent(particle); | |
641 | return p; | |
925e6570 | 642 | } |
48b32e42 | 643 | |
644 | ||
645 | Int_t AliMUONDataInterface::NumberOfTracks() | |
646 | { | |
647 | // Get the number of tracks in the current event. | |
648 | // -1 is returned on error. | |
649 | ||
650 | if (fRunloader == NULL) | |
651 | { | |
8c343c7c | 652 | AliError("File not set."); |
48b32e42 | 653 | return -1; |
925e6570 | 654 | } |
48b32e42 | 655 | if (fEventnumber < 0) |
656 | { | |
8c343c7c | 657 | AliError( "Event not chosen."); |
48b32e42 | 658 | return -1; |
925e6570 | 659 | } |
48b32e42 | 660 | if ( ! FetchTreeH() ) return -1; |
661 | return fData.GetNtracks(); | |
925e6570 | 662 | } |
48b32e42 | 663 | |
664 | ||
665 | Int_t AliMUONDataInterface::NumberOfHits(Int_t track) | |
666 | { | |
667 | // Get the number of hits for the given track in the current event. | |
668 | // -1 is returned on error. | |
669 | ||
670 | if (fRunloader == NULL) | |
671 | { | |
8c343c7c | 672 | AliError("File not set."); |
48b32e42 | 673 | return -1; |
925e6570 | 674 | } |
48b32e42 | 675 | if (fEventnumber < 0) |
676 | { | |
8c343c7c | 677 | AliError("Event not chosen."); |
48b32e42 | 678 | return -1; |
925e6570 | 679 | } |
48b32e42 | 680 | if ( ! FetchTreeH() ) return -1; |
681 | if (fTrack < 0 || fTrack != track) | |
682 | { | |
683 | fData.ResetHits(); | |
684 | fData.GetTrack(track); | |
685 | fTrack = track; | |
925e6570 | 686 | } |
48b32e42 | 687 | return fData.Hits()->GetEntriesFast(); |
925e6570 | 688 | } |
48b32e42 | 689 | |
690 | ||
691 | AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit) | |
692 | { | |
693 | // Fetch the specified hit from the current event. | |
694 | // NULL is returned on error. | |
695 | ||
696 | if (fRunloader == NULL) | |
697 | { | |
8c343c7c | 698 | AliError("File not set."); |
48b32e42 | 699 | return NULL; |
925e6570 | 700 | } |
48b32e42 | 701 | if (fEventnumber < 0) |
702 | { | |
8c343c7c | 703 | AliError("Event not chosen."); |
48b32e42 | 704 | return NULL; |
925e6570 | 705 | } |
48b32e42 | 706 | if ( ! FetchTreeH() ) return NULL; |
707 | if (fTrack < 0 || fTrack != track) | |
708 | { | |
709 | fData.ResetHits(); | |
710 | fData.GetTrack(track); | |
711 | fTrack = track; | |
925e6570 | 712 | } |
48b32e42 | 713 | return static_cast<AliMUONHit*>( fData.Hits()->At(hit) ); |
925e6570 | 714 | } |
48b32e42 | 715 | |
716 | ||
717 | Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode) | |
718 | { | |
719 | // Get the number of s-digits on the chamber, cathode in the current event. | |
720 | // -1 is returned on error. | |
721 | ||
722 | Assert( 0 <= chamber && chamber <= 13 ); | |
723 | Assert( 0 <= cathode && cathode <= 1 ); | |
724 | ||
725 | if (fRunloader == NULL) | |
726 | { | |
8c343c7c | 727 | AliError("File not set."); |
48b32e42 | 728 | return -1; |
925e6570 | 729 | } |
48b32e42 | 730 | if (fEventnumber < 0) |
731 | { | |
8c343c7c | 732 | AliError("Event not chosen."); |
48b32e42 | 733 | return -1; |
925e6570 | 734 | } |
48b32e42 | 735 | |
736 | if ( ! FetchTreeS() ) return -1; | |
737 | if ( fSCathode != cathode ) | |
738 | { | |
739 | fData.ResetSDigits(); | |
740 | fData.GetCathodeS(cathode); | |
741 | fSCathode = cathode; | |
925e6570 | 742 | } |
48b32e42 | 743 | return fData.SDigits(chamber)->GetEntriesFast(); |
925e6570 | 744 | } |
48b32e42 | 745 | |
746 | ||
747 | AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit) | |
748 | { | |
749 | // Fetch the specified s-digits on the chamber, cathode from the current event. | |
750 | // NULL is returned on error. | |
751 | ||
752 | Assert( 0 <= chamber && chamber <= 13 ); | |
753 | Assert( 0 <= cathode && cathode <= 1 ); | |
754 | ||
755 | if (fRunloader == NULL) | |
756 | { | |
8c343c7c | 757 | AliError("File not set."); |
48b32e42 | 758 | return NULL; |
925e6570 | 759 | } |
48b32e42 | 760 | if (fEventnumber < 0) |
761 | { | |
8c343c7c | 762 | AliError("Event not chosen."); |
48b32e42 | 763 | return NULL; |
925e6570 | 764 | } |
48b32e42 | 765 | |
766 | if ( ! FetchTreeS() ) return NULL; | |
767 | if ( fSCathode != cathode ) | |
768 | { | |
769 | fData.ResetSDigits(); | |
770 | fData.GetCathodeS(cathode); | |
771 | fSCathode = cathode; | |
925e6570 | 772 | } |
48b32e42 | 773 | return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) ); |
925e6570 | 774 | } |
48b32e42 | 775 | |
776 | ||
777 | Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode) | |
778 | { | |
779 | // Get the number of digits on the chamber, cathode in the current event. | |
780 | // -1 is returned on error. | |
781 | ||
782 | Assert( 0 <= chamber && chamber <= 13 ); | |
783 | Assert( 0 <= cathode && cathode <= 1 ); | |
784 | ||
785 | if (fRunloader == NULL) | |
786 | { | |
8c343c7c | 787 | AliError("File not set."); |
48b32e42 | 788 | return -1; |
925e6570 | 789 | } |
48b32e42 | 790 | if (fEventnumber < 0) |
791 | { | |
8c343c7c | 792 | AliError("Event not chosen."); |
48b32e42 | 793 | return -1; |
925e6570 | 794 | } |
48b32e42 | 795 | |
796 | if ( ! FetchTreeD() ) return -1; | |
797 | if ( fCathode != cathode ) | |
798 | { | |
799 | fData.ResetDigits(); | |
800 | fData.GetCathode(cathode); | |
801 | fCathode = cathode; | |
925e6570 | 802 | } |
48b32e42 | 803 | return fData.Digits(chamber)->GetEntriesFast(); |
925e6570 | 804 | } |
48b32e42 | 805 | |
806 | ||
807 | AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit) | |
808 | { | |
809 | // Fetch the specified digits on the chamber, cathode from the current event. | |
810 | // NULL is returned on error. | |
811 | ||
812 | Assert( 0 <= chamber && chamber <= 13 ); | |
813 | Assert( 0 <= cathode && cathode <= 1 ); | |
814 | ||
815 | if (fRunloader == NULL) | |
816 | { | |
8c343c7c | 817 | AliError("File not set."); |
48b32e42 | 818 | return NULL; |
925e6570 | 819 | } |
48b32e42 | 820 | if (fEventnumber < 0) |
821 | { | |
8c343c7c | 822 | AliError("Event not chosen."); |
48b32e42 | 823 | return NULL; |
925e6570 | 824 | } |
48b32e42 | 825 | |
826 | if ( ! FetchTreeD() ) return NULL; | |
827 | if ( fCathode != cathode ) | |
828 | { | |
829 | fData.ResetDigits(); | |
830 | fData.GetCathode(cathode); | |
831 | fCathode = cathode; | |
925e6570 | 832 | } |
48b32e42 | 833 | return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) ); |
925e6570 | 834 | } |
48b32e42 | 835 | |
836 | ||
837 | Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber) | |
838 | { | |
839 | // Get the number of raw clusters on the given chamber in the current event. | |
840 | // -1 is returned on error. | |
841 | ||
842 | Assert( 0 <= chamber && chamber <= 13 ); | |
843 | ||
844 | if (fRunloader == NULL) | |
845 | { | |
8c343c7c | 846 | AliError("File not set."); |
48b32e42 | 847 | return -1; |
925e6570 | 848 | } |
48b32e42 | 849 | if (fEventnumber < 0) |
850 | { | |
8c343c7c | 851 | AliError("Event not chosen."); |
48b32e42 | 852 | return -1; |
925e6570 | 853 | } |
48b32e42 | 854 | |
855 | if ( ! FetchTreeR() ) return -1; | |
856 | if ( ! fClusterAddressSet ) | |
857 | { | |
858 | fData.SetTreeAddress("RC"); | |
859 | fData.ResetRawClusters(); | |
860 | fData.GetRawClusters(); | |
861 | fClusterAddressSet = kTRUE; | |
925e6570 | 862 | } |
48b32e42 | 863 | return fData.RawClusters(chamber)->GetEntriesFast(); |
925e6570 | 864 | } |
48b32e42 | 865 | |
866 | ||
867 | AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster) | |
868 | { | |
869 | // Fetch the specified raw cluster on the given chamber from the current event. | |
870 | // NULL is returned on error. | |
871 | ||
872 | Assert( 0 <= chamber && chamber <= 13 ); | |
873 | ||
874 | if (fRunloader == NULL) | |
875 | { | |
8c343c7c | 876 | AliError("File not set."); |
48b32e42 | 877 | return NULL; |
925e6570 | 878 | } |
48b32e42 | 879 | if (fEventnumber < 0) |
880 | { | |
8c343c7c | 881 | AliError("Event not chosen."); |
48b32e42 | 882 | return NULL; |
925e6570 | 883 | } |
48b32e42 | 884 | |
885 | if ( ! FetchTreeR() ) return NULL; | |
886 | if ( ! fClusterAddressSet ) | |
887 | { | |
888 | fData.SetTreeAddress("RC"); | |
889 | fData.ResetRawClusters(); | |
890 | fData.GetRawClusters(); | |
891 | fClusterAddressSet = kTRUE; | |
925e6570 | 892 | } |
48b32e42 | 893 | return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) ); |
925e6570 | 894 | } |
48b32e42 | 895 | |
896 | ||
897 | Int_t AliMUONDataInterface::NumberOfLocalTriggers() | |
898 | { | |
899 | // Get the number of local trigger objects in the current event. | |
900 | // -1 is returned on error. | |
901 | ||
902 | if (fRunloader == NULL) | |
903 | { | |
8c343c7c | 904 | AliError("File not set."); |
48b32e42 | 905 | return -1; |
925e6570 | 906 | } |
48b32e42 | 907 | if (fEventnumber < 0) |
908 | { | |
8c343c7c | 909 | AliError("Event not chosen."); |
48b32e42 | 910 | return -1; |
925e6570 | 911 | } |
48b32e42 | 912 | |
913 | if ( ! FetchTreeR() ) return -1; | |
914 | if ( ! fTriggerAddressSet ) | |
915 | { | |
916 | fData.SetTreeAddress("GLT"); | |
917 | fData.ResetTrigger(); | |
918 | fData.GetTrigger(); | |
919 | fTriggerAddressSet = kTRUE; | |
925e6570 | 920 | } |
48b32e42 | 921 | return fData.LocalTrigger()->GetEntriesFast(); |
925e6570 | 922 | } |
48b32e42 | 923 | |
924 | ||
925 | AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger) | |
926 | { | |
927 | // Fetch the specified local trigger object from the current event. | |
928 | // NULL is returned on error. | |
929 | ||
930 | if (fRunloader == NULL) | |
931 | { | |
8c343c7c | 932 | AliError("File not set."); |
48b32e42 | 933 | return NULL; |
925e6570 | 934 | } |
48b32e42 | 935 | if (fEventnumber < 0) |
936 | { | |
8c343c7c | 937 | AliError( "Event not chosen."); |
48b32e42 | 938 | return NULL; |
925e6570 | 939 | } |
48b32e42 | 940 | |
941 | if ( ! FetchTreeR() ) return NULL; | |
942 | if ( ! fTriggerAddressSet ) | |
943 | { | |
944 | fData.SetTreeAddress("GLT"); | |
945 | fData.ResetTrigger(); | |
946 | fData.GetTrigger(); | |
947 | fTriggerAddressSet = kTRUE; | |
925e6570 | 948 | } |
48b32e42 | 949 | return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) ); |
925e6570 | 950 | } |