]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FEMTOSCOPY/AliFemto/AliFemtoLikeSignAnalysis.cxx
Fix warnings
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemto / AliFemtoLikeSignAnalysis.cxx
CommitLineData
d92ed900 1///////////////////////////////////////////////////////////////////////////
2// //
3// This is an analysis which calculated the background from like sign //
4// pairs in the same event //
5// //
6///////////////////////////////////////////////////////////////////////////
67427ff7 7
d0e92d9a 8#include "AliFemtoLikeSignAnalysis.h"
9#include "AliFemtoParticleCollection.h"
10#include "AliFemtoPicoEventCollectionVector.h"
11#include "AliFemtoPicoEventCollectionVectorHideAway.h"
67427ff7 12
13#ifdef __ROOT__
14ClassImp(AliFemtoLikeSignAnalysis)
15#endif
16
17// this little function used to apply ParticleCuts (TrackCuts or V0Cuts) and fill ParticleCollections of picoEvent
a5b23aa6 18// it is called from AliFemtoSimpleAnalysis::ProcessEvent()
67427ff7 19
20
21extern void FillHbtParticleCollection(AliFemtoParticleCut* partCut,
22 AliFemtoEvent* hbtEvent,
23 AliFemtoParticleCollection* partCollection);
24
25
26//____________________________
0215f606 27AliFemtoLikeSignAnalysis::AliFemtoLikeSignAnalysis(unsigned int bins, double min, double max) :
a5b23aa6 28 AliFemtoSimpleAnalysis(),
0215f606 29 fVertexBins(0),
30 fOverFlow(0),
31 fUnderFlow(0)
32{
d92ed900 33 // standard constructor
67427ff7 34 fVertexBins = bins;
35 fVertexZ[0] = min;
36 fVertexZ[1] = max;
37 fUnderFlow = 0;
38 fOverFlow = 0;
39 if (fMixingBuffer) delete fMixingBuffer;
40 fPicoEventCollectionVectorHideAway = new AliFemtoPicoEventCollectionVectorHideAway(fVertexBins,fVertexZ[0],fVertexZ[1]);
41 /* no-op */
42}
43//____________________________
0215f606 44AliFemtoLikeSignAnalysis::AliFemtoLikeSignAnalysis(const AliFemtoLikeSignAnalysis& a) :
a5b23aa6 45 AliFemtoSimpleAnalysis(a) ,
0215f606 46 fVertexBins(0),
47 fOverFlow(0),
48 fUnderFlow(0)
49{
d92ed900 50 // copy constructor
67427ff7 51 fVertexBins = a.fVertexBins;
52 fVertexZ[0] = a.fVertexZ[0];
53 fVertexZ[1] = a.fVertexZ[1];
54 fUnderFlow = 0;
55 fOverFlow = 0;
56 if (fMixingBuffer) delete fMixingBuffer;
57 fPicoEventCollectionVectorHideAway = new AliFemtoPicoEventCollectionVectorHideAway(fVertexBins,fVertexZ[0],fVertexZ[1]);
58 }
59//____________________________
60AliFemtoLikeSignAnalysis::~AliFemtoLikeSignAnalysis(){
d92ed900 61 // destructor
67427ff7 62 delete fPicoEventCollectionVectorHideAway; fPicoEventCollectionVectorHideAway=0;
63}
64//____________________________
65AliFemtoString AliFemtoLikeSignAnalysis::Report()
66{
d92ed900 67 // prepare report
68 char tCtemp[200];
67427ff7 69 cout << "AliFemtoLikeSignAnalysis - constructing Report..."<<endl;
70 AliFemtoString temp = "-----------\nHbt Analysis Report:\n";
d92ed900 71 sprintf(tCtemp,"Events are mixed in %d bins in the range %E cm to %E cm.\n",fVertexBins,fVertexZ[0],fVertexZ[1]);
72 temp += tCtemp;
73 sprintf(tCtemp,"Events underflowing: %d\n",fUnderFlow);
74 temp += tCtemp;
75 sprintf(tCtemp,"Events overflowing: %d\n",fOverFlow);
76 temp += tCtemp;
a5b23aa6 77 sprintf(tCtemp,"Now adding AliFemtoSimpleAnalysis(base) Report\n");
d92ed900 78 temp += tCtemp;
a5b23aa6 79 temp += "Adding AliFemtoSimpleAnalysis(base) Report now:\n";
80 temp += AliFemtoSimpleAnalysis::Report();
67427ff7 81 temp += "-------------\n";
82 AliFemtoString returnThis=temp;
83 return returnThis;
84}
85//_________________________
86void AliFemtoLikeSignAnalysis::ProcessEvent(const AliFemtoEvent* hbtEvent) {
d92ed900 87 // perform all the analysis tasks for a single event
67427ff7 88 // get right mixing buffer
89 double vertexZ = hbtEvent->PrimVertPos().z();
90 fMixingBuffer = fPicoEventCollectionVectorHideAway->PicoEventCollection(vertexZ);
91 if (!fMixingBuffer) {
92 if ( vertexZ < fVertexZ[0] ) fUnderFlow++;
93 if ( vertexZ > fVertexZ[1] ) fOverFlow++;
94 return;
95 }
96
97 // startup for EbyE
98 EventBegin(hbtEvent);
99 // event cut and event cut monitor
100 bool tmpPassEvent = fEventCut->Pass(hbtEvent);
101 fEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
102 if (tmpPassEvent) {
103 fNeventsProcessed++;
104 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - " << hbtEvent->TrackCollection()->size();
105 cout << " #track=" << hbtEvent->TrackCollection()->size();
106 // OK, analysis likes the event-- build a pico event from it, using tracks the analysis likes...
107 AliFemtoPicoEvent* picoEvent = new AliFemtoPicoEvent; // this is what we will make pairs from and put in Mixing Buffer
108 FillHbtParticleCollection(fFirstParticleCut,(AliFemtoEvent*)hbtEvent,picoEvent->FirstParticleCollection());
109 if ( !(AnalyzeIdenticalParticles()) )
110 FillHbtParticleCollection(fSecondParticleCut,(AliFemtoEvent*)hbtEvent,picoEvent->SecondParticleCollection());
111 cout <<" #particles in First, Second Collections: " <<
112 picoEvent->FirstParticleCollection()->size() << " " <<
113 picoEvent->SecondParticleCollection()->size() << endl;
114
115 if (picoEvent->SecondParticleCollection()->size()*picoEvent->FirstParticleCollection()->size()==0) {
116 delete picoEvent;
117 cout << "AliFemtoLikeSignAnalysis - picoEvent deleted due to empty collection " <<endl;
118 return;
119 }
120 // OK, pico event is built
121 // make real pairs...
122
123 // Fabrice points out that we do not need to keep creating/deleting pairs all the time
124 // We only ever need ONE pair, and we can just keep changing internal pointers
125 // this should help speed things up
d92ed900 126 AliFemtoPair* tThePair = new AliFemtoPair;
67427ff7 127
d92ed900 128 AliFemtoParticleIterator tPartIter1;
129 AliFemtoParticleIterator tPartIter2;
130 AliFemtoCorrFctnIterator tCorrFctnIter;
131 AliFemtoParticleIterator tStartOuterLoop = picoEvent->FirstParticleCollection()->begin(); // always
132 AliFemtoParticleIterator tEndOuterLoop = picoEvent->FirstParticleCollection()->end(); // will be one less if identical
133 AliFemtoParticleIterator tStartInnerLoop;
134 AliFemtoParticleIterator tEndInnerLoop;
67427ff7 135 if (AnalyzeIdenticalParticles()) { // only use First collection
d92ed900 136 tEndOuterLoop--; // outer loop goes to next-to-last particle in First collection
137 tEndInnerLoop = picoEvent->FirstParticleCollection()->end() ; // inner loop goes to last particle in First collection
67427ff7 138 }
139 else { // nonidentical - loop over First and Second collections
d92ed900 140 tStartInnerLoop = picoEvent->SecondParticleCollection()->begin(); // inner loop starts at first particle in Second collection
141 tEndInnerLoop = picoEvent->SecondParticleCollection()->end() ; // inner loop goes to last particle in Second collection
67427ff7 142 }
143 // real pairs
d92ed900 144 for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++){
67427ff7 145 if (AnalyzeIdenticalParticles()){
d92ed900 146 tStartInnerLoop = tPartIter1;
147 tStartInnerLoop++;
67427ff7 148 }
d92ed900 149 tThePair->SetTrack1(*tPartIter1);
150 for (tPartIter2 = tStartInnerLoop; tPartIter2!=tEndInnerLoop;tPartIter2++){
151 tThePair->SetTrack2(*tPartIter2);
67427ff7 152 // The following lines have to be uncommented if you want pairCutMonitors
153 // they are not in for speed reasons
d92ed900 154 // bool tmpPassPair = mPairCut->Pass(tThePair);
155 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 156 // if ( tmpPassPair ) {
d92ed900 157 if (fPairCut->Pass(tThePair)){
158 for (tCorrFctnIter=fCorrFctnCollection->begin();
159 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
160 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
161 if (tCorrFctn) tCorrFctn->AddRealPair(tThePair);
67427ff7 162 }
163 } // if passed pair cut
164 } // loop over second particle
165 } // loop over first particle
166#ifdef STHBTDEBUG
167 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - reals done" << endl;
168#endif
169
170 AliFemtoParticleIterator nextIter;
171 AliFemtoParticleIterator prevIter;
172
173 // like sign first partilce collection pairs
d92ed900 174 prevIter = tEndOuterLoop;
67427ff7 175 prevIter--;
d92ed900 176 for (tPartIter1=tStartOuterLoop;tPartIter1!=prevIter;tPartIter1++){
177 tThePair->SetTrack1(*tPartIter1);
178 nextIter = tPartIter1;
67427ff7 179 nextIter++;
d92ed900 180 for (tPartIter2 = nextIter; tPartIter2!=tEndOuterLoop;tPartIter2++){
181 tThePair->SetTrack2(*tPartIter2);
67427ff7 182 // The following lines have to be uncommented if you want pairCutMonitors
183 // they are not in for speed reasons
d92ed900 184 // bool tmpPassPair = mPairCut->Pass(tThePair);
185 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 186 // if ( tmpPassPair ) {
d92ed900 187 if (fPairCut->Pass(tThePair)){
188 for (tCorrFctnIter=fCorrFctnCollection->begin();
189 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
55dda989 190 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
191 if (tCorrFctn) tCorrFctn->AddLikeSignPositivePair(tThePair);
67427ff7 192 }
193 } // if passed pair cut
194 } // loop over second particle
195 } // loop over first particle
196#ifdef STHBTDEBUG
197 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign first collection done" << endl;
198#endif
199 // like sign second partilce collection pairs
d92ed900 200 prevIter = tEndInnerLoop;
67427ff7 201 prevIter--;
d92ed900 202 for (tPartIter1=tStartInnerLoop;tPartIter1!=prevIter;tPartIter1++){
203 tThePair->SetTrack1(*tPartIter1);
204 nextIter = tPartIter1;
67427ff7 205 nextIter++;
d92ed900 206 for (tPartIter2 = nextIter; tPartIter2!=tEndInnerLoop;tPartIter2++){
207 tThePair->SetTrack2(*tPartIter2);
67427ff7 208 // The following lines have to be uncommented if you want pairCutMonitors
209 // they are not in for speed reasons
d92ed900 210 // bool tmpPassPair = mPairCut->Pass(tThePair);
211 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 212 // if ( tmpPassPair ) {
d92ed900 213 if (fPairCut->Pass(tThePair)){
214 for (tCorrFctnIter=fCorrFctnCollection->begin();
215 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
216 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
217 if (tCorrFctn) tCorrFctn->AddLikeSignNegativePair(tThePair);
67427ff7 218 }
219 } // if passed pair cut
220 } // loop over second particle
221 } // loop over first particle
222#ifdef STHBTDEBUG
223 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign second collection done" << endl;
224#endif
225
226 if (MixingBufferFull()){
227#ifdef STHBTDEBUG
228 cout << "Mixing Buffer is full - lets rock and roll" << endl;
229#endif
230 }
231 else {
232 cout << "Mixing Buffer not full -gotta wait " << MixingBuffer()->size() << endl;
233 }
234 if (MixingBufferFull()){
d92ed900 235 tStartOuterLoop = picoEvent->FirstParticleCollection()->begin();
236 tEndOuterLoop = picoEvent->FirstParticleCollection()->end();
67427ff7 237 AliFemtoPicoEvent* storedEvent;
238 AliFemtoPicoEventIterator picoEventIter;
239 for (picoEventIter=MixingBuffer()->begin();picoEventIter!=MixingBuffer()->end();picoEventIter++){
240 storedEvent = *picoEventIter;
241 if (AnalyzeIdenticalParticles()){
d92ed900 242 tStartInnerLoop = storedEvent->FirstParticleCollection()->begin();
243 tEndInnerLoop = storedEvent->FirstParticleCollection()->end();
67427ff7 244 }
245 else{
d92ed900 246 tStartInnerLoop = storedEvent->SecondParticleCollection()->begin();
247 tEndInnerLoop = storedEvent->SecondParticleCollection()->end();
67427ff7 248 }
d92ed900 249 for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++){
250 tThePair->SetTrack1(*tPartIter1);
251 for (tPartIter2=tStartInnerLoop;tPartIter2!=tEndInnerLoop;tPartIter2++){
252 tThePair->SetTrack2(*tPartIter2);
253 // testing... cout << "tThePair defined... going to pair cut... ";
254 if (fPairCut->Pass(tThePair)){
255 // testing... cout << " tThePair passed PairCut... ";
256 for (tCorrFctnIter=fCorrFctnCollection->begin();
257 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
258 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
259 if (tCorrFctn) {
260 tCorrFctn->AddMixedPair(tThePair);
261 //cout << " tThePair has been added to MixedPair method " << endl;
67427ff7 262 }
263 }
264 } // if passed pair cut
265 } // loop over second particle
266 } // loop over first particle
267 } // loop over pico-events stored in Mixing buffer
268 // Now get rid of oldest stored pico-event in buffer.
269 // This means (1) delete the event from memory, (2) "pop" the pointer to it from the MixingBuffer
270 delete MixingBuffer()->back();
271 MixingBuffer()->pop_back();
272 } // if mixing buffer is full
d92ed900 273 delete tThePair;
67427ff7 274 MixingBuffer()->push_front(picoEvent); // store the current pico-event in buffer
275 } // if currentEvent is accepted by currentAnalysis
276 EventEnd(hbtEvent); // cleanup for EbyE
277 // cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - return to caller ... " << endl;
278}
279
280
281