Skip to content

Commit fd10435

Browse files
authored
[PWGJE] Fixing recoil jet response to fill with delta phi (#11578)
1 parent 85e9628 commit fd10435

File tree

1 file changed

+75
-33
lines changed

1 file changed

+75
-33
lines changed

PWGJE/Tasks/jetHadronRecoil.cxx

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,6 @@ struct JetHadronRecoil {
446446
return;
447447
}
448448

449-
for (const auto& mcdjetWTA : mcdjetsWTA) {
450-
double djet = RecoDecay::sqrtSumOfSquares(RecoDecay::constrainAngle(jetBase.phi() - mcdjetWTA.phi(), -o2::constants::math::PI), jetBase.eta() - mcdjetWTA.eta());
451-
if (mcdjetWTA.pt() > pTHatMaxMCD * pTHat) {
452-
continue;
453-
}
454-
if (djet < 0.6 * jetR) {
455-
dR = djet;
456-
break;
457-
}
458-
}
459-
460449
dR = getWTAaxisDifference(jetBase, mcdjetsWTA, tracks, true);
461450

462451
if (jetBase.has_matchedJetGeo()) {
@@ -481,6 +470,77 @@ struct JetHadronRecoil {
481470
}
482471
}
483472

473+
template <typename T, typename V, typename W, typename U, typename X, typename Y>
474+
void fillRecoilJetMatchedHistograms(T const& jetsBase, V const& mcdjetsWTA, W const& mcpjetsWTA, U const&, X const& tracks, Y const& particles, float weight = 1.0, float rho = 0.0)
475+
{
476+
std::vector<double> phiTTAr;
477+
std::vector<double> phiTTArPart;
478+
double phiTT = 0;
479+
double phiTTPart = 0;
480+
int trigNumber = 0;
481+
int nTT = 0;
482+
float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent));
483+
484+
for (const auto& track : tracks) {
485+
if (!track.has_mcParticle()) {
486+
continue;
487+
}
488+
if (!jetderiveddatautilities::selectTrack(track, trackSelection)) {
489+
continue;
490+
}
491+
if (track.pt() > pTHatTrackMaxMCD * pTHat) {
492+
return;
493+
}
494+
if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) {
495+
phiTTAr.push_back(track.phi());
496+
nTT++;
497+
auto particle = track.template mcParticle_as<Y>();
498+
phiTTArPart.push_back(particle.phi());
499+
}
500+
}
501+
502+
if (nTT > 0) {
503+
trigNumber = rand->Integer(nTT);
504+
phiTT = phiTTAr[trigNumber];
505+
phiTTPart = phiTTAr[trigNumber];
506+
} else {
507+
return;
508+
}
509+
510+
for (const auto& jetBase : jetsBase) {
511+
double dR = 0;
512+
double dRp = 0;
513+
514+
if (jetBase.pt() > pTHatMaxMCD * pTHat) {
515+
return;
516+
}
517+
518+
float dphi = RecoDecay::constrainAngle(jetBase.phi() - phiTT);
519+
dR = getWTAaxisDifference(jetBase, mcdjetsWTA, tracks, true);
520+
521+
if (jetBase.has_matchedJetGeo()) {
522+
for (const auto& jetTag : jetBase.template matchedJetGeo_as<std::decay_t<U>>()) {
523+
if (jetTag.pt() > pTHatMaxMCP * pTHat) {
524+
return;
525+
}
526+
527+
float dphip = RecoDecay::constrainAngle(jetTag.phi() - phiTTPart);
528+
dRp = getWTAaxisDifference(jetTag, mcpjetsWTA, particles, true);
529+
530+
registry.fill(HIST("hPtMatched"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), weight);
531+
registry.fill(HIST("hPhiMatched"), dphi, dphip, weight);
532+
registry.fill(HIST("hPtResolution"), jetTag.pt(), (jetTag.pt() - (jetBase.pt() - (rho * jetBase.area()))) / jetTag.pt(), weight);
533+
registry.fill(HIST("hPhiResolution"), dphip, dphip - dphi, weight);
534+
registry.fill(HIST("hDeltaRMatched"), dR, dRp, weight);
535+
registry.fill(HIST("hDeltaRResolution"), jetTag.pt(), dRp - dR, weight);
536+
registry.fill(HIST("hFullMatching"), jetBase.pt() - (rho * jetBase.area()), jetTag.pt(), dphi, dphip, dR, dRp, weight);
537+
registry.fill(HIST("hPtMatched1d"), jetTag.pt(), weight);
538+
registry.fill(HIST("hDeltaRMatched1d"), dRp, weight);
539+
}
540+
}
541+
}
542+
}
543+
484544
void processData(soa::Filtered<aod::JetCollisions>::iterator const& collision,
485545
soa::Filtered<soa::Join<aod::ChargedJets, aod::ChargedJetConstituents, aod::ChargedJetsMatchedToCharged1Jets>> const& jets,
486546
soa::Filtered<soa::Join<aod::Charged1Jets, aod::Charged1JetConstituents, aod::Charged1JetsMatchedToChargedJets>> const& jetsWTA,
@@ -711,7 +771,7 @@ struct JetHadronRecoil {
711771
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets>> const& mcdjets,
712772
soa::Filtered<soa::Join<aod::Charged1MCDetectorLevelJets, aod::Charged1MCDetectorLevelJetConstituents>> const& mcdjetsWTA,
713773
soa::Filtered<soa::Join<aod::Charged1MCParticleLevelJets, aod::Charged1MCParticleLevelJetConstituents>> const& mcpjetsWTA,
714-
soa::Filtered<aod::JetTracks> const& tracks,
774+
soa::Filtered<aod::JetTracksMCD> const& tracks,
715775
soa::Filtered<aod::JetParticles> const& particles,
716776
aod::JetMcCollisions const&,
717777
soa::Filtered<soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents, aod::ChargedMCParticleLevelJetsMatchedToChargedMCDetectorLevelJets>> const& mcpjets)
@@ -724,24 +784,15 @@ struct JetHadronRecoil {
724784
}
725785
registry.fill(HIST("hZvtxSelected"), collision.posZ());
726786
const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId());
727-
bool ishJetEvent = false;
728-
for (const auto& track : tracks) {
729-
if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) {
730-
ishJetEvent = true;
731-
break;
732-
}
733-
}
734-
if (ishJetEvent) {
735-
fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles);
736-
}
787+
fillRecoilJetMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles);
737788
}
738789
PROCESS_SWITCH(JetHadronRecoil, processRecoilJetsMCPMCDMatched, "process MC matched (recoil jets)", false);
739790

740791
void processRecoilJetsMCPMCDMatchedWeighted(soa::Filtered<aod::JetCollisionsMCD>::iterator const& collision,
741792
soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets>> const& mcdjets,
742793
soa::Filtered<soa::Join<aod::Charged1MCDetectorLevelJets, aod::Charged1MCDetectorLevelJetConstituents>> const& mcdjetsWTA,
743794
soa::Filtered<soa::Join<aod::Charged1MCParticleLevelJets, aod::Charged1MCParticleLevelJetConstituents>> const& mcpjetsWTA,
744-
soa::Filtered<aod::JetTracks> const& tracks,
795+
soa::Filtered<aod::JetTracksMCD> const& tracks,
745796
soa::Filtered<aod::JetParticles> const& particles,
746797
aod::JetMcCollisions const&,
747798
soa::Filtered<soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents, aod::ChargedMCParticleLevelJetsMatchedToChargedMCDetectorLevelJets>> const& mcpjets)
@@ -754,16 +805,7 @@ struct JetHadronRecoil {
754805
}
755806
registry.fill(HIST("hZvtxSelected"), collision.posZ());
756807
const auto& mcpjetsWTACut = mcpjetsWTA.sliceBy(partJetsPerCollision, collision.mcCollisionId());
757-
bool ishJetEvent = false;
758-
for (const auto& track : tracks) {
759-
if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) {
760-
ishJetEvent = true;
761-
break;
762-
}
763-
}
764-
if (ishJetEvent) {
765-
fillMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, collision.mcCollision().weight());
766-
}
808+
fillRecoilJetMatchedHistograms(mcdjets, mcdjetsWTA, mcpjetsWTACut, mcpjets, tracks, particles, collision.mcCollision().weight());
767809
}
768810
PROCESS_SWITCH(JetHadronRecoil, processRecoilJetsMCPMCDMatchedWeighted, "process MC matched with event weights (recoil jets)", false);
769811

0 commit comments

Comments
 (0)