f13e5122f3e3d6329a0f52a19d786cce0fb1c64a
[u/mrichter/AliRoot.git] / HBTAN / AliHBTAnalysisStavinskyMixing.cxx
1 #include "AliHBTAnalysisStavinskyMixing.h"
2 //_________________________________________________________
3 ////////////////////////////////////////////////////////////////////////////
4 //
5 // class AliHBTAnalysisStavinskyMixing
6 //
7 // Central Object Of HBTAnalyser: 
8 // This class performs main looping within HBT Analysis
9 // User must plug a reader of Type AliReader
10 // User plugs in coorelation and monitor functions
11 // as well as monitor functions
12 //
13 // HBT Analysis Tool, which is integral part of AliRoot,
14 // ALICE Off-Line framework:
15 //
16 // Piotr.Skowronski@cern.ch
17 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
18 //
19 ////////////////////////////////////////////////////////////////////////////
20 //_________________________________________________________
21
22
23 #include <TSystem.h>
24 #include <TFile.h>
25
26 #include "AliAOD.h"
27 #include "AliAODParticle.h"
28 #include "AliAODPairCut.h"
29 #include "AliEventCut.h"
30
31 #include "AliEventBuffer.h"
32
33 #include "AliReader.h"
34 #include "AliHBTPair.h"
35 #include "AliHBTFunction.h"
36 #include "AliHBTMonitorFunction.h"
37  
38
39 ClassImp(AliHBTAnalysisStavinskyMixing)
40
41
42 Int_t AliHBTAnalysisStavinskyMixing::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
43 {
44 //Does analysis for both tracks and particles
45 //mainly for resolution study and analysies with weighting algirithms
46   
47 // cut on particles only -- why?
48 // - PID: when we make resolution analysis we want to take only tracks with correct PID
49 // We need cut on tracks because there are data characteristic
50   
51   AliVAODParticle * part1, * part2;
52   AliVAODParticle * track1, * track2;
53   
54   AliAOD * trackEvent = aodrec, *partEvent = aodsim;
55   AliAOD* trackEvent1 = new AliAOD();
56   AliAOD* partEvent1 = new AliAOD();
57
58   AliAOD * trackEvent2,*partEvent2;
59   
60 //  Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
61   
62 //  Int_t nev = fReader->GetNumberOfTrackEvents();
63   static AliHBTPair tpair;
64   static AliHBTPair ppair;
65
66   AliHBTPair* trackpair = &tpair;
67   AliHBTPair* partpair = &ppair;
68  
69   AliHBTPair * tmptrackpair;//temprary pointers to pairs
70   AliHBTPair * tmppartpair;
71   
72   register UInt_t ii;
73   
74   
75
76   if ( !partEvent || !trackEvent ) 
77    {
78      Error("ProcessRecAndSim","<<%s>> Can not get event",GetName());
79      return 1;
80    }
81
82   if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
83    {
84      Error("ProcessRecAndSim",
85            "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d). Skipping Event.",
86             partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
87      return 2;
88    }
89
90
91   for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
92    {
93      /***************************************/
94      /******   Looping same events   ********/
95      /******   filling numerators    ********/
96      /***************************************/
97      if ( (j%fDisplayMixingInfo) == 0)
98         Info("ProcessTracksAndParticles",
99              "Mixing particle %d with particles from the same event",j);
100
101      part1= partEvent->GetParticle(j);
102      track1= trackEvent->GetParticle(j);
103      
104      Bool_t firstcut = (this->*fkPass1)(part1,track1);
105      if (fBufferSize != 0) 
106        if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
107         {
108           //accepted by any cut
109           // we have to copy because reader keeps only one event
110
111           partEvent1->AddParticle(part1);
112           trackEvent1->AddParticle(track1);
113         }
114
115      if (firstcut) continue;
116
117      for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
118        fParticleMonitorFunctions[ii]->Process(part1);
119      for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
120        fTrackMonitorFunctions[ii]->Process(track1);
121      for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
122        fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
123
124      if (fNoCorrfctns) continue;
125
126      for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
127       {
128         part2= partEvent->GetParticle(k);
129         if (part1->GetUID() == part2->GetUID()) continue;
130         partpair->SetParticles(part1,part2);
131
132         track2= trackEvent->GetParticle(k);
133         trackpair->SetParticles(track1,track2);
134
135         if( (this->*fkPass)(partpair,trackpair) ) //check pair cut 
136           { //do not meets crietria of the pair cut, try with swapped pairs
137             if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
138               continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
139             else 
140              { //swaped pair meets all the criteria
141                tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
142                tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
143              }
144           }
145         else
146          {//meets criteria of the pair cut
147            tmptrackpair = trackpair;
148            tmppartpair = partpair;
149          }
150
151         for(ii = 0;ii<fNParticleFunctions;ii++)
152                fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
153
154         for(ii = 0;ii<fNTrackFunctions;ii++)
155                fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
156
157         for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
158                fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
159
160
161         /***************************************/
162         /***** Filling denominators    *********/
163         /***************************************/
164
165         tmppartpair->MirrorSecond();
166         tmptrackpair->MirrorSecond();
167         
168         if((this->*fkPass)(tmppartpair,tmptrackpair) == kFALSE)
169          {
170             for(ii = 0;ii<fNParticleFunctions;ii++)
171               fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
172
173             for(ii = 0;ii<fNTrackFunctions;ii++)
174               fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
175
176             for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
177               fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
178
179          } 
180         
181         tmppartpair->DeleteSecond();
182         tmptrackpair->DeleteSecond();
183         
184        //end of 2nd loop over particles from the same event  
185       }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
186
187     //end of loop over particles from first event
188    }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
189   delete fPartBuffer->Push(partEvent1);
190   delete fTrackBuffer->Push(trackEvent1);
191  //end of loop over events  
192   return 0;
193 }
194 /*************************************************************************************/ 
195
196 Int_t AliHBTAnalysisStavinskyMixing::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
197 {
198   //Does analysis of simulated data
199   AliVAODParticle * part1, * part2;
200   
201   AliAOD* partEvent = aodsim;
202   AliAOD* partEvent1 = new AliAOD();
203
204   AliAOD* partEvent2;
205   
206   AliHBTPair ppair;
207
208   AliHBTPair* partpair = &ppair;
209  
210   AliHBTPair * tmppartpair;
211   
212   register UInt_t ii;
213   
214
215   if ( !partEvent )
216    {
217      Error("ProcessRecAndSim","Can not get event");
218      return 1;
219    }
220
221
222   for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
223    {
224      /***************************************/
225      /******   Looping same events   ********/
226      /******   filling numerators    ********/
227      /***************************************/
228      Warning("ProcessTracksAndParticles","Non-std MIXING");
229      if ( (j%fDisplayMixingInfo) == 0)
230         Info("ProcessTracksAndParticles",
231              "Mixing particle %d with particles from the same event",j);
232
233      part1= partEvent->GetParticle(j);
234
235      Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(part1);
236
237      if (fBufferSize != 0) 
238        if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(part1) == kFALSE ) )
239         {
240           //accepted by any cut
241           // we have to copy because reader keeps only one event
242
243           partEvent1->AddParticle(part1);
244         }
245
246      if (firstcut) continue;
247
248      for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
249        fParticleMonitorFunctions[ii]->Process(part1);
250
251      if ( fNParticleFunctions == 0 ) continue;
252
253      for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
254       {
255         part2= partEvent->GetParticle(k);
256         if (part1->GetUID() == part2->GetUID()) continue;
257         partpair->SetParticles(part1,part2);
258
259            if(fPairCut->Rejected(partpair)) //check pair cut
260             { //do not meets crietria of the 
261               if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
262               else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
263             }
264            else
265             {
266               tmppartpair = partpair;
267             }
268
269         for(ii = 0;ii<fNParticleFunctions;ii++)
270                fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
271
272
273         /***************************************/
274         /***** Filling denominators    *********/
275         /***************************************/
276         
277         tmppartpair->MirrorSecond();
278         
279         if(fPairCut->Rejected(partpair) == kFALSE)
280          {
281            for(ii = 0;ii<fNParticleFunctions;ii++)
282              fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
283          }  
284         tmppartpair->DeleteSecond();
285         
286        //end of 2nd loop over particles from the same event  
287       }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
288
289        }
290   delete fPartBuffer->Push(partEvent1);
291  //end of loop over events  
292   return 0;
293 }
294 /*************************************************************************************/ 
295 Int_t AliHBTAnalysisStavinskyMixing::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
296 {
297   //Does analysis of reconstructed data
298   AliVAODParticle * track1, * track2;
299   
300   AliAOD* trackEvent = aodrec;
301   AliAOD* trackEvent1 = new AliAOD();
302
303   AliAOD* trackEvent2;
304   
305   AliHBTPair tpair;
306
307   AliHBTPair* trackpair = &tpair;
308  
309   AliHBTPair * tmptrackpair;
310   
311   register UInt_t ii;
312   
313
314   if ( !trackEvent )
315    {
316      Error("ProcessRecAndSim","Can not get event");
317      return 1;
318    }
319
320
321   for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
322    {
323      /***************************************/
324      /******   Looping same events   ********/
325      /******   filling numerators    ********/
326      /***************************************/
327      if ( (j%fDisplayMixingInfo) == 0)
328         Info("ProcessTracksAndParticles",
329              "Mixing Particle %d with Particles from the same event",j);
330
331      track1= trackEvent->GetParticle(j);
332
333      Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(track1);
334
335      if (fBufferSize != 0) 
336        if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(track1) == kFALSE ) )
337         {
338           //accepted by any cut
339           // we have to copy because reader keeps only one event
340
341           trackEvent1->AddParticle(track1);
342         }
343
344      if (firstcut) continue;
345
346      for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
347        fParticleMonitorFunctions[ii]->Process(track1);
348
349      if ( fNParticleFunctions == 0 ) continue;
350
351      for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
352       {
353         track2= trackEvent->GetParticle(k);
354         if (track1->GetUID() == track2->GetUID()) continue;
355         trackpair->SetParticles(track1,track2);
356
357            if(fPairCut->Rejected(trackpair)) //check pair cut
358             { //do not meets crietria of the 
359               if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
360               else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
361             }
362            else
363             {
364               tmptrackpair = trackpair;
365             }
366
367         for(ii = 0;ii<fNTrackFunctions;ii++)
368                fParticleFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
369
370        //end of 2nd loop over Particles from the same event  
371       }//for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
372
373      /***************************************/
374      /***** Filling denominators    *********/
375      /***************************************/
376      if (fBufferSize == 0) continue;
377
378      fTrackBuffer->ResetIter();
379          Int_t m = 0;
380          while (( trackEvent2 = fTrackBuffer->Next() ))
381           {
382             m++;
383             if ( (j%fDisplayMixingInfo) == 0)
384                Info("ProcessParticles",
385                     "Mixing Particle %d from current event with Particles from event %d",j,-m);
386             for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++)   //  ... on all Particles
387               {
388
389                 track2= trackEvent2->GetParticle(l);
390                 trackpair->SetParticles(track1,track2);
391
392                 if( fPairCut->Rejected(trackpair) ) //check pair cut
393                   { //do not meets crietria of the 
394                     if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) )
395                       continue;
396                     else 
397                      {
398                        tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
399                      }
400                   }
401                 else
402                  {//meets criteria of the pair cut
403                   tmptrackpair = trackpair;
404                  }
405                  
406                 for(ii = 0;ii<fNTrackFunctions;ii++)
407                   fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
408                  
409              }//for(Int_t l = 0; l<N2;l++)   //  ... on all Particles
410           }
411        }
412   delete fTrackBuffer->Push(trackEvent1);
413  //end of loop over events  
414   return 0;
415 }
416 /*************************************************************************************/ 
417      
418 Int_t AliHBTAnalysisStavinskyMixing::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
419 {
420 //Analyzes both reconstructed and simulated data
421   if (aodrec == 0x0) 
422    {
423      Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
424      return 1;
425    }
426
427   if (aodsim == 0x0) 
428    {
429      Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
430      return 1;
431    }
432
433   if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
434    {
435      Error("ProcessTracksAndParticlesNonIdentAnal",
436            "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
437            aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
438      return 2;
439    }
440
441  
442   AliVAODParticle * part1, * part2;
443   AliVAODParticle * track1, * track2;
444
445   static AliAOD aodrec1;
446   static AliAOD aodsim1;
447
448   AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
449   trackEvent1->Reset();
450   partEvent1->Reset();
451   AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
452   AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
453
454   AliAOD* rawtrackEvent = aodrec;//this we get from Reader
455   AliAOD* rawpartEvent = aodsim;//this we get from Reader
456
457   static AliHBTPair tpair;
458   static AliHBTPair ppair;
459   
460   AliHBTPair* trackpair = &tpair;
461   AliHBTPair* partpair = &ppair;
462
463   register UInt_t ii;
464   
465   /********************************/
466   /*      Filtering out           */
467   /********************************/
468   if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
469    {
470      partEvent2  = new AliAOD();
471      trackEvent2 = new AliAOD();
472    }
473
474   FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
475
476   for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
477    {
478      if ( (j%fDisplayMixingInfo) == 0) 
479         Info("ProcessTracksAndParticlesNonIdentAnal",
480              "Mixing particle %d from current event with particles from current event",j);
481
482      part1= partEvent1->GetParticle(j);
483      track1= trackEvent1->GetParticle(j);
484
485
486      for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
487        fParticleMonitorFunctions[ii]->Process(part1);
488      for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
489        fTrackMonitorFunctions[ii]->Process(track1);
490      for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
491        fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
492
493      if (fNoCorrfctns) continue;
494
495      /***************************************/
496      /******   filling numerators    ********/
497      /****** (particles from event2) ********/
498      /***************************************/
499
500      for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups 
501       {
502         part2= partEvent2->GetParticle(k);
503         if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
504         partpair->SetParticles(part1,part2);
505
506         track2= trackEvent2->GetParticle(k);
507         trackpair->SetParticles(track1,track2);
508
509         if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
510          { //do not meets crietria of the pair cut
511           continue; 
512          }
513         else
514          {//meets criteria of the pair cut
515           for(ii = 0;ii<fNParticleFunctions;ii++)
516                  fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
517
518           for(ii = 0;ii<fNTrackFunctions;ii++)
519                  fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
520
521           for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
522                  fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
523          }
524        }
525
526    if ( fBufferSize == 0) continue;//do not mix diff histograms
527    /***************************************/
528    /***** Filling denominators    *********/
529    /***************************************/
530    fPartBuffer->ResetIter();
531    fTrackBuffer->ResetIter();
532
533    Int_t nmonitor = 0;
534
535    while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
536     {
537       trackEvent3 = fTrackBuffer->Next();
538
539       if ( (j%fDisplayMixingInfo) == 0) 
540         Info("ProcessTracksAndParticlesNonIdentAnal",
541              "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
542
543       for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
544         {
545           part2= partEvent3->GetParticle(k);
546           partpair->SetParticles(part1,part2);
547
548           track2= trackEvent3->GetParticle(k);
549           trackpair->SetParticles(track1,track2);
550
551           if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
552            { //do not meets crietria of the pair cut
553             continue; 
554            }
555           else
556            {//meets criteria of the pair cut
557             UInt_t ii;
558             for(ii = 0;ii<fNParticleFunctions;ii++)
559                    fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
560
561             for(ii = 0;ii<fNTrackFunctions;ii++)
562                    fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
563
564             for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
565                    fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
566            }
567          }// for particles event2
568        }//while event2
569    }//for over particles in event1
570
571  delete fPartBuffer->Push(partEvent2);
572  delete fTrackBuffer->Push(trackEvent2);
573  
574  return 0;
575 }
576 /*************************************************************************************/ 
577 Int_t AliHBTAnalysisStavinskyMixing::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
578 {
579 //does analysis of simulated (MC) data in non-identical mode
580 //i.e. when particles selected by first part. cut are a disjunctive set than particles
581 //passed by the second part. cut
582  if (aodsim == 0x0) 
583   {
584     return 1;
585   }
586  
587  
588   AliVAODParticle * part1, * part2;
589
590   static AliAOD aodsim1;
591
592   AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
593   partEvent1->Reset();
594   AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
595   AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
596
597   AliAOD* rawpartEvent = aodsim;//this we get from Reader
598
599   static AliHBTPair ppair;
600   
601   AliHBTPair* partpair = &ppair;
602
603   register UInt_t ii;
604   
605   /********************************/
606   /*      Filtering out           */
607   /********************************/
608   if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
609    {
610      partEvent2  = new AliAOD();
611    }
612
613   FilterOut(partEvent1, partEvent2, rawpartEvent);
614
615   for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
616    {
617      if ( (j%fDisplayMixingInfo) == 0) 
618         Info("ProcessParticlesNonIdentAnal",
619              "Mixing particle %d from current event with particles from current event",j);
620
621      part1= partEvent1->GetParticle(j);
622
623
624      for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
625        fParticleMonitorFunctions[ii]->Process(part1);
626
627      if (fNParticleFunctions == 0) continue;
628
629      /***************************************/
630      /******   filling numerators    ********/
631      /****** (particles from event2) ********/
632      /***************************************/
633
634      for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups 
635       {
636         part2= partEvent2->GetParticle(k);
637         if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
638         partpair->SetParticles(part1,part2);
639
640
641         if(fPairCut->PassPairProp(partpair) ) //check pair cut
642           { //do not meets crietria of the pair cut
643               continue; 
644           }
645         else
646          {//meets criteria of the pair cut
647           for(ii = 0;ii<fNParticleFunctions;ii++)
648               fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
649          }
650        }
651
652  if ( fBufferSize == 0) continue;//do not mix diff histograms
653  /***************************************/
654  /***** Filling denominators    *********/
655  /***************************************/
656  fPartBuffer->ResetIter();
657
658  Int_t nmonitor = 0;
659
660  while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
661   {
662
663     if ( (j%fDisplayMixingInfo) == 0) 
664       Info("ProcessParticlesNonIdentAnal",
665            "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
666
667     for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
668       {
669         part2= partEvent3->GetParticle(k);
670         partpair->SetParticles(part1,part2);
671
672
673         if(fPairCut->PassPairProp(partpair) ) //check pair cut
674           { //do not meets crietria of the pair cut
675               continue; 
676           }
677         else
678          {//meets criteria of the pair cut
679           for(ii = 0;ii<fNParticleFunctions;ii++)
680            {
681              fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
682            }
683          }
684        }// for particles event2
685      }//while event2
686    }//for over particles in event1
687
688  delete fPartBuffer->Push(partEvent2);
689  
690  return 0;
691 }
692 /*************************************************************************************/ 
693 Int_t AliHBTAnalysisStavinskyMixing::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
694 {
695 //Analyzes both reconstructed and simulated data
696  if (aodrec == 0x0) 
697   {
698     return 1;
699   }
700  
701   AliVAODParticle * track1, * track2;
702
703   static AliAOD aodrec1;
704   AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
705   trackEvent1->Reset();
706   AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
707   AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
708   AliAOD* rawtrackEvent = aodrec;//this we get from Reader
709
710   static AliHBTPair tpair;
711   
712   AliHBTPair* trackpair = &tpair;
713
714   register UInt_t ii;
715   
716   
717   /********************************/
718   /*      Filtering out           */
719   /********************************/
720   if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
721    {
722      trackEvent2 = new AliAOD();
723    }
724
725   FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
726
727   for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
728    {
729      if ( (j%fDisplayMixingInfo) == 0) 
730         Info("ProcessTracksNonIdentAnal",
731              "Mixing particle %d from current event with particles from current event",j);
732
733      track1= trackEvent1->GetParticle(j);
734
735
736      for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
737        fTrackMonitorFunctions[ii]->Process(track1);
738
739      if (fNTrackFunctions == 0x0) continue;
740
741      /***************************************/
742      /******   filling numerators    ********/
743      /****** (particles from event2) ********/
744      /***************************************/
745
746      for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups 
747       {
748         track2= trackEvent2->GetParticle(k);
749         if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
750         trackpair->SetParticles(track1,track2);
751
752
753         if( fPairCut->PassPairProp(trackpair)) //check pair cut
754          { //do not meets crietria of the pair cut
755            continue; 
756          }
757         else
758          {//meets criteria of the pair cut
759            UInt_t ii;
760            for(ii = 0;ii<fNTrackFunctions;ii++)
761                   fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
762          }
763        }
764
765  if ( fBufferSize == 0) continue;//do not mix diff histograms
766  /***************************************/
767  /***** Filling denominators    *********/
768  /***************************************/
769  fTrackBuffer->ResetIter();
770
771  Int_t nmonitor = 0;
772
773  while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
774   {
775     if ( (j%fDisplayMixingInfo) == 0) 
776       Info("ProcessTracksNonIdentAnal",
777            "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
778
779     for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
780       {
781         track2= trackEvent3->GetParticle(k);
782         trackpair->SetParticles(track1,track2);
783
784         if( fPairCut->PassPairProp(trackpair)) //check pair cut
785          { //do not meets crietria of the pair cut
786            continue; 
787          }
788         else
789          {//meets criteria of the pair cut
790            for(ii = 0;ii<fNTrackFunctions;ii++)
791                fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
792          }
793        }// for particles event2
794      }//while event2
795    }//for over particles in event1
796
797  delete fTrackBuffer->Push(trackEvent2);
798  
799  return 0;
800 }
801 /*************************************************************************************/