1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Event handler for AOD input.
20 // This class handles multiple inputs for event mixing.
21 // Author: Andreas Morsch, CERN
22 //-------------------------------------------------------------------------
24 #include "AliMultiAODInputHandler.h"
25 #include "AliAODEvent.h"
26 #include "AliVEventPool.h"
28 #include <TObjArray.h>
32 ClassImp(AliMultiAODInputHandler)
34 AliMultiAODInputHandler::AliMultiAODInputHandler() :
35 AliInputEventHandler(),
44 // Default constructor
47 //______________________________________________________________________________
48 AliMultiAODInputHandler::AliMultiAODInputHandler(Int_t size) :
49 AliInputEventHandler(),
56 fEventBuffer(new AliAODEvent*[size])
58 // Default constructor
59 for (Int_t i = 0; i < size; i++)
60 fEventBuffer[i] = new AliAODEvent();
63 //______________________________________________________________________________
64 AliMultiAODInputHandler::AliMultiAODInputHandler(const char* name, const char* title, Int_t size):
65 AliInputEventHandler(name, title),
72 fEventBuffer(new AliAODEvent*[size])
75 for (Int_t i = 0; i < size; i++)
76 fEventBuffer[i] = new AliAODEvent();
79 //______________________________________________________________________________
80 AliMultiAODInputHandler::~AliMultiAODInputHandler()
85 Bool_t AliMultiAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
87 // Initialisation necessary for each new tree
89 if (!fTree) return kFALSE;
90 // Get pointer to AOD event
91 fEventBuffer[0]->ReadFromTree(fTree);
97 Bool_t AliMultiAODInputHandler::BeginEvent(Long64_t /*entry*/)
99 // Actions before analysis of each event
101 // Reset the number of events buffered for this bin to 0
102 if (fCurrentBin != (fEventPool->BinNumber())) {
103 fCurrentBin = fEventPool->BinNumber();
109 Bool_t AliMultiAODInputHandler::FinishEvent()
112 // Connect the next event in the buffer to the tree
115 fIndex %= fBufferSize;
116 AliInfo(Form("Connecting buffer entry %5d", fIndex));
118 fEventBuffer[fIndex]->ReadFromTree(fTree, "reconnect");
121 if (fNBuffered > fBufferSize) fNBuffered = fBufferSize;
127 AliAODEvent* AliMultiAODInputHandler::GetEvent(Int_t iev) const
129 // Get event number iev from buffer
130 if ((iev < 0) || (iev >= fBufferSize))
132 AliWarning(Form("Event number out of range: %10d", iev));
136 iev = fIndex - (fBufferSize - 1 - iev);
137 if (iev < 0) iev += fBufferSize;
138 AliInfo(Form("Event index in buffer is %5d", iev));
139 return (fEventBuffer[iev]);