7 #include <TClonesArray.h>
12 #include "AliAnalysisManager.h"
13 #include "AliAODEvent.h"
14 #include "AliAODCaloCluster.h"
15 #include "AliESDCaloCluster.h"
16 #include "AliVTrack.h"
17 #include "AliVEventHandler.h"
18 #include "AliEMCALGeometry.h"
38 fHistMatchEtaPhiAll(0),
39 fHistMatchEtaPhiAllTr(0),
40 fHistMatchEtaPhiAllCl(0),
42 fHistNclusMatchvsCent(0),
47 fHistNClusMatchCent(0)
51 for(
Int_t i=0; i<10; i++) {
53 fHistEsubPchRat[i] = 0;
56 fHistEsubPchRatAll[i] = 0;
58 fHistMatchEvsP[i] = 0;
59 fHistMatchdRvsEP[i] = 0;
60 fHistNMatchEnergy[i] = 0;
62 fHistEmbTrackMatchesOversub[i] = 0;
63 fHistNonEmbTrackMatchesOversub[i] = 0;
64 fHistOversubMCClusters[i] = 0;
65 fHistOversubNonMCClusters[i] = 0;
68 for(
Int_t j=0; j<4; j++)
69 fHistNCellsEnergy[i][j] = 0;
72 for(
Int_t j=0; j<9; j++) {
73 for(
Int_t k=0; k<2; k++)
74 fHistMatchEtaPhi[i][j][k] = 0;
82 fOutCaloName(
"CaloClustersCorr"),
91 fHistMatchEtaPhiAll(0),
92 fHistMatchEtaPhiAllTr(0),
93 fHistMatchEtaPhiAllCl(0),
95 fHistNclusMatchvsCent(0),
100 fHistNClusMatchCent(0)
104 for(
Int_t i=0; i<10; i++) {
121 for(
Int_t j=0; j<4; j++)
125 for(
Int_t j=0; j<9; j++) {
126 for(
Int_t k=0; k<2; k++)
133 fBranchNames=
"ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
150 else if (p>=0.5 && p<1.0)
152 else if (p>=1.0 && p<1.5)
154 else if (p>=1.5 && p<2.)
156 else if (p>=2. && p<3.)
158 else if (p>=3. && p<4.)
160 else if (p>=4. && p<5.)
162 else if (p>=5. && p<8.)
175 Double_t EtaSigma[9]={0.0097,0.0075,0.0059,0.0055,0.0053,0.005,0.005,0.0045,0.0042};
176 return 2.0*EtaSigma[pbin];
194 return PhiMean[pbin];
195 }
else if (centbin==1) {
205 return PhiMean[pbin];
206 }
else if (centbin==2) {
216 return PhiMean[pbin];
217 }
else if (centbin==3) {
227 return PhiMean[pbin];
228 }
else if (centbin==4) {
238 return PhiMean[pbin]*(-1.);
239 }
else if (centbin==5) {
249 return PhiMean[pbin]*(-1.);
250 }
else if (centbin==6) {
260 return PhiMean[pbin]*(-1.);
261 }
else if (centbin==7) {
271 return PhiMean[pbin]*(-1.);
292 return 2.*PhiSigma[pbin];
293 }
else if (centbin==1) {
303 return 2.*PhiSigma[pbin];
304 }
else if (centbin==2) {
314 return 2.*PhiSigma[pbin];
315 }
else if (centbin==3) {
325 return 2.*PhiSigma[pbin];
326 }
else if (centbin==4) {
336 return 2.*PhiSigma[pbin];
337 }
else if (centbin==5) {
347 return 2.*PhiSigma[pbin];
348 }
else if (centbin==6) {
358 return 2.*PhiSigma[pbin];
359 }
else if (centbin==7) {
369 return 2.*PhiSigma[pbin];
398 for(
Int_t icent=0; icent<nCentChBins; ++icent) {
399 for(
Int_t ipt=0; ipt<9; ++ipt) {
400 for(
Int_t ieta=0; ieta<2; ++ieta) {
401 name = Form(
"fHistMatchEtaPhi_%i_%i_%i",icent,ipt,ieta);
409 name = Form(
"fHistEsubPch_%i",icent);
410 temp = Form(
"%s (Nmatches==1)",name.Data());
412 fHistEsubPch[icent]->SetXTitle(
"#sum p (GeV) weighted with E_{sub}");
413 fOutput->Add(fHistEsubPch[icent]);
415 name = Form(
"fHistEsubPchRat_%i",icent);
416 temp = Form(
"%s (Nmatches==1)",name.Data());
418 fHistEsubPchRat[icent]->SetXTitle(
"#Sigma p (GeV)");
419 fHistEsubPchRat[icent]->SetYTitle(
"E_{sub} / #sum p");
420 fOutput->Add(fHistEsubPchRat[icent]);
423 for(
Int_t itrk=0; itrk<4; ++itrk) {
424 name = Form(
"fHistNCellsEnergy_%i_%i",icent,itrk);
425 temp = Form(
"%s (Nmatches==%d);N_{cells};E_{clus} (GeV)",name.Data(),itrk);
427 fOutput->Add(fHistNCellsEnergy[icent][itrk]);
430 name = Form(
"fHistEsubPchRatAll_%i",icent);
431 temp = Form(
"%s (all Nmatches)",name.Data());
433 fHistEsubPchRatAll[icent]->SetXTitle(
"#Sigma p (GeV)");
434 fHistEsubPchRatAll[icent]->SetYTitle(
"E_{sub} / #sum p");
435 fOutput->Add(fHistEsubPchRatAll[icent]);
437 name = Form(
"fHistMatchEvsP_%i",icent);
438 temp = Form(
"%s (all Nmatches)",name.Data());
440 fHistMatchEvsP[icent]->SetXTitle(
"E_{clus} (GeV)");
441 fHistMatchEvsP[icent]->SetYTitle(
"E_{clus} / #sum p");
442 fOutput->Add(fHistMatchEvsP[icent]);
444 name = Form(
"fHistMatchdRvsEP_%i",icent);
445 temp = Form(
"%s (all Nmatches)",name.Data());
447 fHistMatchdRvsEP[icent]->SetXTitle(
"#Delta R between track and cluster");
448 fHistMatchdRvsEP[icent]->SetYTitle(
"E_{clus} / p");
449 fOutput->Add(fHistMatchdRvsEP[icent]);
451 name = Form(
"fHistNMatchEnergy_%i",icent);
459 fHistNclusvsCent =
new TH1F(
"Nclusvscent",
"NclusVsCent; Cent (%)", 100, 0, 100);
460 fHistNclusMatchvsCent =
new TH1F(
"NclusMatchvscent",
"NclusMatchVsCent (all Nmatches); Cent (%)", 100, 0, 100);
461 fHistEbefore =
new TH1F(
"Ebefore",
"Ebefore; Cent (%); E_{clus} (GeV)", 100, 0, 100);
462 fHistEafter =
new TH1F(
"Eafter",
"Eafter; Cent (%); E_{clus} (GeV)", 100, 0, 100);
464 fHistNMatchCent =
new TH2F(
"NMatchesCent",
"NMatchesCent; Cent (%); Nmatches", 100, 0, 100, 11, -0.5, 10.5);
465 fHistNClusMatchCent =
new TH2F(
"NClusMatchesCent",
"NClusMatchesCent; Cent (%); Nmatches", 100, 0, 100, 11, -0.5, 10.5);
477 name = Form(
"fHistEmbTrackMatchesOversub_%d",icent);
483 name = Form(
"fHistNonEmbTrackMatchesOversub_%d",icent);
489 name = Form(
"fHistOversubMCClusters_%d",icent);
495 name = Form(
"fHistOversubNonMCClusters_%d",icent);
501 name = Form(
"fHistOversub_%d",icent);
503 fHistOversub[icent]->GetXaxis()->SetTitle(
"E_{clus}^{raw} (GeV)");
504 fHistOversub[icent]->GetYaxis()->SetTitle(
"E_{oversub} / E_{clus}^{raw}");
519 AliError(Form(
"%s: This task needs a particle container!", GetName()));
523 TClass trackClass(tracks->GetClassName());
524 if (!trackClass.InheritsFrom(
"AliVTrack")) {
525 tracks->SetClassName(
"AliVTrack");
530 AliError(Form(
"%s: This task needs a cluster container!", GetName()));
534 TClass clusterClass(clusters->GetClassName());
535 if (!clusterClass.InheritsFrom(
"AliVCluster")) {
536 clusters->SetClassName(
"AliVCluster");
543 if (dynamic_cast<AliAODEvent*>(InputEvent()))
fEsdMode = kFALSE;
567 AliVCluster* cluster = clusters->
GetCluster(icluster);
569 if (!cluster)
return;
572 Int_t Ntrks = Ntrks = cluster->GetNTracksMatched();
573 for (
Int_t i = 0; i < Ntrks; ++i) {
574 AliVTrack* track = 0;
577 Int_t itrack = cluster->GetTrackMatchedIndex(i);
578 if (itrack >= 0) track =
static_cast<AliVTrack*
>(tracks->
GetAcceptParticle(itrack));
581 track =
static_cast<AliVTrack*
>(cluster->GetTrackMatched(i));
582 UInt_t rejectionReason = 0;
586 if (!track)
continue;
594 if (
fDoTrackClus && (track->GetEMCALcluster() != icluster))
continue;
600 if (track->Charge() < 0) centbinch +=
fNcentBins;
604 if (track->Eta() > 0) etabin=1;
629 if ((phidiff < phiCuthi && phidiff > phiCutlo) && TMath::Abs(etadiff) < etaCut) {
642 Double_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
643 Double_t energyclus = cluster->GetNonLinCorrEnergy();
650 if (totalTrkP > 0) trkPMCfrac /= totalTrkP;
666 clusters->ResetCurrentID();
667 AliVCluster *cluster = 0;
686 energyclus = cluster->GetNonLinCorrEnergy();
689 if (energyclus < 0) energyclus = 0;
691 cluster->SetHadCorrEnergy(energyclus);
698 AliESDCaloCluster *ec =
dynamic_cast<AliESDCaloCluster*
>(cluster);
700 oc =
new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
703 AliAODCaloCluster *ac =
dynamic_cast<AliAODCaloCluster*
>(cluster);
705 oc =
new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
708 oc->SetE(energyclus);
709 oc->SetNonLinCorrEnergy(cluster->GetNonLinCorrEnergy());
710 oc->SetHadCorrEnergy(energyclus);
725 AliVCluster* cluster = clusters->
GetCluster(icluster);
727 Double_t energyclus = cluster->GetNonLinCorrEnergy();
729 AliVTrack* track = 0;
731 if (cluster->GetNTracksMatched() > 0) {
733 Int_t itrack = cluster->GetTrackMatchedIndex(0);
734 if (itrack >= 0) track =
static_cast<AliVTrack*
>(tracks->
GetAcceptParticle(itrack));
737 track =
static_cast<AliVTrack*
>(cluster->GetTrackMatched(0));
738 UInt_t rejectionReason = 0;
743 if (!track || track->P() < 1e-6)
return energyclus;
754 Int_t cid = track->GetEMCALcluster();
755 if (
fDoTrackClus && (cid != icluster))
return energyclus;
759 if (track->Charge() < 0) centbinch +=
fNcentBins;
764 if(track->Eta() > 0) etabin = 1;
773 Double_t dRmin = TMath::Sqrt(etadiff*etadiff + phidiff*phidiff);
800 if ((dPhiMin < phiCuthi && dPhiMin > phiCutlo) && TMath::Abs(dEtaMin) < etaCut) {
801 energyclus -= hadCorr * mom;
815 AliVCluster* cluster = clusters->
GetCluster(icluster);
817 Double_t energyclus = cluster->GetNonLinCorrEnergy();
818 Double_t cNcells = cluster->GetNCells();
824 Int_t NMCmatches = 0;
829 Double_t Esub = hadCorr * totalTrkP;
831 if (Esub > energyclus) Esub = energyclus;
836 if (energyclus < clusEexcl) clusEexcl = energyclus;
837 if ((energyclus - Esub) < clusEexcl) Esub = (energyclus - clusEexcl);
849 EsubMC = hadCorr * totalTrkP * trkPMCfrac;
850 EsubBkg = hadCorr * totalTrkP - EsubMC;
851 EclusMC = energyclus * cluster->GetMCEnergyFraction();
852 EclusBkg = energyclus - EclusMC;
854 if (energyclus > Esub)
855 EclusCorr = energyclus - Esub;
857 if (EclusMC > EsubMC)
858 EclusMCcorr = EclusMC - EsubMC;
860 if (EclusBkg > EsubBkg)
861 EclusBkgcorr = EclusBkg - EsubBkg;
863 overSub = EclusMCcorr + EclusBkgcorr - EclusCorr;
881 Double_t EoP = energyclus / totalTrkP;
888 AliVTrack* track = 0;
890 Int_t itrack = cluster->GetTrackMatchedIndex(0);
891 if (itrack >= 0) track =
static_cast<AliVTrack*
>(tracks->
GetAcceptParticle(itrack));
894 track =
static_cast<AliVTrack*
>(cluster->GetTrackMatched(0));
895 UInt_t rejectionReason = 0;
900 if (track->Charge() < 0) centbinchm +=
fNcentBins;
909 if (cluster->GetMCEnergyFraction() > 0.95)
911 else if (cluster->GetMCEnergyFraction() < 0.05)
914 if (trkPMCfrac < 0.05)
916 else if (trkPMCfrac > 0.95)
924 if (EclusBkgcorr + EclusMCcorr > 0) {
925 Double_t newfrac = EclusMCcorr / (EclusBkgcorr + EclusMCcorr);
926 cluster->SetMCEnergyFraction(newfrac);
TH2 * fHistOversubMCClusters[5]
Over-subtracted energy / cluster energy with non-embedded track matches (embedded matches < 5%) ...
TH2 * fHistMatchdRvsEP[5]
n cells vs. cluster energy
TH2 * fHistNClusMatchCent
n matches vs. centraity
Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
Double_t GetEtaSigma(Int_t pbin) const
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
TH1 * fHistEafter
average energy of clusters before correction vs. centrality
TH2 * fHistEsubPchRat[10]
Esub vs. total momentum of matched tracks (only 1 match)
static void GetEtaPhiDiff(const AliVTrack *t, const AliVCluster *v, Double_t &phidiff, Double_t &etadiff)
Calculate and difference between a track (t) and a cluster (c).
Double_t fMinBinPt
min pt in histograms
Double_t GetPhiMean(Int_t pbin, Int_t centbin) const
Int_t fCentBin
!event centrality bin
Double_t ApplyHadCorrAllTracks(Int_t icluster, Double_t hadCorr)
void ExecOnce()
Perform steps needed to initialize the analysis.
UInt_t GetMomBin(Double_t pt) const
TH2 * fHistNMatchEnergy[5]
cluster energy vs. track momentum of matched pairs
TClonesArray * fOutClusters
ESD/AOD mode.
Container for particles within the EMCAL framework.
Bool_t fIsEmbedded
trigger, embedded signal
TH2 * fHistEsubPchRatAll[5]
Esub/momentum of matched tracks vs. total momentum of matched tracks (only 1 match) ...
TH2 * fHistMatchEtaPhiAll
deta vs. dphi of matched cluster-track pairs
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
TH2 * fHistMatchEtaPhi[10][9][2]
output cluster collection
TH2 * fHistEmbTrackMatchesOversub[5]
Esub/momentum of matched tracks vs. total momentum of matched tracks (all number of matches) ...
TH2 * fHistNMatchCent
E/P vs. centrality.
TH2 * fHistOversubNonMCClusters[5]
Over-subtracted energy / cluster energy (cluster MC energy fraction > 95%)
Double_t ApplyHadCorrOneTrack(Int_t icluster, Double_t hadCorr)
Double_t GetPhiSigma(Int_t pbin, Int_t centbin) const
void DoMatchedTracksLoop(Int_t icluster, Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches)
Int_t fNcentBins
how many centrality bins
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
virtual AliVParticle * GetAcceptParticle(Int_t i=-1) const
TH1 * fHistNclusMatchvsCent
n clusters vs. centrality
Double_t fCent
!event centrality
virtual Bool_t AcceptParticle(const AliVParticle *vp, UInt_t &rejectionReason) const
AliVCluster * GetCluster(Int_t i) const
TH2 * fHistMatchEtaPhiAllCl
deta vs. dphi of all cluster-track pairs (tr loop)
TH2 * fHistOversub[5]
Over-subtracted energy / cluster energy (cluster MC energy fraction < 5%)
Int_t fMinMCLabel
minimum MC label value for the tracks/clusters being considered MC particles
TH2 * fHistEoPCent
average energy of clusters after correction vs. centrality
ClassImp(AliHadCorrTask) AliHadCorrTask
TH2 * fHistNonEmbTrackMatchesOversub[5]
Over-subtracted energy / cluster energy with embedded track matches (non-embedded matches < 5%) ...
AliEmcalList * fOutput
!output list
Double_t fMaxBinPt
max pt in histograms
TH1 * fHistEsubPch[10]
n clusters macthed to some track (tracks allowed to match more than one cluster)
TH2 * fHistMatchEtaPhiAllTr
deta vs. dphi of matched cluster-track pairs
void UserCreateOutputObjects()
virtual ~AliHadCorrTask()
Bool_t fCreateHisto
whether or not create histograms
void SetMakeGeneralHistograms(Bool_t g)
TH2 * fHistNCellsEnergy[5][4]
n matches vs. cluster energy
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void AddObjectToEvent(TObject *obj, Bool_t attempt=kFALSE)
Add object to event.
void UserCreateOutputObjects()
Main initialization function on the worker.
TH2 * fHistMatchEvsP[5]
deta vs. dphi of all cluster-track pairs (cl loop)
TH1 * fHistEbefore
n clusters matched to some track vs. centrality
TH1 * fHistNclusvsCent
matching distance vs. E/P
Container structure for EMCAL clusters.
AliVCluster * GetNextAcceptCluster()
Int_t fNbins
no. of pt bins