1 /***************************************************************************
2 * Author: Mike Lisa, Ohio State, lisa@mps.ohio-state.edu
3 ***************************************************************************
5 * Description: part of STAR HBT Framework: AliFemtoMaker package
6 * This is the Class for Analysis objects. Each of the simultaneous
7 * Analyses running should have one of these instantiated. They link
8 * into the Manager in an Analysis Collection.
10 ***************************************************************************
13 * Revision 1.23 2002/11/20 00:09:26 renault
14 * fill a new monitor with (hbtEvent,partCollection)
16 * Revision 1.22 2002/11/03 16:40:31 magestro
17 * Modified ProcessEvent(), added MakePairs() method, and implemented immediate event mixing
19 * Revision 1.21 2002/06/26 17:27:09 lisa
20 * fixed small bug in AliFemtoAnalysis associated with the new feature to require ParticleCollections to have some minimum number of particles
22 * Revision 1.20 2002/06/22 17:53:31 lisa
23 * implemented switch to allow user to require minimum number of particles in First and Second ParticleCollections - default value is zero so if user does not Set this value then behaviour is like before
25 * Revision 1.19 2001/11/06 20:20:53 laue
26 * Order of event-mixing fixed.
28 * Revision 1.18 2001/05/25 23:23:59 lisa
29 * Added in AliFemtoKink stuff
31 * Revision 1.17 2001/04/05 21:57:45 laue
32 * current pico-event becomes a member of the analysis (fPicoEvent) and gets
33 * an access-function (CurrentPicoEvent)
35 * Revision 1.15 2000/09/13 18:09:09 laue
36 * Bux fix: Delete track cut only once for identical particle hbt
38 * Revision 1.14 2000/08/31 22:31:30 laue
39 * AliFemtoAnalysis: output changed (a little bit less)
40 * AliFemtoEvent: new version, members for reference mult added
41 * AliFemtoIOBinary: new IO for new AliFemtoEvent version
42 * AliFemtoTypes: TTree typedef to AliFemtoTTree added
43 * AliFemtoVertexAnalysis: overflow and underflow added
45 * Revision 1.13 2000/08/11 16:35:40 rcwells
46 * Added number of events processed to each HBT analysis
48 * Revision 1.12 2000/07/16 22:23:17 laue
49 * I forgot that we moved memberfunctions out of AliFemtoBaseAnalysis.
50 * So my previous check-ins didn't compile with the library.
53 * Revision 1.11 2000/07/16 21:38:22 laue
54 * AliFemtoCoulomb.cxx AliFemtoSectoredAnalysis.cxx : updated for standalone version
55 * AliFemtoV0.cc AliFemtoV0.h : some cast to prevent compiling warnings
56 * AliFemtoParticle.cc AliFemtoParticle.h : pointers mTrack,mV0 initialized to 0
57 * AliFemtoIOBinary.cc : some printouts in #ifdef STHBTDEBUG
58 * AliFemtoEvent.cc : B-Field set to 0.25Tesla, we have to think about a better
61 * Revision 1.10 2000/07/06 18:45:51 laue
62 * Copy constructor fixed. It couldn't handle identicle particles.
64 * Revision 1.9 2000/04/13 20:20:22 laue
65 * Event mixing corrected. Now the first collection of the current event is
66 * mixed with the second collection from the mixing buffer _AND_ vice verse
68 * Revision 1.8 2000/03/23 23:00:01 laue
69 * AliFemtoAnalysis copy constructor now uses Clone() function of cuts
70 * AliFemtoTypes now has AliFemtoTF1 for fitting purposes
72 * Revision 1.7 2000/03/17 17:23:05 laue
73 * Roberts new three particle correlations implemented.
75 * Revision 1.6 2000/03/16 02:07:04 laue
76 * Copy constructor added to AliFemtoAnalysis (only known cuts, corrfctn).
78 * AliFemtoBinaryReader can now derive filename from StIOMaker and read a list
81 * AliFemtoManager now holds a collection of AliFemtoEventWriters (multiple writes
84 * Revision 1.5 2000/02/13 17:17:12 laue
85 * Calls to the EventBegin() and EventEnd() functions implemented
86 * The actual analysis is moved from AliFemtoManager to AliFemtoAnalysis
88 * Revision 1.4 2000/01/25 17:35:16 laue
89 * I. In order to run the stand alone version of the AliFemtoMaker the following
90 * changes have been done:
91 * a) all ClassDefs and ClassImps have been put into #ifdef __ROOT__ statements
92 * b) unnecessary includes of StMaker.h have been removed
93 * c) the subdirectory AliFemtoMaker/doc/Make has been created including everything
94 * needed for the stand alone version
96 * II. To reduce the amount of compiler warning
97 * a) some variables have been type casted
98 * b) some destructors have been declared as virtual
100 * Revision 1.3 1999/10/04 15:38:53 lisa
101 * include Franks new accessor methods AliFemtoAnalysis::CorrFctn and AliFemtoManager::Analysis as well as McEvent example macro
103 * Revision 1.2 1999/07/06 22:33:22 lisa
104 * Adjusted all to work in pro and new - dev itself is broken
106 * Revision 1.1.1.1 1999/06/29 16:02:57 lisa
107 * Installation of AliFemtoMaker
109 **************************************************************************/
111 #include "Analysis/AliFemtoAnalysis.h"
112 #include "Base/AliFemtoTrackCut.h"
113 #include "Base/AliFemtoV0Cut.h"
114 #include "Base/AliFemtoKinkCut.h"
119 ClassImp(AliFemtoAnalysis)
122 AliFemtoEventCut* copyTheCut(AliFemtoEventCut*);
123 AliFemtoParticleCut* copyTheCut(AliFemtoParticleCut*);
124 AliFemtoPairCut* copyTheCut(AliFemtoPairCut*);
125 AliFemtoCorrFctn* copyTheCorrFctn(AliFemtoCorrFctn*);
127 // this little function used to apply ParticleCuts (TrackCuts or V0Cuts) and fill ParticleCollections of picoEvent
128 // it is called from AliFemtoAnalysis::ProcessEvent()
129 void FillHbtParticleCollection(AliFemtoParticleCut* partCut,
130 AliFemtoEvent* hbtEvent,
131 AliFemtoParticleCollection* partCollection)
133 switch (partCut->Type()) {
134 case hbtTrack: // cut is cutting on Tracks
136 AliFemtoTrackCut* pCut = (AliFemtoTrackCut*) partCut;
137 AliFemtoTrack* pParticle;
138 AliFemtoTrackIterator pIter;
139 AliFemtoTrackIterator startLoop = hbtEvent->TrackCollection()->begin();
140 AliFemtoTrackIterator endLoop = hbtEvent->TrackCollection()->end();
141 for (pIter=startLoop;pIter!=endLoop;pIter++){
143 bool tmpPassParticle = pCut->Pass(pParticle);
144 pCut->FillCutMonitor(pParticle, tmpPassParticle);
145 if (tmpPassParticle){
146 AliFemtoParticle* particle = new AliFemtoParticle(pParticle,pCut->Mass());
147 partCollection->push_back(particle);
152 case hbtV0: // cut is cutting on V0s
154 AliFemtoV0Cut* pCut = (AliFemtoV0Cut*) partCut;
155 AliFemtoV0* pParticle;
156 AliFemtoV0Iterator pIter;
157 AliFemtoV0Iterator startLoop = hbtEvent->V0Collection()->begin();
158 AliFemtoV0Iterator endLoop = hbtEvent->V0Collection()->end();
159 // this following "for" loop is identical to the one above, but because of scoping, I can's see how to avoid repitition...
160 for (pIter=startLoop;pIter!=endLoop;pIter++){
162 bool tmpPassV0 = pCut->Pass(pParticle);
163 pCut->FillCutMonitor(pParticle,tmpPassV0);
165 AliFemtoParticle* particle = new AliFemtoParticle(pParticle,partCut->Mass());
166 partCollection->push_back(particle);
169 pCut->FillCutMonitor(hbtEvent,partCollection);// Gael 19/06/02
172 case hbtKink: // cut is cutting on Kinks -- mal 25May2001
174 AliFemtoKinkCut* pCut = (AliFemtoKinkCut*) partCut;
175 AliFemtoKink* pParticle;
176 AliFemtoKinkIterator pIter;
177 AliFemtoKinkIterator startLoop = hbtEvent->KinkCollection()->begin();
178 AliFemtoKinkIterator endLoop = hbtEvent->KinkCollection()->end();
179 // this following "for" loop is identical to the one above, but because of scoping, I can's see how to avoid repitition...
180 for (pIter=startLoop;pIter!=endLoop;pIter++){
182 bool tmpPass = pCut->Pass(pParticle);
183 pCut->FillCutMonitor(pParticle,tmpPass);
185 AliFemtoParticle* particle = new AliFemtoParticle(pParticle,partCut->Mass());
186 partCollection->push_back(particle);
192 cout << "FillHbtParticleCollection function (in AliFemtoAnalysis.cxx) - undefined Particle Cut type!!! \n";
195 //____________________________
196 AliFemtoAnalysis::AliFemtoAnalysis(){
197 // mControlSwitch = 0;
199 fFirstParticleCut = 0;
200 fSecondParticleCut = 0;
202 fCorrFctnCollection= 0;
203 fCorrFctnCollection = new AliFemtoCorrFctnCollection;
204 fMixingBuffer = new AliFemtoPicoEventCollection;
205 fNeventsProcessed = 0;
208 fPicoEventCollectionVectorHideAway = 0;
210 fMinSizePartCollection=0; // minimum # particles in ParticleCollection
213 //____________________________
215 AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) : AliFemtoBaseAnalysis() {
216 //AliFemtoAnalysis();
218 fFirstParticleCut = 0;
219 fSecondParticleCut = 0;
221 fCorrFctnCollection= 0;
222 fCorrFctnCollection = new AliFemtoCorrFctnCollection;
223 fMixingBuffer = new AliFemtoPicoEventCollection;
224 fNeventsProcessed = 0;
227 // find the right event cut
228 fEventCut = a.fEventCut->Clone();
229 // find the right first particle cut
230 fFirstParticleCut = a.fFirstParticleCut->Clone();
231 // find the right second particle cut
232 if (a.fFirstParticleCut==a.fSecondParticleCut)
233 SetSecondParticleCut(fFirstParticleCut); // identical particle hbt
235 fSecondParticleCut = a.fSecondParticleCut->Clone();
237 fPairCut = a.fPairCut->Clone();
240 SetEventCut(fEventCut); // this will set the myAnalysis pointer inside the cut
241 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - event cut set " << endl;
243 if ( fFirstParticleCut ) {
244 SetFirstParticleCut(fFirstParticleCut); // this will set the myAnalysis pointer inside the cut
245 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - first particle cut set " << endl;
247 if ( fSecondParticleCut ) {
248 SetSecondParticleCut(fSecondParticleCut); // this will set the myAnalysis pointer inside the cut
249 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - second particle cut set " << endl;
251 SetPairCut(fPairCut); // this will set the myAnalysis pointer inside the cut
252 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - pair cut set " << endl;
255 AliFemtoCorrFctnIterator iter;
256 for (iter=a.fCorrFctnCollection->begin(); iter!=a.fCorrFctnCollection->end();iter++){
257 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - looking for correlation functions " << endl;
258 AliFemtoCorrFctn* fctn = (*iter)->Clone();
259 if (fctn) AddCorrFctn(fctn);
260 else cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - correlation function not found " << endl;
263 fNumEventsToMix = a.fNumEventsToMix;
265 fMinSizePartCollection = a.fMinSizePartCollection; // minimum # particles in ParticleCollection
267 cout << " AliFemtoAnalysis::AliFemtoAnalysis(const AliFemtoAnalysis& a) - analysis copied " << endl;
270 //____________________________
271 AliFemtoAnalysis::~AliFemtoAnalysis(){
272 cout << " AliFemtoAnalysis::~AliFemtoAnalysis()" << endl;
273 if (fEventCut) delete fEventCut; fEventCut=0;
274 if (fFirstParticleCut == fSecondParticleCut) fSecondParticleCut=0;
275 if (fFirstParticleCut) delete fFirstParticleCut; fFirstParticleCut=0;
276 if (fSecondParticleCut) delete fSecondParticleCut; fSecondParticleCut=0;
277 if (fPairCut) delete fPairCut; fPairCut=0;
278 // now delete every CorrFunction in the Collection, and then the Collection itself
279 AliFemtoCorrFctnIterator iter;
280 for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
283 delete fCorrFctnCollection;
284 // now delete every PicoEvent in the EventMixingBuffer and then the Buffer itself
286 AliFemtoPicoEventIterator piter;
287 for (piter=fMixingBuffer->begin();piter!=fMixingBuffer->end();piter++){
290 delete fMixingBuffer;
293 //______________________
294 AliFemtoCorrFctn* AliFemtoAnalysis::CorrFctn(int n){ // return pointer to n-th correlation function
295 if ( n<0 || n > (int)fCorrFctnCollection->size() )
297 AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin();
298 for (int i=0; i<n ;i++){
303 //____________________________
304 AliFemtoString AliFemtoAnalysis::Report()
306 cout << "AliFemtoAnalysis - constructing Report..."<<endl;
307 string temp = "-----------\nHbt Analysis Report:\n";
308 temp += "\nEvent Cuts:\n";
309 temp += fEventCut->Report();
310 temp += "\nParticle Cuts - First Particle:\n";
311 temp += fFirstParticleCut->Report();
312 temp += "\nParticle Cuts - Second Particle:\n";
313 temp += fSecondParticleCut->Report();
314 temp += "\nPair Cuts:\n";
315 temp += fPairCut->Report();
316 temp += "\nCorrelation Functions:\n";
317 AliFemtoCorrFctnIterator iter;
318 if ( fCorrFctnCollection->size()==0 ) {
319 cout << "AliFemtoAnalysis-Warning : no correlations functions in this analysis " << endl;
321 for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
322 temp += (*iter)->Report();
325 temp += "-------------\n";
326 AliFemtoString returnThis=temp;
329 //_________________________
330 void AliFemtoAnalysis::ProcessEvent(const AliFemtoEvent* hbtEvent) {
331 // Add event to processed events
332 fPicoEvent=0; // we will get a new pico event, if not prevent corr. fctn to access old pico event
335 EventBegin(hbtEvent);
336 // event cut and event cut monitor
337 bool tmpPassEvent = fEventCut->Pass(hbtEvent);
338 fEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
340 cout << "AliFemtoAnalysis::ProcessEvent() - Event has passed cut - build picoEvent from " <<
341 hbtEvent->TrackCollection()->size() << " tracks in TrackCollection" << endl;
342 // OK, analysis likes the event-- build a pico event from it, using tracks the analysis likes...
343 fPicoEvent = new AliFemtoPicoEvent; // this is what we will make pairs from and put in Mixing Buffer
344 // no memory leak. we will delete picoevents when they come out of the mixing buffer
345 FillHbtParticleCollection(fFirstParticleCut,(AliFemtoEvent*)hbtEvent,fPicoEvent->FirstParticleCollection());
346 if ( !(AnalyzeIdenticalParticles()) )
347 FillHbtParticleCollection(fSecondParticleCut,(AliFemtoEvent*)hbtEvent,fPicoEvent->SecondParticleCollection());
348 cout <<"AliFemtoAnalysis::ProcessEvent - #particles in First, Second Collections: " <<
349 fPicoEvent->FirstParticleCollection()->size() << " " <<
350 fPicoEvent->SecondParticleCollection()->size() << endl;
352 // mal - implement a switch which allows only using events with ParticleCollections containing a minimum
353 // number of entries (jun2002)
354 if ((fPicoEvent->FirstParticleCollection()->size() >= fMinSizePartCollection )
355 && ( AnalyzeIdenticalParticles() || (fPicoEvent->SecondParticleCollection()->size() >= fMinSizePartCollection ))) {
358 //------------------------------------------------------------------------------
359 // Temporary comment:
360 // This whole section rewritten so that all pairs are built using the
361 // same code... easier to read and manage, and MakePairs() can be called by
362 // derived classes. Also, the requirement of a full mixing buffer before
363 // mixing is removed.
364 // Dan Magestro, 11/2002
366 //------ Make real pairs. If identical, make pairs for one collection ------//
368 if (AnalyzeIdenticalParticles()) {
369 MakePairs("real", fPicoEvent->FirstParticleCollection() );
372 MakePairs("real", fPicoEvent->FirstParticleCollection(),
373 fPicoEvent->SecondParticleCollection() );
375 cout << "AliFemtoAnalysis::ProcessEvent() - reals done ";
377 //---- Make pairs for mixed events, looping over events in mixingBuffer ----//
379 AliFemtoPicoEvent* storedEvent;
380 AliFemtoPicoEventIterator fPicoEventIter;
381 for (fPicoEventIter=MixingBuffer()->begin();fPicoEventIter!=MixingBuffer()->end();fPicoEventIter++){
382 storedEvent = *fPicoEventIter;
383 if (AnalyzeIdenticalParticles()) {
384 MakePairs("mixed",fPicoEvent->FirstParticleCollection(),
385 storedEvent->FirstParticleCollection() );
388 MakePairs("mixed",fPicoEvent->FirstParticleCollection(),
389 storedEvent->SecondParticleCollection() );
391 MakePairs("mixed",storedEvent->FirstParticleCollection(),
392 fPicoEvent->SecondParticleCollection() );
395 cout << " - mixed done " << endl;
397 //--------- If mixing buffer is full, delete oldest event ---------//
399 if ( MixingBufferFull() ) {
400 delete MixingBuffer()->back();
401 MixingBuffer()->pop_back();
404 //-------- Add current event (fPicoEvent) to mixing buffer --------//
406 MixingBuffer()->push_front(fPicoEvent);
409 // Temporary comment: End of rewritten section... Dan Magestro, 11/2002
410 //------------------------------------------------------------------------------
413 } // if ParticleCollections are big enough (mal jun2002)
417 } // if currentEvent is accepted by currentAnalysis
418 EventEnd(hbtEvent); // cleanup for EbyE
419 //cout << "AliFemtoAnalysis::ProcessEvent() - return to caller ... " << endl;
421 //_________________________
422 void AliFemtoAnalysis::MakePairs(const char* typeIn, AliFemtoParticleCollection *partCollection1,
423 AliFemtoParticleCollection *partCollection2){
424 // Build pairs, check pair cuts, and call CFs' AddRealPair() or
425 // AddMixedPair() methods. If no second particle collection is
426 // specfied, make pairs within first particle collection.
428 string type = typeIn;
430 AliFemtoPair* ThePair = new AliFemtoPair;
432 AliFemtoCorrFctnIterator CorrFctnIter;
434 AliFemtoParticleIterator PartIter1, PartIter2;
436 AliFemtoParticleIterator StartOuterLoop = partCollection1->begin(); // always
437 AliFemtoParticleIterator EndOuterLoop = partCollection1->end(); // will be one less if identical
438 AliFemtoParticleIterator StartInnerLoop;
439 AliFemtoParticleIterator EndInnerLoop;
440 if (partCollection2) { // Two collections:
441 StartInnerLoop = partCollection2->begin(); // Full inner & outer loops
442 EndInnerLoop = partCollection2->end(); //
444 else { // One collection:
445 EndOuterLoop--; // Outer loop goes to next-to-last particle
446 EndInnerLoop = partCollection1->end() ; // Inner loop goes to last particle
448 for (PartIter1=StartOuterLoop;PartIter1!=EndOuterLoop;PartIter1++) {
449 if (!partCollection2){
450 StartInnerLoop = PartIter1;
453 ThePair->SetTrack1(*PartIter1);
454 for (PartIter2 = StartInnerLoop; PartIter2!=EndInnerLoop;PartIter2++) {
455 ThePair->SetTrack2(*PartIter2);
457 // The following lines have to be uncommented if you want pairCutMonitors
458 // they are not in for speed reasons
459 // bool tmpPassPair = fPairCut->Pass(ThePair);
460 // fPairCut->FillCutMonitor(ThePair, tmpPassPair);
461 // if ( tmpPassPair )
463 //---- If pair passes cut, loop over CF's and add pair to real/mixed ----//
465 if (fPairCut->Pass(ThePair)){
466 for (CorrFctnIter=fCorrFctnCollection->begin();
467 CorrFctnIter!=fCorrFctnCollection->end();CorrFctnIter++){
468 AliFemtoCorrFctn* CorrFctn = *CorrFctnIter;
470 CorrFctn->AddRealPair(ThePair);
471 else if(type == "mixed")
472 CorrFctn->AddMixedPair(ThePair);
474 cout << "Problem with pair type, type = " << type.c_str() << endl;
478 } // loop over second particle
480 } // loop over first particle
485 //_________________________
486 void AliFemtoAnalysis::EventBegin(const AliFemtoEvent* ev){
487 //cout << " AliFemtoAnalysis::EventBegin(const AliFemtoEvent* ev) " << endl;
488 fFirstParticleCut->EventBegin(ev);
489 fSecondParticleCut->EventBegin(ev);
490 fPairCut->EventBegin(ev);
491 for (AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
492 (*iter)->EventBegin(ev);
495 //_________________________
496 void AliFemtoAnalysis::EventEnd(const AliFemtoEvent* ev){
497 fFirstParticleCut->EventEnd(ev);
498 fSecondParticleCut->EventEnd(ev);
499 fPairCut->EventEnd(ev);
500 for (AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
501 (*iter)->EventEnd(ev);
504 //_________________________
505 void AliFemtoAnalysis::Finish(){
506 AliFemtoCorrFctnIterator iter;
507 for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
511 //_________________________
512 void AliFemtoAnalysis::AddEventProcessed() {