]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDataInterface.cxx
- Added handling of tracks and file mask (used when merging different files).
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
index 1224affc9b4f60b740cf2f4d63c59ea3e4117148..de5e177c1983775bc7f386181ae53cca6664abc9 100644 (file)
@@ -3,12 +3,23 @@
 //  email: artur@alice.phy.uct.ac.za
 
 #include <TError.h>
+#include <TParticle.h>
 
 #include "AliRunLoader.h"
 #include "AliLoader.h"
 
 #include "AliMUONDataInterface.h"
-#include "AliMUONData.h"
+#include "AliMUONLocalTrigger.h"
+#include "AliMUONGlobalTrigger.h"
+#include "AliMUONHit.h"
+#include "AliMUONDigit.h"
+#include "AliMUONRawCluster.h"
+#include "AliMUONTrack.h"
+#include "AliLog.h"
+
+#include <iostream>
+using std::endl;
+using std::cout;
 
 
 ClassImp(AliMUONDataInterface)
@@ -20,19 +31,38 @@ AliMUONDataInterface::AliMUONDataInterface()
 // Set all internal pointers to NULL and indices to -1.
 
        Reset();
-};
+}
+
+AliMUONDataInterface::AliMUONDataInterface(const AliMUONDataInterface& rhs)
+  : TObject(rhs)
+{
+// Protected copy constructor
 
+  AliFatal("Not implemented.");
+}
 
 AliMUONDataInterface::~AliMUONDataInterface()
 {
-// Delete the runloader when done.
+// Delete the runloader if we created it.
 // If the runloader is not to be deleted then call Reset just before 
 // the destructor is called.
 
-       if (fRunloader != NULL)
+       if (fRunloader != NULL && fCreatedRunLoader)
                delete fRunloader;
-};
+}
+
+AliMUONDataInterface&  
+AliMUONDataInterface::operator=(const AliMUONDataInterface& rhs)
+{
+// Protected assignement operator
+
+  if (this == &rhs) return *this;
 
+  AliFatal("Not implemented.");
+    
+  return *this;  
+}    
+          
 
 void AliMUONDataInterface::Reset()
 {
@@ -40,6 +70,7 @@ void AliMUONDataInterface::Reset()
 // Note: No resources are released!
 // Specificaly AliRunLoader is not deleted.
 
+       fCreatedRunLoader = kFALSE;
        fRunloader = NULL;
        fMuonloader = NULL;
        fEventnumber = -1;
@@ -51,39 +82,74 @@ void AliMUONDataInterface::Reset()
        fDigitAddressSet = kFALSE;
        fClusterAddressSet = kFALSE;
        fTriggerAddressSet = kFALSE;
-};
+       fRecTracksAddressSet = kFALSE;
+}
 
 
-Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
+Bool_t AliMUONDataInterface::UseCurrentRunLoader()
 {
-// Load the run and muon loaders from the specified file and folder.
-// kTRUE is returned on success and kFALSE on failure.
+// Tries to fetch the current runloader with AliRunLoader::GetRunLoader. If nothing is
+// currently loaded then kFALSE is returned and AliMUONDataInterface is reset.
 
-       fRunloader = AliRunLoader::Open(filename, foldername, "READ");
-       if (fRunloader == NULL)
+       Reset();
+       fRunloader = AliRunLoader::GetRunLoader();
+       if (fRunloader == NULL) return kFALSE;
+       // Fetch the current file name, folder name and event number.
+       fFilename = fRunloader->GetFileName();
+       fFoldername = fRunloader->GetEventFolder()->GetName();
+       fEventnumber = fRunloader->GetEventNumber();
+
+       if ( ! FetchMuonLoader(fFilename.Data(), fFoldername.Data()) )
        {
-               Error("LoadLoaders", "Could not find or load the run loader for the file: %s and folder: %s", 
-                       (const char*)filename, (const char*)foldername);
+               Reset();
                return kFALSE;
-       };
+       }               
+
+       return kTRUE;
+}
+
+
+Bool_t AliMUONDataInterface::FetchMuonLoader(TString filename, TString foldername)
+{
        fMuonloader = fRunloader->GetLoader("MUONLoader");
        if (fMuonloader == NULL)
        {
-               Error("LoadLoaders", "Could not find the MUON loader in file: %s and folder: %s", 
-                       (const char*)filename, (const char*)foldername);
-               fRunloader = NULL;
+               AliError(Form("Could not find the MUON loader in file: %s and folder: %s", 
+                       (const char*)filename, (const char*)foldername));
                return kFALSE;
-       };
+       }
        
        // Need to connect the muon loader to the AliMUONData object,
        // else class to fData will return NULL.
        fData.SetLoader(fMuonloader);
+       return kTRUE;
+}
+
+
+Bool_t AliMUONDataInterface::LoadLoaders(TString filename, TString foldername)
+{
+// Load the run and muon loaders from the specified file and folder.
+// kTRUE is returned on success and kFALSE on failure.
+
+       fRunloader = AliRunLoader::Open(filename, foldername, "READ");
+       if (fRunloader == NULL)
+       {
+               AliError(Form("Could not find or load the run loader for the file: %s and folder: %s", 
+                       (const char*)filename, (const char*)foldername));
+               return kFALSE;
+       }
+       fCreatedRunLoader = kTRUE;
+       if ( ! FetchMuonLoader(filename, foldername) )
+       {
+               fRunloader = NULL;
+               return kFALSE;
+       }
        
        fFilename = filename;
        fFoldername = foldername;
        fEventnumber = -1;  // Reset the event number to force the event to be loaded.
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
@@ -99,11 +165,22 @@ Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
                fRunloader = AliRunLoader::GetRunLoader();
                if (fRunloader == NULL)
                        return LoadLoaders(filename, foldername);
+               else
+               {
+                       if (fMuonloader == NULL)
+                       {
+                               if ( ! FetchMuonLoader(filename, foldername) )
+                               {
+                                       fRunloader = NULL;
+                                       return kFALSE;
+                               }
+                       }
+               }
                
                // Fetch the current file and folder names.
                fFilename = fRunloader->GetFileName();
                fFoldername = fRunloader->GetEventFolder()->GetName();
-       };
+       }
 
        // If filename or foldername are not the same as the ones currently selected then
        // reopen the file.
@@ -111,15 +188,17 @@ Bool_t AliMUONDataInterface::FetchLoaders(TString filename, TString foldername)
        {
                delete fRunloader;
                return LoadLoaders(filename, foldername);
-       };
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
 {
 // Fetch the specified event from the runloader and reset all the track, cathode
 // and address flags to force them to be reloaded.
+// If a negative event number is specified then the current runloader event
+// number is used.
 
        if (fEventnumber < 0)
        {
@@ -132,7 +211,8 @@ Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
                fDigitAddressSet = kFALSE;
                fClusterAddressSet = kFALSE;
                fTriggerAddressSet = kFALSE;
-       };
+               fRecTracksAddressSet = kFALSE;
+       }
        if ( event != fEventnumber )
        {
                if ( fRunloader->GetEvent(event) < 0 ) return kFALSE;
@@ -145,9 +225,10 @@ Bool_t AliMUONDataInterface::FetchEvent(Int_t event)
                fDigitAddressSet = kFALSE;
                fClusterAddressSet = kFALSE;
                fTriggerAddressSet = kFALSE;
-       };
+               fRecTracksAddressSet = kFALSE;
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchTreeK()
@@ -159,12 +240,12 @@ Bool_t AliMUONDataInterface::FetchTreeK()
                fRunloader->LoadKinematics("READ");
                if (fRunloader->TreeK() == NULL)
                {
-                       Error("FetchTreeK", "Could not load TreeK.");
+                       AliError("Could not load TreeK.");
                        return kFALSE;
-               };
-       };
+               }
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchTreeH()
@@ -177,9 +258,9 @@ Bool_t AliMUONDataInterface::FetchTreeH()
                fMuonloader->LoadHits("READ");
                if (fMuonloader->TreeH() == NULL)
                {
-                       Error("FetchTreeH", "Could not load TreeH.");
+                       AliError("Could not load TreeH.");
                        return kFALSE;
-               };
+               }
                fData.SetTreeAddress("H");
                fHitAddressSet = kTRUE;
        }
@@ -187,9 +268,9 @@ Bool_t AliMUONDataInterface::FetchTreeH()
        {
                fData.SetTreeAddress("H");
                fHitAddressSet = kTRUE;
-       };
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchTreeS()
@@ -202,9 +283,9 @@ Bool_t AliMUONDataInterface::FetchTreeS()
                fMuonloader->LoadSDigits("READ");
                if (fMuonloader->TreeS() == NULL)
                {
-                       Error("FetchTreeS", "Could not load TreeS.");
+                       AliError("Could not load TreeS.");
                        return kFALSE;
-               };
+               }
                fData.SetTreeAddress("S");
                fSDigitAddressSet = kTRUE;
        }
@@ -212,9 +293,9 @@ Bool_t AliMUONDataInterface::FetchTreeS()
        {
                fData.SetTreeAddress("S");
                fSDigitAddressSet = kTRUE;
-       };
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchTreeD()
@@ -227,9 +308,9 @@ Bool_t AliMUONDataInterface::FetchTreeD()
                fMuonloader->LoadDigits("READ");
                if (fMuonloader->TreeD() == NULL)
                {
-                       Error("FetchTreeD", "Could not load TreeD.");
+                       AliError("Could not load TreeD.");
                        return kFALSE;
-               };
+               }
                fData.SetTreeAddress("D");
                fDigitAddressSet = kTRUE;
        }
@@ -237,41 +318,60 @@ Bool_t AliMUONDataInterface::FetchTreeD()
        {
                fData.SetTreeAddress("D");
                fDigitAddressSet = kTRUE;
-       };
+       }
        return kTRUE;
-};
+}
 
 
 Bool_t AliMUONDataInterface::FetchTreeR()
 {
-// Fetch the reconstructed objects tree from the current muon loader.
-// Nore: The addresses must still be set. 
-
-       if (fMuonloader->TreeR() == NULL)
+  // Fetch the reconstructed objects tree from the current muon loader.
+  // Note: The addresses must still be set. 
+  
+  if (fMuonloader->TreeR() == NULL)
+    {
+      fMuonloader->LoadRecPoints("READ");
+      if (fMuonloader->TreeR() == NULL)
        {
-               fMuonloader->LoadRecPoints("READ");
-               if (fMuonloader->TreeR() == NULL)
-               {
-                       Error("FetchTreeR", "Could not load TreeR.");
-                       return kFALSE;
-               };
-               
-               // Need to reset these flags so that the cluster and trigger address
-               // gets reset after this method. 
-               fClusterAddressSet = kFALSE;
-               fTriggerAddressSet = kFALSE;
-       };
-       return kTRUE;
-};
-
-
+         AliError("Could not load TreeR.");
+         return kFALSE;
+       }
+      
+      // Need to reset these flags so that the cluster and trigger address
+      // gets reset after this method. 
+      fClusterAddressSet = kFALSE;
+      fTriggerAddressSet = kFALSE;
+    }
+  return kTRUE;
+}
+
+Bool_t AliMUONDataInterface::FetchTreeT()
+{
+  // fetch the reconstructed tracks tree from the current muon loader
+  // note : the addresses must still be set.
+  if (fMuonloader->TreeT() == NULL)
+    {
+      fMuonloader->LoadTracks("READ");
+      if (fMuonloader->TreeT() == NULL)
+       {
+         AliError("Could not load TreeT.");
+         return kFALSE;
+       }
+      
+      // Need to reset these flags so that the rec tracks address
+      // gets reset after this method. 
+      fRecTracksAddressSet = kFALSE;
+    }
+  return kTRUE;
+}
+  
 Int_t AliMUONDataInterface::NumberOfEvents(TString filename, TString foldername)
 {
 // Returns the number of events in the specified file/folder, and -1 on error.
 
        if ( ! FetchLoaders(filename, foldername) ) return -1;
        return fRunloader->GetNumberOfEvents();
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString foldername, Int_t event)
@@ -282,7 +382,7 @@ Int_t AliMUONDataInterface::NumberOfParticles(TString filename, TString folderna
        if ( ! FetchEvent(event) ) return -1;
        if ( ! FetchTreeK() ) return -1;
        return (Int_t) fRunloader->TreeK()->GetEntriesFast();
-};
+}
 
 
 TParticle* AliMUONDataInterface::Particle(
@@ -301,7 +401,7 @@ TParticle* AliMUONDataInterface::Particle(
        treeK->GetBranch("Particles")->SetAddress(&p);
        treeK->GetEvent(particle);
        return p;
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername, Int_t event)
@@ -313,7 +413,7 @@ Int_t AliMUONDataInterface::NumberOfTracks(TString filename, TString foldername,
        if ( ! FetchEvent(event) ) return -1;
        if ( ! FetchTreeH() ) return -1;
        return fData.GetNtracks();
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfHits(
@@ -332,9 +432,9 @@ Int_t AliMUONDataInterface::NumberOfHits(
                fData.ResetHits();
                fData.GetTrack(track);
                fTrack = track;
-       };
+       }
        return fData.Hits()->GetEntriesFast();
-};
+}
 
 
 AliMUONHit* AliMUONDataInterface::Hit(
@@ -354,9 +454,9 @@ AliMUONHit* AliMUONDataInterface::Hit(
                fData.ResetHits();
                fData.GetTrack(track);
                fTrack = track;
-       };
+       }
        return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfSDigits(
@@ -377,11 +477,11 @@ Int_t AliMUONDataInterface::NumberOfSDigits(
        if ( fSCathode != cathode )
        {
                fData.ResetSDigits();
-               fData.GetCathodeS(cathode);
+               fData.GetSDigits();
                fSCathode = cathode;
-       };
+       }
        return fData.SDigits(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONDigit* AliMUONDataInterface::SDigit(
@@ -402,11 +502,11 @@ AliMUONDigit* AliMUONDataInterface::SDigit(
        if ( fSCathode != cathode )
        {
                fData.ResetSDigits();
-               fData.GetCathodeS(cathode);
+               fData.GetSDigits();
                fSCathode = cathode;
-       };
+       }
        return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfDigits(
@@ -426,11 +526,11 @@ Int_t AliMUONDataInterface::NumberOfDigits(
        if ( fCathode != cathode )
        {
                fData.ResetDigits();
-               fData.GetCathode(cathode);
+               fData.GetDigits();
                fCathode = cathode;
-       };
+       }
        return fData.Digits(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONDigit* AliMUONDataInterface::Digit(
@@ -451,11 +551,11 @@ AliMUONDigit* AliMUONDataInterface::Digit(
        if ( fCathode != cathode )
        {
                fData.ResetDigits();
-               fData.GetCathode(cathode);
+               fData.GetDigits();
                fCathode = cathode;
-       };
+       }
        return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfRawClusters(
@@ -476,9 +576,9 @@ Int_t AliMUONDataInterface::NumberOfRawClusters(
                fData.ResetRawClusters();
                fData.GetRawClusters();
                fClusterAddressSet = kTRUE;
-       };
+       }
        return fData.RawClusters(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONRawCluster* AliMUONDataInterface::RawCluster(
@@ -500,9 +600,9 @@ AliMUONRawCluster* AliMUONDataInterface::RawCluster(
                fData.ResetRawClusters();
                fData.GetRawClusters();
                fClusterAddressSet = kTRUE;
-       };
+       }
        return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString foldername, Int_t event)
@@ -512,17 +612,17 @@ Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString filename, TString fold
 
        if ( ! FetchLoaders(filename, foldername) ) return -1;
        if ( ! FetchEvent(event) ) return -1;
-       if ( ! FetchTreeR() ) return -1;
+       if ( ! FetchTreeD() ) return -1;
        if ( ! fTriggerAddressSet )
        {
                // If the local trigger address in TreeR is not set yet then set it now.
                fData.SetTreeAddress("GLT");
                fData.ResetTrigger();
-               fData.GetTrigger();
+               fData.GetTriggerD();
                fTriggerAddressSet = kTRUE;
-       };
+       }
        return fData.LocalTrigger()->GetEntriesFast();
-};
+}
 
 
 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
@@ -534,18 +634,17 @@ AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
 
        if ( ! FetchLoaders(filename, foldername) ) return NULL;
        if ( ! FetchEvent(event) ) return NULL;
-       if ( ! FetchTreeR() ) return NULL;
+       if ( ! FetchTreeD() ) return NULL;
        if ( ! fTriggerAddressSet )
        {
                // If the local trigger address in TreeR is not set yet then set it now.
                fData.SetTreeAddress("GLT");
                fData.ResetTrigger();
-               fData.GetTrigger();
+               fData.GetTriggerD();
                fTriggerAddressSet = kTRUE;
-       };
+       }
        return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
-};
-
+}
 
 Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
 {
@@ -553,7 +652,7 @@ Bool_t AliMUONDataInterface::SetFile(TString filename, TString foldername)
 // kTRUE is returned if the run and muon loaders were found, else kFALSE. 
 
        return FetchLoaders(filename, foldername);
-};
+}
 
 
 Bool_t AliMUONDataInterface::GetEvent(Int_t event)
@@ -561,8 +660,14 @@ Bool_t AliMUONDataInterface::GetEvent(Int_t event)
 // Select the current event from which to fetch data.
 // kTRUE is returned if the event was found, else kFALSE is returned.
 
-       return FetchEvent(event);
-};
+       if (fRunloader == NULL)
+       {
+               AliError("File not set.");
+               return kFALSE;
+       }
+       else
+               return FetchEvent(event);
+}
 
 
 Int_t AliMUONDataInterface::NumberOfEvents()
@@ -572,11 +677,11 @@ Int_t AliMUONDataInterface::NumberOfEvents()
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfEvents", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        return fRunloader->GetNumberOfEvents();
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfParticles()
@@ -586,12 +691,12 @@ Int_t AliMUONDataInterface::NumberOfParticles()
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfParticles", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if ( ! FetchTreeK() ) return -1;
        return (Int_t) fRunloader->TreeK()->GetEntriesFast();
-};
+}
 
 
 TParticle* AliMUONDataInterface::Particle(Int_t particle)
@@ -601,21 +706,21 @@ TParticle* AliMUONDataInterface::Particle(Int_t particle)
 
        if (fRunloader == NULL)
        {
-               Error("Particle", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("Particle", "Event not chosen.");
+               AliError("Event not chosen.");
                return NULL;
-       };
+       }
        if ( ! FetchTreeK() ) return NULL;
        TTree* treeK = fRunloader->TreeK();
        TParticle* p = NULL;
        treeK->GetBranch("Particles")->SetAddress(&p);
        treeK->GetEvent(particle);
        return p;
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfTracks()
@@ -625,17 +730,17 @@ Int_t AliMUONDataInterface::NumberOfTracks()
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfTracks", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfTracks", "Event not chosen.");
+               AliError( "Event not chosen.");
                return -1;
-       };
+       }
        if ( ! FetchTreeH() ) return -1;
        return fData.GetNtracks();
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
@@ -645,23 +750,23 @@ Int_t AliMUONDataInterface::NumberOfHits(Int_t track)
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfHits", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfHits", "Event not chosen.");
+               AliError("Event not chosen.");
                return -1;
-       };
+       }
        if ( ! FetchTreeH() ) return -1;
        if (fTrack < 0 || fTrack != track)
        {
                fData.ResetHits();
                fData.GetTrack(track);
                fTrack = track;
-       };
+       }
        return fData.Hits()->GetEntriesFast();
-};
+}
 
 
 AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
@@ -671,23 +776,23 @@ AliMUONHit* AliMUONDataInterface::Hit(Int_t track, Int_t hit)
 
        if (fRunloader == NULL)
        {
-               Error("Hit", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("Hit", "Event not chosen.");
+               AliError("Event not chosen.");
                return NULL;
-       };
+       }
        if ( ! FetchTreeH() ) return NULL;
        if (fTrack < 0 || fTrack != track)
        {
                fData.ResetHits();
                fData.GetTrack(track);
                fTrack = track;
-       };
+       }
        return static_cast<AliMUONHit*>( fData.Hits()->At(hit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
@@ -700,24 +805,24 @@ Int_t AliMUONDataInterface::NumberOfSDigits(Int_t chamber, Int_t cathode)
        
        if (fRunloader == NULL)
        {
-               Error("NumberOfSDigits", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfSDigits", "Event not chosen.");
+               AliError("Event not chosen.");
                return -1;
-       };
+       }
 
        if ( ! FetchTreeS() ) return -1;
        if ( fSCathode != cathode )
        {
                fData.ResetSDigits();
-               fData.GetCathodeS(cathode);
+               fData.GetSDigits();
                fSCathode = cathode;
-       };
+       }
        return fData.SDigits(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t sdigit)
@@ -730,24 +835,24 @@ AliMUONDigit* AliMUONDataInterface::SDigit(Int_t chamber, Int_t cathode, Int_t s
        
        if (fRunloader == NULL)
        {
-               Error("SDigit", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("SDigit", "Event not chosen.");
+               AliError("Event not chosen.");
                return NULL;
-       };
+       }
 
        if ( ! FetchTreeS() ) return NULL;
        if ( fSCathode != cathode )
        {
                fData.ResetSDigits();
-               fData.GetCathodeS(cathode);
+               fData.GetSDigits();
                fSCathode = cathode;
-       };
+       }
        return static_cast<AliMUONDigit*>( fData.SDigits(chamber)->At(sdigit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
@@ -760,24 +865,24 @@ Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
        
        if (fRunloader == NULL)
        {
-               Error("NumberOfDigits", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfDigits", "Event not chosen.");
+               AliError("Event not chosen.");
                return -1;
-       };
+       }
        
        if ( ! FetchTreeD() ) return -1;
        if ( fCathode != cathode )
        {
                fData.ResetDigits();
-               fData.GetCathode(cathode);
+               fData.GetDigits();
                fCathode = cathode;
-       };
+       }
        return fData.Digits(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t digit)
@@ -790,24 +895,24 @@ AliMUONDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t di
        
        if (fRunloader == NULL)
        {
-               Error("Digit", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("Digit", "Event not chosen.");
+               AliError("Event not chosen.");
                return NULL;
-       };
+       }
 
        if ( ! FetchTreeD() ) return NULL;
        if ( fCathode != cathode )
        {
                fData.ResetDigits();
-               fData.GetCathode(cathode);
+               fData.GetDigits();
                fCathode = cathode;
-       };
+       }
        return static_cast<AliMUONDigit*>( fData.Digits(chamber)->At(digit) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
@@ -819,14 +924,14 @@ Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfRawClusters", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfRawClusters", "Event not chosen.");
+               AliError("Event not chosen.");
                return -1;
-       };
+       }
 
        if ( ! FetchTreeR() ) return -1;
        if ( ! fClusterAddressSet )
@@ -835,9 +940,9 @@ Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
                fData.ResetRawClusters();
                fData.GetRawClusters();
                fClusterAddressSet = kTRUE;
-       };
+       }
        return fData.RawClusters(chamber)->GetEntriesFast();
-};
+}
 
 
 AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster)
@@ -849,14 +954,14 @@ AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster
 
        if (fRunloader == NULL)
        {
-               Error("RawCluster", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("RawCluster", "Event not chosen.");
+               AliError("Event not chosen.");
                return NULL;
-       };
+       }
 
        if ( ! FetchTreeR() ) return NULL;
        if ( ! fClusterAddressSet )
@@ -865,9 +970,9 @@ AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t cluster
                fData.ResetRawClusters();
                fData.GetRawClusters();
                fClusterAddressSet = kTRUE;
-       };
+       }
        return static_cast<AliMUONRawCluster*>( fData.RawClusters(chamber)->At(cluster) );
-};
+}
 
 
 Int_t AliMUONDataInterface::NumberOfLocalTriggers()
@@ -877,25 +982,25 @@ Int_t AliMUONDataInterface::NumberOfLocalTriggers()
 
        if (fRunloader == NULL)
        {
-               Error("NumberOfLocalTriggers", "File not set.");
+               AliError("File not set.");
                return -1;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("NumberOfLocalTriggers", "Event not chosen.");
+               AliError("Event not chosen.");
                return -1;
-       };
+       }
 
-       if ( ! FetchTreeR() ) return -1;
+       if ( ! FetchTreeD() ) return -1;
        if ( ! fTriggerAddressSet )
        {
                fData.SetTreeAddress("GLT");
                fData.ResetTrigger();
-               fData.GetTrigger();
+               fData.GetTriggerD();
                fTriggerAddressSet = kTRUE;
-       };
+       }
        return fData.LocalTrigger()->GetEntriesFast();
-};
+}
 
 
 AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
@@ -905,22 +1010,132 @@ AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t trigger)
 
        if (fRunloader == NULL)
        {
-               Error("LocalTrigger", "File not set.");
+               AliError("File not set.");
                return NULL;
-       };
+       }
        if (fEventnumber < 0)
        {
-               Error("LocalTrigger", "Event not chosen.");
+               AliError( "Event not chosen.");
                return NULL;
-       };
+       }
 
-       if ( ! FetchTreeR() ) return NULL;
+       if ( ! FetchTreeD() ) return NULL;
        if ( ! fTriggerAddressSet )
        {
                fData.SetTreeAddress("GLT");
                fData.ResetTrigger();
-               fData.GetTrigger();
+               fData.GetTriggerD();
                fTriggerAddressSet = kTRUE;
-       };
+       }
        return static_cast<AliMUONLocalTrigger*>( fData.LocalTrigger()->At(trigger) );
-};
+}
+
+Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
+{
+  
+  // Get the number of local trigger objects in the current event.
+  // -1 is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return -1;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError("Event not chosen.");
+      return -1;
+    }
+  
+  if ( ! FetchTreeD() ) return -1;
+  if ( ! fTriggerAddressSet )
+    {
+      fData.SetTreeAddress("GLT");
+      fData.ResetTrigger();
+      fData.GetTriggerD();
+      fTriggerAddressSet = kTRUE;
+    }
+  return fData.GlobalTrigger()->GetEntriesFast();
+}
+
+AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t trigger)
+{
+  // Fetch the specified local trigger object from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return NULL;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return NULL;
+    }
+  
+  if ( ! FetchTreeD() ) return NULL;
+  if ( ! fTriggerAddressSet )
+    {
+      fData.SetTreeAddress("GLT");
+      fData.ResetTrigger();
+      fData.GetTriggerD();
+      fTriggerAddressSet = kTRUE;
+    }
+  return static_cast<AliMUONGlobalTrigger*>( fData.GlobalTrigger()->At(trigger) );
+}
+
+Int_t AliMUONDataInterface::NumberOfRecTracks()
+{
+  // Fetch the number of reconstructed tracks from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return -1;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return -1;
+    }
+  
+  if ( ! FetchTreeT() ) return -1;
+  if ( ! fRecTracksAddressSet )
+    {
+      fData.SetTreeAddress("RT");
+      fData.ResetRecTracks();
+      fData.GetRecTracks();
+      fRecTracksAddressSet = kTRUE;
+    }
+  return fData.RecTracks()->GetEntriesFast();
+}
+
+AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t rectrack)
+{
+  // Fetch the specified reconstructed track object from the current event.
+  // NULL is returned on error.
+  
+  if (fRunloader == NULL)
+    {
+      AliError("File not set.");
+      return NULL;
+    }
+  if (fEventnumber < 0)
+    {
+      AliError( "Event not chosen.");
+      return NULL;
+    }
+  
+  if ( ! FetchTreeT() ) return NULL;
+  if ( ! fRecTracksAddressSet )
+    {
+      fData.SetTreeAddress("RT");
+      fData.ResetRecTracks();
+      fData.GetRecTracks();
+      fRecTracksAddressSet = kTRUE;
+    }
+  return static_cast<AliMUONTrack*>( fData.RecTracks()->At(rectrack) );
+  // return (AliMUONTrack*)(fData.RecTracks()->At(rectrack));
+}