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 **************************************************************************/
20 #include <TParticle.h>
22 #include "AliRunLoader.h"
23 #include "AliLoader.h"
25 #include "AliMUONDataInterface.h"
26 #include "AliMUONLocalTrigger.h"
27 #include "AliMUONGlobalTrigger.h"
28 #include "AliMUONHit.h"
29 #include "AliMUONDigit.h"
30 #include "AliMUONRawCluster.h"
31 #include "AliMUONTrack.h"
39 /// \class AliMUONDataInterface
41 /// An easy to use interface to the MUON module data stored in
42 /// TreeK, TreeH, TreeS, TreeD and TreeR
43 /// One can fetch any of the data objects with all the calls to runloader,
44 /// muon loader and AliMUONData done behind the scenes and automatically.
46 /// This interface in not necessarily the fastest way to fetch the data but
47 /// it is the easiest.
48 /// Note: If independant calls to the run loader, muon loader or
49 /// AliMUONData objects are interspersed with calls to the
50 /// AliMUONDataInterface to fetch data, one might need to call the Reset
51 /// method between these method calls at some point to prevent
52 /// AliMUONDataInterface from getting confused.
53 /// This is necessary since this object assumes the state of runloader,
54 /// muon loader nor AliMUONData has not changed between calls.
55 /// If the state has changes then one must call Reset so that
56 /// AliMUONDataInterface refreshes what it knows about the state
57 /// of the loader and AliMUONData objects.
59 /// \deprecated We have to revisit all this AliMUONData stuff anyway,
60 /// and probably make a real AliMUONLoader instead...
62 /// \author Artur Szostak
63 /// email: artur@alice.phy.uct.ac.za
67 ClassImp(AliMUONDataInterface)
70 AliMUONDataInterface::AliMUONDataInterface()
72 fCreatedRunLoader(kFALSE),
73 fHitAddressSet(kFALSE),
74 fSDigitAddressSet(kFALSE),
75 fDigitAddressSet(kFALSE),
76 fClusterAddressSet(kFALSE),
77 fTriggerAddressSet(kFALSE),
78 fRecTracksAddressSet(kFALSE),
81 fData(0x0, "MUON", "MUON"),
89 /// Set all internal pointers to 0x0 and indices to -1.
94 AliMUONDataInterface::~AliMUONDataInterface()
96 /// Delete the runloader if we created it.
97 /// If the runloader is not to be deleted then call Reset just before
98 /// the destructor is called.
100 if (fRunloader != NULL && fCreatedRunLoader)
104 void AliMUONDataInterface::Reset()
106 /// Sets all internal pointers to NULL and indices to -1.
107 /// Note: No resources are released!
108 /// Specificaly AliRunLoader is not deleted.
110 fCreatedRunLoader = kFALSE;
117 fHitAddressSet = kFALSE;
118 fSDigitAddressSet = kFALSE;
119 fDigitAddressSet = kFALSE;
120 fClusterAddressSet = kFALSE;
121 fTriggerAddressSet = kFALSE;
122 fRecTracksAddressSet = kFALSE;
126 Bool_t AliMUONDataInterface::UseCurrentRunLoader()
128 /// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
129 /// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
132 fRunloader = AliRunLoader::GetRunLoader();
133 if (fRunloader == NULL) return kFALSE;
134 // Fetch the current file name, folder name and event number.
135 fFilename = fRunloader->GetFileName();
136 fFoldername = fRunloader->GetEventFolder()->GetName();
137 fEventnumber = fRunloader->GetEventNumber();
139 if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
149 Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
151 /// Fetches the muon loader for the given filename/foldername
153 fMuonloader = fRunloader->GetLoader("MUONLoader");
154 if (fMuonloader == NULL)
156 AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
157 (const char*)filename, (const char*)foldername));
161 // Need to connect the muon loader to the AliMUONData object,
162 // else class to fData will return NULL.
163 fData.SetLoader(fMuonloader);
168 Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
170 /// Load the run and muon loaders from the specified file and folder.
171 /// kTRUE is returned on success and kFALSE on failure.
173 fRunloader = AliRunLoader::Open(filename, foldername, "READ");
174 if (fRunloader == NULL)
176 AliError(Form("Could not find or load the run loader for the file: %s and folder: %s",
177 (const char*)filename, (const char*)foldername));
180 fCreatedRunLoader = kTRUE;
181 if ( ! FetchMuonLoader(filename, foldername) )
187 fFilename = filename;
188 fFoldername = foldername;
189 fEventnumber = -1; // Reset the event number to force the event to be loaded.
194 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
196 /// Fetch the run loader and muon loader objects from memory if they already exist,
197 /// or from memory if they do not.
198 /// If the currently loaded run loader (if any) is not refering to the file and folder
199 /// we are interested in then it is deleted and reopened with the required file and
202 if (fRunloader == NULL)
204 fRunloader = AliRunLoader::GetRunLoader();
205 if (fRunloader == NULL)
206 return LoadLoaders(filename, foldername);
209 if (fMuonloader == NULL)
211 if ( ! FetchMuonLoader(filename, foldername) )
219 // Fetch the current file and folder names.
220 fFilename = fRunloader->GetFileName();
221 fFoldername = fRunloader->GetEventFolder()->GetName();
224 // If filename or foldername are not the same as the ones currently selected then
226 if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
229 return LoadLoaders(filename, foldername);
235 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
237 /// Fetch the specified event from the runloader and reset all the track, cathode
238 /// and address flags to force them to be reloaded.
239 /// If a negative event number is specified then the current runloader event
242 if (fEventnumber < 0)
244 fEventnumber = fRunloader->GetEventNumber();
248 fHitAddressSet = kFALSE;
249 fSDigitAddressSet = kFALSE;
250 fDigitAddressSet = kFALSE;
251 fClusterAddressSet = kFALSE;
252 fTriggerAddressSet = kFALSE;
253 fRecTracksAddressSet = kFALSE;
255 if ( event != fEventnumber )
257 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
258 fEventnumber = event;
262 fHitAddressSet = kFALSE;
263 fSDigitAddressSet = kFALSE;
264 fDigitAddressSet = kFALSE;
265 fClusterAddressSet = kFALSE;
266 fTriggerAddressSet = kFALSE;
267 fRecTracksAddressSet = kFALSE;
273 Bool_t AliMUONDataInterface::FetchTreeK()
275 /// Fetch the Kine tree from the current run loader.
277 if (fRunloader->TreeK() == NULL)
279 fRunloader->LoadKinematics("READ");
280 if (fRunloader->TreeK() == NULL)
282 AliError("Could not load TreeK.");
290 Bool_t AliMUONDataInterface::FetchTreeH()
292 /// Fetch the Hits tree from the current muon loader.
293 /// Set all the required addresses etc...
295 if (fMuonloader->TreeH() == NULL)
297 fMuonloader->LoadHits("READ");
298 if (fMuonloader->TreeH() == NULL)
300 AliError("Could not load TreeH.");
303 fData.SetTreeAddress("H");
304 fHitAddressSet = kTRUE;
306 else if ( ! fHitAddressSet )
308 fData.SetTreeAddress("H");
309 fHitAddressSet = kTRUE;
315 Bool_t AliMUONDataInterface::FetchTreeS()
317 /// Fetch the S-Digits tree from the current muon loader.
318 /// Set all the required addresses etc...
320 if (fMuonloader->TreeS() == NULL)
322 fMuonloader->LoadSDigits("READ");
323 if (fMuonloader->TreeS() == NULL)
325 AliError("Could not load TreeS.");
328 fData.SetTreeAddress("S");
329 fSDigitAddressSet = kTRUE;
331 else if ( ! fSDigitAddressSet )
333 fData.SetTreeAddress("S");
334 fSDigitAddressSet = kTRUE;
340 Bool_t AliMUONDataInterface::FetchTreeD()
342 /// Fetch the digits tree from the current muon loader.
343 /// Set all the required addresses etc...
345 if (fMuonloader->TreeD() == NULL)
347 fMuonloader->LoadDigits("READ");
348 if (fMuonloader->TreeD() == NULL)
350 AliError("Could not load TreeD.");
353 fData.SetTreeAddress("D");
354 fDigitAddressSet = kTRUE;
356 else if ( ! fDigitAddressSet )
358 fData.SetTreeAddress("D");
359 fDigitAddressSet = kTRUE;
365 Bool_t AliMUONDataInterface::FetchTreeR()
367 /// Fetch the reconstructed objects tree from the current muon loader.
368 /// Note: The addresses must still be set.
370 if (fMuonloader->TreeR() == NULL)
372 fMuonloader->LoadRecPoints("READ");
373 if (fMuonloader->TreeR() == NULL)
375 AliError("Could not load TreeR.");
379 // Need to reset these flags so that the cluster and trigger address
380 // gets reset after this method.
381 fClusterAddressSet = kFALSE;
382 fTriggerAddressSet = kFALSE;
387 Bool_t AliMUONDataInterface::FetchTreeT()
389 /// fetch the reconstructed tracks tree from the current muon loader
390 /// note : the addresses must still be set.
391 if (fMuonloader->TreeT() == NULL)
393 fMuonloader->LoadTracks("READ");
394 if (fMuonloader->TreeT() == NULL)
396 AliError("Could not load TreeT.");
400 // Need to reset these flags so that the rec tracks address
401 // gets reset after this method.
402 fRecTracksAddressSet = kFALSE;
407 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
409 /// Returns the number of events in the specified file/folder, and -1 on error.
411 if ( ! FetchLoaders(filename, foldername) ) return -1;
412 return fRunloader->GetNumberOfEvents();
416 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
418 /// Returns the number of events in the specified file/folder, and -1 on error.
420 if ( ! FetchLoaders(filename, foldername) ) return -1;
421 if ( ! FetchEvent(event) ) return -1;
422 if ( ! FetchTreeK() ) return -1;
423 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
427 TParticle* AliMUONDataInterface::Particle(
428 TString filename, TString foldername, Int_t event, Int_t particle
431 /// Returns the specified particle in the given file, folder and event.
432 /// NULL is returned on error.
434 if ( ! FetchLoaders(filename, foldername) ) return NULL;
435 if ( ! FetchEvent(event) ) return NULL;
436 if ( ! FetchTreeK() ) return NULL;
438 TTree* treeK = fRunloader->TreeK();
440 treeK->GetBranch("Particles")->SetAddress(&p);
441 treeK->GetEvent(particle);
446 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
448 /// Returns the number of tracks in the specified file/folder and event.
449 /// -1 is returned on error.
451 if ( ! FetchLoaders(filename, foldername) ) return -1;
452 if ( ! FetchEvent(event) ) return -1;
453 if ( ! FetchTreeH() ) return -1;
454 return fData.GetNtracks();
458 Int_t AliMUONDataInterface::NumberOfHits(
459 TString filename, TString foldername, Int_t event, Int_t track
462 /// Returns the number of hits in the specified file/folder, event and track.
463 /// -1 is returned on error.
465 if ( ! FetchLoaders(filename, foldername) ) return -1;
466 if ( ! FetchEvent(event) ) return -1;
467 if ( ! FetchTreeH() ) return -1;
469 if (fTrack < 0 || fTrack != track)
472 fData.GetTrack(track);
475 return fData.Hits()->GetEntriesFast();
479 AliMUONHit* AliMUONDataInterface::Hit(
480 TString filename, TString foldername, Int_t event,
481 Int_t track, Int_t hit
484 /// Returns the specified hit in the given file, folder, event and track.
485 /// NULL is returned on error.
487 if ( ! FetchLoaders(filename, foldername) ) return NULL;
488 if ( ! FetchEvent(event) ) return NULL;
489 if ( ! FetchTreeH() ) return NULL;
491 if (fTrack < 0 || fTrack != track)
494 fData.GetTrack(track);
497 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
501 Int_t AliMUONDataInterface::NumberOfSDigits(
502 TString filename, TString foldername, Int_t event,
503 Int_t chamber, Int_t cathode
506 /// Returns the number of s-digits in the given file, folder, event,
507 /// chamber and cathode. -1 is returned on error.
509 assert( 0 <= chamber && chamber <= 13 );
510 assert( 0 <= cathode && cathode <= 1 );
512 if ( ! FetchLoaders(filename, foldername) ) return -1;
513 if ( ! FetchEvent(event) ) return -1;
514 if ( ! FetchTreeS() ) return -1;
516 if ( fSCathode != cathode )
518 fData.ResetSDigits();
522 return fData.SDigits(chamber)->GetEntriesFast();
526 AliMUONDigit* AliMUONDataInterface::SDigit(
527 TString filename, TString foldername, Int_t event,
528 Int_t chamber, Int_t cathode, Int_t sdigit
531 /// Returns the specified s-digit in the given file, folder, event,
532 /// chamber and cathode. NULL is returned on error.
534 assert( 0 <= chamber && chamber <= 13 );
535 assert( 0 <= cathode && cathode <= 1 );
537 if ( ! FetchLoaders(filename, foldername) ) return NULL;
538 if ( ! FetchEvent(event) ) return NULL;
539 if ( ! FetchTreeS() ) return NULL;
541 if ( fSCathode != cathode )
543 fData.ResetSDigits();
547 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
551 Int_t AliMUONDataInterface::NumberOfDigits(
552 TString filename, TString foldername, Int_t event,
553 Int_t chamber, Int_t cathode
556 /// Returns the number of digits in the given file, folder, event,
557 /// chamber and cathode. -1 is returned on error.
558 assert( 0 <= chamber && chamber <= 13 );
559 assert( 0 <= cathode && cathode <= 1 );
561 if ( ! FetchLoaders(filename, foldername) ) return -1;
562 if ( ! FetchEvent(event) ) return -1;
563 if ( ! FetchTreeD() ) return -1;
565 if ( fCathode != cathode )
571 return fData.Digits(chamber)->GetEntriesFast();
575 AliMUONDigit* AliMUONDataInterface::Digit(
576 TString filename, TString foldername, Int_t event,
577 Int_t chamber, Int_t cathode, Int_t digit
580 /// Returns the specified digit in the given file, folder, event,
581 /// chamber and cathode. NULL is returned on error.
583 assert( 0 <= chamber && chamber <= 13 );
584 assert( 0 <= cathode && cathode <= 1 );
586 if ( ! FetchLoaders(filename, foldername) ) return NULL;
587 if ( ! FetchEvent(event) ) return NULL;
588 if ( ! FetchTreeD() ) return NULL;
590 if ( fCathode != cathode )
596 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
600 Int_t AliMUONDataInterface::NumberOfRawClusters(
601 TString filename, TString foldername, Int_t event, Int_t chamber
604 /// Returns the number of raw clusters in the specified file, folder, event and chamber.
605 /// -1 is returned or error.
607 assert( 0 <= chamber && chamber <= 13 );
608 if ( ! FetchLoaders(filename, foldername) ) return -1;
609 if ( ! FetchEvent(event) ) return -1;
610 if ( ! FetchTreeR() ) return -1;
611 if ( ! fClusterAddressSet )
613 // If the raw cluster address in TreeR is not set yet then set it now.
614 fData.SetTreeAddress("RC");
615 fData.ResetRawClusters();
616 fData.GetRawClusters();
617 fClusterAddressSet = kTRUE;
619 return fData.RawClusters(chamber)->GetEntriesFast();
623 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
624 TString filename, TString foldername, Int_t event,
625 Int_t chamber, Int_t cluster
628 /// Fetch the specified raw cluster from the given file, folder, event and chamber number.
629 /// NULL is returned on error.
631 assert( 0 <= chamber && chamber <= 13 );
632 if ( ! FetchLoaders(filename, foldername) ) return NULL;
633 if ( ! FetchEvent(event) ) return NULL;
634 if ( ! FetchTreeR() ) return NULL;
635 if ( ! fClusterAddressSet )
637 // If the raw cluster address in TreeR is not set yet then set it now.
638 fData.SetTreeAddress("RC");
639 fData.ResetRawClusters();
640 fData.GetRawClusters();
641 fClusterAddressSet = kTRUE;
643 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
647 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
649 /// Return the number of local trigger objects in the specified file, folder and
650 /// event number. -1 is returned on error.
652 if ( ! FetchLoaders(filename, foldername) ) return -1;
653 if ( ! FetchEvent(event) ) return -1;
654 if ( ! FetchTreeD() ) return -1;
655 if ( ! fTriggerAddressSet )
657 // If the local trigger address in TreeR is not set yet then set it now.
658 fData.SetTreeAddress("GLT");
659 fData.ResetTrigger();
661 fTriggerAddressSet = kTRUE;
663 return fData.LocalTrigger()->GetEntriesFast();
667 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
668 TString filename, TString foldername, Int_t event, Int_t trigger
671 /// Fetch the specified local trigger object from the given file, folder and event number.
672 /// NULL is returned on error.
674 if ( ! FetchLoaders(filename, foldername) ) return NULL;
675 if ( ! FetchEvent(event) ) return NULL;
676 if ( ! FetchTreeD() ) return NULL;
677 if ( ! fTriggerAddressSet )
679 // If the local trigger address in TreeR is not set yet then set it now.
680 fData.SetTreeAddress("GLT");
681 fData.ResetTrigger();
683 fTriggerAddressSet = kTRUE;
685 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
688 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
690 /// Set the current file and folder from which to fetch data.
691 /// kTRUE is returned if the run and muon loaders were found, else kFALSE.
693 return FetchLoaders(filename, foldername);
697 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
699 /// Select the current event from which to fetch data.
700 /// kTRUE is returned if the event was found, else kFALSE is returned.
702 if (fRunloader == NULL)
704 AliError("File not set.");
708 return FetchEvent(event);
712 Int_t AliMUONDataInterface::NumberOfEvents()
714 /// Get the number of events in the currently selected file.
715 /// -1 is returned on error.
717 if (fRunloader == NULL)
719 AliError("File not set.");
722 return fRunloader->GetNumberOfEvents();
726 Int_t AliMUONDataInterface::NumberOfParticles()
728 /// Get the number of particles in the current event.
729 /// -1 is returned on error.
731 if (fRunloader == NULL)
733 AliError("File not set.");
736 if ( ! FetchTreeK() ) return -1;
737 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
741 TParticle* AliMUONDataInterface::Particle(Int_t particle)
743 /// Fetch the specified particle from the current event.
744 /// NULL is returned on error.
746 if (fRunloader == NULL)
748 AliError("File not set.");
751 if (fEventnumber < 0)
753 AliError("Event not chosen.");
756 if ( ! FetchTreeK() ) return NULL;
757 TTree* treeK = fRunloader->TreeK();
759 treeK->GetBranch("Particles")->SetAddress(&p);
760 treeK->GetEvent(particle);
765 Int_t AliMUONDataInterface::NumberOfTracks()
767 /// Get the number of tracks in the current event.
768 /// -1 is returned on error.
770 if (fRunloader == NULL)
772 AliError("File not set.");
775 if (fEventnumber < 0)
777 AliError( "Event not chosen.");
780 if ( ! FetchTreeH() ) return -1;
781 return fData.GetNtracks();
785 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
787 /// Get the number of hits for the given track in the current event.
788 /// -1 is returned on error.
790 if (fRunloader == NULL)
792 AliError("File not set.");
795 if (fEventnumber < 0)
797 AliError("Event not chosen.");
800 if ( ! FetchTreeH() ) return -1;
801 if (fTrack < 0 || fTrack != track)
804 fData.GetTrack(track);
807 return fData.Hits()->GetEntriesFast();
811 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
813 /// Fetch the specified hit from the current event.
814 /// NULL is returned on error.
816 if (fRunloader == NULL)
818 AliError("File not set.");
821 if (fEventnumber < 0)
823 AliError("Event not chosen.");
826 if ( ! FetchTreeH() ) return NULL;
827 if (fTrack < 0 || fTrack != track)
830 fData.GetTrack(track);
833 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
837 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
839 /// Get the number of s-digits on the chamber, cathode in the current event.
840 /// -1 is returned on error.
842 assert( 0 <= chamber && chamber <= 13 );
843 assert( 0 <= cathode && cathode <= 1 );
845 if (fRunloader == NULL)
847 AliError("File not set.");
850 if (fEventnumber < 0)
852 AliError("Event not chosen.");
856 if ( ! FetchTreeS() ) return -1;
857 if ( fSCathode != cathode )
859 fData.ResetSDigits();
863 return fData.SDigits(chamber)->GetEntriesFast();
867 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
869 /// Fetch the specified s-digits on the chamber, cathode from the current event.
870 /// NULL is returned on error.
872 assert( 0 <= chamber && chamber <= 13 );
873 assert( 0 <= cathode && cathode <= 1 );
875 if (fRunloader == NULL)
877 AliError("File not set.");
880 if (fEventnumber < 0)
882 AliError("Event not chosen.");
886 if ( ! FetchTreeS() ) return NULL;
887 if ( fSCathode != cathode )
889 fData.ResetSDigits();
893 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
897 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
899 /// Get the number of digits on the chamber, cathode in the current event.
900 /// -1 is returned on error.
902 assert( 0 <= chamber && chamber <= 13 );
903 assert( 0 <= cathode && cathode <= 1 );
905 if (fRunloader == NULL)
907 AliError("File not set.");
910 if (fEventnumber < 0)
912 AliError("Event not chosen.");
916 if ( ! FetchTreeD() ) return -1;
917 if ( fCathode != cathode )
923 return fData.Digits(chamber)->GetEntriesFast();
927 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
929 /// Fetch the specified digits on the chamber, cathode from the current event.
930 /// NULL is returned on error.
932 assert( 0 <= chamber && chamber <= 13 );
933 assert( 0 <= cathode && cathode <= 1 );
935 if (fRunloader == NULL)
937 AliError("File not set.");
940 if (fEventnumber < 0)
942 AliError("Event not chosen.");
946 if ( ! FetchTreeD() ) return NULL;
947 if ( fCathode != cathode )
953 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
957 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
959 /// Get the number of raw clusters on the given chamber in the current event.
960 /// -1 is returned on error.
962 assert( 0 <= chamber && chamber <= 13 );
964 if (fRunloader == NULL)
966 AliError("File not set.");
969 if (fEventnumber < 0)
971 AliError("Event not chosen.");
975 if ( ! FetchTreeR() ) return -1;
976 if ( ! fClusterAddressSet )
978 fData.SetTreeAddress("RC");
979 fData.ResetRawClusters();
980 fData.GetRawClusters();
981 fClusterAddressSet = kTRUE;
983 return fData.RawClusters(chamber)->GetEntriesFast();
987 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
989 /// Fetch the specified raw cluster on the given chamber from the current event.
990 /// NULL is returned on error.
992 assert( 0 <= chamber && chamber <= 13 );
994 if (fRunloader == NULL)
996 AliError("File not set.");
999 if (fEventnumber < 0)
1001 AliError("Event not chosen.");
1005 if ( ! FetchTreeR() ) return NULL;
1006 if ( ! fClusterAddressSet )
1008 fData.SetTreeAddress("RC");
1009 fData.ResetRawClusters();
1010 fData.GetRawClusters();
1011 fClusterAddressSet = kTRUE;
1013 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
1017 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
1019 /// Get the number of local trigger objects in the current event.
1020 /// -1 is returned on error.
1022 if (fRunloader == NULL)
1024 AliError("File not set.");
1027 if (fEventnumber < 0)
1029 AliError("Event not chosen.");
1033 if ( ! FetchTreeD() ) return -1;
1034 if ( ! fTriggerAddressSet )
1036 fData.SetTreeAddress("GLT");
1037 fData.ResetTrigger();
1038 fData.GetTriggerD();
1039 fTriggerAddressSet = kTRUE;
1041 return fData.LocalTrigger()->GetEntriesFast();
1045 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
1047 /// Fetch the specified local trigger object from the current event.
1048 /// NULL is returned on error.
1050 if (fRunloader == NULL)
1052 AliError("File not set.");
1055 if (fEventnumber < 0)
1057 AliError( "Event not chosen.");
1061 if ( ! FetchTreeD() ) return NULL;
1062 if ( ! fTriggerAddressSet )
1064 fData.SetTreeAddress("GLT");
1065 fData.ResetTrigger();
1066 fData.GetTriggerD();
1067 fTriggerAddressSet = kTRUE;
1069 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
1072 Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
1074 /// Get the number of local trigger objects in the current event.
1075 /// -1 is returned on error.
1077 if (fRunloader == NULL)
1079 AliError("File not set.");
1082 if (fEventnumber < 0)
1084 AliError("Event not chosen.");
1088 if ( ! FetchTreeD() ) return -1;
1089 if ( ! fTriggerAddressSet )
1091 fData.SetTreeAddress("GLT");
1092 fData.ResetTrigger();
1093 fData.GetTriggerD();
1094 fTriggerAddressSet = kTRUE;
1096 return fData.GlobalTrigger()->GetEntriesFast();
1099 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
1101 /// Fetch the specified local trigger object from the current event.
1102 /// NULL is returned on error.
1104 if (fRunloader == NULL)
1106 AliError("File not set.");
1109 if (fEventnumber < 0)
1111 AliError( "Event not chosen.");
1115 if ( ! FetchTreeD() ) return NULL;
1116 if ( ! fTriggerAddressSet )
1118 fData.SetTreeAddress("GLT");
1119 fData.ResetTrigger();
1120 fData.GetTriggerD();
1121 fTriggerAddressSet = kTRUE;
1123 return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
1126 Int_t AliMUONDataInterface::NumberOfRecTracks()
1128 /// Fetch the number of reconstructed tracks from the current event.
1129 /// NULL is returned on error.
1131 if (fRunloader == NULL)
1133 AliError("File not set.");
1136 if (fEventnumber < 0)
1138 AliError( "Event not chosen.");
1142 if ( ! FetchTreeT() ) return -1;
1143 if ( ! fRecTracksAddressSet )
1145 fData.SetTreeAddress("RT");
1146 fData.ResetRecTracks();
1147 fData.GetRecTracks();
1148 fRecTracksAddressSet = kTRUE;
1150 return fData.RecTracks()->GetEntriesFast();
1153 AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
1155 /// Fetch the specified reconstructed track object from the current event.
1156 /// NULL is returned on error.
1158 if (fRunloader == NULL)
1160 AliError("File not set.");
1163 if (fEventnumber < 0)
1165 AliError( "Event not chosen.");
1169 if ( ! FetchTreeT() ) return NULL;
1170 if ( ! fRecTracksAddressSet )
1172 fData.SetTreeAddress("RT");
1173 fData.ResetRecTracks();
1174 fData.GetRecTracks();
1175 fRecTracksAddressSet = kTRUE;
1177 return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
1178 // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));