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 with EMCal triggered events
17 // Author: Shingo Sakai
26 #include "THnSparse.h"
27 #include "TLorentzVector.h"
30 #include "TGraphErrors.h"
32 #include "TDatabasePDG.h"
34 #include "AliAnalysisTask.h"
35 #include "AliAnalysisManager.h"
37 #include "AliESDEvent.h"
38 #include "AliESDHandler.h"
39 #include "AliAODEvent.h"
40 #include "AliAODHandler.h"
42 #include "AliMCEventHandler.h"
43 #include "AliMCEvent.h"
44 #include "AliMCParticle.h"
46 #include "AliAnalysisTaskHFECal.h"
47 #include "TGeoGlobalMagField.h"
49 #include "AliAnalysisTaskSE.h"
50 #include "TRefArray.h"
52 #include "AliESDInputHandler.h"
53 #include "AliESDpid.h"
54 #include "AliESDtrackCuts.h"
55 #include "AliPhysicsSelection.h"
56 #include "AliESDCaloCluster.h"
57 #include "AliAODCaloCluster.h"
58 #include "AliEMCALRecoUtils.h"
59 #include "AliEMCALGeometry.h"
60 #include "AliGeomManager.h"
62 #include "TGeoManager.h"
66 #include "AliEMCALTrack.h"
69 #include "AliKFParticle.h"
70 #include "AliKFVertex.h"
73 #include "AliPIDResponse.h"
74 #include "AliHFEcontainer.h"
75 #include "AliHFEcuts.h"
76 #include "AliHFEpid.h"
77 #include "AliHFEpidBase.h"
78 #include "AliHFEpidQAmanager.h"
79 #include "AliHFEtools.h"
80 #include "AliCFContainer.h"
81 #include "AliCFManager.h"
85 #include "AliCentrality.h"
89 ClassImp(AliAnalysisTaskHFECal)
90 //________________________________________________________________________
91 AliAnalysisTaskHFECal::AliAnalysisTaskHFECal(const char *name)
92 : AliAnalysisTaskSE(name)
101 ,fIdentifiedAsOutInz(kFALSE)
102 ,fPassTheEventCut(kFALSE)
103 ,fRejectKinkMother(kFALSE)
109 ,fOpeningAngleCut(0.1)
112 ,fInvmassCut(0) // no mass
113 ,fSetMassConstraint(kTRUE)
114 ,fSetMassWidthCut(kFALSE)
115 ,fSetMassNonlinear(kFALSE)
149 ,fTrackPtBefTrkCuts(0)
150 ,fTrackPtAftTrkCuts(0)
172 ,fIncpTMCM20hfeAll(0)
173 ,fIncpTMCM20hfeCheck(0)
174 ,fInputHFEMC_weight(0)
175 ,fIncpTMCM20hfeCheck_weight(0)
182 ,fIncpTMCM20pho_pi0e(0)
183 ,fPhoElecPtMCM20_pi0e(0)
184 ,fSameElecPtMCM20_pi0e(0)
185 ,fIncpTMCM20pho_eta(0)
186 ,fPhoElecPtMCM20_eta(0)
187 ,fSameElecPtMCM20_eta(0)
188 ,fIncpTMCpho_pi0e_TPC(0)
189 ,fPhoElecPtMC_pi0e_TPC(0)
190 ,fSameElecPtMC_pi0e_TPC(0)
191 ,fIncpTMCpho_eta_TPC(0)
192 ,fPhoElecPtMC_eta_TPC(0)
193 ,fSameElecPtMC_eta_TPC(0)
216 ,fPhoVertexReco_HFE(0)
217 ,fPhoVertexReco_EMCal(0)
218 ,fPhoVertexReco_Invmass(0)
219 ,fPhoVertexReco_step0(0)
220 ,fPhoVertexReco_step1(0)
221 ,fPhoVertexReco_step2(0)
222 ,fPhoVertexReco_step3(0)
223 ,fPhoVertexReco_step4(0)
224 ,fPhoVertexReco_step5(0)
229 //,fnSigEtaCorr(NULL)
233 fPID = new AliHFEpid("hfePid");
234 fTrackCuts = new AliESDtrackCuts();
236 for(int i=0; i<7; i++)fnSigEtaCorr[i] = 0;
238 // Define input and output slots here
239 // Input slot #0 works with a TChain
240 DefineInput(0, TChain::Class());
241 // Output slot #0 id reserved by the base class for AOD
242 // Output slot #1 writes into a TH1 container
243 // DefineOutput(1, TH1I::Class());
244 DefineOutput(1, TList::Class());
245 // DefineOutput(3, TTree::Class());
248 //________________________________________________________________________
249 AliAnalysisTaskHFECal::AliAnalysisTaskHFECal()
250 : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskHFECal")
259 ,fIdentifiedAsOutInz(kFALSE)
260 ,fPassTheEventCut(kFALSE)
261 ,fRejectKinkMother(kFALSE)
267 ,fOpeningAngleCut(0.1)
270 ,fInvmassCut(0) // no mass
271 ,fSetMassConstraint(kTRUE)
272 ,fSetMassWidthCut(kFALSE)
273 ,fSetMassNonlinear(kFALSE)
307 ,fTrackPtBefTrkCuts(0)
308 ,fTrackPtAftTrkCuts(0)
330 ,fIncpTMCM20hfeAll(0)
331 ,fIncpTMCM20hfeCheck(0)
332 ,fInputHFEMC_weight(0)
333 ,fIncpTMCM20hfeCheck_weight(0)
340 ,fIncpTMCM20pho_pi0e(0)
341 ,fPhoElecPtMCM20_pi0e(0)
342 ,fSameElecPtMCM20_pi0e(0)
343 ,fIncpTMCM20pho_eta(0)
344 ,fPhoElecPtMCM20_eta(0)
345 ,fSameElecPtMCM20_eta(0)
346 ,fIncpTMCpho_pi0e_TPC(0)
347 ,fPhoElecPtMC_pi0e_TPC(0)
348 ,fSameElecPtMC_pi0e_TPC(0)
349 ,fIncpTMCpho_eta_TPC(0)
350 ,fPhoElecPtMC_eta_TPC(0)
351 ,fSameElecPtMC_eta_TPC(0)
374 ,fPhoVertexReco_HFE(0)
375 ,fPhoVertexReco_EMCal(0)
376 ,fPhoVertexReco_Invmass(0)
377 ,fPhoVertexReco_step0(0)
378 ,fPhoVertexReco_step1(0)
379 ,fPhoVertexReco_step2(0)
380 ,fPhoVertexReco_step3(0)
381 ,fPhoVertexReco_step4(0)
382 ,fPhoVertexReco_step5(0)
387 //,fnSigEtaCorr(NULL)
389 //Default constructor
390 fPID = new AliHFEpid("hfePid");
392 fTrackCuts = new AliESDtrackCuts();
394 for(int i=0; i<7; i++)fnSigEtaCorr[i] = 0;
397 // Define input and output slots here
398 // Input slot #0 works with a TChain
399 DefineInput(0, TChain::Class());
400 // Output slot #0 id reserved by the base class for AOD
401 // Output slot #1 writes into a TH1 container
402 // DefineOutput(1, TH1I::Class());
403 DefineOutput(1, TList::Class());
404 //DefineOutput(3, TTree::Class());
406 //_________________________________________
408 AliAnalysisTaskHFECal::~AliAnalysisTaskHFECal()
420 //_________________________________________
422 void AliAnalysisTaskHFECal::UserExec(Option_t*)
425 //Called for each event
427 // create pointer to event
428 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
430 printf("ERROR: fESD not available\n");
435 AliError("HFE cuts not available");
439 if(!fPID->IsInitialized()){
440 // Initialize PID with the given run number
441 AliWarning("PID not initialised, get from Run no");
442 fPID->InitializePID(fESD->GetRunNumber());
445 if(fmcData)fMC = MCEvent();
446 //AliStack* stack = NULL;
447 if(fmcData && fMC)stack = fMC->Stack();
450 AliCentrality *centrality = fESD->GetCentrality();
451 cent = centrality->GetCentralityPercentile("V0M");
453 //---- fill MC track info
456 Int_t nParticles = stack->GetNtrack();
457 for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
458 TParticle* particle = stack->Particle(iParticle);
459 int fPDG = particle->GetPdgCode();
460 double mcZvertex = fMC->GetPrimaryVertex()->GetZ();
461 double pTMC = particle->Pt();
462 double proR = particle->R();
463 double etaMC = particle->Eta();
464 if(fabs(etaMC)>0.6)continue;
465 Bool_t mcInDtoE= kFALSE;
466 Bool_t mcInBtoE= kFALSE;
468 Bool_t MChijing = fMC->IsFromBGEvent(iParticle);
469 //if(!MChijing)printf("not MC hijing");
471 if(!MChijing)iHijing = 0;
475 mcphoinfo[2] = iHijing;
476 if(fPDG==111)Hpi0pTcheck->Fill(mcphoinfo);
477 if(fPDG==221)HETApTcheck->Fill(mcphoinfo);
478 if(fabs(fPDG)==411 || fabs(fPDG)==413 || fabs(fPDG)==421 || fabs(fPDG)==423 || fabs(fPDG)==431)HDpTcheck->Fill(pTMC,iHijing);
479 if(fabs(fPDG)==511 || fabs(fPDG)==513 || fabs(fPDG)==521 || fabs(fPDG)==523 || fabs(fPDG)==531)HBpTcheck->Fill(pTMC,iHijing);
481 if(particle->GetFirstMother()>-1 && fPDG==22)
483 int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
484 if(parentPID==111 || parentPID==221)HphopTcheck->Fill(pTMC,iHijing); // pi0->g & eta->g
487 if(particle->GetFirstMother()>-1 && fabs(fPDG)==11)
489 int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
490 double pTMCparent = stack->Particle(particle->GetFirstMother())->Pt();
491 if((fabs(parentPID)==411 || fabs(parentPID)==413 || fabs(parentPID)==421 || fabs(parentPID)==423 || fabs(parentPID)==431)&& fabs(fPDG)==11)mcInDtoE = kTRUE;
492 if((fabs(parentPID)==511 || fabs(parentPID)==513 || fabs(parentPID)==521 || fabs(parentPID)==523 || fabs(parentPID)==531)&& fabs(fPDG)==11)mcInBtoE = kTRUE;
493 if((mcInBtoE || mcInDtoE) && fabs(mcZvertex)<10.0)
495 fInputHFEMC->Fill(cent,pTMC);
501 mcinfo[4] = pTMCparent;
502 fInputHFEMC_weight->Fill(mcinfo);
507 if(proR<7.0 && fabs(fPDG)==11)fInputAlle->Fill(cent,pTMC);
514 Int_t fNOtrks = fESD->GetNumberOfTracks();
515 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
517 Double_t pVtxZ = -999;
518 pVtxZ = pVtx->GetZ();
520 if(TMath::Abs(pVtxZ)>10) return;
523 if(fNOtrks<1) return;
526 AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse();
528 AliDebug(1, "Using default PID Response");
529 pidResponse = AliHFEtools::GetDefaultPID(kFALSE, fInputEvent->IsA() == AliAODEvent::Class());
532 fPID->SetPIDResponse(pidResponse);
534 fCFM->SetRecEventInfo(fESD);
538 //if(cent>90.) return;
542 FindTriggerClusters();
546 for(Int_t iCluster=0; iCluster<fESD->GetNumberOfCaloClusters(); iCluster++)
548 AliESDCaloCluster *clust = fESD->GetCaloCluster(iCluster);
549 if(clust && clust->IsEMCAL())
551 double clustE = clust->E();
552 float emcx[3]; // cluster pos
553 clust->GetPosition(emcx);
554 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
555 double emcphi = clustpos.Phi();
556 double emceta = clustpos.Eta();
558 calInfo[0] = emcphi; calInfo[1] = emceta; calInfo[2] = clustE; calInfo[3] = cent; calInfo[4] = clust->Chi2();
559 //fEMCAccE->Fill(calInfo);
560 hEMCAccE->Fill(cent,clustE);
561 if(clustE>maxE)maxE = clustE;
566 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
567 AliESDtrack* track = fESD->GetTrack(iTracks);
569 printf("ERROR: Could not receive track %d\n", iTracks);
573 //--- Get MC informtion
575 int parentlabel = 99999;
576 int parentPID = 99999;
577 int grand_parentlabel = 99999;
578 int grand_parentPID = 99999;
579 Bool_t mcPho = kFALSE;
580 Bool_t mcDtoE= kFALSE;
581 Bool_t mcBtoE= kFALSE;
582 Bool_t mcOrgPi0 = kFALSE;
583 Bool_t mcOrgEta = kFALSE;
586 double mcMompT = 0.0;
587 //double mcGrandMompT = 0.0;
588 double mcWeight = -10.0;
589 double conv_proR = -1.0;
594 if(fmcData && fMC && stack)
596 Int_t label = TMath::Abs(track->GetLabel());
597 mcLabel = track->GetLabel();
602 Bool_t MChijing = fMC->IsFromBGEvent(label);
603 if(!MChijing)iHijing = 0;
605 TParticle* particle = stack->Particle(label);
606 int mcpid = particle->GetPdgCode();
607 mcpT = particle->Pt();
608 conv_proR = particle->R();
609 //printf("MCpid = %d",mcpid);
610 if(particle->GetFirstMother()>-1)
612 //int parentlabel = particle->GetFirstMother();
613 //int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
614 //mcMompT = stack->Particle(particle->GetFirstMother())->Pt();
615 FindMother(particle, parentlabel, parentPID);
616 mcMompT = stack->Particle(parentlabel)->Pt();
617 if((parentPID==22 || parentPID==111 || parentPID==221)&& fabs(mcpid)==11)mcPho = kTRUE;
618 if((fabs(parentPID)==411 || fabs(parentPID)==413 || fabs(parentPID)==421 || fabs(parentPID)==423 || fabs(parentPID)==431)&& fabs(mcpid)==11)mcDtoE = kTRUE;
619 if((fabs(parentPID)==511 || fabs(parentPID)==513 || fabs(parentPID)==521 || fabs(parentPID)==523 || fabs(parentPID)==531)&& fabs(mcpid)==11)mcBtoE = kTRUE;
621 // make D->e pT correlation
622 if(mcDtoE)fMomDtoE->Fill(mcpT,mcMompT);
624 //cout << "check PID = " << parentPID << endl;
625 //cout << "check pho = " << mcPho << endl;
626 //cout << "check D or B = " << mcDtoE << endl;
628 if(parentPID==111 && fabs(mcpid)==11 && mcMompT>0.0)
630 //cout << "find pi0->e " << endl;
632 mcWeight = GetMCweight(mcMompT);
635 if(parentPID==221 && fabs(mcpid)==11 && mcMompT>0.0)
637 //cout << "find Eta->e " << endl;
639 mcWeight = GetMCweightEta(mcMompT);
642 // access grand parent
643 TParticle* particle_parent = stack->Particle(parentlabel); // get parent pointer
644 //if(particle_parent->GetFirstMother()>-1 && parentPID==22 && fabs(mcpid)==11) // get grand parent g->e
645 if(particle_parent->GetFirstMother()>-1 && (parentPID==22 || parentPID==111) && fabs(mcpid)==11) // get grand parent g->e
647 //int grand_parentPID = stack->Particle(particle_parent->GetFirstMother())->GetPdgCode();
648 //double pTtmp = stack->Particle(particle_parent->GetFirstMother())->Pt();
649 FindMother(particle_parent, grand_parentlabel, grand_parentPID);
650 double mcGrandpT = stack->Particle(grand_parentlabel)->Pt();
651 if(grand_parentPID==111 && mcGrandpT>0.0)
653 // check eta->pi0 decay !
654 int grand2_parentlabel = 99999; int grand2_parentPID = 99999;
655 TParticle* particle_grand = stack->Particle(grand_parentlabel); // get parent pointer
656 FindMother(particle_grand, grand2_parentlabel, grand2_parentPID);
657 if(grand2_parentPID==221)
659 //cout << "find Eta->e " << endl;
660 double mcGrandpT2 = stack->Particle(grand2_parentlabel)->Pt();
662 mcWeight = GetMCweight(mcGrandpT2);
663 mcMompT = mcGrandpT2;
667 //cout << "find pi0->e " << endl;
669 mcWeight = GetMCweight(mcGrandpT);
674 if(grand_parentPID==221 && mcGrandpT>0.0)
676 //cout << "find Eta->e " << endl;
679 mcWeight = GetMCweightEta(mcGrandpT);
685 //cout << "===================="<<endl;
686 //cout << "mcDtoE : " << mcDtoE << endl;
687 //cout << "mcBtoE : " << mcBtoE << endl;
688 //cout << "mcPho : " << mcPho << endl;
690 if(fabs(mcpid)==11)mcele= 0.;
691 //cout << "check e: " << mcele << endl;
692 if(fabs(mcpid)==11 && mcDtoE)mcele= 1.;
693 //cout << "check D->e: " << mcele << endl;
694 if(fabs(mcpid)==11 && mcBtoE)mcele= 2.;
695 //cout << "check B->e: " << mcele << endl;
696 if(fabs(mcpid)==11 && mcPho)mcele= 3.;
697 //cout << "check Pho->e: " << mcele << endl;
699 //cout << "check PID " << endl;
702 //cout << "!= 11" << endl;
703 //cout << mcpid << endl;
707 //cout << "mcele==-1" << endl;
708 //cout << mcele << endl;
709 //cout << mcpid << endl;
712 } // end of mcLabel>-1
714 } // <------ end of MC info.
716 //cout << "Pi0 = " << mcOrgPi0 << " ; Eta = " << mcOrgEta << endl;
717 //printf("weight = %f\n",mcWeight);
719 if(TMath::Abs(track->Eta())>0.6) continue;
720 //if(TMath::Abs(track->Pt()<2.5)) continue;
721 if(TMath::Abs(track->Pt()<0.1)) continue;
723 int nITS = track->GetNcls(0);
725 fTrackPtBefTrkCuts->Fill(track->Pt());
728 UChar_t itsPixel = track->GetITSClusterMap();
729 cout << "nITS = " << nITS << endl;
730 if(itsPixel & BIT(0))cout << "1st layer hit" << endl;
731 if(itsPixel & BIT(1))cout << "2nd layer hit" << endl;
732 if(itsPixel & BIT(2))cout << "3rd layer hit" << endl;
733 if(itsPixel & BIT(3))cout << "4th layer hit" << endl;
734 if(itsPixel & BIT(4))cout << "5th layer hit" << endl;
737 if(mcPho)fPhoVertexReco_step0->Fill(track->Pt(),conv_proR); // check MC vertex
739 // RecKine: ITSTPC cuts
740 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
741 if(mcPho && iHijing==1)fPhoVertexReco_step1->Fill(track->Pt(),conv_proR); // check MC vertex
744 if(fRejectKinkMother) { // Quick and dirty fix to reject both kink mothers and daughters
745 if(track->GetKinkIndex(0) != 0) continue;
747 if(mcPho && iHijing==1)fPhoVertexReco_step2->Fill(track->Pt(),conv_proR); // check MC vertex
750 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
751 if(mcPho && iHijing==1)fPhoVertexReco_step3->Fill(track->Pt(),conv_proR); // check MC vertex
753 // HFEcuts: ITS layers cuts
754 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
755 if(mcPho && iHijing==1)fPhoVertexReco_step4->Fill(track->Pt(),conv_proR); // check MC vertex
757 // HFE cuts: TPC PID cleanup
758 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
759 if(mcPho && iHijing==1)fPhoVertexReco_step5->Fill(track->Pt(),conv_proR); // check MC vertex
761 int nTPCcl = track->GetTPCNcls();
762 //int nTPCclF = track->GetTPCNclsF(); // warnings
763 //int nITS = track->GetNcls(0);
765 if(mcPho && iHijing==1)fPhoVertexReco_HFE->Fill(track->Pt(),conv_proR); // check MC vertex
767 fTrackPtAftTrkCuts->Fill(track->Pt());
769 Double_t mom = -999., eop=-999., pt = -999., dEdx=-999., fTPCnSigma=-10, phi=-999., eta=-999.;
771 //if(pt<2.5)continue;
774 //Int_t charge = track->Charge();
781 track->GetImpactParameters(dca_xy,dca_z);
783 dEdx = track->GetTPCsignal();
784 fTPCnSigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron) : 1000;
786 //cout << "nSigma correctoon-----" << endl;
787 //cout << "org = " << fTPCnSigma << endl;
789 if(!fmcData) // nsigma eta correction
791 double nSigexpCorr = NsigmaCorrection(eta,cent);
792 fTPCnSigma -= nSigexpCorr;
795 //cout << "correction = " << fTPCnSigma << endl;
797 //--- track cluster match
799 double ncells = -1.0;
803 double rmatch = -1.0;
804 double nmatch = -1.0;
805 //double oppstatus = 0.0;
807 Bool_t MaxEmatch = kFALSE;
809 Int_t clsId = track->GetEMCALcluster();
811 AliESDCaloCluster *clust = fESD->GetCaloCluster(clsId);
812 if(clust && clust->IsEMCAL()){
814 double clustE = clust->E();
815 if(clustE==maxE)MaxEmatch = kTRUE;
816 eop = clustE/fabs(mom);
818 //double clustT = clust->GetTOF();
819 ncells = clust->GetNCells();
820 m02 = clust->GetM02();
821 m20 = clust->GetM20();
822 disp = clust->GetDispersion();
823 double delphi = clust->GetTrackDx();
824 double deleta = clust->GetTrackDz();
825 rmatch = sqrt(pow(delphi,2)+pow(deleta,2));
826 nmatch = clust->GetNTracksMatched();
827 emctof = clust->GetTOF();
828 //cout << "emctof = " << emctof << endl;
829 cout << "eop org = "<< eop << endl;
833 double mceopcorr = MCEopMeanCorrection(pt,cent);
836 cout << "eop corr = " << eop << endl;
839 valdedx[0] = pt; valdedx[1] = nITS; valdedx[2] = phi; valdedx[3] = eta; valdedx[4] = fTPCnSigma;
840 //valdedx[5] = eop; valdedx[6] = rmatch; valdedx[7] = ncells, valdedx[8] = nmatch; valdedx[9] = m20; valdedx[10] = mcpT;
841 valdedx[5] = eop; valdedx[6] = rmatch; valdedx[7] = dca_xy, valdedx[8] = dca_z; valdedx[9] = m20; valdedx[10] = mcpT;
842 valdedx[11] = cent; valdedx[12] = dEdx; valdedx[13] = eoporg; valdedx[14] = nTPCcl;
844 fEleInfo->Fill(valdedx);
849 //Get Cal info PID response
853 Double_t nSigmaEop = fPID->GetPIDResponse()->NumberOfSigmasEMCAL(track,AliPID::kElectron,eop2,ss);
854 if(fTPCnSigma>-1.5 && fTPCnSigma<3.0 && nITS>2.5 && nTPCcl>100)
859 valEop[2] = nSigmaEop;
860 fElenSigma->Fill(valEop);
863 // --- tarck cut & e ID
865 if(nITS<2.5)continue;
866 if(nTPCcl<100)continue;
868 CheckNclust->Fill(nTPCcl);
869 CheckNits->Fill(nITS);
870 CheckDCA->Fill(dca_xy,dca_z);
871 // check production vertex of photons
874 fdEdxBef->Fill(mom,fTPCnSigma);
875 fTPCnsigma->Fill(mom,fTPCnSigma);
876 if(fTPCnSigma >= -1.0 && fTPCnSigma <= 3)fTrkEovPBef->Fill(pt,eop);
878 //--- track accepted by HFE
881 AliHFEpidObject hfetrack;
882 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
883 hfetrack.SetRecTrack(track);
885 if((0.0< cent) && (cent<5.0)) binct = 0.5;
886 if((5.0< cent) && (cent<10.0)) binct = 1.5;
887 if((10.0< cent) && (cent<20.0)) binct = 2.5;
888 if((20.0< cent) && (cent<30.0)) binct = 3.5;
889 if((30.0< cent) && (cent<40.0)) binct = 4.5;
890 if((40.0< cent) && (cent<50.0)) binct = 5.5;
891 if((50.0< cent) && (cent<60.0)) binct = 6.5;
892 if((60.0< cent) && (cent<70.0)) binct = 7.5;
893 if((70.0< cent) && (cent<80.0)) binct = 8.5;
894 if((80.0< cent) && (cent<90.0)) binct = 9.5;
895 if((90.0< cent) && (cent<100.0)) binct = 10.5;
897 hfetrack.SetCentrality((int)binct); //added
899 if(!fPID->IsSelected(&hfetrack, NULL, "", fPIDqa)) pidpassed = 0;
901 if(pidpassed==0) continue; // nSigma rejection
905 Bool_t fFlagPhotonicElec = kFALSE;
906 Bool_t fFlagConvinatElec = kFALSE;
910 SelectPhotonicElectron(iTracks,cent,track,fFlagPhotonicElec,fFlagConvinatElec,fTPCnSigma,m20,eop,mcele,mcWeight,iHijing,mcOrgPi0,mcOrgEta);
914 SelectPhotonicElectron2(iTracks,cent,track,fFlagPhotonicElec,fFlagConvinatElec,fTPCnSigma,m20,eop,mcele,mcWeight,iHijing,mcOrgPi0,mcOrgEta);
917 //--- check reco eff. with TPC
921 phoval[2] = fTPCnSigma;
925 //if((fTPCnSigma >= -5.0 && fTPCnSigma <= 5) && mcele>-1 && mcPho && mcOrgPi0)
926 if((fTPCnSigma >= -5.0 && fTPCnSigma <= 5) && (mcOrgPi0 || mcOrgEta))
928 if(iHijing==1)mcWeight = 1.0;
931 fIncpTMCpho_pi0e_TPC->Fill(phoval,mcWeight);
932 if(fFlagPhotonicElec) fPhoElecPtMC_pi0e_TPC->Fill(phoval,mcWeight);
933 if(fFlagConvinatElec) fSameElecPtMC_pi0e_TPC->Fill(phoval,mcWeight);
937 fIncpTMCpho_eta_TPC->Fill(phoval,mcWeight);
938 if(fFlagPhotonicElec) fPhoElecPtMC_eta_TPC->Fill(phoval,mcWeight);
939 if(fFlagConvinatElec) fSameElecPtMC_eta_TPC->Fill(phoval,mcWeight);
944 double emcphimim = 1.396;
945 double emcphimax = 3.14;
946 if(phi>emcphimim && phi<emcphimax)
948 if(eop<-900)//no matching
950 if(fFlagPhotonicElec)fMatchV0_0->Fill(pt); // data
951 if(mcele>-0.5)fMatchMC_0->Fill(pt); // MC
955 if(fFlagPhotonicElec)fMatchV0_1->Fill(pt);
956 if(mcele>-0.5)fMatchMC_1->Fill(pt);
960 //+++++++ E/p cut ++++++++++++++++
962 if(eop<0.9 || eop>1.3)continue;
964 fTrkEovPAft->Fill(pt,eop);
965 fdEdxAft->Fill(mom,fTPCnSigma);
968 fIncpT->Fill(cent,pt);
969 if(fFlagPhotonicElec) fPhoElecPt->Fill(cent,pt);
970 if(fFlagConvinatElec) fSameElecPt->Fill(cent,pt);
972 if(m20>0.0 && m20<0.3)
974 fIncpTM20->Fill(cent,pt);
975 ftimingEle->Fill(pt,emctof);
976 if(fFlagPhotonicElec) fPhoElecPtM20->Fill(cent,pt);
977 if(fFlagConvinatElec) fSameElecPtM20->Fill(cent,pt);
978 if(!fFlagPhotonicElec) fSemiElecPtM20->Fill(cent,pt);
983 // check label for electron candidiates
986 if(mcLabel==0)idlabel = 0;
987 fLabelCheck->Fill(pt,idlabel);
988 if(mcLabel==0)fgeoFake->Fill(phi,eta);
990 if(mcLabel<0 && m20>0.0 && m20<0.3 && fTPCnSigma>-1 && fTPCnSigma<3)
992 fFakeTrk0->Fill(cent,pt);
995 if(mcele>-1) // select MC electrons
998 fIncpTMChfeAll->Fill(cent,pt);
999 if(m20>0.0 && m20<0.3)fIncpTMCM20hfeAll->Fill(cent,pt);
1000 if(m20>0.0 && m20<0.3 && fTPCnSigma>-1 && fTPCnSigma<3)fFakeTrk1->Fill(cent,pt);
1002 if(mcBtoE || mcDtoE) // select B->e & D->e
1004 fIncpTMChfe->Fill(cent,pt);
1005 if(m20>0.0 && m20<0.3)
1007 //cout << "MC label = " << mcLabel << endl;
1008 fIncpTMCM20hfe->Fill(cent,pt);
1009 fIncpTMCM20hfeCheck->Fill(cent,mcpT);
1010 fIncpTMCM20hfeCheck_weight->Fill(phoval);
1014 if(mcPho) // select photonic electrons
1017 fIncpTMCpho->Fill(phoval);
1018 if(fFlagPhotonicElec) fPhoElecPtMC->Fill(phoval);
1019 if(fFlagConvinatElec) fSameElecPtMC->Fill(phoval);
1021 if(m20>0.0 && m20<0.3)
1023 fIncpTMCM20pho->Fill(phoval);
1024 if(fFlagPhotonicElec) fPhoElecPtMCM20->Fill(phoval);
1025 if(fFlagConvinatElec) fSameElecPtMCM20->Fill(phoval);
1029 if(iHijing==1)mcWeight = 1.0;
1032 fIncpTMCM20pho_pi0e->Fill(phoval,mcWeight);
1033 if(fFlagPhotonicElec) fPhoElecPtMCM20_pi0e->Fill(phoval,mcWeight);
1034 if(fFlagConvinatElec) fSameElecPtMCM20_pi0e->Fill(phoval,mcWeight);
1036 // check production vertex
1037 fPhoVertexReco_EMCal->Fill(track->Pt(),conv_proR);
1038 if(fFlagPhotonicElec)fPhoVertexReco_Invmass->Fill(track->Pt(),conv_proR);
1044 fIncpTMCM20pho_eta->Fill(phoval,mcWeight);
1045 if(fFlagPhotonicElec) fPhoElecPtMCM20_eta->Fill(phoval,mcWeight);
1046 if(fFlagConvinatElec) fSameElecPtMCM20_eta->Fill(phoval,mcWeight);
1048 // check production vertex
1054 PostData(1, fOutputList);
1056 //_________________________________________
1057 void AliAnalysisTaskHFECal::UserCreateOutputObjects()
1061 //Bool_t mcData = kFALSE;
1062 if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())
1065 printf("+++++ MC Data available");
1069 printf("++++++++= MC analysis \n");
1073 printf("++++++++ real data analysis \n");
1076 printf("+++++++ QA hist %d",fqahist);
1079 fGeom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
1081 //--------Initialize PID
1082 //fPID->SetHasMCData(kFALSE);
1083 fPID->SetHasMCData(fmcData);
1084 if(!fPID->GetNumberOfPIDdetectors())
1086 fPID->AddDetector("TPC", 0);
1087 //fPID->AddDetector("EMCAL", 1); <--- apply PID selection in task
1091 const char *cutmodel;
1093 params[0] = -1.0; //sigma min
1094 double maxnSig = 3.0;
1097 params[0] = -5.0; //sigma min
1101 for(Int_t a=0;a<11;a++)fPID->ConfigureTPCcentralityCut(a,cutmodel,params,maxnSig);
1103 fPID->SortDetectors();
1104 fPIDqa = new AliHFEpidQAmanager();
1105 fPIDqa->Initialize(fPID);
1107 //------- fcut --------------
1108 fCuts = new AliHFEcuts();
1109 fCuts->CreateStandardCuts();
1110 //fCuts->SetMinNClustersTPC(100);
1111 fCuts->SetMinNClustersTPC(90);
1112 fCuts->SetMinRatioTPCclusters(0.6);
1113 fCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
1114 //fCuts->SetMinNClustersITS(3);
1115 fCuts->SetMinNClustersITS(2);
1116 fCuts->SetProductionVertex(0,50,0,50);
1117 fCuts->SetCutITSpixel(AliHFEextraCuts::kAny);
1118 fCuts->SetCheckITSLayerStatus(kFALSE);
1119 fCuts->SetVertexRange(10.);
1120 fCuts->SetTOFPIDStep(kFALSE);
1121 //fCuts->SetPtRange(2, 50);
1122 fCuts->SetPtRange(0.1, 50);
1123 fCuts->SetMaxImpactParam(3.,3.);
1125 //--------Initialize correction Framework and Cuts
1126 fCFM = new AliCFManager;
1127 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
1128 fCFM->SetNStepParticle(kNcutSteps);
1129 for(Int_t istep = 0; istep < kNcutSteps; istep++)
1130 fCFM->SetParticleCutsList(istep, NULL);
1133 AliWarning("Cuts not available. Default cuts will be used");
1134 fCuts = new AliHFEcuts;
1135 fCuts->CreateStandardCuts();
1137 fCuts->Initialize(fCFM);
1139 //---------Output Tlist
1140 fOutputList = new TList();
1141 fOutputList->SetOwner();
1142 fOutputList->Add(fPIDqa->MakeList("PIDQA"));
1144 fNoEvents = new TH1F("fNoEvents","",4,-0.5,3.5) ;
1145 fOutputList->Add(fNoEvents);
1147 Int_t binsE[5] = {250, 100, 1000, 200, 10};
1148 Double_t xminE[5] = {1.0, -1, 0.0, 0, -0.5};
1149 Double_t xmaxE[5] = {3.5, 1, 100.0, 100, 9.5};
1150 fEMCAccE = new THnSparseD("fEMCAccE","EMC acceptance & E;#eta;#phi;Energy;Centrality;trugCondition;",5,binsE,xminE,xmaxE);
1151 //if(fqahist==1)fOutputList->Add(fEMCAccE);
1153 hEMCAccE = new TH2F("hEMCAccE","Cluster Energy",200,0,100,100,0,20);
1154 fOutputList->Add(hEMCAccE);
1156 fTrkpt = new TH1F("fTrkpt","track pt",100,0,50);
1157 fOutputList->Add(fTrkpt);
1159 fTrackPtBefTrkCuts = new TH1F("fTrackPtBefTrkCuts","track pt before track cuts",100,0,50);
1160 fOutputList->Add(fTrackPtBefTrkCuts);
1162 fTrackPtAftTrkCuts = new TH1F("fTrackPtAftTrkCuts","track pt after track cuts",100,0,50);
1163 fOutputList->Add(fTrackPtAftTrkCuts);
1165 fTPCnsigma = new TH2F("fTPCnsigma", "TPC - n sigma",100,0,50,200,-10,10);
1166 fOutputList->Add(fTPCnsigma);
1168 fTrkEovPBef = new TH2F("fTrkEovPBef","track E/p before HFE pid",100,0,50,100,0,2);
1169 fOutputList->Add(fTrkEovPBef);
1171 fTrkEovPAft = new TH2F("fTrkEovPAft","track E/p after HFE pid",100,0,50,100,0,2);
1172 fOutputList->Add(fTrkEovPAft);
1174 fdEdxBef = new TH2F("fdEdxBef","track dEdx vs p before HFE pid",100,0,50,200,-10,10);
1175 fOutputList->Add(fdEdxBef);
1177 fdEdxAft = new TH2F("fdEdxAft","track dEdx vs p after HFE pid",100,0,50,200,-10,10);
1178 fOutputList->Add(fdEdxAft);
1180 fIncpT = new TH2F("fIncpT","HFE pid electro vs. centrality",200,0,100,100,0,50);
1181 fOutputList->Add(fIncpT);
1183 fIncpTM20 = new TH2F("fIncpTM20","HFE pid electro vs. centrality with M20",200,0,100,100,0,50);
1184 fOutputList->Add(fIncpTM20);
1186 Int_t nBinspho[9] = { 10, 30, 600, 60, 50, 4, 40, 8, 30};
1187 Double_t minpho[9] = { 0., 0., -0.1, 40, 0, -0.5, 0,-1.5, 0};
1188 Double_t maxpho[9] = {100., 30., 0.5, 100, 1, 3.5, 2, 6.5, 30};
1190 fInvmassLS = new THnSparseD("fInvmassLS", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2); nSigma; angle; m20cut; eop; Mcele;", 9, nBinspho,minpho, maxpho);
1191 if(fqahist==1)fOutputList->Add(fInvmassLS);
1193 fInvmassULS = new THnSparseD("fInvmassULS", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2); nSigma; angle; m20cut; eop; MCele", 9, nBinspho,minpho, maxpho);
1194 if(fqahist==1)fOutputList->Add(fInvmassULS);
1196 fInvmassLSmc = new THnSparseD("fInvmassLSmc", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2); nSigma; angle; m20cut; eop; Mcele;", 9, nBinspho,minpho, maxpho);
1197 if(fqahist==1)fOutputList->Add(fInvmassLSmc);
1199 fInvmassULSmc = new THnSparseD("fInvmassULSmc", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2); nSigma; angle; m20cut; eop; MCele", 9, nBinspho,minpho, maxpho);
1200 if(fqahist==1)fOutputList->Add(fInvmassULSmc);
1202 fInvmassLSreco = new TH2D("fInvmassLSreco", "Inv mass of LS (e,e) reco; cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1203 fInvmassLSreco->Sumw2();
1204 fOutputList->Add(fInvmassLSreco);
1206 fInvmassULSreco = new TH2D("fInvmassULSreco", "Inv mass of ULS (e,e) reco; cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1207 fInvmassULSreco->Sumw2();
1208 fOutputList->Add(fInvmassULSreco);
1210 fInvmassLSmc0 = new TH2D("fInvmassLSmc0", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1211 fInvmassLSmc0->Sumw2();
1212 fOutputList->Add(fInvmassLSmc0);
1214 fInvmassLSmc1 = new TH2D("fInvmassLSmc1", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1215 fInvmassLSmc1->Sumw2();
1216 fOutputList->Add(fInvmassLSmc1);
1218 fInvmassLSmc2 = new TH2D("fInvmassLSmc2", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1219 fInvmassLSmc2->Sumw2();
1220 fOutputList->Add(fInvmassLSmc2);
1222 fInvmassLSmc3 = new TH2D("fInvmassLSmc3", "Inv mass of LS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1223 fInvmassLSmc3->Sumw2();
1224 fOutputList->Add(fInvmassLSmc3);
1226 fInvmassULSmc0 = new TH2D("fInvmassULSmc0", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1227 fInvmassULSmc0->Sumw2();
1228 fOutputList->Add(fInvmassULSmc0);
1230 fInvmassULSmc1 = new TH2D("fInvmassULSmc1", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1231 fInvmassULSmc1->Sumw2();
1232 fOutputList->Add(fInvmassULSmc1);
1234 fInvmassULSmc2 = new TH2D("fInvmassULSmc2", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1235 fInvmassULSmc2->Sumw2();
1236 fOutputList->Add(fInvmassULSmc2);
1238 fInvmassULSmc3 = new TH2D("fInvmassULSmc3", "Inv mass of ULS (e,e); cent; p_{T} (GeV/c); mass(GeV/c^2)",20,0,20,600,-0.1,0.5 );
1239 fInvmassULSmc3->Sumw2();
1240 fOutputList->Add(fInvmassULSmc3);
1242 fOpeningAngleLS = new TH1F("fOpeningAngleLS","Opening angle for LS pairs",100,0,1);
1243 fOutputList->Add(fOpeningAngleLS);
1245 fOpeningAngleULS = new TH1F("fOpeningAngleULS","Opening angle for ULS pairs",100,0,1);
1246 fOutputList->Add(fOpeningAngleULS);
1248 fPhotoElecPt = new TH1F("fPhotoElecPt", "photonic electron pt",100,0,50);
1249 fOutputList->Add(fPhotoElecPt);
1251 fPhoElecPt = new TH2F("fPhoElecPt", "Pho-inclusive electron pt",200,0,100,100,0,50);
1252 fOutputList->Add(fPhoElecPt);
1254 fPhoElecPtM20 = new TH2F("fPhoElecPtM20", "Pho-inclusive electron pt with M20",200,0,100,100,0,50);
1255 fOutputList->Add(fPhoElecPtM20);
1257 fSameElecPt = new TH2F("fSameElecPt", "Same-inclusive electron pt",200,0,100,100,0,50);
1258 fOutputList->Add(fSameElecPt);
1260 fSameElecPtM20 = new TH2F("fSameElecPtM20", "Same-inclusive electron pt with M20",200,0,100,100,0,50);
1261 fOutputList->Add(fSameElecPtM20);
1263 fSemiElecPtM20 = new TH2F("fSemiElecPtM20", "Semi-inclusive electron pt with M20",200,0,100,100,0,50);
1264 fOutputList->Add(fSemiElecPtM20);
1266 fCent = new TH1F("fCent","Centrality",200,0,100) ;
1267 fOutputList->Add(fCent);
1269 // Make common binning
1270 const Double_t kMinP = 0.;
1271 const Double_t kMaxP = 20.;
1273 //+++ 1st histogram: TPC dEdx with/without EMCAL (p, pT, TPC Signal, phi, eta, Sig, e/p, ,match, cell, M02, M20, Disp, Centrality, select)
1274 // 1st histogram: TPC dEdx with/without EMCAL (p, pT, TPC Signal, phi, eta, Sig, e/p, ,match, dca_xy, dca_z, M20, Disp, Centrality, select)
1275 Int_t nBins[16] = { 100, 7, 60, 20, 90, 100, 25, 60, 60, 100, 40, 10, 250, 100, 100, 8};
1276 Double_t min[16] = {kMinP, -0.5, 1.0, -1.0, -5.0, 0, 0, -3.0, -3.0, 0.0, 0.0, 0, 0, 0, 80, -1.5};
1277 Double_t max[16] = {kMaxP, 6.5, 4.0, 1.0, 4.0, 2.0, 0.05, 3.0, 3.0, 1.0, 20.0, 100, 100, 2.0, 180, 6.5};
1278 //fEleInfo = new THnSparseD("fEleInfo", "Electron Info; pT [GeV/c]; TPC signal;phi;eta;nSig; E/p;Rmatch;Ncell;clsF;M20;mcpT;Centrality;charge;opp;same;trigCond;MCele", 16, nBins, min, max);
1279 fEleInfo = new THnSparseD("fEleInfo", "Electron Info; pT [GeV/c]; TPC signal;phi;eta;nSig; E/p;Rmatch;DCA_xy;DCA_z;M20;mcpT;Centrality;charge;opp;same;trigCond;MCele", 16, nBins, min, max);
1280 //if(fqahist==1)fOutputList->Add(fEleInfo);
1282 // Make common binning
1283 Int_t nBinsEop[3] = { 10, 50, 100};
1284 Double_t minEop[3] = { 0, 0, -5};
1285 Double_t maxEop[3] = {100, 50, 5};
1286 fElenSigma= new THnSparseD("fElenSigma", "Electron nSigma; cent; pT [GeV/c]; nSigma", 3, nBinsEop, minEop, maxEop);
1287 fOutputList->Add(fElenSigma);
1292 fClsEBftTrigCut = new TH1F("fClsEBftTrigCut","cluster E before trigger selection",1000,0,100);
1293 fOutputList->Add(fClsEBftTrigCut);
1295 fClsEAftTrigCut = new TH1F("fClsEAftTrigCut","cluster E if cls has 0 trigcut channel",1000,0,100);
1296 fOutputList->Add(fClsEAftTrigCut);
1298 fClsEAftTrigCut1 = new TH1F("fClsEAftTrigCut1","cluster E if cls with trig channel",1000,0,100);
1299 fOutputList->Add(fClsEAftTrigCut1);
1301 fClsEAftTrigCut2 = new TH1F("fClsEAftTrigCut2","cluster E if cls with trigcut channel",1000,0,100);
1302 fOutputList->Add(fClsEAftTrigCut2);
1304 fClsEAftTrigCut3 = new TH1F("fClsEAftTrigCut3","cluster E if cls with trigcut channel + nCell>Ecorrect",1000,0,100);
1305 fOutputList->Add(fClsEAftTrigCut3);
1307 fClsEAftTrigCut4 = new TH1F("fClsEAftTrigCut4","cluster E if cls with trigcut channel + nCell>Ecorrect + cls time cut",1000,0,100);
1308 fOutputList->Add(fClsEAftTrigCut4);
1310 fClsETime = new TH2F("fClsETime", "Cls time vs E; E; time;",1000,0,100,1000,-0.0000002,0.0000009);
1311 fOutputList->Add(fClsETime);
1313 fClsETime1 = new TH2F("fClsETime1", "Cls time vs E if cls contains trigger channel; E; time;",1000,0,100,1000,-0.0000002,0.0000009);
1314 fOutputList->Add(fClsETime1);
1316 fTrigTimes = new TH1F("fTrigTimes", "Trigger time; time; N;",25,0,25);
1317 fOutputList->Add(fTrigTimes);
1319 fCellCheck = new TH2F("fCellCheck", "Cell vs E; E GeV; Cell ID",10,6,26,12000,0,12000);
1320 fOutputList->Add(fCellCheck);
1324 fInputHFEMC = new TH2F("fInputHFEMC","Input MC HFE pid electro vs. centrality",200,0,100,100,0,50);
1325 fOutputList->Add(fInputHFEMC);
1327 fInputAlle = new TH2F("fInputAlle","Input MC electro vs. centrality",200,0,100,100,0,50);
1328 fOutputList->Add(fInputAlle);
1330 fIncpTMChfe = new TH2F("fIncpTMChfe","MC HFE pid electro vs. centrality",200,0,100,100,0,50);
1331 fOutputList->Add(fIncpTMChfe);
1333 fIncpTMChfeAll = new TH2F("fIncpTMChfeAll","MC Alle pid electro vs. centrality",200,0,100,100,0,50);
1334 fOutputList->Add(fIncpTMChfeAll);
1336 fIncpTMCM20hfe = new TH2F("fIncpTMCM20hfe","MC HFE pid electro vs. centrality with M20",200,0,100,100,0,50);
1337 fOutputList->Add(fIncpTMCM20hfe);
1339 fIncpTMCM20hfeAll = new TH2F("fIncpTMCM20hfeAll","MC Alle pid electro vs. centrality with M20",200,0,100,100,0,50);
1340 fOutputList->Add(fIncpTMCM20hfeAll);
1342 fIncpTMCM20hfeCheck = new TH2F("fIncpTMCM20hfeCheck","MC HFE pid electro vs. centrality with M20 Check",200,0,100,100,0,50);
1343 fOutputList->Add(fIncpTMCM20hfeCheck);
1345 Int_t nBinspho2[5] = { 200, 100, 7, 3, 700};
1346 Double_t minpho2[5] = { 0., 0., -2.5, -0.5, 0.};
1347 Double_t maxpho2[5] = {100., 50., 4.5, 2.5, 70.};
1349 fInputHFEMC_weight = new THnSparseD("fInputHFEMC_weight", "MC HFE electron pt",5,nBinspho2,minpho2,maxpho2);
1350 fOutputList->Add(fInputHFEMC_weight);
1352 fIncpTMCM20hfeCheck_weight = new THnSparseD("fIncpTMCM20hfeCheck_weight", "HFE electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1353 fOutputList->Add(fIncpTMCM20hfeCheck_weight);
1355 fIncpTMCpho = new THnSparseD("fIncpTMCpho","MC Pho pid electro vs. centrality",5,nBinspho2,minpho2,maxpho2);
1356 fOutputList->Add(fIncpTMCpho);
1358 fIncpTMCM20pho = new THnSparseD("fIncpTMCM20pho","MC Pho pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1359 fOutputList->Add(fIncpTMCM20pho);
1361 fPhoElecPtMC = new THnSparseD("fPhoElecPtMC", "MC Pho-inclusive electron pt",5,nBinspho2,minpho2,maxpho2);
1362 fOutputList->Add(fPhoElecPtMC);
1364 fPhoElecPtMCM20 = new THnSparseD("fPhoElecPtMCM20", "MC Pho-inclusive electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1365 fOutputList->Add(fPhoElecPtMCM20);
1367 fSameElecPtMC = new THnSparseD("fSameElecPtMC", "MC Same-inclusive electron pt",5,nBinspho2,minpho2,maxpho2);
1368 fOutputList->Add(fSameElecPtMC);
1370 fSameElecPtMCM20 = new THnSparseD("fSameElecPtMCM20", "MC Same-inclusive electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1371 fOutputList->Add(fSameElecPtMCM20);
1373 fIncpTMCM20pho_pi0e = new THnSparseD("fIncpTMCM20pho_pi0e","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1374 fIncpTMCM20pho_pi0e->Sumw2();
1375 fOutputList->Add(fIncpTMCM20pho_pi0e);
1377 fPhoElecPtMCM20_pi0e = new THnSparseD("fPhoElecPtMCM20_pi0e", "MC Pho-inclusive electron pt with M20 pi0->e",5,nBinspho2,minpho2,maxpho2);
1378 fPhoElecPtMCM20_pi0e->Sumw2();
1379 fOutputList->Add(fPhoElecPtMCM20_pi0e);
1381 fSameElecPtMCM20_pi0e = new THnSparseD("fSameElecPtMCM20_pi0e", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1382 fSameElecPtMCM20_pi0e->Sumw2();
1383 fOutputList->Add(fSameElecPtMCM20_pi0e);
1385 fIncpTMCM20pho_eta = new THnSparseD("fIncpTMCM20pho_eta","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1386 fIncpTMCM20pho_eta->Sumw2();
1387 fOutputList->Add(fIncpTMCM20pho_eta);
1389 fPhoElecPtMCM20_eta = new THnSparseD("fPhoElecPtMCM20_eta", "MC Pho-inclusive electron pt with M20 pi0->e",5,nBinspho2,minpho2,maxpho2);
1390 fPhoElecPtMCM20_eta->Sumw2();
1391 fOutputList->Add(fPhoElecPtMCM20_eta);
1393 fSameElecPtMCM20_eta = new THnSparseD("fSameElecPtMCM20_eta", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1394 fSameElecPtMCM20_eta->Sumw2();
1395 fOutputList->Add(fSameElecPtMCM20_eta);
1397 fIncpTMCpho_pi0e_TPC = new THnSparseD("fIncpTMCpho_pi0e_TPC","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1398 fIncpTMCpho_pi0e_TPC->Sumw2();
1399 fOutputList->Add(fIncpTMCpho_pi0e_TPC);
1401 fPhoElecPtMC_pi0e_TPC = new THnSparseD("fPhoElecPtMC_pi0e_TPC", "MC Pho-inclusive electron pt with pi0->e",5,nBinspho2,minpho2,maxpho2);
1402 fPhoElecPtMC_pi0e_TPC->Sumw2();
1403 fOutputList->Add(fPhoElecPtMC_pi0e_TPC);
1405 fSameElecPtMC_pi0e_TPC = new THnSparseD("fSameElecPtMC_pi0e_TPC", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1406 fSameElecPtMC_pi0e_TPC->Sumw2();
1407 fOutputList->Add(fSameElecPtMC_pi0e_TPC);
1409 fIncpTMCpho_eta_TPC = new THnSparseD("fIncpTMCpho_eta_TPC","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1410 fIncpTMCpho_eta_TPC->Sumw2();
1411 fOutputList->Add(fIncpTMCpho_eta_TPC);
1413 fPhoElecPtMC_eta_TPC = new THnSparseD("fPhoElecPtMC_eta_TPC", "MC Pho-inclusive electron pt with pi0->e",5,nBinspho2,minpho2,maxpho2);
1414 fPhoElecPtMC_eta_TPC->Sumw2();
1415 fOutputList->Add(fPhoElecPtMC_eta_TPC);
1417 fSameElecPtMC_eta_TPC = new THnSparseD("fSameElecPtMC_eta_TPC", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1418 fSameElecPtMC_eta_TPC->Sumw2();
1419 fOutputList->Add(fSameElecPtMC_eta_TPC);
1424 CheckNclust = new TH1D("CheckNclust","cluster check",200,0,200);
1425 fOutputList->Add(CheckNclust);
1427 CheckNits = new TH1D("CheckNits","ITS cluster check",8,-0.5,7.5);
1428 fOutputList->Add(CheckNits);
1430 CheckDCA = new TH2D("CheckDCA","DCA check",200,-5,5,200,-5,5);
1431 fOutputList->Add(CheckDCA);
1433 Hpi0pTcheck = new TH2D("Hpi0pTcheck","Pi0 pT from Hijing",100,0,50,3,-0.5,2.5);
1434 fOutputList->Add(Hpi0pTcheck);
1436 HETApTcheck = new TH2D("HETApTcheck","Eta pT from Hijing",100,0,50,3,-0.5,2.5);
1437 fOutputList->Add(HETApTcheck);
1440 Int_t nBinspho3[3] = { 200, 100, 3};
1441 Double_t minpho3[3] = { 0., 0., -0.5};
1442 Double_t maxpho3[3] = {100., 50., 2.5};
1444 Hpi0pTcheck = new THnSparseD("Hpi0pTcheck","Pi0 pT from Hijing",3,nBinspho3,minpho3,maxpho3);
1445 fOutputList->Add(Hpi0pTcheck);
1447 HETApTcheck = new THnSparseD("HETApTcheck","Eta pT from Hijing",3,nBinspho3,minpho3,maxpho3);
1448 fOutputList->Add(HETApTcheck);
1450 HphopTcheck = new TH2D("HphopTcheck","Pho pT from Hijing",100,0,50,3,-0.5,2.5);
1451 fOutputList->Add(HphopTcheck);
1453 HDpTcheck = new TH2D("HDpTcheck","D pT from Hijing",100,0,50,3,-0.5,2.5);
1454 fOutputList->Add(HDpTcheck);
1456 HBpTcheck = new TH2D("HBpTcheck","B pT from Hijing",100,0,50,3,-0.5,2.5);
1457 fOutputList->Add(HBpTcheck);
1460 fpTCheck = new TH1D("fpTCheck","pT check",500,0,50);
1461 fOutputList->Add(fpTCheck);
1463 fMomDtoE = new TH2D("fMomDtoE","D->E pT correlations;e p_{T} GeV/c;D p_{T} GeV/c",400,0,40,400,0,40);
1464 fOutputList->Add(fMomDtoE);
1466 fLabelCheck = new TH2D("fLabelCheck","MC label",50,0,50,5,-1.5,3.5);
1467 fOutputList->Add(fLabelCheck);
1469 fgeoFake = new TH2D("fgeoFake","Label==0 eta and phi",628,0,6.28,200,-1,1);
1470 fOutputList->Add(fgeoFake);
1472 fFakeTrk0 = new TH2D("fFakeTrk0","fake trakcs",10,0,100,20,0,20);
1473 fOutputList->Add(fFakeTrk0);
1475 fFakeTrk1 = new TH2D("fFakeTrk1","true all e a.f. eID",10,0,100,20,0,20);
1476 fOutputList->Add(fFakeTrk1);
1478 ftimingEle = new TH2D("ftimingEle","electron TOF",100,0,20,100,1e-7,1e-6);
1479 fOutputList->Add(ftimingEle);
1482 // note: parameters 01/31new.TPCnSigmaEtaDep
1483 // 70-90 delta_eta = 0.2
1485 double etaval[12] = {-0.55,-0.45,-0.35,-0.25,-0.15,-0.05,0.05,0.15,0.25,0.35,0.45,0.55};
1486 double corr0[12]= {-0.569177,-0.528844,-0.391979,-0.165494,0.0283495,0.156171,0.266353,0.13103,-0.0250842,-0.274089,-0.45481,-0.536291}; // 0-10 (done)
1487 double corr1[12]= {-0.404742,-0.278953,-0.218069,0.00139927,0.191412,0.354403,0.524594,0.341778,0.244199,-0.112146,-0.160692,-0.352832}; // 10-20 (done)
1488 double corr2[12] = {-0.306007,-0.16821,-0.0248635,0.202233,0.447051,0.497197,0.712251,0.433482,0.337907,0.168426,-0.0693229,-0.0728351}; // 20-30 (done)
1489 double corr3[12] = {-0.13884,-0.0503553,0.104403,0.389773,0.50697,0.539048,0.751642,0.655636,0.518563,0.308156,0.0361159,-0.0491439}; // 30-40 (done)
1490 double corr4[12] = {-0.0319431,0.0808711,0.208774,0.443217,0.557762,0.61453,0.889519,0.808282,0.620394,0.267092,0.15241,-0.0458664}; // 40-50 (done)
1491 double corr5[12] = {-0.130625,0.0189124,0.190344,0.467431,0.546353,0.672251,0.731541,0.802101,0.437108,0.294081,0.193682,0.159074}; // 50-70(done)
1492 double corr6[12] = {0.0600197,0.0600197,0.358366,0.358366,0.973734,0.973734,0.759812,0.759812,0.667861,0.667861,0.415635,0.415635}; // 70-90(done)
1494 fnSigEtaCorr[0] = new TGraphErrors(12,etaval,corr0); // 0-10
1495 fnSigEtaCorr[1] = new TGraphErrors(12,etaval,corr1); // 10-20
1496 fnSigEtaCorr[2] = new TGraphErrors(12,etaval,corr2); // 20-30
1497 fnSigEtaCorr[3] = new TGraphErrors(12,etaval,corr3); // 30-40
1498 fnSigEtaCorr[4] = new TGraphErrors(12,etaval,corr4); // 40-50
1499 fnSigEtaCorr[5] = new TGraphErrors(12,etaval,corr5); // 50-70
1500 fnSigEtaCorr[6] = new TGraphErrors(12,etaval,corr6); // 70-90
1502 fIncMaxE = new TH2D("fIncMaxE","Inc",10,0,100,10,0,100);
1503 fOutputList->Add(fIncMaxE);
1505 fIncReco = new TH2D("fIncReco","Inc",10,0,100,100,0,500);
1506 fOutputList->Add(fIncReco);
1508 fPhoReco = new TH2D("fPhoReco","Pho",10,0,100,100,0,500);
1509 fOutputList->Add(fPhoReco);
1511 fSamReco = new TH2D("fSamReco","Same",10,0,100,100,0,500);
1512 fOutputList->Add(fSamReco);
1514 fIncRecoMaxE = new TH2D("fIncRecoMaxE","Inc",10,0,100,100,0,500);
1515 fOutputList->Add(fIncRecoMaxE);
1517 fPhoRecoMaxE = new TH2D("fPhoRecoMaxE","Pho",10,0,100,100,0,500);
1518 fOutputList->Add(fPhoRecoMaxE);
1520 fSamRecoMaxE = new TH2D("fSamRecoMaxE","Same",10,0,100,100,0,500);
1521 fOutputList->Add(fSamRecoMaxE);
1523 fPhoVertexReco_HFE = new TH2D("fPhoVertexReco_HFE","photon production Vertex mass selection",40,0,20,250,0,50);
1524 fOutputList->Add(fPhoVertexReco_HFE);
1526 fPhoVertexReco_EMCal = new TH2D("fPhoVertexReco_EMCal","photon production Vertex mass selection",40,0,20,250,0,50);
1527 fOutputList->Add(fPhoVertexReco_EMCal);
1529 fPhoVertexReco_Invmass = new TH2D("fPhoVertexReco_Invmass","photon production Vertex mass selection",40,0,20,250,0,50);
1530 fOutputList->Add(fPhoVertexReco_Invmass);
1532 fPhoVertexReco_step0= new TH2D("fPhoVertexReco_step0","photon production Vertex mass selection",40,0,20,250,0,50);
1533 fOutputList->Add(fPhoVertexReco_step0);
1535 fPhoVertexReco_step1= new TH2D("fPhoVertexReco_step1","photon production Vertex mass selection",40,0,20,250,0,50);
1536 fOutputList->Add(fPhoVertexReco_step1);
1538 fPhoVertexReco_step2= new TH2D("fPhoVertexReco_step2","photon production Vertex mass selection",40,0,20,250,0,50);
1539 fOutputList->Add(fPhoVertexReco_step2);
1541 fPhoVertexReco_step3= new TH2D("fPhoVertexReco_step3","photon production Vertex mass selection",40,0,20,250,0,50);
1542 fOutputList->Add(fPhoVertexReco_step3);
1544 fPhoVertexReco_step4= new TH2D("fPhoVertexReco_step4","photon production Vertex mass selection",40,0,20,250,0,50);
1545 fOutputList->Add(fPhoVertexReco_step4);
1547 fPhoVertexReco_step5= new TH2D("fPhoVertexReco_step5","photon production Vertex mass selection",40,0,20,250,0,50);
1548 fOutputList->Add(fPhoVertexReco_step5);
1550 fMatchV0_0 = new TH1D("fMatchV0_0","V0 match",100,0,20);
1551 fOutputList->Add(fMatchV0_0);
1553 fMatchV0_1 = new TH1D("fMatchV0_1","V0 match",100,0,20);
1554 fOutputList->Add(fMatchV0_1);
1556 fMatchMC_0 = new TH1D("fMatchMC_0","MC match",100,0,20);
1557 fOutputList->Add(fMatchMC_0);
1559 fMatchMC_1 = new TH1D("fMatchMC_1","MC match",100,0,20);
1560 fOutputList->Add(fMatchMC_1);
1562 PostData(1,fOutputList);
1565 //________________________________________________________________________
1566 void AliAnalysisTaskHFECal::Terminate(Option_t *)
1568 // Info("Terminate");
1569 AliAnalysisTaskSE::Terminate();
1572 //________________________________________________________________________
1573 Bool_t AliAnalysisTaskHFECal::ProcessCutStep(Int_t cutStep, AliVParticle *track)
1575 // Check single track cuts for a given cut step
1576 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
1577 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
1580 //_________________________________________
1581 void AliAnalysisTaskHFECal::SelectPhotonicElectron(Int_t itrack, Double_t cent, AliESDtrack *track, Bool_t &fFlagPhotonicElec, Bool_t &fFlagConvinatElec, Double_t nSig, Double_t shower, Double_t ep, Double_t mce, Double_t w, Int_t ibgevent, Bool_t tagpi0, Bool_t tageta)
1583 //Identify non-heavy flavour electrons using Invariant mass method
1585 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
1586 fTrackCuts->SetRequireTPCRefit(kTRUE);
1587 fTrackCuts->SetRequireITSRefit(kTRUE);
1588 fTrackCuts->SetEtaRange(-0.9,0.9);
1589 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
1590 fTrackCuts->SetMinNClustersTPC(90);
1592 //const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1593 Double_t bfield = fESD->GetMagneticField();
1594 Double_t emass = 0.51*0.001; // (0.51 MeV)
1596 double ptEle = track->Pt(); //add
1597 if(ibgevent==0 && w > 0.0)
1599 fpTCheck->Fill(ptEle,w);
1602 Bool_t flagPhotonicElec = kFALSE;
1603 Bool_t flagConvinatElec = kFALSE;
1608 Int_t label = TMath::Abs(track->GetLabel());
1609 TParticle* particle = stack->Particle(label);
1610 p1 = particle->GetFirstMother();
1613 //for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1614 for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1615 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1617 printf("ERROR: Could not receive track %d\n", jTracks);
1620 if(itrack==jTracks)continue;
1626 Int_t label2 = TMath::Abs(trackAsso->GetLabel());
1627 TParticle* particle2 = stack->Particle(label2);
1628 Bool_t MChijing_ass = fMC->IsFromBGEvent(label2);
1629 if(MChijing_ass)jbgevent =1;
1630 if(particle2->GetFirstMother()>-1)
1631 p2 = particle2->GetFirstMother();
1634 Double_t dEdxAsso = -999., ptPrim=-999., ptAsso=-999., openingAngle = -999.;
1635 Double_t mass=999., width = -999;
1636 Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1638 //ptPrim = track->Pt();
1641 dEdxAsso = trackAsso->GetTPCsignal();
1642 ptAsso = trackAsso->Pt();
1643 Int_t chargeAsso = trackAsso->Charge();
1644 Int_t charge = track->Charge();
1647 if(ptAsso <fMimpTassCut) continue;
1648 if(!fTrackCuts->AcceptTrack(trackAsso)) continue;
1649 //if(dEdxAsso <65 || dEdxAsso>100) continue;
1650 double fTPCnSigmaAss = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(trackAsso, AliPID::kElectron) : 1000;
1651 //cout << "fTPCnSigmaAss = " << fTPCnSigmaAss << endl;
1652 //cout << "fTPCnSigmaAss Cut = " << fMimNsigassCut << endl;
1653 if(fTPCnSigmaAss <fMimNsigassCut || fTPCnSigmaAss>5) continue;
1654 //cout << "fTPCnSigmaAss a.f. cut = " << fTPCnSigmaAss << endl;
1656 Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1657 if(charge>0) fPDGe1 = -11;
1658 if(chargeAsso>0) fPDGe2 = -11;
1660 //printf("chargeAsso = %d\n",chargeAsso);
1661 //printf("charge = %d\n",charge);
1662 if(charge == chargeAsso) fFlagLS = kTRUE;
1663 if(charge != chargeAsso) fFlagULS = kTRUE;
1665 //printf("fFlagLS = %d\n",fFlagLS);
1666 //printf("fFlagULS = %d\n",fFlagULS);
1669 AliKFParticle::SetField(bfield);
1670 AliKFParticle ge1(*track, fPDGe1);
1671 AliKFParticle ge2(*trackAsso, fPDGe2);
1673 if(fSetMassNonlinear)
1675 ge1.SetNonlinearMassConstraint(emass);
1676 ge2.SetNonlinearMassConstraint(emass);
1679 AliKFParticle recg(ge1, ge2);
1683 AliKFVertex primV(*pVtx);
1687 recg.SetProductionVertex(primV);
1691 if(recg.GetNDF()<1) continue;
1692 Double_t chi2recg = recg.GetChi2()/recg.GetNDF();
1693 Double_t chi2cut = 3.0;
1696 if(fSetMassConstraint)
1698 recg.SetMassConstraint(0,0.0001);
1701 recg.GetMass(mass,width);
1703 if(fSetMassWidthCut && width>1e10)continue;
1706 openingAngle = ge1.GetAngle(ge2);
1707 if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1708 if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1711 if(shower>0.0 && shower<0.3)ishower = 1;
1715 phoinfo[1] = ptPrim;
1718 //phoinfo[3] = dEdxAsso;
1719 phoinfo[4] = openingAngle;
1720 phoinfo[5] = ishower;
1723 phoinfo[8] = ptAsso;
1725 if(fFlagLS) fInvmassLS->Fill(phoinfo);
1726 if(fFlagULS) fInvmassULS->Fill(phoinfo);
1727 if(fFlagLS && ibgevent==0 && jbgevent==0) fInvmassLSmc->Fill(phoinfo,w);
1728 if(fFlagULS && ibgevent==0 && jbgevent==0)
1730 fInvmassULSmc->Fill(phoinfo,w);
1732 //printf("fInvmassCut %f\n",fInvmassCut);
1733 //printf("openingAngle %f\n",fOpeningAngleCut);
1736 if(openingAngle > fOpeningAngleCut) continue;
1738 //if(TMath::Sqrt(TMath::Abs(chi2recg))>chi2cut) continue;
1739 if(chi2recg>chi2cut) continue;
1741 if(fFlagLS ) fInvmassLSreco->Fill(ptPrim,mass);
1742 if(fFlagULS) fInvmassULSreco->Fill(ptPrim,mass);
1745 //printf("mce =%f\n",mce);
1746 if(mce<-0.5) // mce==-1. is real
1748 //printf("Real data\n");
1749 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1750 flagPhotonicElec = kTRUE;
1752 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec){
1753 flagConvinatElec = kTRUE;
1759 //printf("MC data\n");
1763 //cout << "tagpi0 = " << tagpi0 << " ; tageta = " << tageta << endl;
1764 if(fFlagLS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassLSmc0->Fill(ptPrim,mass);
1765 if(fFlagULS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassULSmc0->Fill(ptPrim,mass);
1766 if(fFlagLS && ibgevent==0 && jbgevent==0 && tageta) fInvmassLSmc1->Fill(ptPrim,mass);
1767 if(fFlagULS && ibgevent==0 && jbgevent==0 && tageta) fInvmassULSmc1->Fill(ptPrim,mass);
1768 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassLSmc2->Fill(ptPrim,mass);
1769 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassULSmc2->Fill(ptPrim,mass);
1770 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassLSmc3->Fill(ptPrim,mass);
1771 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassULSmc3->Fill(ptPrim,mass);
1774 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (ibgevent==jbgevent)){
1775 //if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (p1==p2)){ //<--- only MC train (55,56) v5-03-68-AN , 69 & v5-05-70-AN (till 74)
1776 flagPhotonicElec = kTRUE;
1778 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec && (ibgevent==jbgevent)){
1779 flagConvinatElec = kTRUE;
1784 fFlagPhotonicElec = flagPhotonicElec;
1785 fFlagConvinatElec = flagConvinatElec;
1789 //_________________________________________
1790 void AliAnalysisTaskHFECal::SelectPhotonicElectron2(Int_t itrack, Double_t cent, AliESDtrack *track, Bool_t &fFlagPhotonicElec, Bool_t &fFlagConvinatElec, Double_t nSig, Double_t shower, Double_t ep, Double_t mce, Double_t w, Int_t ibgevent, Bool_t tagpi0, Bool_t tageta)
1792 //Identify non-heavy flavour electrons using Invariant mass method
1794 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
1795 fTrackCuts->SetRequireTPCRefit(kTRUE);
1796 fTrackCuts->SetRequireITSRefit(kTRUE);
1797 fTrackCuts->SetEtaRange(-0.9,0.9);
1798 //fTrackCuts->SetRequireSigmaToVertex(kTRUE);
1799 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
1800 fTrackCuts->SetMinNClustersTPC(90);
1802 Double_t eMass = TDatabasePDG::Instance()->GetParticle(11)->Mass(); //Electron mass in GeV
1803 Double_t bfield = fESD->GetMagneticField();
1805 double ptEle = track->Pt(); //add
1806 if(ibgevent==0 && w > 0.0)
1808 fpTCheck->Fill(ptEle,w);
1811 Bool_t flagPhotonicElec = kFALSE;
1812 Bool_t flagConvinatElec = kFALSE;
1817 Int_t label = TMath::Abs(track->GetLabel());
1818 TParticle* particle = stack->Particle(label);
1819 p1 = particle->GetFirstMother();
1822 //for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1823 for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1824 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1826 printf("ERROR: Could not receive track %d\n", jTracks);
1829 if(itrack==jTracks)continue;
1835 Int_t label2 = TMath::Abs(trackAsso->GetLabel());
1836 TParticle* particle2 = stack->Particle(label2);
1837 Bool_t MChijing_ass = fMC->IsFromBGEvent(label2);
1838 if(MChijing_ass)jbgevent =1;
1839 if(particle2->GetFirstMother()>-1)
1840 p2 = particle2->GetFirstMother();
1843 Double_t dEdxAsso = -999., ptPrim=-999., ptAsso=-999., openingAngle = -999.;
1844 //Double_t mass=999., width = -999;
1846 Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1848 //ptPrim = track->Pt();
1851 dEdxAsso = trackAsso->GetTPCsignal();
1852 ptAsso = trackAsso->Pt();
1853 Int_t chargeAsso = trackAsso->Charge();
1854 Int_t charge = track->Charge();
1857 if(ptAsso <0.5) continue;
1858 if(!fTrackCuts->AcceptTrack(trackAsso)) continue;
1859 if(dEdxAsso <65 || dEdxAsso>100) continue; //11a pass1
1861 Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1862 if(charge>0) fPDGe1 = -11;
1863 if(chargeAsso>0) fPDGe2 = -11;
1865 //printf("chargeAsso = %d\n",chargeAsso);
1866 //printf("charge = %d\n",charge);
1867 if(charge == chargeAsso) fFlagLS = kTRUE;
1868 if(charge != chargeAsso) fFlagULS = kTRUE;
1871 double xt1 = 0.0, xt2 = 0.0;
1872 Double_t p1at[3] = {0,0,0};
1873 Double_t p2at[3] = {0,0,0};
1874 //double dca12 = trackAsso->GetDCA(track,bfield,xt2,xt1); //DCA track1-track2
1875 double kHasdcaT1 = track->GetPxPyPzAt(xt1,bfield,p1at); //Track1
1876 double kHasdcaT2 = trackAsso->GetPxPyPzAt(xt2,bfield,p2at); //Track2
1877 if(!kHasdcaT1 || !kHasdcaT2) AliWarning("It could be a problem in the extrapolation");
1878 //cout << "dca = " << dca12 << endl;
1880 TLorentzVector electron1;
1881 TLorentzVector electron2;
1882 TLorentzVector mother;
1884 electron1.SetXYZM(p1at[0], p1at[1], p1at[2], eMass);
1885 electron2.SetXYZM(p2at[0], p2at[1], p2at[2], eMass);
1886 openingAngle = TVector2::Phi_0_2pi(electron1.Angle(electron2.Vect()));
1888 mother = electron1 + electron2;
1889 //double invmassAtDCA = mother.M();
1892 TLorentzVector electron1_2D;
1893 TLorentzVector electron2_2D;
1894 TLorentzVector mother_2D;
1896 double pT1at = sqrt(pow(p1at[0],2)+pow(p1at[1],2));
1897 double pT2at = sqrt(pow(p2at[0],2)+pow(p2at[1],2));
1899 electron1_2D.SetXYZM(pT1at, 0.0, p1at[2], eMass);
1900 electron2_2D.SetXYZM(pT2at, 0.0, p2at[2], eMass);
1902 mother_2D = electron1_2D + electron2_2D;
1903 double invmassAtDCA_2D = mother_2D.M();
1904 mass = invmassAtDCA_2D;
1907 if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1908 if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1911 if(shower>0.0 && shower<0.3)ishower = 1;
1915 phoinfo[1] = ptPrim;
1918 //phoinfo[3] = dEdxAsso;
1919 phoinfo[4] = openingAngle;
1920 phoinfo[5] = ishower;
1923 phoinfo[8] = ptAsso;
1925 if(fFlagLS) fInvmassLS->Fill(phoinfo);
1926 if(fFlagULS) fInvmassULS->Fill(phoinfo);
1927 if(fFlagLS && ibgevent==0 && jbgevent==0) fInvmassLSmc->Fill(phoinfo,w);
1928 if(fFlagULS && ibgevent==0 && jbgevent==0)
1930 fInvmassULSmc->Fill(phoinfo,w);
1932 //printf("fInvmassCut %f\n",fInvmassCut);
1933 //printf("openingAngle %f\n",fOpeningAngleCut);
1936 if(openingAngle > fOpeningAngleCut) continue;
1938 //if(TMath::Sqrt(TMath::Abs(chi2recg))>chi2cut) continue;
1939 //if(chi2recg>chi2cut) continue;
1941 if(fFlagLS ) fInvmassLSreco->Fill(ptPrim,mass);
1942 if(fFlagULS) fInvmassULSreco->Fill(ptPrim,mass);
1945 //printf("mce =%f\n",mce);
1946 if(mce<-0.5) // mce==-1. is real
1948 //printf("Real data\n");
1949 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1950 flagPhotonicElec = kTRUE;
1952 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec){
1953 flagConvinatElec = kTRUE;
1959 //printf("MC data\n");
1963 //cout << "tagpi0 = " << tagpi0 << " ; tageta = " << tageta << endl;
1964 if(fFlagLS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassLSmc0->Fill(ptPrim,mass);
1965 if(fFlagULS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassULSmc0->Fill(ptPrim,mass);
1966 if(fFlagLS && ibgevent==0 && jbgevent==0 && tageta) fInvmassLSmc1->Fill(ptPrim,mass);
1967 if(fFlagULS && ibgevent==0 && jbgevent==0 && tageta) fInvmassULSmc1->Fill(ptPrim,mass);
1968 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassLSmc2->Fill(ptPrim,mass);
1969 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassULSmc2->Fill(ptPrim,mass);
1970 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassLSmc3->Fill(ptPrim,mass);
1971 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassULSmc3->Fill(ptPrim,mass);
1974 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (ibgevent==jbgevent)){
1975 //if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (p1==p2)){ <--- only MC train (55,56) v5-03-68-AN & 69 for check
1976 flagPhotonicElec = kTRUE;
1978 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec && (ibgevent==jbgevent)){
1979 flagConvinatElec = kTRUE;
1984 fFlagPhotonicElec = flagPhotonicElec;
1985 fFlagConvinatElec = flagConvinatElec;
1989 //-------------------------------------------
1991 void AliAnalysisTaskHFECal::FindMother(TParticle* part, int &label, int &pid)
1993 //int label = 99999;
1996 if(part->GetFirstMother()>-1)
1998 label = part->GetFirstMother();
1999 pid = stack->Particle(label)->GetPdgCode();
2001 //cout << "Find Mother : label = " << label << " ; pid" << pid << endl;
2004 double AliAnalysisTaskHFECal::GetMCweight(double mcPi0pT)
2006 double weight = 1.0;
2008 if(mcPi0pT>0.0 && mcPi0pT<5.0)
2010 weight = 0.323*mcPi0pT/(TMath::Exp(-1.6+0.767*mcPi0pT+0.0285*mcPi0pT*mcPi0pT));
2014 weight = 115.0/(0.718*mcPi0pT*TMath::Power(mcPi0pT,3.65));
2019 double AliAnalysisTaskHFECal::GetMCweightEta(double mcEtapT)
2021 double weight = 1.0;
2023 weight = 223.3/TMath::Power((TMath::Exp(-0.17*mcEtapT-0.0322*mcEtapT*mcEtapT)+mcEtapT/1.69),5.65);
2028 //_________________________________________
2029 void AliAnalysisTaskHFECal::FindTriggerClusters()
2031 //cout << "finding trigger patch" << endl;
2033 const int nModuleCols = 2;
2034 const int nModuleRows = 5;
2035 const int nColsFeeModule = 48;
2036 const int nRowsFeeModule = 24;
2037 const int nColsFaltroModule = 24;
2038 const int nRowsFaltroModule = 12;
2039 //const int faltroWidthMax = 20;
2041 // part 1, trigger extraction -------------------------------------
2042 Int_t globCol, globRow;
2043 //Int_t ntimes=0, nTrigChannel=0, nTrigChannelCut=0, trigInCut=0;
2044 Int_t ntimes=0, nTrigChannel=0, nTrigChannelCut=0;
2046 //Int_t trigtimes[faltroWidthMax];
2047 Double_t cellTime[nColsFeeModule*nModuleCols][nRowsFeeModule*nModuleRows];
2048 Double_t cellEnergy[nColsFeeModule*nModuleCols][nRowsFeeModule*nModuleRows];
2049 //Double_t fTrigCutLow = 6;
2050 //Double_t fTrigCutHigh = 10;
2051 Double_t fTimeCutLow = 469e-09;
2052 Double_t fTimeCutHigh = 715e-09;
2054 AliESDCaloTrigger * fCaloTrigger = fESD->GetCaloTrigger( "EMCAL" );
2056 // erase trigger maps
2057 for(Int_t i = 0; i < nColsFaltroModule*nModuleCols; i++ )
2059 for(Int_t j = 0; j < nRowsFaltroModule*nModuleRows; j++ )
2061 ftriggersCut[i][j] = 0;
2062 ftriggers[i][j] = 0;
2063 ftriggersTime[i][j] = 0;
2067 Int_t iglobCol=0, iglobRow=0;
2068 // go through triggers
2069 if( fCaloTrigger->GetEntries() > 0 )
2072 fCaloTrigger->Reset();
2073 while( fCaloTrigger->Next() )
2075 fCaloTrigger->GetPosition( globCol, globRow );
2076 fCaloTrigger->GetNL0Times( ntimes );
2079 if( ntimes < 1 ) continue;
2080 // get precise timings
2081 fCaloTrigger->GetL0Times( trigtimes );
2083 for(Int_t i = 0; i < ntimes; i++ )
2085 // save the first trigger time in channel
2086 if( i == 0 || triggersTime[globCol][globRow] > trigtimes[i] )
2087 triggersTime[globCol][globRow] = trigtimes[i];
2088 //printf("trigger times: %d\n",trigtimes[i]);
2090 if(trigtimes[i] > fTrigCutLow && trigtimes[i] < fTrigCutHigh )
2093 fTrigTimes->Fill(trigtimes[i]);
2097 //L1 analysis from AliAnalysisTaskEMCALTriggerQA
2099 fCaloTrigger->GetTriggerBits(bit);
2100 //cout << "bit = " << bit << endl;
2103 fCaloTrigger->GetL1TimeSum(ts);
2104 //cout << "ts = " << ts << endl;
2105 if (ts > 0)ftriggers[globCol][globRow] = 1;
2106 // number of triggered channels in event
2109 if(ts>0 && (bit >> 6 & 0x1))
2114 //cout << "ts cut = " << ts << endl;
2115 //cout << "globCol = " << globCol << endl;
2116 //cout << "globRow = " << globRow << endl;
2117 ftriggersCut[globCol][globRow] = 1;
2120 } // calo trigger entries
2121 } // has calo trigger entries
2123 // part 2 go through the clusters here -----------------------------------
2124 //cout << " part 2 go through the clusters here ----------------------------------- " << endl;
2125 Int_t nCluster=0, nCell=0, iCell=0, gCell=0;
2126 Short_t cellAddr, nSACell;
2128 //Int_t nSACell, iSACell, mclabel;
2130 Double_t cellAmp=0, cellTimeT=0, clusterTime=0, efrac=0;
2131 Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta, gphi, geta, feta, fphi;
2133 TRefArray *fCaloClusters = new TRefArray();
2134 fESD->GetEMCALClusters( fCaloClusters );
2135 nCluster = fCaloClusters->GetEntries();
2138 // save all cells times if there are clusters
2141 for(Int_t i = 0; i < nColsFeeModule*nModuleCols; i++ ){
2142 for(Int_t j = 0; j < nRowsFeeModule*nModuleRows; j++ ){
2143 cellTime[i][j] = 0.;
2144 cellEnergy[i][j] = 0.;
2149 AliESDCaloCells *fCaloCells = fESD->GetEMCALCells();
2150 //AliVCaloCells fCaloCells = fESD->GetEMCALCells();
2151 nSACell = fCaloCells->GetNumberOfCells();
2152 for(iSACell = 0; iSACell < nSACell; iSACell++ ){
2153 // get the cell info *fCal
2154 fCaloCells->GetCell( iSACell, cellAddr, cellAmp, cellTimeT , mclabel, efrac);
2156 // get cell position
2157 fGeom->GetCellIndex( cellAddr, nSupMod, nModule, nIphi, nIeta );
2158 fGeom->GetCellPhiEtaIndexInSModule( nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2160 // convert co global phi eta
2161 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2162 geta = ieta + nColsFeeModule*(nSupMod%2);
2164 // save cell time and energy
2165 cellTime[geta][gphi] = cellTimeT;
2166 cellEnergy[geta][gphi] = cellAmp;
2171 Int_t nClusterTrig, nClusterTrigCut;
2172 UShort_t *cellAddrs;
2173 Double_t clsE=-999, clsEta=-999, clsPhi=-999;
2174 Float_t clsPos[3] = {0.,0.,0.};
2176 for(Int_t icl=0; icl<fESD->GetNumberOfCaloClusters(); icl++)
2178 AliESDCaloCluster *cluster = fESD->GetCaloCluster(icl);
2179 if(!cluster || !cluster->IsEMCAL()) continue;
2181 // get cluster cells
2182 nCell = cluster->GetNCells();
2184 // get cluster energy
2185 clsE = cluster->E();
2187 // get cluster position
2188 cluster->GetPosition(clsPos);
2189 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
2190 clsEta = clsPosVec.Eta();
2191 clsPhi = clsPosVec.Phi();
2193 // get the cell addresses
2194 cellAddrs = cluster->GetCellsAbsId();
2196 // check if the cluster contains cell, that was marked as triggered
2198 nClusterTrigCut = 0;
2200 // loop the cells to check, if cluser in acceptance
2201 // any cluster with a cell outside acceptance is not considered
2202 for( iCell = 0; iCell < nCell; iCell++ )
2205 //if(clsE>6.0)fCellCheck->Fill(clsE,cellAddrs[iCell]);
2207 // get cell position
2208 fGeom->GetCellIndex( cellAddrs[iCell], nSupMod, nModule, nIphi, nIeta );
2209 fGeom->GetCellPhiEtaIndexInSModule( nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2211 // convert co global phi eta
2212 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2213 geta = ieta + nColsFeeModule*(nSupMod%2);
2215 if( cellTime[geta][gphi] > 0. ){
2216 clusterTime += cellTime[geta][gphi];
2220 // get corresponding FALTRO
2224 //cout << "fphi = " << fphi << endl;
2225 //cout << "feta = " << feta << endl;
2227 // try to match with a triggered
2228 if( ftriggers[feta][fphi]==1)
2231 if( ftriggersCut[feta][fphi]==1)
2232 { nClusterTrigCut++;
2235 //cout << "nClusterTrigCut : " << nClusterTrigCut << endl;
2241 clusterTime = clusterTime / (Double_t)gCell;
2242 // fix the reconstriction code time 100ns jumps
2243 if( fESD->GetBunchCrossNumber() % 4 < 2 )
2244 clusterTime -= 0.0000001;
2246 //fClsETime->Fill(clsE,clusterTime);
2247 //fClsEBftTrigCut->Fill(clsE);
2250 //fClsETime1->Fill(clsE,clusterTime);
2254 cluster->SetChi2(1);
2255 //fClsEAftTrigCut1->Fill(clsE);
2258 if(nClusterTrigCut>0){
2259 cluster->SetChi2(2);
2260 //fClsEAftTrigCut2->Fill(clsE);
2263 if(nClusterTrigCut>0 && ( nCell > (1 + clsE / 3)))
2265 cluster->SetChi2(3);
2266 //fClsEAftTrigCut3->Fill(clsE);
2269 if(nClusterTrigCut>0 && (nCell > (1 + clsE / 3) )&&( clusterTime > fTimeCutLow && clusterTime < fTimeCutHigh ))
2271 // cluster->SetChi2(4);
2272 //fClsEAftTrigCut4->Fill(clsE);
2274 if(nClusterTrigCut<1)
2276 cluster->SetChi2(0);
2278 //fClsEAftTrigCut->Fill(clsE);
2284 // <-------- only MC correction
2285 double AliAnalysisTaskHFECal::MCEopMeanCorrection(double pTmc, float central)
2287 TF1 *fcorr0 = new TF1("fcorr0","[0]*tanh([1]+[2]*x)");
2288 TF1 *fcorr1 = new TF1("fcorr1","[0]*tanh([1]+[2]*x)");
2292 if(central>0 && central<=10)
2294 fcorr0->SetParameters(1.045,1.288,3.18e-01); //
2295 fcorr1->SetParameters(9.91e-01,3.466,2.344);
2297 else if(central>10 && central<=20)
2299 fcorr0->SetParameters(1.029,8.254e-01,4.07e-01);
2300 fcorr1->SetParameters(0.975,2.276,1.501e-01);
2302 else if(central>20 && central<=30)
2304 fcorr0->SetParameters(1.01,8.795e-01,3.904e-01);
2305 fcorr1->SetParameters(9.675e-01,1.654,2.583e-01);
2307 else if(central>30 && central<=40)
2309 fcorr0->SetParameters(1.00,1.466,2.305e-1);
2310 fcorr1->SetParameters(9.637e-01,1.473,2.754e-01);
2312 else if(central>40 && central<=50)
2314 fcorr0->SetParameters(1.00,1.422,1.518e-01);
2315 fcorr1->SetParameters(9.59e-01,1.421,2.931e-01);
2318 else if(central>50 && central<=70)
2320 fcorr0->SetParameters(0.989,2.495,2.167);
2321 fcorr1->SetParameters(0.961,1.734,1.438e-01);
2323 else if(central>70 && central<=100)
2325 fcorr0->SetParameters(0.981,-3.373,3.93327);
2326 fcorr1->SetParameters(9.574e-01,1.698,1.58e-01);
2330 shift = fcorr0->Eval(pTmc)-fcorr1->Eval(pTmc);
2338 // <-------- only Data correction
2339 double AliAnalysisTaskHFECal::NsigmaCorrection(double tmpeta, float central)
2343 if(central>=0 && central<10)
2347 else if(central>=10 && central<20)
2351 else if(central>=20 && central<30)
2355 else if(central>=30 && central<40)
2359 else if(central>=40 && central<50)
2363 else if(central>=50 && central<70)
2372 double shift = fnSigEtaCorr[icent]->Eval(tmpeta);
2374 //cout << "eta correction"<< endl;
2375 //cout << "cent = "<< central<< endl;
2376 //cout << "icent = "<< icent << endl;
2377 //cout << "shift = "<< shift << endl;