]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliMultiAODInputHandler.cxx
Fixes for bug #52499: Field polarities inconsistiency
[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"
4338f373 25#include "AliAODEvent.h"
7de026d8 26#include "AliVEventPool.h"
4338f373 27#include "AliLog.h"
28#include <TObjArray.h>
29#include <TTree.h>
30
31
32ClassImp(AliMultiAODInputHandler)
33
7de026d8 34AliMultiAODInputHandler::AliMultiAODInputHandler() :
35 AliInputEventHandler(),
36 fBufferSize(0),
37 fNBuffered(0),
38 fIndex(0),
39 fCurrentBin(0),
40 fTree(0),
41 fEventPool(0),
42 fEventBuffer(0)
43{
44 // Default constructor
45}
46
4338f373 47//______________________________________________________________________________
48AliMultiAODInputHandler::AliMultiAODInputHandler(Int_t size) :
49 AliInputEventHandler(),
50 fBufferSize(size),
51 fNBuffered(0),
52 fIndex(0),
7de026d8 53 fCurrentBin(0),
4338f373 54 fTree(0),
55 fEventPool(0),
56 fEventBuffer(new AliAODEvent*[size])
57{
58 // Default constructor
59 for (Int_t i = 0; i < size; i++)
60 fEventBuffer[i] = new AliAODEvent();
61}
62
63//______________________________________________________________________________
64AliMultiAODInputHandler::AliMultiAODInputHandler(const char* name, const char* title, Int_t size):
65 AliInputEventHandler(name, title),
66 fBufferSize(size),
67 fNBuffered(0),
68 fIndex(0),
7de026d8 69 fCurrentBin(0),
4338f373 70 fTree(0),
71 fEventPool(0),
72 fEventBuffer(new AliAODEvent*[size])
73{
74 // Constructor
75 for (Int_t i = 0; i < size; i++)
76 fEventBuffer[i] = new AliAODEvent();
77}
78
79//______________________________________________________________________________
80AliMultiAODInputHandler::~AliMultiAODInputHandler()
81{
82// Destructor
83}
84
85Bool_t AliMultiAODInputHandler::Init(TTree* tree, Option_t* /*opt*/)
86{
87 // Initialisation necessary for each new tree
88 fTree = tree;
89 if (!fTree) return kFALSE;
90 // Get pointer to AOD event
91 fEventBuffer[0]->ReadFromTree(fTree);
7de026d8 92 fIndex = 0;
4338f373 93 fNBuffered = 1;
94 return kTRUE;
95}
96
7de026d8 97Bool_t AliMultiAODInputHandler::BeginEvent(Long64_t /*entry*/)
98{
99 // Actions before analysis of each event
100 //
101 // Reset the number of events buffered for this bin to 0
102 if (fCurrentBin != (fEventPool->BinNumber())) {
103 fCurrentBin = fEventPool->BinNumber();
104 fNBuffered = 0;
105 }
106 return kTRUE;
107}
108
4338f373 109Bool_t AliMultiAODInputHandler::FinishEvent()
110{
111 //
112 // Connect the next event in the buffer to the tree
113 fIndex++;
4338f373 114
115 fIndex %= fBufferSize;
116 AliInfo(Form("Connecting buffer entry %5d", fIndex));
7de026d8 117
4338f373 118 fEventBuffer[fIndex]->ReadFromTree(fTree, "reconnect");
7de026d8 119
120 fNBuffered++;
121 if (fNBuffered > fBufferSize) fNBuffered = fBufferSize;
122
4338f373 123 return (kTRUE);
124}
125
126
c9f05157 127AliAODEvent* AliMultiAODInputHandler::GetEvent(Int_t iev) const
4338f373 128{
129 // Get event number iev from buffer
130 if ((iev < 0) || (iev >= fBufferSize))
131 {
132 AliWarning(Form("Event number out of range: %10d", iev));
133 return 0;
134 }
135
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]);
140}
141