Line data Source code
1 : #include "AliEventPoolManager.h"
2 : #include "TList.h"
3 : #include "TRandom.h"
4 : #include <iostream>
5 :
6 : using std::cout;
7 : using std::endl;
8 170 : ClassImp(AliEventPool)
9 :
10 : void AliEventPool::PrintInfo() const
11 : {
12 0 : cout << Form("%20s: %d events", "Pool capacity", fMixDepth) << endl;
13 0 : cout << Form("%20s: %d events, %d tracks", "Current size",
14 0 : GetCurrentNEvents(), NTracksInPool()) << endl;
15 0 : cout << Form("%20s: %.1f to %.1f", "Sub-event mult.", fMultMin, fMultMax) << endl;
16 0 : cout << Form("%20s: %.1f to %.1f", "Z-vtx range", fZvtxMin, fZvtxMax) << endl;
17 0 : cout << Form("%20s: %.1f to %.1f", "Psi range", fPsiMin, fPsiMax) << endl;
18 0 : cout << Form("%20s: %.1f to %.1f", "Pt range", fPtMin, fPtMax) << endl;
19 :
20 0 : return;
21 : }
22 :
23 : Bool_t AliEventPool::EventMatchesBin(Int_t mult, Double_t zvtx, Double_t psi, Double_t pt) const
24 : {
25 0 : return EventMatchesBin((Double_t) mult, zvtx, psi, pt);
26 : }
27 :
28 : Bool_t AliEventPool::EventMatchesBin(Double_t mult, Double_t zvtx, Double_t psi, Double_t pt) const
29 : {
30 : // Lower bin limit included; upper limit excluded.
31 :
32 0 : Bool_t multOK = (mult >= fMultMin && mult < fMultMax);
33 0 : Bool_t zvtxOK = (zvtx >= fZvtxMin && zvtx < fZvtxMax);
34 0 : Bool_t psiOK = (psi >= fPsiMin && psi < fPsiMax);
35 0 : Bool_t ptOK = (pt >= fPtMin && pt < fPtMax);
36 :
37 0 : return (multOK && zvtxOK && psiOK && ptOK);
38 : }
39 :
40 : Int_t AliEventPool::NTracksInPool() const
41 : {
42 : // Number of tracks for this cent, zvtx bin; possibly includes many
43 : // events.
44 :
45 : Int_t ntrk=0;
46 0 : for (Int_t i=0; i<(Int_t)fEvents.size(); ++i) {
47 0 : ntrk += fNTracksInEvent.at(i);
48 : }
49 0 : return ntrk;
50 : }
51 :
52 : Int_t AliEventPool::SetEventMultRange(Int_t multMin, Int_t multMax)
53 : {
54 0 : fMultMin = (Double_t)multMin;
55 0 : fMultMax = (Double_t)multMax;
56 0 : return 0;
57 : }
58 :
59 : Int_t AliEventPool::SetEventMultRange(Double_t multMin, Double_t multMax)
60 : {
61 0 : fMultMin = multMin;
62 0 : fMultMax = multMax;
63 0 : return 0;
64 : }
65 :
66 : Int_t AliEventPool::SetEventZvtxRange(Double_t zvtxMin, Double_t zvtxMax)
67 : {
68 0 : fZvtxMin = zvtxMin;
69 0 : fZvtxMax = zvtxMax;
70 0 : return 0;
71 : }
72 :
73 : Int_t AliEventPool::SetEventPsiRange(Double_t psiMin, Double_t psiMax)
74 : {
75 0 : fPsiMin = psiMin;
76 0 : fPsiMax = psiMax;
77 0 : return 0;
78 : }
79 :
80 : Int_t AliEventPool::SetEventPtRange(Double_t ptMin, Double_t ptMax)
81 : {
82 0 : fPtMin = ptMin;
83 0 : fPtMax = ptMax;
84 0 : return 0;
85 : }
86 :
87 : Int_t AliEventPool::GlobalEventIndex(Int_t j) const
88 : {
89 : // Index returned from passing local pool event index.
90 :
91 0 : if (j < 0 || j >= (Int_t)fEventIndex.size()) {
92 0 : cout << "ERROR in AliEventPool::GlobalEventIndex(): "
93 0 : << " Invalid index " << j << endl;
94 0 : return -99;
95 : }
96 0 : return fEventIndex.at(j);
97 0 : }
98 :
99 : Int_t AliEventPool::UpdatePool(TObjArray *trk)
100 : {
101 : // A rolling buffer (a double-ended queue) is updated by removing
102 : // the oldest event, and appending the newest.
103 : //
104 : // the ownership of <trk> is delegated to this class
105 :
106 0 : if(fLockFlag)
107 : {
108 0 : AliFatal("Tried to fill a locked AliEventPool.");
109 0 : return fEvents.size();
110 : }
111 :
112 : static Int_t iEvent = -1;
113 0 : iEvent++;
114 :
115 0 : Int_t mult = trk->GetEntries();
116 0 : Int_t nTrk = NTracksInPool();
117 :
118 0 : if (!IsReady() && IsReady(nTrk + mult, GetCurrentNEvents() + 1))
119 0 : fNTimes++;
120 :
121 : // remove 0th element before appending this event
122 : Bool_t removeFirstEvent = 0;
123 0 : if (nTrk>fTargetTrackDepth) {
124 0 : Int_t nTrksFirstEvent= fNTracksInEvent.front();
125 0 : Int_t diff = nTrk - nTrksFirstEvent + mult;
126 0 : if (diff>fTargetTrackDepth)
127 0 : removeFirstEvent = 1;
128 0 : }
129 0 : if (removeFirstEvent) {
130 0 : TObjArray *fa = fEvents.front();
131 0 : delete fa;
132 0 : fEvents.pop_front(); // remove first track array
133 0 : fNTracksInEvent.pop_front(); // remove first int
134 0 : fEventIndex.pop_front();
135 0 : }
136 :
137 0 : fNTracksInEvent.push_back(mult);
138 0 : fEvents.push_back(trk);
139 0 : fEventIndex.push_back(iEvent);
140 :
141 0 : if (fNTimes==1) {
142 0 : fFirstFilled = kTRUE;
143 0 : if (AliEventPool::fDebug) {
144 0 : cout << "\nPool " << MultBinIndex() << ", " << ZvtxBinIndex()
145 0 : << " ready at event "<< iEvent;
146 0 : PrintInfo();
147 0 : cout << endl;
148 0 : }
149 0 : fNTimes++; // See this message exactly once/pool
150 0 : } else {
151 0 : fFirstFilled = kFALSE;
152 : }
153 :
154 0 : fWasUpdated = true;
155 :
156 0 : if (AliEventPool::fDebug) {
157 0 : cout << " Event " << fEventIndex.back();
158 0 : cout << " PoolDepth = " << GetCurrentNEvents();
159 0 : cout << " NTracksInCurrentEvent = " << NTracksInCurrentEvent();
160 0 : }
161 :
162 0 : return fEvents.size();
163 0 : }
164 :
165 : Long64_t AliEventPool::Merge(TCollection* hlist)
166 : {
167 0 : if (!hlist)
168 0 : return 0;
169 :
170 0 : Bool_t origLock = fLockFlag;
171 0 : fLockFlag = kFALSE; // temporary deactivate lockflag to allow filling
172 : AliEventPool* tmpObj = 0;
173 0 : TIter objIter(hlist);
174 : // Iterate through all objects to be merged
175 0 : while ( (tmpObj = static_cast<AliEventPool*>(objIter())) )
176 : {
177 : // Update this pool (it won't get fuller than demanded)
178 0 : for(Int_t i=0; i<tmpObj->fEvents.size(); i++)
179 0 : UpdatePool(tmpObj->fEvents.at(i));
180 : }
181 0 : fLockFlag = origLock;
182 0 : return hlist->GetEntries() + 1;
183 0 : }
184 :
185 : void AliEventPool::Clear()
186 : {
187 : // Clear the pool without deleting the object
188 : // Don't touch lock or save flag here to be fully flexible
189 0 : fEvents.clear();
190 0 : fNTracksInEvent.clear();
191 0 : fEventIndex.clear();
192 0 : fWasUpdated = 0;
193 0 : fFirstFilled = 0;
194 0 : fWasUpdated = 0;
195 0 : fFirstFilled = 0;
196 0 : fNTimes = 0;
197 0 : }
198 :
199 : TObject* AliEventPool::GetRandomTrack() const
200 : {
201 : // Get any random track from the pool, sampled with uniform probability.
202 :
203 0 : UInt_t ranEvt = gRandom->Integer(fEvents.size());
204 0 : TObjArray *tca = fEvents.at(ranEvt);
205 0 : UInt_t ranTrk = gRandom->Integer(tca->GetEntries());
206 0 : TObject *trk = (TObject*)tca->At(ranTrk);
207 0 : return trk;
208 : }
209 :
210 : TObjArray* AliEventPool::GetEvent(Int_t i) const
211 : {
212 0 : if (i<0 || i>=(Int_t)fEvents.size()) {
213 0 : cout << "AliEventPool::GetEvent("
214 0 : << i << "): Invalid index" << endl;
215 0 : return 0x0;
216 : }
217 :
218 0 : TObjArray *tca = fEvents.at(i);
219 : return tca;
220 0 : }
221 :
222 : TObjArray* AliEventPool::GetRandomEvent() const
223 : {
224 0 : UInt_t ranEvt = gRandom->Integer(fEvents.size());
225 0 : TObjArray *tca = fEvents.at(ranEvt);
226 0 : return tca;
227 : }
228 :
229 : Int_t AliEventPool::NTracksInEvent(Int_t iEvent) const
230 : {
231 : // Return number of tracks in iEvent, which is the local pool index.
232 :
233 : Int_t n = -1;
234 0 : Int_t curEvent = fEventIndex.back();
235 0 : Int_t offset = curEvent - iEvent;
236 0 : Int_t pos = fEventIndex.size() - offset - 1;
237 :
238 0 : if (offset==0)
239 0 : n = fNTracksInEvent.back();
240 0 : else if (offset < 0 || iEvent < 0) {
241 : n = 0;
242 0 : }
243 0 : else if (offset > 0 && offset <= (int)fEventIndex.size()) {
244 0 : n = fNTracksInEvent.at(pos);
245 0 : }
246 : else
247 0 : cout << "Event info no longer in memory" << endl;
248 0 : return n;
249 : }
250 :
251 170 : ClassImp(AliEventPoolManager)
252 :
253 0 : AliEventPoolManager::AliEventPoolManager(Int_t depth, Int_t minNTracks,
254 : Int_t nMultBins, Double_t *multbins,
255 : Int_t nZvtxBins, Double_t *zvtxbins) :
256 0 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fNPsiBins(0), fNPtBins(0), fMultBins(), fZvtxBins(), fPsiBins(), fPtBins(), fEvPool(0), fTargetTrackDepth(minNTracks)
257 0 : {
258 : // Constructor.
259 : // without Event plane bins or pt bins
260 : Int_t nPsiBins = 1;
261 0 : Double_t psibins[2] = {-999.,999.};
262 : Int_t nPtBins = 1;
263 0 : Double_t ptbins[2] = {-9999.,9999.};
264 :
265 0 : InitEventPools(depth, nMultBins, multbins, nZvtxBins, zvtxbins, nPsiBins, psibins, nPtBins, ptbins);
266 0 : cout << "AliEventPoolManager initialized." << endl;
267 0 : }
268 :
269 0 : AliEventPoolManager::AliEventPoolManager(Int_t depth, Int_t minNTracks,
270 : Int_t nMultBins, Double_t *multbins,
271 : Int_t nZvtxBins, Double_t *zvtxbins,
272 : Int_t nPsiBins, Double_t *psibins) :
273 0 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fNPsiBins(0), fNPtBins(0), fMultBins(), fZvtxBins(), fPsiBins(), fPtBins(), fEvPool(0), fTargetTrackDepth(minNTracks)
274 0 : {
275 : // Constructor.
276 : // without pt bins
277 : Int_t nPtBins = 1;
278 0 : Double_t ptbins[2] = {-9999.,9999.};
279 :
280 0 : InitEventPools(depth, nMultBins, multbins, nZvtxBins, zvtxbins, nPsiBins, psibins, nPtBins, ptbins);
281 0 : cout << "AliEventPoolManager initialized." << endl;
282 0 : }
283 :
284 0 : AliEventPoolManager::AliEventPoolManager(Int_t depth, Int_t minNTracks,
285 : Int_t nMultBins, Double_t *multbins,
286 : Int_t nZvtxBins, Double_t *zvtxbins,
287 : Int_t nPsiBins, Double_t *psibins,
288 : Int_t nPtBins, Double_t *ptbins) :
289 0 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fNPsiBins(0), fNPtBins(0), fMultBins(), fZvtxBins(), fPsiBins(), fPtBins(), fEvPool(0), fTargetTrackDepth(minNTracks)
290 0 : {
291 : // Constructor.
292 :
293 0 : InitEventPools(depth, nMultBins, multbins, nZvtxBins, zvtxbins, nPsiBins, psibins, nPtBins, ptbins);
294 0 : cout << "AliEventPoolManager initialized." << endl;
295 0 : }
296 :
297 0 : AliEventPoolManager::AliEventPoolManager(Int_t depth, Int_t minNTracks, const char* binning) :
298 0 : fDebug(0), fNMultBins(0), fNZvtxBins(0), fNPsiBins(0), fNPtBins(0), fMultBins(), fZvtxBins(), fPsiBins(), fPtBins(), fEvPool(0), fTargetTrackDepth(minNTracks)
299 0 : {
300 0 : Double_t psidummy[2] = {-999.,999.};
301 0 : Double_t ptdummy[2] = {-9999.,9999.};
302 :
303 : // Constructor.
304 0 : Double_t* multbins = GetBinning(binning, "multiplicity", fNMultBins);
305 0 : Double_t* zvtxbins = GetBinning(binning, "vertex", fNZvtxBins);
306 :
307 0 : Double_t* psibins = GetBinning(binning, "psi", fNPsiBins); //optional
308 0 : if (!psibins) {
309 0 : psibins = psidummy;
310 0 : fNPsiBins = 1;
311 0 : }
312 :
313 0 : Double_t* ptbins = GetBinning(binning, "pt", fNPtBins); //optional
314 0 : if (!ptbins) {
315 0 : ptbins = ptdummy;
316 0 : fNPtBins = 1;
317 0 : }
318 :
319 0 : InitEventPools(depth, fNMultBins, multbins, fNZvtxBins, zvtxbins, fNPsiBins, psibins, fNPtBins, ptbins);
320 :
321 0 : cout << "AliEventPoolManager initialized." << endl;
322 0 : }
323 :
324 : Int_t AliEventPoolManager::InitEventPools(Int_t depth,
325 : Int_t nMultBins, Double_t *multbin,
326 : Int_t nZvtxBins, Double_t *zvtxbin,
327 : Int_t nPsiBins, Double_t *psibin,
328 : Int_t nPtBins, Double_t *ptbin)
329 : {
330 : // Assign AliEventPoolManager members. (with Event plane + pt)
331 :
332 0 : fNMultBins = nMultBins;
333 0 : fNZvtxBins = nZvtxBins;
334 0 : fNPsiBins = nPsiBins;
335 0 : fNPtBins = nPtBins;
336 :
337 0 : fMultBins.assign(multbin, multbin+nMultBins+1);
338 0 : fZvtxBins.assign(zvtxbin, zvtxbin+nZvtxBins+1);
339 0 : fPsiBins.assign(psibin, psibin+nPsiBins+1);
340 0 : fPtBins.assign(ptbin, ptbin+nPtBins+1);
341 :
342 0 : for (Int_t iM=0; iM<nMultBins; iM++) {
343 0 : for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
344 0 : for (Int_t iP=0; iP<nPsiBins; iP++) {
345 0 : for (Int_t iPt=0; iPt<nPtBins; iPt++) {
346 :
347 0 : fEvPool.push_back(new AliEventPool(depth,
348 0 : multbin[iM], multbin[iM+1],
349 0 : zvtxbin[iZ], zvtxbin[iZ+1],
350 0 : psibin[iP], psibin[iP+1],
351 0 : ptbin[iPt], ptbin[iPt+1] ));
352 : }
353 : }
354 : }
355 : }
356 :
357 :
358 0 : for (Int_t iM=0; iM<nMultBins; iM++) {
359 0 : for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
360 0 : for (Int_t iP=0; iP<nPsiBins; iP++) {
361 0 : for (Int_t iPt=0; iPt<nPtBins; iPt++) {
362 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetMultBinIndex(iM);
363 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetZvtxBinIndex(iZ);
364 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetPsiBinIndex(iP);
365 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetPtBinIndex(iPt);
366 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetTargetTrackDepth(fTargetTrackDepth);
367 : }
368 : }
369 : }
370 : }
371 :
372 : if (0) {
373 : cout << "fEvPool outer size: " << fEvPool.size() << endl;
374 : for (Int_t iM=0; iM<nMultBins; iM++) {
375 : for (Int_t iZ=0; iZ<nZvtxBins; iZ++) {
376 : for (Int_t iP=0; iP<nPsiBins; iP++) {
377 : for (Int_t iPt=0; iPt<nPtBins; iPt++) {
378 : if(fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))) {
379 : cout << "multiplicity bin: " << iM;
380 : cout << ", z-vertex bin: " << iZ;
381 : cout << ", psi bin: " << iP;
382 : cout << ", pt bin: " << iPt;
383 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->PrintInfo();
384 : }
385 : }
386 : }
387 : }
388 : }
389 : }
390 :
391 0 : return fEvPool.size();
392 0 : }
393 :
394 : Long64_t AliEventPoolManager::Merge(TCollection* hlist)
395 : {
396 0 : if (!hlist)
397 0 : return 0;
398 :
399 : AliEventPoolManager* tmpObj = 0;
400 0 : TIter objIter(hlist);
401 :
402 : // Iterate through all objects to be merged
403 0 : while ( (tmpObj = static_cast<AliEventPoolManager*>(objIter())) )
404 : {
405 0 : for(Int_t i = 0; i<GetNumberOfMultBins(); i++)
406 0 : for(Int_t j = 0; j<GetNumberOfZVtxBins(); j++)
407 0 : for(Int_t k = 0; k<GetNumberOfPsiBins(); k++)
408 0 : for(Int_t l = 0; l<GetNumberOfPtBins(); l++)
409 : {
410 0 : TList* poolList = new TList();
411 0 : AliEventPool* objPool = tmpObj->GetEventPool(i,j,k,l);
412 0 : AliEventPool* pool = GetEventPool(i,j,k,l);
413 :
414 0 : poolList->Add(objPool);
415 0 : pool->Merge(poolList);
416 0 : delete poolList;
417 : }
418 : }
419 0 : return hlist->GetEntries() + 1;
420 0 : }
421 :
422 : void AliEventPoolManager::SetTargetValues(Int_t trackDepth, Float_t fraction, Int_t events)
423 : {
424 : // sets target values (when a pool becomes ready) in all event pools
425 :
426 0 : fTargetTrackDepth = trackDepth;
427 :
428 0 : for (Int_t iM=0; iM<fNMultBins; iM++) {
429 0 : for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
430 0 : for (Int_t iP=0; iP<fNPsiBins; iP++) {
431 0 : for (Int_t iPt=0; iPt<fNPtBins; iPt++) {
432 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetTargetTrackDepth(trackDepth, fraction);
433 0 : fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->SetTargetEvents(events);
434 : }
435 : }
436 : }
437 : }
438 0 : }
439 :
440 : void AliEventPoolManager::ClearPools()
441 : {
442 : // Clear the pools that are not marked to be saved
443 : // Those marked to be saved are now flagged as locked and save deflagged
444 : // to serve a valid input when importing this pool
445 : // Call this function in FinishTaskOutput() of your class
446 :
447 0 : for(Int_t i = 0; i<GetNumberOfMultBins(); i++)
448 0 : for(Int_t j = 0; j<GetNumberOfZVtxBins(); j++)
449 0 : for(Int_t k = 0; k<GetNumberOfPsiBins(); k++)
450 0 : for(Int_t l = 0; l<GetNumberOfPtBins(); l++)
451 : {
452 0 : AliEventPool* pool = GetEventPool(i,j,k,l);
453 0 : if(!pool->GetSaveFlag())
454 0 : pool->Clear();
455 : else
456 : {
457 0 : pool->SetLockFlag(kTRUE);
458 0 : pool->SetSaveFlag(kFALSE);
459 : }
460 : }
461 0 : }
462 :
463 : void AliEventPoolManager::ClearPools(Double_t minCent, Double_t maxCent, Double_t minZvtx, Double_t maxZvtx, Double_t minPsi, Double_t maxPsi, Double_t minPt, Double_t maxPt)
464 : {
465 : // Clear some pools, given by the ranges
466 0 : for(Int_t i = 0; i<GetNumberOfMultBins(); i++)
467 0 : for(Int_t j = 0; j<GetNumberOfZVtxBins(); j++)
468 0 : for(Int_t k = 0; k<GetNumberOfPsiBins(); k++)
469 0 : for(Int_t l = 0; l<GetNumberOfPtBins(); l++)
470 : {
471 0 : AliEventPool* pool = GetEventPool(i,j,0,l);
472 0 : if( (minCent < pool->GetMultMax()) && (maxCent > pool->GetMultMin()) &&
473 0 : (minZvtx < pool->GetZvtxMax()) && (maxZvtx > pool->GetZvtxMin()) &&
474 0 : (minPsi < pool->GetPsiMax()) && (maxPsi > pool->GetPsiMin()) &&
475 0 : (minPt < pool->GetPtMax()) && (maxPt > pool->GetPtMin()) )
476 : {
477 0 : pool->SetLockFlag(kFALSE); // unlock pool
478 0 : pool->Clear(); //clear pool
479 0 : }
480 : }
481 0 : }
482 :
483 : void AliEventPoolManager::SetSaveFlag(Double_t minCent, Double_t maxCent, Double_t minZvtx, Double_t maxZvtx, Double_t minPsi, Double_t maxPsi, Double_t minPt, Double_t maxPt)
484 : {
485 : // set save flag on the pools in range
486 0 : for(Int_t i = 0; i<GetNumberOfMultBins(); i++)
487 0 : for(Int_t j = 0; j<GetNumberOfZVtxBins(); j++)
488 0 : for(Int_t k = 0; k<GetNumberOfPsiBins(); k++)
489 0 : for(Int_t l = 0; l<GetNumberOfPtBins(); l++)
490 : {
491 0 : AliEventPool* pool = GetEventPool(i,j,k,l);
492 0 : if( (minCent < pool->GetMultMax()) && (maxCent > pool->GetMultMin()) &&
493 0 : (minZvtx < pool->GetZvtxMax()) && (maxZvtx > pool->GetZvtxMin()) &&
494 0 : (minPsi < pool->GetPsiMax()) && (maxPsi > pool->GetPsiMin()) &&
495 0 : (minPt < pool->GetPtMax()) && (maxPt > pool->GetPtMin()) )
496 : {
497 0 : if(pool->GetLockFlag())
498 0 : AliWarning("A pool that was already imported is flagged to be saved. Is this really intended?");
499 0 : pool->SetSaveFlag(kTRUE);
500 0 : }
501 : }
502 0 : }
503 :
504 : void AliEventPoolManager::Validate()
505 : {
506 0 : std::cout << "############## AliEventPoolManager ##############\n";
507 0 : std::cout << "== Binning ==\n";
508 0 : TString tmpStr = "cent/mult: ";
509 0 : for(Int_t i = 0; i<fMultBins.size(); i++)
510 0 : tmpStr += Form("%4.3f ", fMultBins[i]);
511 0 : tmpStr += " vertex: ";
512 0 : for(Int_t i = 0; i<fZvtxBins.size(); i++)
513 0 : tmpStr += Form("%4.3f ", fZvtxBins[i]);
514 0 : tmpStr += " psi: ";
515 0 : for(Int_t i = 0; i<fPsiBins.size(); i++)
516 0 : tmpStr += Form("%4.3f ", fPsiBins[i]);
517 0 : tmpStr += " pt: ";
518 0 : for(Int_t i = 0; i<fPtBins.size(); i++)
519 0 : tmpStr += Form("%4.3f ", fPtBins[i]);
520 0 : std::cout << tmpStr.Data() << std::endl;
521 0 : std::cout << "== Event pools ==\n";
522 :
523 0 : std::cout << "Note: Locked pools won't be filled. They are intended to serve as external input.\n";
524 0 : std::cout << " Pools with save flag: Those pools are intended to be written to the output file.\n";
525 :
526 0 : for (Int_t iM=0; iM<fNMultBins; iM++)
527 0 : for (Int_t iZ=0; iZ<fNZvtxBins; iZ++)
528 0 : for (Int_t iP=0; iP<fNPsiBins; iP++)
529 0 : for (Int_t iPt=0; iPt<fNPtBins; iPt++)
530 : {
531 0 : AliEventPool* pool = GetEventPool(iM, iZ, iP, iPt);
532 0 : if(!pool)
533 0 : AliFatal(Form("Pool (%i,%i,%i,%i) is not correctly initialized!", iM, iZ, iP, iPt));
534 0 : if(pool->GetLockFlag())
535 0 : std::cout << Form(" Pool (mult=%4.3f-%4.3f, zvertex=%4.3f-%4.3f, psi=%4.3f-%4.3f, pt=%4.3f-%4.3f) locked", fMultBins[iM], fMultBins[iM+1], fZvtxBins[iZ], fZvtxBins[iZ+1], fPsiBins[iP], fPsiBins[iP+1], fPtBins[iPt], fPtBins[iPt+1]) << std::endl;
536 : }
537 :
538 :
539 0 : for (Int_t iM=0; iM<fNMultBins; iM++)
540 0 : for (Int_t iZ=0; iZ<fNZvtxBins; iZ++)
541 0 : for (Int_t iP=0; iP<fNPsiBins; iP++)
542 0 : for (Int_t iPt=0; iPt<fNPtBins; iPt++)
543 : {
544 0 : AliEventPool* pool = GetEventPool(iM, iZ, iP, iPt);
545 0 : if(pool->GetSaveFlag())
546 0 : std::cout << Form(" Pool (mult=%4.3f-%4.3f, zvertex=%3.3f-%4.3f, psi=%4.3f-%4.3f, pt=%4.3f-%4.3f) will be saved", fMultBins[iM], fMultBins[iM+1], fZvtxBins[iZ], fZvtxBins[iZ+1], fPsiBins[iP], fPsiBins[iP+1], fPtBins[iPt], fPtBins[iPt+1]) << std::endl;
547 : }
548 :
549 0 : std::cout << "############## AliEventPoolManager ##############\n";
550 :
551 0 : }
552 :
553 :
554 : AliEventPool *AliEventPoolManager::GetEventPool(Int_t iMult, Int_t iZvtx, Int_t iPsi, Int_t iPt) const
555 : {
556 0 : if (iMult < 0 || iMult >= fNMultBins)
557 : {
558 0 : AliError(Form("Mult bin %i exceeds maximum of %i",iMult, fNMultBins));
559 0 : return 0x0;
560 : }
561 0 : if (iZvtx < 0 || iZvtx >= fNZvtxBins)
562 : {
563 0 : AliError(Form("Zvtx bin %i exceeds maximum of %i",iZvtx, fNZvtxBins));
564 0 : return 0x0;
565 : }
566 0 : if (iPsi < 0 || iPsi >= fNPsiBins)
567 : {
568 0 : AliError(Form("Psi bin %i exceeds maximum of %i",iPsi, fNPsiBins));
569 0 : return 0x0;
570 : }
571 0 : if (iPt < 0 || iPt >= fNPtBins)
572 : {
573 0 : AliError(Form("Pt bin %i exceeds maximum of %i",iPt, fNPtBins));
574 0 : return 0x0;
575 : }
576 :
577 0 : if(fEvPool.at(GetBinIndex(iMult, iZvtx, iPsi, iPt)))
578 0 : return fEvPool.at(GetBinIndex(iMult, iZvtx, iPsi, iPt));
579 : else
580 0 : AliFatal("Pool does not exist");
581 :
582 0 : return 0;
583 0 : }
584 :
585 : AliEventPool *AliEventPoolManager::GetEventPool(Int_t centVal, Double_t zVtxVal, Double_t psiVal, Int_t iPt) const
586 : {
587 0 : return GetEventPool((Double_t)centVal, zVtxVal, psiVal, iPt);
588 : }
589 :
590 : AliEventPool *AliEventPoolManager::GetEventPool(Double_t centVal, Double_t zVtxVal, Double_t psiVal, Int_t iPt) const
591 : {
592 : // Return appropriate pool for this centrality and z-vertex value.
593 :
594 0 : for (Int_t iM=0; iM<fNMultBins; iM++) {
595 0 : for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
596 0 : for (Int_t iP=0; iP<fNPsiBins; iP++) {
597 0 : AliEventPool* pool = GetEventPool(iM, iZ, iP, iPt);
598 0 : if (pool->EventMatchesBin(centVal, zVtxVal, psiVal, (pool->GetPtMin()+pool->GetPtMax())/2 ))
599 0 : return pool;
600 0 : }
601 : }
602 : }
603 0 : return 0x0;
604 0 : }
605 :
606 : Int_t AliEventPoolManager::UpdatePools(TObjArray *trk)
607 : {
608 : // Call UpdatePool for all bins.
609 :
610 0 : for (Int_t iM=0; iM<fNMultBins; iM++) {
611 0 : for (Int_t iZ=0; iZ<fNZvtxBins; iZ++) {
612 0 : for (Int_t iP=0; iP<fNPsiBins; iP++) {
613 0 : for (Int_t iPt=0; iPt<fNPtBins; iPt++) {
614 0 : if (fEvPool.at(GetBinIndex(iM, iZ, iP, iPt))->UpdatePool(trk) > -1)
615 0 : break;
616 : }
617 : }
618 : }
619 : }
620 0 : return 0;
621 : }
622 :
623 : Double_t* AliEventPoolManager::GetBinning(const char* configuration, const char* tag, Int_t& nBins) const
624 : {
625 : // Same as in AliUEHist
626 :
627 0 : TString config(configuration);
628 0 : TObjArray* lines = config.Tokenize("\n");
629 0 : for (Int_t i=0; i<lines->GetEntriesFast(); i++)
630 : {
631 0 : TString line(lines->At(i)->GetName());
632 0 : if (line.BeginsWith(TString(tag) + ":"))
633 : {
634 0 : line.Remove(0, strlen(tag) + 1);
635 0 : line.ReplaceAll(" ", "");
636 0 : TObjArray* binning = line.Tokenize(",");
637 0 : Double_t* bins = new Double_t[binning->GetEntriesFast()];
638 0 : for (Int_t j=0; j<binning->GetEntriesFast(); j++)
639 0 : bins[j] = TString(binning->At(j)->GetName()).Atof();
640 :
641 0 : nBins = binning->GetEntriesFast() - 1;
642 :
643 0 : delete binning;
644 0 : delete lines;
645 : return bins;
646 : }
647 0 : }
648 :
649 0 : delete lines;
650 0 : return 0;
651 0 : }
652 :
|