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(const AliMUONDataInterface& rhs)
80 // Protected copy constructor
82 AliFatal("Not implemented.");
85 AliMUONDataInterface::~AliMUONDataInterface()
87 // Delete the runloader if we created it.
88 // If the runloader is not to be deleted then call Reset just before
89 // the destructor is called.
91 if (fRunloader != NULL && fCreatedRunLoader)
96 AliMUONDataInterface::operator=(const AliMUONDataInterface& rhs)
98 // Protected assignement operator
100 if (this == &rhs) return *this;
102 AliFatal("Not implemented.");
108 void AliMUONDataInterface::Reset()
110 // Sets all internal pointers to NULL and indices to -1.
111 // Note: No resources are released!
112 // Specificaly AliRunLoader is not deleted.
114 fCreatedRunLoader = kFALSE;
121 fHitAddressSet = kFALSE;
122 fSDigitAddressSet = kFALSE;
123 fDigitAddressSet = kFALSE;
124 fClusterAddressSet = kFALSE;
125 fTriggerAddressSet = kFALSE;
126 fRecTracksAddressSet = kFALSE;
130 Bool_t AliMUONDataInterface::UseCurrentRunLoader()
132 // Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
133 // currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
136 fRunloader = AliRunLoader::GetRunLoader();
137 if (fRunloader == NULL) return kFALSE;
138 // Fetch the current file name, folder name and event number.
139 fFilename = fRunloader->GetFileName();
140 fFoldername = fRunloader->GetEventFolder()->GetName();
141 fEventnumber = fRunloader->GetEventNumber();
143 if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
153 Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
155 // fetches the muon loader for the given filename/foldername
157 fMuonloader = fRunloader->GetLoader("MUONLoader");
158 if (fMuonloader == NULL)
160 AliError(Form("Could not find the MUON loader in file: %s and folder: %s",
161 (const char*)filename, (const char*)foldername));
165 // Need to connect the muon loader to the AliMUONData object,
166 // else class to fData will return NULL.
167 fData.SetLoader(fMuonloader);
172 Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
174 // Load the run and muon loaders from the specified file and folder.
175 // kTRUE is returned on success and kFALSE on failure.
177 fRunloader = AliRunLoader::Open(filename, foldername, "READ");
178 if (fRunloader == NULL)
180 AliError(Form("Could not find or load the run loader for the file: %s and folder: %s",
181 (const char*)filename, (const char*)foldername));
184 fCreatedRunLoader = kTRUE;
185 if ( ! FetchMuonLoader(filename, foldername) )
191 fFilename = filename;
192 fFoldername = foldername;
193 fEventnumber = -1; // Reset the event number to force the event to be loaded.
198 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
200 // Fetch the run loader and muon loader objects from memory if they already exist,
201 // or from memory if they do not.
202 // If the currently loaded run loader (if any) is not refering to the file and folder
203 // we are interested in then it is deleted and reopened with the required file and
206 if (fRunloader == NULL)
208 fRunloader = AliRunLoader::GetRunLoader();
209 if (fRunloader == NULL)
210 return LoadLoaders(filename, foldername);
213 if (fMuonloader == NULL)
215 if ( ! FetchMuonLoader(filename, foldername) )
223 // Fetch the current file and folder names.
224 fFilename = fRunloader->GetFileName();
225 fFoldername = fRunloader->GetEventFolder()->GetName();
228 // If filename or foldername are not the same as the ones currently selected then
230 if ( filename.CompareTo(fFilename) != 0 || foldername.CompareTo(fFoldername) != 0 )
233 return LoadLoaders(filename, foldername);
239 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
241 // Fetch the specified event from the runloader and reset all the track, cathode
242 // and address flags to force them to be reloaded.
243 // If a negative event number is specified then the current runloader event
246 if (fEventnumber < 0)
248 fEventnumber = fRunloader->GetEventNumber();
252 fHitAddressSet = kFALSE;
253 fSDigitAddressSet = kFALSE;
254 fDigitAddressSet = kFALSE;
255 fClusterAddressSet = kFALSE;
256 fTriggerAddressSet = kFALSE;
257 fRecTracksAddressSet = kFALSE;
259 if ( event != fEventnumber )
261 if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
262 fEventnumber = event;
266 fHitAddressSet = kFALSE;
267 fSDigitAddressSet = kFALSE;
268 fDigitAddressSet = kFALSE;
269 fClusterAddressSet = kFALSE;
270 fTriggerAddressSet = kFALSE;
271 fRecTracksAddressSet = kFALSE;
277 Bool_t AliMUONDataInterface::FetchTreeK()
279 // Fetch the Kine tree from the current run loader.
281 if (fRunloader->TreeK() == NULL)
283 fRunloader->LoadKinematics("READ");
284 if (fRunloader->TreeK() == NULL)
286 AliError("Could not load TreeK.");
294 Bool_t AliMUONDataInterface::FetchTreeH()
296 // Fetch the Hits tree from the current muon loader.
297 // Set all the required addresses etc...
299 if (fMuonloader->TreeH() == NULL)
301 fMuonloader->LoadHits("READ");
302 if (fMuonloader->TreeH() == NULL)
304 AliError("Could not load TreeH.");
307 fData.SetTreeAddress("H");
308 fHitAddressSet = kTRUE;
310 else if ( ! fHitAddressSet )
312 fData.SetTreeAddress("H");
313 fHitAddressSet = kTRUE;
319 Bool_t AliMUONDataInterface::FetchTreeS()
321 // Fetch the S-Digits tree from the current muon loader.
322 // Set all the required addresses etc...
324 if (fMuonloader->TreeS() == NULL)
326 fMuonloader->LoadSDigits("READ");
327 if (fMuonloader->TreeS() == NULL)
329 AliError("Could not load TreeS.");
332 fData.SetTreeAddress("S");
333 fSDigitAddressSet = kTRUE;
335 else if ( ! fSDigitAddressSet )
337 fData.SetTreeAddress("S");
338 fSDigitAddressSet = kTRUE;
344 Bool_t AliMUONDataInterface::FetchTreeD()
346 // Fetch the digits tree from the current muon loader.
347 // Set all the required addresses etc...
349 if (fMuonloader->TreeD() == NULL)
351 fMuonloader->LoadDigits("READ");
352 if (fMuonloader->TreeD() == NULL)
354 AliError("Could not load TreeD.");
357 fData.SetTreeAddress("D");
358 fDigitAddressSet = kTRUE;
360 else if ( ! fDigitAddressSet )
362 fData.SetTreeAddress("D");
363 fDigitAddressSet = kTRUE;
369 Bool_t AliMUONDataInterface::FetchTreeR()
371 // Fetch the reconstructed objects tree from the current muon loader.
372 // Note: The addresses must still be set.
374 if (fMuonloader->TreeR() == NULL)
376 fMuonloader->LoadRecPoints("READ");
377 if (fMuonloader->TreeR() == NULL)
379 AliError("Could not load TreeR.");
383 // Need to reset these flags so that the cluster and trigger address
384 // gets reset after this method.
385 fClusterAddressSet = kFALSE;
386 fTriggerAddressSet = kFALSE;
391 Bool_t AliMUONDataInterface::FetchTreeT()
393 // fetch the reconstructed tracks tree from the current muon loader
394 // note : the addresses must still be set.
395 if (fMuonloader->TreeT() == NULL)
397 fMuonloader->LoadTracks("READ");
398 if (fMuonloader->TreeT() == NULL)
400 AliError("Could not load TreeT.");
404 // Need to reset these flags so that the rec tracks address
405 // gets reset after this method.
406 fRecTracksAddressSet = kFALSE;
411 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
413 // Returns the number of events in the specified file/folder, and -1 on error.
415 if ( ! FetchLoaders(filename, foldername) ) return -1;
416 return fRunloader->GetNumberOfEvents();
420 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
422 // Returns the number of events in the specified file/folder, and -1 on error.
424 if ( ! FetchLoaders(filename, foldername) ) return -1;
425 if ( ! FetchEvent(event) ) return -1;
426 if ( ! FetchTreeK() ) return -1;
427 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
431 TParticle* AliMUONDataInterface::Particle(
432 TString filename, TString foldername, Int_t event, Int_t particle
435 // Returns the specified particle in the given file, folder and event.
436 // NULL is returned on error.
438 if ( ! FetchLoaders(filename, foldername) ) return NULL;
439 if ( ! FetchEvent(event) ) return NULL;
440 if ( ! FetchTreeK() ) return NULL;
442 TTree* treeK = fRunloader->TreeK();
444 treeK->GetBranch("Particles")->SetAddress(&p);
445 treeK->GetEvent(particle);
450 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
452 // Returns the number of tracks in the specified file/folder and event.
453 // -1 is returned on error.
455 if ( ! FetchLoaders(filename, foldername) ) return -1;
456 if ( ! FetchEvent(event) ) return -1;
457 if ( ! FetchTreeH() ) return -1;
458 return fData.GetNtracks();
462 Int_t AliMUONDataInterface::NumberOfHits(
463 TString filename, TString foldername, Int_t event, Int_t track
466 // Returns the number of hits in the specified file/folder, event and track.
467 // -1 is returned on error.
469 if ( ! FetchLoaders(filename, foldername) ) return -1;
470 if ( ! FetchEvent(event) ) return -1;
471 if ( ! FetchTreeH() ) return -1;
473 if (fTrack < 0 || fTrack != track)
476 fData.GetTrack(track);
479 return fData.Hits()->GetEntriesFast();
483 AliMUONHit* AliMUONDataInterface::Hit(
484 TString filename, TString foldername, Int_t event,
485 Int_t track, Int_t hit
488 // Returns the specified hit in the given file, folder, event and track.
489 // NULL is returned on error.
491 if ( ! FetchLoaders(filename, foldername) ) return NULL;
492 if ( ! FetchEvent(event) ) return NULL;
493 if ( ! FetchTreeH() ) return NULL;
495 if (fTrack < 0 || fTrack != track)
498 fData.GetTrack(track);
501 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
505 Int_t AliMUONDataInterface::NumberOfSDigits(
506 TString filename, TString foldername, Int_t event,
507 Int_t chamber, Int_t cathode
510 // Returns the number of s-digits in the given file, folder, event,
511 // chamber and cathode. -1 is returned on error.
513 Assert( 0 <= chamber && chamber <= 13 );
514 Assert( 0 <= cathode && cathode <= 1 );
516 if ( ! FetchLoaders(filename, foldername) ) return -1;
517 if ( ! FetchEvent(event) ) return -1;
518 if ( ! FetchTreeS() ) return -1;
520 if ( fSCathode != cathode )
522 fData.ResetSDigits();
526 return fData.SDigits(chamber)->GetEntriesFast();
530 AliMUONDigit* AliMUONDataInterface::SDigit(
531 TString filename, TString foldername, Int_t event,
532 Int_t chamber, Int_t cathode, Int_t sdigit
535 // Returns the specified s-digit in the given file, folder, event,
536 // chamber and cathode. NULL is returned on error.
538 Assert( 0 <= chamber && chamber <= 13 );
539 Assert( 0 <= cathode && cathode <= 1 );
541 if ( ! FetchLoaders(filename, foldername) ) return NULL;
542 if ( ! FetchEvent(event) ) return NULL;
543 if ( ! FetchTreeS() ) return NULL;
545 if ( fSCathode != cathode )
547 fData.ResetSDigits();
551 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
555 Int_t AliMUONDataInterface::NumberOfDigits(
556 TString filename, TString foldername, Int_t event,
557 Int_t chamber, Int_t cathode
560 // Returns the number of digits in the given file, folder, event,
561 // chamber and cathode. -1 is returned on error.
562 Assert( 0 <= chamber && chamber <= 13 );
563 Assert( 0 <= cathode && cathode <= 1 );
565 if ( ! FetchLoaders(filename, foldername) ) return -1;
566 if ( ! FetchEvent(event) ) return -1;
567 if ( ! FetchTreeD() ) return -1;
569 if ( fCathode != cathode )
575 return fData.Digits(chamber)->GetEntriesFast();
579 AliMUONDigit* AliMUONDataInterface::Digit(
580 TString filename, TString foldername, Int_t event,
581 Int_t chamber, Int_t cathode, Int_t digit
584 // Returns the specified digit in the given file, folder, event,
585 // chamber and cathode. NULL is returned on error.
587 Assert( 0 <= chamber && chamber <= 13 );
588 Assert( 0 <= cathode && cathode <= 1 );
590 if ( ! FetchLoaders(filename, foldername) ) return NULL;
591 if ( ! FetchEvent(event) ) return NULL;
592 if ( ! FetchTreeD() ) return NULL;
594 if ( fCathode != cathode )
600 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
604 Int_t AliMUONDataInterface::NumberOfRawClusters(
605 TString filename, TString foldername, Int_t event, Int_t chamber
608 // Returns the number of raw clusters in the specified file, folder, event and chamber.
609 // -1 is returned or error.
611 Assert( 0 <= chamber && chamber <= 13 );
612 if ( ! FetchLoaders(filename, foldername) ) return -1;
613 if ( ! FetchEvent(event) ) return -1;
614 if ( ! FetchTreeR() ) return -1;
615 if ( ! fClusterAddressSet )
617 // If the raw cluster address in TreeR is not set yet then set it now.
618 fData.SetTreeAddress("RC");
619 fData.ResetRawClusters();
620 fData.GetRawClusters();
621 fClusterAddressSet = kTRUE;
623 return fData.RawClusters(chamber)->GetEntriesFast();
627 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
628 TString filename, TString foldername, Int_t event,
629 Int_t chamber, Int_t cluster
632 // Fetch the specified raw cluster from the given file, folder, event and chamber number.
633 // NULL is returned on error.
635 Assert( 0 <= chamber && chamber <= 13 );
636 if ( ! FetchLoaders(filename, foldername) ) return NULL;
637 if ( ! FetchEvent(event) ) return NULL;
638 if ( ! FetchTreeR() ) return NULL;
639 if ( ! fClusterAddressSet )
641 // If the raw cluster address in TreeR is not set yet then set it now.
642 fData.SetTreeAddress("RC");
643 fData.ResetRawClusters();
644 fData.GetRawClusters();
645 fClusterAddressSet = kTRUE;
647 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
651 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
653 // Return the number of local trigger objects in the specified file, folder and
654 // event number. -1 is returned on error.
656 if ( ! FetchLoaders(filename, foldername) ) return -1;
657 if ( ! FetchEvent(event) ) return -1;
658 if ( ! FetchTreeD() ) return -1;
659 if ( ! fTriggerAddressSet )
661 // If the local trigger address in TreeR is not set yet then set it now.
662 fData.SetTreeAddress("GLT");
663 fData.ResetTrigger();
665 fTriggerAddressSet = kTRUE;
667 return fData.LocalTrigger()->GetEntriesFast();
671 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
672 TString filename, TString foldername, Int_t event, Int_t trigger
675 // Fetch the specified local trigger object from the given file, folder and event number.
676 // NULL is returned on error.
678 if ( ! FetchLoaders(filename, foldername) ) return NULL;
679 if ( ! FetchEvent(event) ) return NULL;
680 if ( ! FetchTreeD() ) return NULL;
681 if ( ! fTriggerAddressSet )
683 // If the local trigger address in TreeR is not set yet then set it now.
684 fData.SetTreeAddress("GLT");
685 fData.ResetTrigger();
687 fTriggerAddressSet = kTRUE;
689 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
692 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
694 // Set the current file and folder from which to fetch data.
695 // kTRUE is returned if the run and muon loaders were found, else kFALSE.
697 return FetchLoaders(filename, foldername);
701 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
703 // Select the current event from which to fetch data.
704 // kTRUE is returned if the event was found, else kFALSE is returned.
706 if (fRunloader == NULL)
708 AliError("File not set.");
712 return FetchEvent(event);
716 Int_t AliMUONDataInterface::NumberOfEvents()
718 // Get the number of events in the currently selected file.
719 // -1 is returned on error.
721 if (fRunloader == NULL)
723 AliError("File not set.");
726 return fRunloader->GetNumberOfEvents();
730 Int_t AliMUONDataInterface::NumberOfParticles()
732 // Get the number of particles in the current event.
733 // -1 is returned on error.
735 if (fRunloader == NULL)
737 AliError("File not set.");
740 if ( ! FetchTreeK() ) return -1;
741 return (Int_t) fRunloader->TreeK()->GetEntriesFast();
745 TParticle* AliMUONDataInterface::Particle(Int_t particle)
747 // Fetch the specified particle from the current event.
748 // NULL is returned on error.
750 if (fRunloader == NULL)
752 AliError("File not set.");
755 if (fEventnumber < 0)
757 AliError("Event not chosen.");
760 if ( ! FetchTreeK() ) return NULL;
761 TTree* treeK = fRunloader->TreeK();
763 treeK->GetBranch("Particles")->SetAddress(&p);
764 treeK->GetEvent(particle);
769 Int_t AliMUONDataInterface::NumberOfTracks()
771 // Get the number of tracks in the current event.
772 // -1 is returned on error.
774 if (fRunloader == NULL)
776 AliError("File not set.");
779 if (fEventnumber < 0)
781 AliError( "Event not chosen.");
784 if ( ! FetchTreeH() ) return -1;
785 return fData.GetNtracks();
789 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
791 // Get the number of hits for the given track in the current event.
792 // -1 is returned on error.
794 if (fRunloader == NULL)
796 AliError("File not set.");
799 if (fEventnumber < 0)
801 AliError("Event not chosen.");
804 if ( ! FetchTreeH() ) return -1;
805 if (fTrack < 0 || fTrack != track)
808 fData.GetTrack(track);
811 return fData.Hits()->GetEntriesFast();
815 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
817 // Fetch the specified hit from the current event.
818 // NULL is returned on error.
820 if (fRunloader == NULL)
822 AliError("File not set.");
825 if (fEventnumber < 0)
827 AliError("Event not chosen.");
830 if ( ! FetchTreeH() ) return NULL;
831 if (fTrack < 0 || fTrack != track)
834 fData.GetTrack(track);
837 return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
841 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
843 // Get the number of s-digits on the chamber, cathode in the current event.
844 // -1 is returned on error.
846 Assert( 0 <= chamber && chamber <= 13 );
847 Assert( 0 <= cathode && cathode <= 1 );
849 if (fRunloader == NULL)
851 AliError("File not set.");
854 if (fEventnumber < 0)
856 AliError("Event not chosen.");
860 if ( ! FetchTreeS() ) return -1;
861 if ( fSCathode != cathode )
863 fData.ResetSDigits();
867 return fData.SDigits(chamber)->GetEntriesFast();
871 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
873 // Fetch the specified s-digits on the chamber, cathode from the current event.
874 // NULL is returned on error.
876 Assert( 0 <= chamber && chamber <= 13 );
877 Assert( 0 <= cathode && cathode <= 1 );
879 if (fRunloader == NULL)
881 AliError("File not set.");
884 if (fEventnumber < 0)
886 AliError("Event not chosen.");
890 if ( ! FetchTreeS() ) return NULL;
891 if ( fSCathode != cathode )
893 fData.ResetSDigits();
897 return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
901 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
903 // Get the number of digits on the chamber, cathode in the current event.
904 // -1 is returned on error.
906 Assert( 0 <= chamber && chamber <= 13 );
907 Assert( 0 <= cathode && cathode <= 1 );
909 if (fRunloader == NULL)
911 AliError("File not set.");
914 if (fEventnumber < 0)
916 AliError("Event not chosen.");
920 if ( ! FetchTreeD() ) return -1;
921 if ( fCathode != cathode )
927 return fData.Digits(chamber)->GetEntriesFast();
931 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
933 // Fetch the specified digits on the chamber, cathode from the current event.
934 // NULL is returned on error.
936 Assert( 0 <= chamber && chamber <= 13 );
937 Assert( 0 <= cathode && cathode <= 1 );
939 if (fRunloader == NULL)
941 AliError("File not set.");
944 if (fEventnumber < 0)
946 AliError("Event not chosen.");
950 if ( ! FetchTreeD() ) return NULL;
951 if ( fCathode != cathode )
957 return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
961 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
963 // Get the number of raw clusters on the given chamber in the current event.
964 // -1 is returned on error.
966 Assert( 0 <= chamber && chamber <= 13 );
968 if (fRunloader == NULL)
970 AliError("File not set.");
973 if (fEventnumber < 0)
975 AliError("Event not chosen.");
979 if ( ! FetchTreeR() ) return -1;
980 if ( ! fClusterAddressSet )
982 fData.SetTreeAddress("RC");
983 fData.ResetRawClusters();
984 fData.GetRawClusters();
985 fClusterAddressSet = kTRUE;
987 return fData.RawClusters(chamber)->GetEntriesFast();
991 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
993 // Fetch the specified raw cluster on the given chamber from the current event.
994 // NULL is returned on error.
996 Assert( 0 <= chamber && chamber <= 13 );
998 if (fRunloader == NULL)
1000 AliError("File not set.");
1003 if (fEventnumber < 0)
1005 AliError("Event not chosen.");
1009 if ( ! FetchTreeR() ) return NULL;
1010 if ( ! fClusterAddressSet )
1012 fData.SetTreeAddress("RC");
1013 fData.ResetRawClusters();
1014 fData.GetRawClusters();
1015 fClusterAddressSet = kTRUE;
1017 return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
1021 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
1023 // Get the number of local trigger objects in the current event.
1024 // -1 is returned on error.
1026 if (fRunloader == NULL)
1028 AliError("File not set.");
1031 if (fEventnumber < 0)
1033 AliError("Event not chosen.");
1037 if ( ! FetchTreeD() ) return -1;
1038 if ( ! fTriggerAddressSet )
1040 fData.SetTreeAddress("GLT");
1041 fData.ResetTrigger();
1042 fData.GetTriggerD();
1043 fTriggerAddressSet = kTRUE;
1045 return fData.LocalTrigger()->GetEntriesFast();
1049 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
1051 // Fetch the specified local trigger object from the current event.
1052 // NULL is returned on error.
1054 if (fRunloader == NULL)
1056 AliError("File not set.");
1059 if (fEventnumber < 0)
1061 AliError( "Event not chosen.");
1065 if ( ! FetchTreeD() ) return NULL;
1066 if ( ! fTriggerAddressSet )
1068 fData.SetTreeAddress("GLT");
1069 fData.ResetTrigger();
1070 fData.GetTriggerD();
1071 fTriggerAddressSet = kTRUE;
1073 return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
1076 Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
1079 // Get the number of local trigger objects in the current event.
1080 // -1 is returned on error.
1082 if (fRunloader == NULL)
1084 AliError("File not set.");
1087 if (fEventnumber < 0)
1089 AliError("Event not chosen.");
1093 if ( ! FetchTreeD() ) return -1;
1094 if ( ! fTriggerAddressSet )
1096 fData.SetTreeAddress("GLT");
1097 fData.ResetTrigger();
1098 fData.GetTriggerD();
1099 fTriggerAddressSet = kTRUE;
1101 return fData.GlobalTrigger()->GetEntriesFast();
1104 AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
1106 // Fetch the specified local trigger object from the current event.
1107 // NULL is returned on error.
1109 if (fRunloader == NULL)
1111 AliError("File not set.");
1114 if (fEventnumber < 0)
1116 AliError( "Event not chosen.");
1120 if ( ! FetchTreeD() ) return NULL;
1121 if ( ! fTriggerAddressSet )
1123 fData.SetTreeAddress("GLT");
1124 fData.ResetTrigger();
1125 fData.GetTriggerD();
1126 fTriggerAddressSet = kTRUE;
1128 return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
1131 Int_t AliMUONDataInterface::NumberOfRecTracks()
1133 // Fetch the number of reconstructed tracks from the current event.
1134 // NULL is returned on error.
1136 if (fRunloader == NULL)
1138 AliError("File not set.");
1141 if (fEventnumber < 0)
1143 AliError( "Event not chosen.");
1147 if ( ! FetchTreeT() ) return -1;
1148 if ( ! fRecTracksAddressSet )
1150 fData.SetTreeAddress("RT");
1151 fData.ResetRecTracks();
1152 fData.GetRecTracks();
1153 fRecTracksAddressSet = kTRUE;
1155 return fData.RecTracks()->GetEntriesFast();
1158 AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
1160 // Fetch the specified reconstructed track object from the current event.
1161 // NULL is returned on error.
1163 if (fRunloader == NULL)
1165 AliError("File not set.");
1168 if (fEventnumber < 0)
1170 AliError( "Event not chosen.");
1174 if ( ! FetchTreeT() ) return NULL;
1175 if ( ! fRecTracksAddressSet )
1177 fData.SetTreeAddress("RT");
1178 fData.ResetRecTracks();
1179 fData.GetRecTracks();
1180 fRecTracksAddressSet = kTRUE;
1182 return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
1183 // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));