1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 // Class for heavy-flavour electron v2 with EMCal triggered events
17 // Author: Denise Godoy
25 #include "THnSparse.h"
26 #include "TLorentzVector.h"
30 #include "AliAnalysisTask.h"
31 #include "AliAnalysisManager.h"
33 #include "AliESDEvent.h"
34 #include "AliESDHandler.h"
35 #include "AliAODEvent.h"
36 #include "AliAODHandler.h"
37 #include "AliVEvent.h"
39 #include "AliAnalysisTaskFlowTPCEMCalEP.h"
40 #include "TGeoGlobalMagField.h"
42 #include "AliAnalysisTaskSE.h"
43 #include "TRefArray.h"
45 #include "AliESDInputHandler.h"
46 #include "AliESDpid.h"
47 #include "AliESDtrackCuts.h"
48 #include "AliPhysicsSelection.h"
49 #include "AliESDCaloCluster.h"
50 #include "AliAODCaloCluster.h"
51 #include "AliEMCALRecoUtils.h"
52 #include "AliEMCALGeometry.h"
53 #include "AliGeomManager.h"
55 #include "TGeoManager.h"
59 #include "AliEMCALTrack.h"
62 #include "AliKFParticle.h"
63 #include "AliKFVertex.h"
65 #include "AliMCEventHandler.h"
66 #include "AliMCEvent.h"
67 #include "AliMCParticle.h"
71 #include "AliPIDResponse.h"
72 #include "AliHFEcontainer.h"
73 #include "AliHFEcuts.h"
74 #include "AliHFEpid.h"
75 #include "AliHFEpidBase.h"
76 #include "AliHFEpidQAmanager.h"
77 #include "AliHFEtools.h"
78 #include "AliCFContainer.h"
79 #include "AliCFManager.h"
81 #include "AliEventplane.h"
82 #include "AliCentrality.h"
84 #include "AliSelectNonHFE.h"
87 ClassImp(AliAnalysisTaskFlowTPCEMCalEP)
88 //________________________________________________________________________
89 AliAnalysisTaskFlowTPCEMCalEP::AliAnalysisTaskFlowTPCEMCalEP(const char *name)
90 : AliAnalysisTaskSE(name)
100 ,fIdentifiedAsOutInz(kFALSE)
101 ,fPassTheEventCut(kFALSE)
102 ,fRejectKinkMother(kFALSE)
109 ,fOpeningAngleCut(0.1)
115 ,fnonHFEalgorithm("KF")
125 ,fTrackPtBefTrkCuts(0)
126 ,fTrackPtAftTrkCuts(0)
162 for(Int_t k = 0; k < 6; k++) {
169 fPID = new AliHFEpid("hfePid");
170 fTrackCuts = new AliESDtrackCuts();
171 fNonHFE = new AliSelectNonHFE();
175 // Define input and output slots here
176 // Input slot #0 works with a TChain
177 DefineInput(0, TChain::Class());
178 // Output slot #0 id reserved by the base class for AOD
179 // Output slot #1 writes into a TH1 container
180 // DefineOutput(1, TH1I::Class());
181 DefineOutput(1, TList::Class());
182 // DefineOutput(3, TTree::Class());
185 //________________________________________________________________________
186 AliAnalysisTaskFlowTPCEMCalEP::AliAnalysisTaskFlowTPCEMCalEP()
187 : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisElecHadCorrel")
197 ,fIdentifiedAsOutInz(kFALSE)
198 ,fPassTheEventCut(kFALSE)
199 ,fRejectKinkMother(kFALSE)
206 ,fOpeningAngleCut(0.1)
212 ,fnonHFEalgorithm("KF")
222 ,fTrackPtBefTrkCuts(0)
223 ,fTrackPtAftTrkCuts(0)
258 //Default constructor
260 for(Int_t k = 0; k < 6; k++) {
267 fPID = new AliHFEpid("hfePid");
268 fTrackCuts = new AliESDtrackCuts();
269 fNonHFE = new AliSelectNonHFE();
275 // Define input and output slots here
276 // Input slot #0 works with a TChain
277 DefineInput(0, TChain::Class());
278 // Output slot #0 id reserved by the base class for AOD
279 // Output slot #1 writes into a TH1 container
280 // DefineOutput(1, TH1I::Class());
281 DefineOutput(1, TList::Class());
282 //DefineOutput(3, TTree::Class());
284 //_________________________________________
286 AliAnalysisTaskFlowTPCEMCalEP::~AliAnalysisTaskFlowTPCEMCalEP()
296 //_________________________________________
298 void AliAnalysisTaskFlowTPCEMCalEP::UserExec(Option_t*)
301 //Called for each event
303 // create pointer to event
304 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
306 printf("ERROR: fESD not available\n");
310 fVevent = dynamic_cast<AliVEvent*>(InputEvent());
312 printf("ERROR: fVEvent not available\n");
317 AliError("HFE cuts not available");
321 if(!fPID->IsInitialized()){
322 // Initialize PID with the given run number
323 AliWarning("PID not initialised, get from Run no");
324 if(fIsAOD)fPID->InitializePID(fAOD->GetRunNumber());
325 if(!fIsAOD) fPID->InitializePID(fESD->GetRunNumber());
328 if(fIsMC)fMC = MCEvent();
329 AliStack* stack = NULL;
330 if(fIsMC && fMC) stack = fMC->Stack();
332 Int_t fNOtrks =fESD->GetNumberOfTracks();
333 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
335 Double_t pVtxZ = -999;
336 pVtxZ = pVtx->GetZ();
338 if(TMath::Abs(pVtxZ)>10) return;
341 if(fNOtrks<2) return;
343 fpidResponse = fInputHandler->GetPIDResponse();
345 AliDebug(1, "Using default PID Response");
346 fpidResponse = AliHFEtools::GetDefaultPID(kFALSE, fInputEvent->IsA() == AliAODEvent::Class());
349 fPID->SetPIDResponse(fpidResponse);
351 fCFM->SetRecEventInfo(fVevent);
354 AliCentrality *centrality = fESD->GetCentrality();
355 cent = centrality->GetCentralityPercentile("V0M");
358 // cout<<"TEST: "<<fInvmassCut<< " "<< fOpeningAngleCut<<" "<<fnonHFEalgorithm<<" "<<fminCent<<" "<<fmaxCent<<" here!!!!!!!!!!!" <<endl;
362 Double_t evPlaneV0A = TVector2::Phi_0_2pi(fESD->GetEventplane()->GetEventplane("V0A",fESD,2));
363 if(evPlaneV0A > TMath::Pi()) evPlaneV0A = evPlaneV0A - TMath::Pi();
364 fevPlaneV0A->Fill(evPlaneV0A);
366 Double_t evPlaneV0C = TVector2::Phi_0_2pi(fESD->GetEventplane()->GetEventplane("V0C",fESD,2));
367 if(evPlaneV0C > TMath::Pi()) evPlaneV0C = evPlaneV0C - TMath::Pi();
368 fevPlaneV0C->Fill(evPlaneV0C);
370 Double_t evPlaneV0 = TVector2::Phi_0_2pi(fESD->GetEventplane()->GetEventplane("V0",fESD,2));
371 if(evPlaneV0 > TMath::Pi()) evPlaneV0 = evPlaneV0 - TMath::Pi();
372 fevPlaneV0->Fill(evPlaneV0);
374 AliEventplane* esdTPCep = fESD->GetEventplane();
375 TVector2 *standardQ = 0x0;
376 Double_t qx = -999., qy = -999.;
377 standardQ = esdTPCep->GetQVector();
378 if(!standardQ)return;
383 TVector2 qVectorfortrack;
384 qVectorfortrack.Set(qx,qy);
385 Float_t evPlaneTPC = TVector2::Phi_0_2pi(qVectorfortrack.Phi())/2.;
386 fevPlaneTPC->Fill(evPlaneTPC);
388 //Event plane resolutions
390 // --> 2 subevent method (only for TPC EP)
392 TVector2 *qsub1a = esdTPCep->GetQsub1();
393 TVector2 *qsub2a = esdTPCep->GetQsub2();
394 Double_t evPlaneResTPC = -999.;
395 if(qsub1a && qsub2a){
396 evPlaneResTPC = TMath::Cos(2.*TVector2::Phi_0_2pi(qsub1a->Phi()/2.- qsub2a->Phi()/2.));
399 fTPCsubEPres->Fill(evPlaneResTPC);
401 // --> 3 event method (V0, V0A, and V0C EP)
403 Double_t Qx2pos = -999., Qy2pos = -999., Qx2neg = -999., Qy2neg = -999., Qweight = 1;
405 for(Int_t iTracks = 0; iTracks < fVevent->GetNumberOfTracks(); iTracks++) {
407 AliVParticle* vparticle = fVevent->GetTrack(iTracks);
409 printf("ERROR: Could not receive track %d\n", iTracks);
413 AliESDtrack *trackEP = dynamic_cast<AliESDtrack*>(vparticle);
416 printf("ERROR: Could not receive track %d\n", iTracks);
420 if(TMath::Abs(trackEP->Eta())>0.8 || trackEP->Pt() < 0.15 || trackEP->Pt() > 4) continue;
422 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, trackEP)) continue;
424 if (trackEP->Pt() < 2) Qweight = trackEP->Pt()/2;
425 if (trackEP->Pt() >= 2) Qweight = 1;
428 if(trackEP->Eta()>0 && trackEP->Eta()<0.8){
429 Qx2pos += Qweight*TMath::Cos(2*trackEP->Phi());
430 Qy2pos += Qweight*TMath::Sin(2*trackEP->Phi());
432 if(trackEP->Eta()<0 && trackEP->Eta()>-0.8){
433 Qx2neg += Qweight*TMath::Cos(2*trackEP->Phi());
434 Qy2neg += Qweight*TMath::Sin(2*trackEP->Phi());
436 }//track loop only for EP
438 Double_t evPlaneTPCneg = TMath::ATan2(Qy2neg, Qx2neg)/2;
439 Double_t evPlaneTPCpos = TMath::ATan2(Qy2pos, Qx2pos)/2;
441 Double_t evPlaneRes[7]={GetCos2DeltaPhi(evPlaneV0A,evPlaneV0C),GetCos2DeltaPhi(evPlaneV0A,evPlaneTPC),
442 GetCos2DeltaPhi(evPlaneV0C,evPlaneTPC),GetCos2DeltaPhi(evPlaneV0,evPlaneTPCpos),
443 GetCos2DeltaPhi(evPlaneV0,evPlaneTPCneg),GetCos2DeltaPhi(evPlaneTPCpos,evPlaneTPCneg),cent};
444 fEPres->Fill(evPlaneRes);
447 if(fIsMC && fMC && stack){
448 Int_t nParticles = stack->GetNtrack();
449 for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
450 TParticle* particle = stack->Particle(iParticle);
451 int fPDG = particle->GetPdgCode();
452 double pTMC = particle->Pt();
453 double etaMC = particle->Eta();
454 if(fabs(etaMC)>0.7)continue;
456 Bool_t MChijing = fMC->IsFromBGEvent(iParticle);
458 if(!MChijing)iHijing = 0;
460 if(fPDG==111)fPi0Weight->Fill(pTMC,iHijing);//pi0
461 if(fPDG==221)fEtaWeight->Fill(pTMC,iHijing);//eta
462 if(fPDG==421)fD0Weight->Fill(pTMC,iHijing);//D0
463 if(fPDG==411)fDplusWeight->Fill(pTMC,iHijing);//D+
464 if(fPDG==-411)fDminusWeight->Fill(pTMC,iHijing);//D-
466 Int_t idMother = particle->GetFirstMother();
468 TParticle *mother = stack->Particle(idMother);
469 int motherPDG = mother->GetPdgCode();
470 if(fPDG==22 && motherPDG!=111 && motherPDG!=221)fGammaWeight->Fill(pTMC,iHijing);//gamma
475 Double_t ptRange[8] = {2, 2.5, 3, 4, 6, 8, 10, 13};
476 Double_t ptDmeson[7] = {2,3,4,6,8,12,16};
477 Double_t deltaPhiRange[7];
478 for(Int_t j=0;j<7;j++){
479 deltaPhiRange[j] = j*(TMath::Pi()/6);
483 for(Int_t iTracks = 0; iTracks < fVevent->GetNumberOfTracks(); iTracks++) {
485 AliVParticle* vparticle = fVevent->GetTrack(iTracks);
487 printf("ERROR: Could not receive track %d\n", iTracks);
491 AliVTrack *vtrack = dynamic_cast<AliVTrack*>(vparticle);
492 AliESDtrack *track = dynamic_cast<AliESDtrack*>(vparticle);
494 if (TMath::Abs(track->Eta())>0.7) continue;
496 fTrackPtBefTrkCuts->Fill(track->Pt());
498 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
500 if(fRejectKinkMother) { // Quick and dirty fix to reject both kink mothers and daughters
501 if(track->GetKinkIndex(0) != 0) continue;
504 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
506 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
508 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
510 fTrackPtAftTrkCuts->Fill(track->Pt());
512 Double_t clsE = -999., p = -999., EovP=-999., pt = -999., dEdx=-999., fTPCnSigma=0, phi=-999.,
513 wclsE = -999., wEovP = -999., m02= -999., m20= -999.;
519 Int_t clsId = track->GetEMCALcluster();
521 AliESDCaloCluster *cluster = fESD->GetCaloCluster(clsId);
522 if(cluster && cluster->IsEMCAL()){
524 m20 = cluster->GetM20();
525 m02 = cluster->GetM02();
531 dEdx = track->GetTPCsignal();
534 fTPCnSigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron) : 1000;
535 fdEdxBef->Fill(p,dEdx);
536 fTPCnsigma->Fill(p,fTPCnSigma);
538 //Remove electron candidate from the event plane
539 Float_t evPlaneCorrTPC = evPlaneTPC;
540 if(dEdx>70 && dEdx<90){
541 Double_t qX = standardQ->X() - esdTPCep->GetQContributionX(track);
542 Double_t qY = standardQ->Y() - esdTPCep->GetQContributionY(track);
543 TVector2 newQVectorfortrack;
544 newQVectorfortrack.Set(qX,qY);
545 evPlaneCorrTPC = TVector2::Phi_0_2pi(newQVectorfortrack.Phi())/2;
548 Bool_t fFlagPhotonicElec = kFALSE;
549 Bool_t fFlagPhotonicElecBCG = kFALSE;
551 //Non-HFE reconstruction
552 fNonHFE->SetPIDresponse(fpidResponse);
553 fNonHFE->FindNonHFE(iTracks,vparticle,fVevent);
554 Int_t *fUlsPartner = fNonHFE->GetPartnersULS(); // Pointer to the ULS partners index
555 Int_t *fLsPartner = fNonHFE->GetPartnersLS(); // Pointer to the LS partners index
557 if (fNonHFE->IsULS()) fFlagPhotonicElec=kTRUE;
558 if (fNonHFE->IsLS()) fFlagPhotonicElecBCG=kTRUE;
560 fNonHFE->SetHistAngleBack(fOpAngleBack);
561 fNonHFE->SetHistAngle(fOpAngle);
562 fNonHFE->SetHistMassBack(fInvMassBack);
563 fNonHFE->SetHistMass(fInvMass);
564 if (fnonHFEalgorithm == "DCA")fNonHFE->SetHistDCABack(fDCABack);
565 if (fnonHFEalgorithm == "DCA")fNonHFE->SetHistDCA(fDCA);
568 Double_t corr[11]={phi,fTPCnSigma,cent,pt,EovP,GetDeltaPhi(phi,evPlaneV0),GetCos2DeltaPhi(phi,evPlaneV0), static_cast<Double_t>(fFlagPhotonicElec),
569 static_cast<Double_t>(fFlagPhotonicElecBCG),m02,m20};
572 Int_t whichFirstMother = 0, whichSecondMother = 0, whichThirdMother = 0;
573 Int_t whichPart = -99;
574 Int_t partPDG = -99, motherPDG = -99, secondMotherPDG = -99, thirdMotherPDG = -99;
575 Double_t partPt = -99. , motherPt = -99., secondMotherPt = -99.,thirdMotherPt = -99.;
576 Double_t weight = 1.;
577 Double_t Dweight = 1.;
580 Bool_t pi0Decay= kFALSE;
581 Bool_t etaDecay= kFALSE;
584 Double_t phiD = -999.,phie = -999.,phieRec = -999.,ptD = -999.,pte = -999.,pteRec = -999.;
586 if(fIsMC && fMC && stack){
587 Int_t label = track->GetLabel();
589 TParticle *particle = stack->Particle(label);
591 partPDG = particle->GetPdgCode();
592 partPt = particle->Pt();
594 if (TMath::Abs(partPDG)==11) whichPart = 0; //electron
595 if (partPDG==22) whichPart = 3; //gamma
596 if (partPDG==111) whichPart = 2; //pi0
597 if (partPDG==221) whichPart = 1; //eta
599 MChijing = fMC->IsFromBGEvent(label);
602 if(!MChijing) iHijing = 0; // 0 if enhanced sample
604 Int_t idMother = particle->GetFirstMother();
606 TParticle *mother = stack->Particle(idMother);
607 motherPt = mother->Pt();
608 motherPDG = mother->GetPdgCode();
610 if (motherPDG==22) whichFirstMother = 3; //gamma
611 if (motherPDG==111) whichFirstMother = 2; //pi0
612 if (motherPDG==221) whichFirstMother = 1; //eta
614 Int_t idSecondMother = particle->GetSecondMother();
615 if (idSecondMother>0){
616 TParticle *secondMother = stack->Particle(idSecondMother);
617 secondMotherPt = secondMother->Pt();
618 secondMotherPDG = secondMother->GetPdgCode();
620 if (secondMotherPDG==111) whichSecondMother = 2; //pi0
621 if (secondMotherPDG==221) whichSecondMother = 1; //eta
623 Int_t idThirdMother = secondMother->GetFirstMother();
624 if (idThirdMother>0){
625 TParticle *thirdMother = stack->Particle(idThirdMother);
626 thirdMotherPt = thirdMother->Pt();
627 thirdMotherPDG = thirdMother->GetPdgCode();
629 if (thirdMotherPDG==221) whichThirdMother = 1; //eta
634 if (TMath::Abs(partPDG)==11){
637 if (motherPDG==421 || TMath::Abs(motherPDG)==411){ // D
638 Double_t phi_D = -99., Deltaphi_De=-99.;
639 phi_D = mother->Phi();
640 Deltaphi_De = phi_D - phi;
642 fD0_e->Fill(pt,Deltaphi_De);
644 Dweight= GetDweight(0,motherPt,cent);
645 if(iHijing==1) Dweight = 1.0;
646 for(Int_t i=0;i<6;i++){
647 if (motherPt>=ptDmeson[i] && motherPt<ptDmeson[i+1]) fDe[i]->Fill(pt,Dweight);
650 if (motherPDG==421){ // D0
651 Dweight= GetDweight(1,motherPt,cent);
652 if(iHijing==1) Dweight = 1.0;
653 for(Int_t i=0;i<6;i++){
654 if (motherPt>=ptDmeson[i] && motherPt<ptDmeson[i+1]) fD0e[i]->Fill(pt,Dweight);
657 if (motherPDG==411){ // D+
658 Dweight= GetDweight(2,motherPt,cent);
659 if(iHijing==1) Dweight = 1.0;
660 for(Int_t i=0;i<6;i++){
661 if (motherPt>=ptDmeson[i] && motherPt<ptDmeson[i+1]) fDpluse[i]->Fill(pt,Dweight);
664 if (motherPDG==-411){ //D-
665 Dweight= GetDweight(3,motherPt,cent);
666 if(iHijing==1) Dweight = 1.0;
667 for(Int_t i=0;i<6;i++){
668 if (motherPt>=ptDmeson[i] && motherPt<ptDmeson[i+1]) fDminuse[i]->Fill(pt,Dweight);
673 if (motherPDG==111 && secondMotherPDG!=221){ //not eta -> pi0 -> e
674 weight = GetPi0weight(motherPt,cent);
677 if (motherPDG==22 && secondMotherPDG==111 && thirdMotherPDG!=221){ //not eta -> pi0 -> gamma -> e
678 weight = GetPi0weight(secondMotherPt,cent);
683 if (motherPDG==221){ //eta -> e
684 weight = GetEtaweight(motherPt,cent);
687 if (motherPDG==111 && secondMotherPDG==221){ //eta -> pi0 -> e
688 weight = GetEtaweight(secondMotherPt,cent);
691 if (motherPDG==22 && secondMotherPDG==221){ //eta -> gamma -> e
692 weight = GetEtaweight(secondMotherPt,cent);
695 if (motherPDG==22 && secondMotherPDG==111 && thirdMotherPDG==221){ //eta -> pi0 -> gamma -> e
696 weight = GetEtaweight(thirdMotherPt,cent);
701 if (fTPCnSigma>-1 && fTPCnSigma<3 && EovP>1 && EovP<1.3 && (motherPDG==22 || motherPDG==111 || motherPDG==221)){
702 if(iHijing==1) weight = 1.0;
705 fTot_pi0e->Fill(partPt,weight);
706 if(fFlagPhotonicElec) fPhot_pi0e->Fill(partPt,weight);
707 if(fFlagPhotonicElecBCG) fPhotBCG_pi0e->Fill(partPt,weight);
710 fTot_etae->Fill(partPt,weight);
711 if(fFlagPhotonicElec) fPhot_etae->Fill(partPt,weight);
712 if(fFlagPhotonicElecBCG) fPhotBCG_etae->Fill(partPt,weight);
716 Double_t mc[15]={EovP,fTPCnSigma,partPt, static_cast<Double_t>(fFlagPhotonicElec),
717 static_cast<Double_t>(fFlagPhotonicElecBCG), static_cast<Double_t>(whichPart),cent,pt,
718 static_cast<Double_t>(whichFirstMother), static_cast<Double_t>(whichSecondMother),
719 static_cast<Double_t>(whichThirdMother), static_cast<Double_t>(iHijing),motherPt,secondMotherPt,thirdMotherPt};
721 //fMCphotoElecPt->Fill(mc);
722 if (motherPDG==22 || motherPDG==111 || motherPDG==221) fMCphotoElecPt->Fill(mc);// mother = gamma, pi0, eta
728 if(fTPCnSigma >= 1.5 && fTPCnSigma <= 3)fTrkEovPBef->Fill(pt,EovP);
732 AliHFEpidObject hfetrack;
733 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
734 hfetrack.SetRecTrack(track);
736 if(!fPID->IsSelected(&hfetrack, NULL, "", fPIDqa)) pidpassed = 0;
738 Double_t corrV2[7]={phi,cent,pt,EovP,GetCos2DeltaPhi(phi,evPlaneTPC),GetCos2DeltaPhi(phi,evPlaneV0A),
739 GetCos2DeltaPhi(phi,evPlaneV0C)};
740 fChargPartV2->Fill(corrV2);
742 if(fTPCnSigma >= -0.5){
743 Double_t correctedV2[5]={cent,pt,GetCos2DeltaPhi(phi,evPlaneCorrTPC),GetCos2DeltaPhi(phi,evPlaneV0A),
744 GetCos2DeltaPhi(phi,evPlaneV0C)};
745 feTPCV2->Fill(correctedV2);
748 if(pidpassed==0) continue;
750 Double_t correctedV2[5]={cent,pt,GetCos2DeltaPhi(phi,evPlaneCorrTPC),GetCos2DeltaPhi(phi,evPlaneV0A),
751 GetCos2DeltaPhi(phi,evPlaneV0C)};
753 feV2->Fill(correctedV2);
754 fTrkEovPAft->Fill(pt,EovP);
755 fdEdxAft->Fill(p,dEdx);
757 if(fFlagPhotonicElec){
758 fphoteV2->Fill(correctedV2);
759 fPhotoElecPt->Fill(pt);
762 if(!fFlagPhotonicElec) fSemiInclElecPt->Fill(pt);
765 PostData(1, fOutputList);
767 //_________________________________________
768 void AliAnalysisTaskFlowTPCEMCalEP::UserCreateOutputObjects()
771 if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){
773 printf("+++++ MC Data available");
775 //--------Initialize PID
776 fPID->SetHasMCData(fIsMC);
778 if(!fPID->GetNumberOfPIDdetectors())
780 fPID->AddDetector("TPC", 0);
781 fPID->AddDetector("EMCAL", 1);
784 fPID->SortDetectors();
785 fPIDqa = new AliHFEpidQAmanager();
786 fPIDqa->Initialize(fPID);
788 //--------Initialize correction Framework and Cuts
789 fCFM = new AliCFManager;
790 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
791 fCFM->SetNStepParticle(kNcutSteps);
792 for(Int_t istep = 0; istep < kNcutSteps; istep++)
793 fCFM->SetParticleCutsList(istep, NULL);
796 AliWarning("Cuts not available. Default cuts will be used");
797 fCuts = new AliHFEcuts;
798 fCuts->CreateStandardCuts();
800 fCuts->Initialize(fCFM);
802 //---------Output Tlist
803 fOutputList = new TList();
804 fOutputList->SetOwner();
805 fOutputList->Add(fPIDqa->MakeList("PIDQA"));
807 fNoEvents = new TH1F("fNoEvents","",1,0,1) ;
808 fOutputList->Add(fNoEvents);
810 fTrkpt = new TH1F("fTrkpt","track pt",100,0,50);
811 fOutputList->Add(fTrkpt);
813 fTrackPtBefTrkCuts = new TH1F("fTrackPtBefTrkCuts","track pt before track cuts",100,0,50);
814 fOutputList->Add(fTrackPtBefTrkCuts);
816 fTrackPtAftTrkCuts = new TH1F("fTrackPtAftTrkCuts","track pt after track cuts",100,0,50);
817 fOutputList->Add(fTrackPtAftTrkCuts);
819 fTPCnsigma = new TH2F("fTPCnsigma", "TPC - n sigma",100,0,50,200,-10,10);
820 fOutputList->Add(fTPCnsigma);
822 fTrkEovPBef = new TH2F("fTrkEovPBef","track E/p before HFE pid",100,0,50,100,0,2);
823 fOutputList->Add(fTrkEovPBef);
825 fTrkEovPAft = new TH2F("fTrkEovPAft","track E/p after HFE pid",100,0,50,100,0,2);
826 fOutputList->Add(fTrkEovPAft);
828 fdEdxBef = new TH2F("fdEdxBef","track dEdx vs p before HFE pid",100,0,50,150,0,150);
829 fOutputList->Add(fdEdxBef);
831 fdEdxAft = new TH2F("fdEdxAft","track dEdx vs p after HFE pid",100,0,50,150,0,150);
832 fOutputList->Add(fdEdxAft);
834 fPhotoElecPt = new TH1F("fPhotoElecPt", "photonic electron pt",100,0,50);
835 fOutputList->Add(fPhotoElecPt);
837 fSemiInclElecPt = new TH1F("fSemiInclElecPt", "Semi-inclusive electron pt",100,0,50);
838 fOutputList->Add(fSemiInclElecPt);
840 fCent = new TH1F("fCent","Centrality",100,0,100) ;
841 fOutputList->Add(fCent);
843 fevPlaneV0A = new TH1F("fevPlaneV0A","V0A EP",100,0,TMath::Pi());
844 fOutputList->Add(fevPlaneV0A);
846 fevPlaneV0C = new TH1F("fevPlaneV0C","V0C EP",100,0,TMath::Pi());
847 fOutputList->Add(fevPlaneV0C);
849 fevPlaneV0 = new TH1F("fevPlaneV0","V0 EP",100,0,TMath::Pi());
850 fOutputList->Add(fevPlaneV0);
852 fevPlaneTPC = new TH1F("fevPlaneTPC","TPC EP",100,0,TMath::Pi());
853 fOutputList->Add(fevPlaneTPC);
855 fTPCsubEPres = new TH1F("fTPCsubEPres","TPC subevent plane resolution",100,-1,1);
856 fOutputList->Add(fTPCsubEPres);
858 Int_t binsv1[7]={100,100,100,100,100,100,90}; // V0A-V0C, V0A-TPC, V0C-TPC, V0-TPCpos, V0-TPCneg, TPCpos-TPCneg, cent
859 Double_t xminv1[7]={-1,-1,-1,-1,-1,-1,0};
860 Double_t xmaxv1[7]={1,1,1,1,1,1,90};
861 fEPres = new THnSparseD ("fEPres","EP resolution",7,binsv1,xminv1,xmaxv1);
862 fOutputList->Add(fEPres);
864 //phi,fTPCnSigma,cent,pt,EovP,GetDeltaPhi(phi,evPlaneV0),GetCos2DeltaPhi(phi,evPlaneV0), fFlagPhotonicElec, fFlagPhotonicElecBCG,m02,m20
865 Int_t binsv2[11]={100,200,90,100,100,100,100,3,3,100,100};
866 Double_t xminv2[11]={0,-5,0,0,0,0,-1,-1,-1,0,0};
867 Double_t xmaxv2[11]={2*TMath::Pi(),5,90,50,3,TMath::Pi(),1,2,2,1,1};
868 fCorr = new THnSparseD ("fCorr","Correlations",11,binsv2,xminv2,xmaxv2);
869 fOutputList->Add(fCorr);
871 Int_t binsv3[5]={90,100,100,100,100}; // cent, pt, TPCcos2DeltaPhi, V0Acos2DeltaPhi, V0Ccos2DeltaPhi
872 Double_t xminv3[5]={0,0,-1,-1,-1};
873 Double_t xmaxv3[5]={90,50,1,1,1};
874 feV2 = new THnSparseD ("feV2","inclusive electron v2",5,binsv3,xminv3,xmaxv3);
875 fOutputList->Add(feV2);
877 Int_t binsv4[5]={90,100,100,100,100}; // cent, pt, TPCdeltaPhi, V0AdeltaPhi, V0CdeltaPhi
878 Double_t xminv4[5]={0,0,-1,-1,-1};
879 Double_t xmaxv4[5]={90,50,1,1,1};
880 fphoteV2 = new THnSparseD ("fphoteV2","photonic electron v2",5,binsv4,xminv4,xmaxv4);
881 fOutputList->Add(fphoteV2);
883 Int_t binsv5[7]={100,90,100,100,100,100,100}; // phi, cent, pt, EovP, TPCdeltaPhi, V0AdeltaPhi, V0CdeltaPhi
884 Double_t xminv5[7]={0,0,0,0,-1,-1,-1};
885 Double_t xmaxv5[7]={2*TMath::Pi(),90,50,3,1,1,1};
886 fChargPartV2 = new THnSparseD ("fChargPartV2","Charged particle v2",7,binsv5,xminv5,xmaxv5);
887 fOutputList->Add(fChargPartV2);
889 Int_t binsv6[5]={90,100,100,100,100}; // cent, pt, TPCdeltaPhi, V0AdeltaPhi, V0CdeltaPhi
890 Double_t xminv6[5]={0,0,-1,-1,-1};
891 Double_t xmaxv6[5]={90,50,1,1,1};
892 feTPCV2 = new THnSparseD ("feTPCV2","inclusive electron v2 (TPC)",5,binsv6,xminv6,xmaxv6);
893 fOutputList->Add(feTPCV2);
895 //EovP,fTPCnSigma,partPt,fFlagPhotonicElec,fFlagPhotonicElecBCG,whichPart,cent,pt,firstMother,secondMother,thirdMother,iHijing,motherPt,secondMotherPt,thirdMotherPt
896 Int_t binsv7[15]={100,100,100,3,3,5,90,100,5,5,5,3,100,100,100};
897 Double_t xminv7[15]={0,-3.5,0,-1,-1,-1,0,0,-1,-1,-1,-1,0,0,0};
898 Double_t xmaxv7[15]={3,3.5,50,2,2,4,90,50,4,4,4,2,50,50,50};
899 fMCphotoElecPt = new THnSparseD ("fMCphotoElecPt", "pt distribution (MC)",15,binsv7,xminv7,xmaxv7);
900 fOutputList->Add(fMCphotoElecPt);
902 fGammaWeight = new TH2F("fGammaWeight", "Gamma weight",100,0,50,3,-1,2);
903 fOutputList->Add(fGammaWeight);
905 fPi0Weight = new TH2F("fPi0Weight", "Pi0 weight",100,0,50,3,-1,2);
906 fOutputList->Add(fPi0Weight);
908 fEtaWeight = new TH2F("fEtaWeight", "Eta weight",100,0,50,3,-1,2);
909 fOutputList->Add(fEtaWeight);
911 fD0Weight = new TH2F("fD0Weight", "D0 weight",100,0,50,3,-1,2);
912 fOutputList->Add(fD0Weight);
914 fDplusWeight = new TH2F("fDplusWeight", "D+ weight",100,0,50,3,-1,2);
915 fOutputList->Add(fDplusWeight);
917 fDminusWeight = new TH2F("fDminusWeight", "D- weight",100,0,50,3,-1,2);
918 fOutputList->Add(fDminusWeight);
920 fD0_e = new TH2F("fD0_e", "D0 vs e",100,0,50,200,-6.3,6.3);
921 fOutputList->Add(fD0_e);
923 for(Int_t k = 0; k < 6; k++) {
925 TString De_name = Form("fDe%d",k);
926 TString D0e_name = Form("fD0e%d",k);
927 TString Dpluse_name = Form("fDpluse%d",k);
928 TString Dminuse_name = Form("fDminuse%d",k);
930 fDe[k] = new TH1F((const char*)De_name,"",100,0,50);
931 fD0e[k] = new TH1F((const char*)D0e_name,"",100,0,50);
932 fDpluse[k] = new TH1F((const char*)Dpluse_name,"",100,0,50);
933 fDminuse[k] = new TH1F((const char*)Dminuse_name,"",100,0,50);
935 fOutputList->Add(fDe[k]);
936 fOutputList->Add(fD0e[k]);
937 fOutputList->Add(fDpluse[k]);
938 fOutputList->Add(fDminuse[k]);
943 double bin_v2[9] = {2,2.5,3,4,6,8,10,13,18};
945 fTot_pi0e = new TH1F("fTot_pi0e","fTot_pi0e",nbin_v2,bin_v2);
946 fOutputList->Add(fTot_pi0e);
948 fPhot_pi0e = new TH1F("fPhot_pi0e","fPhot_pi0e",nbin_v2,bin_v2);
949 fOutputList->Add(fPhot_pi0e);
951 fPhotBCG_pi0e = new TH1F("fPhotBCG_pi0e","fPhotBCG_pi0e",nbin_v2,bin_v2);
952 fOutputList->Add(fPhotBCG_pi0e);
954 fTot_etae = new TH1F("fTot_etae","fTot_etae",nbin_v2,bin_v2);
955 fOutputList->Add(fTot_etae);
957 fPhot_etae = new TH1F("fPhot_etae","fPhot_etae",nbin_v2,bin_v2);
958 fOutputList->Add(fPhot_etae);
960 fPhotBCG_etae = new TH1F("fPhotBCG_etae","fPhotBCG_etae",nbin_v2,bin_v2);
961 fOutputList->Add(fPhotBCG_etae);
963 fInvMass = new TH1F("fInvMass","",200,0,0.3);
964 fOutputList->Add(fInvMass);
966 fInvMassBack = new TH1F("fInvMassBack","",200,0,0.3);
967 fOutputList->Add(fInvMassBack);
969 fDCA = new TH1F("fDCA","",200,0,1);
970 fOutputList->Add(fDCA);
972 fDCABack = new TH1F("fDCABack","",200,0,1);
973 fOutputList->Add(fDCABack);
975 fOpAngle = new TH1F("fOpAngle","",200,0,0.5);
976 fOutputList->Add(fOpAngle);
978 fOpAngleBack = new TH1F("fOpAngleBack","",200,0,0.5);
979 fOutputList->Add(fOpAngleBack);
981 PostData(1,fOutputList);
984 //________________________________________________________________________
985 void AliAnalysisTaskFlowTPCEMCalEP::Terminate(Option_t *)
987 // Info("Terminate");
988 AliAnalysisTaskSE::Terminate();
991 //________________________________________________________________________
992 Bool_t AliAnalysisTaskFlowTPCEMCalEP::ProcessCutStep(Int_t cutStep, AliVParticle *track)
994 // Check single track cuts for a given cut step
995 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
996 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
999 //_________________________________________
1000 Double_t AliAnalysisTaskFlowTPCEMCalEP::GetCos2DeltaPhi(Double_t phiA,Double_t phiB) const
1002 //Get cos[2(phi-psi_EP)] or cos[2(psi_subEP1 - psi_subEP2)]
1003 Double_t dPhi = TVector2::Phi_0_2pi(phiA - phiB);
1004 if(dPhi > TMath::Pi()) dPhi = dPhi - TMath::Pi();
1005 Double_t cos2DeltaPhi = TMath::Cos(2*dPhi);
1007 return cos2DeltaPhi;
1009 //_________________________________________
1010 Double_t AliAnalysisTaskFlowTPCEMCalEP::GetDeltaPhi(Double_t phiA,Double_t phiB) const
1013 Double_t dPhi = TVector2::Phi_0_2pi(phiA - phiB);
1014 if(dPhi > TMath::Pi()) dPhi = dPhi - TMath::Pi();
1018 //_________________________________________
1019 Double_t AliAnalysisTaskFlowTPCEMCalEP::GetPi0weight(Double_t mcPi0pT, Float_t cent) const
1022 double weight = 1.0;
1024 if(mcPi0pT>0.0 && mcPi0pT<5.0){
1025 if (cent>20.0 && cent<40.0) weight = (2.877091*mcPi0pT)/(TMath::Power(0.706963+mcPi0pT/3.179309,17.336628)*exp(-mcPi0pT));
1026 if (cent>30.0 && cent<50.0) weight = (2.392024*mcPi0pT)/(TMath::Power(0.688810+mcPi0pT/3.005145,16.811845)*exp(-mcPi0pT));
1029 if (cent>20.0 && cent<40.0) weight = (0.0004*mcPi0pT)/TMath::Power(-0.176181+mcPi0pT/3.989747,5.629235);
1030 if (cent>30.0 && cent<50.0) weight = (0.000186*mcPi0pT)/TMath::Power(-0.606279+mcPi0pT/3.158642,4.365540);
1034 //_________________________________________
1035 Double_t AliAnalysisTaskFlowTPCEMCalEP::GetEtaweight(Double_t mcEtapT, Float_t cent) const
1038 double weight = 1.0;
1040 if (cent>20.0 && cent<40.0) weight = (0.818052*mcEtapT)/(TMath::Power(0.358651+mcEtapT/2.878631,9.494043));
1041 if (cent>30.0 && cent<50.0) weight = (0.622703*mcEtapT)/(TMath::Power(0.323045+mcEtapT/2.736407,9.180356));
1044 //_________________________________________
1045 Double_t AliAnalysisTaskFlowTPCEMCalEP::GetDweight(Int_t whichD, Double_t mcDpT, Float_t cent) const
1048 double weight = 1.0;
1050 if (cent>30.0 && cent<50.0){
1051 if (whichD == 0) weight = 0.271583*TMath::Landau(mcDpT,3.807103,1.536753,0); // D
1052 if (whichD == 1) weight = 0.300771*TMath::Landau(mcDpT,3.725771,1.496980,0); // D0
1053 if (whichD == 2) weight = 0.247280*TMath::Landau(mcDpT,3.746811,1.607551,0); // D+
1054 if (whichD == 3) weight = 0.249410*TMath::Landau(mcDpT,3.611508,1.632196,0); //D-
1058 //_________________________________________
1059 void AliAnalysisTaskFlowTPCEMCalEP::InitParameters()
1063 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
1064 fTrackCuts->SetRequireTPCRefit(kTRUE);
1065 fTrackCuts->SetRequireITSRefit(kTRUE);
1066 fTrackCuts->SetEtaRange(-0.7,0.7);
1067 fTrackCuts->SetRequireSigmaToVertex(kTRUE);
1068 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
1069 fTrackCuts->SetMinNClustersTPC(100);
1070 fTrackCuts->SetPtRange(0.5,100);
1072 fNonHFE->SetAODanalysis(kFALSE);
1073 fNonHFE->SetInvariantMassCut(fInvmassCut);
1074 fNonHFE->SetOpeningAngleCut(fOpeningAngleCut);
1075 fNonHFE->SetChi2OverNDFCut(fChi2Cut);
1076 fNonHFE->SetAlgorithm(fnonHFEalgorithm); //KF or DCA
1077 if (fnonHFEalgorithm == "DCA") fNonHFE->SetDCACut(fDCAcut);
1078 fNonHFE->SetTrackCuts(-3.5,3.5,fTrackCuts);