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 //_________________________________________________________
24 #include "AliAODParticle.h"
25 #include "AliAODPairCut.h"
27 #include "AliEventBuffer.h"
29 #include "AliReader.h"
30 #include "AliHBTPair.h"
31 #include "AliHBTFunction.h"
32 #include "AliHBTMonitorFunction.h"
36 ClassImp(AliHBTAnalysis)
38 const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
39 const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
40 const Int_t AliHBTAnalysis::fgkDefaultBufferSize = 5;
42 AliHBTAnalysis::AliHBTAnalysis():
46 fNParticleFunctions(0),
47 fNParticleAndTrackFunctions(0),
48 fNTrackMonitorFunctions(0),
49 fNParticleMonitorFunctions(0),
50 fNParticleAndTrackMonitorFunctions(0),
51 fTrackFunctions ( new AliHBTOnePairFctn* [fgkFctnArraySize]),
52 fParticleFunctions ( new AliHBTOnePairFctn* [fgkFctnArraySize]),
53 fParticleAndTrackFunctions ( new AliHBTTwoPairFctn* [fgkFctnArraySize]),
54 fParticleMonitorFunctions ( new AliHBTMonOneParticleFctn* [fgkFctnArraySize]),
55 fTrackMonitorFunctions ( new AliHBTMonOneParticleFctn* [fgkFctnArraySize]),
56 fParticleAndTrackMonitorFunctions ( new AliHBTMonTwoParticleFctn* [fgkFctnArraySize]),
57 fPairCut(new AliAODEmptyPairCut()),//empty cut - accepts all particles
59 fDisplayMixingInfo(fgkDefaultMixingInfo),
63 fProcessOption(kSimulatedAndReconstructed),
65 fkPass(&AliHBTAnalysis::PassPartAndTrack), //by default perform cut on both track and particle pair
66 fkPass1(&AliHBTAnalysis::PassPartAndTrack1), //used onluy by ProcessTracksAndParticles
67 fkPass2(&AliHBTAnalysis::PassPartAndTrack2),
68 fkPassPairProp(&AliHBTAnalysis::PassPairPropPartAndTrack)
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),
99 fkPass(&AliHBTAnalysis::PassPartAndTrack), //by default perform cut on both track and particle pair
100 fkPass1(&AliHBTAnalysis::PassPartAndTrack1),
101 fkPass2(&AliHBTAnalysis::PassPartAndTrack2),
102 fkPassPairProp(&AliHBTAnalysis::PassPairPropPartAndTrack)
105 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
107 /*************************************************************************************/
108 AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& /*right*/)
111 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
114 /*************************************************************************************/
115 AliHBTAnalysis::~AliHBTAnalysis()
118 //note that we do not delete functions itself
119 // they should be deleted by whom where created
120 //we only store pointers, and we use "new" only for pointers array
124 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Is Owner: Attempting to delete functions");
126 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Delete functions done");
128 delete [] fTrackFunctions;
129 delete [] fParticleFunctions;
130 delete [] fParticleAndTrackFunctions;
132 delete [] fParticleMonitorFunctions;
133 delete [] fTrackMonitorFunctions;
134 delete [] fParticleAndTrackMonitorFunctions;
136 delete fPairCut; // always have an copy of an object - we create we dstroy
139 /*************************************************************************************/
140 Int_t AliHBTAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
142 //Processes one event
143 if (fProcEvent == 0x0)
145 Error("ProcessEvent","Analysis option not specified");
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
1261 for(ii = 0;ii<fNParticleFunctions;ii++)
1263 if (AliVAODParticle::GetDebug()>5)
1265 Info("WriteFunctions","Writing ParticleFunction %#x",fParticleFunctions[ii]);
1266 Info("WriteFunctions","Writing ParticleFunction %s",fParticleFunctions[ii]->Name());
1268 fParticleFunctions[ii]->Write();
1271 for(ii = 0;ii<fNTrackFunctions;ii++)
1273 if (AliVAODParticle::GetDebug()>5)
1275 Info("WriteFunctions","Writing TrackFunction %#x",fTrackFunctions[ii]);
1276 Info("WriteFunctions","Writing TrackFunction %s",fTrackFunctions[ii]->Name());
1278 fTrackFunctions[ii]->Write();
1281 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1283 if (AliVAODParticle::GetDebug()>5)
1285 Info("WriteFunctions","Writing ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
1286 Info("WriteFunctions","Writing ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
1288 fParticleAndTrackFunctions[ii]->Write();
1291 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
1293 if (AliVAODParticle::GetDebug()>5)
1295 Info("WriteFunctions","Writing ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
1296 Info("WriteFunctions","Writing ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
1298 fParticleMonitorFunctions[ii]->Write();
1301 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
1303 if (AliVAODParticle::GetDebug()>5)
1305 Info("WriteFunctions","Writing TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
1306 Info("WriteFunctions","Writing TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
1308 fTrackMonitorFunctions[ii]->Write();
1311 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
1313 if (AliVAODParticle::GetDebug()>5)
1315 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
1316 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
1318 fParticleAndTrackMonitorFunctions[ii]->Write();
1321 /*************************************************************************************/
1323 void AliHBTAnalysis::SetGlobalPairCut(AliAODPairCut* cut)
1325 //Sets the global cut
1328 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
1331 fPairCut = (AliAODPairCut*)cut->Clone();
1334 /*************************************************************************************/
1336 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1338 //Adds track function
1339 if (f == 0x0) return;
1340 if (fNTrackFunctions == fgkFctnArraySize)
1342 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
1344 fTrackFunctions[fNTrackFunctions] = f;
1347 /*************************************************************************************/
1349 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1351 //adds particle function
1352 if (f == 0x0) return;
1354 if (fNParticleFunctions == fgkFctnArraySize)
1356 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
1358 fParticleFunctions[fNParticleFunctions] = f;
1359 fNParticleFunctions++;
1361 /*************************************************************************************/
1363 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1365 //add resolution function
1366 if (f == 0x0) return;
1367 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
1369 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
1371 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
1372 fNParticleAndTrackFunctions++;
1374 /*************************************************************************************/
1376 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
1378 //add particle monitoring function
1379 if (f == 0x0) return;
1381 if (fNParticleMonitorFunctions == fgkFctnArraySize)
1383 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
1385 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
1386 fNParticleMonitorFunctions++;
1388 /*************************************************************************************/
1390 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
1392 //add track monitoring function
1393 if (f == 0x0) return;
1395 if (fNTrackMonitorFunctions == fgkFctnArraySize)
1397 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
1399 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
1400 fNTrackMonitorFunctions++;
1402 /*************************************************************************************/
1404 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
1406 //add resolution monitoring function
1407 if (f == 0x0) return;
1408 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
1410 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
1412 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
1413 fNParticleAndTrackMonitorFunctions++;
1417 /*************************************************************************************/
1418 /*************************************************************************************/
1420 Bool_t AliHBTAnalysis::RunCoherencyCheck()
1422 //Checks if both HBTRuns are similar
1423 //return true if error found
1424 //if they seem to be OK return false
1428 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
1430 //When we use non-buffering reader this is a big waste of time -> We need to read all data to check it
1431 //and reader is implemented safe in this case anyway
1432 // Info("RunCoherencyCheck","Number of events ...");
1433 // if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
1435 // Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1438 // { //if not the same - ERROR
1439 // Error("RunCoherencyCheck",
1440 // "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
1441 // fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
1445 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1449 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
1451 partEvent= fReader->GetEventSim(i); //gets the "ith" event
1452 trackEvent = fReader->GetEventRec(i);
1454 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
1455 if ( (partEvent == 0x0) || (partEvent == 0x0) )
1457 Error("RunCoherencyCheck",
1458 "One event is NULL and the other one not. Event Number %d",i);
1462 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
1464 Error("RunCoherencyCheck",
1465 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
1466 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
1470 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
1472 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
1474 Error("RunCoherencyCheck",
1475 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
1476 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
1482 Info("RunCoherencyCheck"," Done");
1483 Info("RunCoherencyCheck"," Everything looks OK");
1488 /*************************************************************************************/
1490 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
1492 //Performs analysis for both, tracks and particles
1493 AliAOD* rawtrackEvent, * rawpartEvent;
1496 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1497 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1498 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1500 for (Int_t i = 0;;i++)//infinite loop
1502 if (fReader->Next()) break; //end when no more events available
1504 rawpartEvent = fReader->GetEventSim();
1505 rawtrackEvent = fReader->GetEventRec();
1507 ProcessRecAndSimNonId(rawtrackEvent,rawpartEvent);
1508 }//end of loop over events (1)
1510 /*************************************************************************************/
1512 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1514 //Process Tracks only with non identical mode
1515 AliAOD * rawtrackEvent;
1518 Info("ProcessTracksNonIdentAnal","**************************************");
1519 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1520 Info("ProcessTracksNonIdentAnal","**************************************");
1522 for (Int_t i = 0;;i++)//infinite loop
1524 if (fReader->Next()) break; //end when no more events available
1525 rawtrackEvent = fReader->GetEventRec();
1526 ProcessRecNonId(rawtrackEvent,0x0);
1527 }//end of loop over events (1)
1529 /*************************************************************************************/
1531 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1533 //process paricles only with non identical mode
1534 AliAOD * rawpartEvent = 0x0;
1537 Info("ProcessParticlesNonIdentAnal","**************************************");
1538 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1539 Info("ProcessParticlesNonIdentAnal","**************************************");
1541 for (Int_t i = 0;;i++)//infinite loop
1543 if (fReader->Next()) break; //end when no more events available
1545 rawpartEvent = fReader->GetEventSim();
1546 ProcessSimNonId(0x0,rawpartEvent);
1547 }//end of loop over events (1)
1550 /*************************************************************************************/
1551 void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpart,
1552 AliAOD* outtrack1, AliAOD* outtrack2, AliAOD* intrack) const
1554 //Puts particles accepted as a first particle by global cut in out1
1555 //and as a second particle in out2
1557 AliVAODParticle* part, *track;
1566 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1569 part = inpart->GetParticle(i);
1570 track = intrack->GetParticle(i);
1572 if ( ((this->*fkPass1)(part,track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1573 if ( ((this->*fkPass2)(part,track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1575 if (gDebug)//to be removed in real analysis
1576 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1578 //Particle accpted by both cuts
1579 Error("FilterOut","Particle accepted by both cuts");
1585 outpart1->AddParticle(part);
1586 outtrack1->AddParticle(track);
1592 outpart2->AddParticle(new AliAODParticle(*part));
1593 outtrack2->AddParticle(new AliAODParticle(*track));
1598 /*************************************************************************************/
1600 void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
1602 //Puts particles accepted as a first particle by global cut in out1
1603 //and as a second particle in out2
1604 AliVAODParticle* part;
1609 AliAODParticleCut *cut1 = fPairCut->GetFirstPartCut();
1610 AliAODParticleCut *cut2 = fPairCut->GetSecondPartCut();
1614 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1617 part = in->GetParticle(i);
1619 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1620 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1622 if (gDebug)//to be removed in real analysis
1623 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1625 //Particle accpted by both cuts
1626 Error("FilterOut","Particle accepted by both cuts");
1632 out1->AddParticle(part);
1638 out2->AddParticle(part);
1643 /*************************************************************************************/
1645 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1647 //checks if it is possible to use special analysis for non identical particles
1648 //it means - in global pair cut first particle id is different than second one
1649 //and both are different from 0
1650 //in the future is possible to perform more sophisticated check
1651 //if cuts have excluding requirements
1653 if (fPairCut->IsEmpty())
1656 if (fPairCut->GetFirstPartCut()->IsEmpty())
1659 if (fPairCut->GetSecondPartCut()->IsEmpty())
1662 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1663 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1665 if ( (id1==0) || (id2==0) || (id1==id2) )
1670 /*************************************************************************************/
1672 void AliHBTAnalysis::SetCutsOnParticles()
1674 // -- aplies only to Process("TracksAndParticles")
1675 // (ProcessTracksAndParticles and ProcessTracksAndParticlesNonIdentAnal)
1676 // Only particles properties are checkes against cuts
1677 fkPass = &AliHBTAnalysis::PassPart;
1678 fkPass1 = &AliHBTAnalysis::PassPart1;
1679 fkPass2 = &AliHBTAnalysis::PassPart2;
1680 fkPassPairProp = &AliHBTAnalysis::PassPairPropPart;
1683 /*************************************************************************************/
1685 void AliHBTAnalysis::SetCutsOnTracks()
1687 // -- aplies only to Process("TracksAndParticles")
1688 // (ProcessTracksAndParticles and ProcessTracksAndParticlesNonIdentAnal)
1689 // Only tracks properties are checkes against cuts
1690 Info("SetCutsOnTracks","Only reconstructed particles will be checked");
1691 fkPass = &AliHBTAnalysis::PassTrack;
1692 fkPass1 = &AliHBTAnalysis::PassTrack1;
1693 fkPass2 = &AliHBTAnalysis::PassTrack2;
1694 fkPassPairProp = &AliHBTAnalysis::PassPairPropTrack;
1697 /*************************************************************************************/
1699 void AliHBTAnalysis::SetCutsOnTracksAndParticles()
1701 // -- aplies only to Process("TracksAndParticles")
1702 // (ProcessTracksAndParticles and ProcessTracksAndParticlesNonIdentAnal)
1703 // Both, tracks and particles, properties are checked against cuts
1704 fkPass = &AliHBTAnalysis::PassPartAndTrack;
1705 fkPass1 = &AliHBTAnalysis::PassPartAndTrack1;
1706 fkPass2 = &AliHBTAnalysis::PassPartAndTrack2;
1707 fkPassPairProp = &AliHBTAnalysis::PassPairPropPartAndTrack;
1709 /*************************************************************************************/
1711 void AliHBTAnalysis::PressAnyKey()
1713 //small utility function that helps to make comfortable macros
1716 fcntl(0, F_SETFL, O_NONBLOCK);
1717 ::Info("","Press Any Key to continue ...");
1720 nread = read(0, &c, 1);
1721 gSystem->ProcessEvents();
1725 /*************************************************************************************/