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) )
155 // Double_t x = 0, y = 0, z = 0;
156 // aodrec->GetPrimaryVertex(x,y,z);
157 // Info("ProcessEvent","Event has vertex at %f %f %f",x,y,z);
158 Info("ProcessEvent","Nch is %d",aodsim->GetNumberOfCharged());
159 Info("ProcessEvent","%s: Event cut rejected this event",GetName());
163 //Move event to the apparent vertex -> must be after the event cut
164 //It is important for any cut that use any spacial coordiantes,
165 //f.g. anti-merging cut in order to preserve the same bahavior of variables (f.g. distance between tracks)
166 Double_t dvx = 0, dvy = 0, dvz = 0;
169 Double_t pvx,pvy,pvz;
170 aodrec->GetPrimaryVertex(pvx,pvy,pvz);
172 dvx = fVertexX - pvx;
173 dvy = fVertexY - pvy;
174 dvz = fVertexZ - pvz;
175 aodrec->Move(dvx,dvy,dvz);
178 Int_t result = (this->*fProcEvent)(aodrec,aodsim);
180 if (aodrec) aodrec->Move(-dvx,-dvy,-dvz);//move event back to the same spacial coordinates
184 /*************************************************************************************/
186 Int_t AliHBTAnalysis::Finish()
192 /*************************************************************************************/
194 void AliHBTAnalysis::DeleteFunctions()
196 //Deletes all functions added to analysis
199 for(ii = 0;ii<fNParticleFunctions;ii++)
201 if (AliVAODParticle::GetDebug()>5)
203 Info("DeleteFunctions","Deleting ParticleFunction %#x",fParticleFunctions[ii]);
204 Info("DeleteFunctions","Deleting ParticleFunction %s",fParticleFunctions[ii]->Name());
206 delete fParticleFunctions[ii];
208 fNParticleFunctions = 0;
210 for(ii = 0;ii<fNTrackFunctions;ii++)
212 if (AliVAODParticle::GetDebug()>5)
214 Info("DeleteFunctions","Deleting TrackFunction %#x",fTrackFunctions[ii]);
215 Info("DeleteFunctions","Deleting TrackFunction %s",fTrackFunctions[ii]->Name());
217 delete fTrackFunctions[ii];
219 fNTrackFunctions = 0;
221 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
223 if (AliVAODParticle::GetDebug()>5)
225 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
226 Info("DeleteFunctions","Deleting ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
228 delete fParticleAndTrackFunctions[ii];
230 fNParticleAndTrackFunctions = 0;
232 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
234 if (AliVAODParticle::GetDebug()>5)
236 Info("DeleteFunctions","Deleting ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
237 Info("DeleteFunctions","Deleting ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
239 delete fParticleMonitorFunctions[ii];
241 fNParticleMonitorFunctions = 0;
243 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
245 if (AliVAODParticle::GetDebug()>5)
247 Info("DeleteFunctions","Deleting TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
248 Info("DeleteFunctions","Deleting TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
250 delete fTrackMonitorFunctions[ii];
252 fNTrackMonitorFunctions = 0;
254 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
256 if (AliVAODParticle::GetDebug()>5)
258 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
259 Info("DeleteFunctions","Deleting ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
261 delete fParticleAndTrackMonitorFunctions[ii];
263 fNParticleAndTrackMonitorFunctions = 0;
266 /*************************************************************************************/
268 Int_t AliHBTAnalysis::Init()
270 //Initializeation method
271 //calls Init for all functions
273 //Depending on option and pair cut assigns proper analysis method
274 Bool_t nonid = IsNonIdentAnalysis();
275 switch(fProcessOption)
278 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecNonId;
279 else fProcEvent = &AliHBTAnalysis::ProcessRec;
284 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessSimNonId;
285 else fProcEvent = &AliHBTAnalysis::ProcessSim;
289 case kSimulatedAndReconstructed:
290 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecAndSimNonId;
291 else fProcEvent = &AliHBTAnalysis::ProcessRecAndSim;
295 if (fPartBuffer == 0x0) fPartBuffer = new AliEventBuffer (fBufferSize);
296 else fPartBuffer->Reset();
298 if (fTrackBuffer == 0x0) fTrackBuffer = new AliEventBuffer (fBufferSize);
299 else fTrackBuffer->Reset();
302 fNoCorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
305 for(ii = 0;ii<fNParticleFunctions;ii++)
306 fParticleFunctions[ii]->Init();
308 for(ii = 0;ii<fNTrackFunctions;ii++)
309 fTrackFunctions[ii]->Init();
311 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
312 fParticleAndTrackFunctions[ii]->Init();
314 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
315 fParticleMonitorFunctions[ii]->Init();
317 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
318 fTrackMonitorFunctions[ii]->Init();
320 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
321 fParticleAndTrackMonitorFunctions[ii]->Init();
325 /*************************************************************************************/
327 void AliHBTAnalysis::ResetFunctions()
329 //In case fOwner is true, deletes all functions
330 //in other case, just set number of analysis to 0
331 if (fIsOwner) DeleteFunctions();
334 fNParticleFunctions = 0;
335 fNTrackFunctions = 0;
336 fNParticleAndTrackFunctions = 0;
337 fNParticleMonitorFunctions = 0;
338 fNTrackMonitorFunctions = 0;
339 fNParticleAndTrackMonitorFunctions = 0;
342 /*************************************************************************************/
343 Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
345 //Does analysis for both tracks and particles
346 //mainly for resolution study and analysies with weighting algirithms
348 // cut on particles only -- why?
349 // - PID: when we make resolution analysis we want to take only tracks with correct PID
350 // We need cut on tracks because there are data characteristic
352 AliVAODParticle * part1, * part2;
353 AliVAODParticle * track1, * track2;
355 AliAOD * trackEvent = aodrec, *partEvent = aodsim;
356 AliAOD* trackEvent1 = new AliAOD();
357 AliAOD* partEvent1 = new AliAOD();
358 partEvent1->SetOwner(kTRUE);
359 trackEvent1->SetOwner(kTRUE);
361 AliAOD * trackEvent2,*partEvent2;
363 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
365 // Int_t nev = fReader->GetNumberOfTrackEvents();
366 static AliHBTPair tpair;
367 static AliHBTPair ppair;
369 AliHBTPair* trackpair = &tpair;
370 AliHBTPair* partpair = &ppair;
372 AliHBTPair * tmptrackpair;//temprary pointers to pairs
373 AliHBTPair * tmppartpair;
379 if ( !partEvent || !trackEvent )
381 Error("ProcessRecAndSim","<<%s>> Can not get event",GetName());
385 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
387 Error("ProcessRecAndSim",
388 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d). Skipping Event.",
389 partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
394 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
396 /***************************************/
397 /****** Looping same events ********/
398 /****** filling numerators ********/
399 /***************************************/
400 if ( (j%fDisplayMixingInfo) == 0)
401 Info("ProcessTracksAndParticles",
402 "Mixing particle %d with particles from the same event",j);
404 part1= partEvent->GetParticle(j);
405 track1= trackEvent->GetParticle(j);
407 Bool_t firstcut = (this->*fkPass1)(part1,track1);
408 if (fBufferSize != 0)
409 if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
411 //accepted by any cut
412 // we have to copy because reader keeps only one event
414 partEvent1->AddParticle(part1);
415 trackEvent1->AddParticle(track1);
418 if (firstcut) continue;
420 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
421 fParticleMonitorFunctions[ii]->Process(part1);
422 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
423 fTrackMonitorFunctions[ii]->Process(track1);
424 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
425 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
427 if (fNoCorrfctns) continue;
429 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
431 part2= partEvent->GetParticle(k);
432 if (part1->GetUID() == part2->GetUID()) continue;
433 partpair->SetParticles(part1,part2);
435 track2= trackEvent->GetParticle(k);
436 trackpair->SetParticles(track1,track2);
438 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
439 { //do not meets crietria of the pair cut, try with swapped pairs
440 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
441 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
443 { //swaped pair meets all the criteria
444 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
445 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
449 {//meets criteria of the pair cut
450 tmptrackpair = trackpair;
451 tmppartpair = partpair;
454 for(ii = 0;ii<fNParticleFunctions;ii++)
455 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
457 for(ii = 0;ii<fNTrackFunctions;ii++)
458 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
460 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
461 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
462 //end of 2nd loop over particles from the same event
463 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
465 /***************************************/
466 /***** Filling denominators *********/
467 /***************************************/
468 if (fBufferSize == 0) continue;
470 fPartBuffer->ResetIter();
471 fTrackBuffer->ResetIter();
473 while (( partEvent2 = fPartBuffer->Next() ))
475 trackEvent2 = fTrackBuffer->Next();
478 if ( (j%fDisplayMixingInfo) == 0)
479 Info("ProcessTracksAndParticles",
480 "Mixing particle %d from current event with particles from event %d",j,-m);
482 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
484 part2= partEvent2->GetParticle(l);
485 partpair->SetParticles(part1,part2);
487 track2= trackEvent2->GetParticle(l);
488 trackpair->SetParticles(track1,track2);
490 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
491 { //do not meets crietria of the
492 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
496 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
497 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
501 {//meets criteria of the pair cut
502 tmptrackpair = trackpair;
503 tmppartpair = partpair;
506 for(ii = 0;ii<fNParticleFunctions;ii++)
507 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
509 for(ii = 0;ii<fNTrackFunctions;ii++)
510 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
512 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
513 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
514 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
517 //end of loop over particles from first event
518 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
519 delete fPartBuffer->Push(partEvent1);
520 delete fTrackBuffer->Push(trackEvent1);
521 //end of loop over events
524 /*************************************************************************************/
526 Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
528 //Does analysis of simulated data
529 AliVAODParticle * part1, * part2;
531 AliAOD* partEvent = aodsim;
532 AliAOD* partEvent1 = new AliAOD();
533 partEvent1->SetOwner(kTRUE);
539 AliHBTPair* partpair = &ppair;
541 AliHBTPair * tmppartpair;
549 Error("ProcessRecAndSim","Can not get event");
554 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
556 /***************************************/
557 /****** Looping same events ********/
558 /****** filling numerators ********/
559 /***************************************/
560 if ( (j%fDisplayMixingInfo) == 0)
561 Info("ProcessTracksAndParticles",
562 "Mixing particle %d with particles from the same event",j);
564 part1= partEvent->GetParticle(j);
566 Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(part1);
568 if (fBufferSize != 0)
569 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(part1) == kFALSE ) )
571 //accepted by any cut
572 // we have to copy because reader keeps only one event
574 partEvent1->AddParticle(part1);
577 if (firstcut) continue;
579 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
580 fParticleMonitorFunctions[ii]->Process(part1);
582 if ( fNParticleFunctions == 0 ) continue;
584 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
586 part2= partEvent->GetParticle(k);
587 if (part1->GetUID() == part2->GetUID()) continue;
588 partpair->SetParticles(part1,part2);
590 if(fPairCut->Rejected(partpair)) //check pair cut
591 { //do not meets crietria of the
592 if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
593 else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
597 tmppartpair = partpair;
600 for(ii = 0;ii<fNParticleFunctions;ii++)
601 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
603 //end of 2nd loop over particles from the same event
604 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
606 /***************************************/
607 /***** Filling denominators *********/
608 /***************************************/
609 if (fBufferSize == 0) continue;
611 fPartBuffer->ResetIter();
613 while (( partEvent2 = fPartBuffer->Next() ))
616 if ( (j%fDisplayMixingInfo) == 0)
617 Info("ProcessParticles",
618 "Mixing particle %d from current event with particles from event %d",j,-m);
619 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
622 part2= partEvent2->GetParticle(l);
623 partpair->SetParticles(part1,part2);
625 if( fPairCut->Rejected(partpair) ) //check pair cut
626 { //do not meets crietria of the
627 if( fPairCut->Rejected((AliHBTPair*)partpair->GetSwappedPair()) )
631 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
635 {//meets criteria of the pair cut
636 tmppartpair = partpair;
639 for(ii = 0;ii<fNParticleFunctions;ii++)
640 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
642 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
645 delete fPartBuffer->Push(partEvent1);
646 //end of loop over events
649 /*************************************************************************************/
650 Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
652 //Does analysis of reconstructed data
653 AliVAODParticle * track1, * track2;
655 AliAOD* trackEvent = aodrec;
656 AliAOD* trackEvent1 = new AliAOD();
657 trackEvent1->SetOwner(kTRUE);
663 AliHBTPair* trackpair = &tpair;
665 AliHBTPair * tmptrackpair;
672 Error("ProcessRecAndSim","Can not get event");
677 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
679 /***************************************/
680 /****** Looping same events ********/
681 /****** filling numerators ********/
682 /***************************************/
683 if ( (j%fDisplayMixingInfo) == 0)
684 Info("ProcessTracksAndParticles",
685 "Mixing Particle %d with Particles from the same event",j);
687 track1= trackEvent->GetParticle(j);
689 Bool_t firstcut = fPairCut->GetFirstPartCut()->Rejected(track1);
691 if (fBufferSize != 0)
692 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Rejected(track1) == kFALSE ) )
694 //accepted by any cut
695 // we have to copy because reader keeps only one event
697 trackEvent1->AddParticle(track1);
700 if (firstcut) continue;
702 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
703 fParticleMonitorFunctions[ii]->Process(track1);
705 if ( fNParticleFunctions == 0 ) continue;
707 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
709 track2= trackEvent->GetParticle(k);
710 if (track1->GetUID() == track2->GetUID()) continue;
711 trackpair->SetParticles(track1,track2);
713 if(fPairCut->Rejected(trackpair)) //check pair cut
714 { //do not meets crietria of the
715 if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
716 else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
720 tmptrackpair = trackpair;
723 for(ii = 0;ii<fNTrackFunctions;ii++)
724 fParticleFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
726 //end of 2nd loop over Particles from the same event
727 }//for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
729 /***************************************/
730 /***** Filling denominators *********/
731 /***************************************/
732 if (fBufferSize == 0) continue;
734 fTrackBuffer->ResetIter();
736 while (( trackEvent2 = fTrackBuffer->Next() ))
739 if ( (j%fDisplayMixingInfo) == 0)
740 Info("ProcessParticles",
741 "Mixing Particle %d from current event with Particles from event %d",j,-m);
742 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all Particles
745 track2= trackEvent2->GetParticle(l);
746 trackpair->SetParticles(track1,track2);
748 if( fPairCut->Rejected(trackpair) ) //check pair cut
749 { //do not meets crietria of the
750 if( fPairCut->Rejected((AliHBTPair*)trackpair->GetSwappedPair()) )
754 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
758 {//meets criteria of the pair cut
759 tmptrackpair = trackpair;
762 for(ii = 0;ii<fNTrackFunctions;ii++)
763 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
765 }//for(Int_t l = 0; l<N2;l++) // ... on all Particles
768 delete fTrackBuffer->Push(trackEvent1);
769 //end of loop over events
772 /*************************************************************************************/
774 Int_t AliHBTAnalysis::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
776 //Analyzes both reconstructed and simulated data
779 Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
785 Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
789 if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
791 Error("ProcessTracksAndParticlesNonIdentAnal",
792 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
793 aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
798 AliVAODParticle * part1, * part2;
799 AliVAODParticle * track1, * track2;
801 static AliAOD aodrec1;
802 static AliAOD aodsim1;
804 AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
805 AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
806 AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
808 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
809 AliAOD* rawpartEvent = aodsim;//this we get from Reader
811 static AliHBTPair tpair;
812 static AliHBTPair ppair;
814 AliHBTPair* trackpair = &tpair;
815 AliHBTPair* partpair = &ppair;
820 trackEvent1 = new AliAOD();
821 partEvent1 = new AliAOD();
822 trackEvent1->SetOwner(kFALSE);
823 partEvent1->SetOwner(kFALSE);;
825 /********************************/
827 /********************************/
828 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
830 partEvent2 = new AliAOD();
831 trackEvent2 = new AliAOD();
832 partEvent2->SetOwner(kTRUE);
833 trackEvent2->SetOwner(kTRUE);
836 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
838 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
840 if ( (j%fDisplayMixingInfo) == 0)
841 Info("ProcessTracksAndParticlesNonIdentAnal",
842 "Mixing particle %d from current event with particles from current event",j);
844 part1= partEvent1->GetParticle(j);
845 track1= trackEvent1->GetParticle(j);
848 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
849 fParticleMonitorFunctions[ii]->Process(part1);
850 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
851 fTrackMonitorFunctions[ii]->Process(track1);
852 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
853 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
855 if (fNoCorrfctns) continue;
857 /***************************************/
858 /****** filling numerators ********/
859 /****** (particles from event2) ********/
860 /***************************************/
862 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
864 part2= partEvent2->GetParticle(k);
865 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
866 partpair->SetParticles(part1,part2);
868 track2= trackEvent2->GetParticle(k);
869 trackpair->SetParticles(track1,track2);
871 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
872 { //do not meets crietria of the pair cut
876 {//meets criteria of the pair cut
877 for(ii = 0;ii<fNParticleFunctions;ii++)
878 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
880 for(ii = 0;ii<fNTrackFunctions;ii++)
881 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
883 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
884 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
888 if ( fBufferSize == 0) continue;//do not mix diff histograms
889 /***************************************/
890 /***** Filling denominators *********/
891 /***************************************/
892 fPartBuffer->ResetIter();
893 fTrackBuffer->ResetIter();
897 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
899 trackEvent3 = fTrackBuffer->Next();
901 if ( (j%fDisplayMixingInfo) == 0)
902 Info("ProcessTracksAndParticlesNonIdentAnal",
903 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
905 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
907 part2= partEvent3->GetParticle(k);
908 partpair->SetParticles(part1,part2);
910 track2= trackEvent3->GetParticle(k);
911 trackpair->SetParticles(track1,track2);
913 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
914 { //do not meets crietria of the pair cut
918 {//meets criteria of the pair cut
920 for(ii = 0;ii<fNParticleFunctions;ii++)
921 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
923 for(ii = 0;ii<fNTrackFunctions;ii++)
924 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
926 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
927 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
929 }// for particles event2
931 }//for over particles in event1
933 delete fPartBuffer->Push(partEvent2);
934 delete fTrackBuffer->Push(trackEvent2);
938 /*************************************************************************************/
939 Int_t AliHBTAnalysis::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
941 //does analysis of simulated (MC) data in non-identical mode
942 //i.e. when particles selected by first part. cut are a disjunctive set than particles
943 //passed by the second part. cut
950 AliVAODParticle * part1, * part2;
952 static AliAOD aodsim1;
954 AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
955 AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
956 AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
958 AliAOD* rawpartEvent = aodsim;//this we get from Reader
960 static AliHBTPair ppair;
962 AliHBTPair* partpair = &ppair;
967 partEvent1 = new AliAOD();
968 partEvent1->SetOwner(kFALSE);;
971 /********************************/
973 /********************************/
974 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
976 partEvent2 = new AliAOD();
977 partEvent2->SetOwner(kTRUE);
980 FilterOut(partEvent1, partEvent2, rawpartEvent);
982 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
984 if ( (j%fDisplayMixingInfo) == 0)
985 Info("ProcessParticlesNonIdentAnal",
986 "Mixing particle %d from current event with particles from current event",j);
988 part1= partEvent1->GetParticle(j);
991 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
992 fParticleMonitorFunctions[ii]->Process(part1);
994 if (fNParticleFunctions == 0) continue;
996 /***************************************/
997 /****** filling numerators ********/
998 /****** (particles from event2) ********/
999 /***************************************/
1001 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1003 part2= partEvent2->GetParticle(k);
1004 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
1005 partpair->SetParticles(part1,part2);
1008 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1009 { //do not meets crietria of the pair cut
1013 {//meets criteria of the pair cut
1014 for(ii = 0;ii<fNParticleFunctions;ii++)
1015 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1019 if ( fBufferSize == 0) continue;//do not mix diff histograms
1020 /***************************************/
1021 /***** Filling denominators *********/
1022 /***************************************/
1023 fPartBuffer->ResetIter();
1027 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
1030 if ( (j%fDisplayMixingInfo) == 0)
1031 Info("ProcessParticlesNonIdentAnal",
1032 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1034 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1036 part2= partEvent3->GetParticle(k);
1037 partpair->SetParticles(part1,part2);
1040 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1041 { //do not meets crietria of the pair cut
1045 {//meets criteria of the pair cut
1046 for(ii = 0;ii<fNParticleFunctions;ii++)
1048 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1051 }// for particles event2
1053 }//for over particles in event1
1055 delete fPartBuffer->Push(partEvent2);
1059 /*************************************************************************************/
1060 Int_t AliHBTAnalysis::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
1062 //Analyzes both reconstructed and simulated data
1068 AliVAODParticle * track1, * track2;
1070 static AliAOD aodrec1;
1072 AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
1073 AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
1074 AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
1076 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
1078 static AliHBTPair tpair;
1080 AliHBTPair* trackpair = &tpair;
1085 trackEvent1 = new AliAOD();
1086 trackEvent1->SetOwner(kFALSE);
1088 /********************************/
1090 /********************************/
1091 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1093 trackEvent2 = new AliAOD();
1094 trackEvent2->SetOwner(kTRUE);
1097 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1099 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1101 if ( (j%fDisplayMixingInfo) == 0)
1102 Info("ProcessTracksNonIdentAnal",
1103 "Mixing particle %d from current event with particles from current event",j);
1105 track1= trackEvent1->GetParticle(j);
1108 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1109 fTrackMonitorFunctions[ii]->Process(track1);
1111 if (fNTrackFunctions == 0x0) continue;
1113 /***************************************/
1114 /****** filling numerators ********/
1115 /****** (particles from event2) ********/
1116 /***************************************/
1118 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1120 track2= trackEvent2->GetParticle(k);
1121 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1122 trackpair->SetParticles(track1,track2);
1125 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1126 { //do not meets crietria of the pair cut
1130 {//meets criteria of the pair cut
1132 for(ii = 0;ii<fNTrackFunctions;ii++)
1133 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1137 if ( fBufferSize == 0) continue;//do not mix diff histograms
1138 /***************************************/
1139 /***** Filling denominators *********/
1140 /***************************************/
1141 fTrackBuffer->ResetIter();
1145 while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
1147 if ( (j%fDisplayMixingInfo) == 0)
1148 Info("ProcessTracksNonIdentAnal",
1149 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1151 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1153 track2= trackEvent3->GetParticle(k);
1154 trackpair->SetParticles(track1,track2);
1156 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1157 { //do not meets crietria of the pair cut
1161 {//meets criteria of the pair cut
1162 for(ii = 0;ii<fNTrackFunctions;ii++)
1163 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1165 }// for particles event2
1167 }//for over particles in event1
1169 delete fTrackBuffer->Push(trackEvent2);
1173 /*************************************************************************************/
1175 void AliHBTAnalysis::Process(Option_t* option)
1177 //default option = "TracksAndParticles"
1178 //Main method of the HBT Analysis Package
1179 //It triggers reading with the global cut (default is an empty cut)
1180 //Than it checks options and data which are read
1181 //if everything is OK, then it calls one of the looping methods
1182 //depending on tfReaderhe option
1183 //These methods differs on what thay are looping on
1186 //--------------------------------------------------------------------
1187 //ProcessTracksAndParticles - "TracksAndParticles"
1189 // it loops over both, tracks(reconstructed) and particles(simulated)
1190 // all function gethered in all 3 lists are called for each (double)pair
1192 //ProcessTracks - "Tracks"
1193 // it loops only on tracks(reconstructed),
1194 // functions ONLY from fTrackFunctions list are called
1196 //ProcessParticles - "Particles"
1197 // it loops only on particles(simulated),
1198 // functions ONLY from fParticleAndTrackFunctions list are called
1203 Error("Process","The reader is not set");
1207 const char *oT = strstr(option,"Tracks");
1208 const char *oP = strstr(option,"Particles");
1210 Bool_t nonid = IsNonIdentAnalysis();
1216 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
1217 else ProcessTracksAndParticles();
1223 if (nonid) ProcessTracksNonIdentAnal();
1224 else ProcessTracks();
1230 if (nonid) ProcessParticlesNonIdentAnal();
1231 else ProcessParticles();
1236 /*************************************************************************************/
1238 void AliHBTAnalysis::ProcessTracksAndParticles()
1240 //Makes analysis for both tracks and particles
1241 //mainly for resolution study and analysies with weighting algirithms
1242 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1243 //the loops are splited
1245 // cut on particles only -- why?
1246 // - PID: when we make resolution analysis we want to take only tracks with correct PID
1247 // We need cut on tracks because there are data characteristic to
1249 AliAOD * trackEvent, *partEvent;
1252 while (fReader->Next() == kFALSE)
1254 partEvent = fReader->GetEventSim();
1255 trackEvent = fReader->GetEventRec();
1256 ProcessRecAndSim(trackEvent,partEvent);
1258 }//while (fReader->Next() == kFALSE)
1261 /*************************************************************************************/
1263 void AliHBTAnalysis::ProcessTracks()
1265 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1266 //the loops are splited
1267 AliAOD * trackEvent;
1269 while (fReader->Next() == kFALSE)
1271 trackEvent = fReader->GetEventRec();
1272 ProcessRec(trackEvent,0x0);
1273 }//while (fReader->Next() == kFALSE)
1276 /*************************************************************************************/
1278 void AliHBTAnalysis::ProcessParticles()
1280 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1281 //the loops are splited
1284 while (fReader->Next() == kFALSE)
1286 partEvent = fReader->GetEventSim();
1287 ProcessSim(0x0,partEvent);
1288 }//while (fReader->Next() == kFALSE)
1290 /*************************************************************************************/
1292 void AliHBTAnalysis::WriteFunctions()
1294 //Calls Write for all defined functions in analysis
1295 //== writes all results
1296 TFile* oututfile = 0x0;
1297 if (fOutputFileName)
1299 oututfile = TFile::Open(*fOutputFileName,"update");
1302 for(ii = 0;ii<fNParticleFunctions;ii++)
1304 if (AliVAODParticle::GetDebug()>5)
1306 Info("WriteFunctions","Writing ParticleFunction %#x",fParticleFunctions[ii]);
1307 Info("WriteFunctions","Writing ParticleFunction %s",fParticleFunctions[ii]->Name());
1309 fParticleFunctions[ii]->Write();
1312 for(ii = 0;ii<fNTrackFunctions;ii++)
1314 if (AliVAODParticle::GetDebug()>5)
1316 Info("WriteFunctions","Writing TrackFunction %#x",fTrackFunctions[ii]);
1317 Info("WriteFunctions","Writing TrackFunction %s",fTrackFunctions[ii]->Name());
1319 fTrackFunctions[ii]->Write();
1322 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1324 if (AliVAODParticle::GetDebug()>5)
1326 Info("WriteFunctions","Writing ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
1327 Info("WriteFunctions","Writing ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
1329 fParticleAndTrackFunctions[ii]->Write();
1332 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
1334 if (AliVAODParticle::GetDebug()>5)
1336 Info("WriteFunctions","Writing ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
1337 Info("WriteFunctions","Writing ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
1339 fParticleMonitorFunctions[ii]->Write();
1342 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
1344 if (AliVAODParticle::GetDebug()>5)
1346 Info("WriteFunctions","Writing TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
1347 Info("WriteFunctions","Writing TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
1349 fTrackMonitorFunctions[ii]->Write();
1352 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
1354 if (AliVAODParticle::GetDebug()>5)
1356 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
1357 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
1359 fParticleAndTrackMonitorFunctions[ii]->Write();
1363 /*************************************************************************************/
1365 void AliHBTAnalysis::SetOutputFileName(const char* fname)
1367 //Sets fiele name where to dump results,
1368 //if not specified reults are written to gDirectory
1371 delete fOutputFileName;
1372 fOutputFileName = 0x0;
1375 if ( strcmp(fname,"") == 0 )
1377 delete fOutputFileName;
1378 fOutputFileName = 0x0;
1381 if (fOutputFileName == 0x0) fOutputFileName = new TString(fname);
1382 else *fOutputFileName = fname;
1384 /*************************************************************************************/
1386 void AliHBTAnalysis::SetGlobalPairCut(AliAODPairCut* cut)
1388 //Sets the global cut
1391 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
1394 fPairCut = (AliAODPairCut*)cut->Clone();
1397 /*************************************************************************************/
1399 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1401 //Adds track function
1402 if (f == 0x0) return;
1403 if (fNTrackFunctions == fgkFctnArraySize)
1405 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
1407 fTrackFunctions[fNTrackFunctions] = f;
1410 /*************************************************************************************/
1412 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1414 //adds particle function
1415 if (f == 0x0) return;
1417 if (fNParticleFunctions == fgkFctnArraySize)
1419 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
1421 fParticleFunctions[fNParticleFunctions] = f;
1422 fNParticleFunctions++;
1424 /*************************************************************************************/
1426 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1428 //add resolution function
1429 if (f == 0x0) return;
1430 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
1432 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
1434 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
1435 fNParticleAndTrackFunctions++;
1437 /*************************************************************************************/
1439 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
1441 //add particle monitoring function
1442 if (f == 0x0) return;
1444 if (fNParticleMonitorFunctions == fgkFctnArraySize)
1446 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
1448 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
1449 fNParticleMonitorFunctions++;
1451 /*************************************************************************************/
1453 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
1455 //add track monitoring function
1456 if (f == 0x0) return;
1458 if (fNTrackMonitorFunctions == fgkFctnArraySize)
1460 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
1462 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
1463 fNTrackMonitorFunctions++;
1465 /*************************************************************************************/
1467 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
1469 //add resolution monitoring function
1470 if (f == 0x0) return;
1471 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
1473 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
1475 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
1476 fNParticleAndTrackMonitorFunctions++;
1480 /*************************************************************************************/
1481 /*************************************************************************************/
1483 Bool_t AliHBTAnalysis::RunCoherencyCheck()
1485 //Checks if both HBTRuns are similar
1486 //return true if error found
1487 //if they seem to be OK return false
1491 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
1493 //When we use non-buffering reader this is a big waste of time -> We need to read all data to check it
1494 //and reader is implemented safe in this case anyway
1495 // Info("RunCoherencyCheck","Number of events ...");
1496 // if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
1498 // Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1501 // { //if not the same - ERROR
1502 // Error("RunCoherencyCheck",
1503 // "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
1504 // fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
1508 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1512 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
1514 partEvent= fReader->GetEventSim(i); //gets the "ith" event
1515 trackEvent = fReader->GetEventRec(i);
1517 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
1518 if ( (partEvent == 0x0) || (partEvent == 0x0) )
1520 Error("RunCoherencyCheck",
1521 "One event is NULL and the other one not. Event Number %d",i);
1525 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
1527 Error("RunCoherencyCheck",
1528 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
1529 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
1533 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
1535 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
1537 Error("RunCoherencyCheck",
1538 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
1539 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
1545 Info("RunCoherencyCheck"," Done");
1546 Info("RunCoherencyCheck"," Everything looks OK");
1551 /*************************************************************************************/
1553 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
1555 //Performs analysis for both, tracks and particles
1556 AliAOD* rawtrackEvent, * rawpartEvent;
1559 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1560 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1561 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1563 for (Int_t i = 0;;i++)//infinite loop
1565 if (fReader->Next()) break; //end when no more events available
1567 rawpartEvent = fReader->GetEventSim();
1568 rawtrackEvent = fReader->GetEventRec();
1570 ProcessRecAndSimNonId(rawtrackEvent,rawpartEvent);
1571 }//end of loop over events (1)
1573 /*************************************************************************************/
1575 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1577 //Process Tracks only with non identical mode
1578 AliAOD * rawtrackEvent;
1581 Info("ProcessTracksNonIdentAnal","**************************************");
1582 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1583 Info("ProcessTracksNonIdentAnal","**************************************");
1585 for (Int_t i = 0;;i++)//infinite loop
1587 if (fReader->Next()) break; //end when no more events available
1588 rawtrackEvent = fReader->GetEventRec();
1589 ProcessRecNonId(rawtrackEvent,0x0);
1590 }//end of loop over events (1)
1592 /*************************************************************************************/
1594 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1596 //process paricles only with non identical mode
1597 AliAOD * rawpartEvent = 0x0;
1600 Info("ProcessParticlesNonIdentAnal","**************************************");
1601 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1602 Info("ProcessParticlesNonIdentAnal","**************************************");
1604 for (Int_t i = 0;;i++)//infinite loop
1606 if (fReader->Next()) break; //end when no more events available
1608 rawpartEvent = fReader->GetEventSim();
1609 ProcessSimNonId(0x0,rawpartEvent);
1610 }//end of loop over events (1)
1613 /*************************************************************************************/
1614 void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpart,
1615 AliAOD* outtrack1, AliAOD* outtrack2, AliAOD* intrack) const
1617 //Puts particles accepted as a first particle by global cut in out1
1618 //and as a second particle in out2
1620 AliVAODParticle* part, *track;
1629 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1632 part = inpart->GetParticle(i);
1633 track = intrack->GetParticle(i);
1635 if ( ((this->*fkPass1)(part,track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1636 if ( ((this->*fkPass2)(part,track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1638 if (gDebug)//to be removed in real analysis
1639 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1641 //Particle accpted by both cuts
1642 Error("FilterOut","Particle accepted by both cuts");
1648 outpart1->AddParticle(part);
1649 outtrack1->AddParticle(track);
1655 outpart2->AddParticle(part);
1656 outtrack2->AddParticle(track);
1661 /*************************************************************************************/
1663 void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
1665 //Puts particles accepted as a first particle by global cut in out1
1666 //and as a second particle in out2
1667 AliVAODParticle* part;
1672 AliAODParticleCut *cut1 = fPairCut->GetFirstPartCut();
1673 AliAODParticleCut *cut2 = fPairCut->GetSecondPartCut();
1677 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1680 part = in->GetParticle(i);
1682 if ( cut1->Rejected(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1683 if ( cut2->Rejected(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1685 if (gDebug)//to be removed in real analysis
1686 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1688 //Particle accpted by both cuts
1689 Error("FilterOut","Particle accepted by both cuts");
1695 out1->AddParticle(part);
1701 out2->AddParticle(part);
1706 /*************************************************************************************/
1708 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1710 //checks if it is possible to use special analysis for non identical particles
1711 //it means - in global pair cut first particle id is different than second one
1712 //and both are different from 0
1713 //in the future is possible to perform more sophisticated check
1714 //if cuts have excluding requirements
1716 if (fPairCut->IsEmpty())
1719 if (fPairCut->GetFirstPartCut()->IsEmpty())
1722 if (fPairCut->GetSecondPartCut()->IsEmpty())
1725 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1726 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1728 if ( (id1==0) || (id2==0) || (id1==id2) )
1733 /*************************************************************************************/
1735 void AliHBTAnalysis::SetApparentVertex(Double_t x, Double_t y, Double_t z)
1737 //Sets apparent vertex
1738 // All events have to be moved to the same vertex position in order to
1739 // to be able to comare any space positions (f.g. anti-merging)
1740 // This method defines this position
1746 /*************************************************************************************/
1748 void AliHBTAnalysis::PressAnyKey()
1750 //small utility function that helps to make comfortable macros
1753 fcntl(0, F_SETFL, O_NONBLOCK);
1754 ::Info("","Press Any Key to continue ...");
1757 nread = read(0, &c, 1);
1758 gSystem->ProcessEvents();
1762 /*************************************************************************************/