1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include <TParticle.h>
21 #include "AliRunLoader.h"
22 #include "AliLoader.h"
24 #include "AliMUONDataInterface.h"
25 #include "AliMUONLocalTrigger.h"
26 #include "AliMUONGlobalTrigger.h"
27 #include "AliMUONHit.h"
28 #include "AliMUONDigit.h"
29 #include "AliMUONRawCluster.h"
30 #include "AliMUONTrack.h"
38 /// \class AliMUONDataInterface
40 /// An easy to use interface to the MUON module data stored in
41 /// TreeK, TreeH, TreeS, TreeD and TreeR
42 /// One can fetch any of the data objects with all the calls to runloader,
43 /// muon loader and AliMUONData done behind the scenes and automatically.
45 /// This interface in not necessarily the fastest way to fetch the data but
46 /// it is the easiest.
47 /// Note: If independant calls to the run loader, muon loader or
48 /// AliMUONData objects are interspersed with calls to the
49 /// AliMUONDataInterface to fetch data, one might need to call the Reset
50 /// method between these method calls at some point to prevent
51 /// AliMUONDataInterface from getting confused.
52 /// This is necessary since this object assumes the state of runloader,
53 /// muon loader nor AliMUONData has not changed between calls.
54 /// If the state has changes then one must call Reset so that
55 /// AliMUONDataInterface refreshes what it knows about the state
56 /// of the loader and AliMUONData objects.
58 /// \deprecated We have to revisit all this AliMUONData stuff anyway,
59 /// and probably make a real AliMUONLoader instead...
61 /// \author Artur Szostak
62 /// email: artur@alice.phy.uct.ac.za
66 ClassImp(AliMUONDataInterface)
69 AliMUONDataInterface::AliMUONDataInterface()
71 fCreatedRunLoader(kFALSE),
72 fHitAddressSet(kFALSE),
73 fSDigitAddressSet(kFALSE),
74 fDigitAddressSet(kFALSE),
75 fClusterAddressSet(kFALSE),
76 fTriggerAddressSet(kFALSE),
77 fRecTracksAddressSet(kFALSE),
80 fData(0x0, "MUON", "MUON"),
88 /// Set all internal pointers to 0x0 and indices to -1.
93 AliMUONDataInterface::~AliMUONDataInterface()
95 /// Delete the runloader if we created it.
96 /// If the runloader is not to be deleted then call Reset just before
97 /// the destructor is called.
99 if (fRunloader != NULL && fCreatedRunLoader)
103 void AliMUONDataInterface::Reset()
105 /// Sets all internal pointers to NULL and indices to -1.
106 /// Note: No resources are released!
107 /// Specificaly AliRunLoader is not deleted.
109 fCreatedRunLoader = kFALSE;
116 fHitAddressSet = kFALSE;
117 fSDigitAddressSet = kFALSE;
118 fDigitAddressSet = kFALSE;
119 fClusterAddressSet = kFALSE;
120 fTriggerAddressSet = kFALSE;
121 fRecTracksAddressSet = kFALSE;
125 Bool_t AliMUONDataInterface::UseCurrentRunLoader()
127 /// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
128 /// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
131 fRunloader = AliRunLoader::GetRunLoader();
132 if (fRunloader == NULL) return kFALSE;
133 // Fetch the current file name, folder name and event number.
134 fFilename = fRunloader->GetFileName();
135 fFoldername = fRunloader->GetEventFolder()->GetName();
136 fEventnumber = fRunloader->GetEventNumber();
138 if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
148 Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
150 /// Fetches the muon loader for the given filename/foldername
152 fMuonloader = fRunloader->GetLoader("MUONLoader");
153 if (fMuonloader == NULL)
155 AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
156 (const char*)filename, (const char*)foldername));
160 // Need to connect the muon loader to the AliMUONData object,
161 // else class to fData will return NULL.
162 fData.SetLoader(fMuonloader);
167 Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
169 /// Load the run and muon loaders from the specified file and folder.
170 /// kTRUE is returned on success and kFALSE on failure.
172 fRunloader = AliRunLoader::Open(filename, foldername, "READ");
173 if (fRunloader == NULL)
175 AliError(Form("Could not find or load the run loader for the file: %s and folder: %s",
176 (const char*)filename, (const char*)foldername));
179 fCreatedRunLoader = kTRUE;
180 if ( ! FetchMuonLoader(filename, foldername) )
186 fFilename = filename;
187 fFoldername = foldername;
188 fEventnumber = -1; // Reset the event number to force the event to be loaded.
193 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
195 /// Fetch the run loader and muon loader objects from memory if they already exist,
196 /// or from memory if they do not.
197 /// If the currently loaded run loader (if any) is not refering to the file and folder
198 /// we are interested in then it is deleted and reopened with the required file and
201 if (fRunloader == NULL)
203 fRunloader = AliRunLoader::GetRunLoader();
204 if (fRunloader == NULL)
205 return LoadLoaders(filename, foldername);
208 if (fMuonloader == NULL)
210 if ( ! FetchMuonLoader(filename, foldername) )
218 // Fetch the current file and folder names.
219 fFilename = fRunloader->GetFileName();
220 fFoldername = fRunloader->GetEventFolder()->GetName();
223 // If filename or foldername are not the same as the ones currently selected then
225 if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
228 return LoadLoaders(filename, foldername);
234 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
236 /// Fetch the specified event from the runloader and reset all the track, cathode
237 /// and address flags to force them to be reloaded.
238 /// If a negative event number is specified then the current runloader event
241 if (fEventnumber < 0)
243 fEventnumber = fRunloader->GetEventNumber();
247 fHitAddressSet = kFALSE;
248 fSDigitAddressSet = kFALSE;
249 fDigitAddressSet = kFALSE;
250 fClusterAddressSet = kFALSE;
251 fTriggerAddressSet = kFALSE;
252 fRecTracksAddressSet = kFALSE;
254 if ( event != fEventnumber )
256 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
257 fEventnumber = event;
261 fHitAddressSet = kFALSE;
262 fSDigitAddressSet = kFALSE;
263 fDigitAddressSet = kFALSE;
264 fClusterAddressSet = kFALSE;
265 fTriggerAddressSet = kFALSE;
266 fRecTracksAddressSet = kFALSE;
272 Bool_t AliMUONDataInterface::FetchTreeK()
274 /// Fetch the Kine tree from the current run loader.
276 if (fRunloader->TreeK() == NULL)
278 fRunloader->LoadKinematics("READ");
279 if (fRunloader->TreeK() == NULL)
281 AliError("Could not load TreeK.");
289 Bool_t AliMUONDataInterface::FetchTreeH()
291 /// Fetch the Hits tree from the current muon loader.
292 /// Set all the required addresses etc...
294 if (fMuonloader->TreeH() == NULL)
296 fMuonloader->LoadHits("READ");
297 if (fMuonloader->TreeH() == NULL)
299 AliError("Could not load TreeH.");
302 fData.SetTreeAddress("H");
303 fHitAddressSet = kTRUE;
305 else if ( ! fHitAddressSet )
307 fData.SetTreeAddress("H");
308 fHitAddressSet = kTRUE;
314 Bool_t AliMUONDataInterface::FetchTreeS()
316 /// Fetch the S-Digits tree from the current muon loader.
317 /// Set all the required addresses etc...
319 if (fMuonloader->TreeS() == NULL)
321 fMuonloader->LoadSDigits("READ");
322 if (fMuonloader->TreeS() == NULL)
324 AliError("Could not load TreeS.");
327 fData.SetTreeAddress("S");
328 fSDigitAddressSet = kTRUE;
330 else if ( ! fSDigitAddressSet )
332 fData.SetTreeAddress("S");
333 fSDigitAddressSet = kTRUE;
339 Bool_t AliMUONDataInterface::FetchTreeD()
341 /// Fetch the digits tree from the current muon loader.
342 /// Set all the required addresses etc...
344 if (fMuonloader->TreeD() == NULL)
346 fMuonloader->LoadDigits("READ");
347 if (fMuonloader->TreeD() == NULL)
349 AliError("Could not load TreeD.");
352 fData.SetTreeAddress("D");
353 fDigitAddressSet = kTRUE;
355 else if ( ! fDigitAddressSet )
357 fData.SetTreeAddress("D");
358 fDigitAddressSet = kTRUE;
364 Bool_t AliMUONDataInterface::FetchTreeR()
366 /// Fetch the reconstructed objects tree from the current muon loader.
367 /// Note: The addresses must still be set.
369 if (fMuonloader->TreeR() == NULL)
371 fMuonloader->LoadRecPoints("READ");
372 if (fMuonloader->TreeR() == NULL)
374 AliError("Could not load TreeR.");
378 // Need to reset these flags so that the cluster and trigger address
379 // gets reset after this method.
380 fClusterAddressSet = kFALSE;
381 fTriggerAddressSet = kFALSE;
386 Bool_t AliMUONDataInterface::FetchTreeT()
388 /// fetch the reconstructed tracks tree from the current muon loader
389 /// note : the addresses must still be set.
390 if (fMuonloader->TreeT() == NULL)
392 fMuonloader->LoadTracks("READ");
393 if (fMuonloader->TreeT() == NULL)
395 AliError("Could not load TreeT.");
399 // Need to reset these flags so that the rec tracks address
400 // gets reset after this method.
401 fRecTracksAddressSet = kFALSE;
406 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
408 /// Returns the number of events in the specified file/folder, and -1 on error.
410 if ( ! FetchLoaders(filename, foldername) ) return -1;
411 return fRunloader->GetNumberOfEvents();
415 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
417 /// Returns the number of events in the specified file/folder, and -1 on error.
419 if ( ! FetchLoaders(filename, foldername) ) return -1;
420 if ( ! FetchEvent(event) ) return -1;
421 if ( ! FetchTreeK() ) return -1;
422 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
426 TParticle* AliMUONDataInterface::Particle(
427 TString filename, TString foldername, Int_t event, Int_t particle
430 /// Returns the specified particle in the given file, folder and event.
431 /// NULL is returned on error.
433 if ( ! FetchLoaders(filename, foldername) ) return NULL;
434 if ( ! FetchEvent(event) ) return NULL;
435 if ( ! FetchTreeK() ) return NULL;
437 TTree* treeK = fRunloader->TreeK();
439 treeK->GetBranch("Particles")->SetAddress(&p);
440 treeK->GetEvent(particle);
445 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
447 /// Returns the number of tracks in the specified file/folder and event.
448 /// -1 is returned on error.
450 if ( ! FetchLoaders(filename, foldername) ) return -1;
451 if ( ! FetchEvent(event) ) return -1;
452 if ( ! FetchTreeH() ) return -1;
453 return fData.GetNtracks();
457 Int_t AliMUONDataInterface::NumberOfHits(
458 TString filename, TString foldername, Int_t event, Int_t track
461 /// Returns the number of hits in the specified file/folder, event and track.
462 /// -1 is returned on error.
464 if ( ! FetchLoaders(filename, foldername) ) return -1;
465 if ( ! FetchEvent(event) ) return -1;
466 if ( ! FetchTreeH() ) return -1;
468 if (fTrack < 0 || fTrack != track)
471 fData.GetTrack(track);
474 return fData.Hits()->GetEntriesFast();
478 AliMUONHit* AliMUONDataInterface::Hit(
479 TString filename, TString foldername, Int_t event,
480 Int_t track, Int_t hit
483 /// Returns the specified hit in the given file, folder, event and track.
484 /// NULL is returned on error.
486 if ( ! FetchLoaders(filename, foldername) ) return NULL;
487 if ( ! FetchEvent(event) ) return NULL;
488 if ( ! FetchTreeH() ) return NULL;
490 if (fTrack < 0 || fTrack != track)
493 fData.GetTrack(track);
496 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
500 Int_t AliMUONDataInterface::NumberOfSDigits(
501 TString filename, TString foldername, Int_t event,
502 Int_t chamber, Int_t cathode
505 /// Returns the number of s-digits in the given file, folder, event,
506 /// chamber and cathode. -1 is returned on error.
508 Assert( 0 <= chamber && chamber <= 13 );
509 Assert( 0 <= cathode && cathode <= 1 );
511 if ( ! FetchLoaders(filename, foldername) ) return -1;
512 if ( ! FetchEvent(event) ) return -1;
513 if ( ! FetchTreeS() ) return -1;
515 if ( fSCathode != cathode )
517 fData.ResetSDigits();
521 return fData.SDigits(chamber)->GetEntriesFast();
525 AliMUONDigit* AliMUONDataInterface::SDigit(
526 TString filename, TString foldername, Int_t event,
527 Int_t chamber, Int_t cathode, Int_t sdigit
530 /// Returns the specified s-digit in the given file, folder, event,
531 /// chamber and cathode. NULL is returned on error.
533 Assert( 0 <= chamber && chamber <= 13 );
534 Assert( 0 <= cathode && cathode <= 1 );
536 if ( ! FetchLoaders(filename, foldername) ) return NULL;
537 if ( ! FetchEvent(event) ) return NULL;
538 if ( ! FetchTreeS() ) return NULL;
540 if ( fSCathode != cathode )
542 fData.ResetSDigits();
546 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
550 Int_t AliMUONDataInterface::NumberOfDigits(
551 TString filename, TString foldername, Int_t event,
552 Int_t chamber, Int_t cathode
555 /// Returns the number of digits in the given file, folder, event,
556 /// chamber and cathode. -1 is returned on error.
557 Assert( 0 <= chamber && chamber <= 13 );
558 Assert( 0 <= cathode && cathode <= 1 );
560 if ( ! FetchLoaders(filename, foldername) ) return -1;
561 if ( ! FetchEvent(event) ) return -1;
562 if ( ! FetchTreeD() ) return -1;
564 if ( fCathode != cathode )
570 return fData.Digits(chamber)->GetEntriesFast();
574 AliMUONDigit* AliMUONDataInterface::Digit(
575 TString filename, TString foldername, Int_t event,
576 Int_t chamber, Int_t cathode, Int_t digit
579 /// Returns the specified digit in the given file, folder, event,
580 /// chamber and cathode. NULL is returned on error.
582 Assert( 0 <= chamber && chamber <= 13 );
583 Assert( 0 <= cathode && cathode <= 1 );
585 if ( ! FetchLoaders(filename, foldername) ) return NULL;
586 if ( ! FetchEvent(event) ) return NULL;
587 if ( ! FetchTreeD() ) return NULL;
589 if ( fCathode != cathode )
595 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
599 Int_t AliMUONDataInterface::NumberOfRawClusters(
600 TString filename, TString foldername, Int_t event, Int_t chamber
603 /// Returns the number of raw clusters in the specified file, folder, event and chamber.
604 /// -1 is returned or error.
606 Assert( 0 <= chamber && chamber <= 13 );
607 if ( ! FetchLoaders(filename, foldername) ) return -1;
608 if ( ! FetchEvent(event) ) return -1;
609 if ( ! FetchTreeR() ) return -1;
610 if ( ! fClusterAddressSet )
612 // If the raw cluster address in TreeR is not set yet then set it now.
613 fData.SetTreeAddress("RC");
614 fData.ResetRawClusters();
615 fData.GetRawClusters();
616 fClusterAddressSet = kTRUE;
618 return fData.RawClusters(chamber)->GetEntriesFast();
622 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
623 TString filename, TString foldername, Int_t event,
624 Int_t chamber, Int_t cluster
627 /// Fetch the specified raw cluster from the given file, folder, event and chamber number.
628 /// NULL is returned on error.
630 Assert( 0 <= chamber && chamber <= 13 );
631 if ( ! FetchLoaders(filename, foldername) ) return NULL;
632 if ( ! FetchEvent(event) ) return NULL;
633 if ( ! FetchTreeR() ) return NULL;
634 if ( ! fClusterAddressSet )
636 // If the raw cluster address in TreeR is not set yet then set it now.
637 fData.SetTreeAddress("RC");
638 fData.ResetRawClusters();
639 fData.GetRawClusters();
640 fClusterAddressSet = kTRUE;
642 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
646 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
648 /// Return the number of local trigger objects in the specified file, folder and
649 /// event number. -1 is returned on error.
651 if ( ! FetchLoaders(filename, foldername) ) return -1;
652 if ( ! FetchEvent(event) ) return -1;
653 if ( ! FetchTreeD() ) return -1;
654 if ( ! fTriggerAddressSet )
656 // If the local trigger address in TreeR is not set yet then set it now.
657 fData.SetTreeAddress("GLT");
658 fData.ResetTrigger();
660 fTriggerAddressSet = kTRUE;
662 return fData.LocalTrigger()->GetEntriesFast();
666 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
667 TString filename, TString foldername, Int_t event, Int_t trigger
670 /// Fetch the specified local trigger object from the given file, folder and event number.
671 /// NULL is returned on error.
673 if ( ! FetchLoaders(filename, foldername) ) return NULL;
674 if ( ! FetchEvent(event) ) return NULL;
675 if ( ! FetchTreeD() ) return NULL;
676 if ( ! fTriggerAddressSet )
678 // If the local trigger address in TreeR is not set yet then set it now.
679 fData.SetTreeAddress("GLT");
680 fData.ResetTrigger();
682 fTriggerAddressSet = kTRUE;
684 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
687 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
689 /// Set the current file and folder from which to fetch data.
690 /// kTRUE is returned if the run and muon loaders were found, else kFALSE.
692 return FetchLoaders(filename, foldername);
696 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
698 /// Select the current event from which to fetch data.
699 /// kTRUE is returned if the event was found, else kFALSE is returned.
701 if (fRunloader == NULL)
703 AliError("File not set.");
707 return FetchEvent(event);
711 Int_t AliMUONDataInterface::NumberOfEvents()
713 /// Get the number of events in the currently selected file.
714 /// -1 is returned on error.
716 if (fRunloader == NULL)
718 AliError("File not set.");
721 return fRunloader->GetNumberOfEvents();
725 Int_t AliMUONDataInterface::NumberOfParticles()
727 /// Get the number of particles in the current event.
728 /// -1 is returned on error.
730 if (fRunloader == NULL)
732 AliError("File not set.");
735 if ( ! FetchTreeK() ) return -1;
736 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
740 TParticle* AliMUONDataInterface::Particle(Int_t particle)
742 /// Fetch the specified particle from the current event.
743 /// NULL is returned on error.
745 if (fRunloader == NULL)
747 AliError("File not set.");
750 if (fEventnumber < 0)
752 AliError("Event not chosen.");
755 if ( ! FetchTreeK() ) return NULL;
756 TTree* treeK = fRunloader->TreeK();
758 treeK->GetBranch("Particles")->SetAddress(&p);
759 treeK->GetEvent(particle);
764 Int_t AliMUONDataInterface::NumberOfTracks()
766 /// Get the number of tracks in the current event.
767 /// -1 is returned on error.
769 if (fRunloader == NULL)
771 AliError("File not set.");
774 if (fEventnumber < 0)
776 AliError( "Event not chosen.");
779 if ( ! FetchTreeH() ) return -1;
780 return fData.GetNtracks();
784 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
786 /// Get the number of hits for the given track in the current event.
787 /// -1 is returned on error.
789 if (fRunloader == NULL)
791 AliError("File not set.");
794 if (fEventnumber < 0)
796 AliError("Event not chosen.");
799 if ( ! FetchTreeH() ) return -1;
800 if (fTrack < 0 || fTrack != track)
803 fData.GetTrack(track);
806 return fData.Hits()->GetEntriesFast();
810 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
812 /// Fetch the specified hit from the current event.
813 /// NULL is returned on error.
815 if (fRunloader == NULL)
817 AliError("File not set.");
820 if (fEventnumber < 0)
822 AliError("Event not chosen.");
825 if ( ! FetchTreeH() ) return NULL;
826 if (fTrack < 0 || fTrack != track)
829 fData.GetTrack(track);
832 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
836 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
838 /// Get the number of s-digits on the chamber, cathode in the current event.
839 /// -1 is returned on error.
841 Assert( 0 <= chamber && chamber <= 13 );
842 Assert( 0 <= cathode && cathode <= 1 );
844 if (fRunloader == NULL)
846 AliError("File not set.");
849 if (fEventnumber < 0)
851 AliError("Event not chosen.");
855 if ( ! FetchTreeS() ) return -1;
856 if ( fSCathode != cathode )
858 fData.ResetSDigits();
862 return fData.SDigits(chamber)->GetEntriesFast();
866 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
868 /// Fetch the specified s-digits on the chamber, cathode from the current event.
869 /// NULL is returned on error.
871 Assert( 0 <= chamber && chamber <= 13 );
872 Assert( 0 <= cathode && cathode <= 1 );
874 if (fRunloader == NULL)
876 AliError("File not set.");
879 if (fEventnumber < 0)
881 AliError("Event not chosen.");
885 if ( ! FetchTreeS() ) return NULL;
886 if ( fSCathode != cathode )
888 fData.ResetSDigits();
892 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
896 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
898 /// Get the number of digits on the chamber, cathode in the current event.
899 /// -1 is returned on error.
901 Assert( 0 <= chamber && chamber <= 13 );
902 Assert( 0 <= cathode && cathode <= 1 );
904 if (fRunloader == NULL)
906 AliError("File not set.");
909 if (fEventnumber < 0)
911 AliError("Event not chosen.");
915 if ( ! FetchTreeD() ) return -1;
916 if ( fCathode != cathode )
922 return fData.Digits(chamber)->GetEntriesFast();
926 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
928 /// Fetch the specified digits on the chamber, cathode from the current event.
929 /// NULL is returned on error.
931 Assert( 0 <= chamber && chamber <= 13 );
932 Assert( 0 <= cathode && cathode <= 1 );
934 if (fRunloader == NULL)
936 AliError("File not set.");
939 if (fEventnumber < 0)
941 AliError("Event not chosen.");
945 if ( ! FetchTreeD() ) return NULL;
946 if ( fCathode != cathode )
952 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
956 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
958 /// Get the number of raw clusters on the given chamber in the current event.
959 /// -1 is returned on error.
961 Assert( 0 <= chamber && chamber <= 13 );
963 if (fRunloader == NULL)
965 AliError("File not set.");
968 if (fEventnumber < 0)
970 AliError("Event not chosen.");
974 if ( ! FetchTreeR() ) return -1;
975 if ( ! fClusterAddressSet )
977 fData.SetTreeAddress("RC");
978 fData.ResetRawClusters();
979 fData.GetRawClusters();
980 fClusterAddressSet = kTRUE;
982 return fData.RawClusters(chamber)->GetEntriesFast();
986 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
988 /// Fetch the specified raw cluster on the given chamber from the current event.
989 /// NULL is returned on error.
991 Assert( 0 <= chamber && chamber <= 13 );
993 if (fRunloader == NULL)
995 AliError("File not set.");
998 if (fEventnumber < 0)
1000 AliError("Event not chosen.");
1004 if ( ! FetchTreeR() ) return NULL;
1005 if ( ! fClusterAddressSet )
1007 fData.SetTreeAddress("RC");
1008 fData.ResetRawClusters();
1009 fData.GetRawClusters();
1010 fClusterAddressSet = kTRUE;
1012 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
1016 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
1018 /// Get the number of local trigger objects in the current event.
1019 /// -1 is returned on error.
1021 if (fRunloader == NULL)
1023 AliError("File not set.");
1026 if (fEventnumber < 0)
1028 AliError("Event not chosen.");
1032 if ( ! FetchTreeD() ) return -1;
1033 if ( ! fTriggerAddressSet )
1035 fData.SetTreeAddress("GLT");
1036 fData.ResetTrigger();
1037 fData.GetTriggerD();
1038 fTriggerAddressSet = kTRUE;
1040 return fData.LocalTrigger()->GetEntriesFast();
1044 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
1046 /// Fetch the specified local trigger object from the current event.
1047 /// NULL is returned on error.
1049 if (fRunloader == NULL)
1051 AliError("File not set.");
1054 if (fEventnumber < 0)
1056 AliError( "Event not chosen.");
1060 if ( ! FetchTreeD() ) return NULL;
1061 if ( ! fTriggerAddressSet )
1063 fData.SetTreeAddress("GLT");
1064 fData.ResetTrigger();
1065 fData.GetTriggerD();
1066 fTriggerAddressSet = kTRUE;
1068 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
1071 Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
1073 /// Get the number of local trigger objects in the current event.
1074 /// -1 is returned on error.
1076 if (fRunloader == NULL)
1078 AliError("File not set.");
1081 if (fEventnumber < 0)
1083 AliError("Event not chosen.");
1087 if ( ! FetchTreeD() ) return -1;
1088 if ( ! fTriggerAddressSet )
1090 fData.SetTreeAddress("GLT");
1091 fData.ResetTrigger();
1092 fData.GetTriggerD();
1093 fTriggerAddressSet = kTRUE;
1095 return fData.GlobalTrigger()->GetEntriesFast();
1098 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
1100 /// Fetch the specified local trigger object from the current event.
1101 /// NULL is returned on error.
1103 if (fRunloader == NULL)
1105 AliError("File not set.");
1108 if (fEventnumber < 0)
1110 AliError( "Event not chosen.");
1114 if ( ! FetchTreeD() ) return NULL;
1115 if ( ! fTriggerAddressSet )
1117 fData.SetTreeAddress("GLT");
1118 fData.ResetTrigger();
1119 fData.GetTriggerD();
1120 fTriggerAddressSet = kTRUE;
1122 return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
1125 Int_t AliMUONDataInterface::NumberOfRecTracks()
1127 /// Fetch the number of reconstructed tracks from the current event.
1128 /// NULL is returned on error.
1130 if (fRunloader == NULL)
1132 AliError("File not set.");
1135 if (fEventnumber < 0)
1137 AliError( "Event not chosen.");
1141 if ( ! FetchTreeT() ) return -1;
1142 if ( ! fRecTracksAddressSet )
1144 fData.SetTreeAddress("RT");
1145 fData.ResetRecTracks();
1146 fData.GetRecTracks();
1147 fRecTracksAddressSet = kTRUE;
1149 return fData.RecTracks()->GetEntriesFast();
1152 AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
1154 /// Fetch the specified reconstructed track object from the current event.
1155 /// NULL is returned on error.
1157 if (fRunloader == NULL)
1159 AliError("File not set.");
1162 if (fEventnumber < 0)
1164 AliError( "Event not chosen.");
1168 if ( ! FetchTreeT() ) return NULL;
1169 if ( ! fRecTracksAddressSet )
1171 fData.SetTreeAddress("RT");
1172 fData.ResetRecTracks();
1173 fData.GetRecTracks();
1174 fRecTracksAddressSet = kTRUE;
1176 return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
1177 // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));