Skip to content

Commit 19742f5

Browse files
authored
[PWGJE] Changed for better efficiency correction (#13399)
1 parent ac2da13 commit 19742f5

File tree

1 file changed

+29
-178
lines changed

1 file changed

+29
-178
lines changed

PWGJE/Tasks/jetHadronRecoil.cxx

Lines changed: 29 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct JetHadronRecoil {
143143

144144
registry.add("hZvtxSelected", "Z vertex position;Z_{vtx};entries", {HistType::kTH1F, {{80, -20, 20}}}, doSumw);
145145

146-
if (doprocessData || doprocessDataWithRhoSubtraction || doprocessMCD || doprocessMCDWithRhoSubtraction || doprocessMCDWeighted || doprocessMCDWeightedWithRhoSubtraction || doprocessMCP || doprocessMCPWeighted || doprocessMCPWeightedWithMatchedTracks) {
146+
if (doprocessData || doprocessDataWithRhoSubtraction || doprocessMCD || doprocessMCDWithRhoSubtraction || doprocessMCDWeighted || doprocessMCDWeightedWithRhoSubtraction || doprocessMCP || doprocessMCPWeighted) {
147147
registry.add("hNtrig", "number of triggers;trigger type;entries", {HistType::kTH1F, {{2, 0, 2}}}, doSumw);
148148
registry.add("hSignalTriggersPtHard", "Signal triggers vs PtHard", {HistType::kTH1F, {pThatAxis}}, doSumw);
149149
registry.add("hReferenceTriggersPtHard", "Reference triggers vs PtHard", {HistType::kTH1F, {pThatAxis}}, doSumw);
@@ -186,7 +186,7 @@ struct JetHadronRecoil {
186186
registry.add("hPtTrackMatchedToCollisions", "Track p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}, doSumw);
187187
}
188188

189-
if (doprocessMCP || doprocessMCPWeighted || doprocessMCPWeightedWithMatchedTracks) {
189+
if (doprocessMCP || doprocessMCPWeighted) {
190190
registry.add("hPartvsJets", "comparing leading particles and jets;p_{T,part};p_{T,jet};#hat{p}", {HistType::kTH3F, {{200, 0, 200}, {500, -100, 400}, {195, 5, 200}}}, doSumw);
191191
registry.add("hPtPart", "Particle p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}, doSumw);
192192
registry.add("hEtaPart", "Particle #eta;#eta;entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}, doSumw);
@@ -204,6 +204,7 @@ struct JetHadronRecoil {
204204
if (doprocessJetsMCPMCDMatched || doprocessJetsMCPMCDMatchedWithRhoSubtraction || doprocessJetsMCPMCDMatchedWeighted || doprocessJetsMCPMCDMatchedWeightedWithRhoSubtraction || doprocessRecoilJetsMCPMCDMatched || doprocessRecoilJetsMCPMCDMatchedWeighted || doprocessRecoilJetsMCPMCDMatchedWeightedWithRhoSubtraction) {
205205
registry.add("hPtMatched", "p_{T} matching;p_{T,det};p_{T,part}", {HistType::kTH2F, {{500, -100, 400}, {400, 0, 400}}}, doSumw);
206206
registry.add("hPhiMatched", "#phi matching;#phi_{det};#phi_{part}", {HistType::kTH2F, {{100, 0.0, o2::constants::math::TwoPI}, {100, 0.0, o2::constants::math::TwoPI}}}, doSumw);
207+
registry.add("hPhiMatched2d", "#phi matching 2d;#phi;p_{T}", {HistType::kTH2F, {{100, 0.0, o2::constants::math::TwoPI}, {400, 0, 400}}}, doSumw);
207208
registry.add("hDeltaRMatched", "#DeltaR matching;#DeltaR_{det};#DeltaR_{part}", {HistType::kTH2F, {dRAxisDet, dRAxisPart}}, doSumw);
208209
registry.add("hPtMatched1d", "p_{T} matching 1d;p_{T,part}", {HistType::kTH1F, {{400, 0, 400}}}, doSumw);
209210
registry.add("hDeltaRMatched1d", "#DeltaR matching 1d;#DeltaR_{part}", {HistType::kTH1F, {dRAxisPart}}, doSumw);
@@ -350,8 +351,8 @@ struct JetHadronRecoil {
350351
registry.fill(HIST("hTracksvsJets"), leadingTrackPt, leadingJetPt, pTHat, weight);
351352
}
352353

353-
template <typename T, typename U, typename P>
354-
void fillHistogramsMCD(T const& jets, U const& tracks, P const&, float weight = 1.0, float rho = 0.0, float pTHat = 999.0)
354+
template <typename T, typename U>
355+
void fillHistogramsMCD(T const& jets, U const& tracks, float weight = 1.0, float rho = 0.0, float pTHat = 999.0, auto collisionID = 0)
355356
{
356357
bool isSigCol;
357358
std::vector<double> phiTTAr;
@@ -404,8 +405,8 @@ struct JetHadronRecoil {
404405
registry.fill(HIST("hPtTrackPtHard"), track.pt() / pTHat, track.pt(), weight);
405406
if (track.has_mcParticle()) {
406407
registry.fill(HIST("hPtTrackMatched"), track.pt(), weight);
407-
auto particle = track.template mcParticle_as<P>();
408-
if (track.collisionId() == particle.mcCollisionId()) {
408+
auto mcParticle = track.mcParticle();
409+
if (mcParticle.mcCollisionId() == collisionID) {
409410
registry.fill(HIST("hPtTrackMatchedToCollisions"), track.pt(), weight);
410411
}
411412
}
@@ -615,132 +616,6 @@ struct JetHadronRecoil {
615616
registry.fill(HIST("hPartvsJets"), leadingPartPt, leadingJetPt, pTHat, weight);
616617
}
617618

618-
template <typename T, typename U, typename V>
619-
void fillMCPHistogramsWithMatchedTracks(T const& jets, U const& particles, V const& tracks, float weight = 1.0, float pTHat = 999.0)
620-
{
621-
bool isSigCol;
622-
std::vector<double> phiTTAr;
623-
std::vector<double> ptTTAr;
624-
double phiTT = 0;
625-
double ptTT = 0;
626-
int trigNumber = 0;
627-
int nTT = 0;
628-
double leadingPartPt = 0;
629-
double leadingJetPt = 0;
630-
float dice = rand->Rndm();
631-
if (dice < fracSig)
632-
isSigCol = true;
633-
else
634-
isSigCol = false;
635-
636-
for (const auto& track : tracks) {
637-
if (!track.has_mcParticle()) {
638-
continue;
639-
}
640-
auto particle = track.template mcParticle_as<U>();
641-
if (particle.pt() > leadingPartPt) {
642-
leadingPartPt = particle.pt();
643-
}
644-
if (particle.pt() > pTHatTrackMaxMCD * pTHat) {
645-
if (outlierRejectEvent) {
646-
return;
647-
} else {
648-
continue;
649-
}
650-
}
651-
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
652-
if (!pdgParticle) {
653-
continue;
654-
}
655-
if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) {
656-
continue;
657-
}
658-
if (isSigCol && particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin && track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) {
659-
phiTTAr.push_back(particle.phi());
660-
ptTTAr.push_back(particle.pt());
661-
nTT++;
662-
registry.fill(HIST("hSignalTriggers"), particle.pt(), weight);
663-
}
664-
if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin && track.pt() < ptTTrefMax && track.pt() > ptTTrefMin) {
665-
phiTTAr.push_back(particle.phi());
666-
ptTTAr.push_back(particle.pt());
667-
nTT++;
668-
registry.fill(HIST("hReferenceTriggers"), particle.pt(), weight);
669-
}
670-
registry.fill(HIST("hPtPart"), particle.pt(), weight);
671-
registry.fill(HIST("hEtaPart"), particle.eta(), weight);
672-
registry.fill(HIST("hPhiPart"), particle.phi(), weight);
673-
registry.fill(HIST("hPart3D"), particle.pt(), particle.eta(), particle.phi(), weight);
674-
registry.fill(HIST("hPtPartPtHard"), particle.pt(), particle.pt() / pTHat, weight);
675-
}
676-
677-
if (nTT > 0) {
678-
trigNumber = rand->Integer(nTT);
679-
phiTT = phiTTAr[trigNumber];
680-
ptTT = ptTTAr[trigNumber];
681-
if (isSigCol) {
682-
registry.fill(HIST("hNtrig"), 1.5, weight);
683-
registry.fill(HIST("hSigEventTriggers"), nTT, weight);
684-
registry.fill(HIST("hSignalTriggersPtHard"), ptTT / pTHat, weight);
685-
}
686-
if (!isSigCol) {
687-
registry.fill(HIST("hNtrig"), 0.5, weight);
688-
registry.fill(HIST("hRefEventTriggers"), nTT, weight);
689-
registry.fill(HIST("hReferenceTriggersPtHard"), ptTT / pTHat, weight);
690-
}
691-
}
692-
693-
for (const auto& jet : jets) {
694-
if (jet.pt() > leadingJetPt) {
695-
leadingJetPt = jet.pt();
696-
}
697-
if (jet.pt() > pTHatMaxMCP * pTHat) {
698-
if (outlierRejectEvent) {
699-
return;
700-
} else {
701-
continue;
702-
}
703-
}
704-
for (const auto& constituent : jet.template tracks_as<U>()) {
705-
registry.fill(HIST("hConstituents3D"), constituent.pt(), constituent.eta(), constituent.phi());
706-
}
707-
registry.fill(HIST("hJetPt"), jet.pt(), weight);
708-
registry.fill(HIST("hJetEta"), jet.eta(), weight);
709-
registry.fill(HIST("hJetPhi"), jet.phi(), weight);
710-
registry.fill(HIST("hJet3D"), jet.pt(), jet.eta(), jet.phi(), weight);
711-
712-
if (nTT > 0) {
713-
float dphi = RecoDecay::constrainAngle(jet.phi() - phiTT);
714-
double dR = getWTAaxisDifference(jet, particles);
715-
if (isSigCol) {
716-
if (std::abs(dphi - o2::constants::math::PI) < 0.6) {
717-
registry.fill(HIST("hDeltaRpTSignalPart"), jet.pt(), dR, weight);
718-
registry.fill(HIST("hDeltaRSignalPart"), dR, weight);
719-
}
720-
registry.fill(HIST("hDeltaRpTDPhiSignalPart"), jet.pt(), dphi, dR, weight);
721-
registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight);
722-
if (std::abs(dphi - o2::constants::math::PI) < 0.6) {
723-
registry.fill(HIST("hSignalPt"), jet.pt(), weight);
724-
registry.fill(HIST("hSignalPtHard"), jet.pt(), ptTT / pTHat, weight);
725-
}
726-
}
727-
if (!isSigCol) {
728-
if (std::abs(dphi - o2::constants::math::PI) < 0.6) {
729-
registry.fill(HIST("hDeltaRpTPartReference"), jet.pt(), dR, weight);
730-
registry.fill(HIST("hDeltaRPartReference"), dR, weight);
731-
}
732-
registry.fill(HIST("hDeltaRpTDPhiReferencePart"), jet.pt(), dphi, dR, weight);
733-
registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight);
734-
if (std::abs(dphi - o2::constants::math::PI) < 0.6) {
735-
registry.fill(HIST("hReferencePt"), jet.pt(), weight);
736-
registry.fill(HIST("hReferencePtHard"), jet.pt(), ptTT / pTHat, weight);
737-
}
738-
}
739-
}
740-
}
741-
registry.fill(HIST("hPartvsJets"), leadingPartPt, leadingJetPt, pTHat, weight);
742-
}
743-
744619
template <typename T, typename U, typename X, typename Y>
745620
void fillMatchedHistograms(T const& jetsBase, U const&, X const& tracks, Y const& particles, float weight = 1.0, float rho = 0.0, float pTHat = 999.0)
746621
{
@@ -808,20 +683,18 @@ struct JetHadronRecoil {
808683
continue;
809684
}
810685
}
811-
if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) {
812-
auto particle = track.template mcParticle_as<Y>();
813-
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
814-
if (!pdgParticle) {
815-
continue;
816-
}
817-
if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) {
818-
continue;
819-
}
820-
if (particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) {
821-
nTT++;
822-
phiTTAr.push_back(track.phi());
823-
phiTTArPart.push_back(particle.phi());
824-
}
686+
auto particle = track.template mcParticle_as<Y>();
687+
auto pdgParticle = pdg->GetParticle(particle.pdgCode());
688+
if (!pdgParticle) {
689+
continue;
690+
}
691+
if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) {
692+
continue;
693+
}
694+
if (particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) {
695+
nTT++;
696+
phiTTAr.push_back(track.phi());
697+
phiTTArPart.push_back(particle.phi());
825698
}
826699
}
827700

@@ -861,9 +734,10 @@ struct JetHadronRecoil {
861734
float dphip = RecoDecay::constrainAngle(jetTag.phi() - phiTTPart);
862735
dRp = getWTAaxisDifference(jetTag, particles);
863736
registry.fill(HIST("hPhiMatched"), dphi, dphip, weight);
737+
registry.fill(HIST("hPhiMatched2d"), jetTag.phi(), jetTag.pt(), weight);
864738
registry.fill(HIST("hPhiResolution"), jetTag.pt(), dphip - dphi, weight);
865739
registry.fill(HIST("hFullMatching"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), dphi, dphip, dR, dRp, weight);
866-
if ((std::abs(dphi - o2::constants::math::PI) < 0.6) || (std::abs(dphip - o2::constants::math::PI) < 0.6)) {
740+
if ((std::abs(dphip - o2::constants::math::PI) < 0.6)) {
867741
registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight);
868742
registry.fill(HIST("hDeltaRMatched1d"), dRp, weight);
869743
registry.fill(HIST("hPtMatched"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), weight);
@@ -909,8 +783,7 @@ struct JetHadronRecoil {
909783
void processMCD(soa::Filtered<soa::Join<aod::JetCollisions, aod::JMcCollisionLbs>>::iterator const& collision,
910784
aod::JMcCollisions const&,
911785
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents>> const& jets,
912-
soa::Filtered<aod::JetTracksMCD> const& tracks,
913-
soa::Filtered<aod::JetParticles> const& particles)
786+
soa::Filtered<soa::Join<aod::JetTracks, aod::JTrackExtras, aod::JMcTrackLbs>> const& tracks)
914787
{
915788
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
916789
return;
@@ -928,15 +801,14 @@ struct JetHadronRecoil {
928801
return;
929802
}
930803
registry.fill(HIST("hZvtxSelected"), collision.posZ());
931-
fillHistogramsMCD(jets, tracks, particles, 1.0, 0.0, collision.mcCollision().ptHard());
804+
fillHistogramsMCD(jets, tracks, 1.0, 0.0, collision.mcCollision().ptHard(), collision.mcCollisionId());
932805
}
933806
PROCESS_SWITCH(JetHadronRecoil, processMCD, "process MC detector level", false);
934807

935808
void processMCDWithRhoSubtraction(soa::Filtered<soa::Join<aod::JetCollisions, aod::BkgChargedRhos, aod::JMcCollisionLbs>>::iterator const& collision,
936809
aod::JMcCollisions const&,
937810
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents>> const& jets,
938-
soa::Filtered<aod::JetTracksMCD> const& tracks,
939-
soa::Filtered<aod::JetParticles> const& particles)
811+
soa::Filtered<soa::Join<aod::JetTracks, aod::JTrackExtras, aod::JMcTrackLbs>> const& tracks)
940812
{
941813
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
942814
return;
@@ -954,15 +826,14 @@ struct JetHadronRecoil {
954826
return;
955827
}
956828
registry.fill(HIST("hZvtxSelected"), collision.posZ());
957-
fillHistogramsMCD(jets, tracks, particles, 1.0, collision.rho(), collision.mcCollision().ptHard());
829+
fillHistogramsMCD(jets, tracks, 1.0, collision.rho(), collision.mcCollision().ptHard(), collision.mcCollisionId());
958830
}
959831
PROCESS_SWITCH(JetHadronRecoil, processMCDWithRhoSubtraction, "process MC detector level with rho subtraction", false);
960832

961833
void processMCDWeighted(soa::Filtered<soa::Join<aod::JetCollisions, aod::JMcCollisionLbs>>::iterator const& collision,
962834
aod::JMcCollisions const&,
963835
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents>> const& jets,
964-
soa::Filtered<aod::JetTracksMCD> const& tracks,
965-
soa::Filtered<aod::JetParticles> const& particles)
836+
soa::Filtered<soa::Join<aod::JetTracks, aod::JTrackExtras, aod::JMcTrackLbs>> const& tracks)
966837
{
967838
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
968839
return;
@@ -980,15 +851,14 @@ struct JetHadronRecoil {
980851
return;
981852
}
982853
registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight());
983-
fillHistogramsMCD(jets, tracks, particles, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard());
854+
fillHistogramsMCD(jets, tracks, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard(), collision.mcCollisionId());
984855
}
985856
PROCESS_SWITCH(JetHadronRecoil, processMCDWeighted, "process MC detector level with event weights", false);
986857

987858
void processMCDWeightedWithRhoSubtraction(soa::Filtered<soa::Join<aod::JetCollisions, aod::JMcCollisionLbs, aod::BkgChargedRhos>>::iterator const& collision,
988859
aod::JMcCollisions const&,
989860
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents>> const& jets,
990-
soa::Filtered<aod::JetTracksMCD> const& tracks,
991-
soa::Filtered<aod::JetParticles> const& particles)
861+
soa::Filtered<soa::Join<aod::JetTracks, aod::JTrackExtras, aod::JMcTrackLbs>> const& tracks)
992862
{
993863
if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) {
994864
return;
@@ -1006,7 +876,7 @@ struct JetHadronRecoil {
1006876
return;
1007877
}
1008878
registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight());
1009-
fillHistogramsMCD(jets, tracks, particles, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard());
879+
fillHistogramsMCD(jets, tracks, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard(), collision.mcCollisionId());
1010880
}
1011881
PROCESS_SWITCH(JetHadronRecoil, processMCDWeightedWithRhoSubtraction, "process MC detector level with event weights and rho subtraction", false);
1012882

@@ -1046,25 +916,6 @@ struct JetHadronRecoil {
1046916
}
1047917
PROCESS_SWITCH(JetHadronRecoil, processMCPWeighted, "process MC particle level with event weights", false);
1048918

1049-
void processMCPWeightedWithMatchedTracks(aod::JetMcCollision const& collision,
1050-
soa::Filtered<soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents>> const& jets,
1051-
soa::Filtered<aod::JetParticles> const& particles,
1052-
soa::Filtered<aod::JetTracksMCD> const& tracks)
1053-
{
1054-
if (std::abs(collision.posZ()) > vertexZCut) {
1055-
return;
1056-
}
1057-
if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) {
1058-
return;
1059-
}
1060-
if (collision.ptHard() < pTHatMinEvent) {
1061-
return;
1062-
}
1063-
registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.weight());
1064-
fillMCPHistogramsWithMatchedTracks(jets, particles, tracks, collision.weight(), collision.ptHard());
1065-
}
1066-
PROCESS_SWITCH(JetHadronRecoil, processMCPWeightedWithMatchedTracks, "process MC particle level with event weights - only triggers matched with detector level tracks", false);
1067-
1068919
void processJetsMCPMCDMatched(soa::Filtered<soa::Join<aod::JetCollisionsMCD, aod::JMcCollisionLbs>>::iterator const& collision,
1069920
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets>> const& mcdjets,
1070921
aod::JetTracks const& tracks,

0 commit comments

Comments
 (0)