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