]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONMCDataInterface.cxx
Bug fixes (some outliers in central events) (from Redmer)
[u/mrichter/AliRoot.git] / MUON / AliMUONMCDataInterface.cxx
index 062ae8f6ccb189e1b48749d6c58bd76dcead8012..d1fde983b557c29dde95362611f20b46ed2e9d04 100644 (file)
 #include "AliMUONRegionalTrigger.h"
 #include "AliMUONGlobalTrigger.h"
 
-#include "AliMpIntPair.h"
+#include "AliMpEncodePair.h"
 #include "AliMpDEManager.h"
 #include "AliMpConstants.h"
 #include "AliMpCDB.h"
 
 #include "AliLog.h"
+#include "AliLoader.h"
 #include "AliRunLoader.h"
 #include "AliHeader.h"
 #include "AliStack.h"
 #include "AliCDBManager.h"
 
+#include <TTree.h>
 #include <Riostream.h>
 #include <TClonesArray.h>
 #include <TList.h>
@@ -55,6 +57,8 @@
 #include <cstdlib>
 #include <cassert>
 
+using std::endl;
+using std::cout;
 /// \cond CLASSIMP
 ClassImp(AliMUONMCDataInterface)
 /// \endcond
@@ -82,13 +86,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);
@@ -103,10 +103,6 @@ fIterator(0x0)
 AliMUONMCDataInterface::~AliMUONMCDataInterface()
 {
   /// dtor
-  if ( fLoader ) 
-  {
-    delete fLoader->GetRunLoader();
-  }
   --fgInstanceCounter;
 }
 
@@ -117,6 +113,12 @@ AliMUONMCDataInterface::HitStore(Int_t event, Int_t track)
   /// Return the hitStore for a given track of one event
   /// Return 0x0 if event and/or track 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;
 
@@ -166,6 +168,12 @@ AliMUONMCDataInterface::SDigitStore(Int_t event)
   /// Return the SDigit store for a given event.
   /// Return 0 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;
   
@@ -208,6 +216,12 @@ AliMUONMCDataInterface::DigitStore(Int_t event)
 {
   /// Return a pointer to the digitStore for a given event (or 0 if 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;
   
@@ -250,6 +264,12 @@ AliMUONMCDataInterface::Stack(Int_t event)
 {
   /// Get the Stack (list of generated particles) for one event
   /// 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;
 
@@ -270,6 +290,12 @@ AliMUONMCDataInterface::TrackRefs(Int_t event, Int_t track)
 {
   /// Get the track references for a given (generated) track of one event
   /// 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;
   
@@ -317,6 +343,12 @@ AliMUONMCDataInterface::TriggerStore(Int_t event)
   /// Return the triggerStore 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;
   
@@ -610,6 +642,7 @@ AliMUONMCDataInterface::Open(const char* filename)
   {
     AliError(Form("Cannot open file %s",filename));    
     fIsValid = kFALSE;
+    return;
   }
   
   // Get run number and set it to CDB manager
@@ -978,8 +1011,8 @@ TIterator* AliMUONMCDataInterface::GetIterator(IteratorType type, Int_t x, Int_t
       
       AliMUONVDigitStore* store = SDigitStore(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 = kSDigitIteratorByChamberAndCathode;
       fDataX = chamber;
@@ -1020,8 +1053,8 @@ TIterator* AliMUONMCDataInterface::GetIterator(IteratorType type, Int_t x, Int_t
       
       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;