1 //_________________________________________________________
2 ////////////////////////////////////////////////////////////////////////////
4 // class AliHBTAnalysis
6 // Central Object Of HBTAnalyser:
7 // This class performs main looping within HBT Analysis
8 // User must plug a reader of Type AliHBTReader
9 // User plugs in coorelation and monitor functions
10 // as well as monitor functions
12 // HBT Analysis Tool, which is integral part of AliRoot,
13 // ALICE Off-Line framework:
15 // Piotr.Skowronski@cern.ch
16 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
18 ////////////////////////////////////////////////////////////////////////////
19 //_________________________________________________________
21 #include "AliHBTAnalysis.h"
22 #include "AliHBTRun.h"
23 #include "AliHBTEvent.h"
24 #include "AliHBTReader.h"
25 #include "AliHBTParticle.h"
26 #include "AliHBTParticleCut.h"
27 #include "AliHBTPair.h"
28 #include "AliHBTPairCut.h"
29 #include "AliHBTFunction.h"
30 #include "AliHBTMonitorFunction.h"
31 #include "AliHBTEventBuffer.h"
33 #include <TBenchmark.h>
37 ClassImp(AliHBTAnalysis)
39 const UInt_t AliHBTAnalysis::fgkFctnArraySize = 100;
40 const UInt_t AliHBTAnalysis::fgkDefaultMixingInfo = 1000;
41 const Int_t AliHBTAnalysis::fgkDefaultBufferSize = 5;
43 AliHBTAnalysis::AliHBTAnalysis():
46 fNParticleFunctions(0),
47 fNParticleAndTrackFunctions(0),
48 fNTrackMonitorFunctions(0),
49 fNParticleMonitorFunctions(0),
50 fNParticleAndTrackMonitorFunctions(0),
52 fDisplayMixingInfo(fgkDefaultMixingInfo),
56 fTrackFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
57 fParticleFunctions = new AliHBTOnePairFctn* [fgkFctnArraySize];
58 fParticleAndTrackFunctions = new AliHBTTwoPairFctn* [fgkFctnArraySize];
60 fParticleMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
61 fTrackMonitorFunctions = new AliHBTMonOneParticleFctn* [fgkFctnArraySize];
62 fParticleAndTrackMonitorFunctions = new AliHBTMonTwoParticleFctn* [fgkFctnArraySize];
64 fPairCut = new AliHBTEmptyPairCut();//empty cut - accepts all particles
66 /*************************************************************************************/
68 AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
72 fNParticleFunctions(0),
73 fNParticleAndTrackFunctions(0),
74 fNTrackMonitorFunctions(0),
75 fNParticleMonitorFunctions(0),
76 fNParticleAndTrackMonitorFunctions(0),
78 fParticleFunctions(0x0),
79 fParticleAndTrackFunctions(0x0),
80 fParticleMonitorFunctions(0x0),
81 fTrackMonitorFunctions(0x0),
82 fParticleAndTrackMonitorFunctions(0x0),
84 fBufferSize(fgkDefaultBufferSize),
85 fDisplayMixingInfo(fgkDefaultMixingInfo),
89 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
91 /*************************************************************************************/
92 const AliHBTAnalysis& AliHBTAnalysis::operator=(const AliHBTAnalysis& /*right*/)
95 Fatal("AliHBTAnalysis(const AliHBTAnalysis&)","Sensless");
98 /*************************************************************************************/
99 AliHBTAnalysis::~AliHBTAnalysis()
102 //note that we do not delete functions itself
103 // they should be deleted by whom where created
104 //we only store pointers, and we use "new" only for pointers array
107 delete [] fTrackFunctions;
108 delete [] fParticleFunctions;
109 delete [] fParticleAndTrackFunctions;
111 delete [] fParticleMonitorFunctions;
112 delete [] fTrackMonitorFunctions;
113 delete [] fParticleAndTrackMonitorFunctions;
115 delete fPairCut; // always have an copy of an object - we create we dstroy
118 /*************************************************************************************/
120 void AliHBTAnalysis::DeleteFunctions()
122 //Deletes all functions added to analysis
124 for(ii = 0;ii<fNParticleFunctions;ii++)
125 delete fParticleFunctions[ii];
126 fNParticleFunctions = 0;
128 for(ii = 0;ii<fNTrackFunctions;ii++)
129 delete fTrackFunctions[ii];
130 fNTrackFunctions = 0;
132 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
133 delete fParticleAndTrackFunctions[ii];
134 fNParticleAndTrackFunctions = 0;
136 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
137 delete fParticleMonitorFunctions[ii];
138 fNParticleMonitorFunctions = 0;
140 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
141 delete fTrackMonitorFunctions[ii];
142 fNTrackMonitorFunctions = 0;
144 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
145 delete fParticleAndTrackMonitorFunctions[ii];
146 fNParticleAndTrackMonitorFunctions = 0;
149 /*************************************************************************************/
151 void AliHBTAnalysis::Init()
153 //Initializeation method
154 //calls Init for all functions
156 for(ii = 0;ii<fNParticleFunctions;ii++)
157 fParticleFunctions[ii]->Init();
159 for(ii = 0;ii<fNTrackFunctions;ii++)
160 fTrackFunctions[ii]->Init();
162 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
163 fParticleAndTrackFunctions[ii]->Init();
165 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
166 fParticleMonitorFunctions[ii]->Init();
168 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
169 fTrackMonitorFunctions[ii]->Init();
171 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
172 fParticleAndTrackMonitorFunctions[ii]->Init();
176 /*************************************************************************************/
178 void AliHBTAnalysis::ResetFunctions()
180 //In case fOwner is true, deletes all functions
181 //in other case, just set number of analysis to 0
182 if (fIsOwner) DeleteFunctions();
185 fNParticleFunctions = 0;
186 fNTrackFunctions = 0;
187 fNParticleAndTrackFunctions = 0;
188 fNParticleMonitorFunctions = 0;
189 fNTrackMonitorFunctions = 0;
190 fNParticleAndTrackMonitorFunctions = 0;
193 /*************************************************************************************/
195 void AliHBTAnalysis::Process(Option_t* option)
197 //default option = "TracksAndParticles"
198 //Main method of the HBT Analysis Package
199 //It triggers reading with the global cut (default is an empty cut)
200 //Than it checks options and data which are read
201 //if everything is OK, then it calls one of the looping methods
202 //depending on tfReaderhe option
203 //These methods differs on what thay are looping on
206 //--------------------------------------------------------------------
207 //ProcessTracksAndParticles - "TracksAndParticles"
209 // it loops over both, tracks(reconstructed) and particles(simulated)
210 // all function gethered in all 3 lists are called for each (double)pair
212 //ProcessTracks - "Tracks"
213 // it loops only on tracks(reconstructed),
214 // functions ONLY from fTrackFunctions list are called
216 //ProcessParticles - "Particles"
217 // it loops only on particles(simulated),
218 // functions ONLY from fParticleAndTrackFunctions list are called
223 Error("Process","The reader is not set");
227 const char *oT = strstr(option,"Tracks");
228 const char *oP = strstr(option,"Particles");
230 Bool_t nonid = IsNonIdentAnalysis();
236 if (nonid) ProcessTracksAndParticlesNonIdentAnal();
237 else ProcessTracksAndParticles();
243 if (nonid) ProcessTracksNonIdentAnal();
244 else ProcessTracks();
250 if (nonid) ProcessParticlesNonIdentAnal();
251 else ProcessParticles();
256 /*************************************************************************************/
258 void AliHBTAnalysis::ProcessTracksAndParticles()
260 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
261 //the loops are splited
264 AliHBTParticle * part1, * part2;
265 AliHBTParticle * track1, * track2;
267 AliHBTEvent * trackEvent, *partEvent;
268 AliHBTEvent * trackEvent1 = 0x0,*partEvent1 = 0x0;
269 AliHBTEvent * trackEvent2,*partEvent2;
271 // Int_t N1, N2, N=0; //number of particles in current event(we prcess two events in one time)
273 // Int_t nev = fReader->GetNumberOfTrackEvents();
274 AliHBTPair * trackpair = new AliHBTPair();
275 AliHBTPair * partpair = new AliHBTPair();
277 AliHBTPair * tmptrackpair;//temprary pointers to pairs
278 AliHBTPair * tmppartpair;
280 AliHBTEventBuffer partbuffer(fBufferSize);
281 AliHBTEventBuffer trackbuffer(fBufferSize);
285 Bool_t nocorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
289 while (fReader->Next() == kFALSE)
292 partEvent= fReader->GetParticleEvent();
293 trackEvent = fReader->GetTrackEvent();
295 if ( !partEvent || !trackEvent )
297 Error("ProcessTracksAndParticles","Can not get event");
301 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
303 Fatal("ProcessTracksAndParticles",
304 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
305 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
309 if(partEvent1 == 0x0)
311 partEvent1 = new AliHBTEvent();
312 partEvent1->SetOwner(kTRUE);
314 trackEvent1 = new AliHBTEvent();
315 trackEvent1->SetOwner(kTRUE);
320 trackEvent1->Reset();
323 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
325 /***************************************/
326 /****** Looping same events ********/
327 /****** filling numerators ********/
328 /***************************************/
329 if ( (j%fDisplayMixingInfo) == 0)
330 Info("ProcessTracksAndParticles",
331 "Mixing particle %d from event %d with particles from event %d",j,i,i);
333 part1= partEvent->GetParticle(j);
334 track1= trackEvent->GetParticle(j);
336 //PID imperfections ???
337 // if( part1->GetPdgCode() != track1->GetPdgCode() )
339 // Fatal("ProcessTracksAndParticles",
340 // "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
341 // i,j, part1->GetPdgCode(),track1->GetPdgCode() );
345 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
346 if (fBufferSize != 0)
347 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE) )
349 //accepted by any cut
350 // we have to copy because reader keeps only one event
352 partEvent1->AddParticle(new AliHBTParticle(*part1));
353 trackEvent1->AddParticle(new AliHBTParticle(*track1));
356 if (firstcut) continue;
358 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
359 fParticleMonitorFunctions[ii]->Process(part1);
360 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
361 fTrackMonitorFunctions[ii]->Process(track1);
362 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
363 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
365 if (nocorrfctns) continue;
367 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
369 part2= partEvent->GetParticle(k);
370 if (part1->GetUID() == part2->GetUID()) continue;
371 partpair->SetParticles(part1,part2);
373 track2= trackEvent->GetParticle(k);
374 trackpair->SetParticles(track1,track2);
376 if(fPairCut->Pass(trackpair) ) //check pair cut
377 { //do not meets crietria of the pair cut, try with swapped pairs
378 if( fPairCut->Pass(trackpair->GetSwapedPair()) )
379 continue; //swaped pairs do not meet criteria of pair cut as well, take next particle
381 { //swaped pair meets all the criteria
382 tmppartpair = partpair->GetSwapedPair();
383 tmptrackpair = trackpair->GetSwapedPair();
387 {//meets criteria of the pair cut
388 tmptrackpair = trackpair;
389 tmppartpair = partpair;
391 for(ii = 0;ii<fNParticleFunctions;ii++)
392 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
394 for(ii = 0;ii<fNTrackFunctions;ii++)
395 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
397 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
398 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair,tmppartpair);
399 //end of 2nd loop over particles from the same event
400 }//for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
402 /***************************************/
403 /***** Filling denominators *********/
404 /***************************************/
405 if (fBufferSize == 0) continue;
407 partbuffer.ResetIter();
408 trackbuffer.ResetIter();
410 while (( partEvent2 = partbuffer.Next() ))
412 trackEvent2 = trackbuffer.Next();
415 if ( (j%fDisplayMixingInfo) == 0)
416 Info("ProcessTracksAndParticles",
417 "Mixing particle %d from event %d with particles from event %d",j,i,i-m);
419 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
421 part2= partEvent2->GetParticle(l);
422 partpair->SetParticles(part1,part2);
424 track2= trackEvent2->GetParticle(l);
425 trackpair->SetParticles(track1,track2);
427 if( fPairCut->Pass(partpair) ) //check pair cut
428 { //do not meets crietria of the
429 if( fPairCut->Pass(partpair->GetSwapedPair()) )
433 tmppartpair = partpair->GetSwapedPair();
434 tmptrackpair = trackpair->GetSwapedPair();
438 {//meets criteria of the pair cut
439 tmptrackpair = trackpair;
440 tmppartpair = partpair;
442 for(ii = 0;ii<fNParticleFunctions;ii++)
443 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
445 for(ii = 0;ii<fNTrackFunctions;ii++)
446 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
448 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
449 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair,tmppartpair);
450 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
453 //end of loop over particles from first event
454 }//for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
455 partEvent1 = partbuffer.Push(partEvent1);
456 trackEvent1 = trackbuffer.Push(trackEvent1);
457 //end of loop over events
458 }//while (fReader->Next() == kFALSE)
460 /*************************************************************************************/
462 void AliHBTAnalysis::ProcessTracks()
464 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
465 //the loops are splited
466 AliHBTParticle * track1, * track2;
467 AliHBTEvent * trackEvent;
468 AliHBTEvent * trackEvent1 = 0x0;
469 AliHBTEvent * trackEvent2;
473 AliHBTPair * trackpair = new AliHBTPair();
474 AliHBTPair * tmptrackpair; //temporary pointer
476 AliHBTEventBuffer trackbuffer(fBufferSize);
480 while (fReader->Next() == kFALSE)
483 trackEvent = fReader->GetTrackEvent();
484 if (!trackEvent) continue;
486 if(trackEvent1 == 0x0)
488 trackEvent1 = new AliHBTEvent();
489 trackEvent1->SetOwner(kTRUE);
493 trackEvent1->Reset();
496 for (Int_t j = 0; j<trackEvent->GetNumberOfParticles() ; j++)
498 /***************************************/
499 /****** Looping same events ********/
500 /****** filling numerators ********/
501 /***************************************/
502 if ( (j%fDisplayMixingInfo) == 0)
503 Info("ProcessTracks",
504 "Mixing particle %d from event %d with particles from event %d",j,i,i);
506 track1= trackEvent->GetParticle(j);
507 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(track1);
509 if (fBufferSize != 0)
510 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(track1) == kFALSE) )
512 //accepted by any cut
513 // we have to copy because reader keeps only one event
514 trackEvent1->AddParticle(new AliHBTParticle(*track1));
517 if (firstcut) continue;
519 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
520 fTrackMonitorFunctions[ii]->Process(track1);
522 if ( fNTrackFunctions ==0 ) continue;
524 for (Int_t k =j+1; k < trackEvent->GetNumberOfParticles() ; k++)
526 track2= trackEvent->GetParticle(k);
527 if (track1->GetUID() == track2->GetUID()) continue;
529 trackpair->SetParticles(track1,track2);
530 if(fPairCut->Pass(trackpair)) //check pair cut
531 { //do not meets crietria of the
532 if( fPairCut->Pass(trackpair->GetSwapedPair()) ) continue;
533 else tmptrackpair = trackpair->GetSwapedPair();
537 tmptrackpair = trackpair;
539 for(ii = 0;ii<fNTrackFunctions;ii++)
540 fTrackFunctions[ii]->ProcessSameEventParticles(tmptrackpair);
542 /***************************************/
543 /***** Filling denominators *********/
544 /***************************************/
546 if (fBufferSize == 0) continue;
548 trackbuffer.ResetIter();
551 while (( trackEvent2 = trackbuffer.Next() ))
554 if ( (j%fDisplayMixingInfo) == 0)
555 Info("ProcessTracks",
556 "Mixing track %d from event %d with tracks from event %d",j,i,i-m);
557 for(Int_t l = 0; l<trackEvent2->GetNumberOfParticles();l++) // ... on all particles
560 track2= trackEvent2->GetParticle(l);
561 trackpair->SetParticles(track1,track2);
563 if( fPairCut->Pass(trackpair) ) //check pair cut
564 { //do not meets crietria of the
565 if( fPairCut->Pass(trackpair->GetSwapedPair()) )
569 tmptrackpair = trackpair->GetSwapedPair();
573 {//meets criteria of the pair cut
574 tmptrackpair = trackpair;
577 for(ii = 0;ii<fNTrackFunctions;ii++)
578 fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
580 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
584 trackEvent1 = trackbuffer.Push(trackEvent1);
585 }//while (fReader->Next() == kFALSE)
588 /*************************************************************************************/
590 void AliHBTAnalysis::ProcessParticles()
592 //In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
593 //the loops are splited
594 AliHBTParticle * part1, * part2;
595 AliHBTEvent * partEvent;
596 AliHBTEvent * partEvent1 = 0x0;
597 AliHBTEvent * partEvent2;
601 AliHBTPair * partpair = new AliHBTPair();
602 AliHBTPair * tmppartpair; //temporary pointer
604 AliHBTEventBuffer partbuffer(fBufferSize);
608 while (fReader->Next() == kFALSE)
611 partEvent = fReader->GetParticleEvent();
612 if (!partEvent) continue;
614 if(partEvent1 == 0x0)
616 partEvent1 = new AliHBTEvent();
617 partEvent1->SetOwner(kTRUE);
624 for (Int_t j = 0; j<partEvent->GetNumberOfParticles() ; j++)
626 /***************************************/
627 /****** Looping same events ********/
628 /****** filling numerators ********/
629 /***************************************/
630 if ( (j%fDisplayMixingInfo) == 0)
631 Info("ProcessParticles",
632 "Mixing particle %d from event %d with particles from event %d",j,i,i);
634 part1 = partEvent->GetParticle(j);
635 Bool_t firstcut = fPairCut->GetFirstPartCut()->Pass(part1);
637 if (fBufferSize != 0) //useless in case
638 if ( (firstcut == kFALSE) || (fPairCut->GetSecondPartCut()->Pass(part1) == kFALSE) )
640 //accepted by any cut
641 // we have to copy because reader keeps only one event
642 partEvent1->AddParticle(new AliHBTParticle(*part1));
645 if (firstcut) continue;
647 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
648 fParticleMonitorFunctions[ii]->Process(part1);
650 if ( fNParticleFunctions == 0 ) continue;
652 for (Int_t k =j+1; k < partEvent->GetNumberOfParticles() ; k++)
654 part2= partEvent->GetParticle(k);
655 if (part1->GetUID() == part2->GetUID()) continue;
657 partpair->SetParticles(part1,part2);
658 if(fPairCut->Pass(partpair)) //check pair cut
659 { //do not meets crietria of the
660 if( fPairCut->Pass(partpair->GetSwapedPair()) ) continue;
661 else tmppartpair = partpair->GetSwapedPair();
665 tmppartpair = partpair;
667 for(ii = 0;ii<fNParticleFunctions;ii++)
668 fParticleFunctions[ii]->ProcessSameEventParticles(tmppartpair);
670 /***************************************/
671 /***** Filling denominators *********/
672 /***************************************/
674 if (fBufferSize == 0) continue;
676 partbuffer.ResetIter();
679 while (( partEvent2 = partbuffer.Next() ))
682 if ( (j%fDisplayMixingInfo) == 0)
683 Info("ProcessParticles",
684 "Mixing particle %d from event %d with particles from event %d",j,i,i-m);
685 for(Int_t l = 0; l<partEvent2->GetNumberOfParticles();l++) // ... on all particles
688 part2= partEvent2->GetParticle(l);
689 partpair->SetParticles(part1,part2);
691 if( fPairCut->Pass(partpair) ) //check pair cut
692 { //do not meets crietria of the
693 if( fPairCut->Pass(partpair->GetSwapedPair()) )
697 tmppartpair = partpair->GetSwapedPair();
701 {//meets criteria of the pair cut
702 tmppartpair = partpair;
705 for(ii = 0;ii<fNParticleFunctions;ii++)
706 fParticleFunctions[ii]->ProcessDiffEventParticles(tmppartpair);
708 }//for(Int_t l = 0; l<N2;l++) // ... on all particles
711 partEvent1 = partbuffer.Push(partEvent1);
712 }//while (fReader->Next() == kFALSE)
714 /*************************************************************************************/
716 void AliHBTAnalysis::WriteFunctions()
718 //Calls Write for all defined functions in analysis
719 //== writes all results
721 for(ii = 0;ii<fNParticleFunctions;ii++)
722 fParticleFunctions[ii]->Write();
724 for(ii = 0;ii<fNTrackFunctions;ii++)
725 fTrackFunctions[ii]->Write();
727 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
728 fParticleAndTrackFunctions[ii]->Write();
730 for(ii = 0;ii<fNParticleMonitorFunctions;ii++)
731 fParticleMonitorFunctions[ii]->Write();
733 for(ii = 0;ii<fNTrackMonitorFunctions;ii++)
734 fTrackMonitorFunctions[ii]->Write();
736 for(ii = 0;ii<fNParticleAndTrackMonitorFunctions;ii++)
737 fParticleAndTrackMonitorFunctions[ii]->Write();
739 /*************************************************************************************/
741 void AliHBTAnalysis::SetGlobalPairCut(AliHBTPairCut* cut)
743 //Sets the global cut
746 Error("AliHBTAnalysis::SetGlobalPairCut","Pointer is NULL. Ignoring");
749 fPairCut = (AliHBTPairCut*)cut->Clone();
752 /*************************************************************************************/
754 void AliHBTAnalysis::AddTrackFunction(AliHBTOnePairFctn* f)
756 //Adds track function
757 if (f == 0x0) return;
758 if (fNTrackFunctions == fgkFctnArraySize)
760 Error("AliHBTAnalysis::AddTrackFunction","Can not add this function, not enough place in the array.");
762 fTrackFunctions[fNTrackFunctions] = f;
765 /*************************************************************************************/
767 void AliHBTAnalysis::AddParticleFunction(AliHBTOnePairFctn* f)
769 //adds particle function
770 if (f == 0x0) return;
772 if (fNParticleFunctions == fgkFctnArraySize)
774 Error("AliHBTAnalysis::AddParticleFunction","Can not add this function, not enough place in the array.");
776 fParticleFunctions[fNParticleFunctions] = f;
777 fNParticleFunctions++;
779 /*************************************************************************************/
781 void AliHBTAnalysis::AddParticleAndTrackFunction(AliHBTTwoPairFctn* f)
783 //add resolution function
784 if (f == 0x0) return;
785 if (fNParticleAndTrackFunctions == fgkFctnArraySize)
787 Error("AliHBTAnalysis::AddParticleAndTrackFunction","Can not add this function, not enough place in the array.");
789 fParticleAndTrackFunctions[fNParticleAndTrackFunctions] = f;
790 fNParticleAndTrackFunctions++;
792 /*************************************************************************************/
794 void AliHBTAnalysis::AddParticleMonitorFunction(AliHBTMonOneParticleFctn* f)
796 //add particle monitoring function
797 if (f == 0x0) return;
799 if (fNParticleMonitorFunctions == fgkFctnArraySize)
801 Error("AliHBTAnalysis::AddParticleMonitorFunction","Can not add this function, not enough place in the array.");
803 fParticleMonitorFunctions[fNParticleMonitorFunctions] = f;
804 fNParticleMonitorFunctions++;
806 /*************************************************************************************/
808 void AliHBTAnalysis::AddTrackMonitorFunction(AliHBTMonOneParticleFctn* f)
810 //add track monitoring function
811 if (f == 0x0) return;
813 if (fNTrackMonitorFunctions == fgkFctnArraySize)
815 Error("AliHBTAnalysis::AddTrackMonitorFunction","Can not add this function, not enough place in the array.");
817 fTrackMonitorFunctions[fNTrackMonitorFunctions] = f;
818 fNTrackMonitorFunctions++;
820 /*************************************************************************************/
822 void AliHBTAnalysis::AddParticleAndTrackMonitorFunction(AliHBTMonTwoParticleFctn* f)
824 //add resolution monitoring function
825 if (f == 0x0) return;
826 if (fNParticleAndTrackMonitorFunctions == fgkFctnArraySize)
828 Error("AliHBTAnalysis::AddParticleAndTrackMonitorFunction","Can not add this function, not enough place in the array.");
830 fParticleAndTrackMonitorFunctions[fNParticleAndTrackMonitorFunctions] = f;
831 fNParticleAndTrackMonitorFunctions++;
835 /*************************************************************************************/
836 /*************************************************************************************/
838 Bool_t AliHBTAnalysis::RunCoherencyCheck()
840 //Checks if both HBTRuns are similar
841 //return true if error found
842 //if they seem to be OK return false
844 Info("RunCoherencyCheck","Checking HBT Runs Coherency");
846 Info("RunCoherencyCheck","Number of events ...");
847 if (fReader->GetNumberOfPartEvents() == fReader->GetNumberOfTrackEvents() ) //check whether there is the same number of events
849 Info("RunCoherencyCheck","OK. %d found\n",fReader->GetNumberOfTrackEvents());
852 { //if not the same - ERROR
853 Error("AliHBTAnalysis::RunCoherencyCheck()",
854 "Number of simulated events (%d) is not equal to number of reconstructed events(%d)",
855 fReader->GetNumberOfPartEvents(),fReader->GetNumberOfTrackEvents());
859 Info("RunCoherencyCheck","Checking number of Particles AND Particles Types in each event ...");
861 AliHBTEvent *partEvent;
862 AliHBTEvent *trackEvent;
863 for( i = 0; i<fReader->GetNumberOfTrackEvents();i++)
865 partEvent= fReader->GetParticleEvent(i); //gets the "ith" event
866 trackEvent = fReader->GetTrackEvent(i);
868 if ( (partEvent == 0x0) && (partEvent == 0x0) ) continue;
869 if ( (partEvent == 0x0) || (partEvent == 0x0) )
871 Error("AliHBTAnalysis::RunCoherencyCheck()",
872 "One event is NULL and the other one not. Event Number %d",i);
876 if ( partEvent->GetNumberOfParticles() != trackEvent->GetNumberOfParticles() )
878 Error("AliHBTAnalysis::RunCoherencyCheck()",
879 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
880 i,partEvent->GetNumberOfParticles() , trackEvent->GetNumberOfParticles());
884 for (Int_t j = 0; j<partEvent->GetNumberOfParticles(); j++)
886 if( partEvent->GetParticle(j)->GetPdgCode() != trackEvent->GetParticle(j)->GetPdgCode() )
888 Error("AliHBTAnalysis::RunCoherencyCheck()",
889 "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
890 i,j, partEvent->GetParticle(j)->GetPdgCode(),trackEvent->GetParticle(j)->GetPdgCode() );
896 Info("RunCoherencyCheck"," Done");
897 Info("RunCoherencyCheck"," Everything looks OK");
901 /*************************************************************************************/
903 void AliHBTAnalysis::ProcessTracksAndParticlesNonIdentAnal()
905 //Performs analysis for both, tracks and particles
907 AliHBTParticle * part1, * part2;
908 AliHBTParticle * track1, * track2;
910 AliHBTEvent * trackEvent1=0x0,*partEvent1=0x0;
911 AliHBTEvent * trackEvent2=0x0,*partEvent2=0x0;
912 AliHBTEvent * trackEvent3=0x0,*partEvent3=0x0;
914 AliHBTEvent * rawtrackEvent, *rawpartEvent;//this we get from Reader
916 AliHBTPair * trackpair = new AliHBTPair();
917 AliHBTPair * partpair = new AliHBTPair();
919 AliHBTEventBuffer partbuffer(fBufferSize);
920 AliHBTEventBuffer trackbuffer(fBufferSize);
924 trackEvent1 = new AliHBTEvent();
925 partEvent1 = new AliHBTEvent();
926 trackEvent1->SetOwner(kFALSE);
927 partEvent1->SetOwner(kFALSE);;
929 Bool_t nocorrfctns = (fNParticleFunctions == 0) && (fNTrackFunctions == 0) && (fNParticleAndTrackFunctions == 0);
933 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
934 Info("ProcessTracksAndParticlesNonIdentAnal","***** NON IDENT MODE ****************");
935 Info("ProcessTracksAndParticlesNonIdentAnal","**************************************");
937 for (Int_t i = 0;;i++)//infinite loop
939 if (fReader->Next()) break; //end when no more events available
941 rawpartEvent = fReader->GetParticleEvent();
942 rawtrackEvent = fReader->GetTrackEvent();
943 if ( (rawpartEvent == 0x0) || (rawtrackEvent == 0x0) ) continue;//in case of any error
945 if ( rawpartEvent->GetNumberOfParticles() != rawtrackEvent->GetNumberOfParticles() )
947 Fatal("ProcessTracksAndParticlesNonIdentAnal",
948 "Event %d: Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
949 i,rawpartEvent->GetNumberOfParticles() , rawtrackEvent->GetNumberOfParticles());
953 /********************************/
955 /********************************/
956 if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
958 partEvent2 = new AliHBTEvent();
959 trackEvent2 = new AliHBTEvent();
960 partEvent2->SetOwner(kTRUE);
961 trackEvent2->SetOwner(kTRUE);
964 FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
966 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
968 if ( (j%fDisplayMixingInfo) == 0)
969 Info("ProcessTracksAndParticlesNonIdentAnal",
970 "Mixing particle %d from event %d with particles from event %d",j,i,i);
972 part1= partEvent1->GetParticle(j);
973 track1= trackEvent1->GetParticle(j);
975 //PID reconstruction imperfections
976 // if( part1->GetPdgCode() != track1->GetPdgCode() )
978 // Fatal("ProcessTracksAndParticlesNonIdentAnal",
979 // "Event %d: Particle %d: PID of simulated particle (%d) not the same of reconstructed track (%d)",
980 // i,j, part1->GetPdgCode(),track1->GetPdgCode() );
984 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
985 fParticleMonitorFunctions[ii]->Process(part1);
986 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
987 fTrackMonitorFunctions[ii]->Process(track1);
988 for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
989 fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
991 if (nocorrfctns) continue;
993 /***************************************/
994 /****** filling numerators ********/
995 /****** (particles from event2) ********/
996 /***************************************/
998 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
1000 part2= partEvent2->GetParticle(k);
1001 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
1002 partpair->SetParticles(part1,part2);
1004 track2= trackEvent2->GetParticle(k);
1005 trackpair->SetParticles(track1,track2);
1007 if( (fPairCut->PassPairProp(trackpair)) ) //check pair cut
1008 { //do not meets crietria of the pair cut
1012 {//meets criteria of the pair cut
1013 for(ii = 0;ii<fNParticleFunctions;ii++)
1014 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1016 for(ii = 0;ii<fNTrackFunctions;ii++)
1017 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1019 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1020 fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
1024 if ( fBufferSize == 0) continue;//do not mix diff histograms
1025 /***************************************/
1026 /***** Filling denominators *********/
1027 /***************************************/
1028 partbuffer.ResetIter();
1029 trackbuffer.ResetIter();
1033 while ( (partEvent3 = partbuffer.Next() ) != 0x0)
1035 trackEvent3 = trackbuffer.Next();
1037 if ( (j%fDisplayMixingInfo) == 0)
1038 Info("ProcessTracksAndParticlesNonIdentAnal",
1039 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1041 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1043 part2= partEvent3->GetParticle(k);
1044 partpair->SetParticles(part1,part2);
1046 track2= trackEvent3->GetParticle(k);
1047 trackpair->SetParticles(track1,track2);
1049 if( (fPairCut->PassPairProp(trackpair)) ) //check pair cut
1050 { //do not meets crietria of the pair cut
1054 {//meets criteria of the pair cut
1056 for(ii = 0;ii<fNParticleFunctions;ii++)
1057 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1059 for(ii = 0;ii<fNTrackFunctions;ii++)
1060 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1062 for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
1063 fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
1065 }// for particles event2
1067 }//for over particles in event1
1069 partEvent2 = partbuffer.Push(partEvent2);
1070 trackEvent2 = trackbuffer.Push(trackEvent2);
1072 }//end of loop over events (1)
1074 partbuffer.SetOwner(kTRUE);
1075 trackbuffer.SetOwner(kTRUE);
1085 /*************************************************************************************/
1087 void AliHBTAnalysis::ProcessTracksNonIdentAnal()
1089 //Process Tracks only with non identical mode
1090 AliHBTParticle * track1, * track2;
1092 AliHBTEvent * trackEvent1=0x0;
1093 AliHBTEvent * trackEvent2=0x0;
1094 AliHBTEvent * trackEvent3=0x0;
1096 AliHBTEvent * rawtrackEvent;
1098 AliHBTPair * trackpair = new AliHBTPair();
1099 AliHBTEventBuffer trackbuffer(fBufferSize);
1103 trackEvent1 = new AliHBTEvent();
1104 trackEvent1->SetOwner(kFALSE);
1108 Info("ProcessTracksNonIdentAnal","**************************************");
1109 Info("ProcessTracksNonIdentAnal","***** NON IDENT MODE ****************");
1110 Info("ProcessTracksNonIdentAnal","**************************************");
1113 for (Int_t i = 0;;i++)//infinite loop
1115 if (fReader->Next()) break; //end when no more events available
1116 rawtrackEvent = fReader->GetTrackEvent();
1118 if (rawtrackEvent == 0x0) continue;//in case of any error
1120 /********************************/
1122 /********************************/
1123 if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
1125 trackEvent2 = new AliHBTEvent();
1126 trackEvent2->SetOwner(kTRUE);
1129 FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
1131 for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
1133 if ( (j%fDisplayMixingInfo) == 0)
1134 Info("ProcessTracksNonIdentAnal",
1135 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1137 track1= trackEvent1->GetParticle(j);
1139 for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
1140 fTrackMonitorFunctions[ii]->Process(track1);
1142 if (fNTrackFunctions == 0x0) continue;
1144 /***************************************/
1145 /****** filling numerators ********/
1146 /****** (particles from event2) ********/
1147 /***************************************/
1148 for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++)
1150 track2= trackEvent2->GetParticle(k);
1151 if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
1152 trackpair->SetParticles(track1,track2);
1155 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1156 { //do not meets crietria of the pair cut
1160 {//meets criteria of the pair cut
1162 for(ii = 0;ii<fNTrackFunctions;ii++)
1163 fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
1166 if ( fBufferSize == 0) continue;//do not mix diff histograms
1167 /***************************************/
1168 /***** Filling denominators *********/
1169 /***************************************/
1170 trackbuffer.ResetIter();
1173 while ( (trackEvent3 = trackbuffer.Next() ) != 0x0)
1176 if ( (j%fDisplayMixingInfo) == 0)
1177 Info("ProcessTracksNonIdentAnal",
1178 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1180 for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
1183 track2= trackEvent3->GetParticle(k);
1184 trackpair->SetParticles(track1,track2);
1187 if( fPairCut->PassPairProp(trackpair)) //check pair cut
1188 { //do not meets crietria of the pair cut
1192 {//meets criteria of the pair cut
1193 for(ii = 0;ii<fNTrackFunctions;ii++)
1194 fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
1196 }// for particles event2
1198 }//for over particles in event1
1200 trackEvent2 = trackbuffer.Push(trackEvent2);
1202 }//end of loop over events (1)
1204 trackbuffer.SetOwner(kTRUE);
1209 /*************************************************************************************/
1211 void AliHBTAnalysis::ProcessParticlesNonIdentAnal()
1213 //process paricles only with non identical mode
1214 AliHBTParticle * part1 = 0x0, * part2 = 0x0;
1216 AliHBTEvent * partEvent1 = 0x0;
1217 AliHBTEvent * partEvent2 = 0x0;
1218 AliHBTEvent * partEvent3 = 0x0;
1220 AliHBTEvent * rawpartEvent = 0x0;
1222 AliHBTPair * partpair = new AliHBTPair();
1223 AliHBTEventBuffer partbuffer(fBufferSize);
1227 partEvent1 = new AliHBTEvent();
1228 partEvent1->SetOwner(kFALSE);
1232 Info("ProcessParticlesNonIdentAnal","**************************************");
1233 Info("ProcessParticlesNonIdentAnal","***** NON IDENT MODE ****************");
1234 Info("ProcessParticlesNonIdentAnal","**************************************");
1236 for (Int_t i = 0;;i++)//infinite loop
1238 if (fReader->Next()) break; //end when no more events available
1240 rawpartEvent = fReader->GetParticleEvent();
1241 if ( rawpartEvent == 0x0 ) continue;//in case of any error
1243 /********************************/
1245 /********************************/
1246 if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
1248 partEvent2 = new AliHBTEvent();
1249 partEvent2->SetOwner(kTRUE);
1252 FilterOut(partEvent1, partEvent2, rawpartEvent);
1254 for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
1256 if ( (j%fDisplayMixingInfo) == 0)
1257 Info("ProcessParticlesNonIdentAnal",
1258 "Mixing particle %d from event %d with particles from event %d",j,i,i);
1260 part1= partEvent1->GetParticle(j);
1262 for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
1263 fParticleMonitorFunctions[ii]->Process(part1);
1265 if (fNParticleFunctions == 0) continue;
1267 /***************************************/
1268 /****** filling numerators ********/
1269 /****** (particles from event2) ********/
1270 /***************************************/
1271 for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++)
1273 part2= partEvent2->GetParticle(k);
1274 if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
1275 partpair->SetParticles(part1,part2);
1277 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1278 { //do not meets crietria of the pair cut
1282 {//meets criteria of the pair cut
1283 for(ii = 0;ii<fNParticleFunctions;ii++)
1284 fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
1287 if ( fBufferSize == 0) continue;//do not mix diff histograms
1288 /***************************************/
1289 /***** Filling denominators *********/
1290 /***************************************/
1291 partbuffer.ResetIter();
1294 while ( (partEvent3 = partbuffer.Next() ) != 0x0)
1296 if ( (j%fDisplayMixingInfo) == 0)
1297 Info("ProcessParticlesNonIdentAnal",
1298 "Mixing particle %d from event %d with particles from event %d",j,i,i-(++nmonitor));
1300 for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
1302 part2= partEvent3->GetParticle(k);
1303 partpair->SetParticles(part1,part2);
1305 if(fPairCut->PassPairProp(partpair) ) //check pair cut
1306 { //do not meets crietria of the pair cut
1310 {//meets criteria of the pair cut
1311 for(ii = 0;ii<fNParticleFunctions;ii++)
1313 fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
1316 }// for particles event2
1318 }//for over particles in event1
1319 partEvent2 = partbuffer.Push(partEvent2);
1320 }//end of loop over events (1)
1322 partbuffer.SetOwner(kTRUE);
1328 /*************************************************************************************/
1329 void AliHBTAnalysis::FilterOut(AliHBTEvent* outpart1, AliHBTEvent* outpart2, AliHBTEvent* inpart,
1330 AliHBTEvent* outtrack1, AliHBTEvent* outtrack2, AliHBTEvent* intrack)
1332 //Puts particles accepted as a first particle by global cut in out1
1333 //and as a second particle in out2
1335 AliHBTParticle* part, *track;
1342 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1343 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1347 for (Int_t i = 0; i < inpart->GetNumberOfParticles(); i++)
1350 part = inpart->GetParticle(i);
1351 track = intrack->GetParticle(i);
1353 if ( (cut1->Pass(track)) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1354 if ( (cut2->Pass(track)) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1356 if (gDebug)//to be removed in real analysis
1357 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1359 //Particle accpted by both cuts
1360 Error("FilterOut","Particle accepted by both cuts");
1366 outpart1->AddParticle(part);
1367 outtrack1->AddParticle(track);
1373 outpart2->AddParticle(new AliHBTParticle(*part));
1374 outtrack2->AddParticle(new AliHBTParticle(*track));
1379 /*************************************************************************************/
1381 void AliHBTAnalysis::FilterOut(AliHBTEvent* out1, AliHBTEvent* out2, AliHBTEvent* in)
1383 //Puts particles accepted as a first particle by global cut in out1
1384 //and as a second particle in out2
1385 AliHBTParticle* part;
1390 AliHBTParticleCut *cut1 = fPairCut->GetFirstPartCut();
1391 AliHBTParticleCut *cut2 = fPairCut->GetSecondPartCut();
1395 for (Int_t i = 0; i < in->GetNumberOfParticles(); i++)
1398 part = in->GetParticle(i);
1400 if ( cut1->Pass(part) ) in1 = kFALSE; //if part is rejected by cut1, in1 is false
1401 if ( cut2->Pass(part) ) in2 = kFALSE; //if part is rejected by cut2, in2 is false
1403 if (gDebug)//to be removed in real analysis
1404 if ( in1 && in2 ) //both cuts accepted, should never happen, just in case
1406 //Particle accpted by both cuts
1407 Error("FilterOut","Particle accepted by both cuts");
1413 out1->AddParticle(part);
1419 out2->AddParticle(part);
1424 /*************************************************************************************/
1426 Bool_t AliHBTAnalysis::IsNonIdentAnalysis()
1428 //checks if it is possible to use special analysis for non identical particles
1429 //it means - in global pair cut first particle id is different than second one
1430 //and both are different from 0
1431 //in the future is possible to perform more sophisticated check
1432 //if cuts have excluding requirements
1434 if (fPairCut->IsEmpty())
1437 if (fPairCut->GetFirstPartCut()->IsEmpty())
1440 if (fPairCut->GetSecondPartCut()->IsEmpty())
1443 Int_t id1 = fPairCut->GetFirstPartCut()->GetPID();
1444 Int_t id2 = fPairCut->GetSecondPartCut()->GetPID();
1446 if ( (id1==0) || (id2==0) || (id1==id2) )