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 //____________________________
60 AliFemtoLikeSignAnalysis::~AliFemtoLikeSignAnalysis(){
62 delete fPicoEventCollectionVectorHideAway; fPicoEventCollectionVectorHideAway=0;
64 //____________________________
65 AliFemtoString AliFemtoLikeSignAnalysis::Report()
69 cout << "AliFemtoLikeSignAnalysis - constructing Report..."<<endl;
70 AliFemtoString temp = "-----------\nHbt Analysis Report:\n";
71 sprintf(tCtemp,"Events are mixed in %d bins in the range %E cm to %E cm.\n",fVertexBins,fVertexZ[0],fVertexZ[1]);
73 sprintf(tCtemp,"Events underflowing: %d\n",fUnderFlow);
75 sprintf(tCtemp,"Events overflowing: %d\n",fOverFlow);
77 sprintf(tCtemp,"Now adding AliFemtoSimpleAnalysis(base) Report\n");
79 temp += "Adding AliFemtoSimpleAnalysis(base) Report now:\n";
80 temp += AliFemtoSimpleAnalysis::Report();
81 temp += "-------------\n";
82 AliFemtoString returnThis=temp;
85 //_________________________
86 void AliFemtoLikeSignAnalysis::ProcessEvent(const AliFemtoEvent* hbtEvent) {
87 // perform all the analysis tasks for a single event
88 // get right mixing buffer
89 double vertexZ = hbtEvent->PrimVertPos().z();
90 fMixingBuffer = fPicoEventCollectionVectorHideAway->PicoEventCollection(vertexZ);
92 if ( vertexZ < fVertexZ[0] ) fUnderFlow++;
93 if ( vertexZ > fVertexZ[1] ) fOverFlow++;
99 // event cut and event cut monitor
100 bool tmpPassEvent = fEventCut->Pass(hbtEvent);
101 fEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
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;
115 if (picoEvent->SecondParticleCollection()->size()*picoEvent->FirstParticleCollection()->size()==0) {
117 cout << "AliFemtoLikeSignAnalysis - picoEvent deleted due to empty collection " <<endl;
120 // OK, pico event is built
121 // make real pairs...
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
126 AliFemtoPair* tThePair = new AliFemtoPair;
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;
135 if (AnalyzeIdenticalParticles()) { // only use First collection
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
139 else { // nonidentical - loop over First and Second collections
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
144 for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++){
145 if (AnalyzeIdenticalParticles()){
146 tStartInnerLoop = tPartIter1;
149 tThePair->SetTrack1(*tPartIter1);
150 for (tPartIter2 = tStartInnerLoop; tPartIter2!=tEndInnerLoop;tPartIter2++){
151 tThePair->SetTrack2(*tPartIter2);
152 // The following lines have to be uncommented if you want pairCutMonitors
153 // they are not in for speed reasons
154 // bool tmpPassPair = mPairCut->Pass(tThePair);
155 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
156 // if ( tmpPassPair ) {
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);
163 } // if passed pair cut
164 } // loop over second particle
165 } // loop over first particle
167 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - reals done" << endl;
170 AliFemtoParticleIterator nextIter;
171 AliFemtoParticleIterator prevIter;
173 // like sign first partilce collection pairs
174 prevIter = tEndOuterLoop;
176 for (tPartIter1=tStartOuterLoop;tPartIter1!=prevIter;tPartIter1++){
177 tThePair->SetTrack1(*tPartIter1);
178 nextIter = tPartIter1;
180 for (tPartIter2 = nextIter; tPartIter2!=tEndOuterLoop;tPartIter2++){
181 tThePair->SetTrack2(*tPartIter2);
182 // The following lines have to be uncommented if you want pairCutMonitors
183 // they are not in for speed reasons
184 // bool tmpPassPair = mPairCut->Pass(tThePair);
185 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
186 // if ( tmpPassPair ) {
187 if (fPairCut->Pass(tThePair)){
188 for (tCorrFctnIter=fCorrFctnCollection->begin();
189 tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
190 AliFemtoLikeSignCorrFctn* tCorrFctn = dynamic_cast<AliFemtoLikeSignCorrFctn*>(*tCorrFctnIter);
191 if (tCorrFctn) tCorrFctn->AddLikeSignPositivePair(tThePair);
193 } // if passed pair cut
194 } // loop over second particle
195 } // loop over first particle
197 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign first collection done" << endl;
199 // like sign second partilce collection pairs
200 prevIter = tEndInnerLoop;
202 for (tPartIter1=tStartInnerLoop;tPartIter1!=prevIter;tPartIter1++){
203 tThePair->SetTrack1(*tPartIter1);
204 nextIter = tPartIter1;
206 for (tPartIter2 = nextIter; tPartIter2!=tEndInnerLoop;tPartIter2++){
207 tThePair->SetTrack2(*tPartIter2);
208 // The following lines have to be uncommented if you want pairCutMonitors
209 // they are not in for speed reasons
210 // bool tmpPassPair = mPairCut->Pass(tThePair);
211 // mPairCut->FillCutMonitor(tThePair, tmpPassPair);
212 // if ( tmpPassPair ) {
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);
219 } // if passed pair cut
220 } // loop over second particle
221 } // loop over first particle
223 cout << "AliFemtoLikeSignAnalysis::ProcessEvent() - like sign second collection done" << endl;
226 if (MixingBufferFull()){
228 cout << "Mixing Buffer is full - lets rock and roll" << endl;
232 cout << "Mixing Buffer not full -gotta wait " << MixingBuffer()->size() << endl;
234 if (MixingBufferFull()){
235 tStartOuterLoop = picoEvent->FirstParticleCollection()->begin();
236 tEndOuterLoop = picoEvent->FirstParticleCollection()->end();
237 AliFemtoPicoEvent* storedEvent;
238 AliFemtoPicoEventIterator picoEventIter;
239 for (picoEventIter=MixingBuffer()->begin();picoEventIter!=MixingBuffer()->end();picoEventIter++){
240 storedEvent = *picoEventIter;
241 if (AnalyzeIdenticalParticles()){
242 tStartInnerLoop = storedEvent->FirstParticleCollection()->begin();
243 tEndInnerLoop = storedEvent->FirstParticleCollection()->end();
246 tStartInnerLoop = storedEvent->SecondParticleCollection()->begin();
247 tEndInnerLoop = storedEvent->SecondParticleCollection()->end();
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);
260 tCorrFctn->AddMixedPair(tThePair);
261 //cout << " tThePair has been added to MixedPair method " << endl;
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
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;