1 ///////////////////////////////////////////////////////////////////////////
3 // This is an analysis which calculated the background from like sign //
4 // pairs in the same event //
6 ///////////////////////////////////////////////////////////////////////////
8 #include "AliFemtoLikeSignAnalysis.h"
9 #include "AliFemtoParticleCollection.h"
10 #include "AliFemtoPicoEventCollectionVector.h"
11 #include "AliFemtoPicoEventCollectionVectorHideAway.h"
14 ClassImp(AliFemtoLikeSignAnalysis)
17 // this little function used to apply ParticleCuts (TrackCuts or V0Cuts) and fill ParticleCollections of picoEvent
18 // it is called from AliFemtoSimpleAnalysis::ProcessEvent()
21 extern void FillHbtParticleCollection(AliFemtoParticleCut* partCut,
22 AliFemtoEvent* hbtEvent,
23 AliFemtoParticleCollection* partCollection);
26 //____________________________
27 AliFemtoLikeSignAnalysis::AliFemtoLikeSignAnalysis(unsigned int bins, double min, double max) :
28 AliFemtoSimpleAnalysis(),
33 // standard constructor
39 if (fMixingBuffer) delete fMixingBuffer;
40 fPicoEventCollectionVectorHideAway = new AliFemtoPicoEventCollectionVectorHideAway(fVertexBins,fVertexZ[0],fVertexZ[1]);
43 //____________________________
44 AliFemtoLikeSignAnalysis::AliFemtoLikeSignAnalysis(const AliFemtoLikeSignAnalysis& a) :
45 AliFemtoSimpleAnalysis(a) ,
51 fVertexBins = a.fVertexBins;
52 fVertexZ[0] = a.fVertexZ[0];
53 fVertexZ[1] = a.fVertexZ[1];
56 if (fMixingBuffer) delete fMixingBuffer;
57 fPicoEventCollectionVectorHideAway = new AliFemtoPicoEventCollectionVectorHideAway(fVertexBins,fVertexZ[0],fVertexZ[1]);
59 AliFemtoLikeSignAnalysis& AliFemtoLikeSignAnalysis::operator=(const AliFemtoLikeSignAnalysis& OriginalAnalysis)
61 if (this != &OriginalAnalysis) {
62 fVertexBins = OriginalAnalysis.fVertexBins;
63 fVertexZ[0] = OriginalAnalysis.fVertexZ[0];
64 fVertexZ[1] = OriginalAnalysis.fVertexZ[1];
67 if (fMixingBuffer) delete fMixingBuffer;
68 if (fPicoEventCollectionVectorHideAway) delete fPicoEventCollectionVectorHideAway;
69 fPicoEventCollectionVectorHideAway = new AliFemtoPicoEventCollectionVectorHideAway(fVertexBins,fVertexZ[0],fVertexZ[1]);
76 //____________________________
77 AliFemtoLikeSignAnalysis::~AliFemtoLikeSignAnalysis(){
79 delete fPicoEventCollectionVectorHideAway; fPicoEventCollectionVectorHideAway=0;
81 //____________________________
82 AliFemtoString AliFemtoLikeSignAnalysis::Report()
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]);
90 snprintf(tCtemp , 200, "Events underflowing: %d\n",fUnderFlow);
92 snprintf(tCtemp , 200, "Events overflowing: %d\n",fOverFlow);
94 snprintf(tCtemp , 200, "Now adding AliFemtoSimpleAnalysis(base) Report\n");
96 temp += "Adding AliFemtoSimpleAnalysis(base) Report now:\n";
97 temp += AliFemtoSimpleAnalysis::Report();
98 temp += "-------------\n";
99 AliFemtoString returnThis=temp;
102 //_________________________
103 void 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++;
115 EventBegin(hbtEvent);
116 // event cut and event cut monitor
117 bool tmpPassEvent = fEventCut->Pass(hbtEvent);
118 fEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
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;
132 if (picoEvent->SecondParticleCollection()->size()*picoEvent->FirstParticleCollection()->size()==0) {
134 cout << "AliFemtoLikeSignAnalysis - picoEvent deleted due to empty collection " <<endl;
137 // OK, pico event is built
138 // make real pairs...
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;
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
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
161 for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++){
162 if (AnalyzeIdenticalParticles()){
163 tStartInnerLoop = tPartIter1;
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);
180 } // if passed pair cut
181 } // loop over second particle
182 } // loop over first particle
184 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - reals done" << endl;
187 AliFemtoParticleIterator nextIter;
188 AliFemtoParticleIterator prevIter;
190 // like sign first partilce collection pairs
191 prevIter = tEndOuterLoop;
193 for (tPartIter1=tStartOuterLoop;tPartIter1!=prevIter;tPartIter1++){
194 tThePair->SetTrack1(*tPartIter1);
195 nextIter = tPartIter1;
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);
210 } // if passed pair cut
211 } // loop over second particle
212 } // loop over first particle
214 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign first collection done" << endl;
216 // like sign second partilce collection pairs
217 prevIter = tEndInnerLoop;
219 for (tPartIter1=tStartInnerLoop;tPartIter1!=prevIter;tPartIter1++){
220 tThePair->SetTrack1(*tPartIter1);
221 nextIter = tPartIter1;
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);
236 } // if passed pair cut
237 } // loop over second particle
238 } // loop over first particle
240 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign second collection done" << endl;
243 if (MixingBufferFull()){
245 cout << "Mixing Buffer is full - lets rock and roll" << endl;
249 cout << "Mixing Buffer not full -gotta wait " << MixingBuffer()->size() << endl;
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();
263 tStartInnerLoop = storedEvent->SecondParticleCollection()->begin();
264 tEndInnerLoop = storedEvent->SecondParticleCollection()->end();
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);
277 tCorrFctn->AddMixedPair(tThePair);
278 //cout << " tThePair has been added to MixedPair method " << endl;
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
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;