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]),
64 fDisplayMixingInfo(fgkDefaultMixingInfo),
66 fProcessOption(kSimulatedAndReconstructed),
76 /*************************************************************************************/
78 AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
83 fNParticleFunctions(0),
84 fNParticleAndTrackFunctions(0),
85 fNTrackMonitorFunctions(0),
86 fNParticleMonitorFunctions(0),
87 fNParticleAndTrackMonitorFunctions(0),
89 fParticleFunctions(0x0),
90 fParticleAndTrackFunctions(0x0),
91 fParticleMonitorFunctions(0x0),
92 fTrackMonitorFunctions(0x0),
93 fParticleAndTrackMonitorFunctions(0x0),
97 fBufferSize(fgkDefaultBufferSize),
98 fDisplayMixingInfo(fgkDefaultMixingInfo),
100 fProcessOption(kSimulatedAndReconstructed),
101 fNoCorrfctns(kFALSE),
102 fOutputFileName(0x0),
108 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
110 /*************************************************************************************/
111 AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& /*right*/)
114 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
117 /*************************************************************************************/
118 AliHBTAnalysis::~AliHBTAnalysis()
121 //note that we do not delete functions itself
122 // they should be deleted by whom where created
123 //we only store pointers, and we use "new" only for pointers array
127 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Is Owner: Attempting to delete functions");
129 if (AliVAODParticle::GetDebug()>5)Info("~AliHBTAnalysis","Delete functions done");
131 delete [] fTrackFunctions;
132 delete [] fParticleFunctions;
133 delete [] fParticleAndTrackFunctions;
135 delete [] fParticleMonitorFunctions;
136 delete [] fTrackMonitorFunctions;
137 delete [] fParticleAndTrackMonitorFunctions;
140 delete fOutputFileName;
143 /*************************************************************************************/
145 Int_t AliHBTAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
147 //Processes one event
148 if (fProcEvent == 0x0)
150 Error("ProcessEvent","Analysis <<%s>> option not specified.",GetName());
153 if ( Rejected(aodrec,aodsim) ) return 0;
155 //Move event to the apparent vertex -> must be after the event cut
156 //It is important for any cut that use any spacial coordiantes,
157 //f.g. anti-merging cut in order to preserve the same bahavior of variables (f.g. distance between tracks)
158 Double_t dvx = 0, dvy = 0, dvz = 0;
161 Double_t pvx,pvy,pvz;
162 aodrec->GetPrimaryVertex(pvx,pvy,pvz);
164 dvx = fVertexX - pvx;
165 dvy = fVertexY - pvy;
166 dvz = fVertexZ - pvz;
167 aodrec->Move(dvx,dvy,dvz);
170 Int_t result = (this->*fProcEvent)(aodrec,aodsim);
172 if (aodrec) aodrec->Move(-dvx,-dvy,-dvz);//move event back to the same spacial coordinates
176 /*************************************************************************************/
178 Int_t AliHBTAnalysis::Finish()
184 /*************************************************************************************/
186 void AliHBTAnalysis::DeleteFunctions()
188 //Deletes all functions added to analysis
191 for(ii = 0;ii<fNParticleFunctions;ii++)
193 if (AliVAODParticle::GetDebug()>5)
195 Info("DeleteFunctions","Deleting ParticleFunction %#x",fParticleFunctions[ii]);
196 Info("DeleteFunctions","Deleting ParticleFunction %s",fParticleFunctions[ii]->Name());
198 delete fParticleFunctions[ii];
200 fNParticleFunctions = 0;
202 for(ii = 0;ii<fNTrackFunctions;ii++)
204 if (AliVAODParticle::GetDebug()>5)
206 Info("DeleteFunctions","Deleting TrackFunction %#x",fTrackFunctions[ii]);
207 Info("DeleteFunctions","Deleting TrackFunction %s",fTrackFunctions[ii]->Name());
209 delete fTrackFunctions[ii];
211 fNTrackFunctions = 0;
213 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
215 if (AliVAODParticle::GetDebug()>5)
217 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
218 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
220 delete fParticleAndTrackFunctions[ii];
222 fNParticleAndTrackFunctions = 0;
224 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
226 if (AliVAODParticle::GetDebug()>5)
228 Info("DeleteFunctions","Deleting ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
229 Info("DeleteFunctions","Deleting ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
231 delete fParticleMonitorFunctions[ii];
233 fNParticleMonitorFunctions = 0;
235 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
237 if (AliVAODParticle::GetDebug()>5)
239 Info("DeleteFunctions","Deleting TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
240 Info("DeleteFunctions","Deleting TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
242 delete fTrackMonitorFunctions[ii];
244 fNTrackMonitorFunctions = 0;
246 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
248 if (AliVAODParticle::GetDebug()>5)
250 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
251 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
253 delete fParticleAndTrackMonitorFunctions[ii];
255 fNParticleAndTrackMonitorFunctions = 0;
258 /*************************************************************************************/
260 Int_t AliHBTAnalysis::Init()
262 //Initializeation method
263 //calls Init for all functions
265 //Depending on option and pair cut assigns proper analysis method
266 Bool_t nonid = IsNonIdentAnalysis();
267 switch(fProcessOption)
270 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecNonId;
271 else fProcEvent = &AliHBTAnalysis::ProcessRec;
276 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessSimNonId;
277 else fProcEvent = &AliHBTAnalysis::ProcessSim;
281 case kSimulatedAndReconstructed:
282 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecAndSimNonId;
283 else fProcEvent = &AliHBTAnalysis::ProcessRecAndSim;
287 if (fPartBuffer == 0x0) fPartBuffer = new AliEventBuffer (fBufferSize);
288 else fPartBuffer->Reset();
290 if (fTrackBuffer == 0x0) fTrackBuffer = new AliEventBuffer (fBufferSize);
291 else fTrackBuffer->Reset();
294 fNoCorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
297 for(ii = 0;ii<fNParticleFunctions;ii++)
298 fParticleFunctions[ii]->Init();
300 for(ii = 0;ii<fNTrackFunctions;ii++)
301 fTrackFunctions[ii]->Init();
303 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
304 fParticleAndTrackFunctions[ii]->Init();
306 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
307 fParticleMonitorFunctions[ii]->Init();
309 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
310 fTrackMonitorFunctions[ii]->Init();
312 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
313 fParticleAndTrackMonitorFunctions[ii]->Init();
317 /*************************************************************************************/
319 void AliHBTAnalysis::ResetFunctions()
321 //In case fOwner is true, deletes all functions
322 //in other case, just set number of analysis to 0
323 if (fIsOwner) DeleteFunctions();
326 fNParticleFunctions = 0;
327 fNTrackFunctions = 0;
328 fNParticleAndTrackFunctions = 0;
329 fNParticleMonitorFunctions = 0;
330 fNTrackMonitorFunctions = 0;
331 fNParticleAndTrackMonitorFunctions = 0;
334 /*************************************************************************************/
335 Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
337 //Does analysis for both tracks and particles
338 //mainly for resolution study and analysies with weighting algirithms
340 // cut on particles only -- why?
341 // - PID: when we make resolution analysis we want to take only tracks with correct PID
342 // We need cut on tracks because there are data characteristic
344 AliVAODParticle * part1, * part2;
345 AliVAODParticle * track1, * track2;
347 AliAOD * trackEvent = aodrec, *partEvent = aodsim;
348 AliAOD* trackEvent1 = new AliAOD();
349 AliAOD* partEvent1 = new AliAOD();
350 partEvent1->SetOwner(kTRUE);
351 trackEvent1->SetOwner(kTRUE);
353 AliAOD * trackEvent2,*partEvent2;
355 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
357 // Int_t nev = fReader->GetNumberOfTrackEvents();
358 static AliHBTPair tpair;
359 static AliHBTPair ppair;
361 AliHBTPair* trackpair = &tpair;
362 AliHBTPair* partpair = &ppair;
364 AliHBTPair * tmptrackpair;//temprary pointers to pairs
365 AliHBTPair * tmppartpair;
371 if ( !partEvent || !trackEvent )
373 Error("ProcessRecAndSim","<<%s>> Can not get event",GetName());
377 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
379 Error("ProcessRecAndSim",
380 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d). Skipping Event.",
381 partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
386 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
388 /***************************************/
389 /****** Looping same events ********/
390 /****** filling numerators ********/
391 /***************************************/
392 if ( (j%fDisplayMixingInfo) == 0)
393 Info("ProcessTracksAndParticles",
394 "Mixing particle %d with particles from the same event",j);
396 part1= partEvent->GetParticle(j);
397 track1= trackEvent->GetParticle(j);
399 Bool_t firstcut = (this->*fkPass1)(part1,track1);
400 if (fBufferSize != 0)
401 if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
403 //accepted by any cut
404 // we have to copy because reader keeps only one event
406 partEvent1->AddParticle(new AliAODParticle(*part1));
407 trackEvent1->AddParticle(new AliAODParticle(*track1));
410 if (firstcut) continue;
412 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
413 fParticleMonitorFunctions[ii]->Process(part1);
414 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
415 fTrackMonitorFunctions[ii]->Process(track1);
416 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
417 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
419 if (fNoCorrfctns) continue;
421 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
423 part2= partEvent->GetParticle(k);
424 if (part1->GetUID() == part2->GetUID()) continue;
425 partpair->SetParticles(part1,part2);
427 track2= trackEvent->GetParticle(k);
428 trackpair->SetParticles(track1,track2);
430 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
431 { //do not meets crietria of the pair cut, try with swapped pairs
432 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
433 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
435 { //swaped pair meets all the criteria
436 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
437 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
441 {//meets criteria of the pair cut
442 tmptrackpair = trackpair;
443 tmppartpair = partpair;
446 for(ii = 0;ii<fNParticleFunctions;ii++)
447 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
449 for(ii = 0;ii<fNTrackFunctions;ii++)
450 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
452 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
453 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
454 //end of 2nd loop over particles from the same event
455 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
457 /***************************************/
458 /***** Filling denominators *********/
459 /***************************************/
460 if (fBufferSize == 0) continue;
462 fPartBuffer->ResetIter();
463 fTrackBuffer->ResetIter();
465 while (( partEvent2 = fPartBuffer->Next() ))
467 trackEvent2 = fTrackBuffer->Next();
470 if ( (j%fDisplayMixingInfo) == 0)
471 Info("ProcessTracksAndParticles",
472 "Mixing particle %d from current event with particles from event %d",j,-m);
474 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
476 part2= partEvent2->GetParticle(l);
477 partpair->SetParticles(part1,part2);
479 track2= trackEvent2->GetParticle(l);
480 trackpair->SetParticles(track1,track2);
482 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
483 { //do not meets crietria of the
484 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
488 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
489 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
493 {//meets criteria of the pair cut
494 tmptrackpair = trackpair;
495 tmppartpair = partpair;
498 for(ii = 0;ii<fNParticleFunctions;ii++)
499 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
501 for(ii = 0;ii<fNTrackFunctions;ii++)
502 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
504 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
505 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
506 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
509 //end of loop over particles from first event
510 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
511 delete fPartBuffer->Push(partEvent1);
512 delete fTrackBuffer->Push(trackEvent1);
513 //end of loop over events
516 /*************************************************************************************/
518 Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
520 //Does analysis of simulated data
521 AliVAODParticle * part1, * part2;
523 AliAOD* partEvent = aodsim;
524 AliAOD* partEvent1 = new AliAOD();
525 partEvent1->SetOwner(kTRUE);
531 AliHBTPair* partpair = &ppair;
533 AliHBTPair * tmppartpair;
541 Error("ProcessRecAndSim","Can not get event");
546 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
548 /***************************************/
549 /****** Looping same events ********/
550 /****** filling numerators ********/
551 /***************************************/
552 if ( (j%fDisplayMixingInfo) == 0)
553 Info("ProcessTracksAndParticles",
554 "Mixing particle %d with particles from the same event",j);
556 part1= partEvent->GetParticle(j);
558 Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(part1);
560 if (fBufferSize != 0)
561 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(part1) == kFALSE ) )
563 //accepted by any cut
564 // we have to copy because reader keeps only one event
566 partEvent1->AddParticle(new AliAODParticle(*part1));
569 if (firstcut) continue;
571 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
572 fParticleMonitorFunctions[ii]->Process(part1);
574 if ( fNParticleFunctions == 0 ) continue;
576 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
578 part2= partEvent->GetParticle(k);
579 if (part1->GetUID() == part2->GetUID()) continue;
580 partpair->SetParticles(part1,part2);
582 if(fPairCut->Rejected(partpair)) //check pair cut
583 { //do not meets crietria of the
584 if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
585 else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
589 tmppartpair = partpair;
592 for(ii = 0;ii<fNParticleFunctions;ii++)
593 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
595 //end of 2nd loop over particles from the same event
596 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
598 /***************************************/
599 /***** Filling denominators *********/
600 /***************************************/
601 if (fBufferSize == 0) continue;
603 fPartBuffer->ResetIter();
605 while (( partEvent2 = fPartBuffer->Next() ))
608 if ( (j%fDisplayMixingInfo) == 0)
609 Info("ProcessParticles",
610 "Mixing particle %d from current event with particles from event %d",j,-m);
611 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
614 part2= partEvent2->GetParticle(l);
615 partpair->SetParticles(part1,part2);
617 if( fPairCut->Rejected(partpair) ) //check pair cut
618 { //do not meets crietria of the
619 if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) )
623 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
627 {//meets criteria of the pair cut
628 tmppartpair = partpair;
631 for(ii = 0;ii<fNParticleFunctions;ii++)
632 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
634 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
637 delete fPartBuffer->Push(partEvent1);
638 //end of loop over events
641 /*************************************************************************************/
642 Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
644 //Does analysis of reconstructed data
645 AliVAODParticle * track1, * track2;
647 AliAOD* trackEvent = aodrec;
648 AliAOD* trackEvent1 = new AliAOD();
649 trackEvent1->SetOwner(kTRUE);
655 AliHBTPair* trackpair = &tpair;
657 AliHBTPair * tmptrackpair;
664 Error("ProcessRecAndSim","Can not get event");
669 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
671 /***************************************/
672 /****** Looping same events ********/
673 /****** filling numerators ********/
674 /***************************************/
675 if ( (j%fDisplayMixingInfo) == 0)
676 Info("ProcessTracksAndParticles",
677 "Mixing Particle %d with Particles from the same event",j);
679 track1= trackEvent->GetParticle(j);
681 Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(track1);
683 if (fBufferSize != 0)
684 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(track1) == kFALSE ) )
686 //accepted by any cut
687 // we have to copy because reader keeps only one event
689 trackEvent1->AddParticle(new AliAODParticle(*track1));
692 if (firstcut) continue;
694 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
695 fParticleMonitorFunctions[ii]->Process(track1);
697 if ( fNParticleFunctions == 0 ) continue;
699 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
701 track2= trackEvent->GetParticle(k);
702 if (track1->GetUID() == track2->GetUID()) continue;
703 trackpair->SetParticles(track1,track2);
705 if(fPairCut->Rejected(trackpair)) //check pair cut
706 { //do not meets crietria of the
707 if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
708 else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
712 tmptrackpair = trackpair;
715 for(ii = 0;ii<fNTrackFunctions;ii++)
716 fParticleFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
718 //end of 2nd loop over Particles from the same event
719 }//for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
721 /***************************************/
722 /***** Filling denominators *********/
723 /***************************************/
724 if (fBufferSize == 0) continue;
726 fTrackBuffer->ResetIter();
728 while (( trackEvent2 = fTrackBuffer->Next() ))
731 if ( (j%fDisplayMixingInfo) == 0)
732 Info("ProcessParticles",
733 "Mixing Particle %d from current event with Particles from event %d",j,-m);
734 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all Particles
737 track2= trackEvent2->GetParticle(l);
738 trackpair->SetParticles(track1,track2);
740 if( fPairCut->Rejected(trackpair) ) //check pair cut
741 { //do not meets crietria of the
742 if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) )
746 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
750 {//meets criteria of the pair cut
751 tmptrackpair = trackpair;
754 for(ii = 0;ii<fNTrackFunctions;ii++)
755 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
757 }//for(Int_t l = 0; l<N2;l++) // ... on all Particles
760 delete fTrackBuffer->Push(trackEvent1);
761 //end of loop over events
764 /*************************************************************************************/
766 Int_t AliHBTAnalysis::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
768 //Analyzes both reconstructed and simulated data
771 Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
777 Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
781 if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
783 Error("ProcessTracksAndParticlesNonIdentAnal",
784 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
785 aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
790 AliVAODParticle * part1, * part2;
791 AliVAODParticle * track1, * track2;
793 static AliAOD aodrec1;
794 static AliAOD aodsim1;
796 AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
797 AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
798 AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
800 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
801 AliAOD* rawpartEvent = aodsim;//this we get from Reader
803 static AliHBTPair tpair;
804 static AliHBTPair ppair;
806 AliHBTPair* trackpair = &tpair;
807 AliHBTPair* partpair = &ppair;
812 trackEvent1 = new AliAOD();
813 partEvent1 = new AliAOD();
814 trackEvent1->SetOwner(kFALSE);
815 partEvent1->SetOwner(kFALSE);;
817 /********************************/
819 /********************************/
820 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
822 partEvent2 = new AliAOD();
823 trackEvent2 = new AliAOD();
824 partEvent2->SetOwner(kTRUE);
825 trackEvent2->SetOwner(kTRUE);
828 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
830 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
832 if ( (j%fDisplayMixingInfo) == 0)
833 Info("ProcessTracksAndParticlesNonIdentAnal",
834 "Mixing particle %d from current event with particles from current event",j);
836 part1= partEvent1->GetParticle(j);
837 track1= trackEvent1->GetParticle(j);
840 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
841 fParticleMonitorFunctions[ii]->Process(part1);
842 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
843 fTrackMonitorFunctions[ii]->Process(track1);
844 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
845 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
847 if (fNoCorrfctns) continue;
849 /***************************************/
850 /****** filling numerators ********/
851 /****** (particles from event2) ********/
852 /***************************************/
854 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
856 part2= partEvent2->GetParticle(k);
857 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
858 partpair->SetParticles(part1,part2);
860 track2= trackEvent2->GetParticle(k);
861 trackpair->SetParticles(track1,track2);
863 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
864 { //do not meets crietria of the pair cut
868 {//meets criteria of the pair cut
869 for(ii = 0;ii<fNParticleFunctions;ii++)
870 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
872 for(ii = 0;ii<fNTrackFunctions;ii++)
873 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
875 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
876 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
880 if ( fBufferSize == 0) continue;//do not mix diff histograms
881 /***************************************/
882 /***** Filling denominators *********/
883 /***************************************/
884 fPartBuffer->ResetIter();
885 fTrackBuffer->ResetIter();
889 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
891 trackEvent3 = fTrackBuffer->Next();
893 if ( (j%fDisplayMixingInfo) == 0)
894 Info("ProcessTracksAndParticlesNonIdentAnal",
895 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
897 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
899 part2= partEvent3->GetParticle(k);
900 partpair->SetParticles(part1,part2);
902 track2= trackEvent3->GetParticle(k);
903 trackpair->SetParticles(track1,track2);
905 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
906 { //do not meets crietria of the pair cut
910 {//meets criteria of the pair cut
912 for(ii = 0;ii<fNParticleFunctions;ii++)
913 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
915 for(ii = 0;ii<fNTrackFunctions;ii++)
916 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
918 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
919 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
921 }// for particles event2
923 }//for over particles in event1
925 delete fPartBuffer->Push(partEvent2);
926 delete fTrackBuffer->Push(trackEvent2);
930 /*************************************************************************************/
931 Int_t AliHBTAnalysis::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
933 //does analysis of simulated (MC) data in non-identical mode
934 //i.e. when particles selected by first part. cut are a disjunctive set than particles
935 //passed by the second part. cut
942 AliVAODParticle * part1, * part2;
944 static AliAOD aodsim1;
946 AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
947 AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
948 AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
950 AliAOD* rawpartEvent = aodsim;//this we get from Reader
952 static AliHBTPair ppair;
954 AliHBTPair* partpair = &ppair;
959 partEvent1 = new AliAOD();
960 partEvent1->SetOwner(kFALSE);;
963 /********************************/
965 /********************************/
966 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
968 partEvent2 = new AliAOD();
969 partEvent2->SetOwner(kTRUE);
972 FilterOut(partEvent1, partEvent2, rawpartEvent);
974 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
976 if ( (j%fDisplayMixingInfo) == 0)
977 Info("ProcessParticlesNonIdentAnal",
978 "Mixing particle %d from current event with particles from current event",j);
980 part1= partEvent1->GetParticle(j);
983 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
984 fParticleMonitorFunctions[ii]->Process(part1);
986 if (fNParticleFunctions == 0) continue;
988 /***************************************/
989 /****** filling numerators ********/
990 /****** (particles from event2) ********/
991 /***************************************/
993 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
995 part2= partEvent2->GetParticle(k);
996 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
997 partpair->SetParticles(part1,part2);
1000 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1001 { //do not meets crietria of the pair cut
1005 {//meets criteria of the pair cut
1006 for(ii = 0;ii<fNParticleFunctions;ii++)
1007 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1011 if ( fBufferSize == 0) continue;//do not mix diff histograms
1012 /***************************************/
1013 /***** Filling denominators *********/
1014 /***************************************/
1015 fPartBuffer->ResetIter();
1019 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
1022 if ( (j%fDisplayMixingInfo) == 0)
1023 Info("ProcessParticlesNonIdentAnal",
1024 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1026 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1028 part2= partEvent3->GetParticle(k);
1029 partpair->SetParticles(part1,part2);
1032 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1033 { //do not meets crietria of the pair cut
1037 {//meets criteria of the pair cut
1038 for(ii = 0;ii<fNParticleFunctions;ii++)
1040 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1043 }// for particles event2
1045 }//for over particles in event1
1047 delete fPartBuffer->Push(partEvent2);
1051 /*************************************************************************************/
1052 Int_t AliHBTAnalysis::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
1054 //Analyzes both reconstructed and simulated data
1060 AliVAODParticle * track1, * track2;
1062 static AliAOD aodrec1;
1064 AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
1065 AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
1066 AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
1068 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
1070 static AliHBTPair tpair;
1072 AliHBTPair* trackpair = &tpair;
1077 trackEvent1 = new AliAOD();
1078 trackEvent1->SetOwner(kFALSE);
1080 /********************************/
1082 /********************************/
1083 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1085 trackEvent2 = new AliAOD();
1086 trackEvent2->SetOwner(kTRUE);
1089 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1091 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1093 if ( (j%fDisplayMixingInfo) == 0)
1094 Info("ProcessTracksNonIdentAnal",
1095 "Mixing particle %d from current event with particles from current event",j);
1097 track1= trackEvent1->GetParticle(j);
1100 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1101 fTrackMonitorFunctions[ii]->Process(track1);
1103 if (fNTrackFunctions == 0x0) continue;
1105 /***************************************/
1106 /****** filling numerators ********/
1107 /****** (particles from event2) ********/
1108 /***************************************/
1110 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1112 track2= trackEvent2->GetParticle(k);
1113 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1114 trackpair->SetParticles(track1,track2);
1117 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1118 { //do not meets crietria of the pair cut
1122 {//meets criteria of the pair cut
1124 for(ii = 0;ii<fNTrackFunctions;ii++)
1125 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1129 if ( fBufferSize == 0) continue;//do not mix diff histograms
1130 /***************************************/
1131 /***** Filling denominators *********/
1132 /***************************************/
1133 fTrackBuffer->ResetIter();
1137 while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
1139 if ( (j%fDisplayMixingInfo) == 0)
1140 Info("ProcessTracksNonIdentAnal",
1141 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1143 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1145 track2= trackEvent3->GetParticle(k);
1146 trackpair->SetParticles(track1,track2);
1148 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1149 { //do not meets crietria of the pair cut
1153 {//meets criteria of the pair cut
1154 for(ii = 0;ii<fNTrackFunctions;ii++)
1155 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1157 }// for particles event2
1159 }//for over particles in event1
1161 delete fTrackBuffer->Push(trackEvent2);
1165 /*************************************************************************************/
1167 void AliHBTAnalysis::Process(Option_t* option)
1169 //default option = "TracksAndParticles"
1170 //Main method of the HBT Analysis Package
1171 //It triggers reading with the global cut (default is an empty cut)
1172 //Than it checks options and data which are read
1173 //if everything is OK, then it calls one of the looping methods
1174 //depending on tfReaderhe option
1175 //These methods differs on what thay are looping on
1178 //--------------------------------------------------------------------
1179 //ProcessTracksAndParticles - "TracksAndParticles"
1181 // it loops over both, tracks(reconstructed) and particles(simulated)
1182 // all function gethered in all 3 lists are called for each (double)pair
1184 //ProcessTracks - "Tracks"
1185 // it loops only on tracks(reconstructed),
1186 // functions ONLY from fTrackFunctions list are called
1188 //ProcessParticles - "Particles"
1189 // it loops only on particles(simulated),
1190 // functions ONLY from fParticleAndTrackFunctions list are called
1195 Error("Process","The reader is not set");
1199 const char *oT = strstr(option,"Tracks");
1200 const char *oP = strstr(option,"Particles");
1202 Bool_t nonid = IsNonIdentAnalysis();
1208 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
1209 else ProcessTracksAndParticles();
1215 if (nonid) ProcessTracksNonIdentAnal();
1216 else ProcessTracks();
1222 if (nonid) ProcessParticlesNonIdentAnal();
1223 else ProcessParticles();
1228 /*************************************************************************************/
1230 void AliHBTAnalysis::ProcessTracksAndParticles()
1232 //Makes analysis for both tracks and particles
1233 //mainly for resolution study and analysies with weighting algirithms
1234 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1235 //the loops are splited
1237 // cut on particles only -- why?
1238 // - PID: when we make resolution analysis we want to take only tracks with correct PID
1239 // We need cut on tracks because there are data characteristic to
1241 AliAOD * trackEvent, *partEvent;
1244 while (fReader->Next() == kFALSE)
1246 partEvent = fReader->GetEventSim();
1247 trackEvent = fReader->GetEventRec();
1248 ProcessRecAndSim(trackEvent,partEvent);
1250 }//while (fReader->Next() == kFALSE)
1253 /*************************************************************************************/
1255 void AliHBTAnalysis::ProcessTracks()
1257 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1258 //the loops are splited
1259 AliAOD * trackEvent;
1261 while (fReader->Next() == kFALSE)
1263 trackEvent = fReader->GetEventRec();
1264 ProcessRec(trackEvent,0x0);
1265 }//while (fReader->Next() == kFALSE)
1268 /*************************************************************************************/
1270 void AliHBTAnalysis::ProcessParticles()
1272 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1273 //the loops are splited
1276 while (fReader->Next() == kFALSE)
1278 partEvent = fReader->GetEventSim();
1279 ProcessSim(0x0,partEvent);
1280 }//while (fReader->Next() == kFALSE)
1282 /*************************************************************************************/
1284 void AliHBTAnalysis::WriteFunctions()
1286 //Calls Write for all defined functions in analysis
1287 //== writes all results
1288 TFile* oututfile = 0x0;
1289 if (fOutputFileName)
1291 oututfile = TFile::Open(*fOutputFileName,"update");
1294 for(ii = 0;ii<fNParticleFunctions;ii++)
1296 if (AliVAODParticle::GetDebug()>5)
1298 Info("WriteFunctions","Writing ParticleFunction %#x",fParticleFunctions[ii]);
1299 Info("WriteFunctions","Writing ParticleFunction %s",fParticleFunctions[ii]->Name());
1301 fParticleFunctions[ii]->Write();
1304 for(ii = 0;ii<fNTrackFunctions;ii++)
1306 if (AliVAODParticle::GetDebug()>5)
1308 Info("WriteFunctions","Writing TrackFunction %#x",fTrackFunctions[ii]);
1309 Info("WriteFunctions","Writing TrackFunction %s",fTrackFunctions[ii]->Name());
1311 fTrackFunctions[ii]->Write();
1314 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1316 if (AliVAODParticle::GetDebug()>5)
1318 Info("WriteFunctions","Writing ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
1319 Info("WriteFunctions","Writing ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
1321 fParticleAndTrackFunctions[ii]->Write();
1324 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
1326 if (AliVAODParticle::GetDebug()>5)
1328 Info("WriteFunctions","Writing ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
1329 Info("WriteFunctions","Writing ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
1331 fParticleMonitorFunctions[ii]->Write();
1334 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
1336 if (AliVAODParticle::GetDebug()>5)
1338 Info("WriteFunctions","Writing TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
1339 Info("WriteFunctions","Writing TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
1341 fTrackMonitorFunctions[ii]->Write();
1344 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
1346 if (AliVAODParticle::GetDebug()>5)
1348 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
1349 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
1351 fParticleAndTrackMonitorFunctions[ii]->Write();
1355 /*************************************************************************************/
1357 void AliHBTAnalysis::SetOutputFileName(const char* fname)
1359 //Sets fiele name where to dump results,
1360 //if not specified reults are written to gDirectory
1363 delete fOutputFileName;
1364 fOutputFileName = 0x0;
1367 if ( strcmp(fname,"") == 0 )
1369 delete fOutputFileName;
1370 fOutputFileName = 0x0;
1373 if (fOutputFileName == 0x0) fOutputFileName = new TString(fname);
1374 else *fOutputFileName = fname;
1376 /*************************************************************************************/
1378 void AliHBTAnalysis::SetGlobalPairCut(AliAODPairCut* cut)
1380 //Sets the global cut
1383 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
1386 fPairCut = (AliAODPairCut*)cut->Clone();
1389 /*************************************************************************************/
1391 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1393 //Adds track function
1394 if (f == 0x0) return;
1395 if (fNTrackFunctions == fgkFctnArraySize)
1397 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
1399 fTrackFunctions[fNTrackFunctions] = f;
1402 /*************************************************************************************/
1404 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1406 //adds particle function
1407 if (f == 0x0) return;
1409 if (fNParticleFunctions == fgkFctnArraySize)
1411 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
1413 fParticleFunctions[fNParticleFunctions] = f;
1414 fNParticleFunctions++;
1416 /*************************************************************************************/
1418 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1420 //add resolution function
1421 if (f == 0x0) return;
1422 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
1424 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
1426 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
1427 fNParticleAndTrackFunctions++;
1429 /*************************************************************************************/
1431 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
1433 //add particle monitoring function
1434 if (f == 0x0) return;
1436 if (fNParticleMonitorFunctions == fgkFctnArraySize)
1438 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
1440 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
1441 fNParticleMonitorFunctions++;
1443 /*************************************************************************************/
1445 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
1447 //add track monitoring function
1448 if (f == 0x0) return;
1450 if (fNTrackMonitorFunctions == fgkFctnArraySize)
1452 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
1454 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
1455 fNTrackMonitorFunctions++;
1457 /*************************************************************************************/
1459 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
1461 //add resolution monitoring function
1462 if (f == 0x0) return;
1463 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
1465 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
1467 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
1468 fNParticleAndTrackMonitorFunctions++;
1472 /*************************************************************************************/
1473 /*************************************************************************************/
1475 Bool_t AliHBTAnalysis::RunCoherencyCheck()
1477 //Checks if both HBTRuns are similar
1478 //return true if error found
1479 //if they seem to be OK return false
1483 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
1485 //When we use non-buffering reader this is a big waste of time -> We need to read all data to check it
1486 //and reader is implemented safe in this case anyway
1487 // Info("RunCoherencyCheck","Number of events ...");
1488 // if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
1490 // Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1493 // { //if not the same - ERROR
1494 // Error("RunCoherencyCheck",
1495 // "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
1496 // fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
1500 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1504 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
1506 partEvent= fReader->GetEventSim(i); //gets the "ith" event
1507 trackEvent = fReader->GetEventRec(i);
1509 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
1510 if ( (partEvent == 0x0) || (partEvent == 0x0) )
1512 Error("RunCoherencyCheck",
1513 "One event is NULL and the other one not. Event Number %d",i);
1517 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
1519 Error("RunCoherencyCheck",
1520 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
1521 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
1525 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
1527 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
1529 Error("RunCoherencyCheck",
1530 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
1531 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
1537 Info("RunCoherencyCheck"," Done");
1538 Info("RunCoherencyCheck"," Everything looks OK");
1543 /*************************************************************************************/
1545 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
1547 //Performs analysis for both, tracks and particles
1548 AliAOD* rawtrackEvent, * rawpartEvent;
1551 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1552 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1553 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1555 for (Int_t i = 0;;i++)//infinite loop
1557 if (fReader->Next()) break; //end when no more events available
1559 rawpartEvent = fReader->GetEventSim();
1560 rawtrackEvent = fReader->GetEventRec();
1562 ProcessRecAndSimNonId(rawtrackEvent,rawpartEvent);
1563 }//end of loop over events (1)
1565 /*************************************************************************************/
1567 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1569 //Process Tracks only with non identical mode
1570 AliAOD * rawtrackEvent;
1573 Info("ProcessTracksNonIdentAnal","**************************************");
1574 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1575 Info("ProcessTracksNonIdentAnal","**************************************");
1577 for (Int_t i = 0;;i++)//infinite loop
1579 if (fReader->Next()) break; //end when no more events available
1580 rawtrackEvent = fReader->GetEventRec();
1581 ProcessRecNonId(rawtrackEvent,0x0);
1582 }//end of loop over events (1)
1584 /*************************************************************************************/
1586 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1588 //process paricles only with non identical mode
1589 AliAOD * rawpartEvent = 0x0;
1592 Info("ProcessParticlesNonIdentAnal","**************************************");
1593 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1594 Info("ProcessParticlesNonIdentAnal","**************************************");
1596 for (Int_t i = 0;;i++)//infinite loop
1598 if (fReader->Next()) break; //end when no more events available
1600 rawpartEvent = fReader->GetEventSim();
1601 ProcessSimNonId(0x0,rawpartEvent);
1602 }//end of loop over events (1)
1605 /*************************************************************************************/
1606 void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpart,
1607 AliAOD* outtrack1, AliAOD* outtrack2, AliAOD* intrack) const
1609 //Puts particles accepted as a first particle by global cut in out1
1610 //and as a second particle in out2
1612 AliVAODParticle* part, *track;
1621 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1624 part = inpart->GetParticle(i);
1625 track = intrack->GetParticle(i);
1627 if ( ((this->*fkPass1)(part,track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1628 if ( ((this->*fkPass2)(part,track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1630 if (gDebug)//to be removed in real analysis
1631 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1633 //Particle accpted by both cuts
1634 Error("FilterOut","Particle accepted by both cuts");
1640 outpart1->AddParticle(part);
1641 outtrack1->AddParticle(track);
1647 outpart2->AddParticle(new AliAODParticle(*part));
1648 outtrack2->AddParticle(new AliAODParticle(*track));
1653 /*************************************************************************************/
1655 void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
1657 //Puts particles accepted as a first particle by global cut in out1
1658 //and as a second particle in out2
1659 AliVAODParticle* part;
1664 AliAODParticleCut *cut1 = fPairCut->GetFirstPartCut();
1665 AliAODParticleCut *cut2 = fPairCut->GetSecondPartCut();
1669 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1672 part = in->GetParticle(i);
1674 if ( cut1->Rejected(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1675 if ( cut2->Rejected(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1677 if (gDebug)//to be removed in real analysis
1678 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1680 //Particle accpted by both cuts
1681 Error("FilterOut","Particle accepted by both cuts");
1687 out1->AddParticle(part);
1693 out2->AddParticle(part);
1698 /*************************************************************************************/
1700 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1702 //checks if it is possible to use special analysis for non identical particles
1703 //it means - in global pair cut first particle id is different than second one
1704 //and both are different from 0
1705 //in the future is possible to perform more sophisticated check
1706 //if cuts have excluding requirements
1708 if (fPairCut->IsEmpty())
1711 if (fPairCut->GetFirstPartCut()->IsEmpty())
1714 if (fPairCut->GetSecondPartCut()->IsEmpty())
1717 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1718 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1720 if ( (id1==0) || (id2==0) || (id1==id2) )
1725 /*************************************************************************************/
1727 void AliHBTAnalysis::SetApparentVertex(Double_t x, Double_t y, Double_t z)
1729 //Sets apparent vertex
1730 // All events have to be moved to the same vertex position in order to
1731 // to be able to comare any space positions (f.g. anti-merging)
1732 // This method defines this position
1738 /*************************************************************************************/
1740 void AliHBTAnalysis::PressAnyKey()
1742 //small utility function that helps to make comfortable macros
1745 fcntl(0, F_SETFL, O_NONBLOCK);
1746 ::Info("","Press Any Key to continue ...");
1749 nread = read(0, &c, 1);
1750 gSystem->ProcessEvents();
1754 /*************************************************************************************/