1 #include "AliHBTAnalysis.h"
2 //_________________________________________________________
3 ////////////////////////////////////////////////////////////////////////////
5 // class AliHBTAnalysis
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
13 // HBT Analysis Tool, which is integral part of AliRoot,
14 // ALICE Off-Line framework:
16 // Piotr.Skowronski@cern.ch
17 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
19 ////////////////////////////////////////////////////////////////////////////
20 //_________________________________________________________
27 #include "AliAODParticle.h"
28 #include "AliAODPairCut.h"
29 #include "AliEventCut.h"
31 #include "AliEventBuffer.h"
33 #include "AliReader.h"
34 #include "AliHBTPair.h"
35 #include "AliHBTFunction.h"
36 #include "AliHBTMonitorFunction.h"
39 ClassImp(AliHBTAnalysis)
41 const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
42 const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
43 const Int_t AliHBTAnalysis::fgkDefaultBufferSize = 5;
45 AliHBTAnalysis::AliHBTAnalysis():
49 fNParticleFunctions(0),
50 fNParticleAndTrackFunctions(0),
51 fNTrackMonitorFunctions(0),
52 fNParticleMonitorFunctions(0),
53 fNParticleAndTrackMonitorFunctions(0),
54 fTrackFunctions ( new AliHBTOnePairFctn* [fgkFctnArraySize]),
55 fParticleFunctions ( new AliHBTOnePairFctn* [fgkFctnArraySize]),
56 fParticleAndTrackFunctions ( new AliHBTTwoPairFctn* [fgkFctnArraySize]),
57 fParticleMonitorFunctions ( new AliHBTMonOneParticleFctn* [fgkFctnArraySize]),
58 fTrackMonitorFunctions ( new AliHBTMonOneParticleFctn* [fgkFctnArraySize]),
59 fParticleAndTrackMonitorFunctions ( new AliHBTMonTwoParticleFctn* [fgkFctnArraySize]),
62 fDisplayMixingInfo(fgkDefaultMixingInfo),
66 fProcessOption(kSimulatedAndReconstructed),
73 /*************************************************************************************/
75 AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
80 fNParticleFunctions(0),
81 fNParticleAndTrackFunctions(0),
82 fNTrackMonitorFunctions(0),
83 fNParticleMonitorFunctions(0),
84 fNParticleAndTrackMonitorFunctions(0),
86 fParticleFunctions(0x0),
87 fParticleAndTrackFunctions(0x0),
88 fParticleMonitorFunctions(0x0),
89 fTrackMonitorFunctions(0x0),
90 fParticleAndTrackMonitorFunctions(0x0),
92 fBufferSize(fgkDefaultBufferSize),
93 fDisplayMixingInfo(fgkDefaultMixingInfo),
97 fProcessOption(kSimulatedAndReconstructed),
102 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
104 /*************************************************************************************/
105 AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& /*right*/)
108 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
111 /*************************************************************************************/
112 AliHBTAnalysis::~AliHBTAnalysis()
115 //note that we do not delete functions itself
116 // they should be deleted by whom where created
117 //we only store pointers, and we use "new" only for pointers array
121 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Is Owner: Attempting to delete functions");
123 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Delete functions done");
125 delete [] fTrackFunctions;
126 delete [] fParticleFunctions;
127 delete [] fParticleAndTrackFunctions;
129 delete [] fParticleMonitorFunctions;
130 delete [] fTrackMonitorFunctions;
131 delete [] fParticleAndTrackMonitorFunctions;
134 delete fOutputFileName;
137 /*************************************************************************************/
139 Int_t AliHBTAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
141 //Processes one event
142 if (fProcEvent == 0x0)
144 Error("ProcessEvent","Analysis option not specified");
147 if ( Pass(aodrec,aodsim) ) return 0;
149 return (this->*fProcEvent)(aodrec,aodsim);
151 /*************************************************************************************/
153 Int_t AliHBTAnalysis::Finish()
159 /*************************************************************************************/
161 void AliHBTAnalysis::DeleteFunctions()
163 //Deletes all functions added to analysis
165 for(ii = 0;ii<fNParticleFunctions;ii++)
167 if (AliVAODParticle::GetDebug()>5)
169 Info("DeleteFunctions","Deleting ParticleFunction %#x",fParticleFunctions[ii]);
170 Info("DeleteFunctions","Deleting ParticleFunction %s",fParticleFunctions[ii]->Name());
172 delete fParticleFunctions[ii];
174 fNParticleFunctions = 0;
176 for(ii = 0;ii<fNTrackFunctions;ii++)
178 if (AliVAODParticle::GetDebug()>5)
180 Info("DeleteFunctions","Deleting TrackFunction %#x",fTrackFunctions[ii]);
181 Info("DeleteFunctions","Deleting TrackFunction %s",fTrackFunctions[ii]->Name());
183 delete fTrackFunctions[ii];
185 fNTrackFunctions = 0;
187 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
189 if (AliVAODParticle::GetDebug()>5)
191 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
192 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
194 delete fParticleAndTrackFunctions[ii];
196 fNParticleAndTrackFunctions = 0;
198 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
200 if (AliVAODParticle::GetDebug()>5)
202 Info("DeleteFunctions","Deleting ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
203 Info("DeleteFunctions","Deleting ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
205 delete fParticleMonitorFunctions[ii];
207 fNParticleMonitorFunctions = 0;
209 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
211 if (AliVAODParticle::GetDebug()>5)
213 Info("DeleteFunctions","Deleting TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
214 Info("DeleteFunctions","Deleting TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
216 delete fTrackMonitorFunctions[ii];
218 fNTrackMonitorFunctions = 0;
220 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
222 if (AliVAODParticle::GetDebug()>5)
224 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
225 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
227 delete fParticleAndTrackMonitorFunctions[ii];
229 fNParticleAndTrackMonitorFunctions = 0;
232 /*************************************************************************************/
234 Int_t AliHBTAnalysis::Init()
236 //Initializeation method
237 //calls Init for all functions
239 //Depending on option and pair cut assigns proper analysis method
240 Bool_t nonid = IsNonIdentAnalysis();
241 switch(fProcessOption)
244 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecNonId;
245 else fProcEvent = &AliHBTAnalysis::ProcessRec;
249 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessSimNonId;
250 else fProcEvent = &AliHBTAnalysis::ProcessSim;
253 case kSimulatedAndReconstructed:
254 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecAndSimNonId;
255 else fProcEvent = &AliHBTAnalysis::ProcessRecAndSim;
259 if (fPartBuffer == 0x0) fPartBuffer = new AliEventBuffer (fBufferSize);
260 else fPartBuffer->Reset();
262 if (fTrackBuffer == 0x0) fTrackBuffer = new AliEventBuffer (fBufferSize);
263 else fTrackBuffer->Reset();
266 fNoCorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
269 for(ii = 0;ii<fNParticleFunctions;ii++)
270 fParticleFunctions[ii]->Init();
272 for(ii = 0;ii<fNTrackFunctions;ii++)
273 fTrackFunctions[ii]->Init();
275 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
276 fParticleAndTrackFunctions[ii]->Init();
278 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
279 fParticleMonitorFunctions[ii]->Init();
281 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
282 fTrackMonitorFunctions[ii]->Init();
284 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
285 fParticleAndTrackMonitorFunctions[ii]->Init();
289 /*************************************************************************************/
291 void AliHBTAnalysis::ResetFunctions()
293 //In case fOwner is true, deletes all functions
294 //in other case, just set number of analysis to 0
295 if (fIsOwner) DeleteFunctions();
298 fNParticleFunctions = 0;
299 fNTrackFunctions = 0;
300 fNParticleAndTrackFunctions = 0;
301 fNParticleMonitorFunctions = 0;
302 fNTrackMonitorFunctions = 0;
303 fNParticleAndTrackMonitorFunctions = 0;
306 /*************************************************************************************/
307 Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
309 //Does analysis for both tracks and particles
310 //mainly for resolution study and analysies with weighting algirithms
312 // cut on particles only -- why?
313 // - PID: when we make resolution analysis we want to take only tracks with correct PID
314 // We need cut on tracks because there are data characteristic
316 AliVAODParticle * part1, * part2;
317 AliVAODParticle * track1, * track2;
319 AliAOD * trackEvent = aodrec, *partEvent = aodsim;
320 AliAOD* trackEvent1 = new AliAOD();
321 AliAOD* partEvent1 = new AliAOD();
322 partEvent1->SetOwner(kTRUE);
323 trackEvent1->SetOwner(kTRUE);
325 AliAOD * trackEvent2,*partEvent2;
327 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
329 // Int_t nev = fReader->GetNumberOfTrackEvents();
330 static AliHBTPair tpair;
331 static AliHBTPair ppair;
333 AliHBTPair* trackpair = &tpair;
334 AliHBTPair* partpair = &ppair;
336 AliHBTPair * tmptrackpair;//temprary pointers to pairs
337 AliHBTPair * tmppartpair;
343 if ( !partEvent || !trackEvent )
345 Error("ProcessRecAndSim","Can not get event");
349 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
351 Error("ProcessRecAndSim",
352 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d). Skipping Event.",
353 partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
358 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
360 /***************************************/
361 /****** Looping same events ********/
362 /****** filling numerators ********/
363 /***************************************/
364 if ( (j%fDisplayMixingInfo) == 0)
365 Info("ProcessTracksAndParticles",
366 "Mixing particle %d with particles from the same event",j);
368 part1= partEvent->GetParticle(j);
369 track1= trackEvent->GetParticle(j);
371 Bool_t firstcut = (this->*fkPass1)(part1,track1);
372 if (fBufferSize != 0)
373 if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
375 //accepted by any cut
376 // we have to copy because reader keeps only one event
378 partEvent1->AddParticle(new AliAODParticle(*part1));
379 trackEvent1->AddParticle(new AliAODParticle(*track1));
382 if (firstcut) continue;
384 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
385 fParticleMonitorFunctions[ii]->Process(part1);
386 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
387 fTrackMonitorFunctions[ii]->Process(track1);
388 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
389 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
391 if (fNoCorrfctns) continue;
393 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
395 part2= partEvent->GetParticle(k);
396 if (part1->GetUID() == part2->GetUID()) continue;
397 partpair->SetParticles(part1,part2);
399 track2= trackEvent->GetParticle(k);
400 trackpair->SetParticles(track1,track2);
402 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
403 { //do not meets crietria of the pair cut, try with swapped pairs
404 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
405 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
407 { //swaped pair meets all the criteria
408 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
409 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
413 {//meets criteria of the pair cut
414 tmptrackpair = trackpair;
415 tmppartpair = partpair;
418 for(ii = 0;ii<fNParticleFunctions;ii++)
419 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
421 for(ii = 0;ii<fNTrackFunctions;ii++)
422 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
424 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
425 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
426 //end of 2nd loop over particles from the same event
427 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
429 /***************************************/
430 /***** Filling denominators *********/
431 /***************************************/
432 if (fBufferSize == 0) continue;
434 fPartBuffer->ResetIter();
435 fTrackBuffer->ResetIter();
437 while (( partEvent2 = fPartBuffer->Next() ))
439 trackEvent2 = fTrackBuffer->Next();
442 if ( (j%fDisplayMixingInfo) == 0)
443 Info("ProcessTracksAndParticles",
444 "Mixing particle %d from current event with particles from event %d",j,-m);
446 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
448 part2= partEvent2->GetParticle(l);
449 partpair->SetParticles(part1,part2);
451 track2= trackEvent2->GetParticle(l);
452 trackpair->SetParticles(track1,track2);
454 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
455 { //do not meets crietria of the
456 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
460 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
461 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
465 {//meets criteria of the pair cut
466 tmptrackpair = trackpair;
467 tmppartpair = partpair;
470 for(ii = 0;ii<fNParticleFunctions;ii++)
471 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
473 for(ii = 0;ii<fNTrackFunctions;ii++)
474 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
476 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
477 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
478 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
481 //end of loop over particles from first event
482 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
483 delete fPartBuffer->Push(partEvent1);
484 delete fTrackBuffer->Push(trackEvent1);
485 //end of loop over events
488 /*************************************************************************************/
490 Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
492 //Does analysis of simulated data
493 AliVAODParticle * part1, * part2;
495 AliAOD* partEvent = aodsim;
496 AliAOD* partEvent1 = new AliAOD();
497 partEvent1->SetOwner(kTRUE);
503 AliHBTPair* partpair = &ppair;
505 AliHBTPair * tmppartpair;
513 Error("ProcessRecAndSim","Can not get event");
518 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
520 /***************************************/
521 /****** Looping same events ********/
522 /****** filling numerators ********/
523 /***************************************/
524 if ( (j%fDisplayMixingInfo) == 0)
525 Info("ProcessTracksAndParticles",
526 "Mixing particle %d with particles from the same event",j);
528 part1= partEvent->GetParticle(j);
530 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
532 if (fBufferSize != 0)
533 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE ) )
535 //accepted by any cut
536 // we have to copy because reader keeps only one event
538 partEvent1->AddParticle(new AliAODParticle(*part1));
541 if (firstcut) continue;
543 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
544 fParticleMonitorFunctions[ii]->Process(part1);
546 if ( fNParticleFunctions == 0 ) continue;
548 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
550 part2= partEvent->GetParticle(k);
551 if (part1->GetUID() == part2->GetUID()) continue;
552 partpair->SetParticles(part1,part2);
554 if(fPairCut->Pass(partpair)) //check pair cut
555 { //do not meets crietria of the
556 if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
557 else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
561 tmppartpair = partpair;
564 for(ii = 0;ii<fNParticleFunctions;ii++)
565 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
567 //end of 2nd loop over particles from the same event
568 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
570 /***************************************/
571 /***** Filling denominators *********/
572 /***************************************/
573 if (fBufferSize == 0) continue;
575 fPartBuffer->ResetIter();
577 while (( partEvent2 = fPartBuffer->Next() ))
580 if ( (j%fDisplayMixingInfo) == 0)
581 Info("ProcessParticles",
582 "Mixing particle %d from current event with particles from event %d",j,-m);
583 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
586 part2= partEvent2->GetParticle(l);
587 partpair->SetParticles(part1,part2);
589 if( fPairCut->Pass(partpair) ) //check pair cut
590 { //do not meets crietria of the
591 if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) )
595 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
599 {//meets criteria of the pair cut
600 tmppartpair = partpair;
603 for(ii = 0;ii<fNParticleFunctions;ii++)
604 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
606 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
609 delete fPartBuffer->Push(partEvent1);
610 //end of loop over events
613 /*************************************************************************************/
614 Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
616 //Does analysis of reconstructed data
617 AliVAODParticle * track1, * track2;
619 AliAOD* trackEvent = aodrec;
620 AliAOD* trackEvent1 = new AliAOD();
621 trackEvent1->SetOwner(kTRUE);
627 AliHBTPair* trackpair = &tpair;
629 AliHBTPair * tmptrackpair;
636 Error("ProcessRecAndSim","Can not get event");
641 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
643 /***************************************/
644 /****** Looping same events ********/
645 /****** filling numerators ********/
646 /***************************************/
647 if ( (j%fDisplayMixingInfo) == 0)
648 Info("ProcessTracksAndParticles",
649 "Mixing Particle %d with Particles from the same event",j);
651 track1= trackEvent->GetParticle(j);
653 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(track1);
655 if (fBufferSize != 0)
656 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(track1) == kFALSE ) )
658 //accepted by any cut
659 // we have to copy because reader keeps only one event
661 trackEvent1->AddParticle(new AliAODParticle(*track1));
664 if (firstcut) continue;
666 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
667 fParticleMonitorFunctions[ii]->Process(track1);
669 if ( fNParticleFunctions == 0 ) continue;
671 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
673 track2= trackEvent->GetParticle(k);
674 if (track1->GetUID() == track2->GetUID()) continue;
675 trackpair->SetParticles(track1,track2);
677 if(fPairCut->Pass(trackpair)) //check pair cut
678 { //do not meets crietria of the
679 if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
680 else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
684 tmptrackpair = trackpair;
687 for(ii = 0;ii<fNTrackFunctions;ii++)
688 fParticleFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
690 //end of 2nd loop over Particles from the same event
691 }//for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
693 /***************************************/
694 /***** Filling denominators *********/
695 /***************************************/
696 if (fBufferSize == 0) continue;
698 fTrackBuffer->ResetIter();
700 while (( trackEvent2 = fTrackBuffer->Next() ))
703 if ( (j%fDisplayMixingInfo) == 0)
704 Info("ProcessParticles",
705 "Mixing Particle %d from current event with Particles from event %d",j,-m);
706 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all Particles
709 track2= trackEvent2->GetParticle(l);
710 trackpair->SetParticles(track1,track2);
712 if( fPairCut->Pass(trackpair) ) //check pair cut
713 { //do not meets crietria of the
714 if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) )
718 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
722 {//meets criteria of the pair cut
723 tmptrackpair = trackpair;
726 for(ii = 0;ii<fNTrackFunctions;ii++)
727 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
729 }//for(Int_t l = 0; l<N2;l++) // ... on all Particles
732 delete fTrackBuffer->Push(trackEvent1);
733 //end of loop over events
736 /*************************************************************************************/
738 Int_t AliHBTAnalysis::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
740 //Analyzes both reconstructed and simulated data
743 Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
749 Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
753 if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
755 Error("ProcessTracksAndParticlesNonIdentAnal",
756 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
757 aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
762 AliVAODParticle * part1, * part2;
763 AliVAODParticle * track1, * track2;
765 static AliAOD aodrec1;
766 static AliAOD aodsim1;
768 AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
769 AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
770 AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
772 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
773 AliAOD* rawpartEvent = aodsim;//this we get from Reader
775 static AliHBTPair tpair;
776 static AliHBTPair ppair;
778 AliHBTPair* trackpair = &tpair;
779 AliHBTPair* partpair = &ppair;
784 trackEvent1 = new AliAOD();
785 partEvent1 = new AliAOD();
786 trackEvent1->SetOwner(kFALSE);
787 partEvent1->SetOwner(kFALSE);;
789 /********************************/
791 /********************************/
792 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
794 partEvent2 = new AliAOD();
795 trackEvent2 = new AliAOD();
796 partEvent2->SetOwner(kTRUE);
797 trackEvent2->SetOwner(kTRUE);
800 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
802 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
804 if ( (j%fDisplayMixingInfo) == 0)
805 Info("ProcessTracksAndParticlesNonIdentAnal",
806 "Mixing particle %d from current event with particles from current event",j);
808 part1= partEvent1->GetParticle(j);
809 track1= trackEvent1->GetParticle(j);
812 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
813 fParticleMonitorFunctions[ii]->Process(part1);
814 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
815 fTrackMonitorFunctions[ii]->Process(track1);
816 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
817 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
819 if (fNoCorrfctns) continue;
821 /***************************************/
822 /****** filling numerators ********/
823 /****** (particles from event2) ********/
824 /***************************************/
826 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
828 part2= partEvent2->GetParticle(k);
829 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
830 partpair->SetParticles(part1,part2);
832 track2= trackEvent2->GetParticle(k);
833 trackpair->SetParticles(track1,track2);
835 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
836 { //do not meets crietria of the pair cut
840 {//meets criteria of the pair cut
841 for(ii = 0;ii<fNParticleFunctions;ii++)
842 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
844 for(ii = 0;ii<fNTrackFunctions;ii++)
845 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
847 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
848 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
852 if ( fBufferSize == 0) continue;//do not mix diff histograms
853 /***************************************/
854 /***** Filling denominators *********/
855 /***************************************/
856 fPartBuffer->ResetIter();
857 fTrackBuffer->ResetIter();
861 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
863 trackEvent3 = fTrackBuffer->Next();
865 if ( (j%fDisplayMixingInfo) == 0)
866 Info("ProcessTracksAndParticlesNonIdentAnal",
867 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
869 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
871 part2= partEvent3->GetParticle(k);
872 partpair->SetParticles(part1,part2);
874 track2= trackEvent3->GetParticle(k);
875 trackpair->SetParticles(track1,track2);
877 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
878 { //do not meets crietria of the pair cut
882 {//meets criteria of the pair cut
884 for(ii = 0;ii<fNParticleFunctions;ii++)
885 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
887 for(ii = 0;ii<fNTrackFunctions;ii++)
888 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
890 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
891 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
893 }// for particles event2
895 }//for over particles in event1
897 delete fPartBuffer->Push(partEvent2);
898 delete fTrackBuffer->Push(trackEvent2);
902 /*************************************************************************************/
903 Int_t AliHBTAnalysis::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
905 //does analysis of simulated (MC) data in non-identical mode
906 //i.e. when particles selected by first part. cut are a disjunctive set than particles
907 //passed by the second part. cut
914 AliVAODParticle * part1, * part2;
916 static AliAOD aodsim1;
918 AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
919 AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
920 AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
922 AliAOD* rawpartEvent = aodsim;//this we get from Reader
924 static AliHBTPair ppair;
926 AliHBTPair* partpair = &ppair;
931 partEvent1 = new AliAOD();
932 partEvent1->SetOwner(kFALSE);;
935 /********************************/
937 /********************************/
938 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
940 partEvent2 = new AliAOD();
941 partEvent2->SetOwner(kTRUE);
944 FilterOut(partEvent1, partEvent2, rawpartEvent);
946 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
948 if ( (j%fDisplayMixingInfo) == 0)
949 Info("ProcessParticlesNonIdentAnal",
950 "Mixing particle %d from current event with particles from current event",j);
952 part1= partEvent1->GetParticle(j);
955 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
956 fParticleMonitorFunctions[ii]->Process(part1);
958 if (fNParticleFunctions == 0) continue;
960 /***************************************/
961 /****** filling numerators ********/
962 /****** (particles from event2) ********/
963 /***************************************/
965 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
967 part2= partEvent2->GetParticle(k);
968 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
969 partpair->SetParticles(part1,part2);
972 if(fPairCut->PassPairProp(partpair) ) //check pair cut
973 { //do not meets crietria of the pair cut
977 {//meets criteria of the pair cut
978 for(ii = 0;ii<fNParticleFunctions;ii++)
979 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
983 if ( fBufferSize == 0) continue;//do not mix diff histograms
984 /***************************************/
985 /***** Filling denominators *********/
986 /***************************************/
987 fPartBuffer->ResetIter();
991 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
994 if ( (j%fDisplayMixingInfo) == 0)
995 Info("ProcessParticlesNonIdentAnal",
996 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
998 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1000 part2= partEvent3->GetParticle(k);
1001 partpair->SetParticles(part1,part2);
1004 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1005 { //do not meets crietria of the pair cut
1009 {//meets criteria of the pair cut
1010 for(ii = 0;ii<fNParticleFunctions;ii++)
1012 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1015 }// for particles event2
1017 }//for over particles in event1
1019 delete fPartBuffer->Push(partEvent2);
1023 /*************************************************************************************/
1024 Int_t AliHBTAnalysis::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
1026 //Analyzes both reconstructed and simulated data
1032 AliVAODParticle * track1, * track2;
1034 static AliAOD aodrec1;
1036 AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
1037 AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
1038 AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
1040 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
1042 static AliHBTPair tpair;
1044 AliHBTPair* trackpair = &tpair;
1049 trackEvent1 = new AliAOD();
1050 trackEvent1->SetOwner(kFALSE);
1052 /********************************/
1054 /********************************/
1055 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1057 trackEvent2 = new AliAOD();
1058 trackEvent2->SetOwner(kTRUE);
1061 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1063 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1065 if ( (j%fDisplayMixingInfo) == 0)
1066 Info("ProcessTracksNonIdentAnal",
1067 "Mixing particle %d from current event with particles from current event",j);
1069 track1= trackEvent1->GetParticle(j);
1072 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1073 fTrackMonitorFunctions[ii]->Process(track1);
1075 if (fNTrackFunctions == 0x0) continue;
1077 /***************************************/
1078 /****** filling numerators ********/
1079 /****** (particles from event2) ********/
1080 /***************************************/
1082 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1084 track2= trackEvent2->GetParticle(k);
1085 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1086 trackpair->SetParticles(track1,track2);
1089 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1090 { //do not meets crietria of the pair cut
1094 {//meets criteria of the pair cut
1096 for(ii = 0;ii<fNTrackFunctions;ii++)
1097 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1101 if ( fBufferSize == 0) continue;//do not mix diff histograms
1102 /***************************************/
1103 /***** Filling denominators *********/
1104 /***************************************/
1105 fTrackBuffer->ResetIter();
1109 while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
1111 if ( (j%fDisplayMixingInfo) == 0)
1112 Info("ProcessTracksNonIdentAnal",
1113 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1115 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1117 track2= trackEvent3->GetParticle(k);
1118 trackpair->SetParticles(track1,track2);
1120 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1121 { //do not meets crietria of the pair cut
1125 {//meets criteria of the pair cut
1126 for(ii = 0;ii<fNTrackFunctions;ii++)
1127 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1129 }// for particles event2
1131 }//for over particles in event1
1133 delete fTrackBuffer->Push(trackEvent2);
1137 /*************************************************************************************/
1139 void AliHBTAnalysis::Process(Option_t* option)
1141 //default option = "TracksAndParticles"
1142 //Main method of the HBT Analysis Package
1143 //It triggers reading with the global cut (default is an empty cut)
1144 //Than it checks options and data which are read
1145 //if everything is OK, then it calls one of the looping methods
1146 //depending on tfReaderhe option
1147 //These methods differs on what thay are looping on
1150 //--------------------------------------------------------------------
1151 //ProcessTracksAndParticles - "TracksAndParticles"
1153 // it loops over both, tracks(reconstructed) and particles(simulated)
1154 // all function gethered in all 3 lists are called for each (double)pair
1156 //ProcessTracks - "Tracks"
1157 // it loops only on tracks(reconstructed),
1158 // functions ONLY from fTrackFunctions list are called
1160 //ProcessParticles - "Particles"
1161 // it loops only on particles(simulated),
1162 // functions ONLY from fParticleAndTrackFunctions list are called
1167 Error("Process","The reader is not set");
1171 const char *oT = strstr(option,"Tracks");
1172 const char *oP = strstr(option,"Particles");
1174 Bool_t nonid = IsNonIdentAnalysis();
1180 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
1181 else ProcessTracksAndParticles();
1187 if (nonid) ProcessTracksNonIdentAnal();
1188 else ProcessTracks();
1194 if (nonid) ProcessParticlesNonIdentAnal();
1195 else ProcessParticles();
1200 /*************************************************************************************/
1202 void AliHBTAnalysis::ProcessTracksAndParticles()
1204 //Makes analysis for both tracks and particles
1205 //mainly for resolution study and analysies with weighting algirithms
1206 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1207 //the loops are splited
1209 // cut on particles only -- why?
1210 // - PID: when we make resolution analysis we want to take only tracks with correct PID
1211 // We need cut on tracks because there are data characteristic to
1213 AliAOD * trackEvent, *partEvent;
1216 while (fReader->Next() == kFALSE)
1218 partEvent = fReader->GetEventSim();
1219 trackEvent = fReader->GetEventRec();
1220 ProcessRecAndSim(trackEvent,partEvent);
1222 }//while (fReader->Next() == kFALSE)
1225 /*************************************************************************************/
1227 void AliHBTAnalysis::ProcessTracks()
1229 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1230 //the loops are splited
1231 AliAOD * trackEvent;
1233 while (fReader->Next() == kFALSE)
1235 trackEvent = fReader->GetEventRec();
1236 ProcessRec(trackEvent,0x0);
1237 }//while (fReader->Next() == kFALSE)
1240 /*************************************************************************************/
1242 void AliHBTAnalysis::ProcessParticles()
1244 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1245 //the loops are splited
1248 while (fReader->Next() == kFALSE)
1250 partEvent = fReader->GetEventSim();
1251 ProcessSim(0x0,partEvent);
1252 }//while (fReader->Next() == kFALSE)
1254 /*************************************************************************************/
1256 void AliHBTAnalysis::WriteFunctions()
1258 //Calls Write for all defined functions in analysis
1259 //== writes all results
1260 TFile* oututfile = 0x0;
1261 if (fOutputFileName)
1263 oututfile = TFile::Open(*fOutputFileName,"update");
1266 for(ii = 0;ii<fNParticleFunctions;ii++)
1268 if (AliVAODParticle::GetDebug()>5)
1270 Info("WriteFunctions","Writing ParticleFunction %#x",fParticleFunctions[ii]);
1271 Info("WriteFunctions","Writing ParticleFunction %s",fParticleFunctions[ii]->Name());
1273 fParticleFunctions[ii]->Write();
1276 for(ii = 0;ii<fNTrackFunctions;ii++)
1278 if (AliVAODParticle::GetDebug()>5)
1280 Info("WriteFunctions","Writing TrackFunction %#x",fTrackFunctions[ii]);
1281 Info("WriteFunctions","Writing TrackFunction %s",fTrackFunctions[ii]->Name());
1283 fTrackFunctions[ii]->Write();
1286 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1288 if (AliVAODParticle::GetDebug()>5)
1290 Info("WriteFunctions","Writing ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
1291 Info("WriteFunctions","Writing ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
1293 fParticleAndTrackFunctions[ii]->Write();
1296 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
1298 if (AliVAODParticle::GetDebug()>5)
1300 Info("WriteFunctions","Writing ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
1301 Info("WriteFunctions","Writing ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
1303 fParticleMonitorFunctions[ii]->Write();
1306 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
1308 if (AliVAODParticle::GetDebug()>5)
1310 Info("WriteFunctions","Writing TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
1311 Info("WriteFunctions","Writing TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
1313 fTrackMonitorFunctions[ii]->Write();
1316 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
1318 if (AliVAODParticle::GetDebug()>5)
1320 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
1321 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
1323 fParticleAndTrackMonitorFunctions[ii]->Write();
1327 /*************************************************************************************/
1329 void AliHBTAnalysis::SetOutputFileName(const char* fname)
1331 //Sets fiele name where to dump results,
1332 //if not specified reults are written to gDirectory
1335 delete fOutputFileName;
1336 fOutputFileName = 0x0;
1339 if ( strcmp(fname,"") == 0 )
1341 delete fOutputFileName;
1342 fOutputFileName = 0x0;
1345 if (fOutputFileName == 0x0) fOutputFileName = new TString(fname);
1346 else *fOutputFileName = fname;
1348 /*************************************************************************************/
1350 void AliHBTAnalysis::SetGlobalPairCut(AliAODPairCut* cut)
1352 //Sets the global cut
1355 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
1358 fPairCut = (AliAODPairCut*)cut->Clone();
1361 /*************************************************************************************/
1363 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1365 //Adds track function
1366 if (f == 0x0) return;
1367 if (fNTrackFunctions == fgkFctnArraySize)
1369 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
1371 fTrackFunctions[fNTrackFunctions] = f;
1374 /*************************************************************************************/
1376 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1378 //adds particle function
1379 if (f == 0x0) return;
1381 if (fNParticleFunctions == fgkFctnArraySize)
1383 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
1385 fParticleFunctions[fNParticleFunctions] = f;
1386 fNParticleFunctions++;
1388 /*************************************************************************************/
1390 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1392 //add resolution function
1393 if (f == 0x0) return;
1394 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
1396 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
1398 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
1399 fNParticleAndTrackFunctions++;
1401 /*************************************************************************************/
1403 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
1405 //add particle monitoring function
1406 if (f == 0x0) return;
1408 if (fNParticleMonitorFunctions == fgkFctnArraySize)
1410 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
1412 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
1413 fNParticleMonitorFunctions++;
1415 /*************************************************************************************/
1417 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
1419 //add track monitoring function
1420 if (f == 0x0) return;
1422 if (fNTrackMonitorFunctions == fgkFctnArraySize)
1424 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
1426 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
1427 fNTrackMonitorFunctions++;
1429 /*************************************************************************************/
1431 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
1433 //add resolution monitoring function
1434 if (f == 0x0) return;
1435 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
1437 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
1439 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
1440 fNParticleAndTrackMonitorFunctions++;
1444 /*************************************************************************************/
1445 /*************************************************************************************/
1447 Bool_t AliHBTAnalysis::RunCoherencyCheck()
1449 //Checks if both HBTRuns are similar
1450 //return true if error found
1451 //if they seem to be OK return false
1455 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
1457 //When we use non-buffering reader this is a big waste of time -> We need to read all data to check it
1458 //and reader is implemented safe in this case anyway
1459 // Info("RunCoherencyCheck","Number of events ...");
1460 // if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
1462 // Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1465 // { //if not the same - ERROR
1466 // Error("RunCoherencyCheck",
1467 // "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
1468 // fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
1472 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1476 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
1478 partEvent= fReader->GetEventSim(i); //gets the "ith" event
1479 trackEvent = fReader->GetEventRec(i);
1481 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
1482 if ( (partEvent == 0x0) || (partEvent == 0x0) )
1484 Error("RunCoherencyCheck",
1485 "One event is NULL and the other one not. Event Number %d",i);
1489 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
1491 Error("RunCoherencyCheck",
1492 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
1493 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
1497 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
1499 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
1501 Error("RunCoherencyCheck",
1502 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
1503 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
1509 Info("RunCoherencyCheck"," Done");
1510 Info("RunCoherencyCheck"," Everything looks OK");
1515 /*************************************************************************************/
1517 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
1519 //Performs analysis for both, tracks and particles
1520 AliAOD* rawtrackEvent, * rawpartEvent;
1523 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1524 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1525 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1527 for (Int_t i = 0;;i++)//infinite loop
1529 if (fReader->Next()) break; //end when no more events available
1531 rawpartEvent = fReader->GetEventSim();
1532 rawtrackEvent = fReader->GetEventRec();
1534 ProcessRecAndSimNonId(rawtrackEvent,rawpartEvent);
1535 }//end of loop over events (1)
1537 /*************************************************************************************/
1539 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1541 //Process Tracks only with non identical mode
1542 AliAOD * rawtrackEvent;
1545 Info("ProcessTracksNonIdentAnal","**************************************");
1546 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1547 Info("ProcessTracksNonIdentAnal","**************************************");
1549 for (Int_t i = 0;;i++)//infinite loop
1551 if (fReader->Next()) break; //end when no more events available
1552 rawtrackEvent = fReader->GetEventRec();
1553 ProcessRecNonId(rawtrackEvent,0x0);
1554 }//end of loop over events (1)
1556 /*************************************************************************************/
1558 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1560 //process paricles only with non identical mode
1561 AliAOD * rawpartEvent = 0x0;
1564 Info("ProcessParticlesNonIdentAnal","**************************************");
1565 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1566 Info("ProcessParticlesNonIdentAnal","**************************************");
1568 for (Int_t i = 0;;i++)//infinite loop
1570 if (fReader->Next()) break; //end when no more events available
1572 rawpartEvent = fReader->GetEventSim();
1573 ProcessSimNonId(0x0,rawpartEvent);
1574 }//end of loop over events (1)
1577 /*************************************************************************************/
1578 void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpart,
1579 AliAOD* outtrack1, AliAOD* outtrack2, AliAOD* intrack) const
1581 //Puts particles accepted as a first particle by global cut in out1
1582 //and as a second particle in out2
1584 AliVAODParticle* part, *track;
1593 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1596 part = inpart->GetParticle(i);
1597 track = intrack->GetParticle(i);
1599 if ( ((this->*fkPass1)(part,track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1600 if ( ((this->*fkPass2)(part,track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1602 if (gDebug)//to be removed in real analysis
1603 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1605 //Particle accpted by both cuts
1606 Error("FilterOut","Particle accepted by both cuts");
1612 outpart1->AddParticle(part);
1613 outtrack1->AddParticle(track);
1619 outpart2->AddParticle(new AliAODParticle(*part));
1620 outtrack2->AddParticle(new AliAODParticle(*track));
1625 /*************************************************************************************/
1627 void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
1629 //Puts particles accepted as a first particle by global cut in out1
1630 //and as a second particle in out2
1631 AliVAODParticle* part;
1636 AliAODParticleCut *cut1 = fPairCut->GetFirstPartCut();
1637 AliAODParticleCut *cut2 = fPairCut->GetSecondPartCut();
1641 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1644 part = in->GetParticle(i);
1646 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1647 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1649 if (gDebug)//to be removed in real analysis
1650 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1652 //Particle accpted by both cuts
1653 Error("FilterOut","Particle accepted by both cuts");
1659 out1->AddParticle(part);
1665 out2->AddParticle(part);
1670 /*************************************************************************************/
1672 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1674 //checks if it is possible to use special analysis for non identical particles
1675 //it means - in global pair cut first particle id is different than second one
1676 //and both are different from 0
1677 //in the future is possible to perform more sophisticated check
1678 //if cuts have excluding requirements
1680 if (fPairCut->IsEmpty())
1683 if (fPairCut->GetFirstPartCut()->IsEmpty())
1686 if (fPairCut->GetSecondPartCut()->IsEmpty())
1689 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1690 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1692 if ( (id1==0) || (id2==0) || (id1==id2) )
1697 /*************************************************************************************/
1699 void AliHBTAnalysis::PressAnyKey()
1701 //small utility function that helps to make comfortable macros
1704 fcntl(0, F_SETFL, O_NONBLOCK);
1705 ::Info("","Press Any Key to continue ...");
1708 nread = read(0, &c, 1);
1709 gSystem->ProcessEvents();
1713 /*************************************************************************************/