update to master versions
[u/mrichter/AliRoot.git] / PWGCF / Correlations / JCORRAN / AliJEventPool.cxx
CommitLineData
66be7134 1#include <TRandom.h>
2#include "AliJEventPool.h"
3
4#include <TH1D.h>
5
6#include "AliJTrack.h"
7#include "AliJPhoton.h"
8#include <TClonesArray.h>
9
10#include "AliJBaseTrack.h"
11#include "AliJPhoton.h"
12
13
14#include "AliJPiZero.h"
15
16#include "AliJCard.h"
17#include "AliJCorrelations.h"
18#include "AliJHistos.h"
19
20
21// event mixing
22// blah
23// blah
24// blah
25// blah
26
27AliJEventPool::AliJEventPool(AliJCard *cardin, AliJHistos *histosin, AliJCorrelations *coin, particleType particle ) :
28 fcard(cardin),
29 fcorrelations(coin),
30 fhistos(histosin),
31 ftk(NULL),
32 ftk1(NULL),
33 ftk2(NULL),
34 fthisPoolType(particle),
35 fpoolList(NULL)
36{
37 // constructor
38
39 if(fcard->GetNoOfBins(kCentrType) > kMaxNoCentrBin ){
40 cout<<"ERROR: No of Centrality bins exceed max dim in AliJEventPool.h"<<endl;
41 exit(0);
42 }
43 for(int ic=0;ic<fcard->GetNoOfBins(kCentrType);ic++){
44 cout<<"Mixing pool depth for icbin = "<< ic << " is " << fcard->GetEventPoolDepth(ic) <<" for <"<<kParticleTypeStrName[particle] <<"> and prototype "<<kParticleProtoType[particle]<<endl;
45 if(fcard->GetEventPoolDepth(ic) > MAXNOEVENT ){
46 cout<<"ERROR: Event pool depth exeed max="<<MAXNOEVENT<<" in AliJEventPool.h"<<endl;
47 exit(0);
48 }
49 } cout <<endl;
50
51 for(int ic=0;ic<fcard->GetNoOfBins(kCentrType);ic++){
52 for(int ie=0;ie<fcard->GetEventPoolDepth(ic); ie++){
53 fLists[ic][ie] = new TClonesArray(kParticleProtoType[particle],1500);
54 }
55 flastAccepted[ic] = -1; //to start from 0
56 fwhereToStore[ic] = -1; //to start from 0
57 fnoMix[ic] = 0;
58 fnoMixCut[ic] = 0;
59 }
60
61 ftk = new AliJBaseTrack;
62 ftk1 = new AliJBaseTrack;
63 ftk2 = new AliJBaseTrack;
64
65}
66
67AliJEventPool::~AliJEventPool( ){
68 // destructor
69 delete ftk;
70 delete ftk1;
71 delete ftk2;
72}
73
74AliJEventPool::AliJEventPool(const AliJEventPool& obj) :
75 fcard(obj.fcard),
76 fcorrelations(obj.fcorrelations),
77 fhistos(obj.fhistos),
78 ftk(obj.ftk),
79 ftk1(obj.ftk1),
80 ftk2(obj.ftk2),
81 fthisPoolType(obj.fthisPoolType),
82 fpoolList(obj.fpoolList)
83{
84 // copy constructor
85 JUNUSED(obj);
86}
87
88AliJEventPool& AliJEventPool::operator=(const AliJEventPool& obj){
89 // equal sign operator
90 JUNUSED(obj);
91 return *this;
92}
93
94
95//______________________________________________________________________________
96void AliJEventPool::Mix( TClonesArray *triggList,
97 corrFillType cFTyp,
98 float cent, float Z, float thisMult, int iev){
99 // mixer
100 int cBin = fcard->GetBin(kCentrType, cent);
101 int zBin = fcard->GetBin(kZVertType, Z);
102 int noTrigg=triggList->GetEntriesFast();
103 int noAssoc=0;
104
105// cout << "c: " << cBin << endl;
106
107
108 for(int backCounter=0; backCounter <= flastAccepted[cBin]; backCounter++){
109 fpoolList = fLists [cBin] [backCounter];
110 noAssoc = fpoolList->GetEntries();
111
112 if(noAssoc<=0) continue;
113
114 //mixit=======
115 fnoMix[cBin]++;
116
117 if(
118 fcard->SimilarCentrality(fcentrality[cBin][backCounter], cent, cBin) &&
119 fcard->SimilarMultiplicity(fmult[cBin][backCounter], thisMult) &&
120 fcard->GetBin(kZVertType, fZVertex[cBin][backCounter])==zBin &&
121 fevent[cBin][backCounter] != iev )
122 {
123 fnoMixCut[cBin]++;
124 //=================================================
125 // try to use only one track from each fevent
126 //=================================================
127 for(int ii=0;ii<noTrigg;ii++){
128 ftk1 = (AliJBaseTrack*)triggList->At(ii);
129 //fhistos->fhTriggPtBin[kMixed][cBin][iptt]->Fill(ptt); //who needs that?
130 for(int jj=0;jj<noAssoc ;jj++){
131 ftk2 = (AliJBaseTrack*)fpoolList->At(jj);
132 fcorrelations->FillHisto(cFTyp,kMixed, cBin, zBin, ftk1, ftk2);
133 } //inner loop mixing
134 }//outer loop mixing
135 }//if good for mix
136 }//mixed fevent loop
137}
138
139//______________________________________________________________________________
140void AliJEventPool::AcceptList(TClonesArray *inList, float cent, float Z, float inMult, int iev){
141 //////////////////////////////////////////////////////////////
142 // circular buffer. New fevent added after the previous one,
143 // mixing goes backwards
144 //////////////////////////////////////////////////////////////
145 int cBin = fcard->GetBin(kCentrType, cent);
146 flastAccepted[cBin]++;
147 fwhereToStore[cBin]++;
148 if( flastAccepted[cBin] >= fcard->GetEventPoolDepth(cBin) ) flastAccepted[cBin] = fcard->GetEventPoolDepth(cBin)-1;
149 if( fwhereToStore[cBin] >= fcard->GetEventPoolDepth(cBin) ) fwhereToStore[cBin] = 0;
150 fevent [cBin][fwhereToStore[cBin]] = iev;
151 fZVertex [cBin][fwhereToStore[cBin]] = Z;
152 fcentrality[cBin][fwhereToStore[cBin]] = cent;
153 fmult [cBin][fwhereToStore[cBin]] = inMult;
154
155 fLists[cBin][fwhereToStore[cBin]]->Clear();
156 for(int i=0;i<inList->GetEntriesFast();i++){
5ca97880 157 if( fthisPoolType == kJPhoton || fthisPoolType == kJDecayphoton ){
66be7134 158 AliJPhoton *tkp = (AliJPhoton*)inList->At(i);
159 new ((*fLists[cBin][fwhereToStore[cBin]])[i]) AliJPhoton(*tkp);
160 }
5ca97880 161 else if( fthisPoolType == kJPizero || fthisPoolType == kJEta ){
66be7134 162 AliJPiZero *tkpz = (AliJPiZero*)inList->At(i);
163 new ((*fLists[cBin][fwhereToStore[cBin]])[i]) AliJPiZero(*tkpz);
164 }
165 else{
166 AliJTrack *tk3 = (AliJTrack*)inList->At(i);
167 new ((*fLists[cBin][fwhereToStore[cBin]])[i]) AliJTrack(*tk3);
168 }
169 }
170
171}
172
173
174
175
176
177//==================== Sampling ===========================
178void AliJEventPool::Mysample(TH1D *fromh, TH1D *toh )
179{
180 // sampler
181 if(fabs(toh->GetBinWidth(1)-fromh->GetBinWidth(1))>1e-5){
182 cout<<" Attempt to integrate histograms with non-compatible binning"<<endl;
183 printf("%16.14f %16.14f %16.14f \n", fromh->GetBinWidth(1), toh->GetBinWidth(1), fabs(toh->GetBinWidth(1)-fromh->GetBinWidth(1)) );
184 return;
185 }
186
187 for(int idphi=1; idphi<=toh->GetNbinsX(); idphi++){
188 double sum=0,err=0, a,b,e;
189 for (int i = 1;i <= fromh->GetNbinsX();i++)
190 {
191 double phi1 = fromh->GetBinCenter(i);
192 double fdphi = toh->GetBinCenter(idphi);
193 double phi2 = atan2(sin(phi1+fdphi),cos(phi1+fdphi));
194 a=fromh->GetBinContent(i);
195 b=fromh->GetBinContent(fromh->FindBin(phi2));
196 sum += a*b;
197 err += a*b*(a+b);
198 }
199 if( idphi==1 || idphi== toh->GetNbinsX() ) sum /= 2.0;
200 toh->SetBinContent(idphi,toh->GetBinContent(idphi)+sum);
201 e=toh->GetBinError(idphi);
202 toh->SetBinError(idphi,sqrt(err+e*e));
203 }
204}
205
206//______________________________________________________________________________
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227