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