3 // Hadronic correction task.
5 // Author: R.Reed, C.Loizides, S.Aiola
8 #include <TClonesArray.h>
13 #include "AliAnalysisManager.h"
14 #include "AliAODEvent.h"
15 #include "AliAODCaloCluster.h"
16 #include "AliESDCaloCluster.h"
17 #include "AliVTrack.h"
18 #include "AliPicoTrack.h"
19 #include "AliVEventHandler.h"
20 #include "AliEmcalParticle.h"
21 #include "AliEMCALGeometry.h"
22 #include "AliParticleContainer.h"
23 #include "AliClusterContainer.h"
25 #include "AliHadCorrTask.h"
27 ClassImp(AliHadCorrTask)
29 //________________________________________________________________________
30 AliHadCorrTask::AliHadCorrTask() :
31 AliAnalysisTaskEmcal("AliHadCorrTask", kFALSE),
42 fHistNclusMatchvsCent(0),
47 fHistNClusMatchCent(0)
49 // Default constructor.
51 for(Int_t i=0; i<8; i++) {
53 fHistEsubPchRat[i] = 0;
54 fHistEsubPchRatAll[i] = 0;
57 fHistMatchEvsP[i] = 0;
58 fHistMatchdRvsEP[i] = 0;
59 fHistNMatchEnergy[i] = 0;
61 fHistEmbTrackMatchesOversub[i] = 0;
62 fHistNonEmbTrackMatchesOversub[i] = 0;
63 fHistOversubMCClusters[i] = 0;
64 fHistOversubNonMCClusters[i] = 0;
67 for(Int_t j=0; j<4; j++)
68 fHistNCellsEnergy[i][j] = 0;
71 for(Int_t j=0; j<9; j++) {
72 for(Int_t k=0; k<2; k++)
73 fHistMatchEtaPhi[i][j][k] = 0;
78 //________________________________________________________________________
79 AliHadCorrTask::AliHadCorrTask(const char *name, Bool_t histo) :
80 AliAnalysisTaskEmcal(name, histo),
81 fOutCaloName("CaloClustersCorr"),
91 fHistNclusMatchvsCent(0),
96 fHistNClusMatchCent(0)
98 // Standard constructor.
100 for(Int_t i=0; i<8; i++) {
102 fHistEsubPchRat[i] = 0;
103 fHistEsubPchRatAll[i] = 0;
106 fHistMatchEvsP[i] = 0;
107 fHistMatchdRvsEP[i] = 0;
108 fHistNMatchEnergy[i] = 0;
110 fHistEmbTrackMatchesOversub[i] = 0;
111 fHistNonEmbTrackMatchesOversub[i] = 0;
112 fHistOversubMCClusters[i] = 0;
113 fHistOversubNonMCClusters[i] = 0;
116 for(Int_t j=0; j<4; j++)
117 fHistNCellsEnergy[i][j] = 0;
120 for(Int_t j=0; j<9; j++) {
121 for(Int_t k=0; k<2; k++)
122 fHistMatchEtaPhi[i][j][k] = 0;
126 SetMakeGeneralHistograms(histo);
128 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
131 //________________________________________________________________________
132 AliHadCorrTask::~AliHadCorrTask()
137 //________________________________________________________________________
138 UInt_t AliHadCorrTask::GetMomBin(Double_t p) const
145 else if (p>=0.5 && p<1.0)
147 else if (p>=1.0 && p<1.5)
149 else if (p>=1.5 && p<2.)
151 else if (p>=2. && p<3.)
153 else if (p>=3. && p<4.)
155 else if (p>=4. && p<5.)
157 else if (p>=5. && p<8.)
165 //________________________________________________________________________
166 Double_t AliHadCorrTask::GetEtaSigma(Int_t pbin) const
170 Double_t EtaSigma[9]={0.0097,0.0075,0.0059,0.0055,0.0053,0.005,0.005,0.0045,0.0042};
171 return 2.0*EtaSigma[pbin];
174 //________________________________________________________________________
175 Double_t AliHadCorrTask::GetPhiMean(Int_t pbin, Int_t centbin) const
180 Double_t PhiMean[9]={0.036,
189 return PhiMean[pbin];
190 } else if (centbin==1) {
191 Double_t PhiMean[9]={0.036,
200 return PhiMean[pbin];
201 } else if (centbin==2) {
202 Double_t PhiMean[9]={0.036,
211 return PhiMean[pbin];
212 } else if (centbin==3) {
213 Double_t PhiMean[9]={0.036,
222 return PhiMean[pbin];
223 } else if (centbin==4) {
224 Double_t PhiMean[9]={0.036,
233 return PhiMean[pbin]*(-1.);
234 } else if (centbin==5) {
235 Double_t PhiMean[9]={0.036,
244 return PhiMean[pbin]*(-1.);
245 } else if (centbin==6) {
246 Double_t PhiMean[9]={0.036,
255 return PhiMean[pbin]*(-1.);
256 } else if (centbin==7) {
257 Double_t PhiMean[9]={0.036,
266 return PhiMean[pbin]*(-1.);
272 //________________________________________________________________________
273 Double_t AliHadCorrTask::GetPhiSigma(Int_t pbin, Int_t centbin) const
278 Double_t PhiSigma[9]={0.0221,
287 return 2.*PhiSigma[pbin];
288 } else if (centbin==1) {
289 Double_t PhiSigma[9]={0.0217,
298 return 2.*PhiSigma[pbin];
299 } else if (centbin==2) {
300 Double_t PhiSigma[9]={0.0211,
309 return 2.*PhiSigma[pbin];
310 } else if (centbin==3) {
311 Double_t PhiSigma[9]={0.0215,
320 return 2.*PhiSigma[pbin];
321 } else if (centbin==4) {
322 Double_t PhiSigma[9]={0.0199,
331 return 2.*PhiSigma[pbin];
332 } else if (centbin==5) {
333 Double_t PhiSigma[9]={0.0200,
342 return 2.*PhiSigma[pbin];
343 } else if (centbin==6) {
344 Double_t PhiSigma[9]={0.0202,
353 return 2.*PhiSigma[pbin];
354 } else if (centbin==7) {
355 Double_t PhiSigma[9]={0.0205,
364 return 2.*PhiSigma[pbin];
370 //________________________________________________________________________
371 void AliHadCorrTask::UserCreateOutputObjects()
373 // Create my user objects.
375 if (!fCreateHisto) return;
377 AliAnalysisTaskEmcal::UserCreateOutputObjects();
381 const Int_t nCentChBins = fNcentBins * 2;
383 for(Int_t icent=0; icent<nCentChBins; ++icent) {
384 for(Int_t ipt=0; ipt<9; ++ipt) {
385 for(Int_t ieta=0; ieta<2; ++ieta) {
386 name = Form("fHistMatchEtaPhi_%i_%i_%i",icent,ipt,ieta);
387 fHistMatchEtaPhi[icent][ipt][ieta] = new TH2F(name, name, fNbins, -0.1, 0.1, fNbins, -0.1, 0.1);
388 fOutput->Add(fHistMatchEtaPhi[icent][ipt][ieta]);
392 name = Form("fHistEsubPch_%i",icent);
393 fHistEsubPch[icent]=new TH1F(name, name, fNbins, fMinBinPt, fMaxBinPt);
394 fOutput->Add(fHistEsubPch[icent]);
396 name = Form("fHistEsubPchRat_%i",icent);
397 fHistEsubPchRat[icent]=new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins*2, 0., 10.);
398 fOutput->Add(fHistEsubPchRat[icent]);
400 name = Form("fHistEsubPchRatAll_%i",icent);
401 fHistEsubPchRatAll[icent]=new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins*2, 0., 10.);
402 fOutput->Add(fHistEsubPchRatAll[icent]);
404 if (icent<fNcentBins) {
405 for(Int_t itrk=0; itrk<4; ++itrk) {
406 name = Form("fHistNCellsEnergy_%i_%i",icent,itrk);
407 fHistNCellsEnergy[icent][itrk] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, 101, -0.5, 100.5);
408 fOutput->Add(fHistNCellsEnergy[icent][itrk]);
411 name = Form("fHistMatchEvsP_%i",icent);
412 fHistMatchEvsP[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins*2, 0., 10.);
413 fOutput->Add(fHistMatchEvsP[icent]);
415 name = Form("fHistMatchdRvsEP_%i",icent);
416 fHistMatchdRvsEP[icent] = new TH2F(name, name, fNbins, 0., 0.2, fNbins*2, 0., 10.);
417 fOutput->Add(fHistMatchdRvsEP[icent]);
419 name = Form("fHistNMatchEnergy_%i",icent);
420 fHistNMatchEnergy[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, 101, -0.5, 100.5);
421 fOutput->Add(fHistNMatchEnergy[icent]);
425 fHistNclusvsCent = new TH1F("Nclusvscent", "NclusVsCent", 100, 0, 100);
426 fHistNclusMatchvsCent = new TH1F("NclusMatchvscent", "NclusMatchVsCent", 100, 0, 100);
427 fHistEbefore = new TH1F("Ebefore", "Ebefore", 100, 0, 100);
428 fHistEafter = new TH1F("Eafter", "Eafter", 100, 0, 100);
429 fHistEoPCent = new TH2F("EoPCent", "EoPCent", 100, 0, 100, fNbins*2, 0, 10);
430 fHistNMatchCent = new TH2F("NMatchesCent", "NMatchesCent", 100, 0, 100, 11, -0.5, 10.5);
431 fHistNClusMatchCent = new TH2F("NClusMatchesCent", "NClusMatchesCent", 100, 0, 100, 11, -0.5, 10.5);
433 fOutput->Add(fHistNclusMatchvsCent);
434 fOutput->Add(fHistNclusvsCent);
435 fOutput->Add(fHistEbefore);
436 fOutput->Add(fHistEafter);
437 fOutput->Add(fHistEoPCent);
438 fOutput->Add(fHistNMatchCent);
439 fOutput->Add(fHistNClusMatchCent);
442 for(Int_t icent=0; icent<fNcentBins; ++icent) {
443 name = Form("fHistEmbTrackMatchesOversub_%d",icent);
444 fHistEmbTrackMatchesOversub[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins, 0, 1.2);
445 fHistEmbTrackMatchesOversub[icent]->GetXaxis()->SetTitle("E_{clus}^{raw} (GeV)");
446 fHistEmbTrackMatchesOversub[icent]->GetYaxis()->SetTitle("E_{oversub} / E_{clus}^{raw}");
447 fOutput->Add(fHistEmbTrackMatchesOversub[icent]);
449 name = Form("fHistNonEmbTrackMatchesOversub_%d",icent);
450 fHistNonEmbTrackMatchesOversub[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins, 0, 1.2);
451 fHistNonEmbTrackMatchesOversub[icent]->GetXaxis()->SetTitle("E_{clus}^{raw} (GeV)");
452 fHistNonEmbTrackMatchesOversub[icent]->GetYaxis()->SetTitle("E_{oversub} / E_{clus}^{raw}");
453 fOutput->Add(fHistNonEmbTrackMatchesOversub[icent]);
455 name = Form("fHistOversubMCClusters_%d",icent);
456 fHistOversubMCClusters[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins, 0, 1.2);
457 fHistOversubMCClusters[icent]->GetXaxis()->SetTitle("E_{clus}^{raw} (GeV)");
458 fHistOversubMCClusters[icent]->GetYaxis()->SetTitle("E_{oversub} / E_{clus}^{raw}");
459 fOutput->Add(fHistOversubMCClusters[icent]);
461 name = Form("fHistOversubNonMCClusters_%d",icent);
462 fHistOversubNonMCClusters[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins, 0, 1.2);
463 fHistOversubNonMCClusters[icent]->GetXaxis()->SetTitle("E_{clus}^{raw} (GeV)");
464 fHistOversubNonMCClusters[icent]->GetYaxis()->SetTitle("E_{oversub} / E_{clus}^{raw}");
465 fOutput->Add(fHistOversubNonMCClusters[icent]);
467 name = Form("fHistOversub_%d",icent);
468 fHistOversub[icent] = new TH2F(name, name, fNbins, fMinBinPt, fMaxBinPt, fNbins, 0, 1.2);
469 fHistOversub[icent]->GetXaxis()->SetTitle("E_{clus}^{raw} (GeV)");
470 fHistOversub[icent]->GetYaxis()->SetTitle("E_{oversub} / E_{clus}^{raw}");
471 fOutput->Add(fHistOversub[icent]);
475 PostData(1, fOutput);
478 //________________________________________________________________________
479 void AliHadCorrTask::ExecOnce()
481 // Initialize the analysis.
483 if (fParticleCollArray.GetEntriesFast()<2) {
484 AliError(Form("Wrong number of particle collections (%d), required 2",fParticleCollArray.GetEntriesFast()));
488 for (Int_t i = 0; i < 2; i++) {
489 AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i));
490 cont->SetClassName("AliEmcalParticle");
493 // Do base class initializations and if it fails -> bail out
494 AliAnalysisTaskEmcal::ExecOnce();
495 if (!fInitialized) return;
497 if (dynamic_cast<AliAODEvent*>(InputEvent())) fEsdMode = kFALSE;
500 fOutClusters = new TClonesArray("AliESDCaloCluster");
502 fOutClusters = new TClonesArray("AliAODCaloCluster");
504 fOutClusters->SetName(fOutCaloName);
506 // post output in event if not yet present
507 if (!(InputEvent()->FindListObject(fOutCaloName))) {
508 InputEvent()->AddObject(fOutClusters);
511 fInitialized = kFALSE;
512 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data()));
517 //________________________________________________________________________
518 void AliHadCorrTask::DoTrackLoop()
520 AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
521 AliParticleContainer *clusters = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
523 AliEmcalParticle *emctrack = 0;
525 tracks->ResetCurrentID();
526 while ((emctrack = static_cast<AliEmcalParticle*>(tracks->GetNextAcceptParticle()))) {
527 Int_t NmatchClus = 0;
529 if (!emctrack->IsEMCAL()) continue;
531 AliVTrack *track = emctrack->GetTrack();
532 if (!track) continue;
534 if (track->GetTrackEtaOnEMCal() < fGeom->GetArm1EtaMin() - fEtaMatch ||
535 track->GetTrackEtaOnEMCal() > fGeom->GetArm1EtaMax() + fEtaMatch ||
536 track->GetTrackPhiOnEMCal() < fGeom->GetArm1PhiMin() * TMath::DegToRad() - fPhiMatch ||
537 track->GetTrackPhiOnEMCal() > fGeom->GetArm1PhiMax() * TMath::DegToRad() + fPhiMatch)
540 Int_t Nclus = emctrack->GetNumberOfMatchedObj();
542 for (Int_t iClus = 0; iClus < Nclus; ++iClus) {
543 AliEmcalParticle *emccluster = static_cast<AliEmcalParticle*>(clusters->GetAcceptParticle(emctrack->GetMatchedObjId(iClus)));
544 if (!emccluster) continue;
546 AliVCluster *cluster = emccluster->GetCluster();
547 if (!cluster->IsEMCAL()) continue;
548 if (!cluster) continue;
550 Double_t etadiff = 999;
551 Double_t phidiff = 999;
552 AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff);
554 if (TMath::Abs(phidiff) < fPhiMatch && TMath::Abs(etadiff) < fEtaMatch) NmatchClus++;
556 fHistNClusMatchCent->Fill(fCent, NmatchClus);
560 //________________________________________________________________________
561 void AliHadCorrTask::DoMatchedTracksLoop(AliEmcalParticle *emccluster, Double_t &totalTrkP, Int_t &Nmatches, Double_t &trkPMCfrac, Int_t &NMCmatches)
563 // Do the loop over matched tracks for cluster emccluster.
565 AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
567 AliVCluster *cluster = emccluster->GetCluster();
568 Int_t iClus = emccluster->IdInCollection();
569 Double_t energyclus = cluster->E();
571 // loop over matched tracks
572 const Int_t Ntrks = emccluster->GetNumberOfMatchedObj();
573 for (Int_t i = 0; i < Ntrks; ++i) {
574 Int_t iTrack = emccluster->GetMatchedObjId(i);
575 Double_t dR = emccluster->GetMatchedObjDistance(i);
577 AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(tracks->GetAcceptParticle(iTrack));
578 if (!emctrack) continue;
580 // check if track also points to cluster
581 if (fDoTrackClus && (emctrack->GetMatchedObjId(0)) != iClus) continue;
583 AliVTrack *track = emctrack->GetTrack();
584 if (!track) continue;
586 Double_t etadiff = 999;
587 Double_t phidiff = 999;
588 AliPicoTrack::GetEtaPhiDiff(track, cluster, phidiff, etadiff);
590 Double_t mom = track->P();
591 UInt_t mombin = GetMomBin(mom);
592 Int_t centbinch = fCentBin;
593 if (track->Charge()<0)
594 centbinch += fNcentBins;
598 if(track->Eta() > 0) etabin=1;
599 fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(etadiff, phidiff);
602 Double_t etaCut = 0.0;
603 Double_t phiCutlo = 0.0;
604 Double_t phiCuthi = 0.0;
607 phiCutlo = -fPhiMatch;
608 phiCuthi = +fPhiMatch;
610 phiCutlo = GetPhiMean(mombin, centbinch) - GetPhiSigma(mombin, fCentBin);
611 phiCuthi = GetPhiMean(mombin, centbinch) + GetPhiSigma(mombin, fCentBin);
617 etaCut = GetEtaSigma(mombin);
620 if ((phidiff < phiCuthi && phidiff > phiCutlo) && TMath::Abs(etadiff) < etaCut) {
621 if (track->GetLabel() > fMinMCLabel) {
623 trkPMCfrac += track->P();
626 totalTrkP += track->P();
630 fHistMatchdRvsEP[fCentBin]->Fill(dR, energyclus / mom);
637 trkPMCfrac /= totalTrkP;
640 //________________________________________________________________________
641 Bool_t AliHadCorrTask::Run()
643 // Run the hadronic correction
645 AliParticleContainer *clusters = static_cast<AliParticleContainer*>(fParticleCollArray.At(1));
646 AliEmcalParticle *emccluster = 0;
652 fOutClusters->Delete();
656 // loop over all clusters
657 clusters->ResetCurrentID();
658 while ((emccluster = static_cast<AliEmcalParticle*>(clusters->GetNextAcceptParticle()))) {
659 if (!emccluster->IsEMCAL()) continue;
661 AliVCluster *cluster = emccluster->GetCluster();
662 if (!cluster) continue;
664 Double_t energyclus = 0;
666 fHistEbefore->Fill(fCent, cluster->E());
667 fHistNclusvsCent->Fill(fCent);
670 // apply correction / subtraction
671 // to subtract only the closest track set fHadCor to a %
672 // to subtract all tracks within the cut set fHadCor to %+1
674 energyclus = ApplyHadCorrAllTracks(emccluster, fHadCorr - 1);
675 else if (fHadCorr > 0)
676 energyclus = ApplyHadCorrOneTrack(emccluster, fHadCorr);
678 energyclus = cluster->E();
683 if (energyclus > 0) { // create corrected cluster
686 AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(cluster);
688 oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
690 AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(cluster);
692 oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
694 oc->SetE(energyclus);
698 if (fCreateHisto) fHistEafter->Fill(fCent, energyclus);
705 //________________________________________________________________________
706 Double_t AliHadCorrTask::ApplyHadCorrOneTrack(AliEmcalParticle *emccluster, Double_t hadCorr)
708 // Apply the hadronic correction with one track only.
710 AliVCluster *cluster = emccluster->GetCluster();
711 if (!cluster) return 0;
713 Double_t energyclus = cluster->E();
714 Int_t iMin = emccluster->GetMatchedObjId();
718 AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
719 AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(tracks->GetParticle(iMin));
720 if (!emctrack) return energyclus;
722 // check if track also points to cluster
723 Int_t cid = emctrack->GetMatchedObjId();
724 if (fDoTrackClus && (cid!=emccluster->IdInCollection())) return energyclus;
726 AliVTrack *track = emctrack->GetTrack();
727 if (!track) return energyclus;
729 Double_t mom = track->P();
730 if (mom < 1e-6) return energyclus;
732 Double_t dRmin = emccluster->GetMatchedObjDistance();
733 Double_t dEtaMin = 1e9;
734 Double_t dPhiMin = 1e9;
735 AliPicoTrack::GetEtaPhiDiff(track, cluster, dPhiMin, dEtaMin);
737 UInt_t mombin = GetMomBin(mom);
738 Int_t centbinch = fCentBin;
739 if (track->Charge()<0) centbinch += fNcentBins;
741 // plot some histograms if switched on
747 fHistMatchEtaPhi[centbinch][mombin][etabin]->Fill(dEtaMin, dPhiMin);
750 fHistMatchEvsP[fCentBin]->Fill(energyclus, energyclus / mom);
751 fHistEoPCent->Fill(fCent, energyclus / mom);
752 fHistMatchdRvsEP[fCentBin]->Fill(dRmin, energyclus / mom);
756 // define eta/phi cuts
757 Double_t etaCut = 0.0;
758 Double_t phiCutlo = 0.0;
759 Double_t phiCuthi = 0.0;
761 phiCutlo = -fPhiMatch;
762 phiCuthi = +fPhiMatch;
765 phiCutlo = GetPhiMean(mombin, centbinch) - GetPhiSigma(mombin, fCentBin);
766 phiCuthi = GetPhiMean(mombin, centbinch) + GetPhiSigma(mombin, fCentBin);
772 etaCut = GetEtaSigma(mombin);
775 // apply the correction if the track is in the eta/phi window
776 if ((dPhiMin < phiCuthi && dPhiMin > phiCutlo) && TMath::Abs(dEtaMin) < etaCut) {
777 energyclus -= hadCorr * mom;
783 //________________________________________________________________________
784 Double_t AliHadCorrTask::ApplyHadCorrAllTracks(AliEmcalParticle *emccluster, Double_t hadCorr)
786 // Apply the hadronic correction with all tracks.
788 AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0));
790 AliVCluster *cluster = emccluster->GetCluster();
792 Double_t energyclus = cluster->E();
793 Double_t cNcells = cluster->GetNCells();
795 Double_t totalTrkP = 0.0; // count total track momentum
796 Int_t Nmatches = 0; // count total number of matches
798 Double_t trkPMCfrac = 0.0; // count total track momentum
799 Int_t NMCmatches = 0; // count total number of matches
801 // do the loop over the matched tracks and get the number of matches and the total momentum
802 DoMatchedTracksLoop(emccluster, totalTrkP, Nmatches, trkPMCfrac, NMCmatches);
804 Double_t Esub = hadCorr * totalTrkP;
806 if (Esub > energyclus) Esub = energyclus;
808 // applying Peter's proposed algorithm
809 // never subtract the full energy of the cluster
810 Double_t clusEexcl = fEexclCell * cNcells;
811 if (energyclus < clusEexcl) clusEexcl = energyclus;
812 if ((energyclus - Esub) < clusEexcl) Esub = (energyclus - clusEexcl);
816 Double_t EsubBkg = 0;
817 Double_t EclusMC = 0;
818 Double_t EclusBkg = 0;
819 Double_t EclusCorr = 0;
820 Double_t EclusMCcorr = 0;
821 Double_t EclusBkgcorr = 0;
822 Double_t overSub = 0;
824 EsubMC = hadCorr * totalTrkP * trkPMCfrac;
825 EsubBkg = hadCorr * totalTrkP - EsubMC;
826 EclusMC = energyclus * cluster->GetMCEnergyFraction();
827 EclusBkg = energyclus - EclusMC;
829 if (energyclus > Esub)
830 EclusCorr = energyclus - Esub;
832 if (EclusMC > EsubMC)
833 EclusMCcorr = EclusMC - EsubMC;
835 if (EclusBkg > EsubBkg)
836 EclusBkgcorr = EclusBkg - EsubBkg;
838 overSub = EclusMCcorr + EclusBkgcorr - EclusCorr;
841 // plot some histograms if switched on
843 fHistNMatchCent->Fill(fCent, Nmatches);
844 fHistNMatchEnergy[fCentBin]->Fill(energyclus, Nmatches);
847 fHistNclusMatchvsCent->Fill(fCent);
850 fHistNCellsEnergy[fCentBin][Nmatches]->Fill(energyclus, cNcells);
852 fHistNCellsEnergy[fCentBin][3]->Fill(energyclus, cNcells);
855 Double_t EoP = energyclus / totalTrkP;
856 fHistEoPCent->Fill(fCent, EoP);
857 fHistMatchEvsP[fCentBin]->Fill(energyclus, EoP);
859 fHistEsubPchRatAll[fCentBin]->Fill(totalTrkP, Esub / totalTrkP);
862 Int_t iMin = emccluster->GetMatchedObjId();
863 AliEmcalParticle *emctrack = static_cast<AliEmcalParticle*>(tracks->GetParticle(iMin));
865 AliVTrack *track = emctrack->GetTrack();
867 Int_t centbinchm = fCentBin;
868 if (track->Charge()<0) centbinchm += fNcentBins;
870 fHistEsubPchRat[centbinchm]->Fill(totalTrkP, Esub / totalTrkP);
871 fHistEsubPch[centbinchm]->Fill(totalTrkP, Esub);
877 fHistOversub[fCentBin]->Fill(energyclus, overSub / energyclus);
879 if (cluster->GetMCEnergyFraction() > 0.95)
880 fHistOversubMCClusters[fCentBin]->Fill(energyclus, overSub / energyclus);
881 else if (cluster->GetMCEnergyFraction() < 0.05)
882 fHistOversubNonMCClusters[fCentBin]->Fill(energyclus, overSub / energyclus);
884 if (trkPMCfrac < 0.05)
885 fHistNonEmbTrackMatchesOversub[fCentBin]->Fill(energyclus, overSub / energyclus);
886 else if (trkPMCfrac > 0.95)
887 fHistEmbTrackMatchesOversub[fCentBin]->Fill(energyclus, overSub / energyclus);
892 if (fIsEmbedded && fDoExact) {
894 if (EclusBkgcorr + EclusMCcorr > 0) {
895 Double_t newfrac = EclusMCcorr / (EclusBkgcorr + EclusMCcorr);
896 cluster->SetMCEnergyFraction(newfrac);
900 // apply the correction