1 #include "AliPool.h.txt"
3 // ===================================================================
5 // ===================================================================
9 KiddiePool::~KiddiePool()
11 while (!fEvents.empty()) {
12 MiniEvent* fe= fEvents.front();
20 KiddiePool::PrintInfo() const
22 cout << Form("%20s: %d events", "Pool capacity", fMixDepth) << endl;
23 cout << Form("%20s: %d events, %d tracks", "Current size",
24 GetCurrentNEvents(), NTracksInPool()) << endl;
25 cout << Form("%20s: %.1f to %.1f", "Sub-event mult.", fMultMin, fMultMax) << endl;
26 cout << Form("%20s: %.1f to %.1f", "Z-vtx range", fZvtxMin, fZvtxMax) << endl;
32 KiddiePool::EventMatchesBin(Int_t mult, Double_t zvtx) const
34 return EventMatchesBin((Double_t) mult, zvtx);
38 KiddiePool::EventMatchesBin(Double_t mult, Double_t zvtx) const
40 // Lower bin limit included; upper limit excluded.
42 Bool_t multOK = (mult >= fMultMin && mult < fMultMax);
43 Bool_t zvtxOK = (zvtx >= fZvtxMin && zvtx < fZvtxMax);
44 return (multOK && zvtxOK);
48 KiddiePool::NTracksInPool() const
50 // Number of tracks for this cent, zvtx bin; possibly includes many events.
53 for (Int_t i=0; i<(Int_t)fEvents.size(); ++i) {
54 ntrk += fNTracksInEvent.at(i);
60 KiddiePool::SetEventMultRange(Int_t multMin, Int_t multMax)
62 fMultMin = (Double_t)multMin;
63 fMultMax = (Double_t)multMax;
68 KiddiePool::SetEventMultRange(Double_t multMin, Double_t multMax)
76 KiddiePool::SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax)
84 KiddiePool::GlobalEventIndex(Int_t j) const
86 // Index returned from passing local pool event index.
88 if (j < 0 || j >= (Int_t)fEventIndex.size()) {
89 cout << "ERROR in KiddiePool::GlobalEventIndex(): "
90 << " Invalid index " << j << endl;
93 return fEventIndex.at(j);
97 KiddiePool::UpdatePool(MiniEvent* miniEvt)
99 // A rolling buffer (a double-ended queue) is updated by removing
100 // the oldest event, and appending the newest.
102 static Int_t iEvent = -1;
105 Int_t mult = miniEvt->size(); // # tracks in this (mini) event
106 Int_t nTrk = NTracksInPool();
108 if (nTrk < fTargetTrackDepth && ((nTrk + mult) >= fTargetTrackDepth))
111 // remove 0th element before appending this event
112 Bool_t removeFirstEvent = 0;
113 if (nTrk>fTargetTrackDepth) {
114 Int_t nTrksFirstEvent= fNTracksInEvent.front();
115 Int_t diff = nTrk - nTrksFirstEvent + mult;
116 if (diff>fTargetTrackDepth)
117 removeFirstEvent = 1;
119 if (removeFirstEvent) {
120 MiniEvent* oldestEvent = fEvents.front();
122 fEvents.pop_front(); // remove first track array
123 fNTracksInEvent.pop_front(); // remove first int
124 fEventIndex.pop_front();
127 fNTracksInEvent.push_back(mult);
128 fEvents.push_back(miniEvt);
129 fEventIndex.push_back(iEvent);
132 fFirstFilled = kTRUE;
133 if (KiddiePool::fDebug) {
134 cout << "\nPool " << MultBinIndex() << ", " << ZvtxBinIndex()
135 << " ready at event "<< iEvent;
139 fNTimes++; // See this message exactly once/pool
141 fFirstFilled = kFALSE;
146 if (KiddiePool::fDebug) {
147 cout << " Event " << fEventIndex.back();
148 cout << " PoolDepth = " << GetCurrentNEvents();
149 cout << " NTracksInCurrentEvent = " << " " << mult << endl;
152 return fEvents.size();
156 KiddiePool::GetEvent(Int_t i) const
158 if (i<0 || i>=(Int_t)fEvents.size()) {
159 cout << "KiddiePool::GetEvent("
160 << i << "): Invalid index" << endl;
164 MiniEvent* ev = fEvents.at(i);
169 KiddiePool::NTracksInEvent(Int_t iEvent) const
171 // Return number of tracks in iEvent, which is the local pool index.
174 Int_t curEvent = fEventIndex.back();
175 Int_t offset = curEvent - iEvent;
176 Int_t pos = fEventIndex.size() - offset - 1;
179 n = fNTracksInEvent.back();
180 else if (offset < 0 || iEvent < 0) {
183 else if (offset > 0 && offset <= (int)fEventIndex.size()) {
184 n = fNTracksInEvent.at(pos);
187 cout << "Event info no longer in memory" << endl;
191 // ===================================================================
193 // ===================================================================
196 ClassImp(KiddiePoolManager)
198 KiddiePoolManager::KiddiePoolManager(Int_t depth, Int_t minNTracks,
199 Int_t nMultBins, Double_t *multbins,
200 Int_t nZvtxBins, Double_t *zvtxbins)
201 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fEvPool(0), fTargetTrackDepth(minNTracks)
205 InitEventPools(depth, nMultBins, multbins, nZvtxBins, zvtxbins);
206 cout << "KiddiePoolManager initialized." << endl;
209 KiddiePoolManager::~KiddiePoolManager()
211 for (Int_t iM=0; iM<fNMultBins; iM++) {
212 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
213 KiddiePool* pool = fEvPool.at(iM).at(iZ);
219 Int_t KiddiePoolManager::InitEventPools(Int_t depth,
220 Int_t nMultBins, Double_t *multbin,
221 Int_t nZvtxBins, Double_t *zvtxbin)
223 // Assign KiddiePoolManager members.
225 fNMultBins = nMultBins;
226 fNZvtxBins = nZvtxBins;
228 for (Int_t iM=0; iM<fNMultBins; iM++) {
229 std::vector<KiddiePool*> evp;
230 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
231 evp.push_back(new KiddiePool(depth,
232 multbin[iM], multbin[iM+1],
233 zvtxbin[iZ], zvtxbin[iZ+1] ));
235 fEvPool.push_back(evp);
238 for (Int_t iM=0; iM<nMultBins; iM++) {
239 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
240 fEvPool.at(iM).at(iZ)->SetMultBinIndex(iM);
241 fEvPool.at(iM).at(iZ)->SetZvtxBinIndex(iZ);
242 fEvPool.at(iM).at(iZ)->SetTargetTrackDepth(fTargetTrackDepth);
243 fEvPool.at(iM).at(iZ)->SetDebug(fDebug);
248 cout << "fEvPool outer size: " << fEvPool.size() << endl;
249 for (Int_t iM=0; iM<nMultBins; iM++) {
250 for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
251 if(fEvPool.at(iM).at(iZ)) {
252 cout << "multiplicity bin: " << iM;
253 cout << ", z-vertex bin: " << iZ;
254 fEvPool.at(iM).at(iZ)->PrintInfo();
260 return fEvPool.size();
264 KiddiePoolManager::GetEventPool(Int_t iMult, Int_t iZvtx) const
266 if (iMult < 0 || iMult >= fNMultBins)
268 if (iZvtx < 0 || iZvtx >= fNZvtxBins)
270 return fEvPool.at(iMult).at(iZvtx);
274 KiddiePoolManager::GetEventPool(Int_t centVal, Double_t zVtxVal) const
276 return GetEventPool((Double_t)centVal, zVtxVal);
280 KiddiePoolManager::GetEventPool(Double_t centVal, Double_t zVtxVal) const
282 // Return appropriate pool for this centrality and z-vertex value.
284 for (Int_t iM=0; iM<fNMultBins; iM++) {
285 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
286 KiddiePool* pool = GetEventPool(iM, iZ);
287 if (pool->EventMatchesBin(centVal, zVtxVal))
295 KiddiePoolManager::UpdatePools(MiniEvent* miniEvt)
297 // Call UpdatePool for all bins.
299 for (Int_t iM=0; iM<fNMultBins; iM++) {
300 for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
301 if (fEvPool.at(iM).at(iZ)->UpdatePool(miniEvt) > -1)