]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMultiAODInputHandler.cxx
Fix fixed-string length bug
[u/mrichter/AliRoot.git] / STEER / AliMultiAODInputHandler.cxx
CommitLineData
4338f373 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// Event handler for AOD input.
20// This class handles multiple inputs for event mixing.
21// Author: Andreas Morsch, CERN
22//-------------------------------------------------------------------------
23
24#include "AliMultiAODInputHandler.h"
25//#include "AliEventPool.h"
26#include "AliAODEvent.h"
27#include "AliLog.h"
28#include <TObjArray.h>
29#include <TTree.h>
30
31
32ClassImp(AliMultiAODInputHandler)
33
34//______________________________________________________________________________
35AliMultiAODInputHandler::AliMultiAODInputHandler(Int_t size) :
36 AliInputEventHandler(),
37 fBufferSize(size),
38 fNBuffered(0),
39 fIndex(0),
40 fTree(0),
41 fEventPool(0),
42 fEventBuffer(new AliAODEvent*[size])
43{
44 // Default constructor
45 for (Int_t i = 0; i < size; i++)
46 fEventBuffer[i] = new AliAODEvent();
47}
48
49//______________________________________________________________________________
50AliMultiAODInputHandler::AliMultiAODInputHandler(const char* name, const char* title, Int_t size):
51 AliInputEventHandler(name, title),
52 fBufferSize(size),
53 fNBuffered(0),
54 fIndex(0),
55 fTree(0),
56 fEventPool(0),
57 fEventBuffer(new AliAODEvent*[size])
58{
59 // Constructor
60 for (Int_t i = 0; i < size; i++)
61 fEventBuffer[i] = new AliAODEvent();
62}
63
64//______________________________________________________________________________
65AliMultiAODInputHandler::~AliMultiAODInputHandler()
66{
67// Destructor
68}
69
70Bool_t AliMultiAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
71{
72 // Initialisation necessary for each new tree
73 fTree = tree;
74 if (!fTree) return kFALSE;
75 // Get pointer to AOD event
76 fEventBuffer[0]->ReadFromTree(fTree);
77 fIndex = 0;
78 fNBuffered = 1;
79 return kTRUE;
80}
81
82Bool_t AliMultiAODInputHandler::FinishEvent()
83{
84 //
85 // Connect the next event in the buffer to the tree
86 fIndex++;
87 fNBuffered++;
88 if (fNBuffered > fBufferSize) fNBuffered = fBufferSize;
89
90 fIndex %= fBufferSize;
91 AliInfo(Form("Connecting buffer entry %5d", fIndex));
92 fEventBuffer[fIndex]->Clear();
93 fEventBuffer[fIndex]->ReadFromTree(fTree, "reconnect");
94 return (kTRUE);
95}
96
97
c9f05157 98AliAODEvent* AliMultiAODInputHandler::GetEvent(Int_t iev) const
4338f373 99{
100 // Get event number iev from buffer
101 if ((iev < 0) || (iev >= fBufferSize))
102 {
103 AliWarning(Form("Event number out of range: %10d", iev));
104 return 0;
105 }
106
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]);
111}
112