|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file jetSpectraChargedGen.cxx |
| 13 | +/// \brief Charged-particle jet spectra at MC-particle level for generator-only |
| 14 | +/// AODs (no reconstruction tables required). Companion to |
| 15 | +/// jetSpectraCharged.cxx for productions such as EPOS 4 on-the-fly |
| 16 | +/// where only mc-particle and mc-collision tables exist. |
| 17 | +/// \author Joonsuk Bae <joonsuk.bae@cern.ch> |
| 18 | + |
| 19 | +#include "PWGJE/Core/JetFindingUtilities.h" |
| 20 | +#include "PWGJE/Core/JetUtilities.h" |
| 21 | +#include "PWGJE/DataModel/Jet.h" |
| 22 | +#include "PWGJE/DataModel/JetSubtraction.h" |
| 23 | + |
| 24 | +#include <CommonConstants/MathConstants.h> |
| 25 | +#include <Framework/ASoA.h> |
| 26 | +#include <Framework/AnalysisTask.h> |
| 27 | +#include <Framework/Configurable.h> |
| 28 | +#include <Framework/HistogramRegistry.h> |
| 29 | +#include <Framework/HistogramSpec.h> |
| 30 | +#include <Framework/InitContext.h> |
| 31 | +#include <Framework/runDataProcessing.h> |
| 32 | + |
| 33 | +#include <cmath> |
| 34 | +#include <string> |
| 35 | + |
| 36 | +using namespace o2; |
| 37 | +using namespace o2::framework; |
| 38 | +using namespace o2::framework::expressions; |
| 39 | + |
| 40 | +struct JetSpectraChargedGen { |
| 41 | + |
| 42 | + using JetBkgRhoMcCollisions = soa::Join<aod::JetMcCollisions, aod::BkgChargedMcRhos>; |
| 43 | + |
| 44 | + HistogramRegistry registry{"registry", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 45 | + |
| 46 | + Configurable<float> selectedJetsRadius{"selectedJetsRadius", 0.2, "resolution parameter for histograms without radius"}; |
| 47 | + Configurable<float> jetEtaMin{"jetEtaMin", -0.7, "minimum jet pseudorapidity"}; |
| 48 | + Configurable<float> jetEtaMax{"jetEtaMax", 0.7, "maximum jet pseudorapidity"}; |
| 49 | + Configurable<float> trackEtaMin{"trackEtaMin", -0.9, "minimum particle pseudorapidity"}; |
| 50 | + Configurable<float> trackEtaMax{"trackEtaMax", 0.9, "maximum particle pseudorapidity"}; |
| 51 | + Configurable<float> jetAreaFractionMin{"jetAreaFractionMin", -99.0, "minimum area fraction relative to pi R^2"}; |
| 52 | + Configurable<float> leadingConstituentPtMin{"leadingConstituentPtMin", -99.0, "minimum pT of the leading constituent"}; |
| 53 | + Configurable<float> leadingConstituentPtMax{"leadingConstituentPtMax", 9999.0, "maximum pT of the leading constituent"}; |
| 54 | + Configurable<float> pTHatMaxMCP{"pTHatMaxMCP", 999.0, "maximum jet pT in units of pTHat (outlier rejection)"}; |
| 55 | + Configurable<float> pTHatAbsoluteMin{"pTHatAbsoluteMin", -99.0, "minimum pTHat"}; |
| 56 | + Configurable<float> pTHatExponent{"pTHatExponent", 6.0, "exponent of the event weight for the back-calculation of pTHat"}; |
| 57 | + Configurable<float> simPtRef{"simPtRef", 10.0, "reference pT for the back-calculation of pTHat from the event weight"}; |
| 58 | + Configurable<float> vertexZCut{"vertexZCut", 10.0, "truth vertex-z cut; <=0 disables"}; |
| 59 | + Configurable<float> kappa{"kappa", 1.0, "angularity kappa"}; |
| 60 | + Configurable<float> alpha{"alpha", 1.0, "angularity alpha"}; |
| 61 | + Configurable<double> jetPtMax{"jetPtMax", 200.0, "max of the jet pT axis"}; |
| 62 | + |
| 63 | + static constexpr float kConfigSwitchLow = -98.0f; |
| 64 | + static constexpr float kConfigSwitchHigh = 9998.0f; |
| 65 | + |
| 66 | + void init(InitContext const&) |
| 67 | + { |
| 68 | + AxisSpec jetPtAxis = {static_cast<int>(jetPtMax), 0.0, jetPtMax, "#it{p}_{T,jet} (GeV/#it{c})"}; |
| 69 | + AxisSpec etaAxis = {100, -1.0, 1.0, "#eta_{jet}"}; |
| 70 | + AxisSpec phiAxis = {160, -1.0, 7.0, "#varphi_{jet}"}; |
| 71 | + AxisSpec rhoAxis = {200, 0.0, 200.0, "#rho (GeV/#it{c})"}; |
| 72 | + |
| 73 | + registry.add("h_mccollisions", "MC collisions counter;;entries", {HistType::kTH1F, {{1, 0.0, 1.0}}}); |
| 74 | + registry.add("h_mccollisions_rho", "#rho distribution;#rho (GeV/#it{c});entries", {HistType::kTH1F, {rhoAxis}}); |
| 75 | + registry.add("p_xSection", ";;<#sigma_{gen}> from HepMC (pb)", {HistType::kTProfile, {{1, 0.0, 1.0}}}); |
| 76 | + |
| 77 | + registry.add("h_jet_pt_part", ";#it{p}_{T,jet}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {jetPtAxis}}); |
| 78 | + registry.add("h_jet_eta_part", ";#eta_{jet}^{part};entries", {HistType::kTH1F, {etaAxis}}); |
| 79 | + registry.add("h_jet_phi_part", ";#varphi_{jet}^{part};entries", {HistType::kTH1F, {phiAxis}}); |
| 80 | + registry.add("h3_jet_pt_jet_eta_jet_phi_part", ";#it{p}_{T,jet}^{part};#eta_{jet}^{part};#varphi_{jet}^{part}", |
| 81 | + {HistType::kTH3F, {jetPtAxis, etaAxis, phiAxis}}); |
| 82 | + registry.add("h2_jet_pt_part_jet_area_part", ";#it{p}_{T,jet}^{part};jet area", |
| 83 | + {HistType::kTH2F, {jetPtAxis, {200, 0.0, 4.0}}}); |
| 84 | + registry.add("h2_jet_pt_part_jet_ntracks_part", ";#it{p}_{T,jet}^{part};#it{N}_{tracks}", |
| 85 | + {HistType::kTH2F, {jetPtAxis, {100, 0.0, 100.0}}}); |
| 86 | + registry.add("h2_jet_pt_part_track_pt_part", ";#it{p}_{T,jet}^{part};#it{p}_{T,track}^{part}", |
| 87 | + {HistType::kTH2F, {jetPtAxis, jetPtAxis}}); |
| 88 | + registry.add("h2_jet_pt_jet_angularity_part", ";#it{p}_{T,jet}^{part};angularity", |
| 89 | + {HistType::kTH2F, {jetPtAxis, {200, 0.0, 4.0}}}); |
| 90 | + |
| 91 | + registry.add("h_jet_pt_part_rhoareasubtracted", ";#it{p}_{T,jet}^{part,sub} (GeV/#it{c});entries", |
| 92 | + {HistType::kTH1F, {{static_cast<int>(2 * jetPtMax), -jetPtMax, jetPtMax}}}); |
| 93 | + registry.add("h_jet_eta_part_rhoareasubtracted", ";#eta_{jet}^{part};entries", {HistType::kTH1F, {etaAxis}}); |
| 94 | + registry.add("h_jet_phi_part_rhoareasubtracted", ";#varphi_{jet}^{part};entries", {HistType::kTH1F, {phiAxis}}); |
| 95 | + registry.add("h3_jet_pt_jet_eta_jet_phi_part_rhoareasubtracted", |
| 96 | + ";#it{p}_{T,jet}^{part,sub};#eta_{jet}^{part};#varphi_{jet}^{part}", |
| 97 | + {HistType::kTH3F, {{static_cast<int>(2 * jetPtMax), -jetPtMax, jetPtMax}, etaAxis, phiAxis}}); |
| 98 | + registry.add("h2_jet_pt_part_jet_area_part_rhoareasubtracted", ";#it{p}_{T,jet}^{part,sub};jet area", |
| 99 | + {HistType::kTH2F, {{static_cast<int>(2 * jetPtMax), -jetPtMax, jetPtMax}, {200, 0.0, 4.0}}}); |
| 100 | + registry.add("h2_jet_pt_part_jet_ntracks_part_rhoareasubtracted", ";#it{p}_{T,jet}^{part,sub};#it{N}_{tracks}", |
| 101 | + {HistType::kTH2F, {{static_cast<int>(2 * jetPtMax), -jetPtMax, jetPtMax}, {100, 0.0, 100.0}}}); |
| 102 | + } |
| 103 | + |
| 104 | + // Truth-only zvtx cut: returns true if accepted. |
| 105 | + template <typename TMcColl> |
| 106 | + bool passVertexZ(TMcColl const& mccollision) |
| 107 | + { |
| 108 | + if (vertexZCut <= 0.0f) { |
| 109 | + return true; |
| 110 | + } |
| 111 | + return std::abs(mccollision.posZ()) < vertexZCut; |
| 112 | + } |
| 113 | + |
| 114 | + template <typename TJet> |
| 115 | + bool isAcceptedJet(TJet const& jet) |
| 116 | + { |
| 117 | + if (jetAreaFractionMin > kConfigSwitchLow) { |
| 118 | + if (jet.area() < jetAreaFractionMin * o2::constants::math::PI * (jet.r() / 100.0) * (jet.r() / 100.0)) { |
| 119 | + return false; |
| 120 | + } |
| 121 | + } |
| 122 | + bool checkMin = (leadingConstituentPtMin > kConfigSwitchLow); |
| 123 | + bool checkMax = (leadingConstituentPtMax < kConfigSwitchHigh); |
| 124 | + if (!checkMin && !checkMax) { |
| 125 | + return true; |
| 126 | + } |
| 127 | + bool passMin = !checkMin; |
| 128 | + bool passMax = checkMax; |
| 129 | + for (const auto& constituent : jet.template tracks_as<aod::JetParticles>()) { |
| 130 | + double pt = constituent.pt(); |
| 131 | + if (checkMin && pt >= leadingConstituentPtMin) { |
| 132 | + passMin = true; |
| 133 | + } |
| 134 | + if (checkMax && pt > leadingConstituentPtMax) { |
| 135 | + passMax = false; |
| 136 | + } |
| 137 | + } |
| 138 | + return passMin && passMax; |
| 139 | + } |
| 140 | + |
| 141 | + template <typename TJet> |
| 142 | + void fillRawHistograms(TJet const& jet, float weight, float pTHat) |
| 143 | + { |
| 144 | + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { |
| 145 | + return; |
| 146 | + } |
| 147 | + if (jet.r() == std::round(selectedJetsRadius * 100.0f)) { |
| 148 | + registry.fill(HIST("h_jet_pt_part"), jet.pt(), weight); |
| 149 | + registry.fill(HIST("h_jet_eta_part"), jet.eta(), weight); |
| 150 | + registry.fill(HIST("h_jet_phi_part"), jet.phi(), weight); |
| 151 | + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi_part"), jet.pt(), jet.eta(), jet.phi(), weight); |
| 152 | + registry.fill(HIST("h2_jet_pt_part_jet_area_part"), jet.pt(), jet.area(), weight); |
| 153 | + registry.fill(HIST("h2_jet_pt_part_jet_ntracks_part"), jet.pt(), jet.tracksIds().size(), weight); |
| 154 | + } |
| 155 | + float angularity = 0.0f; |
| 156 | + for (const auto& constituent : jet.template tracks_as<aod::JetParticles>()) { |
| 157 | + registry.fill(HIST("h2_jet_pt_part_track_pt_part"), jet.pt(), constituent.pt(), weight); |
| 158 | + angularity += std::pow(constituent.pt(), kappa) * std::pow(jetutilities::deltaR(jet, constituent), alpha); |
| 159 | + } |
| 160 | + angularity /= (jet.pt() * (jet.r() / 100.0f)); |
| 161 | + registry.fill(HIST("h2_jet_pt_jet_angularity_part"), jet.pt(), angularity, weight); |
| 162 | + } |
| 163 | + |
| 164 | + template <typename TJet> |
| 165 | + void fillAreaSubHistograms(TJet const& jet, float rho, float weight, float pTHat) |
| 166 | + { |
| 167 | + if (jet.pt() > pTHatMaxMCP * pTHat || pTHat < pTHatAbsoluteMin) { |
| 168 | + return; |
| 169 | + } |
| 170 | + if (jet.r() != std::round(selectedJetsRadius * 100.0f)) { |
| 171 | + return; |
| 172 | + } |
| 173 | + double ptSub = jet.pt() - (rho * jet.area()); |
| 174 | + registry.fill(HIST("h_jet_pt_part_rhoareasubtracted"), ptSub, weight); |
| 175 | + registry.fill(HIST("h3_jet_pt_jet_eta_jet_phi_part_rhoareasubtracted"), ptSub, jet.eta(), jet.phi(), weight); |
| 176 | + if (ptSub > 0.0) { |
| 177 | + registry.fill(HIST("h_jet_eta_part_rhoareasubtracted"), jet.eta(), weight); |
| 178 | + registry.fill(HIST("h_jet_phi_part_rhoareasubtracted"), jet.phi(), weight); |
| 179 | + registry.fill(HIST("h2_jet_pt_part_jet_area_part_rhoareasubtracted"), ptSub, jet.area(), weight); |
| 180 | + registry.fill(HIST("h2_jet_pt_part_jet_ntracks_part_rhoareasubtracted"), ptSub, jet.tracksIds().size(), weight); |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + void processDummy(aod::JDummys const&) {} |
| 185 | + PROCESS_SWITCH(JetSpectraChargedGen, processDummy, "dummy process", true); |
| 186 | + |
| 187 | + void processChargedGen(aod::JetMcCollisions::iterator const& mccollision, |
| 188 | + soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents> const& jets, |
| 189 | + aod::JetParticles const&) |
| 190 | + { |
| 191 | + if (!passVertexZ(mccollision)) { |
| 192 | + return; |
| 193 | + } |
| 194 | + registry.fill(HIST("h_mccollisions"), 0.5); |
| 195 | + registry.fill(HIST("p_xSection"), 0.5, mccollision.xsectGen()); |
| 196 | + for (auto const& jet : jets) { |
| 197 | + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { |
| 198 | + continue; |
| 199 | + } |
| 200 | + if (!isAcceptedJet(jet)) { |
| 201 | + continue; |
| 202 | + } |
| 203 | + fillRawHistograms(jet, /*weight*/ 1.0f, /*pTHat*/ 999.0f); |
| 204 | + } |
| 205 | + } |
| 206 | + PROCESS_SWITCH(JetSpectraChargedGen, processChargedGen, |
| 207 | + "charged-jet spectra at MC particle level (generator-only AOD)", false); |
| 208 | + |
| 209 | + void processChargedGenWeighted(aod::JetMcCollisions::iterator const& mccollision, |
| 210 | + soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents> const& jets, |
| 211 | + aod::JetParticles const&) |
| 212 | + { |
| 213 | + if (!passVertexZ(mccollision)) { |
| 214 | + return; |
| 215 | + } |
| 216 | + float weight = mccollision.weight(); |
| 217 | + float pTHat = simPtRef / std::pow(weight, 1.0f / pTHatExponent); |
| 218 | + registry.fill(HIST("h_mccollisions"), 0.5, weight); |
| 219 | + registry.fill(HIST("p_xSection"), 0.5, mccollision.xsectGen(), weight); |
| 220 | + for (auto const& jet : jets) { |
| 221 | + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { |
| 222 | + continue; |
| 223 | + } |
| 224 | + if (!isAcceptedJet(jet)) { |
| 225 | + continue; |
| 226 | + } |
| 227 | + fillRawHistograms(jet, weight, pTHat); |
| 228 | + } |
| 229 | + } |
| 230 | + PROCESS_SWITCH(JetSpectraChargedGen, processChargedGenWeighted, |
| 231 | + "charged-jet spectra at MC particle level, weighted (generator-only AOD)", false); |
| 232 | + |
| 233 | + void processChargedAreaSubGen(JetBkgRhoMcCollisions::iterator const& mccollision, |
| 234 | + soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents> const& jets, |
| 235 | + aod::JetParticles const&) |
| 236 | + { |
| 237 | + if (!passVertexZ(mccollision)) { |
| 238 | + return; |
| 239 | + } |
| 240 | + registry.fill(HIST("h_mccollisions"), 0.5); |
| 241 | + registry.fill(HIST("p_xSection"), 0.5, mccollision.xsectGen()); |
| 242 | + registry.fill(HIST("h_mccollisions_rho"), mccollision.rho()); |
| 243 | + for (auto const& jet : jets) { |
| 244 | + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { |
| 245 | + continue; |
| 246 | + } |
| 247 | + if (!isAcceptedJet(jet)) { |
| 248 | + continue; |
| 249 | + } |
| 250 | + fillAreaSubHistograms(jet, mccollision.rho(), /*weight*/ 1.0f, /*pTHat*/ 999.0f); |
| 251 | + } |
| 252 | + } |
| 253 | + PROCESS_SWITCH(JetSpectraChargedGen, processChargedAreaSubGen, |
| 254 | + "charged-jet area-subtracted spectra at MC particle level (generator-only AOD)", false); |
| 255 | + |
| 256 | + void processChargedAreaSubGenWeighted(JetBkgRhoMcCollisions::iterator const& mccollision, |
| 257 | + soa::Join<aod::ChargedMCParticleLevelJets, aod::ChargedMCParticleLevelJetConstituents> const& jets, |
| 258 | + aod::JetParticles const&) |
| 259 | + { |
| 260 | + if (!passVertexZ(mccollision)) { |
| 261 | + return; |
| 262 | + } |
| 263 | + float weight = mccollision.weight(); |
| 264 | + float pTHat = simPtRef / std::pow(weight, 1.0f / pTHatExponent); |
| 265 | + registry.fill(HIST("h_mccollisions"), 0.5, weight); |
| 266 | + registry.fill(HIST("p_xSection"), 0.5, mccollision.xsectGen(), weight); |
| 267 | + registry.fill(HIST("h_mccollisions_rho"), mccollision.rho(), weight); |
| 268 | + for (auto const& jet : jets) { |
| 269 | + if (!jetfindingutilities::isInEtaAcceptance(jet, jetEtaMin, jetEtaMax, trackEtaMin, trackEtaMax)) { |
| 270 | + continue; |
| 271 | + } |
| 272 | + if (!isAcceptedJet(jet)) { |
| 273 | + continue; |
| 274 | + } |
| 275 | + fillAreaSubHistograms(jet, mccollision.rho(), weight, pTHat); |
| 276 | + } |
| 277 | + } |
| 278 | + PROCESS_SWITCH(JetSpectraChargedGen, processChargedAreaSubGenWeighted, |
| 279 | + "charged-jet area-subtracted spectra at MC particle level, weighted (generator-only AOD)", false); |
| 280 | +}; |
| 281 | + |
| 282 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 283 | +{ |
| 284 | + return WorkflowSpec{adaptAnalysisTask<JetSpectraChargedGen>(cfgc, TaskName{"jet-spectra-charged-gen"})}; |
| 285 | +} |
0 commit comments