8 #include <TClonesArray.h>
13 #include "AliAnalysisManager.h"
14 #include "AliAODEvent.h"
15 #include "AliAODCaloCluster.h"
16 #include "AliESDCaloCluster.h"
17 #include "AliVTrack.h"
19 #include "AliVEventHandler.h"
21 #include "AliEMCALGeometry.h"
41 fHistMatchEtaPhiAll(0),
42 fHistMatchEtaPhiAllTr(0),
43 fHistMatchEtaPhiAllCl(0),
45 fHistNclusMatchvsCent(0),
50 fHistNClusMatchCent(0)
54 for(Int_t i=0; i<8; i++) {
56 fHistEsubPchRat[i] = 0;
57 fHistEsubPchRatAll[i] = 0;
60 fHistMatchEvsP[i] = 0;
61 fHistMatchdRvsEP[i] = 0;
62 fHistNMatchEnergy[i] = 0;
64 fHistEmbTrackMatchesOversub[i] = 0;
65 fHistNonEmbTrackMatchesOversub[i] = 0;
66 fHistOversubMCClusters[i] = 0;
67 fHistOversubNonMCClusters[i] = 0;
70 for(Int_t j=0; j<4; j++)
71 fHistNCellsEnergy[i][j] = 0;
74 for(Int_t j=0; j<9; j++) {
75 for(Int_t k=0; k<2; k++)
76 fHistMatchEtaPhi[i][j][k] = 0;
84 fOutCaloName(
"CaloClustersCorr"),
93 fHistMatchEtaPhiAll(0),
94 fHistMatchEtaPhiAllTr(0),
95 fHistMatchEtaPhiAllCl(0),
97 fHistNclusMatchvsCent(0),
102 fHistNClusMatchCent(0)
106 for(Int_t i=0; i<8; i++) {
122 for(Int_t j=0; j<4; j++)
126 for(Int_t j=0; j<9; j++) {
127 for(Int_t k=0; k<2; k++)
134 fBranchNames=
"ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
151 else if (p>=0.5 && p<1.0)
153 else if (p>=1.0 && p<1.5)
155 else if (p>=1.5 && p<2.)
157 else if (p>=2. && p<3.)
159 else if (p>=3. && p<4.)
161 else if (p>=4. && p<5.)
163 else if (p>=5. && p<8.)
176 Double_t EtaSigma[9]={0.0097,0.0075,0.0059,0.0055,0.0053,0.005,0.005,0.0045,0.0042};
177 return 2.0*EtaSigma[pbin];
186 Double_t PhiMean[9]={0.036,
195 return PhiMean[pbin];
196 }
else if (centbin==1) {
197 Double_t PhiMean[9]={0.036,
206 return PhiMean[pbin];
207 }
else if (centbin==2) {
208 Double_t PhiMean[9]={0.036,
217 return PhiMean[pbin];
218 }
else if (centbin==3) {
219 Double_t PhiMean[9]={0.036,
228 return PhiMean[pbin];
229 }
else if (centbin==4) {
230 Double_t PhiMean[9]={0.036,
239 return PhiMean[pbin]*(-1.);
240 }
else if (centbin==5) {
241 Double_t PhiMean[9]={0.036,
250 return PhiMean[pbin]*(-1.);
251 }
else if (centbin==6) {
252 Double_t PhiMean[9]={0.036,
261 return PhiMean[pbin]*(-1.);
262 }
else if (centbin==7) {
263 Double_t PhiMean[9]={0.036,
272 return PhiMean[pbin]*(-1.);
284 Double_t PhiSigma[9]={0.0221,
293 return 2.*PhiSigma[pbin];
294 }
else if (centbin==1) {
295 Double_t PhiSigma[9]={0.0217,
304 return 2.*PhiSigma[pbin];
305 }
else if (centbin==2) {
306 Double_t PhiSigma[9]={0.0211,
315 return 2.*PhiSigma[pbin];
316 }
else if (centbin==3) {
317 Double_t PhiSigma[9]={0.0215,
326 return 2.*PhiSigma[pbin];
327 }
else if (centbin==4) {
328 Double_t PhiSigma[9]={0.0199,
337 return 2.*PhiSigma[pbin];
338 }
else if (centbin==5) {
339 Double_t PhiSigma[9]={0.0200,
348 return 2.*PhiSigma[pbin];
349 }
else if (centbin==6) {
350 Double_t PhiSigma[9]={0.0202,
359 return 2.*PhiSigma[pbin];
360 }
else if (centbin==7) {
361 Double_t PhiSigma[9]={0.0205,
370 return 2.*PhiSigma[pbin];
399 for(Int_t icent=0; icent<nCentChBins; ++icent) {
400 for(Int_t ipt=0; ipt<9; ++ipt) {
401 for(Int_t ieta=0; ieta<2; ++ieta) {
402 name = Form(
"fHistMatchEtaPhi_%i_%i_%i",icent,ipt,ieta);
410 name = Form(
"fHistEsubPch_%i",icent);
411 temp = Form(
"%s (Nmatches==1)",name.Data());
413 fHistEsubPch[icent]->SetXTitle(
"#sum p (GeV) weighted with E_{sub}");
414 fOutput->Add(fHistEsubPch[icent]);
416 name = Form(
"fHistEsubPchRat_%i",icent);
417 temp = Form(
"%s (Nmatches==1)",name.Data());
419 fHistEsubPchRat[icent]->SetXTitle(
"#Sigma p (GeV)");
420 fHistEsubPchRat[icent]->SetYTitle(
"E_{sub} / #sum p");
421 fOutput->Add(fHistEsubPchRat[icent]);
423 name = Form(
"fHistEsubPchRatAll_%i",icent);
424 temp = Form(
"%s (all Nmatches)",name.Data());
426 fHistEsubPchRatAll[icent]->SetXTitle(
"#Sigma p (GeV)");
427 fHistEsubPchRatAll[icent]->SetYTitle(
"E_{sub} / #sum p");
428 fOutput->Add(fHistEsubPchRatAll[icent]);
431 for(Int_t itrk=0; itrk<4; ++itrk) {
432 name = Form(
"fHistNCellsEnergy_%i_%i",icent,itrk);
433 temp = Form(
"%s (Nmatches==%d);N_{cells};E_{clus} (GeV)",name.Data(),itrk);
435 fOutput->Add(fHistNCellsEnergy[icent][itrk]);
438 name = Form(
"fHistMatchEvsP_%i",icent);
439 temp = Form(
"%s (all Nmatches)",name.Data());
441 fHistMatchEvsP[icent]->SetXTitle(
"E_{clus} (GeV)");
442 fHistMatchEvsP[icent]->SetYTitle(
"E_{clus} / #sum p");
443 fOutput->Add(fHistMatchEvsP[icent]);
445 name = Form(
"fHistMatchdRvsEP_%i",icent);
446 temp = Form(
"%s (all Nmatches)",name.Data());
448 fHistMatchdRvsEP[icent]->SetXTitle(
"#Delta R between track and cluster");
449 fHistMatchdRvsEP[icent]->SetYTitle(
"E_{clus} / p");
450 fOutput->Add(fHistMatchdRvsEP[icent]);
452 name = Form(
"fHistNMatchEnergy_%i",icent);
460 fHistNclusvsCent =
new TH1F(
"Nclusvscent",
"NclusVsCent; Cent (%)", 100, 0, 100);
461 fHistNclusMatchvsCent =
new TH1F(
"NclusMatchvscent",
"NclusMatchVsCent (all Nmatches); Cent (%)", 100, 0, 100);
462 fHistEbefore =
new TH1F(
"Ebefore",
"Ebefore; Cent (%); E_{clus} (GeV)", 100, 0, 100);
463 fHistEafter =
new TH1F(
"Eafter",
"Eafter; Cent (%); E_{clus} (GeV)", 100, 0, 100);
464 fHistEoPCent =
new TH2F(
"EoPCent",
"EoPCent; Cent (%); E_{clus} / #sum p", 100, 0, 100,
fNbins*2, 0, 10);
465 fHistNMatchCent =
new TH2F(
"NMatchesCent",
"NMatchesCent; Cent (%); Nmatches", 100, 0, 100, 11, -0.5, 10.5);
466 fHistNClusMatchCent =
new TH2F(
"NClusMatchesCent",
"NClusMatchesCent; Cent (%); Nmatches", 100, 0, 100, 11, -0.5, 10.5);
477 for(Int_t icent=0; icent<
fNcentBins; ++icent) {
478 name = Form(
"fHistEmbTrackMatchesOversub_%d",icent);
484 name = Form(
"fHistNonEmbTrackMatchesOversub_%d",icent);
490 name = Form(
"fHistOversubMCClusters_%d",icent);
496 name = Form(
"fHistOversubNonMCClusters_%d",icent);
502 name = Form(
"fHistOversub_%d",icent);
504 fHistOversub[icent]->GetXaxis()->SetTitle(
"E_{clus}^{raw} (GeV)");
505 fHistOversub[icent]->GetYaxis()->SetTitle(
"E_{oversub} / E_{clus}^{raw}");
519 AliError(Form(
"Wrong number of particle collections (%d), required 2",
fParticleCollArray.GetEntriesFast()));
523 for (Int_t i = 0; i < 2; i++) {
532 if (dynamic_cast<AliAODEvent*>(InputEvent()))
fEsdMode = kFALSE;
547 AliFatal(Form(
"%s: Container with same name %s already present. Aborting", GetName(),
fOutCaloName.Data()));
564 Int_t NmatchClus = 0;
566 if (!emctrack->
IsEMCAL())
continue;
568 AliVTrack *track = emctrack->
GetTrack();
569 if (!track)
continue;
571 if (track->GetTrackEtaOnEMCal() <
fGeom->GetArm1EtaMin() -
fEtaMatch ||
572 track->GetTrackEtaOnEMCal() >
fGeom->GetArm1EtaMax() +
fEtaMatch ||
573 track->GetTrackPhiOnEMCal() <
fGeom->GetArm1PhiMin() * TMath::DegToRad() -
fPhiMatch ||
574 track->GetTrackPhiOnEMCal() >
fGeom->GetArm1PhiMax() * TMath::DegToRad() +
fPhiMatch)
579 for (Int_t iClus = 0; iClus < Nclus; ++iClus) {
582 if (!emccluster)
continue;
584 AliVCluster *cluster = emccluster->
GetCluster();
585 if (!cluster)
continue;
586 if (!cluster->IsEMCAL())
continue;
588 Double_t etadiff = 999;
589 Double_t phidiff = 999;
601 Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches)
606 AliVCluster *cluster = emccluster->
GetCluster();
611 for (Int_t i = 0; i < Ntrks; ++i) {
615 if (!emctrack)
continue;
617 AliVTrack *track = emctrack->
GetTrack();
618 if (!track)
continue;
620 Double_t etadiff = 999;
621 Double_t phidiff = 999;
629 Double_t mom = track->P();
632 if (track->Charge()<0)
637 if(track->Eta() > 0) etabin=1;
642 Double_t etaCut = 0.0;
643 Double_t phiCutlo = 0.0;
644 Double_t phiCuthi = 0.0;
660 if ((phidiff < phiCuthi && phidiff > phiCutlo) && TMath::Abs(etadiff) < etaCut) {
671 Double_t energyclus = cluster->E();
679 trkPMCfrac /= totalTrkP;
702 if (!emccluster->
IsEMCAL())
continue;
704 AliVCluster *cluster = emccluster->
GetCluster();
705 if (!cluster)
continue;
707 Double_t energyclus = 0;
721 energyclus = cluster->E();
726 if (energyclus > 0) {
729 AliESDCaloCluster *ec =
dynamic_cast<AliESDCaloCluster*
>(cluster);
731 oc =
new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
733 AliAODCaloCluster *ac =
dynamic_cast<AliAODCaloCluster*
>(cluster);
735 oc =
new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
737 oc->SetE(energyclus);
753 AliVCluster *cluster = emccluster->
GetCluster();
754 if (!cluster)
return 0;
756 Double_t energyclus = cluster->E();
763 if (!emctrack)
return energyclus;
765 AliVTrack *track = emctrack->
GetTrack();
766 if (!track)
return energyclus;
768 Double_t mom = track->P();
769 if (mom < 1e-6)
return energyclus;
771 Double_t dEtaMin = 1e9;
772 Double_t dPhiMin = 1e9;
783 if (track->Charge()<0) centbinch +=
fNcentBins;
803 Double_t etaCut = 0.0;
804 Double_t phiCutlo = 0.0;
805 Double_t phiCuthi = 0.0;
822 if ((dPhiMin < phiCuthi && dPhiMin > phiCutlo) && TMath::Abs(dEtaMin) < etaCut) {
823 energyclus -= hadCorr * mom;
836 AliVCluster *cluster = emccluster->
GetCluster();
838 Double_t energyclus = cluster->E();
839 Double_t cNcells = cluster->GetNCells();
841 Double_t totalTrkP = 0.0;
844 Double_t trkPMCfrac = 0.0;
845 Int_t NMCmatches = 0;
850 Double_t Esub = hadCorr * totalTrkP;
852 if (Esub > energyclus) Esub = energyclus;
857 if (energyclus < clusEexcl) clusEexcl = energyclus;
858 if ((energyclus - Esub) < clusEexcl) Esub = (energyclus - clusEexcl);
862 Double_t EsubBkg = 0;
863 Double_t EclusMC = 0;
864 Double_t EclusBkg = 0;
865 Double_t EclusCorr = 0;
866 Double_t EclusMCcorr = 0;
867 Double_t EclusBkgcorr = 0;
868 Double_t overSub = 0;
870 EsubMC = hadCorr * totalTrkP * trkPMCfrac;
871 EsubBkg = hadCorr * totalTrkP - EsubMC;
872 EclusMC = energyclus * cluster->GetMCEnergyFraction();
873 EclusBkg = energyclus - EclusMC;
875 if (energyclus > Esub)
876 EclusCorr = energyclus - Esub;
878 if (EclusMC > EsubMC)
879 EclusMCcorr = EclusMC - EsubMC;
881 if (EclusBkg > EsubBkg)
882 EclusBkgcorr = EclusBkg - EsubBkg;
884 overSub = EclusMCcorr + EclusBkgcorr - EclusCorr;
901 Double_t EoP = energyclus / totalTrkP;
911 AliVTrack *track = emctrack->
GetTrack();
914 if (track->Charge()<0) centbinchm +=
fNcentBins;
924 if (cluster->GetMCEnergyFraction() > 0.95)
926 else if (cluster->GetMCEnergyFraction() < 0.05)
929 if (trkPMCfrac < 0.05)
931 else if (trkPMCfrac > 0.95)
939 if (EclusBkgcorr + EclusMCcorr > 0) {
940 Double_t newfrac = EclusMCcorr / (EclusBkgcorr + EclusMCcorr);
941 cluster->SetMCEnergyFraction(newfrac);
TH2 * fHistNonEmbTrackMatchesOversub[4]
Over-subtracted energy / cluster energy with embedded track matches (non-embedded matches < 5%) ...
Double_t ApplyHadCorrOneTrack(AliEmcalParticle *emccluster, Double_t hadCorr)
TH2 * fHistNClusMatchCent
n matches vs. centraity
TH2 * fHistOversubNonMCClusters[4]
Over-subtracted energy / cluster energy (cluster MC energy fraction > 95%)
TH2 * fHistEmbTrackMatchesOversub[4]
Esub/momentum of matched tracks vs. total momentum of matched tracks (all number of matches) ...
Int_t GetMatchedObjId(UShort_t i=0) const
Double_t GetEtaSigma(Int_t pbin) const
UShort_t GetNumberOfMatchedObj() const
void SetClassName(const char *clname)
TH2 * fHistEsubPchRatAll[8]
Esub/momentum of matched tracks vs. total momentum of matched tracks (only 1 match) ...
TH1 * fHistEafter
average energy of clusters before correction vs. centrality
Double_t GetPhiMean(Int_t pbin, Int_t centbin) const
Int_t fCentBin
event centrality
TH2 * fHistNCellsEnergy[4][4]
n matches vs. cluster energy
TH2 * fHistOversub[4]
Over-subtracted energy / cluster energy (cluster MC energy fraction < 5%)
AliVTrack * GetTrack() const
UInt_t GetMomBin(Double_t pt) const
TList * fOutput
x-section from pythia header
TClonesArray * fOutClusters
ESD/AOD mode.
TObjArray fParticleCollArray
TH2 * fHistMatchEtaPhiAll
deta vs. dphi of matched cluster-track pairs
TH2 * fHistNMatchCent
E/P vs. centrality.
Double_t ApplyHadCorrAllTracks(AliEmcalParticle *emccluster, Double_t hadCorr)
AliVParticle * GetParticle(Int_t i) const
AliEMCALGeometry * fGeom
whether it's an ESD analysis
AliVParticle * GetAcceptParticle(Int_t i)
Double_t GetPhiSigma(Int_t pbin, Int_t centbin) const
Int_t IdInCollection() const
TH1 * fHistNclusMatchvsCent
n clusters vs. centrality
Double_t fCent
trigger patch info array
AliVParticle * GetNextAcceptParticle(Int_t i=-1)
TH2 * fHistMatchdRvsEP[4]
n cells vs. cluster energy
Double_t GetMatchedObjDistance(UShort_t i=0) const
TH2 * fHistMatchEtaPhiAllCl
deta vs. dphi of all cluster-track pairs (tr loop)
TH2 * fHistOversubMCClusters[4]
Over-subtracted energy / cluster energy with non-embedded track matches (embedded matches < 5%) ...
TH2 * fHistEoPCent
average energy of clusters after correction vs. centrality
TH1 * fHistEsubPch[8]
n clusters macthed to some track (tracks allowed to match more than one cluster)
TH2 * fHistMatchEtaPhi[8][9][2]
output cluster collection
ClassImp(AliHadCorrTask) AliHadCorrTask
AliVCluster * GetCluster() const
TH2 * fHistNMatchEnergy[4]
cluster energy vs. track momentum of matched pairs
TH2 * fHistMatchEtaPhiAllTr
deta vs. dphi of matched cluster-track pairs
void UserCreateOutputObjects()
virtual ~AliHadCorrTask()
void SetMakeGeneralHistograms(Bool_t g)
TH2 * fHistMatchEvsP[4]
deta vs. dphi of all cluster-track pairs (cl loop)
void UserCreateOutputObjects()
static void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
TH2 * fHistEsubPchRat[8]
Esub vs. total momentum of matched tracks (only 1 match)
TH1 * fHistEbefore
n clusters matched to some track vs. centrality
void DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches)
TH1 * fHistNclusvsCent
matching distance vs. E/P
void ResetCurrentID(Int_t i=0)