]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FEMTOSCOPY/AliFemto/AliFemtoSimpleAnalysis.cxx
Bring AliFemto up to date with latest code developements
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / AliFemto / AliFemtoSimpleAnalysis.cxx
1 ///////////////////////////////////////////////////////////////////////////
2 //                                                                       //
3 // AliFemtoSimpleAnalysis - the most basic analysis there is. All other        //
4 // inherit from this one. Provides basic functionality for the analysis. //
5 // To properly set up the analysis the following steps should be taken:  //
6 //                                                                       //
7 // - create particle cuts and add them via SetFirstParticleCut and       //
8 //   SetSecondParticleCut. If one analyzes identical particle            //
9 //   correlations, the first particle cut must be also the second        //
10 //   particle cut.                                                       //
11 //                                                                       //
12 // - create pair cuts and add them via SetPairCut                        //
13 //                                                                       //
14 // - create one or many correlation functions and add them via           //
15 //   AddCorrFctn method.                                                 //
16 //                                                                       //
17 // - specify how many events are to be strored in the mixing buffer for  //
18 //   background construction                                             //
19 //                                                                       //
20 // Then, when the analysis is run, for each event, the EventBegin is     //
21 // called before any processing is done, then the ProcessEvent is called //
22 // which takes care of creating real and mixed pairs and sending them    //
23 // to all the registered correlation functions. At the end of each event,//
24 // after all pairs are processed, EventEnd is called. After the whole    //
25 // analysis finishes (there is no more events to process) Finish() is    //
26 // called.                                                               //
27 //                                                                       //
28 ///////////////////////////////////////////////////////////////////////////
29 #include "AliFemtoSimpleAnalysis.h"
30 #include "AliFemtoTrackCut.h"
31 #include "AliFemtoV0Cut.h"
32 #include "AliFemtoKinkCut.h"
33 #include <string>
34 #include <iostream>
35
36 // blah blah
37
38 #ifdef __ROOT__ 
39 ClassImp(AliFemtoSimpleAnalysis)
40 #endif
41
42 AliFemtoEventCut*    copyTheCut(AliFemtoEventCut*);
43 AliFemtoParticleCut* copyTheCut(AliFemtoParticleCut*);
44 AliFemtoPairCut*     copyTheCut(AliFemtoPairCut*);
45 AliFemtoCorrFctn*    copyTheCorrFctn(AliFemtoCorrFctn*);
46
47 // this little function used to apply ParticleCuts (TrackCuts or V0Cuts) and fill ParticleCollections of picoEvent
48 //  it is called from AliFemtoSimpleAnalysis::ProcessEvent()
49 void FillHbtParticleCollection(AliFemtoParticleCut*         partCut,
50                                AliFemtoEvent*               hbtEvent,
51                                AliFemtoParticleCollection*  partCollection)
52 {
53   // Fill particle collections from the event
54   // by the particles that pass all the cuts
55   switch (partCut->Type()) {
56   case hbtTrack:       // cut is cutting on Tracks
57     {
58       AliFemtoTrackCut* pCut = (AliFemtoTrackCut*) partCut;
59       AliFemtoTrack* pParticle;
60       AliFemtoTrackIterator pIter;
61       AliFemtoTrackIterator startLoop = hbtEvent->TrackCollection()->begin();
62       AliFemtoTrackIterator endLoop   = hbtEvent->TrackCollection()->end();
63       for (pIter=startLoop;pIter!=endLoop;pIter++){
64         pParticle = *pIter;
65         bool tmpPassParticle = pCut->Pass(pParticle);
66         pCut->FillCutMonitor(pParticle, tmpPassParticle);
67         if (tmpPassParticle){   
68           AliFemtoParticle* particle = new AliFemtoParticle(pParticle,pCut->Mass());
69           partCollection->push_back(particle);
70         }
71       }
72       break;
73     }
74   case hbtV0:          // cut is cutting on V0s
75     {
76       AliFemtoV0Cut* pCut = (AliFemtoV0Cut*) partCut;
77       AliFemtoV0* pParticle;
78       AliFemtoV0Iterator pIter;
79       AliFemtoV0Iterator startLoop = hbtEvent->V0Collection()->begin();
80       AliFemtoV0Iterator endLoop   = hbtEvent->V0Collection()->end();
81       // this following "for" loop is identical to the one above, but because of scoping, I can's see how to avoid repitition...
82       for (pIter=startLoop;pIter!=endLoop;pIter++){
83         pParticle = *pIter; 
84         bool tmpPassV0 = pCut->Pass(pParticle);
85         pCut->FillCutMonitor(pParticle,tmpPassV0);
86         if (tmpPassV0){
87           AliFemtoParticle* particle = new AliFemtoParticle(pParticle,partCut->Mass());
88           partCollection->push_back(particle);
89         }
90       }
91       pCut->FillCutMonitor(hbtEvent,partCollection);// Gael 19/06/02
92       break;
93     }
94   case hbtKink:          // cut is cutting on Kinks  -- mal 25May2001
95     {
96       AliFemtoKinkCut* pCut = (AliFemtoKinkCut*) partCut;
97       AliFemtoKink* pParticle;
98       AliFemtoKinkIterator pIter;
99       AliFemtoKinkIterator startLoop = hbtEvent->KinkCollection()->begin();
100       AliFemtoKinkIterator endLoop   = hbtEvent->KinkCollection()->end();
101       // this following "for" loop is identical to the one above, but because of scoping, I can's see how to avoid repitition...
102       for (pIter=startLoop;pIter!=endLoop;pIter++){
103         pParticle = *pIter; 
104         bool tmpPass = pCut->Pass(pParticle);
105         pCut->FillCutMonitor(pParticle,tmpPass);
106         if (tmpPass){
107           AliFemtoParticle* particle = new AliFemtoParticle(pParticle,partCut->Mass());
108           partCollection->push_back(particle);
109         }
110       }
111       break;
112     }
113   default:
114     cout << "FillHbtParticleCollection function (in AliFemtoSimpleAnalysis.cxx) - undefined Particle Cut type!!! \n";
115   }
116 }
117 //____________________________
118 AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis() :
119   fPicoEventCollectionVectorHideAway(0), 
120   fPairCut(0),            
121   fCorrFctnCollection(0), 
122   fEventCut(0),           
123   fFirstParticleCut(0),   
124   fSecondParticleCut(0),  
125   fMixingBuffer(0),       
126   fPicoEvent(0),          
127   fNumEventsToMix(0),                     
128   fNeventsProcessed(0),                   
129   fMinSizePartCollection(0)
130 {
131   // Default constructor
132   //  mControlSwitch     = 0;
133   fCorrFctnCollection = new AliFemtoCorrFctnCollection;
134   fMixingBuffer = new AliFemtoPicoEventCollection;
135 }
136 //____________________________
137
138 AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) : 
139   AliFemtoAnalysis(),
140   fPicoEventCollectionVectorHideAway(0), 
141   fPairCut(0),            
142   fCorrFctnCollection(0), 
143   fEventCut(0),           
144   fFirstParticleCut(0),   
145   fSecondParticleCut(0),  
146   fMixingBuffer(0),       
147   fPicoEvent(0),          
148   fNumEventsToMix(0),                     
149   fNeventsProcessed(0),                   
150   fMinSizePartCollection(0)
151 {
152   // Copy constructor
153   //AliFemtoSimpleAnalysis();
154   fCorrFctnCollection = new AliFemtoCorrFctnCollection;
155   fMixingBuffer = new AliFemtoPicoEventCollection;
156
157   // find the right event cut
158   fEventCut = a.fEventCut->Clone();
159   // find the right first particle cut
160   fFirstParticleCut = a.fFirstParticleCut->Clone();
161   // find the right second particle cut
162   if (a.fFirstParticleCut==a.fSecondParticleCut) 
163     SetSecondParticleCut(fFirstParticleCut); // identical particle hbt
164   else
165   fSecondParticleCut = a.fSecondParticleCut->Clone();
166
167   fPairCut = a.fPairCut->Clone();
168   
169   if ( fEventCut ) {
170       SetEventCut(fEventCut); // this will set the myAnalysis pointer inside the cut
171       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - event cut set " << endl;
172   }
173   if ( fFirstParticleCut ) {
174       SetFirstParticleCut(fFirstParticleCut); // this will set the myAnalysis pointer inside the cut
175       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - first particle cut set " << endl;
176   }
177   if ( fSecondParticleCut ) {
178       SetSecondParticleCut(fSecondParticleCut); // this will set the myAnalysis pointer inside the cut
179       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - second particle cut set " << endl;
180   }  if ( fPairCut ) {
181       SetPairCut(fPairCut); // this will set the myAnalysis pointer inside the cut
182       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - pair cut set " << endl;
183   }
184
185   AliFemtoCorrFctnIterator iter;
186   for (iter=a.fCorrFctnCollection->begin(); iter!=a.fCorrFctnCollection->end();iter++){
187     cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - looking for correlation functions " << endl;
188     AliFemtoCorrFctn* fctn = (*iter)->Clone();
189     if (fctn) AddCorrFctn(fctn);
190     else cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - correlation function not found " << endl;
191   }
192
193   fNumEventsToMix = a.fNumEventsToMix;
194
195   fMinSizePartCollection = a.fMinSizePartCollection;  // minimum # particles in ParticleCollection
196
197   cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - analysis copied " << endl;
198
199 }
200 //____________________________
201 AliFemtoSimpleAnalysis::~AliFemtoSimpleAnalysis(){
202   // destructor
203   cout << " AliFemtoSimpleAnalysis::~AliFemtoSimpleAnalysis()" << endl;
204   if (fEventCut) delete fEventCut; fEventCut=0;
205   if (fFirstParticleCut == fSecondParticleCut) fSecondParticleCut=0;
206   if (fFirstParticleCut)  delete fFirstParticleCut; fFirstParticleCut=0;
207   if (fSecondParticleCut) delete fSecondParticleCut; fSecondParticleCut=0;
208   if (fPairCut) delete fPairCut; fPairCut=0;
209   // now delete every CorrFunction in the Collection, and then the Collection itself
210   AliFemtoCorrFctnIterator iter;
211   for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
212     delete *iter;
213   }
214   delete fCorrFctnCollection;
215   // now delete every PicoEvent in the EventMixingBuffer and then the Buffer itself
216   if (fMixingBuffer) {
217     AliFemtoPicoEventIterator piter;
218     for (piter=fMixingBuffer->begin();piter!=fMixingBuffer->end();piter++){
219       delete *piter;
220     }
221     delete fMixingBuffer;
222   }
223 }
224 //______________________
225 AliFemtoSimpleAnalysis& AliFemtoSimpleAnalysis::operator=(const AliFemtoSimpleAnalysis& aAna) 
226 {
227   // Assignment operator
228   if (this == &aAna)
229     return *this;
230
231   fCorrFctnCollection = new AliFemtoCorrFctnCollection;
232   fMixingBuffer = new AliFemtoPicoEventCollection;
233
234   // find the right event cut
235   fEventCut = aAna.fEventCut->Clone();
236   // find the right first particle cut
237   fFirstParticleCut = aAna.fFirstParticleCut->Clone();
238   // find the right second particle cut
239   if (aAna.fFirstParticleCut==aAna.fSecondParticleCut) 
240     SetSecondParticleCut(fFirstParticleCut); // identical particle hbt
241   else
242     fSecondParticleCut = aAna.fSecondParticleCut->Clone();
243
244   fPairCut = aAna.fPairCut->Clone();
245   
246   if ( fEventCut ) {
247       SetEventCut(fEventCut); // this will set the myAnalysis pointer inside the cut
248       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - event cut set " << endl;
249   }
250   if ( fFirstParticleCut ) {
251       SetFirstParticleCut(fFirstParticleCut); // this will set the myAnalysis pointer inside the cut
252       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - first particle cut set " << endl;
253   }
254   if ( fSecondParticleCut ) {
255       SetSecondParticleCut(fSecondParticleCut); // this will set the myAnalysis pointer inside the cut
256       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - second particle cut set " << endl;
257   }  if ( fPairCut ) {
258       SetPairCut(fPairCut); // this will set the myAnalysis pointer inside the cut
259       cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - pair cut set " << endl;
260   }
261
262   AliFemtoCorrFctnIterator iter;
263   for (iter=aAna.fCorrFctnCollection->begin(); iter!=aAna.fCorrFctnCollection->end();iter++){
264     cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - looking for correlation functions " << endl;
265     AliFemtoCorrFctn* fctn = (*iter)->Clone();
266     if (fctn) AddCorrFctn(fctn);
267     else cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - correlation function not found " << endl;
268   }
269
270   fNumEventsToMix = aAna.fNumEventsToMix;
271
272   fMinSizePartCollection = aAna.fMinSizePartCollection;  // minimum # particles in ParticleCollection
273
274   cout << " AliFemtoSimpleAnalysis::AliFemtoSimpleAnalysis(const AliFemtoSimpleAnalysis& a) - analysis copied " << endl;
275
276   return *this;
277 }
278 //______________________
279 AliFemtoCorrFctn* AliFemtoSimpleAnalysis::CorrFctn(int n){  
280   // return pointer to n-th correlation function
281   if ( n<0 || n > (int)fCorrFctnCollection->size() )
282     return NULL;
283   AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin();
284   for (int i=0; i<n ;i++){
285     iter++;
286   }
287   return *iter;
288 }
289 //____________________________
290 AliFemtoString AliFemtoSimpleAnalysis::Report()
291 {
292   // Create a simple report from the analysis execution
293   cout << "AliFemtoSimpleAnalysis - constructing Report..."<<endl;
294   string temp = "-----------\nHbt Analysis Report:\n";
295   temp += "\nEvent Cuts:\n";
296   temp += fEventCut->Report();
297   temp += "\nParticle Cuts - First Particle:\n";
298   temp += fFirstParticleCut->Report();
299   temp += "\nParticle Cuts - Second Particle:\n";
300   temp += fSecondParticleCut->Report();
301   temp += "\nPair Cuts:\n";
302   temp += fPairCut->Report();
303   temp += "\nCorrelation Functions:\n";
304   AliFemtoCorrFctnIterator iter;
305   if ( fCorrFctnCollection->size()==0 ) {
306     cout << "AliFemtoSimpleAnalysis-Warning : no correlations functions in this analysis " << endl;
307   }
308   for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
309     temp += (*iter)->Report();
310     temp += "\n";
311   }
312   temp += "-------------\n";
313   AliFemtoString returnThis=temp;
314   return returnThis;
315 }
316 //_________________________
317 void AliFemtoSimpleAnalysis::ProcessEvent(const AliFemtoEvent* hbtEvent) {
318   // Add event to processed events
319   fPicoEvent=0; // we will get a new pico event, if not prevent corr. fctn to access old pico event
320   AddEventProcessed();
321   // startup for EbyE 
322   EventBegin(hbtEvent);  
323   // event cut and event cut monitor
324   bool tmpPassEvent = fEventCut->Pass(hbtEvent);
325   fEventCut->FillCutMonitor(hbtEvent, tmpPassEvent);
326   if (tmpPassEvent) {
327     cout << "AliFemtoSimpleAnalysis::ProcessEvent() - Event has passed cut - build picoEvent from " <<
328       hbtEvent->TrackCollection()->size() << " tracks in TrackCollection" << endl;
329     // OK, analysis likes the event-- build a pico event from it, using tracks the analysis likes...
330     fPicoEvent = new AliFemtoPicoEvent; // this is what we will make pairs from and put in Mixing Buffer
331     // no memory leak. we will delete picoevents when they come out of the mixing buffer
332     FillHbtParticleCollection(fFirstParticleCut,(AliFemtoEvent*)hbtEvent,fPicoEvent->FirstParticleCollection());
333     if ( !(AnalyzeIdenticalParticles()) )
334       FillHbtParticleCollection(fSecondParticleCut,(AliFemtoEvent*)hbtEvent,fPicoEvent->SecondParticleCollection());
335     cout <<"AliFemtoSimpleAnalysis::ProcessEvent - #particles in First, Second Collections: " <<
336       fPicoEvent->FirstParticleCollection()->size() << " " <<
337       fPicoEvent->SecondParticleCollection()->size() << endl;
338     
339     // mal - implement a switch which allows only using events with ParticleCollections containing a minimum
340     // number of entries (jun2002)
341     if ((fPicoEvent->FirstParticleCollection()->size() >= fMinSizePartCollection )
342         && ( AnalyzeIdenticalParticles() || (fPicoEvent->SecondParticleCollection()->size() >= fMinSizePartCollection ))) {
343
344
345 //------------------------------------------------------------------------------
346 //   Temporary comment:
347 //      This whole section rewritten so that all pairs are built using the
348 //      same code... easier to read and manage, and MakePairs() can be called by
349 //      derived classes.  Also, the requirement of a full mixing buffer before
350 //      mixing is removed.
351 //                          Dan Magestro, 11/2002
352
353       //------ Make real pairs. If identical, make pairs for one collection ------//
354
355       if (AnalyzeIdenticalParticles()) {
356         MakePairs("real", fPicoEvent->FirstParticleCollection() );
357       }
358       else {
359         MakePairs("real", fPicoEvent->FirstParticleCollection(),
360                           fPicoEvent->SecondParticleCollection() );
361       }
362       cout << "AliFemtoSimpleAnalysis::ProcessEvent() - reals done ";
363
364       //---- Make pairs for mixed events, looping over events in mixingBuffer ----//
365
366       AliFemtoPicoEvent* storedEvent;
367       AliFemtoPicoEventIterator fPicoEventIter;
368       for (fPicoEventIter=MixingBuffer()->begin();fPicoEventIter!=MixingBuffer()->end();fPicoEventIter++){
369         storedEvent = *fPicoEventIter;
370         if (AnalyzeIdenticalParticles()) {
371           MakePairs("mixed",fPicoEvent->FirstParticleCollection(),
372                             storedEvent->FirstParticleCollection() );
373         }
374         else {
375           MakePairs("mixed",fPicoEvent->FirstParticleCollection(),
376                             storedEvent->SecondParticleCollection() );
377
378           MakePairs("mixed",storedEvent->FirstParticleCollection(),
379                             fPicoEvent->SecondParticleCollection() );
380         }
381       }
382       cout << " - mixed done   " << endl;
383
384       //--------- If mixing buffer is full, delete oldest event ---------//
385
386       if ( MixingBufferFull() ) {
387         delete MixingBuffer()->back();
388         MixingBuffer()->pop_back();
389       }
390
391       //-------- Add current event (fPicoEvent) to mixing buffer --------//
392
393       MixingBuffer()->push_front(fPicoEvent);
394
395
396 // Temporary comment: End of rewritten section... Dan Magestro, 11/2002
397 //------------------------------------------------------------------------------
398
399
400     }  // if ParticleCollections are big enough (mal jun2002)
401     else{
402       delete fPicoEvent;
403     }
404   }   // if currentEvent is accepted by currentAnalysis
405   EventEnd(hbtEvent);  // cleanup for EbyE 
406   //cout << "AliFemtoSimpleAnalysis::ProcessEvent() - return to caller ... " << endl;
407 }
408 //_________________________
409 void AliFemtoSimpleAnalysis::MakePairs(const char* typeIn, AliFemtoParticleCollection *partCollection1,
410                                             AliFemtoParticleCollection *partCollection2){
411 // Build pairs, check pair cuts, and call CFs' AddRealPair() or
412 // AddMixedPair() methods. If no second particle collection is
413 // specfied, make pairs within first particle collection.
414
415   string type = typeIn;
416
417   AliFemtoPair* tPair = new AliFemtoPair;
418
419   AliFemtoCorrFctnIterator tCorrFctnIter;
420
421   AliFemtoParticleIterator tPartIter1, tPartIter2;
422
423   AliFemtoParticleIterator tStartOuterLoop = partCollection1->begin();  // always
424   AliFemtoParticleIterator tEndOuterLoop   = partCollection1->end();    // will be one less if identical
425   AliFemtoParticleIterator tStartInnerLoop;
426   AliFemtoParticleIterator tEndInnerLoop;
427   if (partCollection2) {                        // Two collections:
428     tStartInnerLoop = partCollection2->begin();  //   Full inner & outer loops
429     tEndInnerLoop   = partCollection2->end();    //
430   }
431   else {                                        // One collection:
432     tEndOuterLoop--;                             //   Outer loop goes to next-to-last particle
433     tEndInnerLoop = partCollection1->end() ;     //   Inner loop goes to last particle
434   }
435   for (tPartIter1=tStartOuterLoop;tPartIter1!=tEndOuterLoop;tPartIter1++) {
436     if (!partCollection2){
437       tStartInnerLoop = tPartIter1;
438       tStartInnerLoop++;
439     }
440     tPair->SetTrack1(*tPartIter1);
441     for (tPartIter2 = tStartInnerLoop; tPartIter2!=tEndInnerLoop;tPartIter2++) {
442       tPair->SetTrack2(*tPartIter2);
443
444       // The following lines have to be uncommented if you want pairCutMonitors
445       // they are not in for speed reasons
446       // bool tmpPassPair = fPairCut->Pass(tPair);
447       // fPairCut->FillCutMonitor(tPair, tmpPassPair);
448       // if ( tmpPassPair )
449
450       //---- If pair passes cut, loop over CF's and add pair to real/mixed ----//
451
452       if (fPairCut->Pass(tPair)){
453         for (tCorrFctnIter=fCorrFctnCollection->begin();
454              tCorrFctnIter!=fCorrFctnCollection->end();tCorrFctnIter++){
455           AliFemtoCorrFctn* tCorrFctn = *tCorrFctnIter;
456           if(type == "real")
457             tCorrFctn->AddRealPair(tPair);
458           else if(type == "mixed")
459             tCorrFctn->AddMixedPair(tPair);
460           else
461             cout << "Problem with pair type, type = " << type.c_str() << endl;
462         }
463       }
464
465     }    // loop over second particle
466
467   }      // loop over first particle
468
469   delete tPair;
470
471 }
472 //_________________________
473 void AliFemtoSimpleAnalysis::EventBegin(const AliFemtoEvent* ev){
474   // Perform initialization operations at the beginning of the event processing
475   //cout << " AliFemtoSimpleAnalysis::EventBegin(const AliFemtoEvent* ev) " << endl;
476   fFirstParticleCut->EventBegin(ev);
477   fSecondParticleCut->EventBegin(ev);
478   fPairCut->EventBegin(ev);
479   for (AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
480     (*iter)->EventBegin(ev);
481   }
482 }
483 //_________________________
484 void AliFemtoSimpleAnalysis::EventEnd(const AliFemtoEvent* ev){
485   // Fiinsh operations at the end of event processing
486   fFirstParticleCut->EventEnd(ev);
487   fSecondParticleCut->EventEnd(ev);
488   fPairCut->EventEnd(ev);
489   for (AliFemtoCorrFctnIterator iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
490     (*iter)->EventEnd(ev);
491   }
492 }
493 //_________________________
494 void AliFemtoSimpleAnalysis::Finish(){
495   // Perform finishing operations after all events are processed
496   AliFemtoCorrFctnIterator iter;
497   for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
498     (*iter)->Finish();
499   }
500 }
501 //_________________________
502 void AliFemtoSimpleAnalysis::AddEventProcessed() {
503   // Increase count of processed events
504   fNeventsProcessed++;
505 }
506 //_________________________
507 TList* AliFemtoSimpleAnalysis::ListSettings()
508 {
509   // Collect settings list
510   TList *tListSettings = new TList();
511
512   TList *p1Cut = fFirstParticleCut->ListSettings();
513
514   TListIter nextp1(p1Cut);
515   while (TObject *obj = nextp1.Next()) {
516     TString cuts(obj->GetName());
517     cuts.Prepend("AliFemtoSimpleAnalysis.");
518     tListSettings->Add(new TObjString(cuts.Data()));
519   }
520
521   if (fSecondParticleCut != fFirstParticleCut) {
522     TList *p2Cut = fSecondParticleCut->ListSettings();
523     
524     TIter nextp2(p2Cut);
525     while (TObject *obj = nextp2()) {
526       TString cuts(obj->GetName());
527       cuts.Prepend("AliFemtoSimpleAnalysis.");
528       tListSettings->Add(new TObjString(cuts.Data()));
529     }
530   }
531
532   TList *pairCut = fPairCut->ListSettings();
533
534   TIter nextpair(pairCut);
535   while (TObject *obj = nextpair()) {
536     TString cuts(obj->GetName());
537     cuts.Prepend("AliFemtoSimpleAnalysis.");
538     tListSettings->Add(new TObjString(cuts.Data()));
539   }
540
541   return tListSettings;
542   
543 }
544
545 //_________________________
546 TList* AliFemtoSimpleAnalysis::GetOutputList()
547 {
548   // Collect the list of output objects
549   // to be written 
550   TList *tOutputList = new TList();
551
552   TList *p1Cut = fFirstParticleCut->GetOutputList();
553
554   TListIter nextp1(p1Cut);
555   while (TObject *obj = nextp1.Next()) {
556     tOutputList->Add(obj);
557   }
558
559   if (fSecondParticleCut != fFirstParticleCut) {
560     TList *p2Cut = fSecondParticleCut->GetOutputList();
561     
562     TIter nextp2(p2Cut);
563     while (TObject *obj = nextp2()) {
564       tOutputList->Add(obj);
565     }
566   }
567
568   TList *pairCut = fPairCut->GetOutputList();
569
570   TIter nextpair(pairCut);
571   while (TObject *obj = nextpair()) {
572     tOutputList->Add(obj);
573   }
574
575   AliFemtoCorrFctnIterator iter;
576   for (iter=fCorrFctnCollection->begin(); iter!=fCorrFctnCollection->end();iter++){
577     TList *tListCf = (*iter)->GetOutputList();
578     
579     TIter nextListCf(tListCf);
580     while (TObject *obj = nextListCf()) {
581       tOutputList->Add(obj);
582     }
583   }
584
585   return tOutputList;
586   
587 }