]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
PreReading of MC information on demand.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 Oct 2009 17:08:29 +0000 (17:08 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 28 Oct 2009 17:08:29 +0000 (17:08 +0000)
STEER/AliMCEvent.cxx
STEER/AliMCEvent.h
STEER/AliMCEventHandler.cxx
STEER/AliMCEventHandler.h

index e7b687aec4a1e4d7f65c6175f3d6f8f394c555bf..526340e03fb964a5df15a210635e92eb16dd53ac 100644 (file)
@@ -636,6 +636,8 @@ Bool_t AliMCEvent::IsPhysicalPrimary(Int_t i)
 
 void AliMCEvent::InitEvent()
 {
+//
+// Initialize the subsidiary event structure
     if (fSubsidiaryEvents) {
        TIter next(fSubsidiaryEvents);
        AliMCEvent* evt;
@@ -659,6 +661,23 @@ void AliMCEvent::InitEvent()
        }
     }
 }
+void AliMCEvent::PreReadAll()                              
+{
+    // Preread the MC information
+    Int_t i;
+    // secondaries
+    for (i = fStack->GetNprimary(); i < fStack->GetNtrack(); i++) 
+    {
+       GetTrack(i);
+    }
+    // primaries
+    for (i = 0; i < fStack->GetNprimary(); i++) 
+    {
+       GetTrack(i);
+    }
+    
+    
+}
 
 
 ClassImp(AliMCEvent)
index aabdae664693ae39d6254cc21cf4415611227c6d..ab584cf4126331ba9ebf1cd70ae06541f1cb5dbd 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     virtual void SetStdNames()                             {;}
     virtual void Print(Option_t */*option=""*/)  const     {;}
-    
+    virtual void PreReadAll();
 
     // Header
     virtual AliVHeader* GetHeader()          const         {return 0;}
index ca1855e9cabb2b830858ffa5d58e8d5dbff28046..9c37a1dfee572c973979d79c7a7de6845b4eb3f0 100644 (file)
@@ -66,7 +66,8 @@ AliMCEventHandler::AliMCEventHandler() :
     fReadTR(kTRUE),
     fInitOk(kFALSE),
     fSubsidiaryHandlers(0),
-    fEventsInContainer(0)
+    fEventsInContainer(0),
+    fPreReadMode(kNoPreRead)
 {
   //
   // Default constructor
@@ -97,7 +98,8 @@ AliMCEventHandler::AliMCEventHandler(const char* name, const char* title) :
     fReadTR(kTRUE),
     fInitOk(kFALSE),
     fSubsidiaryHandlers(0),
-    fEventsInContainer(0)
+    fEventsInContainer(0),
+    fPreReadMode(kNoPreRead)
 {
   //
   // Constructor
@@ -286,6 +288,11 @@ Bool_t AliMCEventHandler::BeginEvent(Long64_t entry)
        }
        fMCEvent->InitEvent();
     }
+    
+    if (fPreReadMode == kLmPreRead) {
+       fMCEvent->PreReadAll();
+    }
+
     return result;
     
 }
index 8fa8cc4d6d3fc1852d6072dbc4f904230a3961ae..b86f0bf736f9906e2d931b2dd8cbeb61950ee99e 100644 (file)
@@ -35,6 +35,9 @@ class AliMCEvent;
 class AliMCEventHandler : public AliVEventHandler
 {
 public:
+
+    enum PreReadMode_t {kNoPreRead = 0, kLmPreRead = 1, kHmPreRead = 2};
+
     AliMCEventHandler();
     AliMCEventHandler(const char* name, const char* title);
     virtual ~AliMCEventHandler();
@@ -57,6 +60,7 @@ public:
     virtual void         SetReadTR(Bool_t flag) { fReadTR = flag; }
     virtual void         AddSubsidiaryHandler(AliMCEventHandler* handler);
     virtual void         SetNumberOfEventsInContainer(Int_t nev) {fEventsInContainer = nev;}
+    virtual void         SetPreReadMode(PreReadMode_t mode) {fPreReadMode = mode;}
     //
     AliMCEvent* MCEvent() const {return fMCEvent;} 
     TTree*      TreeTR()  const {return fTreeTR;}
@@ -96,7 +100,9 @@ private:
     Bool_t                 fReadTR;             // determines if TR shall be read
     Bool_t                 fInitOk;             // Initialization ok
     TList                 *fSubsidiaryHandlers; //! List of subsidiary MC handlers (for example for Background)
-    Int_t                  fEventsInContainer;  //! Number of events in container class 
+    Int_t                  fEventsInContainer;  //! Number of events in container class
+    PreReadMode_t          fPreReadMode;        //! Pre reading mode
+    
     ClassDef(AliMCEventHandler,1)  //MC Truth EventHandler class
 };
 #endif