]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONDataInterface.cxx
The variable fSeed is not really needed as the fitter is called in a way that the...
[u/mrichter/AliRoot.git] / MUON / AliMUONDataInterface.cxx
index deee01130a01e3e09eb7643552144f32971d9b15..72c171400e45cfb63bdca88cebf881e4f24805d6 100644 (file)
 #include "AliMUONVTriggerStore.h"
 #include "AliMpCDB.h"
 
-#include "AliMpIntPair.h"
+#include "AliMpEncodePair.h"
 #include "AliMpDEManager.h"
 #include "AliMpConstants.h"
 #include "AliMpCDB.h"
 
 #include "AliLoader.h"
-#include "AliLog.h"
 #include "AliRunLoader.h"
 #include "AliHeader.h"
 #include "AliCDBManager.h"
 
-#include <TError.h>
-#include <TParticle.h>
 #include <Riostream.h>
 #include <TFile.h>
 #include <TList.h>
@@ -81,6 +78,7 @@ fDigitStore(0x0),
 fTriggerStore(0x0),
 fClusterStore(0x0),
 fCurrentEvent(-1),
+fTreeLetter(""),
 fIsValid(kFALSE),
 fCurrentIteratorType(kNoIterator),
 fCurrentIndex(-1),
@@ -93,13 +91,9 @@ fIterator(0x0)
   
   ++fgInstanceCounter;
   
-  if (AliCDBManager::Instance() != NULL)
-  {
-    if (AliCDBManager::Instance()->GetDefaultStorage() == NULL)
-    {
-      AliInfo("Default storage for CDB not set.");
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-    }
+  if ( AliCDBManager::Instance() != NULL &&
+       AliCDBManager::Instance()->GetDefaultStorage() == NULL ) {
+      AliFatal("CDB default storage not defined.");
   }
   
   Open(filename);
@@ -129,12 +123,25 @@ 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 and fDigitStore != 0x0) return fDigitStore;
   
-  ResetStores();
-  if (not LoadEvent(event)) return 0x0;
+  if (event == fCurrentEvent)
+  {
+    if (fDigitStore != 0x0)
+      return fDigitStore;
+  }
+  else
+  {
+    ResetStores();
+    if ( not LoadEvent(event) ) return 0x0;
+  }
   
   fLoader->LoadDigits();
   
@@ -165,12 +172,25 @@ 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 (not IsValid()) return 0x0;
-  if (event == fCurrentEvent and fClusterStore != 0x0) return fClusterStore;
   
-  ResetStores();
-  if (not LoadEvent(event)) return 0x0;
+  if (event == fCurrentEvent)
+  {
+    if (fClusterStore != 0x0)
+      return fClusterStore;
+  }
+  else
+  {
+    ResetStores();
+    if ( not LoadEvent(event) ) return 0x0;
+  }
   
   fLoader->LoadRecPoints();
   
@@ -202,12 +222,39 @@ AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
   /// 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 (not IsValid()) return 0x0;
-  if (event == fCurrentEvent and fTriggerStore != 0x0) return fTriggerStore;
   
-  ResetStores();
-  if (not LoadEvent(event)) return 0x0;
+  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* tree(0x0);
   
@@ -247,6 +294,7 @@ AliMUONDataInterface::TriggerStore(Int_t event, const char* treeLetter)
   {
     fLoader->UnloadRecPoints();
   }
+  fTreeLetter = stree;
   
   return fTriggerStore;
 }
@@ -759,8 +807,8 @@ TIterator* AliMUONDataInterface::GetIterator(IteratorType type, Int_t x, Int_t y
       
       AliMUONVDigitStore* store = DigitStore(fCurrentEvent);
       if (store == 0x0) return 0x0;
-      AliMpIntPair pair = AliMpDEManager::GetDetElemIdRange(chamber);
-      fIterator = store->CreateIterator(pair.GetFirst(), pair.GetSecond(), cathode);
+      MpPair_t pair = AliMpDEManager::GetDetElemIdRange(chamber);
+      fIterator = store->CreateIterator(AliMp::PairFirst(pair), AliMp::PairSecond(pair), cathode);
       if (fIterator == 0x0) return 0x0;
       fCurrentIteratorType = kDigitIteratorByChamberAndCathode;
       fDataX = chamber;