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)
148 ,fTrackPtBefTrkCuts(0)
149 ,fTrackPtAftTrkCuts(0)
171 ,fIncpTMCM20hfeAll(0)
172 ,fIncpTMCM20hfeCheck(0)
173 ,fInputHFEMC_weight(0)
174 ,fIncpTMCM20hfeCheck_weight(0)
181 ,fIncpTMCM20pho_pi0e(0)
182 ,fPhoElecPtMCM20_pi0e(0)
183 ,fSameElecPtMCM20_pi0e(0)
184 ,fIncpTMCM20pho_eta(0)
185 ,fPhoElecPtMCM20_eta(0)
186 ,fSameElecPtMCM20_eta(0)
187 ,fIncpTMCpho_pi0e_TPC(0)
188 ,fPhoElecPtMC_pi0e_TPC(0)
189 ,fSameElecPtMC_pi0e_TPC(0)
190 ,fIncpTMCpho_eta_TPC(0)
191 ,fPhoElecPtMC_eta_TPC(0)
192 ,fSameElecPtMC_eta_TPC(0)
214 //,fnSigEtaCorr(NULL)
218 fPID = new AliHFEpid("hfePid");
219 fTrackCuts = new AliESDtrackCuts();
221 for(int i=0; i<7; i++)fnSigEtaCorr[i] = 0;
223 // Define input and output slots here
224 // Input slot #0 works with a TChain
225 DefineInput(0, TChain::Class());
226 // Output slot #0 id reserved by the base class for AOD
227 // Output slot #1 writes into a TH1 container
228 // DefineOutput(1, TH1I::Class());
229 DefineOutput(1, TList::Class());
230 // DefineOutput(3, TTree::Class());
233 //________________________________________________________________________
234 AliAnalysisTaskHFECal::AliAnalysisTaskHFECal()
235 : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskHFECal")
244 ,fIdentifiedAsOutInz(kFALSE)
245 ,fPassTheEventCut(kFALSE)
246 ,fRejectKinkMother(kFALSE)
252 ,fOpeningAngleCut(0.1)
255 ,fInvmassCut(0) // no mass
256 ,fSetMassConstraint(kTRUE)
257 ,fSetMassWidthCut(kFALSE)
258 ,fSetMassNonlinear(kFALSE)
291 ,fTrackPtBefTrkCuts(0)
292 ,fTrackPtAftTrkCuts(0)
314 ,fIncpTMCM20hfeAll(0)
315 ,fIncpTMCM20hfeCheck(0)
316 ,fInputHFEMC_weight(0)
317 ,fIncpTMCM20hfeCheck_weight(0)
324 ,fIncpTMCM20pho_pi0e(0)
325 ,fPhoElecPtMCM20_pi0e(0)
326 ,fSameElecPtMCM20_pi0e(0)
327 ,fIncpTMCM20pho_eta(0)
328 ,fPhoElecPtMCM20_eta(0)
329 ,fSameElecPtMCM20_eta(0)
330 ,fIncpTMCpho_pi0e_TPC(0)
331 ,fPhoElecPtMC_pi0e_TPC(0)
332 ,fSameElecPtMC_pi0e_TPC(0)
333 ,fIncpTMCpho_eta_TPC(0)
334 ,fPhoElecPtMC_eta_TPC(0)
335 ,fSameElecPtMC_eta_TPC(0)
357 //,fnSigEtaCorr(NULL)
359 //Default constructor
360 fPID = new AliHFEpid("hfePid");
362 fTrackCuts = new AliESDtrackCuts();
364 for(int i=0; i<7; i++)fnSigEtaCorr[i] = 0;
367 // Define input and output slots here
368 // Input slot #0 works with a TChain
369 DefineInput(0, TChain::Class());
370 // Output slot #0 id reserved by the base class for AOD
371 // Output slot #1 writes into a TH1 container
372 // DefineOutput(1, TH1I::Class());
373 DefineOutput(1, TList::Class());
374 //DefineOutput(3, TTree::Class());
376 //_________________________________________
378 AliAnalysisTaskHFECal::~AliAnalysisTaskHFECal()
390 //_________________________________________
392 void AliAnalysisTaskHFECal::UserExec(Option_t*)
395 //Called for each event
397 // create pointer to event
398 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
400 printf("ERROR: fESD not available\n");
405 AliError("HFE cuts not available");
409 if(!fPID->IsInitialized()){
410 // Initialize PID with the given run number
411 AliWarning("PID not initialised, get from Run no");
412 fPID->InitializePID(fESD->GetRunNumber());
415 if(fmcData)fMC = MCEvent();
416 //AliStack* stack = NULL;
417 if(fmcData && fMC)stack = fMC->Stack();
420 AliCentrality *centrality = fESD->GetCentrality();
421 cent = centrality->GetCentralityPercentile("V0M");
423 //---- fill MC track info
426 Int_t nParticles = stack->GetNtrack();
427 for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
428 TParticle* particle = stack->Particle(iParticle);
429 int fPDG = particle->GetPdgCode();
430 double mcZvertex = fMC->GetPrimaryVertex()->GetZ();
431 double pTMC = particle->Pt();
432 double proR = particle->R();
433 double etaMC = particle->Eta();
434 if(fabs(etaMC)>0.6)continue;
435 Bool_t mcInDtoE= kFALSE;
436 Bool_t mcInBtoE= kFALSE;
438 Bool_t MChijing = fMC->IsFromBGEvent(iParticle);
439 //if(!MChijing)printf("not MC hijing");
441 if(!MChijing)iHijing = 0;
445 mcphoinfo[2] = iHijing;
446 if(fPDG==111)Hpi0pTcheck->Fill(mcphoinfo);
447 if(fPDG==221)HETApTcheck->Fill(mcphoinfo);
448 if(fabs(fPDG)==411 || fabs(fPDG)==413 || fabs(fPDG)==421 || fabs(fPDG)==423 || fabs(fPDG)==431)HDpTcheck->Fill(pTMC,iHijing);
449 if(fabs(fPDG)==511 || fabs(fPDG)==513 || fabs(fPDG)==521 || fabs(fPDG)==523 || fabs(fPDG)==531)HBpTcheck->Fill(pTMC,iHijing);
451 if(particle->GetFirstMother()>-1 && fPDG==22)
453 int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
454 if(parentPID==111 || parentPID==221)HphopTcheck->Fill(pTMC,iHijing); // pi0->g & eta->g
457 if(particle->GetFirstMother()>-1 && fabs(fPDG)==11)
459 int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
460 double pTMCparent = stack->Particle(particle->GetFirstMother())->Pt();
461 if((fabs(parentPID)==411 || fabs(parentPID)==413 || fabs(parentPID)==421 || fabs(parentPID)==423 || fabs(parentPID)==431)&& fabs(fPDG)==11)mcInDtoE = kTRUE;
462 if((fabs(parentPID)==511 || fabs(parentPID)==513 || fabs(parentPID)==521 || fabs(parentPID)==523 || fabs(parentPID)==531)&& fabs(fPDG)==11)mcInBtoE = kTRUE;
463 if((mcInBtoE || mcInDtoE) && fabs(mcZvertex)<10.0)
465 fInputHFEMC->Fill(cent,pTMC);
471 mcinfo[4] = pTMCparent;
472 fInputHFEMC_weight->Fill(mcinfo);
477 if(proR<7.0 && fabs(fPDG)==11)fInputAlle->Fill(cent,pTMC);
484 Int_t fNOtrks = fESD->GetNumberOfTracks();
485 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
487 Double_t pVtxZ = -999;
488 pVtxZ = pVtx->GetZ();
490 if(TMath::Abs(pVtxZ)>10) return;
493 if(fNOtrks<1) return;
496 AliPIDResponse *pidResponse = fInputHandler->GetPIDResponse();
498 AliDebug(1, "Using default PID Response");
499 pidResponse = AliHFEtools::GetDefaultPID(kFALSE, fInputEvent->IsA() == AliAODEvent::Class());
502 fPID->SetPIDResponse(pidResponse);
504 fCFM->SetRecEventInfo(fESD);
508 //if(cent>90.) return;
512 FindTriggerClusters();
516 for(Int_t iCluster=0; iCluster<fESD->GetNumberOfCaloClusters(); iCluster++)
518 AliESDCaloCluster *clust = fESD->GetCaloCluster(iCluster);
519 if(clust && clust->IsEMCAL())
521 double clustE = clust->E();
522 float emcx[3]; // cluster pos
523 clust->GetPosition(emcx);
524 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
525 double emcphi = clustpos.Phi();
526 double emceta = clustpos.Eta();
528 calInfo[0] = emcphi; calInfo[1] = emceta; calInfo[2] = clustE; calInfo[3] = cent; calInfo[4] = clust->Chi2();
529 //fEMCAccE->Fill(calInfo);
530 hEMCAccE->Fill(cent,clustE);
531 if(clustE>maxE)maxE = clustE;
536 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
537 AliESDtrack* track = fESD->GetTrack(iTracks);
539 printf("ERROR: Could not receive track %d\n", iTracks);
543 //--- Get MC informtion
545 int parentlabel = 99999;
546 int parentPID = 99999;
547 int grand_parentlabel = 99999;
548 int grand_parentPID = 99999;
549 Bool_t mcPho = kFALSE;
550 Bool_t mcDtoE= kFALSE;
551 Bool_t mcBtoE= kFALSE;
552 Bool_t mcOrgPi0 = kFALSE;
553 Bool_t mcOrgEta = kFALSE;
556 double mcMompT = 0.0;
557 //double mcGrandMompT = 0.0;
558 double mcWeight = -10.0;
563 if(fmcData && fMC && stack)
565 Int_t label = TMath::Abs(track->GetLabel());
566 mcLabel = track->GetLabel();
571 Bool_t MChijing = fMC->IsFromBGEvent(label);
572 if(!MChijing)iHijing = 0;
574 TParticle* particle = stack->Particle(label);
575 int mcpid = particle->GetPdgCode();
576 mcpT = particle->Pt();
577 //printf("MCpid = %d",mcpid);
578 if(particle->GetFirstMother()>-1)
580 //int parentlabel = particle->GetFirstMother();
581 //int parentPID = stack->Particle(particle->GetFirstMother())->GetPdgCode();
582 //mcMompT = stack->Particle(particle->GetFirstMother())->Pt();
583 FindMother(particle, parentlabel, parentPID);
584 mcMompT = stack->Particle(parentlabel)->Pt();
585 if((parentPID==22 || parentPID==111 || parentPID==221)&& fabs(mcpid)==11)mcPho = kTRUE;
586 if((fabs(parentPID)==411 || fabs(parentPID)==413 || fabs(parentPID)==421 || fabs(parentPID)==423 || fabs(parentPID)==431)&& fabs(mcpid)==11)mcDtoE = kTRUE;
587 if((fabs(parentPID)==511 || fabs(parentPID)==513 || fabs(parentPID)==521 || fabs(parentPID)==523 || fabs(parentPID)==531)&& fabs(mcpid)==11)mcBtoE = kTRUE;
589 // make D->e pT correlation
590 if(mcDtoE)fMomDtoE->Fill(mcpT,mcMompT);
592 //cout << "check PID = " << parentPID << endl;
593 //cout << "check pho = " << mcPho << endl;
594 //cout << "check D or B = " << mcDtoE << endl;
596 if(parentPID==111 && fabs(mcpid)==11 && mcMompT>0.0)
598 //cout << "find pi0->e " << endl;
600 mcWeight = GetMCweight(mcMompT);
603 if(parentPID==221 && fabs(mcpid)==11 && mcMompT>0.0)
605 //cout << "find Eta->e " << endl;
607 mcWeight = GetMCweightEta(mcMompT);
610 // access grand parent
611 TParticle* particle_parent = stack->Particle(parentlabel); // get parent pointer
612 //if(particle_parent->GetFirstMother()>-1 && parentPID==22 && fabs(mcpid)==11) // get grand parent g->e
613 if(particle_parent->GetFirstMother()>-1 && (parentPID==22 || parentPID==111) && fabs(mcpid)==11) // get grand parent g->e
615 //int grand_parentPID = stack->Particle(particle_parent->GetFirstMother())->GetPdgCode();
616 //double pTtmp = stack->Particle(particle_parent->GetFirstMother())->Pt();
617 FindMother(particle_parent, grand_parentlabel, grand_parentPID);
618 double mcGrandpT = stack->Particle(grand_parentlabel)->Pt();
619 if(grand_parentPID==111 && mcGrandpT>0.0)
621 // check eta->pi0 decay !
622 int grand2_parentlabel = 99999; int grand2_parentPID = 99999;
623 TParticle* particle_grand = stack->Particle(grand_parentlabel); // get parent pointer
624 FindMother(particle_grand, grand2_parentlabel, grand2_parentPID);
625 if(grand2_parentPID==221)
627 //cout << "find Eta->e " << endl;
628 double mcGrandpT2 = stack->Particle(grand2_parentlabel)->Pt();
630 mcWeight = GetMCweight(mcGrandpT2);
631 mcMompT = mcGrandpT2;
635 //cout << "find pi0->e " << endl;
637 mcWeight = GetMCweight(mcGrandpT);
642 if(grand_parentPID==221 && mcGrandpT>0.0)
644 //cout << "find Eta->e " << endl;
647 mcWeight = GetMCweightEta(mcGrandpT);
653 //cout << "===================="<<endl;
654 //cout << "mcDtoE : " << mcDtoE << endl;
655 //cout << "mcBtoE : " << mcBtoE << endl;
656 //cout << "mcPho : " << mcPho << endl;
658 if(fabs(mcpid)==11)mcele= 0.;
659 //cout << "check e: " << mcele << endl;
660 if(fabs(mcpid)==11 && mcDtoE)mcele= 1.;
661 //cout << "check D->e: " << mcele << endl;
662 if(fabs(mcpid)==11 && mcBtoE)mcele= 2.;
663 //cout << "check B->e: " << mcele << endl;
664 if(fabs(mcpid)==11 && mcPho)mcele= 3.;
665 //cout << "check Pho->e: " << mcele << endl;
667 //cout << "check PID " << endl;
670 //cout << "!= 11" << endl;
671 //cout << mcpid << endl;
675 //cout << "mcele==-1" << endl;
676 //cout << mcele << endl;
677 //cout << mcpid << endl;
680 } // end of mcLabel>-1
682 } // <------ end of MC info.
684 //cout << "Pi0 = " << mcOrgPi0 << " ; Eta = " << mcOrgEta << endl;
685 //printf("weight = %f\n",mcWeight);
687 if(TMath::Abs(track->Eta())>0.6) continue;
688 if(TMath::Abs(track->Pt()<2.5)) continue;
690 fTrackPtBefTrkCuts->Fill(track->Pt());
691 // RecKine: ITSTPC cuts
692 if(!ProcessCutStep(AliHFEcuts::kStepRecKineITSTPC, track)) continue;
695 if(fRejectKinkMother) { // Quick and dirty fix to reject both kink mothers and daughters
696 if(track->GetKinkIndex(0) != 0) continue;
700 if(!ProcessCutStep(AliHFEcuts::kStepRecPrim, track)) continue;
702 // HFEcuts: ITS layers cuts
703 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsITS, track)) continue;
705 // HFE cuts: TPC PID cleanup
706 if(!ProcessCutStep(AliHFEcuts::kStepHFEcutsTPC, track)) continue;
708 int nTPCcl = track->GetTPCNcls();
709 //int nTPCclF = track->GetTPCNclsF(); // warnings
710 int nITS = track->GetNcls(0);
712 fTrackPtAftTrkCuts->Fill(track->Pt());
714 Double_t mom = -999., eop=-999., pt = -999., dEdx=-999., fTPCnSigma=-10, phi=-999., eta=-999.;
718 //Int_t charge = track->Charge();
723 dEdx = track->GetTPCsignal();
724 fTPCnSigma = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(track, AliPID::kElectron) : 1000;
726 //cout << "nSigma correctoon-----" << endl;
727 //cout << "org = " << fTPCnSigma << endl;
729 if(!fmcData) // nsigma eta correction
731 double nSigexpCorr = NsigmaCorrection(eta,cent);
732 fTPCnSigma -= nSigexpCorr;
735 //cout << "correction = " << fTPCnSigma << endl;
737 //--- track cluster match
739 double ncells = -1.0;
743 double rmatch = -1.0;
744 double nmatch = -1.0;
745 //double oppstatus = 0.0;
747 Bool_t MaxEmatch = kFALSE;
749 Int_t clsId = track->GetEMCALcluster();
751 AliESDCaloCluster *clust = fESD->GetCaloCluster(clsId);
752 if(clust && clust->IsEMCAL()){
754 double clustE = clust->E();
755 if(clustE==maxE)MaxEmatch = kTRUE;
756 eop = clustE/fabs(mom);
758 //double clustT = clust->GetTOF();
759 ncells = clust->GetNCells();
760 m02 = clust->GetM02();
761 m20 = clust->GetM20();
762 disp = clust->GetDispersion();
763 double delphi = clust->GetTrackDx();
764 double deleta = clust->GetTrackDz();
765 rmatch = sqrt(pow(delphi,2)+pow(deleta,2));
766 nmatch = clust->GetNTracksMatched();
767 emctof = clust->GetTOF();
768 //cout << "emctof = " << emctof << endl;
769 cout << "eop org = "<< eop << endl;
773 double mceopcorr = MCEopMeanCorrection(pt,cent);
776 cout << "eop corr = " << eop << endl;
779 valdedx[0] = pt; valdedx[1] = nITS; valdedx[2] = phi; valdedx[3] = eta; valdedx[4] = fTPCnSigma;
780 valdedx[5] = eop; valdedx[6] = rmatch; valdedx[7] = ncells, valdedx[8] = nmatch; valdedx[9] = m20; valdedx[10] = mcpT;
781 //valdedx[11] = cent; valdedx[12] = dEdx; valdedx[13] = oppstatus; valdedx[14] = nTPCcl;
782 valdedx[11] = cent; valdedx[12] = dEdx; valdedx[13] = eoporg; valdedx[14] = nTPCcl;
784 fEleInfo->Fill(valdedx);
789 //Get Cal info PID response
793 Double_t nSigmaEop = fPID->GetPIDResponse()->NumberOfSigmasEMCAL(track,AliPID::kElectron,eop2,ss);
794 if(fTPCnSigma>-1.5 && fTPCnSigma<3.0 && nITS>2.5 && nTPCcl>100)
799 valEop[2] = nSigmaEop;
800 fElenSigma->Fill(valEop);
803 // --- tarck cut & e ID
805 if(nITS<2.5)continue;
806 if(nTPCcl<100)continue;
808 CheckNclust->Fill(nTPCcl);
809 CheckNits->Fill(nITS);
811 fdEdxBef->Fill(mom,fTPCnSigma);
812 fTPCnsigma->Fill(mom,fTPCnSigma);
813 if(fTPCnSigma >= -1.0 && fTPCnSigma <= 3)fTrkEovPBef->Fill(pt,eop);
815 //--- track accepted by HFE
818 AliHFEpidObject hfetrack;
819 hfetrack.SetAnalysisType(AliHFEpidObject::kESDanalysis);
820 hfetrack.SetRecTrack(track);
822 if((0.0< cent) && (cent<5.0)) binct = 0.5;
823 if((5.0< cent) && (cent<10.0)) binct = 1.5;
824 if((10.0< cent) && (cent<20.0)) binct = 2.5;
825 if((20.0< cent) && (cent<30.0)) binct = 3.5;
826 if((30.0< cent) && (cent<40.0)) binct = 4.5;
827 if((40.0< cent) && (cent<50.0)) binct = 5.5;
828 if((50.0< cent) && (cent<60.0)) binct = 6.5;
829 if((60.0< cent) && (cent<70.0)) binct = 7.5;
830 if((70.0< cent) && (cent<80.0)) binct = 8.5;
831 if((80.0< cent) && (cent<90.0)) binct = 9.5;
832 if((90.0< cent) && (cent<100.0)) binct = 10.5;
834 hfetrack.SetCentrality((int)binct); //added
836 if(!fPID->IsSelected(&hfetrack, NULL, "", fPIDqa)) pidpassed = 0;
838 if(pidpassed==0) continue;
842 Bool_t fFlagPhotonicElec = kFALSE;
843 Bool_t fFlagConvinatElec = kFALSE;
847 SelectPhotonicElectron(iTracks,cent,track,fFlagPhotonicElec,fFlagConvinatElec,fTPCnSigma,m20,eop,mcele,mcWeight,iHijing,mcOrgPi0,mcOrgEta);
851 SelectPhotonicElectron2(iTracks,cent,track,fFlagPhotonicElec,fFlagConvinatElec,fTPCnSigma,m20,eop,mcele,mcWeight,iHijing,mcOrgPi0,mcOrgEta);
854 //--- check reco eff. with TPC
858 phoval[2] = fTPCnSigma;
862 //if((fTPCnSigma >= -5.0 && fTPCnSigma <= 5) && mcele>-1 && mcPho && mcOrgPi0)
863 if((fTPCnSigma >= -5.0 && fTPCnSigma <= 5) && (mcOrgPi0 || mcOrgEta))
865 if(iHijing==1)mcWeight = 1.0;
868 fIncpTMCpho_pi0e_TPC->Fill(phoval,mcWeight);
869 if(fFlagPhotonicElec) fPhoElecPtMC_pi0e_TPC->Fill(phoval,mcWeight);
870 if(fFlagConvinatElec) fSameElecPtMC_pi0e_TPC->Fill(phoval,mcWeight);
874 fIncpTMCpho_eta_TPC->Fill(phoval,mcWeight);
875 if(fFlagPhotonicElec) fPhoElecPtMC_eta_TPC->Fill(phoval,mcWeight);
876 if(fFlagConvinatElec) fSameElecPtMC_eta_TPC->Fill(phoval,mcWeight);
880 //+++++++ E/p cut ++++++++++++++++
882 if(eop<0.9 || eop>1.3)continue;
884 fTrkEovPAft->Fill(pt,eop);
885 fdEdxAft->Fill(mom,fTPCnSigma);
888 fIncpT->Fill(cent,pt);
889 if(fFlagPhotonicElec) fPhoElecPt->Fill(cent,pt);
890 if(fFlagConvinatElec) fSameElecPt->Fill(cent,pt);
892 if(m20>0.0 && m20<0.3)
894 fIncpTM20->Fill(cent,pt);
895 ftimingEle->Fill(pt,emctof);
896 if(fFlagPhotonicElec) fPhoElecPtM20->Fill(cent,pt);
897 if(fFlagConvinatElec) fSameElecPtM20->Fill(cent,pt);
903 double recopT = SumpT(iTracks,track);
905 if(m20>0.0 && m20<0.3)
907 if(MaxEmatch)fIncMaxE->Fill(cent,pt);
910 fIncReco->Fill(cent,recopT);
911 if(fFlagPhotonicElec) fPhoReco->Fill(cent,recopT);
912 if(fFlagConvinatElec) fSamReco->Fill(cent,recopT);
915 fIncRecoMaxE->Fill(cent,recopT);
916 if(fFlagPhotonicElec) fPhoRecoMaxE->Fill(cent,recopT);
917 if(fFlagConvinatElec) fSamRecoMaxE->Fill(cent,recopT);
924 // check label for electron candidiates
927 if(mcLabel==0)idlabel = 0;
928 fLabelCheck->Fill(pt,idlabel);
929 if(mcLabel==0)fgeoFake->Fill(phi,eta);
931 if(mcLabel<0 && m20>0.0 && m20<0.3 && fTPCnSigma>-1 && fTPCnSigma<3)
933 fFakeTrk0->Fill(cent,pt);
936 if(mcele>-1) // select MC electrons
939 fIncpTMChfeAll->Fill(cent,pt);
940 if(m20>0.0 && m20<0.3)fIncpTMCM20hfeAll->Fill(cent,pt);
941 if(m20>0.0 && m20<0.3 && fTPCnSigma>-1 && fTPCnSigma<3)fFakeTrk1->Fill(cent,pt);
943 if(mcBtoE || mcDtoE) // select B->e & D->e
945 fIncpTMChfe->Fill(cent,pt);
946 if(m20>0.0 && m20<0.3)
948 //cout << "MC label = " << mcLabel << endl;
949 fIncpTMCM20hfe->Fill(cent,pt);
950 fIncpTMCM20hfeCheck->Fill(cent,mcpT);
951 fIncpTMCM20hfeCheck_weight->Fill(phoval);
955 if(mcPho) // select photonic electrons
958 fIncpTMCpho->Fill(phoval);
959 if(fFlagPhotonicElec) fPhoElecPtMC->Fill(phoval);
960 if(fFlagConvinatElec) fSameElecPtMC->Fill(phoval);
962 if(m20>0.0 && m20<0.3)
964 fIncpTMCM20pho->Fill(phoval);
965 if(fFlagPhotonicElec) fPhoElecPtMCM20->Fill(phoval);
966 if(fFlagConvinatElec) fSameElecPtMCM20->Fill(phoval);
970 if(iHijing==1)mcWeight = 1.0;
973 fIncpTMCM20pho_pi0e->Fill(phoval,mcWeight);
974 if(fFlagPhotonicElec) fPhoElecPtMCM20_pi0e->Fill(phoval,mcWeight);
975 if(fFlagConvinatElec) fSameElecPtMCM20_pi0e->Fill(phoval,mcWeight);
979 fIncpTMCM20pho_eta->Fill(phoval,mcWeight);
980 if(fFlagPhotonicElec) fPhoElecPtMCM20_eta->Fill(phoval,mcWeight);
981 if(fFlagConvinatElec) fSameElecPtMCM20_eta->Fill(phoval,mcWeight);
989 PostData(1, fOutputList);
991 //_________________________________________
992 void AliAnalysisTaskHFECal::UserCreateOutputObjects()
996 //Bool_t mcData = kFALSE;
997 if(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())
1000 printf("+++++ MC Data available");
1004 printf("++++++++= MC analysis \n");
1008 printf("++++++++ real data analysis \n");
1011 printf("+++++++ QA hist %d",fqahist);
1014 fGeom = AliEMCALGeometry::GetInstance("EMCAL_COMPLETEV1");
1016 //--------Initialize PID
1017 //fPID->SetHasMCData(kFALSE);
1018 fPID->SetHasMCData(fmcData);
1019 if(!fPID->GetNumberOfPIDdetectors())
1021 fPID->AddDetector("TPC", 0);
1022 //fPID->AddDetector("EMCAL", 1); <--- apply PID selection in task
1026 const char *cutmodel;
1028 params[0] = -1.0; //sigma min
1029 double maxnSig = 3.0;
1032 params[0] = -5.0; //sigma min
1036 for(Int_t a=0;a<11;a++)fPID->ConfigureTPCcentralityCut(a,cutmodel,params,maxnSig);
1038 fPID->SortDetectors();
1039 fPIDqa = new AliHFEpidQAmanager();
1040 fPIDqa->Initialize(fPID);
1042 //------- fcut --------------
1043 fCuts = new AliHFEcuts();
1044 fCuts->CreateStandardCuts();
1045 //fCuts->SetMinNClustersTPC(100);
1046 fCuts->SetMinNClustersTPC(90);
1047 fCuts->SetMinRatioTPCclusters(0.6);
1048 fCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
1049 //fCuts->SetMinNClustersITS(3);
1050 fCuts->SetMinNClustersITS(2);
1051 fCuts->SetCutITSpixel(AliHFEextraCuts::kAny);
1052 fCuts->SetCheckITSLayerStatus(kFALSE);
1053 fCuts->SetVertexRange(10.);
1054 fCuts->SetTOFPIDStep(kFALSE);
1055 fCuts->SetPtRange(2, 50);
1056 fCuts->SetMaxImpactParam(3.,3.);
1058 //--------Initialize correction Framework and Cuts
1059 fCFM = new AliCFManager;
1060 const Int_t kNcutSteps = AliHFEcuts::kNcutStepsMCTrack + AliHFEcuts::kNcutStepsRecTrack + AliHFEcuts::kNcutStepsDETrack;
1061 fCFM->SetNStepParticle(kNcutSteps);
1062 for(Int_t istep = 0; istep < kNcutSteps; istep++)
1063 fCFM->SetParticleCutsList(istep, NULL);
1066 AliWarning("Cuts not available. Default cuts will be used");
1067 fCuts = new AliHFEcuts;
1068 fCuts->CreateStandardCuts();
1070 fCuts->Initialize(fCFM);
1072 //---------Output Tlist
1073 fOutputList = new TList();
1074 fOutputList->SetOwner();
1075 fOutputList->Add(fPIDqa->MakeList("PIDQA"));
1077 fNoEvents = new TH1F("fNoEvents","",4,-0.5,3.5) ;
1078 fOutputList->Add(fNoEvents);
1080 Int_t binsE[5] = {250, 100, 1000, 200, 10};
1081 Double_t xminE[5] = {1.0, -1, 0.0, 0, -0.5};
1082 Double_t xmaxE[5] = {3.5, 1, 100.0, 100, 9.5};
1083 fEMCAccE = new THnSparseD("fEMCAccE","EMC acceptance & E;#eta;#phi;Energy;Centrality;trugCondition;",5,binsE,xminE,xmaxE);
1084 //if(fqahist==1)fOutputList->Add(fEMCAccE);
1086 hEMCAccE = new TH2F("hEMCAccE","Cluster Energy",200,0,100,100,0,20);
1087 fOutputList->Add(hEMCAccE);
1089 fTrkpt = new TH1F("fTrkpt","track pt",100,0,50);
1090 fOutputList->Add(fTrkpt);
1092 fTrackPtBefTrkCuts = new TH1F("fTrackPtBefTrkCuts","track pt before track cuts",100,0,50);
1093 fOutputList->Add(fTrackPtBefTrkCuts);
1095 fTrackPtAftTrkCuts = new TH1F("fTrackPtAftTrkCuts","track pt after track cuts",100,0,50);
1096 fOutputList->Add(fTrackPtAftTrkCuts);
1098 fTPCnsigma = new TH2F("fTPCnsigma", "TPC - n sigma",100,0,50,200,-10,10);
1099 fOutputList->Add(fTPCnsigma);
1101 fTrkEovPBef = new TH2F("fTrkEovPBef","track E/p before HFE pid",100,0,50,100,0,2);
1102 fOutputList->Add(fTrkEovPBef);
1104 fTrkEovPAft = new TH2F("fTrkEovPAft","track E/p after HFE pid",100,0,50,100,0,2);
1105 fOutputList->Add(fTrkEovPAft);
1107 fdEdxBef = new TH2F("fdEdxBef","track dEdx vs p before HFE pid",100,0,50,200,-10,10);
1108 fOutputList->Add(fdEdxBef);
1110 fdEdxAft = new TH2F("fdEdxAft","track dEdx vs p after HFE pid",100,0,50,200,-10,10);
1111 fOutputList->Add(fdEdxAft);
1113 fIncpT = new TH2F("fIncpT","HFE pid electro vs. centrality",200,0,100,100,0,50);
1114 fOutputList->Add(fIncpT);
1116 fIncpTM20 = new TH2F("fIncpTM20","HFE pid electro vs. centrality with M20",200,0,100,100,0,50);
1117 fOutputList->Add(fIncpTM20);
1119 Int_t nBinspho[9] = { 10, 30, 600, 60, 50, 4, 40, 8, 30};
1120 Double_t minpho[9] = { 0., 0., -0.1, 40, 0, -0.5, 0,-1.5, 0};
1121 Double_t maxpho[9] = {100., 30., 0.5, 100, 1, 3.5, 2, 6.5, 30};
1123 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);
1124 if(fqahist==1)fOutputList->Add(fInvmassLS);
1126 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);
1127 if(fqahist==1)fOutputList->Add(fInvmassULS);
1129 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);
1130 if(fqahist==1)fOutputList->Add(fInvmassLSmc);
1132 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);
1133 if(fqahist==1)fOutputList->Add(fInvmassULSmc);
1135 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 );
1136 fInvmassLSreco->Sumw2();
1137 fOutputList->Add(fInvmassLSreco);
1139 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 );
1140 fInvmassULSreco->Sumw2();
1141 fOutputList->Add(fInvmassULSreco);
1143 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 );
1144 fInvmassLSmc0->Sumw2();
1145 fOutputList->Add(fInvmassLSmc0);
1147 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 );
1148 fInvmassLSmc1->Sumw2();
1149 fOutputList->Add(fInvmassLSmc1);
1151 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 );
1152 fInvmassLSmc2->Sumw2();
1153 fOutputList->Add(fInvmassLSmc2);
1155 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 );
1156 fInvmassLSmc3->Sumw2();
1157 fOutputList->Add(fInvmassLSmc3);
1159 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 );
1160 fInvmassULSmc0->Sumw2();
1161 fOutputList->Add(fInvmassULSmc0);
1163 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 );
1164 fInvmassULSmc1->Sumw2();
1165 fOutputList->Add(fInvmassULSmc1);
1167 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 );
1168 fInvmassULSmc2->Sumw2();
1169 fOutputList->Add(fInvmassULSmc2);
1171 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 );
1172 fInvmassULSmc3->Sumw2();
1173 fOutputList->Add(fInvmassULSmc3);
1175 fOpeningAngleLS = new TH1F("fOpeningAngleLS","Opening angle for LS pairs",100,0,1);
1176 fOutputList->Add(fOpeningAngleLS);
1178 fOpeningAngleULS = new TH1F("fOpeningAngleULS","Opening angle for ULS pairs",100,0,1);
1179 fOutputList->Add(fOpeningAngleULS);
1181 fPhotoElecPt = new TH1F("fPhotoElecPt", "photonic electron pt",100,0,50);
1182 fOutputList->Add(fPhotoElecPt);
1184 fPhoElecPt = new TH2F("fPhoElecPt", "Pho-inclusive electron pt",200,0,100,100,0,50);
1185 fOutputList->Add(fPhoElecPt);
1187 fPhoElecPtM20 = new TH2F("fPhoElecPtM20", "Pho-inclusive electron pt with M20",200,0,100,100,0,50);
1188 fOutputList->Add(fPhoElecPtM20);
1190 fSameElecPt = new TH2F("fSameElecPt", "Same-inclusive electron pt",200,0,100,100,0,50);
1191 fOutputList->Add(fSameElecPt);
1193 fSameElecPtM20 = new TH2F("fSameElecPtM20", "Same-inclusive electron pt with M20",200,0,100,100,0,50);
1194 fOutputList->Add(fSameElecPtM20);
1196 fCent = new TH1F("fCent","Centrality",200,0,100) ;
1197 fOutputList->Add(fCent);
1199 // Make common binning
1200 const Double_t kMinP = 0.;
1201 const Double_t kMaxP = 20.;
1203 // 1st histogram: TPC dEdx with/without EMCAL (p, pT, TPC Signal, phi, eta, Sig, e/p, ,match, cell, M02, M20, Disp, Centrality, select)
1204 Int_t nBins[16] = { 100, 7, 60, 20, 90, 100, 25, 40, 10, 100, 100, 10, 250, 100, 100, 8};
1205 Double_t min[16] = {kMinP, -0.5, 1.0, -1.0, -5.0, 0, 0, 0, 0.0, 0.0, 0.0, 0, 0, 0, 80, -1.5};
1206 Double_t max[16] = {kMaxP, 6.5, 4.0, 1.0, 4.0, 2.0, 0.05, 40, 10, 1.0, 20.0, 100, 100, 2.0, 180, 6.5};
1207 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);
1208 fOutputList->Add(fEleInfo);
1210 // Make common binning
1211 Int_t nBinsEop[3] = { 10, 50, 100};
1212 Double_t minEop[3] = { 0, 0, -5};
1213 Double_t maxEop[3] = {100, 50, 5};
1214 fElenSigma= new THnSparseD("fElenSigma", "Electron nSigma; cent; pT [GeV/c]; nSigma", 3, nBinsEop, minEop, maxEop);
1215 fOutputList->Add(fElenSigma);
1220 fClsEBftTrigCut = new TH1F("fClsEBftTrigCut","cluster E before trigger selection",1000,0,100);
1221 fOutputList->Add(fClsEBftTrigCut);
1223 fClsEAftTrigCut = new TH1F("fClsEAftTrigCut","cluster E if cls has 0 trigcut channel",1000,0,100);
1224 fOutputList->Add(fClsEAftTrigCut);
1226 fClsEAftTrigCut1 = new TH1F("fClsEAftTrigCut1","cluster E if cls with trig channel",1000,0,100);
1227 fOutputList->Add(fClsEAftTrigCut1);
1229 fClsEAftTrigCut2 = new TH1F("fClsEAftTrigCut2","cluster E if cls with trigcut channel",1000,0,100);
1230 fOutputList->Add(fClsEAftTrigCut2);
1232 fClsEAftTrigCut3 = new TH1F("fClsEAftTrigCut3","cluster E if cls with trigcut channel + nCell>Ecorrect",1000,0,100);
1233 fOutputList->Add(fClsEAftTrigCut3);
1235 fClsEAftTrigCut4 = new TH1F("fClsEAftTrigCut4","cluster E if cls with trigcut channel + nCell>Ecorrect + cls time cut",1000,0,100);
1236 fOutputList->Add(fClsEAftTrigCut4);
1238 fClsETime = new TH2F("fClsETime", "Cls time vs E; E; time;",1000,0,100,1000,-0.0000002,0.0000009);
1239 fOutputList->Add(fClsETime);
1241 fClsETime1 = new TH2F("fClsETime1", "Cls time vs E if cls contains trigger channel; E; time;",1000,0,100,1000,-0.0000002,0.0000009);
1242 fOutputList->Add(fClsETime1);
1244 fTrigTimes = new TH1F("fTrigTimes", "Trigger time; time; N;",25,0,25);
1245 fOutputList->Add(fTrigTimes);
1247 fCellCheck = new TH2F("fCellCheck", "Cell vs E; E GeV; Cell ID",10,6,26,12000,0,12000);
1248 fOutputList->Add(fCellCheck);
1252 fInputHFEMC = new TH2F("fInputHFEMC","Input MC HFE pid electro vs. centrality",200,0,100,100,0,50);
1253 fOutputList->Add(fInputHFEMC);
1255 fInputAlle = new TH2F("fInputAlle","Input MC electro vs. centrality",200,0,100,100,0,50);
1256 fOutputList->Add(fInputAlle);
1258 fIncpTMChfe = new TH2F("fIncpTMChfe","MC HFE pid electro vs. centrality",200,0,100,100,0,50);
1259 fOutputList->Add(fIncpTMChfe);
1261 fIncpTMChfeAll = new TH2F("fIncpTMChfeAll","MC Alle pid electro vs. centrality",200,0,100,100,0,50);
1262 fOutputList->Add(fIncpTMChfeAll);
1264 fIncpTMCM20hfe = new TH2F("fIncpTMCM20hfe","MC HFE pid electro vs. centrality with M20",200,0,100,100,0,50);
1265 fOutputList->Add(fIncpTMCM20hfe);
1267 fIncpTMCM20hfeAll = new TH2F("fIncpTMCM20hfeAll","MC Alle pid electro vs. centrality with M20",200,0,100,100,0,50);
1268 fOutputList->Add(fIncpTMCM20hfeAll);
1270 fIncpTMCM20hfeCheck = new TH2F("fIncpTMCM20hfeCheck","MC HFE pid electro vs. centrality with M20 Check",200,0,100,100,0,50);
1271 fOutputList->Add(fIncpTMCM20hfeCheck);
1273 Int_t nBinspho2[5] = { 200, 100, 7, 3, 700};
1274 Double_t minpho2[5] = { 0., 0., -2.5, -0.5, 0.};
1275 Double_t maxpho2[5] = {100., 50., 4.5, 2.5, 70.};
1277 fInputHFEMC_weight = new THnSparseD("fInputHFEMC_weight", "MC HFE electron pt",5,nBinspho2,minpho2,maxpho2);
1278 fOutputList->Add(fInputHFEMC_weight);
1280 fIncpTMCM20hfeCheck_weight = new THnSparseD("fIncpTMCM20hfeCheck_weight", "HFE electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1281 fOutputList->Add(fIncpTMCM20hfeCheck_weight);
1283 fIncpTMCpho = new THnSparseD("fIncpTMCpho","MC Pho pid electro vs. centrality",5,nBinspho2,minpho2,maxpho2);
1284 fOutputList->Add(fIncpTMCpho);
1286 fIncpTMCM20pho = new THnSparseD("fIncpTMCM20pho","MC Pho pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1287 fOutputList->Add(fIncpTMCM20pho);
1289 fPhoElecPtMC = new THnSparseD("fPhoElecPtMC", "MC Pho-inclusive electron pt",5,nBinspho2,minpho2,maxpho2);
1290 fOutputList->Add(fPhoElecPtMC);
1292 fPhoElecPtMCM20 = new THnSparseD("fPhoElecPtMCM20", "MC Pho-inclusive electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1293 fOutputList->Add(fPhoElecPtMCM20);
1295 fSameElecPtMC = new THnSparseD("fSameElecPtMC", "MC Same-inclusive electron pt",5,nBinspho2,minpho2,maxpho2);
1296 fOutputList->Add(fSameElecPtMC);
1298 fSameElecPtMCM20 = new THnSparseD("fSameElecPtMCM20", "MC Same-inclusive electron pt with M20",5,nBinspho2,minpho2,maxpho2);
1299 fOutputList->Add(fSameElecPtMCM20);
1301 fIncpTMCM20pho_pi0e = new THnSparseD("fIncpTMCM20pho_pi0e","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1302 fIncpTMCM20pho_pi0e->Sumw2();
1303 fOutputList->Add(fIncpTMCM20pho_pi0e);
1305 fPhoElecPtMCM20_pi0e = new THnSparseD("fPhoElecPtMCM20_pi0e", "MC Pho-inclusive electron pt with M20 pi0->e",5,nBinspho2,minpho2,maxpho2);
1306 fPhoElecPtMCM20_pi0e->Sumw2();
1307 fOutputList->Add(fPhoElecPtMCM20_pi0e);
1309 fSameElecPtMCM20_pi0e = new THnSparseD("fSameElecPtMCM20_pi0e", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1310 fSameElecPtMCM20_pi0e->Sumw2();
1311 fOutputList->Add(fSameElecPtMCM20_pi0e);
1313 fIncpTMCM20pho_eta = new THnSparseD("fIncpTMCM20pho_eta","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1314 fIncpTMCM20pho_eta->Sumw2();
1315 fOutputList->Add(fIncpTMCM20pho_eta);
1317 fPhoElecPtMCM20_eta = new THnSparseD("fPhoElecPtMCM20_eta", "MC Pho-inclusive electron pt with M20 pi0->e",5,nBinspho2,minpho2,maxpho2);
1318 fPhoElecPtMCM20_eta->Sumw2();
1319 fOutputList->Add(fPhoElecPtMCM20_eta);
1321 fSameElecPtMCM20_eta = new THnSparseD("fSameElecPtMCM20_eta", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1322 fSameElecPtMCM20_eta->Sumw2();
1323 fOutputList->Add(fSameElecPtMCM20_eta);
1325 fIncpTMCpho_pi0e_TPC = new THnSparseD("fIncpTMCpho_pi0e_TPC","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1326 fIncpTMCpho_pi0e_TPC->Sumw2();
1327 fOutputList->Add(fIncpTMCpho_pi0e_TPC);
1329 fPhoElecPtMC_pi0e_TPC = new THnSparseD("fPhoElecPtMC_pi0e_TPC", "MC Pho-inclusive electron pt with pi0->e",5,nBinspho2,minpho2,maxpho2);
1330 fPhoElecPtMC_pi0e_TPC->Sumw2();
1331 fOutputList->Add(fPhoElecPtMC_pi0e_TPC);
1333 fSameElecPtMC_pi0e_TPC = new THnSparseD("fSameElecPtMC_pi0e_TPC", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1334 fSameElecPtMC_pi0e_TPC->Sumw2();
1335 fOutputList->Add(fSameElecPtMC_pi0e_TPC);
1337 fIncpTMCpho_eta_TPC = new THnSparseD("fIncpTMCpho_eta_TPC","MC Pho pi0->e pid electro vs. centrality with M20",5,nBinspho2,minpho2,maxpho2);
1338 fIncpTMCpho_eta_TPC->Sumw2();
1339 fOutputList->Add(fIncpTMCpho_eta_TPC);
1341 fPhoElecPtMC_eta_TPC = new THnSparseD("fPhoElecPtMC_eta_TPC", "MC Pho-inclusive electron pt with pi0->e",5,nBinspho2,minpho2,maxpho2);
1342 fPhoElecPtMC_eta_TPC->Sumw2();
1343 fOutputList->Add(fPhoElecPtMC_eta_TPC);
1345 fSameElecPtMC_eta_TPC = new THnSparseD("fSameElecPtMC_eta_TPC", "MC Same-inclusive electron pt pi0->e",5,nBinspho2,minpho2,maxpho2);
1346 fSameElecPtMC_eta_TPC->Sumw2();
1347 fOutputList->Add(fSameElecPtMC_eta_TPC);
1352 CheckNclust = new TH1D("CheckNclust","cluster check",200,0,200);
1353 fOutputList->Add(CheckNclust);
1355 CheckNits = new TH1D("CheckNits","ITS cluster check",8,-0.5,7.5);
1356 fOutputList->Add(CheckNits);
1358 Hpi0pTcheck = new TH2D("Hpi0pTcheck","Pi0 pT from Hijing",100,0,50,3,-0.5,2.5);
1359 fOutputList->Add(Hpi0pTcheck);
1361 HETApTcheck = new TH2D("HETApTcheck","Eta pT from Hijing",100,0,50,3,-0.5,2.5);
1362 fOutputList->Add(HETApTcheck);
1365 Int_t nBinspho3[3] = { 200, 100, 3};
1366 Double_t minpho3[3] = { 0., 0., -0.5};
1367 Double_t maxpho3[3] = {100., 50., 2.5};
1369 Hpi0pTcheck = new THnSparseD("Hpi0pTcheck","Pi0 pT from Hijing",3,nBinspho3,minpho3,maxpho3);
1370 fOutputList->Add(Hpi0pTcheck);
1372 HETApTcheck = new THnSparseD("HETApTcheck","Eta pT from Hijing",3,nBinspho3,minpho3,maxpho3);
1373 fOutputList->Add(HETApTcheck);
1375 HphopTcheck = new TH2D("HphopTcheck","Pho pT from Hijing",100,0,50,3,-0.5,2.5);
1376 fOutputList->Add(HphopTcheck);
1378 HDpTcheck = new TH2D("HDpTcheck","D pT from Hijing",100,0,50,3,-0.5,2.5);
1379 fOutputList->Add(HDpTcheck);
1381 HBpTcheck = new TH2D("HBpTcheck","B pT from Hijing",100,0,50,3,-0.5,2.5);
1382 fOutputList->Add(HBpTcheck);
1385 fpTCheck = new TH1D("fpTCheck","pT check",500,0,50);
1386 fOutputList->Add(fpTCheck);
1388 fMomDtoE = new TH2D("fMomDtoE","D->E pT correlations;e p_{T} GeV/c;D p_{T} GeV/c",400,0,40,400,0,40);
1389 fOutputList->Add(fMomDtoE);
1391 fLabelCheck = new TH2D("fLabelCheck","MC label",50,0,50,5,-1.5,3.5);
1392 fOutputList->Add(fLabelCheck);
1394 fgeoFake = new TH2D("fgeoFake","Label==0 eta and phi",628,0,6.28,200,-1,1);
1395 fOutputList->Add(fgeoFake);
1397 fFakeTrk0 = new TH2D("fFakeTrk0","fake trakcs",10,0,100,20,0,20);
1398 fOutputList->Add(fFakeTrk0);
1400 fFakeTrk1 = new TH2D("fFakeTrk1","true all e a.f. eID",10,0,100,20,0,20);
1401 fOutputList->Add(fFakeTrk1);
1403 ftimingEle = new TH2D("ftimingEle","electron TOF",100,0,20,100,1e-7,1e-6);
1404 fOutputList->Add(ftimingEle);
1407 // note: parameters 01/31new.TPCnSigmaEtaDep
1408 // 70-90 delta_eta = 0.2
1410 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};
1411 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)
1412 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)
1413 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)
1414 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)
1415 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)
1416 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)
1417 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)
1419 fnSigEtaCorr[0] = new TGraphErrors(12,etaval,corr0); // 0-10
1420 fnSigEtaCorr[1] = new TGraphErrors(12,etaval,corr1); // 10-20
1421 fnSigEtaCorr[2] = new TGraphErrors(12,etaval,corr2); // 20-30
1422 fnSigEtaCorr[3] = new TGraphErrors(12,etaval,corr3); // 30-40
1423 fnSigEtaCorr[4] = new TGraphErrors(12,etaval,corr4); // 40-50
1424 fnSigEtaCorr[5] = new TGraphErrors(12,etaval,corr5); // 50-70
1425 fnSigEtaCorr[6] = new TGraphErrors(12,etaval,corr6); // 70-90
1427 fIncMaxE = new TH2D("fIncMaxE","Inc",10,0,100,10,0,100);
1428 fOutputList->Add(fIncMaxE);
1430 fIncReco = new TH2D("fIncReco","Inc",10,0,100,100,0,500);
1431 fOutputList->Add(fIncReco);
1433 fPhoReco = new TH2D("fPhoReco","Pho",10,0,100,100,0,500);
1434 fOutputList->Add(fPhoReco);
1436 fSamReco = new TH2D("fSamReco","Same",10,0,100,100,0,500);
1437 fOutputList->Add(fSamReco);
1439 fIncRecoMaxE = new TH2D("fIncRecoMaxE","Inc",10,0,100,100,0,500);
1440 fOutputList->Add(fIncRecoMaxE);
1442 fPhoRecoMaxE = new TH2D("fPhoRecoMaxE","Pho",10,0,100,100,0,500);
1443 fOutputList->Add(fPhoRecoMaxE);
1445 fSamRecoMaxE = new TH2D("fSamRecoMaxE","Same",10,0,100,100,0,500);
1446 fOutputList->Add(fSamRecoMaxE);
1448 PostData(1,fOutputList);
1451 //________________________________________________________________________
1452 void AliAnalysisTaskHFECal::Terminate(Option_t *)
1454 // Info("Terminate");
1455 AliAnalysisTaskSE::Terminate();
1458 //________________________________________________________________________
1459 Bool_t AliAnalysisTaskHFECal::ProcessCutStep(Int_t cutStep, AliVParticle *track)
1461 // Check single track cuts for a given cut step
1462 const Int_t kMCOffset = AliHFEcuts::kNcutStepsMCTrack;
1463 if(!fCFM->CheckParticleCuts(cutStep + kMCOffset, track)) return kFALSE;
1466 //_________________________________________
1467 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)
1469 //Identify non-heavy flavour electrons using Invariant mass method
1471 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
1472 fTrackCuts->SetRequireTPCRefit(kTRUE);
1473 fTrackCuts->SetRequireITSRefit(kTRUE);
1474 fTrackCuts->SetEtaRange(-0.9,0.9);
1475 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
1476 fTrackCuts->SetMinNClustersTPC(90);
1478 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1479 Double_t bfield = fESD->GetMagneticField();
1480 Double_t emass = 0.51*0.001; // (0.51 MeV)
1482 double ptEle = track->Pt(); //add
1483 if(ibgevent==0 && w > 0.0)
1485 fpTCheck->Fill(ptEle,w);
1488 Bool_t flagPhotonicElec = kFALSE;
1489 Bool_t flagConvinatElec = kFALSE;
1494 Int_t label = TMath::Abs(track->GetLabel());
1495 TParticle* particle = stack->Particle(label);
1496 p1 = particle->GetFirstMother();
1499 //for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1500 for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1501 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1503 printf("ERROR: Could not receive track %d\n", jTracks);
1506 if(itrack==jTracks)continue;
1512 Int_t label2 = TMath::Abs(trackAsso->GetLabel());
1513 TParticle* particle2 = stack->Particle(label2);
1514 Bool_t MChijing_ass = fMC->IsFromBGEvent(label2);
1515 if(MChijing_ass)jbgevent =1;
1516 if(particle2->GetFirstMother()>-1)
1517 p2 = particle2->GetFirstMother();
1520 Double_t dEdxAsso = -999., ptPrim=-999., ptAsso=-999., openingAngle = -999.;
1521 Double_t mass=999., width = -999;
1522 Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1524 //ptPrim = track->Pt();
1527 dEdxAsso = trackAsso->GetTPCsignal();
1528 ptAsso = trackAsso->Pt();
1529 Int_t chargeAsso = trackAsso->Charge();
1530 Int_t charge = track->Charge();
1533 if(ptAsso <fMimpTassCut) continue;
1534 if(!fTrackCuts->AcceptTrack(trackAsso)) continue;
1535 //if(dEdxAsso <65 || dEdxAsso>100) continue;
1536 double fTPCnSigmaAss = fPID->GetPIDResponse() ? fPID->GetPIDResponse()->NumberOfSigmasTPC(trackAsso, AliPID::kElectron) : 1000;
1537 //cout << "fTPCnSigmaAss = " << fTPCnSigmaAss << endl;
1538 //cout << "fTPCnSigmaAss Cut = " << fMimNsigassCut << endl;
1539 if(fTPCnSigmaAss <fMimNsigassCut || fTPCnSigmaAss>5) continue;
1540 //cout << "fTPCnSigmaAss a.f. cut = " << fTPCnSigmaAss << endl;
1542 Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1543 if(charge>0) fPDGe1 = -11;
1544 if(chargeAsso>0) fPDGe2 = -11;
1546 //printf("chargeAsso = %d\n",chargeAsso);
1547 //printf("charge = %d\n",charge);
1548 if(charge == chargeAsso) fFlagLS = kTRUE;
1549 if(charge != chargeAsso) fFlagULS = kTRUE;
1551 //printf("fFlagLS = %d\n",fFlagLS);
1552 //printf("fFlagULS = %d\n",fFlagULS);
1555 AliKFParticle::SetField(bfield);
1556 AliKFParticle ge1(*track, fPDGe1);
1557 AliKFParticle ge2(*trackAsso, fPDGe2);
1559 if(fSetMassNonlinear)
1561 ge1.SetNonlinearMassConstraint(emass);
1562 ge2.SetNonlinearMassConstraint(emass);
1565 AliKFParticle recg(ge1, ge2);
1569 AliKFVertex primV(*pVtx);
1573 recg.SetProductionVertex(primV);
1577 if(recg.GetNDF()<1) continue;
1578 Double_t chi2recg = recg.GetChi2()/recg.GetNDF();
1579 Double_t chi2cut = 3.0;
1582 if(fSetMassConstraint)
1584 recg.SetMassConstraint(0,0.0001);
1587 recg.GetMass(mass,width);
1589 if(fSetMassWidthCut && width>1e10)continue;
1592 openingAngle = ge1.GetAngle(ge2);
1593 if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1594 if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1597 if(shower>0.0 && shower<0.3)ishower = 1;
1601 phoinfo[1] = ptPrim;
1604 //phoinfo[3] = dEdxAsso;
1605 phoinfo[4] = openingAngle;
1606 phoinfo[5] = ishower;
1609 phoinfo[8] = ptAsso;
1611 if(fFlagLS) fInvmassLS->Fill(phoinfo);
1612 if(fFlagULS) fInvmassULS->Fill(phoinfo);
1613 if(fFlagLS && ibgevent==0 && jbgevent==0) fInvmassLSmc->Fill(phoinfo,w);
1614 if(fFlagULS && ibgevent==0 && jbgevent==0)
1616 fInvmassULSmc->Fill(phoinfo,w);
1618 //printf("fInvmassCut %f\n",fInvmassCut);
1619 //printf("openingAngle %f\n",fOpeningAngleCut);
1622 if(openingAngle > fOpeningAngleCut) continue;
1624 //if(TMath::Sqrt(TMath::Abs(chi2recg))>chi2cut) continue;
1625 if(chi2recg>chi2cut) continue;
1627 if(fFlagLS ) fInvmassLSreco->Fill(ptPrim,mass);
1628 if(fFlagULS) fInvmassULSreco->Fill(ptPrim,mass);
1631 //printf("mce =%f\n",mce);
1632 if(mce<-0.5) // mce==-1. is real
1634 //printf("Real data\n");
1635 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1636 flagPhotonicElec = kTRUE;
1638 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec){
1639 flagConvinatElec = kTRUE;
1645 //printf("MC data\n");
1649 //cout << "tagpi0 = " << tagpi0 << " ; tageta = " << tageta << endl;
1650 if(fFlagLS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassLSmc0->Fill(ptPrim,mass);
1651 if(fFlagULS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassULSmc0->Fill(ptPrim,mass);
1652 if(fFlagLS && ibgevent==0 && jbgevent==0 && tageta) fInvmassLSmc1->Fill(ptPrim,mass);
1653 if(fFlagULS && ibgevent==0 && jbgevent==0 && tageta) fInvmassULSmc1->Fill(ptPrim,mass);
1654 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassLSmc2->Fill(ptPrim,mass);
1655 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassULSmc2->Fill(ptPrim,mass);
1656 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassLSmc3->Fill(ptPrim,mass);
1657 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassULSmc3->Fill(ptPrim,mass);
1660 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (ibgevent==jbgevent)){
1661 //if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (p1==p2)){ <--- only MC train (55,56) v5-03-68-AN & 69 for check
1662 flagPhotonicElec = kTRUE;
1664 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec && (ibgevent==jbgevent)){
1665 flagConvinatElec = kTRUE;
1670 fFlagPhotonicElec = flagPhotonicElec;
1671 fFlagConvinatElec = flagConvinatElec;
1675 //_________________________________________
1676 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)
1678 //Identify non-heavy flavour electrons using Invariant mass method
1680 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
1681 fTrackCuts->SetRequireTPCRefit(kTRUE);
1682 fTrackCuts->SetRequireITSRefit(kTRUE);
1683 fTrackCuts->SetEtaRange(-0.9,0.9);
1684 //fTrackCuts->SetRequireSigmaToVertex(kTRUE);
1685 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
1686 fTrackCuts->SetMinNClustersTPC(90);
1688 //const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
1689 Double_t eMass = TDatabasePDG::Instance()->GetParticle(11)->Mass(); //Electron mass in GeV
1690 Double_t bfield = fESD->GetMagneticField();
1692 double ptEle = track->Pt(); //add
1693 if(ibgevent==0 && w > 0.0)
1695 fpTCheck->Fill(ptEle,w);
1698 Bool_t flagPhotonicElec = kFALSE;
1699 Bool_t flagConvinatElec = kFALSE;
1704 Int_t label = TMath::Abs(track->GetLabel());
1705 TParticle* particle = stack->Particle(label);
1706 p1 = particle->GetFirstMother();
1709 //for(Int_t jTracks = itrack+1; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1710 for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
1711 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
1713 printf("ERROR: Could not receive track %d\n", jTracks);
1716 if(itrack==jTracks)continue;
1722 Int_t label2 = TMath::Abs(trackAsso->GetLabel());
1723 TParticle* particle2 = stack->Particle(label2);
1724 Bool_t MChijing_ass = fMC->IsFromBGEvent(label2);
1725 if(MChijing_ass)jbgevent =1;
1726 if(particle2->GetFirstMother()>-1)
1727 p2 = particle2->GetFirstMother();
1730 Double_t dEdxAsso = -999., ptPrim=-999., ptAsso=-999., openingAngle = -999.;
1731 //Double_t mass=999., width = -999;
1733 Bool_t fFlagLS=kFALSE, fFlagULS=kFALSE;
1735 //ptPrim = track->Pt();
1738 dEdxAsso = trackAsso->GetTPCsignal();
1739 ptAsso = trackAsso->Pt();
1740 Int_t chargeAsso = trackAsso->Charge();
1741 Int_t charge = track->Charge();
1744 if(ptAsso <0.5) continue;
1745 if(!fTrackCuts->AcceptTrack(trackAsso)) continue;
1746 if(dEdxAsso <65 || dEdxAsso>100) continue; //11a pass1
1748 Int_t fPDGe1 = 11; Int_t fPDGe2 = 11;
1749 if(charge>0) fPDGe1 = -11;
1750 if(chargeAsso>0) fPDGe2 = -11;
1752 //printf("chargeAsso = %d\n",chargeAsso);
1753 //printf("charge = %d\n",charge);
1754 if(charge == chargeAsso) fFlagLS = kTRUE;
1755 if(charge != chargeAsso) fFlagULS = kTRUE;
1758 double xt1 = 0.0, xt2 = 0.0;
1759 Double_t p1at[3] = {0,0,0};
1760 Double_t p2at[3] = {0,0,0};
1761 //double dca12 = trackAsso->GetDCA(track,bfield,xt2,xt1); //DCA track1-track2
1762 double kHasdcaT1 = track->GetPxPyPzAt(xt1,bfield,p1at); //Track1
1763 double kHasdcaT2 = trackAsso->GetPxPyPzAt(xt2,bfield,p2at); //Track2
1764 if(!kHasdcaT1 || !kHasdcaT2) AliWarning("It could be a problem in the extrapolation");
1765 //cout << "dca = " << dca12 << endl;
1767 TLorentzVector electron1;
1768 TLorentzVector electron2;
1769 TLorentzVector mother;
1771 electron1.SetXYZM(p1at[0], p1at[1], p1at[2], eMass);
1772 electron2.SetXYZM(p2at[0], p2at[1], p2at[2], eMass);
1773 openingAngle = TVector2::Phi_0_2pi(electron1.Angle(electron2.Vect()));
1775 mother = electron1 + electron2;
1776 //double invmassAtDCA = mother.M();
1779 TLorentzVector electron1_2D;
1780 TLorentzVector electron2_2D;
1781 TLorentzVector mother_2D;
1783 double pT1at = sqrt(pow(p1at[0],2)+pow(p1at[1],2));
1784 double pT2at = sqrt(pow(p2at[0],2)+pow(p2at[1],2));
1786 electron1_2D.SetXYZM(pT1at, 0.0, p1at[2], eMass);
1787 electron2_2D.SetXYZM(pT2at, 0.0, p2at[2], eMass);
1789 mother_2D = electron1_2D + electron2_2D;
1790 double invmassAtDCA_2D = mother_2D.M();
1791 mass = invmassAtDCA_2D;
1794 if(fFlagLS) fOpeningAngleLS->Fill(openingAngle);
1795 if(fFlagULS) fOpeningAngleULS->Fill(openingAngle);
1798 if(shower>0.0 && shower<0.3)ishower = 1;
1802 phoinfo[1] = ptPrim;
1805 //phoinfo[3] = dEdxAsso;
1806 phoinfo[4] = openingAngle;
1807 phoinfo[5] = ishower;
1810 phoinfo[8] = ptAsso;
1812 if(fFlagLS) fInvmassLS->Fill(phoinfo);
1813 if(fFlagULS) fInvmassULS->Fill(phoinfo);
1814 if(fFlagLS && ibgevent==0 && jbgevent==0) fInvmassLSmc->Fill(phoinfo,w);
1815 if(fFlagULS && ibgevent==0 && jbgevent==0)
1817 fInvmassULSmc->Fill(phoinfo,w);
1819 //printf("fInvmassCut %f\n",fInvmassCut);
1820 //printf("openingAngle %f\n",fOpeningAngleCut);
1823 if(openingAngle > fOpeningAngleCut) continue;
1825 //if(TMath::Sqrt(TMath::Abs(chi2recg))>chi2cut) continue;
1826 //if(chi2recg>chi2cut) continue;
1828 if(fFlagLS ) fInvmassLSreco->Fill(ptPrim,mass);
1829 if(fFlagULS) fInvmassULSreco->Fill(ptPrim,mass);
1832 //printf("mce =%f\n",mce);
1833 if(mce<-0.5) // mce==-1. is real
1835 //printf("Real data\n");
1836 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec){
1837 flagPhotonicElec = kTRUE;
1839 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec){
1840 flagConvinatElec = kTRUE;
1846 //printf("MC data\n");
1850 //cout << "tagpi0 = " << tagpi0 << " ; tageta = " << tageta << endl;
1851 if(fFlagLS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassLSmc0->Fill(ptPrim,mass);
1852 if(fFlagULS && ibgevent==0 && jbgevent==0 && tagpi0) fInvmassULSmc0->Fill(ptPrim,mass);
1853 if(fFlagLS && ibgevent==0 && jbgevent==0 && tageta) fInvmassLSmc1->Fill(ptPrim,mass);
1854 if(fFlagULS && ibgevent==0 && jbgevent==0 && tageta) fInvmassULSmc1->Fill(ptPrim,mass);
1855 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassLSmc2->Fill(ptPrim,mass);
1856 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tagpi0) fInvmassULSmc2->Fill(ptPrim,mass);
1857 if(fFlagLS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassLSmc3->Fill(ptPrim,mass);
1858 if(fFlagULS && ibgevent==0 && jbgevent==0 && (p1==p2) && tageta) fInvmassULSmc3->Fill(ptPrim,mass);
1861 if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (ibgevent==jbgevent)){
1862 //if(mass<fInvmassCut && fFlagULS && !flagPhotonicElec && (p1==p2)){ <--- only MC train (55,56) v5-03-68-AN & 69 for check
1863 flagPhotonicElec = kTRUE;
1865 if(mass<fInvmassCut && fFlagLS && !flagConvinatElec && (ibgevent==jbgevent)){
1866 flagConvinatElec = kTRUE;
1871 fFlagPhotonicElec = flagPhotonicElec;
1872 fFlagConvinatElec = flagConvinatElec;
1876 //-------------------------------------------
1878 void AliAnalysisTaskHFECal::FindMother(TParticle* part, int &label, int &pid)
1880 //int label = 99999;
1883 if(part->GetFirstMother()>-1)
1885 label = part->GetFirstMother();
1886 pid = stack->Particle(label)->GetPdgCode();
1888 //cout << "Find Mother : label = " << label << " ; pid" << pid << endl;
1891 double AliAnalysisTaskHFECal::GetMCweight(double mcPi0pT)
1893 double weight = 1.0;
1895 if(mcPi0pT>0.0 && mcPi0pT<5.0)
1897 weight = 0.323*mcPi0pT/(TMath::Exp(-1.6+0.767*mcPi0pT+0.0285*mcPi0pT*mcPi0pT));
1901 weight = 115.0/(0.718*mcPi0pT*TMath::Power(mcPi0pT,3.65));
1906 double AliAnalysisTaskHFECal::GetMCweightEta(double mcEtapT)
1908 double weight = 1.0;
1910 weight = 223.3/TMath::Power((TMath::Exp(-0.17*mcEtapT-0.0322*mcEtapT*mcEtapT)+mcEtapT/1.69),5.65);
1915 //_________________________________________
1916 void AliAnalysisTaskHFECal::FindTriggerClusters()
1918 //cout << "finding trigger patch" << endl;
1920 const int nModuleCols = 2;
1921 const int nModuleRows = 5;
1922 const int nColsFeeModule = 48;
1923 const int nRowsFeeModule = 24;
1924 const int nColsFaltroModule = 24;
1925 const int nRowsFaltroModule = 12;
1926 //const int faltroWidthMax = 20;
1928 // part 1, trigger extraction -------------------------------------
1929 Int_t globCol, globRow;
1930 //Int_t ntimes=0, nTrigChannel=0, nTrigChannelCut=0, trigInCut=0;
1931 Int_t ntimes=0, nTrigChannel=0, nTrigChannelCut=0;
1933 //Int_t trigtimes[faltroWidthMax];
1934 Double_t cellTime[nColsFeeModule*nModuleCols][nRowsFeeModule*nModuleRows];
1935 Double_t cellEnergy[nColsFeeModule*nModuleCols][nRowsFeeModule*nModuleRows];
1936 //Double_t fTrigCutLow = 6;
1937 //Double_t fTrigCutHigh = 10;
1938 Double_t fTimeCutLow = 469e-09;
1939 Double_t fTimeCutHigh = 715e-09;
1941 AliESDCaloTrigger * fCaloTrigger = fESD->GetCaloTrigger( "EMCAL" );
1943 // erase trigger maps
1944 for(Int_t i = 0; i < nColsFaltroModule*nModuleCols; i++ )
1946 for(Int_t j = 0; j < nRowsFaltroModule*nModuleRows; j++ )
1948 ftriggersCut[i][j] = 0;
1949 ftriggers[i][j] = 0;
1950 ftriggersTime[i][j] = 0;
1954 Int_t iglobCol=0, iglobRow=0;
1955 // go through triggers
1956 if( fCaloTrigger->GetEntries() > 0 )
1959 fCaloTrigger->Reset();
1960 while( fCaloTrigger->Next() )
1962 fCaloTrigger->GetPosition( globCol, globRow );
1963 fCaloTrigger->GetNL0Times( ntimes );
1966 if( ntimes < 1 ) continue;
1967 // get precise timings
1968 fCaloTrigger->GetL0Times( trigtimes );
1970 for(Int_t i = 0; i < ntimes; i++ )
1972 // save the first trigger time in channel
1973 if( i == 0 || triggersTime[globCol][globRow] > trigtimes[i] )
1974 triggersTime[globCol][globRow] = trigtimes[i];
1975 //printf("trigger times: %d\n",trigtimes[i]);
1977 if(trigtimes[i] > fTrigCutLow && trigtimes[i] < fTrigCutHigh )
1980 fTrigTimes->Fill(trigtimes[i]);
1984 //L1 analysis from AliAnalysisTaskEMCALTriggerQA
1986 fCaloTrigger->GetTriggerBits(bit);
1987 //cout << "bit = " << bit << endl;
1990 fCaloTrigger->GetL1TimeSum(ts);
1991 //cout << "ts = " << ts << endl;
1992 if (ts > 0)ftriggers[globCol][globRow] = 1;
1993 // number of triggered channels in event
1996 if(ts>0 && (bit >> 6 & 0x1))
2001 //cout << "ts cut = " << ts << endl;
2002 //cout << "globCol = " << globCol << endl;
2003 //cout << "globRow = " << globRow << endl;
2004 ftriggersCut[globCol][globRow] = 1;
2007 } // calo trigger entries
2008 } // has calo trigger entries
2010 // part 2 go through the clusters here -----------------------------------
2011 //cout << " part 2 go through the clusters here ----------------------------------- " << endl;
2012 Int_t nCluster=0, nCell=0, iCell=0, gCell=0;
2013 Short_t cellAddr, nSACell;
2015 //Int_t nSACell, iSACell, mclabel;
2017 Double_t cellAmp=0, cellTimeT=0, clusterTime=0, efrac=0;
2018 Int_t nSupMod, nModule, nIphi, nIeta, iphi, ieta, gphi, geta, feta, fphi;
2020 TRefArray *fCaloClusters = new TRefArray();
2021 fESD->GetEMCALClusters( fCaloClusters );
2022 nCluster = fCaloClusters->GetEntries();
2025 // save all cells times if there are clusters
2028 for(Int_t i = 0; i < nColsFeeModule*nModuleCols; i++ ){
2029 for(Int_t j = 0; j < nRowsFeeModule*nModuleRows; j++ ){
2030 cellTime[i][j] = 0.;
2031 cellEnergy[i][j] = 0.;
2036 AliESDCaloCells *fCaloCells = fESD->GetEMCALCells();
2037 //AliVCaloCells fCaloCells = fESD->GetEMCALCells();
2038 nSACell = fCaloCells->GetNumberOfCells();
2039 for(iSACell = 0; iSACell < nSACell; iSACell++ ){
2040 // get the cell info *fCal
2041 fCaloCells->GetCell( iSACell, cellAddr, cellAmp, cellTimeT , mclabel, efrac);
2043 // get cell position
2044 fGeom->GetCellIndex( cellAddr, nSupMod, nModule, nIphi, nIeta );
2045 fGeom->GetCellPhiEtaIndexInSModule( nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2047 // convert co global phi eta
2048 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2049 geta = ieta + nColsFeeModule*(nSupMod%2);
2051 // save cell time and energy
2052 cellTime[geta][gphi] = cellTimeT;
2053 cellEnergy[geta][gphi] = cellAmp;
2058 Int_t nClusterTrig, nClusterTrigCut;
2059 UShort_t *cellAddrs;
2060 Double_t clsE=-999, clsEta=-999, clsPhi=-999;
2061 Float_t clsPos[3] = {0.,0.,0.};
2063 for(Int_t icl=0; icl<fESD->GetNumberOfCaloClusters(); icl++)
2065 AliESDCaloCluster *cluster = fESD->GetCaloCluster(icl);
2066 if(!cluster || !cluster->IsEMCAL()) continue;
2068 // get cluster cells
2069 nCell = cluster->GetNCells();
2071 // get cluster energy
2072 clsE = cluster->E();
2074 // get cluster position
2075 cluster->GetPosition(clsPos);
2076 TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
2077 clsEta = clsPosVec.Eta();
2078 clsPhi = clsPosVec.Phi();
2080 // get the cell addresses
2081 cellAddrs = cluster->GetCellsAbsId();
2083 // check if the cluster contains cell, that was marked as triggered
2085 nClusterTrigCut = 0;
2087 // loop the cells to check, if cluser in acceptance
2088 // any cluster with a cell outside acceptance is not considered
2089 for( iCell = 0; iCell < nCell; iCell++ )
2092 //if(clsE>6.0)fCellCheck->Fill(clsE,cellAddrs[iCell]);
2094 // get cell position
2095 fGeom->GetCellIndex( cellAddrs[iCell], nSupMod, nModule, nIphi, nIeta );
2096 fGeom->GetCellPhiEtaIndexInSModule( nSupMod,nModule, nIphi, nIeta, iphi, ieta);
2098 // convert co global phi eta
2099 gphi = iphi + nRowsFeeModule*(nSupMod/2);
2100 geta = ieta + nColsFeeModule*(nSupMod%2);
2102 if( cellTime[geta][gphi] > 0. ){
2103 clusterTime += cellTime[geta][gphi];
2107 // get corresponding FALTRO
2111 //cout << "fphi = " << fphi << endl;
2112 //cout << "feta = " << feta << endl;
2114 // try to match with a triggered
2115 if( ftriggers[feta][fphi]==1)
2118 if( ftriggersCut[feta][fphi]==1)
2119 { nClusterTrigCut++;
2122 //cout << "nClusterTrigCut : " << nClusterTrigCut << endl;
2128 clusterTime = clusterTime / (Double_t)gCell;
2129 // fix the reconstriction code time 100ns jumps
2130 if( fESD->GetBunchCrossNumber() % 4 < 2 )
2131 clusterTime -= 0.0000001;
2133 //fClsETime->Fill(clsE,clusterTime);
2134 //fClsEBftTrigCut->Fill(clsE);
2137 //fClsETime1->Fill(clsE,clusterTime);
2141 cluster->SetChi2(1);
2142 //fClsEAftTrigCut1->Fill(clsE);
2145 if(nClusterTrigCut>0){
2146 cluster->SetChi2(2);
2147 //fClsEAftTrigCut2->Fill(clsE);
2150 if(nClusterTrigCut>0 && ( nCell > (1 + clsE / 3)))
2152 cluster->SetChi2(3);
2153 //fClsEAftTrigCut3->Fill(clsE);
2156 if(nClusterTrigCut>0 && (nCell > (1 + clsE / 3) )&&( clusterTime > fTimeCutLow && clusterTime < fTimeCutHigh ))
2158 // cluster->SetChi2(4);
2159 //fClsEAftTrigCut4->Fill(clsE);
2161 if(nClusterTrigCut<1)
2163 cluster->SetChi2(0);
2165 //fClsEAftTrigCut->Fill(clsE);
2171 // <-------- only MC correction
2172 double AliAnalysisTaskHFECal::MCEopMeanCorrection(double pTmc, float central)
2174 TF1 *fcorr0 = new TF1("fcorr0","[0]*tanh([1]+[2]*x)");
2175 TF1 *fcorr1 = new TF1("fcorr1","[0]*tanh([1]+[2]*x)");
2179 if(central>0 && central<=10)
2181 fcorr0->SetParameters(1.045,1.288,3.18e-01); //
2182 fcorr1->SetParameters(9.91e-01,3.466,2.344);
2184 else if(central>10 && central<=20)
2186 fcorr0->SetParameters(1.029,8.254e-01,4.07e-01);
2187 fcorr1->SetParameters(0.975,2.276,1.501e-01);
2189 else if(central>20 && central<=30)
2191 fcorr0->SetParameters(1.01,8.795e-01,3.904e-01);
2192 fcorr1->SetParameters(9.675e-01,1.654,2.583e-01);
2194 else if(central>30 && central<=40)
2196 fcorr0->SetParameters(1.00,1.466,2.305e-1);
2197 fcorr1->SetParameters(9.637e-01,1.473,2.754e-01);
2199 else if(central>40 && central<=50)
2201 fcorr0->SetParameters(1.00,1.422,1.518e-01);
2202 fcorr1->SetParameters(9.59e-01,1.421,2.931e-01);
2205 else if(central>50 && central<=70)
2207 fcorr0->SetParameters(0.989,2.495,2.167);
2208 fcorr1->SetParameters(0.961,1.734,1.438e-01);
2210 else if(central>70 && central<=100)
2212 fcorr0->SetParameters(0.981,-3.373,3.93327);
2213 fcorr1->SetParameters(9.574e-01,1.698,1.58e-01);
2217 shift = fcorr0->Eval(pTmc)-fcorr1->Eval(pTmc);
2225 // <-------- only Data correction
2226 double AliAnalysisTaskHFECal::NsigmaCorrection(double tmpeta, float central)
2230 if(central>=0 && central<10)
2234 else if(central>=10 && central<20)
2238 else if(central>=20 && central<30)
2242 else if(central>=30 && central<40)
2246 else if(central>=40 && central<50)
2250 else if(central>=50 && central<70)
2259 double shift = fnSigEtaCorr[icent]->Eval(tmpeta);
2261 //cout << "eta correction"<< endl;
2262 //cout << "cent = "<< central<< endl;
2263 //cout << "icent = "<< icent << endl;
2264 //cout << "shift = "<< shift << endl;
2271 double AliAnalysisTaskHFECal::SumpT(Int_t itrack, AliESDtrack* track)
2274 fTrackCuts->SetAcceptKinkDaughters(kFALSE);
2275 fTrackCuts->SetRequireTPCRefit(kTRUE);
2276 fTrackCuts->SetRequireITSRefit(kTRUE);
2277 fTrackCuts->SetEtaRange(-0.9,0.9);
2278 //fTrackCuts->SetRequireSigmaToVertex(kTRUE);
2279 fTrackCuts->SetMaxChi2PerClusterTPC(3.5);
2280 fTrackCuts->SetMinNClustersTPC(90);
2282 double pTrecp = track->Pt();
2283 double phiorg = track->Phi();
2284 double etaorg = track->Eta();
2286 for(Int_t jTracks = 0; jTracks<fESD->GetNumberOfTracks(); jTracks++){
2287 AliESDtrack* trackAsso = fESD->GetTrack(jTracks);
2289 printf("ERROR: Could not receive track %d\n", jTracks);
2292 if(itrack==jTracks)continue;
2293 double pTAss = trackAsso->Pt();
2294 double etaAss = trackAsso->Eta();
2295 double phiAss = trackAsso->Phi();
2297 double delphi = phiorg - phiAss;
2298 double deleta = etaorg - etaAss;
2300 double R = sqrt(pow(deleta,2)+pow(delphi,2));
2301 if(pTAss<0.5)continue;
2302 if(R<0.4)pTrecp+=pTAss;