From 35152e4b3316f27799d35037808315406821d098 Mon Sep 17 00:00:00 2001 From: morsch Date: Wed, 28 Oct 2009 17:08:29 +0000 Subject: [PATCH] PreReading of MC information on demand. --- STEER/AliMCEvent.cxx | 19 +++++++++++++++++++ STEER/AliMCEvent.h | 2 +- STEER/AliMCEventHandler.cxx | 11 +++++++++-- STEER/AliMCEventHandler.h | 8 +++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/STEER/AliMCEvent.cxx b/STEER/AliMCEvent.cxx index e7b687aec4a..526340e03fb 100644 --- a/STEER/AliMCEvent.cxx +++ b/STEER/AliMCEvent.cxx @@ -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) diff --git a/STEER/AliMCEvent.h b/STEER/AliMCEvent.h index aabdae66469..ab584cf4126 100644 --- a/STEER/AliMCEvent.h +++ b/STEER/AliMCEvent.h @@ -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;} diff --git a/STEER/AliMCEventHandler.cxx b/STEER/AliMCEventHandler.cxx index ca1855e9cab..9c37a1dfee5 100644 --- a/STEER/AliMCEventHandler.cxx +++ b/STEER/AliMCEventHandler.cxx @@ -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; } diff --git a/STEER/AliMCEventHandler.h b/STEER/AliMCEventHandler.h index 8fa8cc4d6d3..b86f0bf736f 100644 --- a/STEER/AliMCEventHandler.h +++ b/STEER/AliMCEventHandler.h @@ -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 -- 2.39.3