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()
70 : TObject(), fData(NULL, "MUON", "MUON")
72 /// Set all internal pointers to NULL and indices to -1.
77 AliMUONDataInterface::~AliMUONDataInterface()
79 /// Delete the runloader if we created it.
80 /// If the runloader is not to be deleted then call Reset just before
81 /// the destructor is called.
83 if (fRunloader != NULL && fCreatedRunLoader)
87 void AliMUONDataInterface::Reset()
89 /// Sets all internal pointers to NULL and indices to -1.
90 /// Note: No resources are released!
91 /// Specificaly AliRunLoader is not deleted.
93 fCreatedRunLoader = kFALSE;
100 fHitAddressSet = kFALSE;
101 fSDigitAddressSet = kFALSE;
102 fDigitAddressSet = kFALSE;
103 fClusterAddressSet = kFALSE;
104 fTriggerAddressSet = kFALSE;
105 fRecTracksAddressSet = kFALSE;
109 Bool_t AliMUONDataInterface::UseCurrentRunLoader()
111 /// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
112 /// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
115 fRunloader = AliRunLoader::GetRunLoader();
116 if (fRunloader == NULL) return kFALSE;
117 // Fetch the current file name, folder name and event number.
118 fFilename = fRunloader->GetFileName();
119 fFoldername = fRunloader->GetEventFolder()->GetName();
120 fEventnumber = fRunloader->GetEventNumber();
122 if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
132 Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
134 /// Fetches the muon loader for the given filename/foldername
136 fMuonloader = fRunloader->GetLoader("MUONLoader");
137 if (fMuonloader == NULL)
139 AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
140 (const char*)filename, (const char*)foldername));
144 // Need to connect the muon loader to the AliMUONData object,
145 // else class to fData will return NULL.
146 fData.SetLoader(fMuonloader);
151 Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
153 /// Load the run and muon loaders from the specified file and folder.
154 /// kTRUE is returned on success and kFALSE on failure.
156 fRunloader = AliRunLoader::Open(filename, foldername, "READ");
157 if (fRunloader == NULL)
159 AliError(Form("Could not find or load the run loader for the file: %s and folder: %s",
160 (const char*)filename, (const char*)foldername));
163 fCreatedRunLoader = kTRUE;
164 if ( ! FetchMuonLoader(filename, foldername) )
170 fFilename = filename;
171 fFoldername = foldername;
172 fEventnumber = -1; // Reset the event number to force the event to be loaded.
177 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
179 /// Fetch the run loader and muon loader objects from memory if they already exist,
180 /// or from memory if they do not.
181 /// If the currently loaded run loader (if any) is not refering to the file and folder
182 /// we are interested in then it is deleted and reopened with the required file and
185 if (fRunloader == NULL)
187 fRunloader = AliRunLoader::GetRunLoader();
188 if (fRunloader == NULL)
189 return LoadLoaders(filename, foldername);
192 if (fMuonloader == NULL)
194 if ( ! FetchMuonLoader(filename, foldername) )
202 // Fetch the current file and folder names.
203 fFilename = fRunloader->GetFileName();
204 fFoldername = fRunloader->GetEventFolder()->GetName();
207 // If filename or foldername are not the same as the ones currently selected then
209 if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
212 return LoadLoaders(filename, foldername);
218 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
220 /// Fetch the specified event from the runloader and reset all the track, cathode
221 /// and address flags to force them to be reloaded.
222 /// If a negative event number is specified then the current runloader event
225 if (fEventnumber < 0)
227 fEventnumber = fRunloader->GetEventNumber();
231 fHitAddressSet = kFALSE;
232 fSDigitAddressSet = kFALSE;
233 fDigitAddressSet = kFALSE;
234 fClusterAddressSet = kFALSE;
235 fTriggerAddressSet = kFALSE;
236 fRecTracksAddressSet = kFALSE;
238 if ( event != fEventnumber )
240 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
241 fEventnumber = event;
245 fHitAddressSet = kFALSE;
246 fSDigitAddressSet = kFALSE;
247 fDigitAddressSet = kFALSE;
248 fClusterAddressSet = kFALSE;
249 fTriggerAddressSet = kFALSE;
250 fRecTracksAddressSet = kFALSE;
256 Bool_t AliMUONDataInterface::FetchTreeK()
258 /// Fetch the Kine tree from the current run loader.
260 if (fRunloader->TreeK() == NULL)
262 fRunloader->LoadKinematics("READ");
263 if (fRunloader->TreeK() == NULL)
265 AliError("Could not load TreeK.");
273 Bool_t AliMUONDataInterface::FetchTreeH()
275 /// Fetch the Hits tree from the current muon loader.
276 /// Set all the required addresses etc...
278 if (fMuonloader->TreeH() == NULL)
280 fMuonloader->LoadHits("READ");
281 if (fMuonloader->TreeH() == NULL)
283 AliError("Could not load TreeH.");
286 fData.SetTreeAddress("H");
287 fHitAddressSet = kTRUE;
289 else if ( ! fHitAddressSet )
291 fData.SetTreeAddress("H");
292 fHitAddressSet = kTRUE;
298 Bool_t AliMUONDataInterface::FetchTreeS()
300 /// Fetch the S-Digits tree from the current muon loader.
301 /// Set all the required addresses etc...
303 if (fMuonloader->TreeS() == NULL)
305 fMuonloader->LoadSDigits("READ");
306 if (fMuonloader->TreeS() == NULL)
308 AliError("Could not load TreeS.");
311 fData.SetTreeAddress("S");
312 fSDigitAddressSet = kTRUE;
314 else if ( ! fSDigitAddressSet )
316 fData.SetTreeAddress("S");
317 fSDigitAddressSet = kTRUE;
323 Bool_t AliMUONDataInterface::FetchTreeD()
325 /// Fetch the digits tree from the current muon loader.
326 /// Set all the required addresses etc...
328 if (fMuonloader->TreeD() == NULL)
330 fMuonloader->LoadDigits("READ");
331 if (fMuonloader->TreeD() == NULL)
333 AliError("Could not load TreeD.");
336 fData.SetTreeAddress("D");
337 fDigitAddressSet = kTRUE;
339 else if ( ! fDigitAddressSet )
341 fData.SetTreeAddress("D");
342 fDigitAddressSet = kTRUE;
348 Bool_t AliMUONDataInterface::FetchTreeR()
350 /// Fetch the reconstructed objects tree from the current muon loader.
351 /// Note: The addresses must still be set.
353 if (fMuonloader->TreeR() == NULL)
355 fMuonloader->LoadRecPoints("READ");
356 if (fMuonloader->TreeR() == NULL)
358 AliError("Could not load TreeR.");
362 // Need to reset these flags so that the cluster and trigger address
363 // gets reset after this method.
364 fClusterAddressSet = kFALSE;
365 fTriggerAddressSet = kFALSE;
370 Bool_t AliMUONDataInterface::FetchTreeT()
372 /// fetch the reconstructed tracks tree from the current muon loader
373 /// note : the addresses must still be set.
374 if (fMuonloader->TreeT() == NULL)
376 fMuonloader->LoadTracks("READ");
377 if (fMuonloader->TreeT() == NULL)
379 AliError("Could not load TreeT.");
383 // Need to reset these flags so that the rec tracks address
384 // gets reset after this method.
385 fRecTracksAddressSet = kFALSE;
390 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
392 /// Returns the number of events in the specified file/folder, and -1 on error.
394 if ( ! FetchLoaders(filename, foldername) ) return -1;
395 return fRunloader->GetNumberOfEvents();
399 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
401 /// Returns the number of events in the specified file/folder, and -1 on error.
403 if ( ! FetchLoaders(filename, foldername) ) return -1;
404 if ( ! FetchEvent(event) ) return -1;
405 if ( ! FetchTreeK() ) return -1;
406 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
410 TParticle* AliMUONDataInterface::Particle(
411 TString filename, TString foldername, Int_t event, Int_t particle
414 /// Returns the specified particle in the given file, folder and event.
415 /// NULL is returned on error.
417 if ( ! FetchLoaders(filename, foldername) ) return NULL;
418 if ( ! FetchEvent(event) ) return NULL;
419 if ( ! FetchTreeK() ) return NULL;
421 TTree* treeK = fRunloader->TreeK();
423 treeK->GetBranch("Particles")->SetAddress(&p);
424 treeK->GetEvent(particle);
429 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
431 /// Returns the number of tracks in the specified file/folder and event.
432 /// -1 is returned on error.
434 if ( ! FetchLoaders(filename, foldername) ) return -1;
435 if ( ! FetchEvent(event) ) return -1;
436 if ( ! FetchTreeH() ) return -1;
437 return fData.GetNtracks();
441 Int_t AliMUONDataInterface::NumberOfHits(
442 TString filename, TString foldername, Int_t event, Int_t track
445 /// Returns the number of hits in the specified file/folder, event and track.
446 /// -1 is returned on error.
448 if ( ! FetchLoaders(filename, foldername) ) return -1;
449 if ( ! FetchEvent(event) ) return -1;
450 if ( ! FetchTreeH() ) return -1;
452 if (fTrack < 0 || fTrack != track)
455 fData.GetTrack(track);
458 return fData.Hits()->GetEntriesFast();
462 AliMUONHit* AliMUONDataInterface::Hit(
463 TString filename, TString foldername, Int_t event,
464 Int_t track, Int_t hit
467 /// Returns the specified hit in the given file, folder, event and track.
468 /// NULL is returned on error.
470 if ( ! FetchLoaders(filename, foldername) ) return NULL;
471 if ( ! FetchEvent(event) ) return NULL;
472 if ( ! FetchTreeH() ) return NULL;
474 if (fTrack < 0 || fTrack != track)
477 fData.GetTrack(track);
480 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
484 Int_t AliMUONDataInterface::NumberOfSDigits(
485 TString filename, TString foldername, Int_t event,
486 Int_t chamber, Int_t cathode
489 /// Returns the number of s-digits in the given file, folder, event,
490 /// chamber and cathode. -1 is returned on error.
492 Assert( 0 <= chamber && chamber <= 13 );
493 Assert( 0 <= cathode && cathode <= 1 );
495 if ( ! FetchLoaders(filename, foldername) ) return -1;
496 if ( ! FetchEvent(event) ) return -1;
497 if ( ! FetchTreeS() ) return -1;
499 if ( fSCathode != cathode )
501 fData.ResetSDigits();
505 return fData.SDigits(chamber)->GetEntriesFast();
509 AliMUONDigit* AliMUONDataInterface::SDigit(
510 TString filename, TString foldername, Int_t event,
511 Int_t chamber, Int_t cathode, Int_t sdigit
514 /// Returns the specified s-digit in the given file, folder, event,
515 /// chamber and cathode. NULL is returned on error.
517 Assert( 0 <= chamber && chamber <= 13 );
518 Assert( 0 <= cathode && cathode <= 1 );
520 if ( ! FetchLoaders(filename, foldername) ) return NULL;
521 if ( ! FetchEvent(event) ) return NULL;
522 if ( ! FetchTreeS() ) return NULL;
524 if ( fSCathode != cathode )
526 fData.ResetSDigits();
530 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
534 Int_t AliMUONDataInterface::NumberOfDigits(
535 TString filename, TString foldername, Int_t event,
536 Int_t chamber, Int_t cathode
539 /// Returns the number of digits in the given file, folder, event,
540 /// chamber and cathode. -1 is returned on error.
541 Assert( 0 <= chamber && chamber <= 13 );
542 Assert( 0 <= cathode && cathode <= 1 );
544 if ( ! FetchLoaders(filename, foldername) ) return -1;
545 if ( ! FetchEvent(event) ) return -1;
546 if ( ! FetchTreeD() ) return -1;
548 if ( fCathode != cathode )
554 return fData.Digits(chamber)->GetEntriesFast();
558 AliMUONDigit* AliMUONDataInterface::Digit(
559 TString filename, TString foldername, Int_t event,
560 Int_t chamber, Int_t cathode, Int_t digit
563 /// Returns the specified digit in the given file, folder, event,
564 /// chamber and cathode. NULL is returned on error.
566 Assert( 0 <= chamber && chamber <= 13 );
567 Assert( 0 <= cathode && cathode <= 1 );
569 if ( ! FetchLoaders(filename, foldername) ) return NULL;
570 if ( ! FetchEvent(event) ) return NULL;
571 if ( ! FetchTreeD() ) return NULL;
573 if ( fCathode != cathode )
579 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
583 Int_t AliMUONDataInterface::NumberOfRawClusters(
584 TString filename, TString foldername, Int_t event, Int_t chamber
587 /// Returns the number of raw clusters in the specified file, folder, event and chamber.
588 /// -1 is returned or error.
590 Assert( 0 <= chamber && chamber <= 13 );
591 if ( ! FetchLoaders(filename, foldername) ) return -1;
592 if ( ! FetchEvent(event) ) return -1;
593 if ( ! FetchTreeR() ) return -1;
594 if ( ! fClusterAddressSet )
596 // If the raw cluster address in TreeR is not set yet then set it now.
597 fData.SetTreeAddress("RC");
598 fData.ResetRawClusters();
599 fData.GetRawClusters();
600 fClusterAddressSet = kTRUE;
602 return fData.RawClusters(chamber)->GetEntriesFast();
606 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
607 TString filename, TString foldername, Int_t event,
608 Int_t chamber, Int_t cluster
611 /// Fetch the specified raw cluster from the given file, folder, event and chamber number.
612 /// NULL is returned on error.
614 Assert( 0 <= chamber && chamber <= 13 );
615 if ( ! FetchLoaders(filename, foldername) ) return NULL;
616 if ( ! FetchEvent(event) ) return NULL;
617 if ( ! FetchTreeR() ) return NULL;
618 if ( ! fClusterAddressSet )
620 // If the raw cluster address in TreeR is not set yet then set it now.
621 fData.SetTreeAddress("RC");
622 fData.ResetRawClusters();
623 fData.GetRawClusters();
624 fClusterAddressSet = kTRUE;
626 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
630 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
632 /// Return the number of local trigger objects in the specified file, folder and
633 /// event number. -1 is returned on error.
635 if ( ! FetchLoaders(filename, foldername) ) return -1;
636 if ( ! FetchEvent(event) ) return -1;
637 if ( ! FetchTreeD() ) return -1;
638 if ( ! fTriggerAddressSet )
640 // If the local trigger address in TreeR is not set yet then set it now.
641 fData.SetTreeAddress("GLT");
642 fData.ResetTrigger();
644 fTriggerAddressSet = kTRUE;
646 return fData.LocalTrigger()->GetEntriesFast();
650 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
651 TString filename, TString foldername, Int_t event, Int_t trigger
654 /// Fetch the specified local trigger object from the given file, folder and event number.
655 /// NULL is returned on error.
657 if ( ! FetchLoaders(filename, foldername) ) return NULL;
658 if ( ! FetchEvent(event) ) return NULL;
659 if ( ! FetchTreeD() ) return NULL;
660 if ( ! fTriggerAddressSet )
662 // If the local trigger address in TreeR is not set yet then set it now.
663 fData.SetTreeAddress("GLT");
664 fData.ResetTrigger();
666 fTriggerAddressSet = kTRUE;
668 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
671 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
673 /// Set the current file and folder from which to fetch data.
674 /// kTRUE is returned if the run and muon loaders were found, else kFALSE.
676 return FetchLoaders(filename, foldername);
680 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
682 /// Select the current event from which to fetch data.
683 /// kTRUE is returned if the event was found, else kFALSE is returned.
685 if (fRunloader == NULL)
687 AliError("File not set.");
691 return FetchEvent(event);
695 Int_t AliMUONDataInterface::NumberOfEvents()
697 /// Get the number of events in the currently selected file.
698 /// -1 is returned on error.
700 if (fRunloader == NULL)
702 AliError("File not set.");
705 return fRunloader->GetNumberOfEvents();
709 Int_t AliMUONDataInterface::NumberOfParticles()
711 /// Get the number of particles in the current event.
712 /// -1 is returned on error.
714 if (fRunloader == NULL)
716 AliError("File not set.");
719 if ( ! FetchTreeK() ) return -1;
720 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
724 TParticle* AliMUONDataInterface::Particle(Int_t particle)
726 /// Fetch the specified particle from the current event.
727 /// NULL is returned on error.
729 if (fRunloader == NULL)
731 AliError("File not set.");
734 if (fEventnumber < 0)
736 AliError("Event not chosen.");
739 if ( ! FetchTreeK() ) return NULL;
740 TTree* treeK = fRunloader->TreeK();
742 treeK->GetBranch("Particles")->SetAddress(&p);
743 treeK->GetEvent(particle);
748 Int_t AliMUONDataInterface::NumberOfTracks()
750 /// Get the number of tracks in the current event.
751 /// -1 is returned on error.
753 if (fRunloader == NULL)
755 AliError("File not set.");
758 if (fEventnumber < 0)
760 AliError( "Event not chosen.");
763 if ( ! FetchTreeH() ) return -1;
764 return fData.GetNtracks();
768 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
770 /// Get the number of hits for the given track in the current event.
771 /// -1 is returned on error.
773 if (fRunloader == NULL)
775 AliError("File not set.");
778 if (fEventnumber < 0)
780 AliError("Event not chosen.");
783 if ( ! FetchTreeH() ) return -1;
784 if (fTrack < 0 || fTrack != track)
787 fData.GetTrack(track);
790 return fData.Hits()->GetEntriesFast();
794 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
796 /// Fetch the specified hit from the current event.
797 /// NULL is returned on error.
799 if (fRunloader == NULL)
801 AliError("File not set.");
804 if (fEventnumber < 0)
806 AliError("Event not chosen.");
809 if ( ! FetchTreeH() ) return NULL;
810 if (fTrack < 0 || fTrack != track)
813 fData.GetTrack(track);
816 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
820 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
822 /// Get the number of s-digits on the chamber, cathode in the current event.
823 /// -1 is returned on error.
825 Assert( 0 <= chamber && chamber <= 13 );
826 Assert( 0 <= cathode && cathode <= 1 );
828 if (fRunloader == NULL)
830 AliError("File not set.");
833 if (fEventnumber < 0)
835 AliError("Event not chosen.");
839 if ( ! FetchTreeS() ) return -1;
840 if ( fSCathode != cathode )
842 fData.ResetSDigits();
846 return fData.SDigits(chamber)->GetEntriesFast();
850 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
852 /// Fetch the specified s-digits on the chamber, cathode from the current event.
853 /// NULL is returned on error.
855 Assert( 0 <= chamber && chamber <= 13 );
856 Assert( 0 <= cathode && cathode <= 1 );
858 if (fRunloader == NULL)
860 AliError("File not set.");
863 if (fEventnumber < 0)
865 AliError("Event not chosen.");
869 if ( ! FetchTreeS() ) return NULL;
870 if ( fSCathode != cathode )
872 fData.ResetSDigits();
876 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
880 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
882 /// Get the number of digits on the chamber, cathode in the current event.
883 /// -1 is returned on error.
885 Assert( 0 <= chamber && chamber <= 13 );
886 Assert( 0 <= cathode && cathode <= 1 );
888 if (fRunloader == NULL)
890 AliError("File not set.");
893 if (fEventnumber < 0)
895 AliError("Event not chosen.");
899 if ( ! FetchTreeD() ) return -1;
900 if ( fCathode != cathode )
906 return fData.Digits(chamber)->GetEntriesFast();
910 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
912 /// Fetch the specified digits on the chamber, cathode from the current event.
913 /// NULL is returned on error.
915 Assert( 0 <= chamber && chamber <= 13 );
916 Assert( 0 <= cathode && cathode <= 1 );
918 if (fRunloader == NULL)
920 AliError("File not set.");
923 if (fEventnumber < 0)
925 AliError("Event not chosen.");
929 if ( ! FetchTreeD() ) return NULL;
930 if ( fCathode != cathode )
936 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
940 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
942 /// Get the number of raw clusters on the given chamber in the current event.
943 /// -1 is returned on error.
945 Assert( 0 <= chamber && chamber <= 13 );
947 if (fRunloader == NULL)
949 AliError("File not set.");
952 if (fEventnumber < 0)
954 AliError("Event not chosen.");
958 if ( ! FetchTreeR() ) return -1;
959 if ( ! fClusterAddressSet )
961 fData.SetTreeAddress("RC");
962 fData.ResetRawClusters();
963 fData.GetRawClusters();
964 fClusterAddressSet = kTRUE;
966 return fData.RawClusters(chamber)->GetEntriesFast();
970 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
972 /// Fetch the specified raw cluster on the given chamber from the current event.
973 /// NULL is returned on error.
975 Assert( 0 <= chamber && chamber <= 13 );
977 if (fRunloader == NULL)
979 AliError("File not set.");
982 if (fEventnumber < 0)
984 AliError("Event not chosen.");
988 if ( ! FetchTreeR() ) return NULL;
989 if ( ! fClusterAddressSet )
991 fData.SetTreeAddress("RC");
992 fData.ResetRawClusters();
993 fData.GetRawClusters();
994 fClusterAddressSet = kTRUE;
996 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
1000 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
1002 /// Get the number of local trigger objects in the current event.
1003 /// -1 is returned on error.
1005 if (fRunloader == NULL)
1007 AliError("File not set.");
1010 if (fEventnumber < 0)
1012 AliError("Event not chosen.");
1016 if ( ! FetchTreeD() ) return -1;
1017 if ( ! fTriggerAddressSet )
1019 fData.SetTreeAddress("GLT");
1020 fData.ResetTrigger();
1021 fData.GetTriggerD();
1022 fTriggerAddressSet = kTRUE;
1024 return fData.LocalTrigger()->GetEntriesFast();
1028 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
1030 /// Fetch the specified local trigger object from the current event.
1031 /// NULL is returned on error.
1033 if (fRunloader == NULL)
1035 AliError("File not set.");
1038 if (fEventnumber < 0)
1040 AliError( "Event not chosen.");
1044 if ( ! FetchTreeD() ) return NULL;
1045 if ( ! fTriggerAddressSet )
1047 fData.SetTreeAddress("GLT");
1048 fData.ResetTrigger();
1049 fData.GetTriggerD();
1050 fTriggerAddressSet = kTRUE;
1052 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
1055 Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
1057 /// Get the number of local trigger objects in the current event.
1058 /// -1 is returned on error.
1060 if (fRunloader == NULL)
1062 AliError("File not set.");
1065 if (fEventnumber < 0)
1067 AliError("Event not chosen.");
1071 if ( ! FetchTreeD() ) return -1;
1072 if ( ! fTriggerAddressSet )
1074 fData.SetTreeAddress("GLT");
1075 fData.ResetTrigger();
1076 fData.GetTriggerD();
1077 fTriggerAddressSet = kTRUE;
1079 return fData.GlobalTrigger()->GetEntriesFast();
1082 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
1084 /// Fetch the specified local trigger object from the current event.
1085 /// NULL is returned on error.
1087 if (fRunloader == NULL)
1089 AliError("File not set.");
1092 if (fEventnumber < 0)
1094 AliError( "Event not chosen.");
1098 if ( ! FetchTreeD() ) return NULL;
1099 if ( ! fTriggerAddressSet )
1101 fData.SetTreeAddress("GLT");
1102 fData.ResetTrigger();
1103 fData.GetTriggerD();
1104 fTriggerAddressSet = kTRUE;
1106 return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
1109 Int_t AliMUONDataInterface::NumberOfRecTracks()
1111 /// Fetch the number of reconstructed tracks from the current event.
1112 /// NULL is returned on error.
1114 if (fRunloader == NULL)
1116 AliError("File not set.");
1119 if (fEventnumber < 0)
1121 AliError( "Event not chosen.");
1125 if ( ! FetchTreeT() ) return -1;
1126 if ( ! fRecTracksAddressSet )
1128 fData.SetTreeAddress("RT");
1129 fData.ResetRecTracks();
1130 fData.GetRecTracks();
1131 fRecTracksAddressSet = kTRUE;
1133 return fData.RecTracks()->GetEntriesFast();
1136 AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
1138 /// Fetch the specified reconstructed track object from the current event.
1139 /// NULL is returned on error.
1141 if (fRunloader == NULL)
1143 AliError("File not set.");
1146 if (fEventnumber < 0)
1148 AliError( "Event not chosen.");
1152 if ( ! FetchTreeT() ) return NULL;
1153 if ( ! fRecTracksAddressSet )
1155 fData.SetTreeAddress("RT");
1156 fData.ResetRecTracks();
1157 fData.GetRecTracks();
1158 fRecTracksAddressSet = kTRUE;
1160 return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
1161 // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));