+ track2= trackEvent2->GetParticle(l);
+ trackpair->SetParticles(track1,track2);
+
+ if( fPairCut->Pass(trackpair) ) //check pair cut
+ { //do not meets crietria of the
+ if( fPairCut->Pass((AliHBTPair*)trackpair->GetSwappedPair()) )
+ continue;
+ else
+ {
+ tmptrackpair = (AliHBTPair*)trackpair->GetSwappedPair();
+ }
+ }
+ else
+ {//meets criteria of the pair cut
+ tmptrackpair = trackpair;
+ }
+
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+ fTrackFunctions[ii]->ProcessDiffEventParticles(tmptrackpair);
+
+ }//for(Int_t l = 0; l<N2;l++) // ... on all Particles
+ }
+ }
+ delete fTrackBuffer->Push(trackEvent1);
+ //end of loop over events
+ return 0;
+}
+/*************************************************************************************/
+
+Int_t AliHBTAnalysis::ProcessRecAndSimNonId(AliAOD* aodrec, AliAOD* aodsim)
+{
+//Analyzes both reconstructed and simulated data
+ if (aodrec == 0x0)
+ {
+ Error("ProcessTracksAndParticlesNonIdentAnal","Reconstructed event is NULL");
+ return 1;
+ }
+
+ if (aodsim == 0x0)
+ {
+ Error("ProcessTracksAndParticlesNonIdentAnal","Simulated event is NULL");
+ return 1;
+ }
+
+ if ( aodrec->GetNumberOfParticles() != aodsim->GetNumberOfParticles() )
+ {
+ Error("ProcessTracksAndParticlesNonIdentAnal",
+ "Number of simulated particles (%d) not equal to number of reconstructed tracks (%d)",
+ aodsim->GetNumberOfParticles() , aodrec->GetNumberOfParticles());
+ return 2;
+ }
+
+
+ AliVAODParticle * part1, * part2;
+ AliVAODParticle * track1, * track2;
+
+ static AliAOD aodrec1;
+ static AliAOD aodsim1;
+
+ AliAOD * trackEvent1=&aodrec1,*partEvent1=&aodsim1;//Particle that passes first particle cut, this event
+ AliAOD * trackEvent2=0x0,*partEvent2=0x0;//Particle that passes second particle cut, this event
+ AliAOD * trackEvent3=0x0,*partEvent3=0x0;//Particle that passes second particle cut, events from buffer
+
+ AliAOD* rawtrackEvent = aodrec;//this we get from Reader
+ AliAOD* rawpartEvent = aodsim;//this we get from Reader
+
+ static AliHBTPair tpair;
+ static AliHBTPair ppair;
+
+ AliHBTPair* trackpair = &tpair;
+ AliHBTPair* partpair = &ppair;
+
+ register UInt_t ii;
+
+
+ trackEvent1 = new AliAOD();
+ partEvent1 = new AliAOD();
+ trackEvent1->SetOwner(kFALSE);
+ partEvent1->SetOwner(kFALSE);;
+
+ /********************************/
+ /* Filtering out */
+ /********************************/
+ if ( ( (partEvent2==0x0) || (trackEvent2==0x0)) )//in case fBufferSize == 0 and pointers are created do not eneter
+ {
+ partEvent2 = new AliAOD();
+ trackEvent2 = new AliAOD();
+ partEvent2->SetOwner(kTRUE);
+ trackEvent2->SetOwner(kTRUE);
+ }
+
+ FilterOut(partEvent1, partEvent2, rawpartEvent, trackEvent1, trackEvent2, rawtrackEvent);
+
+ for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
+ {
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessTracksAndParticlesNonIdentAnal",
+ "Mixing particle %d from current event with particles from current event",j);
+
+ part1= partEvent1->GetParticle(j);
+ track1= trackEvent1->GetParticle(j);
+
+
+ for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+ fParticleMonitorFunctions[ii]->Process(part1);
+ for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+ fTrackMonitorFunctions[ii]->Process(track1);
+ for(ii = 0; ii<fNParticleAndTrackMonitorFunctions; ii++)
+ fParticleAndTrackMonitorFunctions[ii]->Process(track1,part1);
+
+ if (fNoCorrfctns) continue;
+
+ /***************************************/
+ /****** filling numerators ********/
+ /****** (particles from event2) ********/
+ /***************************************/
+
+ for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
+ {
+ part2= partEvent2->GetParticle(k);
+ if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
+ partpair->SetParticles(part1,part2);
+
+ track2= trackEvent2->GetParticle(k);
+ trackpair->SetParticles(track1,track2);
+
+ if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+ fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
+
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+ fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
+
+ for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
+ fParticleAndTrackFunctions[ii]->ProcessSameEventParticles(trackpair,partpair);
+ }
+ }
+
+ if ( fBufferSize == 0) continue;//do not mix diff histograms
+ /***************************************/
+ /***** Filling denominators *********/
+ /***************************************/
+ fPartBuffer->ResetIter();
+ fTrackBuffer->ResetIter();
+
+ Int_t nmonitor = 0;
+
+ while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
+ {
+ trackEvent3 = fTrackBuffer->Next();
+
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessTracksAndParticlesNonIdentAnal",
+ "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
+
+ for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
+ {
+ part2= partEvent3->GetParticle(k);
+ partpair->SetParticles(part1,part2);
+
+ track2= trackEvent3->GetParticle(k);
+ trackpair->SetParticles(track1,track2);
+
+ if( (this->*fkPassPairProp)(partpair,trackpair) ) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ UInt_t ii;
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+ fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
+
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+ fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
+
+ for(ii = 0;ii<fNParticleAndTrackFunctions;ii++)
+ fParticleAndTrackFunctions[ii]->ProcessDiffEventParticles(trackpair,partpair);
+ }
+ }// for particles event2
+ }//while event2
+ }//for over particles in event1
+
+ delete fPartBuffer->Push(partEvent2);
+ delete fTrackBuffer->Push(trackEvent2);
+
+ return 0;
+}
+/*************************************************************************************/
+Int_t AliHBTAnalysis::ProcessSimNonId(AliAOD* /*aodrec*/, AliAOD* aodsim)
+{
+//does analysis of simulated (MC) data in non-identical mode
+//i.e. when particles selected by first part. cut are a disjunctive set than particles
+//passed by the second part. cut
+ if (aodsim == 0x0)
+ {
+ return 1;
+ }
+
+
+ AliVAODParticle * part1, * part2;
+
+ static AliAOD aodsim1;
+
+ AliAOD* partEvent1=&aodsim1;//Particle that passes first particle cut, this event
+ AliAOD* partEvent2=0x0;//Particle that passes second particle cut, this event
+ AliAOD* partEvent3=0x0;//Particle that passes second particle cut, events from buffer
+
+ AliAOD* rawpartEvent = aodsim;//this we get from Reader
+
+ static AliHBTPair ppair;
+
+ AliHBTPair* partpair = &ppair;
+
+ register UInt_t ii;
+
+
+ partEvent1 = new AliAOD();
+ partEvent1->SetOwner(kFALSE);;
+
+
+ /********************************/
+ /* Filtering out */
+ /********************************/
+ if (partEvent2==0x0)//in case fBufferSize == 0 and pointers are created do not eneter
+ {
+ partEvent2 = new AliAOD();
+ partEvent2->SetOwner(kTRUE);
+ }
+
+ FilterOut(partEvent1, partEvent2, rawpartEvent);
+
+ for (Int_t j = 0; j<partEvent1->GetNumberOfParticles() ; j++)
+ {
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessParticlesNonIdentAnal",
+ "Mixing particle %d from current event with particles from current event",j);
+
+ part1= partEvent1->GetParticle(j);
+
+
+ for(ii = 0; ii<fNParticleMonitorFunctions; ii++)
+ fParticleMonitorFunctions[ii]->Process(part1);
+
+ if (fNParticleFunctions == 0) continue;
+
+ /***************************************/
+ /****** filling numerators ********/
+ /****** (particles from event2) ********/
+ /***************************************/
+
+ for (Int_t k = 0; k < partEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
+ {
+ part2= partEvent2->GetParticle(k);
+ if (part1->GetUID() == part2->GetUID()) continue;//this is the same particle but with different PID
+ partpair->SetParticles(part1,part2);
+
+
+ if(fPairCut->PassPairProp(partpair) ) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+ fParticleFunctions[ii]->ProcessSameEventParticles(partpair);
+ }
+ }
+
+ if ( fBufferSize == 0) continue;//do not mix diff histograms
+ /***************************************/
+ /***** Filling denominators *********/
+ /***************************************/
+ fPartBuffer->ResetIter();
+
+ Int_t nmonitor = 0;
+
+ while ( (partEvent3 = fPartBuffer->Next() ) != 0x0)
+ {
+
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessParticlesNonIdentAnal",
+ "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
+
+ for (Int_t k = 0; k < partEvent3->GetNumberOfParticles() ; k++)
+ {
+ part2= partEvent3->GetParticle(k);
+ partpair->SetParticles(part1,part2);
+
+
+ if(fPairCut->PassPairProp(partpair) ) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ for(ii = 0;ii<fNParticleFunctions;ii++)
+ {
+ fParticleFunctions[ii]->ProcessDiffEventParticles(partpair);
+ }
+ }
+ }// for particles event2
+ }//while event2
+ }//for over particles in event1
+
+ delete fPartBuffer->Push(partEvent2);
+
+ return 0;
+}
+/*************************************************************************************/
+Int_t AliHBTAnalysis::ProcessRecNonId(AliAOD* aodrec, AliAOD* /*aodsim*/)
+{
+//Analyzes both reconstructed and simulated data
+ if (aodrec == 0x0)
+ {
+ return 1;
+ }
+
+ AliVAODParticle * track1, * track2;
+
+ static AliAOD aodrec1;
+
+ AliAOD * trackEvent1=&aodrec1;//Particle that passes first particle cut, this event
+ AliAOD * trackEvent2=0x0;//Particle that passes second particle cut, this event
+ AliAOD * trackEvent3=0x0;//Particle that passes second particle cut, events from buffer
+
+ AliAOD* rawtrackEvent = aodrec;//this we get from Reader
+
+ static AliHBTPair tpair;
+
+ AliHBTPair* trackpair = &tpair;
+
+ register UInt_t ii;
+
+
+ trackEvent1 = new AliAOD();
+ trackEvent1->SetOwner(kFALSE);
+
+ /********************************/
+ /* Filtering out */
+ /********************************/
+ if ( trackEvent2==0x0 )//in case fBufferSize == 0 and pointers are created do not eneter
+ {
+ trackEvent2 = new AliAOD();
+ trackEvent2->SetOwner(kTRUE);
+ }
+
+ FilterOut(trackEvent1, trackEvent2, rawtrackEvent);
+
+ for (Int_t j = 0; j<trackEvent1->GetNumberOfParticles() ; j++)
+ {
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessTracksNonIdentAnal",
+ "Mixing particle %d from current event with particles from current event",j);
+
+ track1= trackEvent1->GetParticle(j);
+
+
+ for(ii = 0; ii<fNTrackMonitorFunctions; ii++)
+ fTrackMonitorFunctions[ii]->Process(track1);
+
+ if (fNTrackFunctions == 0x0) continue;
+
+ /***************************************/
+ /****** filling numerators ********/
+ /****** (particles from event2) ********/
+ /***************************************/
+
+ for (Int_t k = 0; k < trackEvent2->GetNumberOfParticles() ; k++) //partEvent1 and partEvent2 are particles from the same event but separated to two groups
+ {
+ track2= trackEvent2->GetParticle(k);
+ if (track1->GetUID() == track2->GetUID()) continue;//this is the same particle but with different PID
+ trackpair->SetParticles(track1,track2);
+
+
+ if( fPairCut->PassPairProp(trackpair)) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ UInt_t ii;
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+ fTrackFunctions[ii]->ProcessSameEventParticles(trackpair);
+ }
+ }
+
+ if ( fBufferSize == 0) continue;//do not mix diff histograms
+ /***************************************/
+ /***** Filling denominators *********/
+ /***************************************/
+ fTrackBuffer->ResetIter();
+
+ Int_t nmonitor = 0;
+
+ while ( (trackEvent3 = fTrackBuffer->Next() ) != 0x0)
+ {
+ if ( (j%fDisplayMixingInfo) == 0)
+ Info("ProcessTracksNonIdentAnal",
+ "Mixing particle %d from current event with particles from event%d",j,-(++nmonitor));
+
+ for (Int_t k = 0; k < trackEvent3->GetNumberOfParticles() ; k++)
+ {
+ track2= trackEvent3->GetParticle(k);
+ trackpair->SetParticles(track1,track2);
+
+ if( fPairCut->PassPairProp(trackpair)) //check pair cut
+ { //do not meets crietria of the pair cut
+ continue;
+ }
+ else
+ {//meets criteria of the pair cut
+ for(ii = 0;ii<fNTrackFunctions;ii++)
+ fTrackFunctions[ii]->ProcessDiffEventParticles(trackpair);
+ }
+ }// for particles event2
+ }//while event2
+ }//for over particles in event1
+
+ delete fTrackBuffer->Push(trackEvent2);
+
+ return 0;
+}
+/*************************************************************************************/
+
+void AliHBTAnalysis::Process(Option_t* option)
+{
+ //default option = "TracksAndParticles"
+ //Main method of the HBT Analysis Package
+ //It triggers reading with the global cut (default is an empty cut)
+ //Than it checks options and data which are read
+ //if everything is OK, then it calls one of the looping methods
+ //depending on tfReaderhe option
+ //These methods differs on what thay are looping on
+ //
+ // METHOD OPTION
+ //--------------------------------------------------------------------
+ //ProcessTracksAndParticles - "TracksAndParticles"
+ // DEFAULT
+ // it loops over both, tracks(reconstructed) and particles(simulated)
+ // all function gethered in all 3 lists are called for each (double)pair
+ //
+ //ProcessTracks - "Tracks"
+ // it loops only on tracks(reconstructed),
+ // functions ONLY from fTrackFunctions list are called
+ //
+ //ProcessParticles - "Particles"
+ // it loops only on particles(simulated),
+ // functions ONLY from fParticleAndTrackFunctions list are called
+ //
+ //
+ if (!fReader)
+ {
+ Error("Process","The reader is not set");
+ return;
+ }
+
+ const char *oT = strstr(option,"Tracks");
+ const char *oP = strstr(option,"Particles");
+
+ Bool_t nonid = IsNonIdentAnalysis();
+
+ Init();
+
+ if(oT && oP)
+ {
+ if (nonid) ProcessTracksAndParticlesNonIdentAnal();
+ else ProcessTracksAndParticles();
+ return;
+ }
+
+ if(oT)
+ {
+ if (nonid) ProcessTracksNonIdentAnal();
+ else ProcessTracks();
+ return;
+ }
+
+ if(oP)
+ {
+ if (nonid) ProcessParticlesNonIdentAnal();
+ else ProcessParticles();
+ return;
+ }
+
+}
+/*************************************************************************************/
+
+void AliHBTAnalysis::ProcessTracksAndParticles()
+{
+//Makes analysis for both tracks and particles
+//mainly for resolution study and analysies with weighting algirithms
+//In order to minimize calling AliRun::GetEvent (we need at one time particles from different events),
+//the loops are splited
+
+// cut on particles only -- why?
+// - PID: when we make resolution analysis we want to take only tracks with correct PID
+// We need cut on tracks because there are data characteristic to
+
+ AliAOD * trackEvent, *partEvent;
+
+ fReader->Rewind();
+ while (fReader->Next() == kFALSE)
+ {
+ partEvent = fReader->GetEventSim();
+ trackEvent = fReader->GetEventRec();
+ ProcessRecAndSim(trackEvent,partEvent);