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 option not specified");
153 if ( Pass(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;
275 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessSimNonId;
276 else fProcEvent = &AliHBTAnalysis::ProcessSim;
279 case kSimulatedAndReconstructed:
280 if (nonid) fProcEvent = &AliHBTAnalysis::ProcessRecAndSimNonId;
281 else fProcEvent = &AliHBTAnalysis::ProcessRecAndSim;
285 if (fPartBuffer == 0x0) fPartBuffer = new AliEventBuffer (fBufferSize);
286 else fPartBuffer->Reset();
288 if (fTrackBuffer == 0x0) fTrackBuffer = new AliEventBuffer (fBufferSize);
289 else fTrackBuffer->Reset();
292 fNoCorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
295 for(ii = 0;ii<fNParticleFunctions;ii++)
296 fParticleFunctions[ii]->Init();
298 for(ii = 0;ii<fNTrackFunctions;ii++)
299 fTrackFunctions[ii]->Init();
301 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
302 fParticleAndTrackFunctions[ii]->Init();
304 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
305 fParticleMonitorFunctions[ii]->Init();
307 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
308 fTrackMonitorFunctions[ii]->Init();
310 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
311 fParticleAndTrackMonitorFunctions[ii]->Init();
315 /*************************************************************************************/
317 void AliHBTAnalysis::ResetFunctions()
319 //In case fOwner is true, deletes all functions
320 //in other case, just set number of analysis to 0
321 if (fIsOwner) DeleteFunctions();
324 fNParticleFunctions = 0;
325 fNTrackFunctions = 0;
326 fNParticleAndTrackFunctions = 0;
327 fNParticleMonitorFunctions = 0;
328 fNTrackMonitorFunctions = 0;
329 fNParticleAndTrackMonitorFunctions = 0;
332 /*************************************************************************************/
333 Int_t AliHBTAnalysis::ProcessRecAndSim(AliAOD* aodrec, AliAOD* aodsim)
335 //Does analysis for both tracks and particles
336 //mainly for resolution study and analysies with weighting algirithms
338 // cut on particles only -- why?
339 // - PID: when we make resolution analysis we want to take only tracks with correct PID
340 // We need cut on tracks because there are data characteristic
342 AliVAODParticle * part1, * part2;
343 AliVAODParticle * track1, * track2;
345 AliAOD * trackEvent = aodrec, *partEvent = aodsim;
346 AliAOD* trackEvent1 = new AliAOD();
347 AliAOD* partEvent1 = new AliAOD();
348 partEvent1->SetOwner(kTRUE);
349 trackEvent1->SetOwner(kTRUE);
351 AliAOD * trackEvent2,*partEvent2;
353 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
355 // Int_t nev = fReader->GetNumberOfTrackEvents();
356 static AliHBTPair tpair;
357 static AliHBTPair ppair;
359 AliHBTPair* trackpair = &tpair;
360 AliHBTPair* partpair = &ppair;
362 AliHBTPair * tmptrackpair;//temprary pointers to pairs
363 AliHBTPair * tmppartpair;
369 if ( !partEvent || !trackEvent )
371 Error("ProcessRecAndSim","Can not get event");
375 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
377 Error("ProcessRecAndSim",
378 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d). Skipping Event.",
379 partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
384 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
386 /***************************************/
387 /****** Looping same events ********/
388 /****** filling numerators ********/
389 /***************************************/
390 if ( (j%fDisplayMixingInfo) == 0)
391 Info("ProcessTracksAndParticles",
392 "Mixing particle %d with particles from the same event",j);
394 part1= partEvent->GetParticle(j);
395 track1= trackEvent->GetParticle(j);
397 Bool_t firstcut = (this->*fkPass1)(part1,track1);
398 if (fBufferSize != 0)
399 if ( (firstcut == kFALSE) || ( (this->*fkPass2)(part1,track1) == kFALSE ) )
401 //accepted by any cut
402 // we have to copy because reader keeps only one event
404 partEvent1->AddParticle(new AliAODParticle(*part1));
405 trackEvent1->AddParticle(new AliAODParticle(*track1));
408 if (firstcut) continue;
410 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
411 fParticleMonitorFunctions[ii]->Process(part1);
412 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
413 fTrackMonitorFunctions[ii]->Process(track1);
414 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
415 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
417 if (fNoCorrfctns) continue;
419 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
421 part2= partEvent->GetParticle(k);
422 if (part1->GetUID() == part2->GetUID()) continue;
423 partpair->SetParticles(part1,part2);
425 track2= trackEvent->GetParticle(k);
426 trackpair->SetParticles(track1,track2);
428 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
429 { //do not meets crietria of the pair cut, try with swapped pairs
430 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
431 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
433 { //swaped pair meets all the criteria
434 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
435 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
439 {//meets criteria of the pair cut
440 tmptrackpair = trackpair;
441 tmppartpair = partpair;
444 for(ii = 0;ii<fNParticleFunctions;ii++)
445 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
447 for(ii = 0;ii<fNTrackFunctions;ii++)
448 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
450 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
451 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
452 //end of 2nd loop over particles from the same event
453 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
455 /***************************************/
456 /***** Filling denominators *********/
457 /***************************************/
458 if (fBufferSize == 0) continue;
460 fPartBuffer->ResetIter();
461 fTrackBuffer->ResetIter();
463 while (( partEvent2 = fPartBuffer->Next() ))
465 trackEvent2 = fTrackBuffer->Next();
468 if ( (j%fDisplayMixingInfo) == 0)
469 Info("ProcessTracksAndParticles",
470 "Mixing particle %d from current event with particles from event %d",j,-m);
472 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
474 part2= partEvent2->GetParticle(l);
475 partpair->SetParticles(part1,part2);
477 track2= trackEvent2->GetParticle(l);
478 trackpair->SetParticles(track1,track2);
480 if( (this->*fkPass)(partpair,trackpair) ) //check pair cut
481 { //do not meets crietria of the
482 if( (this->*fkPass)((AliHBTPair*)partpair->GetSwappedPair(),(AliHBTPair*)trackpair->GetSwappedPair()) )
486 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
487 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
491 {//meets criteria of the pair cut
492 tmptrackpair = trackpair;
493 tmppartpair = partpair;
496 for(ii = 0;ii<fNParticleFunctions;ii++)
497 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
499 for(ii = 0;ii<fNTrackFunctions;ii++)
500 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
502 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
503 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
504 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
507 //end of loop over particles from first event
508 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
509 delete fPartBuffer->Push(partEvent1);
510 delete fTrackBuffer->Push(trackEvent1);
511 //end of loop over events
514 /*************************************************************************************/
516 Int_t AliHBTAnalysis::ProcessSim(AliAOD* /*aodrec*/, AliAOD* aodsim)
518 //Does analysis of simulated data
519 AliVAODParticle * part1, * part2;
521 AliAOD* partEvent = aodsim;
522 AliAOD* partEvent1 = new AliAOD();
523 partEvent1->SetOwner(kTRUE);
529 AliHBTPair* partpair = &ppair;
531 AliHBTPair * tmppartpair;
539 Error("ProcessRecAndSim","Can not get event");
544 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
546 /***************************************/
547 /****** Looping same events ********/
548 /****** filling numerators ********/
549 /***************************************/
550 if ( (j%fDisplayMixingInfo) == 0)
551 Info("ProcessTracksAndParticles",
552 "Mixing particle %d with particles from the same event",j);
554 part1= partEvent->GetParticle(j);
556 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
558 if (fBufferSize != 0)
559 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE ) )
561 //accepted by any cut
562 // we have to copy because reader keeps only one event
564 partEvent1->AddParticle(new AliAODParticle(*part1));
567 if (firstcut) continue;
569 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
570 fParticleMonitorFunctions[ii]->Process(part1);
572 if ( fNParticleFunctions == 0 ) continue;
574 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
576 part2= partEvent->GetParticle(k);
577 if (part1->GetUID() == part2->GetUID()) continue;
578 partpair->SetParticles(part1,part2);
580 if(fPairCut->Pass(partpair)) //check pair cut
581 { //do not meets crietria of the
582 if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) ) continue;
583 else tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
587 tmppartpair = partpair;
590 for(ii = 0;ii<fNParticleFunctions;ii++)
591 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
593 //end of 2nd loop over particles from the same event
594 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
596 /***************************************/
597 /***** Filling denominators *********/
598 /***************************************/
599 if (fBufferSize == 0) continue;
601 fPartBuffer->ResetIter();
603 while (( partEvent2 = fPartBuffer->Next() ))
606 if ( (j%fDisplayMixingInfo) == 0)
607 Info("ProcessParticles",
608 "Mixing particle %d from current event with particles from event %d",j,-m);
609 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
612 part2= partEvent2->GetParticle(l);
613 partpair->SetParticles(part1,part2);
615 if( fPairCut->Pass(partpair) ) //check pair cut
616 { //do not meets crietria of the
617 if( fPairCut->Pass((AliHBTPair*)partpair->GetSwappedPair()) )
621 tmppartpair = (AliHBTPair*)partpair->GetSwappedPair();
625 {//meets criteria of the pair cut
626 tmppartpair = partpair;
629 for(ii = 0;ii<fNParticleFunctions;ii++)
630 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
632 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
635 delete fPartBuffer->Push(partEvent1);
636 //end of loop over events
639 /*************************************************************************************/
640 Int_t AliHBTAnalysis::ProcessRec(AliAOD* aodrec, AliAOD* /*aodsim*/)
642 //Does analysis of reconstructed data
643 AliVAODParticle * track1, * track2;
645 AliAOD* trackEvent = aodrec;
646 AliAOD* trackEvent1 = new AliAOD();
647 trackEvent1->SetOwner(kTRUE);
653 AliHBTPair* trackpair = &tpair;
655 AliHBTPair * tmptrackpair;
662 Error("ProcessRecAndSim","Can not get event");
667 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
669 /***************************************/
670 /****** Looping same events ********/
671 /****** filling numerators ********/
672 /***************************************/
673 if ( (j%fDisplayMixingInfo) == 0)
674 Info("ProcessTracksAndParticles",
675 "Mixing Particle %d with Particles from the same event",j);
677 track1= trackEvent->GetParticle(j);
679 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(track1);
681 if (fBufferSize != 0)
682 if ( (firstcut == kFALSE) || ( fPairCut->GetSecondPartCut()->Pass(track1) == kFALSE ) )
684 //accepted by any cut
685 // we have to copy because reader keeps only one event
687 trackEvent1->AddParticle(new AliAODParticle(*track1));
690 if (firstcut) continue;
692 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
693 fParticleMonitorFunctions[ii]->Process(track1);
695 if ( fNParticleFunctions == 0 ) continue;
697 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
699 track2= trackEvent->GetParticle(k);
700 if (track1->GetUID() == track2->GetUID()) continue;
701 trackpair->SetParticles(track1,track2);
703 if(fPairCut->Pass(trackpair)) //check pair cut
704 { //do not meets crietria of the
705 if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) ) continue;
706 else tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
710 tmptrackpair = trackpair;
713 for(ii = 0;ii<fNTrackFunctions;ii++)
714 fParticleFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
716 //end of 2nd loop over Particles from the same event
717 }//for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
719 /***************************************/
720 /***** Filling denominators *********/
721 /***************************************/
722 if (fBufferSize == 0) continue;
724 fTrackBuffer->ResetIter();
726 while (( trackEvent2 = fTrackBuffer->Next() ))
729 if ( (j%fDisplayMixingInfo) == 0)
730 Info("ProcessParticles",
731 "Mixing Particle %d from current event with Particles from event %d",j,-m);
732 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all Particles
735 track2= trackEvent2->GetParticle(l);
736 trackpair->SetParticles(track1,track2);
738 if( fPairCut->Pass(trackpair) ) //check pair cut
739 { //do not meets crietria of the
740 if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) )
744 tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
748 {//meets criteria of the pair cut
749 tmptrackpair = trackpair;
752 for(ii = 0;ii<fNTrackFunctions;ii++)
753 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
755 }//for(Int_t l = 0; l<N2;l++) // ... on all Particles
758 delete fTrackBuffer->Push(trackEvent1);
759 //end of loop over events
762 /*************************************************************************************/
764 Int_t AliHBTAnalysis::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
766 //Analyzes both reconstructed and simulated data
769 Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
775 Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
779 if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
781 Error("ProcessTracksAndParticlesNonIdentAnal",
782 "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
783 aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
788 AliVAODParticle * part1, * part2;
789 AliVAODParticle * track1, * track2;
791 static AliAOD aodrec1;
792 static AliAOD aodsim1;
794 AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
795 AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
796 AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
798 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
799 AliAOD* rawpartEvent = aodsim;//this we get from Reader
801 static AliHBTPair tpair;
802 static AliHBTPair ppair;
804 AliHBTPair* trackpair = &tpair;
805 AliHBTPair* partpair = &ppair;
810 trackEvent1 = new AliAOD();
811 partEvent1 = new AliAOD();
812 trackEvent1->SetOwner(kFALSE);
813 partEvent1->SetOwner(kFALSE);;
815 /********************************/
817 /********************************/
818 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
820 partEvent2 = new AliAOD();
821 trackEvent2 = new AliAOD();
822 partEvent2->SetOwner(kTRUE);
823 trackEvent2->SetOwner(kTRUE);
826 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
828 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
830 if ( (j%fDisplayMixingInfo) == 0)
831 Info("ProcessTracksAndParticlesNonIdentAnal",
832 "Mixing particle %d from current event with particles from current event",j);
834 part1= partEvent1->GetParticle(j);
835 track1= trackEvent1->GetParticle(j);
838 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
839 fParticleMonitorFunctions[ii]->Process(part1);
840 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
841 fTrackMonitorFunctions[ii]->Process(track1);
842 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
843 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
845 if (fNoCorrfctns) continue;
847 /***************************************/
848 /****** filling numerators ********/
849 /****** (particles from event2) ********/
850 /***************************************/
852 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
854 part2= partEvent2->GetParticle(k);
855 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
856 partpair->SetParticles(part1,part2);
858 track2= trackEvent2->GetParticle(k);
859 trackpair->SetParticles(track1,track2);
861 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
862 { //do not meets crietria of the pair cut
866 {//meets criteria of the pair cut
867 for(ii = 0;ii<fNParticleFunctions;ii++)
868 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
870 for(ii = 0;ii<fNTrackFunctions;ii++)
871 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
873 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
874 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
878 if ( fBufferSize == 0) continue;//do not mix diff histograms
879 /***************************************/
880 /***** Filling denominators *********/
881 /***************************************/
882 fPartBuffer->ResetIter();
883 fTrackBuffer->ResetIter();
887 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
889 trackEvent3 = fTrackBuffer->Next();
891 if ( (j%fDisplayMixingInfo) == 0)
892 Info("ProcessTracksAndParticlesNonIdentAnal",
893 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
895 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
897 part2= partEvent3->GetParticle(k);
898 partpair->SetParticles(part1,part2);
900 track2= trackEvent3->GetParticle(k);
901 trackpair->SetParticles(track1,track2);
903 if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
904 { //do not meets crietria of the pair cut
908 {//meets criteria of the pair cut
910 for(ii = 0;ii<fNParticleFunctions;ii++)
911 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
913 for(ii = 0;ii<fNTrackFunctions;ii++)
914 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
916 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
917 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
919 }// for particles event2
921 }//for over particles in event1
923 delete fPartBuffer->Push(partEvent2);
924 delete fTrackBuffer->Push(trackEvent2);
928 /*************************************************************************************/
929 Int_t AliHBTAnalysis::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
931 //does analysis of simulated (MC) data in non-identical mode
932 //i.e. when particles selected by first part. cut are a disjunctive set than particles
933 //passed by the second part. cut
940 AliVAODParticle * part1, * part2;
942 static AliAOD aodsim1;
944 AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
945 AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
946 AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
948 AliAOD* rawpartEvent = aodsim;//this we get from Reader
950 static AliHBTPair ppair;
952 AliHBTPair* partpair = &ppair;
957 partEvent1 = new AliAOD();
958 partEvent1->SetOwner(kFALSE);;
961 /********************************/
963 /********************************/
964 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
966 partEvent2 = new AliAOD();
967 partEvent2->SetOwner(kTRUE);
970 FilterOut(partEvent1, partEvent2, rawpartEvent);
972 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
974 if ( (j%fDisplayMixingInfo) == 0)
975 Info("ProcessParticlesNonIdentAnal",
976 "Mixing particle %d from current event with particles from current event",j);
978 part1= partEvent1->GetParticle(j);
981 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
982 fParticleMonitorFunctions[ii]->Process(part1);
984 if (fNParticleFunctions == 0) continue;
986 /***************************************/
987 /****** filling numerators ********/
988 /****** (particles from event2) ********/
989 /***************************************/
991 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
993 part2= partEvent2->GetParticle(k);
994 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
995 partpair->SetParticles(part1,part2);
998 if(fPairCut->PassPairProp(partpair) ) //check pair cut
999 { //do not meets crietria of the pair cut
1003 {//meets criteria of the pair cut
1004 for(ii = 0;ii<fNParticleFunctions;ii++)
1005 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1009 if ( fBufferSize == 0) continue;//do not mix diff histograms
1010 /***************************************/
1011 /***** Filling denominators *********/
1012 /***************************************/
1013 fPartBuffer->ResetIter();
1017 while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
1020 if ( (j%fDisplayMixingInfo) == 0)
1021 Info("ProcessParticlesNonIdentAnal",
1022 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1024 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1026 part2= partEvent3->GetParticle(k);
1027 partpair->SetParticles(part1,part2);
1030 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1031 { //do not meets crietria of the pair cut
1035 {//meets criteria of the pair cut
1036 for(ii = 0;ii<fNParticleFunctions;ii++)
1038 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1041 }// for particles event2
1043 }//for over particles in event1
1045 delete fPartBuffer->Push(partEvent2);
1049 /*************************************************************************************/
1050 Int_t AliHBTAnalysis::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
1052 //Analyzes both reconstructed and simulated data
1058 AliVAODParticle * track1, * track2;
1060 static AliAOD aodrec1;
1062 AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
1063 AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
1064 AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
1066 AliAOD* rawtrackEvent = aodrec;//this we get from Reader
1068 static AliHBTPair tpair;
1070 AliHBTPair* trackpair = &tpair;
1075 trackEvent1 = new AliAOD();
1076 trackEvent1->SetOwner(kFALSE);
1078 /********************************/
1080 /********************************/
1081 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1083 trackEvent2 = new AliAOD();
1084 trackEvent2->SetOwner(kTRUE);
1087 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1089 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1091 if ( (j%fDisplayMixingInfo) == 0)
1092 Info("ProcessTracksNonIdentAnal",
1093 "Mixing particle %d from current event with particles from current event",j);
1095 track1= trackEvent1->GetParticle(j);
1098 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1099 fTrackMonitorFunctions[ii]->Process(track1);
1101 if (fNTrackFunctions == 0x0) continue;
1103 /***************************************/
1104 /****** filling numerators ********/
1105 /****** (particles from event2) ********/
1106 /***************************************/
1108 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1110 track2= trackEvent2->GetParticle(k);
1111 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1112 trackpair->SetParticles(track1,track2);
1115 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1116 { //do not meets crietria of the pair cut
1120 {//meets criteria of the pair cut
1122 for(ii = 0;ii<fNTrackFunctions;ii++)
1123 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1127 if ( fBufferSize == 0) continue;//do not mix diff histograms
1128 /***************************************/
1129 /***** Filling denominators *********/
1130 /***************************************/
1131 fTrackBuffer->ResetIter();
1135 while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
1137 if ( (j%fDisplayMixingInfo) == 0)
1138 Info("ProcessTracksNonIdentAnal",
1139 "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
1141 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1143 track2= trackEvent3->GetParticle(k);
1144 trackpair->SetParticles(track1,track2);
1146 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1147 { //do not meets crietria of the pair cut
1151 {//meets criteria of the pair cut
1152 for(ii = 0;ii<fNTrackFunctions;ii++)
1153 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1155 }// for particles event2
1157 }//for over particles in event1
1159 delete fTrackBuffer->Push(trackEvent2);
1163 /*************************************************************************************/
1165 void AliHBTAnalysis::Process(Option_t* option)
1167 //default option = "TracksAndParticles"
1168 //Main method of the HBT Analysis Package
1169 //It triggers reading with the global cut (default is an empty cut)
1170 //Than it checks options and data which are read
1171 //if everything is OK, then it calls one of the looping methods
1172 //depending on tfReaderhe option
1173 //These methods differs on what thay are looping on
1176 //--------------------------------------------------------------------
1177 //ProcessTracksAndParticles - "TracksAndParticles"
1179 // it loops over both, tracks(reconstructed) and particles(simulated)
1180 // all function gethered in all 3 lists are called for each (double)pair
1182 //ProcessTracks - "Tracks"
1183 // it loops only on tracks(reconstructed),
1184 // functions ONLY from fTrackFunctions list are called
1186 //ProcessParticles - "Particles"
1187 // it loops only on particles(simulated),
1188 // functions ONLY from fParticleAndTrackFunctions list are called
1193 Error("Process","The reader is not set");
1197 const char *oT = strstr(option,"Tracks");
1198 const char *oP = strstr(option,"Particles");
1200 Bool_t nonid = IsNonIdentAnalysis();
1206 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
1207 else ProcessTracksAndParticles();
1213 if (nonid) ProcessTracksNonIdentAnal();
1214 else ProcessTracks();
1220 if (nonid) ProcessParticlesNonIdentAnal();
1221 else ProcessParticles();
1226 /*************************************************************************************/
1228 void AliHBTAnalysis::ProcessTracksAndParticles()
1230 //Makes analysis for both tracks and particles
1231 //mainly for resolution study and analysies with weighting algirithms
1232 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1233 //the loops are splited
1235 // cut on particles only -- why?
1236 // - PID: when we make resolution analysis we want to take only tracks with correct PID
1237 // We need cut on tracks because there are data characteristic to
1239 AliAOD * trackEvent, *partEvent;
1242 while (fReader->Next() == kFALSE)
1244 partEvent = fReader->GetEventSim();
1245 trackEvent = fReader->GetEventRec();
1246 ProcessRecAndSim(trackEvent,partEvent);
1248 }//while (fReader->Next() == kFALSE)
1251 /*************************************************************************************/
1253 void AliHBTAnalysis::ProcessTracks()
1255 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1256 //the loops are splited
1257 AliAOD * trackEvent;
1259 while (fReader->Next() == kFALSE)
1261 trackEvent = fReader->GetEventRec();
1262 ProcessRec(trackEvent,0x0);
1263 }//while (fReader->Next() == kFALSE)
1266 /*************************************************************************************/
1268 void AliHBTAnalysis::ProcessParticles()
1270 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
1271 //the loops are splited
1274 while (fReader->Next() == kFALSE)
1276 partEvent = fReader->GetEventSim();
1277 ProcessSim(0x0,partEvent);
1278 }//while (fReader->Next() == kFALSE)
1280 /*************************************************************************************/
1282 void AliHBTAnalysis::WriteFunctions()
1284 //Calls Write for all defined functions in analysis
1285 //== writes all results
1286 TFile* oututfile = 0x0;
1287 if (fOutputFileName)
1289 oututfile = TFile::Open(*fOutputFileName,"update");
1292 for(ii = 0;ii<fNParticleFunctions;ii++)
1294 if (AliVAODParticle::GetDebug()>5)
1296 Info("WriteFunctions","Writing ParticleFunction %#x",fParticleFunctions[ii]);
1297 Info("WriteFunctions","Writing ParticleFunction %s",fParticleFunctions[ii]->Name());
1299 fParticleFunctions[ii]->Write();
1302 for(ii = 0;ii<fNTrackFunctions;ii++)
1304 if (AliVAODParticle::GetDebug()>5)
1306 Info("WriteFunctions","Writing TrackFunction %#x",fTrackFunctions[ii]);
1307 Info("WriteFunctions","Writing TrackFunction %s",fTrackFunctions[ii]->Name());
1309 fTrackFunctions[ii]->Write();
1312 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1314 if (AliVAODParticle::GetDebug()>5)
1316 Info("WriteFunctions","Writing ParticleAndTrackFunction %#x",fParticleAndTrackFunctions[ii]);
1317 Info("WriteFunctions","Writing ParticleAndTrackFunction %s",fParticleAndTrackFunctions[ii]->Name());
1319 fParticleAndTrackFunctions[ii]->Write();
1322 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
1324 if (AliVAODParticle::GetDebug()>5)
1326 Info("WriteFunctions","Writing ParticleMonitorFunction %#x",fParticleMonitorFunctions[ii]);
1327 Info("WriteFunctions","Writing ParticleMonitorFunction %s",fParticleMonitorFunctions[ii]->Name());
1329 fParticleMonitorFunctions[ii]->Write();
1332 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
1334 if (AliVAODParticle::GetDebug()>5)
1336 Info("WriteFunctions","Writing TrackMonitorFunction %#x",fTrackMonitorFunctions[ii]);
1337 Info("WriteFunctions","Writing TrackMonitorFunction %s",fTrackMonitorFunctions[ii]->Name());
1339 fTrackMonitorFunctions[ii]->Write();
1342 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
1344 if (AliVAODParticle::GetDebug()>5)
1346 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %#x",fParticleAndTrackMonitorFunctions[ii]);
1347 Info("WriteFunctions","Writing ParticleAndTrackMonitorFunction %s",fParticleAndTrackMonitorFunctions[ii]->Name());
1349 fParticleAndTrackMonitorFunctions[ii]->Write();
1353 /*************************************************************************************/
1355 void AliHBTAnalysis::SetOutputFileName(const char* fname)
1357 //Sets fiele name where to dump results,
1358 //if not specified reults are written to gDirectory
1361 delete fOutputFileName;
1362 fOutputFileName = 0x0;
1365 if ( strcmp(fname,"") == 0 )
1367 delete fOutputFileName;
1368 fOutputFileName = 0x0;
1371 if (fOutputFileName == 0x0) fOutputFileName = new TString(fname);
1372 else *fOutputFileName = fname;
1374 /*************************************************************************************/
1376 void AliHBTAnalysis::SetGlobalPairCut(AliAODPairCut* cut)
1378 //Sets the global cut
1381 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
1384 fPairCut = (AliAODPairCut*)cut->Clone();
1387 /*************************************************************************************/
1389 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
1391 //Adds track function
1392 if (f == 0x0) return;
1393 if (fNTrackFunctions == fgkFctnArraySize)
1395 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
1397 fTrackFunctions[fNTrackFunctions] = f;
1400 /*************************************************************************************/
1402 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
1404 //adds particle function
1405 if (f == 0x0) return;
1407 if (fNParticleFunctions == fgkFctnArraySize)
1409 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
1411 fParticleFunctions[fNParticleFunctions] = f;
1412 fNParticleFunctions++;
1414 /*************************************************************************************/
1416 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
1418 //add resolution function
1419 if (f == 0x0) return;
1420 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
1422 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
1424 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
1425 fNParticleAndTrackFunctions++;
1427 /*************************************************************************************/
1429 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
1431 //add particle monitoring function
1432 if (f == 0x0) return;
1434 if (fNParticleMonitorFunctions == fgkFctnArraySize)
1436 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
1438 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
1439 fNParticleMonitorFunctions++;
1441 /*************************************************************************************/
1443 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
1445 //add track monitoring function
1446 if (f == 0x0) return;
1448 if (fNTrackMonitorFunctions == fgkFctnArraySize)
1450 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
1452 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
1453 fNTrackMonitorFunctions++;
1455 /*************************************************************************************/
1457 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
1459 //add resolution monitoring function
1460 if (f == 0x0) return;
1461 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
1463 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
1465 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
1466 fNParticleAndTrackMonitorFunctions++;
1470 /*************************************************************************************/
1471 /*************************************************************************************/
1473 Bool_t AliHBTAnalysis::RunCoherencyCheck()
1475 //Checks if both HBTRuns are similar
1476 //return true if error found
1477 //if they seem to be OK return false
1481 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
1483 //When we use non-buffering reader this is a big waste of time -> We need to read all data to check it
1484 //and reader is implemented safe in this case anyway
1485 // Info("RunCoherencyCheck","Number of events ...");
1486 // if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
1488 // Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
1491 // { //if not the same - ERROR
1492 // Error("RunCoherencyCheck",
1493 // "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
1494 // fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
1498 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
1502 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
1504 partEvent= fReader->GetEventSim(i); //gets the "ith" event
1505 trackEvent = fReader->GetEventRec(i);
1507 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
1508 if ( (partEvent == 0x0) || (partEvent == 0x0) )
1510 Error("RunCoherencyCheck",
1511 "One event is NULL and the other one not. Event Number %d",i);
1515 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
1517 Error("RunCoherencyCheck",
1518 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
1519 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
1523 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
1525 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
1527 Error("RunCoherencyCheck",
1528 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
1529 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
1535 Info("RunCoherencyCheck"," Done");
1536 Info("RunCoherencyCheck"," Everything looks OK");
1541 /*************************************************************************************/
1543 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
1545 //Performs analysis for both, tracks and particles
1546 AliAOD* rawtrackEvent, * rawpartEvent;
1549 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1550 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1551 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
1553 for (Int_t i = 0;;i++)//infinite loop
1555 if (fReader->Next()) break; //end when no more events available
1557 rawpartEvent = fReader->GetEventSim();
1558 rawtrackEvent = fReader->GetEventRec();
1560 ProcessRecAndSimNonId(rawtrackEvent,rawpartEvent);
1561 }//end of loop over events (1)
1563 /*************************************************************************************/
1565 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1567 //Process Tracks only with non identical mode
1568 AliAOD * rawtrackEvent;
1571 Info("ProcessTracksNonIdentAnal","**************************************");
1572 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1573 Info("ProcessTracksNonIdentAnal","**************************************");
1575 for (Int_t i = 0;;i++)//infinite loop
1577 if (fReader->Next()) break; //end when no more events available
1578 rawtrackEvent = fReader->GetEventRec();
1579 ProcessRecNonId(rawtrackEvent,0x0);
1580 }//end of loop over events (1)
1582 /*************************************************************************************/
1584 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1586 //process paricles only with non identical mode
1587 AliAOD * rawpartEvent = 0x0;
1590 Info("ProcessParticlesNonIdentAnal","**************************************");
1591 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1592 Info("ProcessParticlesNonIdentAnal","**************************************");
1594 for (Int_t i = 0;;i++)//infinite loop
1596 if (fReader->Next()) break; //end when no more events available
1598 rawpartEvent = fReader->GetEventSim();
1599 ProcessSimNonId(0x0,rawpartEvent);
1600 }//end of loop over events (1)
1603 /*************************************************************************************/
1604 void AliHBTAnalysis::FilterOut(AliAOD* outpart1, AliAOD* outpart2, AliAOD* inpart,
1605 AliAOD* outtrack1, AliAOD* outtrack2, AliAOD* intrack) const
1607 //Puts particles accepted as a first particle by global cut in out1
1608 //and as a second particle in out2
1610 AliVAODParticle* part, *track;
1619 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1622 part = inpart->GetParticle(i);
1623 track = intrack->GetParticle(i);
1625 if ( ((this->*fkPass1)(part,track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1626 if ( ((this->*fkPass2)(part,track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1628 if (gDebug)//to be removed in real analysis
1629 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1631 //Particle accpted by both cuts
1632 Error("FilterOut","Particle accepted by both cuts");
1638 outpart1->AddParticle(part);
1639 outtrack1->AddParticle(track);
1645 outpart2->AddParticle(new AliAODParticle(*part));
1646 outtrack2->AddParticle(new AliAODParticle(*track));
1651 /*************************************************************************************/
1653 void AliHBTAnalysis::FilterOut(AliAOD* out1, AliAOD* out2, AliAOD* in) const
1655 //Puts particles accepted as a first particle by global cut in out1
1656 //and as a second particle in out2
1657 AliVAODParticle* part;
1662 AliAODParticleCut *cut1 = fPairCut->GetFirstPartCut();
1663 AliAODParticleCut *cut2 = fPairCut->GetSecondPartCut();
1667 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1670 part = in->GetParticle(i);
1672 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1673 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1675 if (gDebug)//to be removed in real analysis
1676 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1678 //Particle accpted by both cuts
1679 Error("FilterOut","Particle accepted by both cuts");
1685 out1->AddParticle(part);
1691 out2->AddParticle(part);
1696 /*************************************************************************************/
1698 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1700 //checks if it is possible to use special analysis for non identical particles
1701 //it means - in global pair cut first particle id is different than second one
1702 //and both are different from 0
1703 //in the future is possible to perform more sophisticated check
1704 //if cuts have excluding requirements
1706 if (fPairCut->IsEmpty())
1709 if (fPairCut->GetFirstPartCut()->IsEmpty())
1712 if (fPairCut->GetSecondPartCut()->IsEmpty())
1715 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1716 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1718 if ( (id1==0) || (id2==0) || (id1==id2) )
1723 /*************************************************************************************/
1725 void AliHBTAnalysis::SetApparentVertex(Double_t x, Double_t y, Double_t z)
1727 //Sets apparent vertex
1728 // All events have to be moved to the same vertex position in order to
1729 // to be able to comare any space positions (f.g. anti-merging)
1730 // This method defines this position
1736 /*************************************************************************************/
1738 void AliHBTAnalysis::PressAnyKey()
1740 //small utility function that helps to make comfortable macros
1743 fcntl(0, F_SETFL, O_NONBLOCK);
1744 ::Info("","Press Any Key to continue ...");
1747 nread = read(0, &c, 1);
1748 gSystem->ProcessEvents();
1752 /*************************************************************************************/