]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDataInterface.cxx
ESD file is added to the list of proof output files. It is then automatically merged...
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
index 18f85aeb77062e4f6489b1eed5e63c463dc73333..7aa2ccbaaa76c3cf9835db3c4f02176f3a67b2be 100644 (file)
 /* $Id$ */
 
 #include "AliMUONDataInterface.h"
-#include "AliMUONDigit.h"
 #include "AliMUONGeometryTransformer.h"
-#include "AliMUONGlobalTrigger.h"
-#include "AliMUONHit.h"
+#include "AliMUONVDigit.h"
+#include "AliMUONVCluster.h"
 #include "AliMUONLocalTrigger.h"
-#include "AliMUONRawCluster.h"
-#include "AliMUONTrack.h"
+#include "AliMUONRegionalTrigger.h"
+#include "AliMUONGlobalTrigger.h"
 #include "AliMUONTriggerCircuit.h"
 #include "AliMUONVClusterStore.h"
 #include "AliMUONVDigitStore.h"
-#include "AliMUONVTrackStore.h"
 #include "AliMUONVTriggerStore.h"
-#include "AliMUONVTriggerTrackStore.h"
+#include "AliMpCDB.h"
+
+#include "AliMpIntPair.h"
+#include "AliMpDEManager.h"
+#include "AliMpConstants.h"
 #include "AliMpCDB.h"
 
 #include "AliLoader.h"
 #include "AliLog.h"
-#include "AliLog.h"
 #include "AliRunLoader.h"
+#include "AliHeader.h"
+#include "AliCDBManager.h"
 
 #include <TError.h>
 #include <TParticle.h>
 #include <TList.h>
 #include <TNtuple.h>
 #include <TSystem.h>
+#include <TIterator.h>
+#include <cstdlib>
+#include <cassert>
 
 //-----------------------------------------------------------------------------
 /// \class AliMUONDataInterface
 ///
 /// An easy to use interface to the MUON data data stored in
-/// TreeS, TreeD, TreeR and TreeT.
+/// TreeS, TreeD and TreeR.
 ///
 /// For MC related information (i.e. TreeH, TreeK, TreeTR), see
 /// AliMUONMCDataInterface.
 /// This interface in not necessarily the fastest way to fetch the data but
 /// it is the easiest.
 ///
-/// \author Laurent Aphecetche, Subatech
+/// \author Laurent Aphecetche, Subatech & Artur Szostak <artursz@iafrica.com> (University of Cape Town)
 //-----------------------------------------------------------------------------
 
 /// \cond CLASSIMP
 ClassImp(AliMUONDataInterface)
 /// \endcond
 
-//AliLoader* fLoader; //!< Tree accessor
-//AliMUONVDigitStore* fDigitStore; //!< current digit store (owner)
-//AliMUONVTriggerStore* fTriggerStore; //!< current trigger store (owner)
-//AliMUONVClusterStore* fClusterStore; //!< current cluster store (owner)
-//AliMUONVTrackStore* fTrackStore; //!< current track store (owner)
-//AliMUONVTriggerTrackStore* fTriggerTrackStore; //!< current trigger track store (owner)
-//Int_t fCurrentEvent; //!< Current event we've read in
-//Bool_t fIsValid; //!< whether we were initialized properly or not
 
 Int_t AliMUONDataInterface::fgInstanceCounter(0);
 
@@ -82,30 +80,94 @@ fLoader(0x0),
 fDigitStore(0x0),
 fTriggerStore(0x0),
 fClusterStore(0x0),
-fTrackStore(0x0),
-fTriggerTrackStore(0x0),
 fCurrentEvent(-1),
-fIsValid(kFALSE)
+fTreeLetter(""),
+fIsValid(kFALSE),
+fCurrentIteratorType(kNoIterator),
+fCurrentIndex(-1),
+fDataX(-1),
+fDataY(-1),
+fIterator(0x0)
 {
   /// ctor
   /// @param filename should be the full path to a valid galice.root file
   
   ++fgInstanceCounter;
   
+  if ( AliCDBManager::Instance() != NULL &&
+       AliCDBManager::Instance()->GetDefaultStorage() == NULL ) {
+      AliFatal("CDB default storage not defined.");
+  }
+  
   Open(filename);
+
+  // Load mapping
+  if ( ! AliMpCDB::LoadDDLStore() ) {
+    AliFatal("Could not access mapping from OCDB !");
+  }
 }
 
 //______________________________________________________________________________
 AliMUONDataInterface::~AliMUONDataInterface()
 {
   /// dtor
-  if ( fLoader ) 
+  ResetStores();
+  if ( fLoader != 0x0 ) 
   {
     delete fLoader->GetRunLoader();
   }
   --fgInstanceCounter;  
 }
 
+//______________________________________________________________________________
+AliMUONVDigitStore*
+AliMUONDataInterface::DigitStore(Int_t event)
+{
+  /// Return digitStore for a given event.
+  /// Return 0x0 if event not found.
+  /// Returned pointer should not be deleted
+  ///
+  /// \note If a previous store has been retrieved by one of the methods of
+  /// this class, but for a different event number, then those stores will
+  /// be deleted and no longer valid.
+  /// If you require access to the data for the earlier retrieved store,
+  /// but for different events, then you should deep copy / clone the object.
+  
+  if (not IsValid()) return 0x0;
+  
+  if (event == fCurrentEvent)
+  {
+    if (fDigitStore != 0x0)
+      return fDigitStore;
+  }
+  else
+  {
+    ResetStores();
+    if ( not LoadEvent(event) ) return 0x0;
+  }
+  
+  fLoader->LoadDigits();
+  
+  TTree* treeD = fLoader->TreeD();
+  if (treeD == 0x0)
+  {
+    AliError("Could not get treeD");
+    return 0x0;
+  }
+  
+  fDigitStore = AliMUONVDigitStore::Create(*treeD);
+  if ( fDigitStore != 0x0 ) 
+  {
+    fDigitStore->Clear();
+    fDigitStore->Connect(*treeD);
+    treeD->GetEvent(0);
+  }
+  
+  fLoader->UnloadDigits();
+  
+  return fDigitStore;
+}
+
 //______________________________________________________________________________
 AliMUONVClusterStore*
 AliMUONDataInterface::ClusterStore(Int_t event)
@@ -113,25 +175,37 @@ AliMUONDataInterface::ClusterStore(Int_t event)
   /// Return clusterStore for a given event.
   /// Return 0x0 if event not found.
   /// Returned pointer should not be deleted
+  ///
+  /// \note If a previous store has been retrieved by one of the methods of
+  /// this class, but for a different event number, then those stores will
+  /// be deleted and no longer valid.
+  /// If you require access to the data for the earlier retrieved store,
+  /// but for different events, then you should deep copy / clone the object.
   
-  if ( LoadEvent(event) ) return 0x0;
+  if (not IsValid()) return 0x0;
+  
+  if (event == fCurrentEvent)
+  {
+    if (fClusterStore != 0x0)
+      return fClusterStore;
+  }
+  else
+  {
+    ResetStores();
+    if ( not LoadEvent(event) ) return 0x0;
+  }
   
   fLoader->LoadRecPoints();
   
   TTree* treeR = fLoader->TreeR();
-  
-  if (!treeR)
+  if (treeR == 0x0)
   {
     AliError("Could not get treeR");
     return 0x0;
   }
   
-  if (!fClusterStore)
-  {
-    fClusterStore = AliMUONVClusterStore::Create(*treeR);
-  }
-  
-  if ( fClusterStore ) 
+  fClusterStore = AliMUONVClusterStore::Create(*treeR);
+  if ( fClusterStore != 0x0 ) 
   {
     fClusterStore->Clear();
     fClusterStore->Connect(*treeR);
@@ -143,41 +217,89 @@ AliMUONDataInterface::ClusterStore(Int_t event)
   return fClusterStore;
 }
 
-//______________________________________________________________________________
-AliMUONVDigitStore*
-AliMUONDataInterface::DigitStore(Int_t event)
+//_____________________________________________________________________________
+AliMUONVTriggerStore*
+AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
 {
-  /// Return digitStore for a given event.
+  /// Return the triggerStore for a given event.
   /// Return 0x0 if event not found.
   /// Returned pointer should not be deleted
+  /// treeLetter can be R or D to tell from which tree to read the information
+  ///
+  /// \note If a previous store has been retrieved by one of the methods of
+  /// this class, but for a different event number, then those stores will
+  /// be deleted and no longer valid.
+  /// If you require access to the data for the earlier retrieved store,
+  /// but for different events, then you should deep copy / clone the object.
   
-  if ( LoadEvent(event) ) return 0x0;
+  if (not IsValid()) return 0x0;
   
-  fLoader->LoadDigits();
+  if (event == fCurrentEvent)
+  {
+    if (fTreeLetter == treeLetter)
+    {
+      if (fTriggerStore != 0x0)
+        return fTriggerStore;
+    }
+    else
+    {
+      // Reset only the fTriggerStore since the others might still be valid
+      // for the same event.
+      if (fTriggerStore != 0x0)
+      {
+        delete fTriggerStore;
+        fTriggerStore = 0x0;
+      }
+    }
+  }
+  else
+  {
+    // Event has changed so reset all the stores.
+    ResetStores();
+    if ( not LoadEvent(event) ) return 0x0;
+  }
   
-  TTree* treeD = fLoader->TreeD();
+  TTree* tree(0x0);
   
-  if (!treeD)
+  TString stree(treeLetter);
+  stree.ToUpper();
+  
+  if ( stree == "D" )
   {
-    AliError("Could not get treeD");
-    return 0x0;
+    fLoader->LoadDigits();    
+    tree = fLoader->TreeD();
+  }
+  else if ( stree == "R" )
+  {
+    fLoader->LoadRecPoints();
+    tree = fLoader->TreeR();
   }
   
-  if (!fDigitStore)
+  if ( tree == 0x0 ) 
   {
-    fDigitStore = AliMUONVDigitStore::Create(*treeD);
+    AliError(Form("Could not get tree%s",treeLetter));
+    return 0x0;
   }
   
-  if ( fDigitStore ) 
+  fTriggerStore = AliMUONVTriggerStore::Create(*tree);
+  if ( fTriggerStore != 0x0 ) 
   {
-    fDigitStore->Clear();
-    fDigitStore->Connect(*treeD);
-    treeD->GetEvent(0);
+    fTriggerStore->Clear();
+    fTriggerStore->Connect(*tree);
+    tree->GetEvent(0);
   }
   
-  fLoader->UnloadDigits();
+  if ( stree == "D" )
+  {
+    fLoader->UnloadDigits();    
+  }
+  else if ( stree == "R" )
+  {
+    fLoader->UnloadRecPoints();
+  }
+  fTreeLetter = stree;
   
-  return fDigitStore;
+  return fTriggerStore;
 }
 
 //______________________________________________________________________________
@@ -186,7 +308,7 @@ AliMUONDataInterface::DumpDigits(Int_t event, Bool_t sorted)
 {
   /// Dump the digits for a given event, sorted if so required
   DigitStore(event);
-  if ( fDigitStore ) 
+  if ( fDigitStore != 0x0 
   {
     if ( sorted ) 
     {
@@ -205,7 +327,7 @@ AliMUONDataInterface::DumpRecPoints(Int_t event, Bool_t sorted)
 {
   /// Dump the recpoints for a given event, sorted if so required
   ClusterStore(event);
-  if ( fClusterStore ) 
+  if ( fClusterStore != 0x0 
   {
     if ( sorted ) 
     {
@@ -239,48 +361,6 @@ AliMUONDataInterface::DumpSorted(const AliMUONVStore& store) const
   list.Print();
 }
 
-//______________________________________________________________________________
-void
-AliMUONDataInterface::DumpTracks(Int_t event, Bool_t sorted)
-{
-  /// Dump tracks for a given event, sorted if requested
-  
-  TrackStore(event);
-  
-  if ( fTrackStore ) 
-  {
-    if ( sorted ) 
-    {
-      DumpSorted(*fTrackStore);
-    }
-    else
-    {
-      fTrackStore->Print();
-    }
-  }
-}
-
-//______________________________________________________________________________
-void
-AliMUONDataInterface::DumpTriggerTracks(Int_t event, Bool_t sorted)
-{
-  /// Dump trigger tracks for a given event, sorted if requested
-
-  TriggerTrackStore(event);
-  
-  if ( fTriggerTrackStore ) 
-  {
-    if ( sorted ) 
-    {
-      DumpSorted(*fTriggerTrackStore);
-    }
-    else
-    {
-      fTriggerTrackStore->Print();
-    }
-  }
-}
-
 //_____________________________________________________________________________
 void
 AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter)
@@ -297,7 +377,7 @@ AliMUONDataInterface::DumpTrigger(Int_t event, const char* treeLetter)
   {
     TriggerStore(event,treeLetter);
   
-    if ( fTriggerStore ) 
+    if ( fTriggerStore != 0x0 
     {
       fTriggerStore->Print();
     }
@@ -337,20 +417,7 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
   AliMUONGeometryTransformer transformer;
   transformer.LoadGeometryData(Form("%s/geometry.root",
                                     gSystem->DirName(fLoader->GetRunLoader()->GetFileName())));
-  
-  // Load mapping
-  if ( ! AliMpCDB::LoadMpSegmentation() ) 
-  {
-    AliFatal("Could not access mapping from OCDB !");
-  }
-  
-  // Load DDL store
-  if ( ! AliMpCDB::LoadDDLStore() ) 
-  {
-    AliFatal("Could not access DDL Store from OCDB !");
-  }
-
-  AliMUONTriggerCircuit triggerCircuit(&transformer);
+    AliMUONTriggerCircuit triggerCircuit(&transformer);
 
   // select output file name from selected Tree
   Char_t fileNameOut[30];
@@ -372,7 +439,7 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
   {
     if (ievent%100==0) AliInfo(Form("Processing event %d\n",ievent));
     
-    AliMUONVTriggerStore* triggerStore = TriggerStore(ievent);
+    AliMUONVTriggerStore* triggerStore = TriggerStore(ievent,treeLetter);
     
     if (!triggerStore)
     {
@@ -394,15 +461,8 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
     AliMUONLocalTrigger* locTrg(0x0);
     while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
     {
-      Bool_t xTrig=kFALSE;
-      Bool_t yTrig=kFALSE;
-      
-      if ( locTrg->LoSdev()==1 && locTrg->LoDev()==0 && 
-           locTrg->LoStripX()==0) xTrig=kFALSE; // no trigger in X
-      else xTrig=kTRUE;                         // trigger in X
-      if (locTrg->LoTrigY()==1 && 
-          locTrg->LoStripY()==15 ) yTrig = kFALSE; // no trigger in Y
-      else yTrig = kTRUE;                          // trigger in Y
+      Bool_t xTrig=locTrg->IsTrigX();
+      Bool_t yTrig=locTrg->IsTrigY();
       
       if (xTrig && yTrig) 
       { // fill ntuple if trigger in X and Y                   
@@ -448,33 +508,23 @@ AliMUONDataInterface::NtupleTrigger(const char* treeLetter)
   myFile.Close();
 }
 
-//______________________________________________________________________________
-Bool_t
-AliMUONDataInterface::IsValid() const
-{
-  /// Whether we were properly initialized from a valid galice.root file
-  return fIsValid;
-}
-
 //_____________________________________________________________________________
-Int_t
+Bool_t
 AliMUONDataInterface::LoadEvent(Int_t event)
 {
   /// Load event if different from the current one.
-  if ( event != fCurrentEvent ) 
+  /// Returns kFALSE on error and kTRUE if the event was loaded.
+  
+  assert( IsValid() );
+  
+  AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader()));
+  if (fLoader->GetRunLoader()->GetEvent(event) == 0)
   {
     fCurrentEvent = event;
-    AliDebug(1,Form("Loading event %d using runLoader %p",event,fLoader->GetRunLoader()));
-    if ( event < NumberOfEvents() )
-    {
-      return fLoader->GetRunLoader()->GetEvent(event);
-    }
-    else
-    {
-      return 1;
-    }
+    return kTRUE;
   }
-  return 0;
+  else
+    return kFALSE;
 }
 
 //______________________________________________________________________________
@@ -482,7 +532,7 @@ Int_t
 AliMUONDataInterface::NumberOfEvents() const
 {
   /// Number of events in the current galice.root file we're attached to 
-  if (!IsValid()) return 0;
+  if (not IsValid()) return -1;
   return fLoader->GetRunLoader()->GetNumberOfEvents();
 }
 
@@ -492,20 +542,11 @@ AliMUONDataInterface::Open(const char* filename)
 {
   /// Connect to a given galice.root file
   
-  delete fDigitStore;
-  fDigitStore=0x0;
-  delete fTriggerStore;
-  fTriggerStore=0x0;
-  delete fClusterStore;
-  fClusterStore=0x0;
-  delete fTrackStore;
-  fTrackStore=0x0;
-  delete fTriggerTrackStore;
-  fTriggerTrackStore=0x0;
+  ResetStores();
   
   fCurrentEvent=-1;
   
-  if ( fLoader ) 
+  if ( fLoader != 0x0 
   {
     delete fLoader->GetRunLoader();
   }
@@ -516,496 +557,372 @@ AliMUONDataInterface::Open(const char* filename)
   
   TString foldername(Form("%s-%d",ClassName(),fgInstanceCounter));
   
-  while (AliRunLoader::GetRunLoader(foldername)) 
+  while (AliRunLoader::GetRunLoader(foldername) != 0x0
   {
     delete AliRunLoader::GetRunLoader(foldername);
   }
   
   AliRunLoader* runLoader = AliRunLoader::Open(filename,foldername);
-  if (!runLoader
+  if (runLoader == 0x0
   {
     AliError(Form("Cannot open file %s",filename));    
     fIsValid = kFALSE;
   }
+
+  runLoader->LoadHeader();
+  if ( ! runLoader->GetHeader() ) {
+    AliError("Cannot load header.");    
+    fIsValid = kFALSE;
+  }
+  else {
+    Int_t runNumber = runLoader->GetHeader()->GetRun();
+    AliCDBManager::Instance()->SetRun(runNumber);
+  }  
+  runLoader->UnloadHeader(); 
+
   fLoader = runLoader->GetDetectorLoader("MUON");
-  if (!fLoader
+  if (fLoader == 0x0
   {
     AliError("Cannot get AliMUONLoader");
     fIsValid = kFALSE;
   }
   
-  if (!IsValid())
+  if (not IsValid())
   {
     AliError(Form("Could not access %s filename. Object is unuseable",filename));
   }
 }
 
-//______________________________________________________________________________
-AliMUONVTrackStore* 
-AliMUONDataInterface::TrackStore(Int_t event)
-{
-  /// Return the trackStore for a given event.
-  /// Return 0x0 if event not found.
-  /// Returned pointer should not be deleted
-  
-  if ( LoadEvent(event) ) return 0x0;
-  
-  fLoader->LoadTracks();
-  
-  TTree* treeT = fLoader->TreeT();
-  
-  if (!treeT)
-  {
-    AliError("Could not get treeT");
-    return 0x0;
-  }
-  
-  if (!fTrackStore)
-  {
-    fTrackStore = AliMUONVTrackStore::Create(*treeT);
-  }
-  
-  if ( fTrackStore ) 
-  {
-    fTrackStore->Clear();
-    fTrackStore->Connect(*treeT);
-    treeT->GetEvent(0);
-  }
-  
-  fLoader->UnloadTracks();
-  
-  return fTrackStore;
-}
-
-//______________________________________________________________________________
-AliMUONVTriggerTrackStore* 
-AliMUONDataInterface::TriggerTrackStore(Int_t event)
-{
-  /// Return the triggerTrackStore for a given event.
-  /// Return 0x0 if event not found.
-  /// Returned pointer should not be deleted
-  
-  if ( LoadEvent(event) ) return 0x0;
-  
-  fLoader->LoadTracks();
-  
-  TTree* treeT = fLoader->TreeT();
-  
-  if (!treeT)
-  {
-    AliError("Could not get treeT");
-    return 0x0;
-  }
-  
-  if (!fTriggerTrackStore)
-  {
-    fTriggerTrackStore = AliMUONVTriggerTrackStore::Create(*treeT);
-  }
-  
-  if ( fTriggerTrackStore ) 
-  {
-    fTriggerTrackStore->Clear();
-    fTriggerTrackStore->Connect(*treeT);
-    treeT->GetEvent(0);
-  }
-  
-  fLoader->UnloadTracks();
-  
-  return fTriggerTrackStore;  
-}
-
 //_____________________________________________________________________________
-AliMUONVTriggerStore*
-AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
+Bool_t AliMUONDataInterface::GetEvent(Int_t event)
 {
-  /// Return the triggerStore for a given event.
-  /// Return 0x0 if event not found.
-  /// Returned pointer should not be deleted
-  /// treeLetter can be R or D to tell from which tree to read the information
-  
-  if ( LoadEvent(event) ) return 0x0;
-  
-  TTree* tree(0x0);
-  
-  TString stree(treeLetter);
-  stree.ToUpper();
-  
-  if ( stree == "D" )
-  {
-    fLoader->LoadDigits();    
-    tree = fLoader->TreeD();
-  }
-  else if ( stree == "R" )
-  {
-    fLoader->LoadRecPoints();
-    tree = fLoader->TreeR();
-  }
-  
-  if ( !tree ) 
-  {
-    AliError(Form("Could not get tree%s",treeLetter));
-    return 0x0;
-  }
-  
-  if (!fTriggerStore)
-  {
-    fTriggerStore = AliMUONVTriggerStore::Create(*tree);
-  }
-  
-  if ( fTriggerStore ) 
-  {
-    fTriggerStore->Clear();
-    fTriggerStore->Connect(*tree);
-    tree->GetEvent(0);
-  }
-  
-  if ( stree == "D" )
-  {
-    fLoader->UnloadDigits();    
-  }
-  else if ( stree == "R" )
-  {
-    fLoader->UnloadRecPoints();
-  }
-  
-  return fTriggerStore;
-}
-
-//______________________________________________________________________________
-//______________________________________________________________________________
-//______________________________________________________________________________
-//______________________________________________________________________________
-
-void AliMUONDataInterface::Reset()
-{
-/// \deprecated Method is going to be removed
+/// Loads all reconstructed data for the given event.
 
-  AliFatal("Deprecated");
+  if (DigitStore(event) == 0x0) return kFALSE;
+  if (ClusterStore(event) == 0x0) return kFALSE;
+  if (TriggerStore(event) == 0x0) return kFALSE;
+  return kTRUE;
 }
 
-Bool_t AliMUONDataInterface::UseCurrentRunLoader()
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return kFALSE;
-}
-  
-Int_t AliMUONDataInterface::NumberOfEvents(TString , TString )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfParticles(TString , TString , Int_t )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-TParticle* AliMUONDataInterface::Particle(
-               TString , TString , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfTracks(TString , TString , Int_t )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfHits(
-               TString , TString , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-AliMUONHit* AliMUONDataInterface::Hit(
-               TString , TString , Int_t ,
-               Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfSDigits(
-               TString , TString , Int_t ,
-               Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-AliMUONDigit* AliMUONDataInterface::SDigit(
-               TString , TString , Int_t ,
-               Int_t , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfDigits(
-               TString , TString , Int_t ,
-               Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-AliMUONDigit* AliMUONDataInterface::Digit(
-               TString , TString , Int_t ,
-               Int_t , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfRawClusters(
-               TString , TString , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-AliMUONRawCluster* AliMUONDataInterface::RawCluster(
-               TString , TString , Int_t ,
-               Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Int_t AliMUONDataInterface::NumberOfLocalTriggers(TString , TString , Int_t )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(
-               TString , TString , Int_t , Int_t 
-       )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-Bool_t AliMUONDataInterface::SetFile(TString , TString )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-Bool_t AliMUONDataInterface::GetEvent(Int_t )
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-Int_t AliMUONDataInterface::NumberOfParticles()
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
-}
-
-
-TParticle* AliMUONDataInterface::Particle(Int_t )
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::NumberOfDigits(Int_t detElemId)
 {
-/// \deprecated Method is going to be removed
+/// Returns the number of digits to be found on a given detector element.
+/// @param detElemId  The detector element ID number to search on.
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
+  return CountObjects(iter);
 }
 
-
-Int_t AliMUONDataInterface::NumberOfTracks()
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONDataInterface::Digit(Int_t detElemId, Int_t index)
 {
-/// \deprecated Method is going to be removed
+/// Returns the a pointer to the index'th digit on the specified detector element.
+/// @param detElemId  The detector element ID number to search on.
+/// @param index  The index number of the digit to fetch in the range [0 .. N-1],
+///   where N = NumberOfDigits(detElemId)
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kDigitIteratorByDetectorElement, detElemId);
+  return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
 }
 
-
-Int_t AliMUONDataInterface::NumberOfHits(Int_t )
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::NumberOfDigits(Int_t chamber, Int_t cathode)
 {
-/// \deprecated Method is going to be removed
+/// Returns the number of digits to be found on a specific chamber and cathode.
+/// @param chamber  The chamber number in the range [0 .. 13].
+/// @param cathode  The cathode in the range [0 .. 1], where 0 is the bending and
+///   1 is the non-bending plane.
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
+  return CountObjects(iter);
 }
 
-
-AliMUONHit* 
-AliMUONDataInterface::Hit(Int_t , Int_t )
+//_____________________________________________________________________________
+AliMUONVDigit* AliMUONDataInterface::Digit(Int_t chamber, Int_t cathode, Int_t index)
 {
-/// \deprecated Method is going to be removed
+/// Returns the a pointer to the index'th digit on the specified chamber and cathode.
+/// @param chamber  The chamber number in the range [0 .. 13].
+/// @param cathode  The cathode in the range [0 .. 1], where 0 is the bending and
+///   1 is the non-bending plane.
+/// @param index  The index number of the digit to fetch in the range [0 .. N-1],
+///   where N = NumberOfDigits(chamber, cathode)
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kDigitIteratorByChamberAndCathode, chamber, cathode);
+  return static_cast<AliMUONVDigit*>( FetchObject(iter, index) );
 }
 
-
-Int_t AliMUONDataInterface::NumberOfSDigits(Int_t , Int_t )
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t chamber)
 {
-/// \deprecated Method is going to be removed
+/// Returns the number of reconstructed raw clusters on the specified chamber.
+/// @param chamber  The chamber number in the range [0 .. 13].
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kRawClusterIterator, chamber);
+  return CountObjects(iter);
 }
 
-
-AliMUONDigit* AliMUONDataInterface::SDigit(Int_t , Int_t , Int_t )
+//_____________________________________________________________________________
+AliMUONVCluster* AliMUONDataInterface::RawCluster(Int_t chamber, Int_t index)
 {
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
+/// Returns a pointer to the index'th raw cluster on the specified chamber.
+/// @param chamber  The chamber number in the range [0 .. 13].
+/// @param index  The index number of the raw cluster to fetch in the range [0 .. N-1],
+///   where N = NumberOfRawClusters(chamber)
 
+  TIterator* iter = GetIterator(kRawClusterIterator, chamber);
+  return static_cast<AliMUONVCluster*>( FetchObject(iter, index) );
 }
 
-
-Int_t AliMUONDataInterface::NumberOfDigits(Int_t , Int_t )
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::NumberOfLocalTriggers()
 {
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
+/// Returns the number of reconstructed local trigger objects.
 
+  TIterator* iter = GetIterator(kLocalTriggerIterator);
+  return CountObjects(iter);
 }
 
-
-AliMUONDigit* AliMUONDataInterface::Digit(Int_t , Int_t , Int_t )
+//_____________________________________________________________________________
+AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t index)
 {
-/// \deprecated Method is going to be removed
+/// Returns a pointer to the index'th local trigger object.
+/// @param index  The index number of the local trigger object to fetch in the range [0 .. N-1],
+///   where N = NumberOfLocalTriggers()
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kLocalTriggerIterator);
+  return static_cast<AliMUONLocalTrigger*>( FetchObject(iter, index) );
 }
 
-
-Int_t AliMUONDataInterface::NumberOfRawClusters(Int_t )
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::NumberOfRegionalTriggers()
 {
-/// \deprecated Method is going to be removed
+/// Returns the number of regional trigger objects reconstructed.
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kRegionalTriggerIterator);
+  return CountObjects(iter);
 }
 
-
-AliMUONRawCluster* AliMUONDataInterface::RawCluster(Int_t , Int_t )
+//_____________________________________________________________________________
+AliMUONRegionalTrigger* AliMUONDataInterface::RegionalTrigger(Int_t index)
 {
-/// \deprecated Method is going to be removed
+/// Returns a pointer to the index'th regional trigger object.
+/// @param index  The index number of the regional trigger object to fetch in the range [0 .. N-1],
+///   where N = NumberOfRegionalTriggers()
 
-  AliFatal("Deprecated");
-  return 0;
+  TIterator* iter = GetIterator(kRegionalTriggerIterator);
+  return static_cast<AliMUONRegionalTrigger*>( FetchObject(iter, index) );
 }
 
-
-Int_t AliMUONDataInterface::NumberOfLocalTriggers()
+//_____________________________________________________________________________
+AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger()
 {
-/// \deprecated Method is going to be removed
+/// Returns a pointer to the reconstructed global trigger object for the event.
 
-  AliFatal("Deprecated");
-  return 0;
+  AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
+  if (store == 0x0) return 0x0;
+  return store->Global();
 }
 
-
-AliMUONLocalTrigger* AliMUONDataInterface::LocalTrigger(Int_t )
+//_____________________________________________________________________________
+void AliMUONDataInterface::ResetStores()
 {
-/// \deprecated Method is going to be removed
+/// Deletes all the store objects that have been created and resets the pointers to 0x0.
+/// The temporary iterator object is automatically reset. See ResetIterator for more details.
 
-  AliFatal("Deprecated");
-  return 0;
+  ResetIterator();
+  if (fDigitStore != 0x0)
+  {
+    delete fDigitStore;
+    fDigitStore = 0x0;
+  }
+  if (fTriggerStore != 0x0)
+  {
+    delete fTriggerStore;
+    fTriggerStore = 0x0;
+  }
+  if (fClusterStore != 0x0)
+  {
+    delete fClusterStore;
+    fClusterStore = 0x0;
+  }
 }
 
-Int_t AliMUONDataInterface::NumberOfGlobalTriggers()
-{
-/// \deprecated Method is going to be removed
-
-  AliFatal("Deprecated");
-  return 0;
+//_____________________________________________________________________________
+TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y)
+{
+/// Creates an appropriate iterator object and returns it.
+/// If the iterator has already been created then that one is returned otherwise
+/// a new object is created.
+/// Depending on the value of 'type' the semantics of parameters x and y can change.
+/// @param type  The type of iterator to create.
+/// @param x  This is the detector element ID if type == kDigitIteratorByDetectorElement
+///           If type equals kDigitIteratorByChamberAndCathode or kRawClusterIterator
+///           then this is the chamber number. In all other cases this parameter is
+///           ignored.
+/// @param y  If type == kDigitIteratorByChamberAndCathode then this parameter is the
+///           cathode number. In all other cases this parameter is
+///           ignored.
+
+  if (type == fCurrentIteratorType and fDataX == x and fDataY == y)
+       return fIterator;
+  
+  if (fCurrentEvent == -1)
+  {
+    AliError("No event was selected. Try first using GetEvent().");
+    return 0x0;
+  }
+  
+  ResetIterator();
+  
+  switch (type)
+  {
+  case kDigitIteratorByDetectorElement:
+    {
+      Int_t detElem = x;
+      AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
+      if (store == 0x0) return 0x0;
+      fIterator = store->CreateIterator(detElem, detElem, 2);
+      if (fIterator == 0x0) return 0x0;
+      fCurrentIteratorType = kDigitIteratorByDetectorElement;
+      fDataX = detElem;
+      return fIterator;
+    }
+    
+  case kDigitIteratorByChamberAndCathode:
+    {
+      Int_t chamber = x;
+      Int_t cathode = y;
+      if (chamber < 0 or AliMpConstants::NofChambers() <= chamber)
+      {
+        AliError(Form(
+          "Must have give a chamber value in the range [0..%d], but got a value of: %d",
+          AliMpConstants::NofChambers() - 1,
+          chamber
+        ));
+        return 0x0;
+      }
+      if (cathode < 0 or 1 < cathode)
+      {
+        AliError(Form("Must have give a cathode value in the range [0..1], but got a value of: %d", cathode));
+        return 0x0;
+      }
+      
+      AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
+      if (store == 0x0) return 0x0;
+      AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
+      fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
+      if (fIterator == 0x0) return 0x0;
+      fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
+      fDataX = chamber;
+      fDataY = cathode;
+      return fIterator;
+    }
+    
+  case kRawClusterIterator:
+    {
+      Int_t chamber = x;
+      AliMUONVClusterStore* store = ClusterStore(fCurrentEvent);
+      if (store == 0x0) return 0x0;
+      fIterator = store->CreateChamberIterator(chamber, chamber);
+      if (fIterator == 0x0) return 0x0;
+      fCurrentIteratorType = kRawClusterIterator;
+      fDataX = chamber;
+      return fIterator;
+    }
+    
+  case kLocalTriggerIterator:
+    {
+      AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
+      if (store == 0x0) return 0x0;
+      fIterator = store->CreateLocalIterator();
+      if (fIterator == 0x0) return 0x0;
+      fCurrentIteratorType = kLocalTriggerIterator;
+      return fIterator;
+    }
+    
+  case kRegionalTriggerIterator:
+    {
+      AliMUONVTriggerStore* store = TriggerStore(fCurrentEvent);
+      if (store == 0x0) return 0x0;
+      fIterator = store->CreateRegionalIterator();
+      if (fIterator == 0x0) return 0x0;
+      fCurrentIteratorType = kRegionalTriggerIterator;
+      return fIterator;
+    }
+    
+  default:
+    return 0x0;
+  }
 }
 
-AliMUONGlobalTrigger* AliMUONDataInterface::GlobalTrigger(Int_t )
+//_____________________________________________________________________________
+void AliMUONDataInterface::ResetIterator()
 {
-/// \deprecated Method is going to be removed
+/// The temporary iterator object is deleted if it exists and the pointer reset to 0x0.
+/// The iterator type and temporary data indicating the state of the iterator are
+/// also reset.
 
-  AliFatal("Deprecated");
-  return 0;
+  if (fIterator != 0x0) delete fIterator;
+  fCurrentIteratorType = kNoIterator;
+  fCurrentIndex = fDataX = fDataY = -1;
+  fIterator = 0x0;
 }
 
-Int_t AliMUONDataInterface::NumberOfRecTracks()
+//_____________________________________________________________________________
+Int_t AliMUONDataInterface::CountObjects(TIterator* iter)
 {
-/// \deprecated Method is going to be removed
+/// Counts the number of objects in the iterator and resets it.
+/// @return The number of objects in 'iter'.
 
-  AliFatal("Deprecated");
-  return 0;
+  if (iter == 0x0) return -1;
+  Int_t count = 0;
+  iter->Reset();
+  while ( iter->Next() != 0x0 ) count++;
+  iter->Reset();
+  fCurrentIndex = -1;
+  return count;
 }
 
-AliMUONTrack* AliMUONDataInterface::RecTrack(Int_t )
-{
-/// \deprecated Method is going to be removed
+//_____________________________________________________________________________
+TObject* AliMUONDataInterface::FetchObject(TIterator* iter, Int_t index)
+{
+/// Fetches the index'th object from the iterator counting the first object
+/// returned by iterator after it is reset as index == 0. The next object
+/// has index == 1 and so on where the last object returned by the iterator
+/// has index == N-1 where N = CountObjects(iter)
+/// This method will only reset the iterator if index is smaller than
+/// fCurrentIndex, which is used to track the iteration progress and is
+/// updated when a new object if returned by this method.
+/// @param iter  The iterator to fetch an object from.
+/// @param index The index number of the object to fetch in the range [0 .. N-1]
+///        where N = CountObjects(iter)
+
+  if (index < 0)
+  {
+    AliError(Form("Index is out of bounds. Got a value of %d.", index));
+    return 0x0;
+  }
 
-  AliFatal("Deprecated");
-  return 0;
+  if (iter == 0x0) return 0x0;
+  if (index <= fCurrentIndex)
+  {
+    iter->Reset();
+    fCurrentIndex = -1;
+  }
+  
+  TObject* object = 0x0;
+  while (fCurrentIndex < index)
+  {
+    object = iter->Next();
+    if (object == 0x0)
+    {
+      AliError(Form("Index is out of bounds. Got a value of %d.", index));
+      iter->Reset();
+      fCurrentIndex = -1;
+      return 0x0;
+    }
+    fCurrentIndex++;
+  }
+  return object;
 }