1 #include "AliHBTAnalysis.h"
3 #include "AliHBTEvent.h"
4 #include "AliHBTReader.h"
5 #include "AliHBTParticle.h"
6 #include "AliHBTParticleCut.h"
7 #include "AliHBTPair.h"
8 #include "AliHBTPairCut.h"
9 #include "AliHBTFunction.h"
10 #include "AliHBTMonitorFunction.h"
11 #include "AliHBTEventBuffer.h"
13 #include <TBenchmark.h>
16 //_________________________________________________________
17 ///////////////////////////////////////////////////////////
19 //Central Object Of HBTAnalyser:
20 //This class performs main looping within HBT Analysis
21 //User must plug a reader of Type AliHBTReader
22 //User plugs in coorelation and monitor functions
23 //as well as monitor functions
25 //HBT Analysis Tool, which is integral part of AliRoot,
26 //ALICE Off-Line framework:
28 //Piotr.Skowronski@cern.ch
29 //more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
31 //_________________________________________________________
33 ClassImp(AliHBTAnalysis)
35 const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
36 const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
37 const Int_t AliHBTAnalysis::fgkDefaultBufferSize = 5;
39 AliHBTAnalysis::AliHBTAnalysis():
42 fNParticleFunctions(0),
43 fNParticleAndTrackFunctions(0),
44 fNTrackMonitorFunctions(0),
45 fNParticleMonitorFunctions(0),
46 fNParticleAndTrackMonitorFunctions(0),
48 fDisplayMixingInfo(fgkDefaultMixingInfo),
52 fTrackFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
53 fParticleFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
54 fParticleAndTrackFunctions = new AliHBTTwoPairFctn* [fgkFctnArraySize];
56 fParticleMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
57 fTrackMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
58 fParticleAndTrackMonitorFunctions = new AliHBTMonTwoParticleFctn* [fgkFctnArraySize];
60 fPairCut = new AliHBTEmptyPairCut();//empty cut - accepts all particles
62 /*************************************************************************************/
64 AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
68 fNParticleFunctions(0),
69 fNParticleAndTrackFunctions(0),
70 fNTrackMonitorFunctions(0),
71 fNParticleMonitorFunctions(0),
72 fNParticleAndTrackMonitorFunctions(0),
74 fParticleFunctions(0x0),
75 fParticleAndTrackFunctions(0x0),
76 fParticleMonitorFunctions(0x0),
77 fTrackMonitorFunctions(0x0),
78 fParticleAndTrackMonitorFunctions(0x0),
80 fBufferSize(fgkDefaultBufferSize),
81 fDisplayMixingInfo(fgkDefaultMixingInfo),
85 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
87 /*************************************************************************************/
88 const AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& /*right*/)
91 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
94 /*************************************************************************************/
95 AliHBTAnalysis::~AliHBTAnalysis()
98 //note that we do not delete functions itself
99 // they should be deleted by whom where created
100 //we only store pointers, and we use "new" only for pointers array
103 delete [] fTrackFunctions;
104 delete [] fParticleFunctions;
105 delete [] fParticleAndTrackFunctions;
107 delete [] fParticleMonitorFunctions;
108 delete [] fTrackMonitorFunctions;
109 delete [] fParticleAndTrackMonitorFunctions;
111 delete fPairCut; // always have an copy of an object - we create we dstroy
114 /*************************************************************************************/
116 void AliHBTAnalysis::DeleteFunctions()
118 //Deletes all functions added to analysis
120 for(ii = 0;ii<fNParticleFunctions;ii++)
121 delete fParticleFunctions[ii];
122 fNParticleFunctions = 0;
124 for(ii = 0;ii<fNTrackFunctions;ii++)
125 delete fTrackFunctions[ii];
126 fNTrackFunctions = 0;
128 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
129 delete fParticleAndTrackFunctions[ii];
130 fNParticleAndTrackFunctions = 0;
132 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
133 delete fParticleMonitorFunctions[ii];
134 fNParticleMonitorFunctions = 0;
136 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
137 delete fTrackMonitorFunctions[ii];
138 fNTrackMonitorFunctions = 0;
140 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
141 delete fParticleAndTrackMonitorFunctions[ii];
142 fNParticleAndTrackMonitorFunctions = 0;
144 /*************************************************************************************/
146 void AliHBTAnalysis::Init()
148 //Initializeation method
149 //calls Init for all functions
151 for(ii = 0;ii<fNParticleFunctions;ii++)
152 fParticleFunctions[ii]->Init();
154 for(ii = 0;ii<fNTrackFunctions;ii++)
155 fTrackFunctions[ii]->Init();
157 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
158 fParticleAndTrackFunctions[ii]->Init();
160 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
161 fParticleMonitorFunctions[ii]->Init();
163 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
164 fTrackMonitorFunctions[ii]->Init();
166 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
167 fParticleAndTrackMonitorFunctions[ii]->Init();
169 /*************************************************************************************/
171 void AliHBTAnalysis::ResetFunctions()
173 //In case fOwner is true, deletes all functions
174 //in other case, just set number of analysis to 0
175 if (fIsOwner) DeleteFunctions();
178 fNParticleFunctions = 0;
179 fNTrackFunctions = 0;
180 fNParticleAndTrackFunctions = 0;
181 fNParticleMonitorFunctions = 0;
182 fNTrackMonitorFunctions = 0;
183 fNParticleAndTrackMonitorFunctions = 0;
186 /*************************************************************************************/
188 void AliHBTAnalysis::Process(Option_t* option)
190 //default option = "TracksAndParticles"
191 //Main method of the HBT Analysis Package
192 //It triggers reading with the global cut (default is an empty cut)
193 //Than it checks options and data which are read
194 //if everything is OK, then it calls one of the looping methods
195 //depending on tfReaderhe option
196 //These methods differs on what thay are looping on
199 //--------------------------------------------------------------------
200 //ProcessTracksAndParticles - "TracksAndParticles"
202 // it loops over both, tracks(reconstructed) and particles(simulated)
203 // all function gethered in all 3 lists are called for each (double)pair
205 //ProcessTracks - "Tracks"
206 // it loops only on tracks(reconstructed),
207 // functions ONLY from fTrackFunctions list are called
209 //ProcessParticles - "Particles"
210 // it loops only on particles(simulated),
211 // functions ONLY from fParticleAndTrackFunctions list are called
216 Error("Process","The reader is not set");
220 const char *oT = strstr(option,"Tracks");
221 const char *oP = strstr(option,"Particles");
223 Bool_t nonid = IsNonIdentAnalysis();
229 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
230 else ProcessTracksAndParticles();
236 if (nonid) ProcessTracksNonIdentAnal();
237 else ProcessTracks();
243 if (nonid) ProcessParticlesNonIdentAnal();
244 else ProcessParticles();
249 /*************************************************************************************/
251 void AliHBTAnalysis::ProcessTracksAndParticles()
253 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
254 //the loops are splited
257 AliHBTParticle * part1, * part2;
258 AliHBTParticle * track1, * track2;
260 AliHBTEvent * trackEvent, *partEvent;
261 AliHBTEvent * trackEvent1 = 0x0,*partEvent1 = 0x0;
262 AliHBTEvent * trackEvent2,*partEvent2;
264 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
266 // Int_t nev = fReader->GetNumberOfTrackEvents();
267 AliHBTPair * trackpair = new AliHBTPair();
268 AliHBTPair * partpair = new AliHBTPair();
270 AliHBTPair * tmptrackpair;//temprary pointers to pairs
271 AliHBTPair * tmppartpair;
273 AliHBTEventBuffer partbuffer(fBufferSize);
274 AliHBTEventBuffer trackbuffer(fBufferSize);
279 Bool_t nocorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
283 while (fReader->Next() == kFALSE)
286 partEvent= fReader->GetParticleEvent();
287 trackEvent = fReader->GetTrackEvent();
289 if ( !partEvent || !trackEvent )
291 Error("ProcessTracksAndParticles","Can not get event");
295 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
297 Fatal("ProcessTracksAndParticles",
298 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
299 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
303 if(partEvent1 == 0x0)
305 partEvent1 = new AliHBTEvent();
306 partEvent1->SetOwner(kTRUE);
308 trackEvent1 = new AliHBTEvent();
309 trackEvent1->SetOwner(kTRUE);
314 trackEvent1->Reset();
317 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
319 /***************************************/
320 /****** Looping same events ********/
321 /****** filling numerators ********/
322 /***************************************/
323 if ( (j%fDisplayMixingInfo) == 0)
324 Info("ProcessTracksAndParticles",
325 "Mixing particle %d from event %d with particles from event %d",j,i,i);
327 part1= partEvent->GetParticle(j);
328 track1= trackEvent->GetParticle(j);
330 if( part1->GetPdgCode() != track1->GetPdgCode() )
332 Fatal("ProcessTracksAndParticles",
333 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
334 i,j, part1->GetPdgCode(),track1->GetPdgCode() );
338 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
340 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE) )
342 //accepted by any cut
343 // we have to copy because reader keeps only one event
345 partEvent1->AddParticle(new AliHBTParticle(*part1));
346 trackEvent1->AddParticle(new AliHBTParticle(*track1));
349 if (firstcut) continue;
351 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
352 fParticleMonitorFunctions[ii]->Process(part1);
353 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
354 fTrackMonitorFunctions[ii]->Process(track1);
355 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
356 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
358 if (nocorrfctns) continue;
360 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
362 part2= partEvent->GetParticle(k);
363 if (part1->GetUID() == part2->GetUID()) continue;
364 partpair->SetParticles(part1,part2);
366 track2= trackEvent->GetParticle(k);
367 trackpair->SetParticles(track1,track2);
369 if(fPairCut->Pass(partpair) ) //check pair cut
370 { //do not meets crietria of the pair cut, try with swapped pairs
371 if( fPairCut->Pass(partpair->GetSwapedPair()) )
372 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
374 { //swaped pair meets all the criteria
375 tmppartpair = partpair->GetSwapedPair();
376 tmptrackpair = trackpair->GetSwapedPair();
380 {//meets criteria of the pair cut
381 tmptrackpair = trackpair;
382 tmppartpair = partpair;
384 for(ii = 0;ii<fNParticleFunctions;ii++)
385 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
387 for(ii = 0;ii<fNTrackFunctions;ii++)
388 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
390 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
391 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
392 //end of 2nd loop over particles from the same event
393 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
395 /***************************************/
396 /***** Filling denominators *********/
397 /***************************************/
398 if (fBufferSize == 0) continue;
400 partbuffer.ResetIter();
401 trackbuffer.ResetIter();
403 while (( partEvent2 = partbuffer.Next() ))
405 trackEvent2 = trackbuffer.Next();
408 if ( (j%fDisplayMixingInfo) == 0)
409 Info("ProcessTracksAndParticles",
410 "Mixing particle %d from event %d with particles from event %d",j,i,i-m);
412 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
414 part2= partEvent2->GetParticle(l);
415 partpair->SetParticles(part1,part2);
417 track2= trackEvent2->GetParticle(l);
418 trackpair->SetParticles(track1,track2);
420 if( fPairCut->Pass(partpair) ) //check pair cut
421 { //do not meets crietria of the
422 if( fPairCut->Pass(partpair->GetSwapedPair()) )
426 tmppartpair = partpair->GetSwapedPair();
427 tmptrackpair = trackpair->GetSwapedPair();
431 {//meets criteria of the pair cut
432 tmptrackpair = trackpair;
433 tmppartpair = partpair;
435 for(ii = 0;ii<fNParticleFunctions;ii++)
436 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
438 for(ii = 0;ii<fNTrackFunctions;ii++)
439 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
441 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
442 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
443 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
446 //end of loop over particles from first event
447 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
448 partEvent1 = partbuffer.Push(partEvent1);
449 trackEvent1 = trackbuffer.Push(trackEvent1);
450 //end of loop over events
451 }//while (fReader->Next() == kFALSE)
453 /*************************************************************************************/
455 void AliHBTAnalysis::ProcessTracks()
457 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
458 //the loops are splited
459 AliHBTParticle * track1, * track2;
460 AliHBTEvent * trackEvent;
461 AliHBTEvent * trackEvent1 = 0x0;
462 AliHBTEvent * trackEvent2;
466 AliHBTPair * trackpair = new AliHBTPair();
467 AliHBTPair * tmptrackpair; //temporary pointer
469 AliHBTEventBuffer trackbuffer(fBufferSize);
473 while (fReader->Next() == kFALSE)
476 trackEvent = fReader->GetTrackEvent();
477 if (!trackEvent) continue;
479 if(trackEvent1 == 0x0)
481 trackEvent1 = new AliHBTEvent();
482 trackEvent1->SetOwner(kTRUE);
486 trackEvent1->Reset();
489 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
491 /***************************************/
492 /****** Looping same events ********/
493 /****** filling numerators ********/
494 /***************************************/
495 if ( (j%fDisplayMixingInfo) == 0)
496 Info("ProcessTracks",
497 "Mixing particle %d from event %d with particles from event %d",j,i,i);
499 track1= trackEvent->GetParticle(j);
500 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(track1);
502 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(track1) == kFALSE) )
504 //accepted by any cut
505 // we have to copy because reader keeps only one event
506 trackEvent1->AddParticle(new AliHBTParticle(*track1));
509 if (firstcut) continue;
511 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
512 fTrackMonitorFunctions[ii]->Process(track1);
514 if ( fNTrackFunctions ==0 ) continue;
516 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
518 track2= trackEvent->GetParticle(k);
519 if (track1->GetUID() == track2->GetUID()) continue;
521 trackpair->SetParticles(track1,track2);
522 if(fPairCut->Pass(trackpair)) //check pair cut
523 { //do not meets crietria of the
524 if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
525 else tmptrackpair = trackpair->GetSwapedPair();
529 tmptrackpair = trackpair;
531 for(ii = 0;ii<fNTrackFunctions;ii++)
532 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
534 /***************************************/
535 /***** Filling denominators *********/
536 /***************************************/
538 if (fBufferSize == 0) continue;
540 trackbuffer.ResetIter();
542 while (( trackEvent2 = trackbuffer.Next() ))
544 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all particles
547 track2= trackEvent2->GetParticle(l);
548 trackpair->SetParticles(track1,track2);
550 if( fPairCut->Pass(trackpair) ) //check pair cut
551 { //do not meets crietria of the
552 if( fPairCut->Pass(trackpair->GetSwapedPair()) )
556 tmptrackpair = trackpair->GetSwapedPair();
560 {//meets criteria of the pair cut
561 tmptrackpair = trackpair;
564 for(ii = 0;ii<fNTrackFunctions;ii++)
565 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
567 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
571 trackEvent1 = trackbuffer.Push(trackEvent1);
572 }//while (fReader->Next() == kFALSE)
575 /*************************************************************************************/
577 void AliHBTAnalysis::ProcessParticles()
579 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
580 //the loops are splited
581 AliHBTParticle * part1, * part2;
582 AliHBTEvent * partEvent;
583 AliHBTEvent * partEvent1 = 0x0;
584 AliHBTEvent * partEvent2;
588 AliHBTPair * partpair = new AliHBTPair();
589 AliHBTPair * tmppartpair; //temporary pointer
591 AliHBTEventBuffer partbuffer(fBufferSize);
595 while (fReader->Next() == kFALSE)
598 partEvent = fReader->GetParticleEvent();
599 if (!partEvent) continue;
601 if(partEvent1 == 0x0)
603 partEvent1 = new AliHBTEvent();
604 partEvent1->SetOwner(kTRUE);
611 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
613 /***************************************/
614 /****** Looping same events ********/
615 /****** filling numerators ********/
616 /***************************************/
617 if ( (j%fDisplayMixingInfo) == 0)
619 "Mixing particle %d from event %d with particles from event %d",j,i,i);
621 part1= partEvent->GetParticle(j);
622 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
624 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE) )
626 //accepted by any cut
627 // we have to copy because reader keeps only one event
628 partEvent1->AddParticle(new AliHBTParticle(*part1));
631 if (firstcut) continue;
633 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
634 fParticleMonitorFunctions[ii]->Process(part1);
636 if ( fNParticleFunctions == 0 ) continue;
638 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
640 part2= partEvent->GetParticle(k);
641 if (part1->GetUID() == part2->GetUID()) continue;
643 partpair->SetParticles(part1,part2);
644 if(fPairCut->Pass(partpair)) //check pair cut
645 { //do not meets crietria of the
646 if( fPairCut->Pass(partpair->GetSwapedPair()) ) continue;
647 else tmppartpair = partpair->GetSwapedPair();
651 tmppartpair = partpair;
653 for(ii = 0;ii<fNParticleFunctions;ii++)
654 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
656 /***************************************/
657 /***** Filling denominators *********/
658 /***************************************/
660 if (fBufferSize == 0) continue;
662 partbuffer.ResetIter();
664 while (( partEvent2 = partbuffer.Next() ))
666 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
669 part2= partEvent2->GetParticle(l);
670 partpair->SetParticles(part1,part2);
672 if( fPairCut->Pass(partpair) ) //check pair cut
673 { //do not meets crietria of the
674 if( fPairCut->Pass(partpair->GetSwapedPair()) )
678 tmppartpair = partpair->GetSwapedPair();
682 {//meets criteria of the pair cut
683 tmppartpair = partpair;
686 for(ii = 0;ii<fNParticleFunctions;ii++)
687 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
689 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
692 partEvent1 = partbuffer.Push(partEvent1);
693 }//while (fReader->Next() == kFALSE)
695 /*************************************************************************************/
697 void AliHBTAnalysis::WriteFunctions()
699 //Calls Write for all defined functions in analysis
700 //== writes all results
702 for(ii = 0;ii<fNParticleFunctions;ii++)
703 fParticleFunctions[ii]->Write();
705 for(ii = 0;ii<fNTrackFunctions;ii++)
706 fTrackFunctions[ii]->Write();
708 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
709 fParticleAndTrackFunctions[ii]->Write();
711 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
712 fParticleMonitorFunctions[ii]->Write();
714 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
715 fTrackMonitorFunctions[ii]->Write();
717 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
718 fParticleAndTrackMonitorFunctions[ii]->Write();
720 /*************************************************************************************/
722 void AliHBTAnalysis::SetGlobalPairCut(AliHBTPairCut* cut)
724 //Sets the global cut
727 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
730 fPairCut = (AliHBTPairCut*)cut->Clone();
733 /*************************************************************************************/
735 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
737 //Adds track function
738 if (f == 0x0) return;
739 if (fNTrackFunctions == fgkFctnArraySize)
741 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
743 fTrackFunctions[fNTrackFunctions] = f;
746 /*************************************************************************************/
748 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
750 //adds particle function
751 if (f == 0x0) return;
753 if (fNParticleFunctions == fgkFctnArraySize)
755 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
757 fParticleFunctions[fNParticleFunctions] = f;
758 fNParticleFunctions++;
760 /*************************************************************************************/
762 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
764 //add resolution function
765 if (f == 0x0) return;
766 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
768 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
770 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
771 fNParticleAndTrackFunctions++;
773 /*************************************************************************************/
775 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
777 //add particle monitoring function
778 if (f == 0x0) return;
780 if (fNParticleMonitorFunctions == fgkFctnArraySize)
782 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
784 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
785 fNParticleMonitorFunctions++;
787 /*************************************************************************************/
789 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
791 //add track monitoring function
792 if (f == 0x0) return;
794 if (fNTrackMonitorFunctions == fgkFctnArraySize)
796 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
798 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
799 fNTrackMonitorFunctions++;
801 /*************************************************************************************/
803 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
805 //add resolution monitoring function
806 if (f == 0x0) return;
807 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
809 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
811 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
812 fNParticleAndTrackMonitorFunctions++;
816 /*************************************************************************************/
817 /*************************************************************************************/
819 Bool_t AliHBTAnalysis::RunCoherencyCheck()
821 //Checks if both HBTRuns are similar
822 //return true if error found
823 //if they seem to be OK return false
825 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
827 Info("RunCoherencyCheck","Number of events ...");
828 if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
830 Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
833 { //if not the same - ERROR
834 Error("AliHBTAnalysis::RunCoherencyCheck()",
835 "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
836 fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
840 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
842 AliHBTEvent *partEvent;
843 AliHBTEvent *trackEvent;
844 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
846 partEvent= fReader->GetParticleEvent(i); //gets the "ith" event
847 trackEvent = fReader->GetTrackEvent(i);
849 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
850 if ( (partEvent == 0x0) || (partEvent == 0x0) )
852 Error("AliHBTAnalysis::RunCoherencyCheck()",
853 "One event is NULL and the other one not. Event Number %d",i);
857 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
859 Error("AliHBTAnalysis::RunCoherencyCheck()",
860 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
861 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
865 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
867 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
869 Error("AliHBTAnalysis::RunCoherencyCheck()",
870 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
871 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
877 Info("RunCoherencyCheck"," Done");
878 Info("RunCoherencyCheck"," Everything looks OK");
882 /*************************************************************************************/
884 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
886 //Performs analysis for both, tracks and particles
888 AliHBTParticle * part1, * part2;
889 AliHBTParticle * track1, * track2;
891 AliHBTEvent * trackEvent1=0x0,*partEvent1=0x0;
892 AliHBTEvent * trackEvent2=0x0,*partEvent2=0x0;
893 AliHBTEvent * trackEvent3=0x0,*partEvent3=0x0;
895 AliHBTEvent * rawtrackEvent, *rawpartEvent;//this we get from Reader
897 AliHBTPair * trackpair = new AliHBTPair();
898 AliHBTPair * partpair = new AliHBTPair();
900 AliHBTEventBuffer partbuffer(fBufferSize);
901 AliHBTEventBuffer trackbuffer(fBufferSize);
905 trackEvent1 = new AliHBTEvent();
906 partEvent1 = new AliHBTEvent();
907 trackEvent1->SetOwner(kFALSE);
908 partEvent1->SetOwner(kFALSE);;
910 Bool_t nocorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
914 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
915 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
916 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
918 for (Int_t i = 0;;i++)//infinite loop
920 if (fReader->Next()) break; //end when no more events available
922 rawpartEvent = fReader->GetParticleEvent();
923 rawtrackEvent = fReader->GetTrackEvent();
924 if ( (rawpartEvent == 0x0) || (rawtrackEvent == 0x0) ) continue;//in case of any error
926 if ( rawpartEvent->GetNumberOfParticles() != rawtrackEvent->GetNumberOfParticles() )
928 Fatal("ProcessTracksAndParticlesNonIdentAnal",
929 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
930 i,rawpartEvent->GetNumberOfParticles() , rawtrackEvent->GetNumberOfParticles());
934 /********************************/
936 /********************************/
937 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
939 partEvent2 = new AliHBTEvent();
940 trackEvent2 = new AliHBTEvent();
941 partEvent2->SetOwner(kTRUE);
942 trackEvent2->SetOwner(kTRUE);
945 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
947 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
949 if ( (j%fDisplayMixingInfo) == 0)
950 Info("ProcessTracksAndParticlesNonIdentAnal",
951 "Mixing particle %d from event %d with particles from event %d",j,i,i);
953 part1= partEvent1->GetParticle(j);
954 track1= trackEvent1->GetParticle(j);
956 if( part1->GetPdgCode() != track1->GetPdgCode() )
958 Fatal("ProcessTracksAndParticlesNonIdentAnal",
959 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
960 i,j, part1->GetPdgCode(),track1->GetPdgCode() );
964 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
965 fParticleMonitorFunctions[ii]->Process(part1);
966 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
967 fTrackMonitorFunctions[ii]->Process(track1);
968 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
969 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
971 if (nocorrfctns) continue;
973 /***************************************/
974 /****** filling numerators ********/
975 /****** (particles from event2) ********/
976 /***************************************/
978 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
980 part2= partEvent2->GetParticle(k);
981 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
982 partpair->SetParticles(part1,part2);
984 track2= trackEvent2->GetParticle(k);
985 trackpair->SetParticles(track1,track2);
987 if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
988 { //do not meets crietria of the pair cut
992 {//meets criteria of the pair cut
993 for(ii = 0;ii<fNParticleFunctions;ii++)
994 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
996 for(ii = 0;ii<fNTrackFunctions;ii++)
997 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
999 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1000 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
1004 if ( fBufferSize == 0) continue;//do not mix diff histograms
1005 /***************************************/
1006 /***** Filling denominators *********/
1007 /***************************************/
1008 partbuffer.ResetIter();
1009 trackbuffer.ResetIter();
1013 while ( (partEvent3 = partbuffer.Next() ) != 0x0)
1015 trackEvent3 = trackbuffer.Next();
1017 if ( (j%fDisplayMixingInfo) == 0)
1018 Info("ProcessTracksAndParticlesNonIdentAnal",
1019 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1021 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1023 part2= partEvent3->GetParticle(k);
1024 partpair->SetParticles(part1,part2);
1026 track2= trackEvent3->GetParticle(k);
1027 trackpair->SetParticles(track1,track2);
1029 if( (fPairCut->PassPairProp(partpair)) ) //check pair cut
1030 { //do not meets crietria of the pair cut
1034 {//meets criteria of the pair cut
1036 for(ii = 0;ii<fNParticleFunctions;ii++)
1037 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1039 for(ii = 0;ii<fNTrackFunctions;ii++)
1040 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1042 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1043 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
1045 }// for particles event2
1047 }//for over particles in event1
1049 partEvent2 = partbuffer.Push(partEvent2);
1050 trackEvent2 = trackbuffer.Push(trackEvent2);
1052 }//end of loop over events (1)
1054 partbuffer.SetOwner(kTRUE);
1055 trackbuffer.SetOwner(kTRUE);
1065 /*************************************************************************************/
1067 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1069 //Process Tracks only with non identical mode
1070 AliHBTParticle * track1, * track2;
1072 AliHBTEvent * trackEvent1=0x0;
1073 AliHBTEvent * trackEvent2=0x0;
1074 AliHBTEvent * trackEvent3=0x0;
1076 AliHBTEvent * rawtrackEvent;
1078 AliHBTPair * trackpair = new AliHBTPair();
1079 AliHBTEventBuffer trackbuffer(fBufferSize);
1083 trackEvent1 = new AliHBTEvent();
1084 trackEvent1->SetOwner(kFALSE);
1088 Info("ProcessTracksNonIdentAnal","**************************************");
1089 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1090 Info("ProcessTracksNonIdentAnal","**************************************");
1093 for (Int_t i = 0;;i++)//infinite loop
1095 if (fReader->Next()) break; //end when no more events available
1096 rawtrackEvent = fReader->GetTrackEvent();
1098 if (rawtrackEvent == 0x0) continue;//in case of any error
1100 /********************************/
1102 /********************************/
1103 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1105 trackEvent2 = new AliHBTEvent();
1106 trackEvent2->SetOwner(kTRUE);
1109 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1111 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1113 if ( (j%fDisplayMixingInfo) == 0)
1114 Info("ProcessTracksNonIdentAnal",
1115 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1117 track1= trackEvent1->GetParticle(j);
1119 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1120 fTrackMonitorFunctions[ii]->Process(track1);
1122 if (fNTrackFunctions == 0x0) continue;
1124 /***************************************/
1125 /****** filling numerators ********/
1126 /****** (particles from event2) ********/
1127 /***************************************/
1128 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++)
1130 track2= trackEvent2->GetParticle(k);
1131 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1132 trackpair->SetParticles(track1,track2);
1135 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1136 { //do not meets crietria of the pair cut
1140 {//meets criteria of the pair cut
1142 for(ii = 0;ii<fNTrackFunctions;ii++)
1143 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1146 if ( fBufferSize == 0) continue;//do not mix diff histograms
1147 /***************************************/
1148 /***** Filling denominators *********/
1149 /***************************************/
1150 trackbuffer.ResetIter();
1153 while ( (trackEvent3 = trackbuffer.Next() ) != 0x0)
1156 if ( (j%fDisplayMixingInfo) == 0)
1157 Info("ProcessTracksNonIdentAnal",
1158 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1160 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1163 track2= trackEvent3->GetParticle(k);
1164 trackpair->SetParticles(track1,track2);
1167 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1168 { //do not meets crietria of the pair cut
1172 {//meets criteria of the pair cut
1173 for(ii = 0;ii<fNTrackFunctions;ii++)
1174 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1176 }// for particles event2
1178 }//for over particles in event1
1180 trackEvent2 = trackbuffer.Push(trackEvent2);
1182 }//end of loop over events (1)
1184 trackbuffer.SetOwner(kTRUE);
1189 /*************************************************************************************/
1191 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1193 //process paricles only with non identical mode
1194 AliHBTParticle * part1 = 0x0, * part2 = 0x0;
1196 AliHBTEvent * partEvent1 = 0x0;
1197 AliHBTEvent * partEvent2 = 0x0;
1198 AliHBTEvent * partEvent3 = 0x0;
1200 AliHBTEvent * rawpartEvent = 0x0;
1202 AliHBTPair * partpair = new AliHBTPair();
1203 AliHBTEventBuffer partbuffer(fBufferSize);
1207 partEvent1 = new AliHBTEvent();
1208 partEvent1->SetOwner(kFALSE);
1212 Info("ProcessParticlesNonIdentAnal","**************************************");
1213 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1214 Info("ProcessParticlesNonIdentAnal","**************************************");
1216 for (Int_t i = 0;;i++)//infinite loop
1218 if (fReader->Next()) break; //end when no more events available
1220 rawpartEvent = fReader->GetParticleEvent();
1221 if ( rawpartEvent == 0x0 ) continue;//in case of any error
1223 /********************************/
1225 /********************************/
1226 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
1228 partEvent2 = new AliHBTEvent();
1229 partEvent2->SetOwner(kTRUE);
1232 FilterOut(partEvent1, partEvent2, rawpartEvent);
1234 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
1236 if ( (j%fDisplayMixingInfo) == 0)
1237 Info("ProcessParticlesNonIdentAnal",
1238 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1240 part1= partEvent1->GetParticle(j);
1242 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
1243 fParticleMonitorFunctions[ii]->Process(part1);
1245 if (fNParticleFunctions == 0) continue;
1247 /***************************************/
1248 /****** filling numerators ********/
1249 /****** (particles from event2) ********/
1250 /***************************************/
1251 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++)
1253 part2= partEvent2->GetParticle(k);
1254 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
1255 partpair->SetParticles(part1,part2);
1257 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1258 { //do not meets crietria of the pair cut
1262 {//meets criteria of the pair cut
1263 for(ii = 0;ii<fNParticleFunctions;ii++)
1264 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1267 if ( fBufferSize == 0) continue;//do not mix diff histograms
1268 /***************************************/
1269 /***** Filling denominators *********/
1270 /***************************************/
1271 partbuffer.ResetIter();
1274 while ( (partEvent3 = partbuffer.Next() ) != 0x0)
1276 if ( (j%fDisplayMixingInfo) == 0)
1277 Info("ProcessParticlesNonIdentAnal",
1278 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1280 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1282 part2= partEvent3->GetParticle(k);
1283 partpair->SetParticles(part1,part2);
1285 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1286 { //do not meets crietria of the pair cut
1290 {//meets criteria of the pair cut
1291 for(ii = 0;ii<fNParticleFunctions;ii++)
1293 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1296 }// for particles event2
1298 }//for over particles in event1
1299 partEvent2 = partbuffer.Push(partEvent2);
1300 }//end of loop over events (1)
1302 partbuffer.SetOwner(kTRUE);
1308 /*************************************************************************************/
1309 void AliHBTAnalysis::FilterOut(AliHBTEvent* outpart1, AliHBTEvent* outpart2, AliHBTEvent* inpart,
1310 AliHBTEvent* outtrack1, AliHBTEvent* outtrack2, AliHBTEvent* intrack)
1312 //Puts particles accepted as a first particle by global cut in out1
1313 //and as a second particle in out2
1315 AliHBTParticle* part, *track;
1322 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1323 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1327 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1330 part = inpart->GetParticle(i);
1331 track = intrack->GetParticle(i);
1333 if ( (cut1->Pass(part)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1334 if ( (cut2->Pass(part)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1336 if (gDebug)//to be removed in real analysis
1337 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1339 //Particle accpted by both cuts
1340 Error("FilterOut","Particle accepted by both cuts");
1346 outpart1->AddParticle(part);
1347 outtrack1->AddParticle(track);
1353 outpart2->AddParticle(new AliHBTParticle(*part));
1354 outtrack2->AddParticle(new AliHBTParticle(*track));
1359 /*************************************************************************************/
1361 void AliHBTAnalysis::FilterOut(AliHBTEvent* out1, AliHBTEvent* out2, AliHBTEvent* in)
1363 //Puts particles accepted as a first particle by global cut in out1
1364 //and as a second particle in out2
1365 AliHBTParticle* part;
1370 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1371 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1375 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1378 part = in->GetParticle(i);
1380 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1381 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1383 if (gDebug)//to be removed in real analysis
1384 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1386 //Particle accpted by both cuts
1387 Error("FilterOut","Particle accepted by both cuts");
1393 out1->AddParticle(part);
1399 out2->AddParticle(part);
1404 /*************************************************************************************/
1406 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1408 //checks if it is possible to use special analysis for non identical particles
1409 //it means - in global pair cut first particle id is different than second one
1410 //and both are different from 0
1411 //in the future is possible to perform more sophisticated check
1412 //if cuts have excluding requirements
1414 if (fPairCut->IsEmpty())
1417 if (fPairCut->GetFirstPartCut()->IsEmpty())
1420 if (fPairCut->GetSecondPartCut()->IsEmpty())
1423 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1424 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1426 if ( (id1==0) || (id2==0) || (id1==id2) )