From 1b8043c6e8018f83a077e71dbb7d01eff4452576 Mon Sep 17 00:00:00 2001 From: jaimenorman Date: Sun, 24 Dec 2023 11:40:43 +0000 Subject: [PATCH] PWGJE: add weighted track and number of collisions option (#4179) * add weighted track and number of collisions options to QA tasks * fix exponent in weighting --- PWGJE/Tasks/jetfinderQA.cxx | 52 +++++++++++++++++++------- PWGJE/Tasks/jetfinderfullQA.cxx | 66 ++++++++++++++++++++++----------- PWGJE/Tasks/jetfinderhfQA.cxx | 51 ++++++++++++++++++------- 3 files changed, 120 insertions(+), 49 deletions(-) diff --git a/PWGJE/Tasks/jetfinderQA.cxx b/PWGJE/Tasks/jetfinderQA.cxx index 5d8aa9d7be7..b9792d1287a 100644 --- a/PWGJE/Tasks/jetfinderQA.cxx +++ b/PWGJE/Tasks/jetfinderQA.cxx @@ -54,7 +54,7 @@ struct JetFinderQATask { Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; - Configurable pTHatExponent{"pTHatExponent", 0.1666, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; std::vector filledJetR; std::vector jetRadiiValues; @@ -158,11 +158,15 @@ struct JetFinderQATask { registry.add("h3_jet_r_jet_pt_track_eta_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#eta_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); registry.add("h3_jet_r_jet_pt_track_phi_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});#varphi_{jet tracks}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {160, -1.0, 7.}}}); } - if (doprocessTracks) { + + if (doprocessTracks || doprocessTracksWeighted) { registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); registry.add("h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); + if (doprocessTracksWeighted) { + registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + } } if (doprocessMCCollisionsWeighted) { @@ -180,7 +184,7 @@ struct JetFinderQATask { void fillHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -210,7 +214,7 @@ struct JetFinderQATask { void fillMCPHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCP * pTHat) { return; } @@ -238,7 +242,7 @@ struct JetFinderQATask { template void fillMCMatchedHistograms(T const& mcdjet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (mcdjet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -265,6 +269,18 @@ struct JetFinderQATask { } } + void fillTrackHistograms(soa::Filtered const& tracks, float weight = 1.0) + { + for (auto const& track : tracks) { + if (!JetDerivedDataUtilities::selectTrack(track, trackSelection)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt(), weight); + registry.fill(HIST("h_track_eta"), track.eta(), weight); + registry.fill(HIST("h_track_phi"), track.phi(), weight); + } + } + void processJetsData(soa::Join::iterator const& jet, JetTracks const& tracks) { fillHistograms(jet); @@ -452,22 +468,30 @@ struct JetFinderQATask { void processTracks(aod::JCollision const& collision, soa::Filtered const& tracks) { - registry.fill(HIST("h_collisions"), 0.5); if (!JetDerivedDataUtilities::selectCollision(collision, eventSelection)) { return; } registry.fill(HIST("h_collisions"), 1.5); - for (auto const& track : tracks) { - if (!JetDerivedDataUtilities::selectTrack(track, trackSelection)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } + fillTrackHistograms(tracks); } PROCESS_SWITCH(JetFinderQATask, processTracks, "QA for charged tracks", false); + + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JMcCollisions const& mcCollisions, + soa::Filtered const& tracks) + { + float eventWeight = collision.mcCollision().weight(); + registry.fill(HIST("h_collisions"), 0.5); + registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); + if (!JetDerivedDataUtilities::selectCollision(collision, eventSelection)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + fillTrackHistograms(tracks, eventWeight); + } + PROCESS_SWITCH(JetFinderQATask, processTracksWeighted, "QA for charged tracks weighted", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-finder-charged-qa"})}; } diff --git a/PWGJE/Tasks/jetfinderfullQA.cxx b/PWGJE/Tasks/jetfinderfullQA.cxx index be3eb984981..78f854107ca 100644 --- a/PWGJE/Tasks/jetfinderfullQA.cxx +++ b/PWGJE/Tasks/jetfinderfullQA.cxx @@ -63,7 +63,7 @@ struct JetFinderFullQATask { Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; - Configurable pTHatExponent{"pTHatExponent", 0.1666, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; std::vector filledJetR; std::vector jetRadiiValues; @@ -138,7 +138,7 @@ struct JetFinderFullQATask { registry.add("h3_jet_pt_part_jet_ntracks_part_jet_ntracks", ";#it{p}_{T,jet}^{part} (GeV/#it{c}); N_{jet tracks}^{part}; N_{jet tracks}", {HistType::kTH3F, {{200, 0.0, 200}, {100, -0.5, 99.5}, {100, -0.5, 99.5}}}); } - if (doprocessTracks) { + if (doprocessTracks || doprocessTracksWeighted) { registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); @@ -147,6 +147,9 @@ struct JetFinderFullQATask { registry.add("h_cluster_eta", "cluster #eta;#eta_{cluster};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); registry.add("h_cluster_phi", "cluster #varphi;#varphi_{cluster};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); registry.add("h_cluster_energy", "cluster E;E_{cluster} (GeV);entries", {HistType::kTH1F, {{200, 0., 200.}}}); + if (doprocessTracksWeighted) { + registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + } } if (doprocessMCCollisionsWeighted) { @@ -176,7 +179,7 @@ struct JetFinderFullQATask { void fillHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -216,7 +219,7 @@ struct JetFinderFullQATask { void fillMCPHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCP * pTHat) { return; } @@ -245,7 +248,7 @@ struct JetFinderFullQATask { void fillMCMatchedHistograms(T const& mcdjet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (mcdjet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -272,6 +275,25 @@ struct JetFinderFullQATask { } } + void fillTrackHistograms(soa::Filtered const& tracks, soa::Filtered const& clusters, float weight = 1.0) + { + for (auto const& track : tracks) { + if (!JetDerivedDataUtilities::selectTrack(track, trackSelection) || !JetDerivedDataUtilities::applyTrackKinematics(track, trackPtMin, trackPtMax, trackEtaMin, trackEtaMax)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt(), weight); + registry.fill(HIST("h_track_eta"), track.eta(), weight); + registry.fill(HIST("h_track_phi"), track.phi(), weight); + } + for (auto const& cluster : clusters) { + double clusterpt = cluster.energy() / std::cosh(cluster.eta()); + registry.fill(HIST("h_cluster_pt"), clusterpt, weight); + registry.fill(HIST("h_cluster_eta"), cluster.eta(), weight); + registry.fill(HIST("h_cluster_phi"), cluster.phi(), weight); + registry.fill(HIST("h_cluster_energy"), cluster.energy(), weight); + } + } + void processDummy(aod::JCollisions const& collision) { } @@ -348,29 +370,31 @@ struct JetFinderFullQATask { soa::Filtered const& tracks, soa::Filtered const& clusters) { - registry.fill(HIST("h_collisions"), 0.5); if (!JetDerivedDataUtilities::eventEMCAL(collision)) { return; } registry.fill(HIST("h_collisions"), 1.5); - for (auto const& track : tracks) { - if (!JetDerivedDataUtilities::selectTrack(track, trackSelection) || !JetDerivedDataUtilities::applyTrackKinematics(track, trackPtMin, trackPtMax, trackEtaMin, trackEtaMax)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } - for (auto const& cluster : clusters) { - double clusterpt = cluster.energy() / std::cosh(cluster.eta()); - registry.fill(HIST("h_cluster_pt"), clusterpt); - registry.fill(HIST("h_cluster_eta"), cluster.eta()); - registry.fill(HIST("h_cluster_phi"), cluster.phi()); - registry.fill(HIST("h_cluster_energy"), cluster.energy()); - } + fillTrackHistograms(tracks, clusters); } PROCESS_SWITCH(JetFinderFullQATask, processTracks, "QA for charged tracks", false); + + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JMcCollisions const& mcCollisions, + soa::Filtered const& tracks, + soa::Filtered const& clusters) + { + float eventWeight = collision.mcCollision().weight(); + registry.fill(HIST("h_collisions"), 0.5); + registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); + if (!JetDerivedDataUtilities::eventEMCAL(collision)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + fillTrackHistograms(tracks, clusters, eventWeight); + } + PROCESS_SWITCH(JetFinderFullQATask, processTracksWeighted, "QA for charged tracks weighted", false); }; using JetFinderFullJetsQATask = JetFinderFullQATask; diff --git a/PWGJE/Tasks/jetfinderhfQA.cxx b/PWGJE/Tasks/jetfinderhfQA.cxx index 9ec10903cd4..1072e967b6d 100644 --- a/PWGJE/Tasks/jetfinderhfQA.cxx +++ b/PWGJE/Tasks/jetfinderhfQA.cxx @@ -60,7 +60,7 @@ struct JetFinderHFQATask { Configurable selectionFlagBplus{"selectionFlagBplus", 1, "Selection Flag for B+"}; Configurable pTHatMaxMCD{"pTHatMaxMCD", 999.0, "maximum fraction of hard scattering for jet acceptance in detector MC"}; Configurable pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum fraction of hard scattering for jet acceptance in particle MC"}; - Configurable pTHatExponent{"pTHatExponent", 0.1666, "exponent of the event weight for the calculation of pTHat"}; + Configurable pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the calculation of pTHat"}; HfHelper hfHelper; std::vector filledJetR; @@ -204,11 +204,14 @@ struct JetFinderHFQATask { registry.add("h3_jet_r_jet_pt_candidate_y_Triggered_Both", "#it{R}_{jet};#it{p}_{T,jet} (GeV/#it{c});y_{candidate}", {HistType::kTH3F, {{jetRadiiBins, ""}, {200, 0., 200.}, {100, -1.0, 1.0}}}); } - if (doprocessTracks) { + if (doprocessTracks || doprocessTracksWeighted) { registry.add("h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); registry.add("h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); registry.add("h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}); registry.add("h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{160, -1.0, 7.}}}); + if (doprocessTracksWeighted) { + registry.add("h_collisions_weighted", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}); + } } if (doprocessMCCollisionsWeighted) { @@ -234,7 +237,7 @@ struct JetFinderHFQATask { void fillHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -303,7 +306,7 @@ struct JetFinderHFQATask { void fillMCPHistograms(T const& jet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (jet.pt() > pTHatMaxMCP * pTHat) { return; } @@ -344,7 +347,7 @@ struct JetFinderHFQATask { void fillMCMatchedHistograms(T const& mcdjet, float weight = 1.0) { - float pTHat = 10. / (std::pow(weight, pTHatExponent)); + float pTHat = 10. / (std::pow(weight, 1.0 / pTHatExponent)); if (mcdjet.pt() > pTHatMaxMCD * pTHat) { return; } @@ -399,6 +402,18 @@ struct JetFinderHFQATask { } } + void fillTrackHistograms(soa::Filtered const& tracks, float weight = 1.0) + { + for (auto const& track : tracks) { + if (!JetDerivedDataUtilities::selectTrack(track, trackSelection)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt(), weight); + registry.fill(HIST("h_track_eta"), track.eta(), weight); + registry.fill(HIST("h_track_phi"), track.phi(), weight); + } + } + void processDummy(aod::Collisions const& collision) { } @@ -611,22 +626,30 @@ struct JetFinderHFQATask { void processTracks(aod::JCollision const& collision, soa::Filtered const& tracks) { - registry.fill(HIST("h_collisions"), 0.5); if (!JetDerivedDataUtilities::selectCollision(collision, eventSelection)) { return; } registry.fill(HIST("h_collisions"), 1.5); - for (auto const& track : tracks) { - if (!JetDerivedDataUtilities::selectTrack(track, trackSelection)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } + fillTrackHistograms(tracks); } PROCESS_SWITCH(JetFinderHFQATask, processTracks, "QA for charged tracks", false); + + void processTracksWeighted(soa::Join::iterator const& collision, + aod::JMcCollisions const& mcCollisions, + soa::Filtered const& tracks) + { + float eventWeight = collision.mcCollision().weight(); + registry.fill(HIST("h_collisions"), 0.5); + registry.fill(HIST("h_collisions_weighted"), 0.5, eventWeight); + if (!JetDerivedDataUtilities::selectCollision(collision, eventSelection)) { + return; + } + registry.fill(HIST("h_collisions"), 1.5); + registry.fill(HIST("h_collisions_weighted"), 1.5, eventWeight); + fillTrackHistograms(tracks, eventWeight); + } + PROCESS_SWITCH(JetFinderHFQATask, processTracksWeighted, "QA for charged tracks weighted", false); }; using JetFinderD0QATask = JetFinderHFQATask, aod::D0ChargedMCDetectorLevelJets, aod::D0ChargedMCDetectorLevelJetConstituents, aod::D0ChargedMCDetectorLevelJetsMatchedToD0ChargedMCParticleLevelJets, aod::D0ChargedMCDetectorLevelJetEventWeights, soa::Join, aod::D0ChargedMCParticleLevelJets, aod::D0ChargedMCParticleLevelJetConstituents, aod::D0ChargedMCParticleLevelJetsMatchedToD0ChargedMCDetectorLevelJets, aod::D0ChargedMCParticleLevelJetEventWeights, soa::Join>;