3 // ===================================================================
5 // ===================================================================
12 AliEvtPool::~AliEvtPool()
14 while (!fEvents.empty()) {
15 MiniEvent* fe= fEvents.front();
23 AliEvtPool::PrintInfo() const
25 cout << Form("%20s: %d events", "Pool capacity", fMixDepth) << endl;
26 cout << Form("%20s: %d events, %d tracks", "Current size",
27 GetCurrentNEvents(), NTracksInPool()) << endl;
28 cout << Form("%20s: %.1f to %.1f", "Sub-event mult.", fMultMin, fMultMax) << endl;
29 cout << Form("%20s: %.1f to %.1f", "Z-vtx range", fZvtxMin, fZvtxMax) << endl;
35 AliEvtPool::EventMatchesBin(Int_t mult, Double_t zvtx) const
37 return EventMatchesBin((Double_t) mult, zvtx);
41 AliEvtPool::EventMatchesBin(Double_t mult, Double_t zvtx) const
43 // Lower bin limit included; upper limit excluded.
45 Bool_t multOK = (mult >= fMultMin && mult < fMultMax);
46 Bool_t zvtxOK = (zvtx >= fZvtxMin && zvtx < fZvtxMax);
47 return (multOK && zvtxOK);
51 AliEvtPool::NTracksInPool() const
53 // Number of tracks for this cent, zvtx bin; possibly includes many events.
56 for (Int_t i=0; i<(Int_t)fEvents.size(); ++i) {
57 ntrk += fNTracksInEvent.at(i);
63 AliEvtPool::SetEventMultRange(Int_t multMin, Int_t multMax)
65 fMultMin = (Double_t)multMin;
66 fMultMax = (Double_t)multMax;
71 AliEvtPool::SetEventMultRange(Double_t multMin, Double_t multMax)
79 AliEvtPool::SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax)
87 AliEvtPool::GlobalEventIndex(Int_t j) const
89 // Index returned from passing local pool event index.
91 if (j < 0 || j >= (Int_t)fEventIndex.size()) {
92 cout << "ERROR in AliEvtPool::GlobalEventIndex(): "
93 << " Invalid index " << j << endl;
96 return fEventIndex.at(j);
100 AliEvtPool::UpdatePool(MiniEvent* miniEvt)
102 // A rolling buffer (a double-ended queue) is updated by removing
103 // the oldest event, and appending the newest.
105 static Int_t iEvent = -1;
108 Int_t mult = miniEvt->size(); // # tracks in this (mini) event
109 Int_t nTrk = NTracksInPool();
111 if (nTrk < fTargetTrackDepth && ((nTrk + mult) >= fTargetTrackDepth))
114 // remove 0th element before appending this event
115 Bool_t removeFirstEvent = 0;
116 if (nTrk>fTargetTrackDepth) {
117 Int_t nTrksFirstEvent= fNTracksInEvent.front();
118 Int_t diff = nTrk - nTrksFirstEvent + mult;
119 if (diff>fTargetTrackDepth)
120 removeFirstEvent = 1;
122 if (removeFirstEvent) {
123 MiniEvent* oldestEvent = fEvents.front();
124 oldestEvent->clear();
126 fEvents.pop_front(); // remove first track array
127 fNTracksInEvent.pop_front(); // remove first int
128 fEventIndex.pop_front();
131 fNTracksInEvent.push_back(mult);
132 fEvents.push_back(miniEvt);
133 fEventIndex.push_back(iEvent);
136 fFirstFilled = kTRUE;
137 if (AliEvtPool::fDebug) {
138 cout << "\nPool " << MultBinIndex() << ", " << ZvtxBinIndex()
139 << " ready at event "<< iEvent;
143 fNTimes++; // See this message exactly once/pool
145 fFirstFilled = kFALSE;
150 if (AliEvtPool::fDebug) {
151 cout << " Event " << fEventIndex.back();
152 cout << " PoolDepth = " << GetCurrentNEvents();
153 cout << " NTracksInCurrentEvent = " << " " << mult << endl;
156 return fEvents.size();
160 AliEvtPool::GetEvent(Int_t i) const
162 if (i<0 || i>=(Int_t)fEvents.size()) {
163 cout << "AliEvtPool::GetEvent("
164 << i << "): Invalid index" << endl;
168 MiniEvent* ev = fEvents.at(i);
173 AliEvtPool::NTracksInEvent(Int_t iEvent) const
175 // Return number of tracks in iEvent, which is the local pool index.
178 Int_t curEvent = fEventIndex.back();
179 Int_t offset = curEvent - iEvent;
180 Int_t pos = fEventIndex.size() - offset - 1;
183 n = fNTracksInEvent.back();
184 else if (offset < 0 || iEvent < 0) {
187 else if (offset > 0 && offset <= (int)fEventIndex.size()) {
188 n = fNTracksInEvent.at(pos);
191 cout << "Event info no longer in memory" << endl;
195 // ===================================================================
197 // ===================================================================
200 ClassImp(AliEvtPoolManager)
202 AliEvtPoolManager::AliEvtPoolManager(Int_t depth, Int_t minNTracks,
203 Int_t nMultBins, Double_t *multbins,
204 Int_t nZvtxBins, Double_t *zvtxbins)
205 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fEvPool(0), fTargetTrackDepth(minNTracks)
209 InitEventPools(depth, nMultBins, multbins, nZvtxBins, zvtxbins);
210 cout << "AliEvtPoolManager initialized." << endl;
213 AliEvtPoolManager::~AliEvtPoolManager()
215 for (Int_t iM=0; iM<fNMultBins; iM++) {
216 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
217 AliEvtPool* pool = fEvPool.at(iM).at(iZ);
223 Int_t AliEvtPoolManager::InitEventPools(Int_t depth,
224 Int_t nMultBins, Double_t *multbin,
225 Int_t nZvtxBins, Double_t *zvtxbin)
227 // Assign AliEvtPoolManager members.
229 fNMultBins = nMultBins;
230 fNZvtxBins = nZvtxBins;
232 for (Int_t iM=0; iM<fNMultBins; iM++) {
233 std::vector<AliEvtPool*> evp;
234 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
235 evp.push_back(new AliEvtPool(depth,
236 multbin[iM], multbin[iM+1],
237 zvtxbin[iZ], zvtxbin[iZ+1] ));
239 fEvPool.push_back(evp);
242 for (Int_t iM=0; iM<nMultBins; iM++) {
243 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
244 fEvPool.at(iM).at(iZ)->SetMultBinIndex(iM);
245 fEvPool.at(iM).at(iZ)->SetZvtxBinIndex(iZ);
246 fEvPool.at(iM).at(iZ)->SetTargetTrackDepth(fTargetTrackDepth);
247 fEvPool.at(iM).at(iZ)->SetDebug(fDebug);
252 cout << "fEvPool outer size: " << fEvPool.size() << endl;
253 for (Int_t iM=0; iM<nMultBins; iM++) {
254 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
255 if(fEvPool.at(iM).at(iZ)) {
256 cout << "multiplicity bin: " << iM;
257 cout << ", z-vertex bin: " << iZ;
258 fEvPool.at(iM).at(iZ)->PrintInfo();
264 return fEvPool.size();
268 AliEvtPoolManager::GetEventPool(Int_t iMult, Int_t iZvtx) const
270 if (iMult < 0 || iMult >= fNMultBins)
272 if (iZvtx < 0 || iZvtx >= fNZvtxBins)
274 return fEvPool.at(iMult).at(iZvtx);
278 AliEvtPoolManager::GetEventPool(Int_t centVal, Double_t zVtxVal) const
280 return GetEventPool((Double_t)centVal, zVtxVal);
284 AliEvtPoolManager::GetEventPool(Double_t centVal, Double_t zVtxVal) const
286 // Return appropriate pool for this centrality and z-vertex value.
288 for (Int_t iM=0; iM<fNMultBins; iM++) {
289 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
290 AliEvtPool* pool = GetEventPool(iM, iZ);
291 if (pool->EventMatchesBin(centVal, zVtxVal))
299 AliEvtPoolManager::UpdatePools(MiniEvent* miniEvt)
301 // Call UpdatePool for all bins.
303 for (Int_t iM=0; iM<fNMultBins; iM++) {
304 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
305 if (fEvPool.at(iM).at(iZ)->UpdatePool(miniEvt) > -1)