Lines getting the matched track moved to a method in AliCalorimeterUtils. Lines copie...
[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 }
76f2a6ef 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
67427ff7 76//____________________________
77AliFemtoLikeSignAnalysis::~AliFemtoLikeSignAnalysis(){
d92ed900 78 // destructor
67427ff7 79 delete fPicoEventCollectionVectorHideAway; fPicoEventCollectionVectorHideAway=0;
80}
81//____________________________
82AliFemtoString AliFemtoLikeSignAnalysis::Report()
83{
d92ed900 84 // prepare report
85 char tCtemp[200];
67427ff7 86 cout << "AliFemtoLikeSignAnalysis - constructing Report..."<<endl;
87 AliFemtoString temp = "-----------\nHbt Analysis Report:\n";
3be563bf 88 snprintf(tCtemp , 200, "Events are mixed in %d bins in the range %E cm to %E cm.\n",fVertexBins,fVertexZ[0],fVertexZ[1]);
d92ed900 89 temp += tCtemp;
3be563bf 90 snprintf(tCtemp , 200, "Events underflowing: %d\n",fUnderFlow);
d92ed900 91 temp += tCtemp;
3be563bf 92 snprintf(tCtemp , 200, "Events overflowing: %d\n",fOverFlow);
d92ed900 93 temp += tCtemp;
3be563bf 94 snprintf(tCtemp , 200, "Now adding AliFemtoSimpleAnalysis(base) Report\n");
d92ed900 95 temp += tCtemp;
a5b23aa6 96 temp += "Adding AliFemtoSimpleAnalysis(base) Report now:\n";
97 temp += AliFemtoSimpleAnalysis::Report();
67427ff7 98 temp += "-------------\n";
99 AliFemtoString returnThis=temp;
100 return returnThis;
101}
102//_________________________
103void AliFemtoLikeSignAnalysis::ProcessEvent(const AliFemtoEvent* hbtEvent) {
d92ed900 104 // perform all the analysis tasks for a single event
67427ff7 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
d92ed900 143 AliFemtoPair* tThePair = new AliFemtoPair;
67427ff7 144
d92ed900 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;
67427ff7 152 if (AnalyzeIdenticalParticles()) { // only use First collection
d92ed900 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
67427ff7 155 }
156 else { // nonidentical - loop over First and Second collections
d92ed900 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
67427ff7 159 }
160 // real pairs
d92ed900 161 for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++){
67427ff7 162 if (AnalyzeIdenticalParticles()){
d92ed900 163 tStartInnerLoop = tPartIter1;
164 tStartInnerLoop++;
67427ff7 165 }
d92ed900 166 tThePair->SetTrack1(*tPartIter1);
167 for (tPartIter2 = tStartInnerLoop; tPartIter2!=tEndInnerLoop;tPartIter2++){
168 tThePair->SetTrack2(*tPartIter2);
67427ff7 169 // The following lines have to be uncommented if you want pairCutMonitors
170 // they are not in for speed reasons
d92ed900 171 // bool tmpPassPair = mPairCut->Pass(tThePair);
172 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 173 // if ( tmpPassPair ) {
d92ed900 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);
67427ff7 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
d92ed900 191 prevIter = tEndOuterLoop;
67427ff7 192 prevIter--;
d92ed900 193 for (tPartIter1=tStartOuterLoop;tPartIter1!=prevIter;tPartIter1++){
194 tThePair->SetTrack1(*tPartIter1);
195 nextIter = tPartIter1;
67427ff7 196 nextIter++;
d92ed900 197 for (tPartIter2 = nextIter; tPartIter2!=tEndOuterLoop;tPartIter2++){
198 tThePair->SetTrack2(*tPartIter2);
67427ff7 199 // The following lines have to be uncommented if you want pairCutMonitors
200 // they are not in for speed reasons
d92ed900 201 // bool tmpPassPair = mPairCut->Pass(tThePair);
202 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 203 // if ( tmpPassPair ) {
d92ed900 204 if (fPairCut->Pass(tThePair)){
205 for (tCorrFctnIter=fCorrFctnCollection->begin();
206 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
55dda989 207 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
208 if (tCorrFctn) tCorrFctn->AddLikeSignPositivePair(tThePair);
67427ff7 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
d92ed900 217 prevIter = tEndInnerLoop;
67427ff7 218 prevIter--;
d92ed900 219 for (tPartIter1=tStartInnerLoop;tPartIter1!=prevIter;tPartIter1++){
220 tThePair->SetTrack1(*tPartIter1);
221 nextIter = tPartIter1;
67427ff7 222 nextIter++;
d92ed900 223 for (tPartIter2 = nextIter; tPartIter2!=tEndInnerLoop;tPartIter2++){
224 tThePair->SetTrack2(*tPartIter2);
67427ff7 225 // The following lines have to be uncommented if you want pairCutMonitors
226 // they are not in for speed reasons
d92ed900 227 // bool tmpPassPair = mPairCut->Pass(tThePair);
228 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
67427ff7 229 // if ( tmpPassPair ) {
d92ed900 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);
67427ff7 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()){
d92ed900 252 tStartOuterLoop = picoEvent->FirstParticleCollection()->begin();
253 tEndOuterLoop = picoEvent->FirstParticleCollection()->end();
67427ff7 254 AliFemtoPicoEvent* storedEvent;
255 AliFemtoPicoEventIterator picoEventIter;
256 for (picoEventIter=MixingBuffer()->begin();picoEventIter!=MixingBuffer()->end();picoEventIter++){
257 storedEvent = *picoEventIter;
258 if (AnalyzeIdenticalParticles()){
d92ed900 259 tStartInnerLoop = storedEvent->FirstParticleCollection()->begin();
260 tEndInnerLoop = storedEvent->FirstParticleCollection()->end();
67427ff7 261 }
262 else{
d92ed900 263 tStartInnerLoop = storedEvent->SecondParticleCollection()->begin();
264 tEndInnerLoop = storedEvent->SecondParticleCollection()->end();
67427ff7 265 }
d92ed900 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;
67427ff7 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
d92ed900 290 delete tThePair;
67427ff7 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