+Double_t AliAnalysisTaskFlowTPCEMCalEP::GetCos2DeltaPhi(Double_t phiA,Double_t phiB) const
+{
+ //Get cos[2(phi-psi_EP)] or cos[2(psi_subEP1 - psi_subEP2)]
+ Double_t dPhi = TVector2::Phi_0_2pi(phiA - phiB);
+ if(dPhi > TMath::Pi()) dPhi = dPhi - TMath::Pi();
+ Double_t cos2DeltaPhi = TMath::Cos(2*dPhi);
+
+ return cos2DeltaPhi;
+}
+//_________________________________________
+Double_t AliAnalysisTaskFlowTPCEMCalEP::GetDeltaPhi(Double_t phiA,Double_t phiB) const
+{
+ //Get phi-psi_EP
+ Double_t dPhi = TVector2::Phi_0_2pi(phiA - phiB);
+ if(dPhi > TMath::Pi()) dPhi = dPhi - TMath::Pi();
+
+ return dPhi;
+}
+//_________________________________________
+Double_t AliAnalysisTaskFlowTPCEMCalEP::GetPi0weight(Double_t mcPi0pT, Float_t cent) const
+{
+ //Get Pi0 weight
+ double weight = 1.0;
+ return weight;
+}
+//_________________________________________
+Double_t AliAnalysisTaskFlowTPCEMCalEP::GetEtaweight(Double_t mcEtapT, Float_t cent) const
+{
+ //Get eta weight
+ double weight = 1.0;
+ return weight;
+}
+//_________________________________________
+Double_t AliAnalysisTaskFlowTPCEMCalEP::GetSigmaEMCal(Double_t EoverP, Double_t pt, Float_t cent) const
+{
+ //Get sigma for EMCal PID
+ Double_t NumberOfSigmasEMCal = 99.;
+ Double_t ptRange[9] = {1.5,2,2.5,3,4,6,8,10,13};
+
+ if (cent>=0 && cent<10){
+ Double_t mean[8]={0.953184,0.957259,0.97798,0.9875,1.03409,1.06257,1.02776,1.04338};
+ Double_t sigma[8]={0.130003,0.113493,0.092966,0.0836828,0.101804,0.0893414,0.0950752,0.050427};
+ for(Int_t i=0;i<8;i++) {
+ if (pt>=ptRange[i] && pt<ptRange[i+1]){
+ NumberOfSigmasEMCal = (mean[i]-EoverP)/sigma[i];
+ continue;
+ }
+ }
+ }
+ if (cent>=10 && cent<20){
+ Double_t mean[8]={0.96905,0.952985,0.96871,0.983934,1.00047,0.988736,1.02101,1.04557};
+ Double_t sigma[8]={0.0978103,0.103215,0.0958494,0.0797962,0.0719482,0.0672677,0.0754882,0.0461192};
+ for(Int_t i=0;i<8;i++) {
+ if (pt>=ptRange[i] && pt<ptRange[i+1]){
+ NumberOfSigmasEMCal = (mean[i]-EoverP)/sigma[i];
+ continue;
+ }
+ }
+ }
+ if (cent>=20 && cent<40){
+ Double_t mean[8]={0.947362,0.951933,0.959288,0.977004,0.984502,1.02004,1.00489,0.986696};
+ Double_t sigma[8]={0.100127,0.0887731,0.0842077,0.0787335,0.0804325,0.0652376,0.0766669,0.0597849};
+ for(Int_t i=0;i<8;i++) {
+ if (pt>=ptRange[i] && pt<ptRange[i+1]){
+ NumberOfSigmasEMCal = (mean[i]-EoverP)/sigma[i];
+ continue;
+ }
+ }
+ }
+
+
+
+ return NumberOfSigmasEMCal;
+}
+//_________________________________________
+Bool_t AliAnalysisTaskFlowTPCEMCalEP::IsPi0EtaFromHFdecay(TParticle *particle, AliStack* stack)
+{
+ // Check if the mother comes from heavy-flavour decays
+
+ Bool_t isHFdecay = kFALSE;
+ Int_t partPDG = particle->GetPdgCode();
+
+ if (TMath::Abs(partPDG)!=111 || TMath::Abs(partPDG)!=221) return isHFdecay; // particle is not pi0 or eta
+
+ Int_t idMother = particle->GetFirstMother();
+ if (idMother>0){
+ TParticle *mother = stack->Particle(idMother);
+ Int_t motherPDG = mother->GetPdgCode();
+
+ // c decays
+ if((TMath::Abs(motherPDG)==411) || (TMath::Abs(motherPDG)==421) || (TMath::Abs(motherPDG)==431) || (TMath::Abs(motherPDG)==4122) || (TMath::Abs(motherPDG)==4132) || (TMath::Abs(motherPDG)==4232) || (TMath::Abs(motherPDG)==43320)) isHFdecay = kTRUE;
+
+ // b decays
+ if((TMath::Abs(motherPDG)==511) || (TMath::Abs(motherPDG)==521) || (TMath::Abs(motherPDG)==531) || (TMath::Abs(motherPDG)==5122) || (TMath::Abs(motherPDG)==5132) || (TMath::Abs(motherPDG)==5232) || (TMath::Abs(motherPDG)==53320)) isHFdecay = kTRUE;
+ }
+
+ return isHFdecay;
+}
+//_________________________________________
+Bool_t AliAnalysisTaskFlowTPCEMCalEP::IsPi0EtaFromLMdecay(TParticle *particle, AliStack* stack)
+{
+ // Check if the mother comes from light-meson decays
+
+ Bool_t isLMdecay = kFALSE;
+ Int_t partPDG = particle->GetPdgCode();
+
+ if (TMath::Abs(partPDG)!=111 || TMath::Abs(partPDG)!=221) return isLMdecay; // particle is not pi0 or eta
+
+ Int_t idMother = particle->GetFirstMother();
+ if (idMother>0){
+ TParticle *mother = stack->Particle(idMother);
+ Int_t motherPDG = mother->GetPdgCode();
+
+ if(motherPDG == 111 || motherPDG == 221 || motherPDG==223 || motherPDG==333 || motherPDG==331 || (TMath::Abs(motherPDG)==113) || (TMath::Abs(motherPDG)==213) || (TMath::Abs(motherPDG)==313) || (TMath::Abs(motherPDG)==323)) isLMdecay = kTRUE;
+ }
+
+ return isLMdecay;
+}
+//_________________________________________
+Bool_t AliAnalysisTaskFlowTPCEMCalEP::IsPi0EtaPrimary(TParticle *particle, AliStack* stack)
+{
+ // Check if the pi0 or eta are primary
+
+ Bool_t isprimary = kFALSE;
+ Int_t partPDG = particle->GetPdgCode();
+
+ if (TMath::Abs(partPDG)!=111 || TMath::Abs(partPDG)!=221) return isprimary; // particle is not pi0 or eta
+
+
+ Bool_t pi0etaprimary = particle->IsPrimary();
+ Int_t idMother = particle->GetFirstMother();
+
+ if (pi0etaprimary && idMother<=0) isprimary = kTRUE;
+
+ return isprimary;
+}
+//_________________________________________
+Bool_t AliAnalysisTaskFlowTPCEMCalEP::IsElectronFromPi0(TParticle *particle, AliStack* stack, Double_t &weight, Float_t cent)
+{
+ // Check if electron comes from primary pi0 not from light-meson and heavy-flavour decays
+
+ Bool_t isPi0Decay = kFALSE;
+ Int_t partPDG = particle->GetPdgCode();
+
+ if (TMath::Abs(partPDG)!=11) return isPi0Decay; // particle is not electron
+
+ Int_t idMother = particle->GetFirstMother();
+ if (idMother>0){
+ TParticle *mother = stack->Particle(idMother);
+ Int_t motherPDG = mother->GetPdgCode();
+ Double_t motherPt = mother->Pt();
+
+ Bool_t isMotherPi0primary = IsPi0EtaPrimary(mother,stack);
+ Bool_t isMotherPi0fromHF = IsPi0EtaFromHFdecay(mother,stack);
+ Bool_t isMotherPi0fromLM = IsPi0EtaFromLMdecay(mother,stack);
+
+ if (motherPDG==111 && (isMotherPi0primary || (!isMotherPi0fromHF && !isMotherPi0fromLM))){ // pi0 -> e
+ isPi0Decay = kTRUE;
+ weight = GetPi0weight(motherPt,cent);
+ }
+
+ Int_t idSecondMother = particle->GetSecondMother();
+ if (motherPDG==22 && idSecondMother>0){
+ TParticle *secondMother = stack->Particle(idSecondMother);
+ Int_t secondMotherPDG = secondMother->GetPdgCode();
+ Double_t secondMotherPt = secondMother->Pt();
+
+ Bool_t isSecondMotherPi0primary = IsPi0EtaPrimary(secondMother,stack);
+ Bool_t isSecondMotherPi0fromHF = IsPi0EtaFromHFdecay(secondMother,stack);
+ Bool_t isSecondMotherPi0fromLM = IsPi0EtaFromLMdecay(secondMother,stack);
+
+ if (secondMotherPDG==111 && (isSecondMotherPi0primary || (!isSecondMotherPi0fromHF && !isSecondMotherPi0fromLM))){ //pi0 -> gamma -> e
+ isPi0Decay = kTRUE;
+ weight = GetPi0weight(secondMotherPt,cent);
+ }
+ }
+ }
+ return isPi0Decay;
+}
+//_________________________________________
+Bool_t AliAnalysisTaskFlowTPCEMCalEP::IsElectronFromEta(TParticle *particle, AliStack* stack, Double_t &weight, Float_t cent)
+{
+ // Check if electron comes from primary eta not from light-meson and heavy-flavour decays
+
+ Bool_t isEtaDecay = kFALSE;
+ Int_t partPDG = particle->GetPdgCode();
+
+ if (TMath::Abs(partPDG)!=11) return isEtaDecay; // particle is not electron
+
+ Int_t idMother = particle->GetFirstMother();
+ if (idMother>0){
+ TParticle *mother = stack->Particle(idMother);
+ Int_t motherPDG = mother->GetPdgCode();
+ Double_t motherPt = mother->Pt();
+
+ Bool_t isMotherEtaprimary = IsPi0EtaPrimary(mother,stack);
+ Bool_t isMotherEtafromHF = IsPi0EtaFromHFdecay(mother,stack);
+ Bool_t isMotherEtafromLM = IsPi0EtaFromLMdecay(mother,stack);
+
+ if (motherPDG==221 && (isMotherEtaprimary || (!isMotherEtafromHF && !isMotherEtafromLM))){ //primary eta -> e
+ isEtaDecay = kTRUE;
+ weight = GetEtaweight(motherPt,cent);
+ }
+
+ Int_t idSecondMother = mother->GetFirstMother();
+ if ((motherPDG==22 || motherPDG==111) && idSecondMother>0){
+ TParticle *secondMother = stack->Particle(idSecondMother);
+ Int_t secondMotherPDG = secondMother->GetPdgCode();
+ Double_t secondMotherPt = secondMother->Pt();
+
+ Bool_t isSecondMotherEtaprimary = IsPi0EtaPrimary(secondMother,stack);
+ Bool_t isSecondMotherEtafromHF = IsPi0EtaFromHFdecay(secondMother,stack);
+ Bool_t isSecondMotherEtafromLM = IsPi0EtaFromLMdecay(secondMother,stack);
+
+ if (secondMotherPDG==221 && (isSecondMotherEtaprimary || (!isSecondMotherEtafromHF && !isSecondMotherEtafromLM))){ //eta -> pi0/g-> e
+ isEtaDecay = kTRUE;
+ weight = GetEtaweight(secondMotherPt,cent);
+ }
+ Int_t idThirdMother = secondMother->GetFirstMother();
+ if (idThirdMother>0){
+ TParticle *thirdMother = stack->Particle(idThirdMother);
+ Int_t thirdMotherPDG = thirdMother->GetPdgCode();
+ Double_t thirdMotherPt = thirdMother->Pt();
+
+ Bool_t isThirdMotherEtaprimary = IsPi0EtaPrimary(thirdMother,stack);
+ Bool_t isThirdMotherEtafromHF = IsPi0EtaFromHFdecay(thirdMother,stack);
+ Bool_t isThirdMotherEtafromLM = IsPi0EtaFromLMdecay(thirdMother,stack);
+
+ if (motherPDG==22 && secondMotherPDG==111 && thirdMotherPDG==221 && (isThirdMotherEtaprimary || (!isThirdMotherEtafromHF && !isThirdMotherEtafromLM))){//p eta->pi0->g-> e
+ isEtaDecay = kTRUE;
+ weight = GetEtaweight(thirdMotherPt,cent);
+ }
+ }
+ }
+ }
+ return isEtaDecay;
+}
+//_________________________________________
+void AliAnalysisTaskFlowTPCEMCalEP::SelectPhotonicElectron(Int_t iTracks,AliESDtrack *track,Bool_t &fFlagPhotonicElec, Bool_t &fFlagPhotonicElecBCG,Double_t weight, Int_t iCent)