From 379713ada903f539cd4ecd3a8a01d7de40349f79 Mon Sep 17 00:00:00 2001 From: morsch Date: Thu, 13 Jan 2011 15:33:12 +0000 Subject: [PATCH] Cleanup of name confusion in 44819 Missing files added. --- ANALYSIS/AliMultiEventInputHandler.cxx | 2 - ANALYSIS/AliMultiInputEventHandler.cxx | 248 +++++++++++++++++++++++++ ANALYSIS/AliMultiInputEventHandler.h | 57 ++++++ 3 files changed, 305 insertions(+), 2 deletions(-) create mode 100644 ANALYSIS/AliMultiInputEventHandler.cxx create mode 100644 ANALYSIS/AliMultiInputEventHandler.h diff --git a/ANALYSIS/AliMultiEventInputHandler.cxx b/ANALYSIS/AliMultiEventInputHandler.cxx index 8985e255063..7a2fb658840 100644 --- a/ANALYSIS/AliMultiEventInputHandler.cxx +++ b/ANALYSIS/AliMultiEventInputHandler.cxx @@ -144,8 +144,6 @@ Bool_t AliMultiEventInputHandler::BeginEvent(Long64_t /*entry*/) // Actions before analysis of each event // // Reset the number of events buffered for this bin to 0 - printf("BeginEvent %5d %5d \n", - fCurrentBin, fEventPool->BinNumber()); if (fCurrentBin != (fEventPool->BinNumber())) { fCurrentBin = fEventPool->BinNumber(); diff --git a/ANALYSIS/AliMultiInputEventHandler.cxx b/ANALYSIS/AliMultiInputEventHandler.cxx new file mode 100644 index 00000000000..5ac395ad325 --- /dev/null +++ b/ANALYSIS/AliMultiInputEventHandler.cxx @@ -0,0 +1,248 @@ +// +// Class AliMultiInputEventHandler +// +// Multi input event handler +// TODO example +// author: +// Martin Vala (martin.vala@cern.ch) +// + +#include "AliLog.h" +#include "AliMCEventHandler.h" + +#include "AliMultiInputEventHandler.h" + +ClassImp(AliMultiInputEventHandler) + +static Option_t *gCurrentMultiDataType = "ESD"; + +//_____________________________________________________________________________ +AliMultiInputEventHandler::AliMultiInputEventHandler(const Int_t size, const char *name) : + AliInputEventHandler(name, name), + fBufferSize(size), + fInputHandlers(), + fAnalysisType(0) +{ +// +// Default constructor. +// + AliDebug(AliLog::kDebug + 10, "<-"); + fInputHandlers.SetOwner(kTRUE); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +AliMultiInputEventHandler::~AliMultiInputEventHandler() +{ + // + // Destructor + // + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + + +//_____________________________________________________________________________ +AliVEventHandler *AliMultiInputEventHandler::InputEventHandler(const Int_t index) +{ + // + // Returns input handler + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + if ((index >= 0) && (index < fBufferSize)) { + return (AliVEventHandler *) fInputHandlers.At(index); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return 0; +} + +//_____________________________________________________________________________ +void AliMultiInputEventHandler::AddInputEventHandler(AliVEventHandler*inHandler) +{ + // + // Create N (fBufferSize) copies of input handler + // + if (inHandler->InheritsFrom("AliESDInputHandler")) gCurrentMultiDataType = "ESD"; + if (inHandler->InheritsFrom("AliAODInputHandler")) gCurrentMultiDataType = "AOD"; + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliDebug(AliLog::kDebug + 5, Form("Creating %d input event handlers ...", fBufferSize)); + AliDebug(AliLog::kDebug + 5, Form("Adding input handler with index %d ...", fBufferSize)); + fInputHandlers.Add(inHandler); + fBufferSize++; + AliDebug(AliLog::kDebug + 5, Form("->")); +} + +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::Init(Option_t *opt) +{ + // + // Init() is called for all mix input handlers. + // + fAnalysisType = opt; + AliDebug(AliLog::kDebug + 5, Form("<- \"%s\"", opt)); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->Init(fAnalysisType); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::Init(opt); +} +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::Init(TTree *tree, Option_t *opt) +{ + // + // Init(const char*path) is called for all mix input handlers. + // Create event pool if needed + // + fAnalysisType = opt; + AliDebug(AliLog::kDebug + 5, Form("<- %p %s", (void *) tree, tree->GetName())); + if (!tree) { + AliError(Form("-> tree is null")); + return kFALSE; + } + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->Init(tree, fAnalysisType); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::Init(tree, opt); +} +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::Notify() +{ + // + // Notify() is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->Notify(); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::Notify(); +} + +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::Notify(const char *path) +{ + // + // Notify(const char*path) is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<- %s", path)); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->Notify(path); + } + AliDebug(AliLog::kDebug + 5, Form("->")); +// return AliInputEventHandler::Notify(path); + return AliInputEventHandler::Notify(path); +} +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::BeginEvent(Long64_t entry) +{ + // + // BeginEvent(Long64_t entry) is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry)); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->BeginEvent(entry); + } + GetEntry(); + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::BeginEvent(entry); +} + + +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::GetEntry() +{ + // + // Sets correct events to every mix events + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->GetEntry(); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::GetEntry(); +} +//_____________________________________________________________________________ +Bool_t AliMultiInputEventHandler::FinishEvent() +{ + // + // FinishEvent() is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliInputEventHandler *eh = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliInputEventHandler *) next())) { + eh->FinishEvent(); + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return AliInputEventHandler::FinishEvent(); +} + +AliInputEventHandler *AliMultiInputEventHandler::GetFirstInputEventHandler() +{ + // + // Return first InputEventHandler + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliVEventHandler *eh = 0; + AliInputEventHandler *handler = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliVEventHandler *) next())) { + handler = dynamic_cast(eh); + if (handler) return handler; + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return 0; +} +AliMCEventHandler *AliMultiInputEventHandler::GetFirstMCEventHandler() +{ + // + // Return first MCEventHandler + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliVEventHandler *eh = 0; + AliMCEventHandler *handler = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliVEventHandler *) next())) { + handler = dynamic_cast(eh); + if (handler) return handler; + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return 0; +} + +AliMultiInputEventHandler *AliMultiInputEventHandler::GetFirstMultiInputHandler() +{ + // + // Return first MultiInputHandler + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliVEventHandler *eh = 0; + AliMultiInputEventHandler *handler = 0; + TObjArrayIter next(&fInputHandlers); + while ((eh = (AliVEventHandler *) next())) { + handler = dynamic_cast(eh); + if (handler) return handler; + } + AliDebug(AliLog::kDebug + 5, Form("->")); + return 0; +} + +//______________________________________________________________________________ +Option_t *AliMultiInputEventHandler::GetDataType() const +{ + // Returns handled data type. + return gCurrentMultiDataType; +} diff --git a/ANALYSIS/AliMultiInputEventHandler.h b/ANALYSIS/AliMultiInputEventHandler.h new file mode 100644 index 00000000000..9463569577f --- /dev/null +++ b/ANALYSIS/AliMultiInputEventHandler.h @@ -0,0 +1,57 @@ +// +// Class AliMultiInputEventHandler +// +// Multi input event handler +// TODO example +// author: +// Martin Vala (martin.vala@cern.ch) +// + +#ifndef ALIMULTIINPUTEVENTHANDLER_H +#define ALIMULTIINPUTEVENTHANDLER_H + +#include + +#include "AliInputEventHandler.h" + +class AliMCEventHandler; +class AliMultiInputEventHandler : public AliInputEventHandler { + +public: + AliMultiInputEventHandler(const Int_t size = 0, const char *name = "name"); + virtual ~AliMultiInputEventHandler(); + + // From the interface + virtual Bool_t Init(Option_t *opt); + virtual Bool_t Init(TTree *tree, Option_t *opt); + virtual Bool_t BeginEvent(Long64_t entry); + virtual Bool_t GetEntry(); + virtual Bool_t FinishEvent(); + virtual Bool_t Notify(); + virtual Bool_t Notify(const char *path); + + // add input handler + virtual void AddInputEventHandler(AliVEventHandler*inHandler); + AliVEventHandler *InputEventHandler(const Int_t index); + Int_t BufferSize() const { return fBufferSize; } + TObjArray *InputEventHandlers() { return &fInputHandlers; } + + AliInputEventHandler *GetFirstInputEventHandler(); + AliMCEventHandler *GetFirstMCEventHandler(); + AliMultiInputEventHandler *GetFirstMultiInputHandler(); + + Option_t *GetDataType() const; + +protected: + + Int_t fBufferSize; // Size of the buffer + TObjArray fInputHandlers; // buffer of input handlers + Option_t *fAnalysisType; //! local, proof, grid +private: + AliMultiInputEventHandler(const AliMultiInputEventHandler& handler); + AliMultiInputEventHandler &operator=(const AliMultiInputEventHandler &handler); + + ClassDef(AliMultiInputEventHandler, 1) +}; + +#endif -- 2.39.3