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 "AliEventPool.h"
26 #include "AliAODEvent.h"
28 #include <TObjArray.h>
32 ClassImp(AliMultiAODInputHandler)
34 //______________________________________________________________________________
35 AliMultiAODInputHandler::AliMultiAODInputHandler(Int_t size) :
36 AliInputEventHandler(),
42 fEventBuffer(new AliAODEvent*[size])
44 // Default constructor
45 for (Int_t i = 0; i < size; i++)
46 fEventBuffer[i] = new AliAODEvent();
49 //______________________________________________________________________________
50 AliMultiAODInputHandler::AliMultiAODInputHandler(const char* name, const char* title, Int_t size):
51 AliInputEventHandler(name, title),
57 fEventBuffer(new AliAODEvent*[size])
60 for (Int_t i = 0; i < size; i++)
61 fEventBuffer[i] = new AliAODEvent();
64 //______________________________________________________________________________
65 AliMultiAODInputHandler::~AliMultiAODInputHandler()
70 Bool_t AliMultiAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
72 // Initialisation necessary for each new tree
74 if (!fTree) return kFALSE;
75 // Get pointer to AOD event
76 fEventBuffer[0]->ReadFromTree(fTree);
82 Bool_t AliMultiAODInputHandler::FinishEvent()
85 // Connect the next event in the buffer to the tree
88 if (fNBuffered > fBufferSize) fNBuffered = fBufferSize;
90 fIndex %= fBufferSize;
91 AliInfo(Form("Connecting buffer entry %5d", fIndex));
92 fEventBuffer[fIndex]->Clear();
93 fEventBuffer[fIndex]->ReadFromTree(fTree, "reconnect");
98 AliAODEvent* AliMultiAODInputHandler::GetEvent(Int_t iev) const
100 // Get event number iev from buffer
101 if ((iev < 0) || (iev >= fBufferSize))
103 AliWarning(Form("Event number out of range: %10d", iev));
107 iev = fIndex - (fBufferSize - 1 - iev);
108 if (iev < 0) iev += fBufferSize;
109 AliInfo(Form("Event index in buffer is %5d", iev));
110 return (fEventBuffer[iev]);