]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/JetCorrel/AliJetCorrelMixer.cxx
pass 5 histos and selections
[u/mrichter/AliRoot.git] / PWG4 / JetCorrel / AliJetCorrelMixer.cxx
CommitLineData
c97d2ae1 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Id: $ */
16
17//__________________________________________
18// Event mixing class. A 6-dimensinal pool fPool is maintained:
19// type(fixed), type_idx(fixed), vertex(fixed), centrality(fixed),
20// and event(dynamic), particle(dynamic)
21// fixed dimensions are fixed at task initialization time (via AliJetCorrelSelector)
22// event&particle are allow to float during runtime (via linked lists TList=event & CorrelList_t=particle)
23//-- Author: Paul Constantin
24
25#include "AliJetCorrelMixer.h"
26
27using namespace std;
c97d2ae1 28
29ClassImp(AliJetCorrelMixer)
30
31AliJetCorrelMixer::AliJetCorrelMixer() :
32 fSelector(NULL), fMaker(NULL), fWriter(NULL),
33 TriggEvnt(new CorrelList_t), AssocEvnt(new CorrelList_t),
e1b97289 34 AssocIter(NULL), TriggIter(NULL),
c97d2ae1 35 fNumCentBins(0), fNumVertBins(0), fPoolDepth(0), fNumCorrel(0), fNumTriggs(0), fNumAssocs(0){
36 // constructor
37}
38
39AliJetCorrelMixer::~AliJetCorrelMixer(){
40 // destructor
41 CleanPool(triggs);
42 CleanPool(assocs);
43 if(TriggEvnt) delete TriggEvnt;
44 if(AssocEvnt) delete AssocEvnt;
45}
46
47void AliJetCorrelMixer::Init(AliJetCorrelSelector * const s, AliJetCorrelMaker * const m, AliJetCorrelWriter * const w){
48 // initialization method
49 fSelector = s;
50 fMaker = m;
51 fWriter = w;
52
53 fNumCentBins = fSelector->NoOfBins(centr);
54 fNumVertBins = fSelector->NoOfBins(zvert);
55 fPoolDepth = fSelector->PoolDepth();
56 fNumCorrel = fMaker->NoOfCorrel();
57 fNumTriggs = fMaker->NoOfTrigg();
58 fNumAssocs = fMaker->NoOfAssoc();
59
60 for(UInt_t vBin=0; vBin<fNumVertBins; vBin++){
61 for(UInt_t cBin=0; cBin<fNumCentBins; cBin++){
62 for(UInt_t it=0; it<fNumTriggs; it++)
63 fPool[triggs][it][vBin][cBin] = new TList;
64 for(UInt_t ia=0; ia<fNumAssocs; ia++)
65 fPool[assocs][ia][vBin][cBin] = new TList;
66 }
67 }
68}
69
70void AliJetCorrelMixer::FillPool(CorrelList_t *partList, UInt_t pIdx, UInt_t vBin, UInt_t cBin){
71 // pool filling method
72 if(partList->Size()<1) return;
73 PoolType_t pType = partList->PoolID();
74 UInt_t pSize = fPool[pType][pIdx][vBin][cBin]->GetSize();
75 // when pool depth is reached, pop pool before new event push (keep const depth)
76 if(pSize>=fPoolDepth) fPool[pType][pIdx][vBin][cBin]->RemoveFirst();
77 // incoming list is cleared at end-of-event; hence, store in pool a deep copy:
78 fPool[pType][pIdx][vBin][cBin]->AddLast(partList->DeepCopy());
79}
80
81void AliJetCorrelMixer::Mix(UInt_t vBin, UInt_t cBin, UInt_t it, UInt_t ia, UInt_t ic){
82 // rolling buffer mixing method
83 TListIter* iterAssocPool=(TListIter*)fPool[assocs][ia][vBin][cBin]->MakeIterator();
84 while(fPool[triggs][it][vBin][cBin]->GetSize()>0){ // evaluate here due to popping
85 TriggEvnt = (CorrelList_t*)fPool[triggs][it][vBin][cBin]->First();
86 TriggIter = TriggEvnt->Head();
87
88 while((AssocEvnt=(CorrelList_t*)iterAssocPool->Next())){
89 AssocIter = AssocEvnt->Head();
90
91 if(TriggEvnt->EvtID()==AssocEvnt->EvtID()) continue; // don't mix same event!
92
93 while(!TriggIter.HasEnded()){
94 while(!AssocIter.HasEnded()){
95 fWriter->FillCorrelations(mixed,ic,cBin,vBin,TriggIter.Data(),AssocIter.Data()); // trigg first!
96 AssocIter.Move();
97 } // loop over associated particles
98 AssocIter = AssocEvnt->Head(); // reset associated particle iterator to list head
99 TriggIter.Move();
100 } // loop over trigger particles
101 TriggIter = TriggEvnt->Head(); // reset trigger particle iterator to list head
102 } // loop over associated pool
103 fPool[triggs][it][vBin][cBin]->RemoveFirst();
104 } // if trigger pool is not empty
105}
106
107void AliJetCorrelMixer::CleanPool(PoolType_t pType){
108 // pool cleaning
109 UInt_t size = 0;
110 if(pType==triggs) size = fNumTriggs;
111 if(pType==assocs) size = fNumAssocs;
112 for(UInt_t k=0; k<size; k++){
113 for(UInt_t vBin=0; vBin<fNumVertBins; vBin++)
114 for(UInt_t cBin=0; cBin<fNumCentBins; cBin++)
115 fPool[pType][k][vBin][cBin]->Delete(); // Remove all list objects AND delete all heap based objects
116 }
117}
118
119UInt_t AliJetCorrelMixer::PoolSize(PoolType_t pType, UInt_t vBin, UInt_t cBin){
120 // computes (static) pool size
121 UInt_t totalPoolSize=0;
122 UInt_t partSize = sizeof(CorrelParticle_t);
123 UInt_t listOverhead = sizeof(CorrelListNode_t);
124 CorrelList_t* partList; TListIter* iter;
125 UInt_t fNum = fNumAssocs; if(pType==triggs) fNum = fNumTriggs;
126 for(UInt_t i=0; i<fNum; i++){
127 iter=(TListIter*)fPool[pType][i][vBin][cBin]->MakeIterator();
128 while((partList=(CorrelList_t*)iter->Next()))
129 totalPoolSize += partList->Size()*(partSize+listOverhead);
130 }
131 return totalPoolSize/1024;
132}
133
134void AliJetCorrelMixer::ShowSummary(PoolType_t pType, UInt_t pIdx, UInt_t vBin, UInt_t cBin){
135 // pool printout method
136 UInt_t totalPoolSize=0;
137 TListIter* iter=(TListIter*)fPool[pType][pIdx][vBin][cBin]->MakeIterator();
138 CorrelList_t* partList;
139 while((partList=(CorrelList_t*)iter->Next())) totalPoolSize += partList->Size();
140
141 if(pType==triggs) std::cout<<"TriggPool[";
142 if(pType==assocs) std::cout<<"AssocPool[";
143 std::cout<<vBin<<"]["<<cBin<<"]: nevt="<<fPool[pType][pIdx][vBin][cBin]->GetSize()<<" npart="<<totalPoolSize<<std::endl;
144}
145
146void AliJetCorrelMixer::ShowPool(PoolType_t pType, UInt_t vBin, UInt_t cBin){
147 // all pools printout
148 CorrelList_t* tempList; TListIter* iter;
149 UInt_t size = 0;
150 if(pType==triggs) size = fNumTriggs;
151 if(pType==assocs) size = fNumAssocs;
152 for(UInt_t k=0; k<size; k++){
153 iter=(TListIter*)fPool[pType][k][vBin][cBin]->MakeIterator();
154 while((tempList=(CorrelList_t*)iter->Next())) tempList->Show();
155 }
156}