|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \author Nicolo' Jacazio <nicolo.jacazio@cern.ch>, CERN |
| 12 | +/// \brief Task to extract LUTs for the fast simulation from full simulation |
| 13 | +/// \since 27/04/2021 |
| 14 | + |
| 15 | +// O2 includes |
| 16 | +#include "Framework/AnalysisTask.h" |
| 17 | +#include "AnalysisCore/MC.h" |
| 18 | +#include "ReconstructionDataFormats/Track.h" |
| 19 | + |
| 20 | +using namespace o2; |
| 21 | +using namespace framework; |
| 22 | +using namespace framework::expressions; |
| 23 | + |
| 24 | +void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions) |
| 25 | +{ |
| 26 | + std::vector<ConfigParamSpec> options{ |
| 27 | + {"lul-el", VariantType::Int, 1, {"LUT input for the Electron PDG code"}}, |
| 28 | + {"lut-mu", VariantType::Int, 1, {"LUT input for the Muon PDG code"}}, |
| 29 | + {"lut-pi", VariantType::Int, 1, {"LUT input for the Pion PDG code"}}, |
| 30 | + {"lut-ka", VariantType::Int, 1, {"LUT input for the Kaon PDG code"}}, |
| 31 | + {"lut-pr", VariantType::Int, 1, {"LUT input for the Proton PDG code"}}}; |
| 32 | + std::swap(workflowOptions, options); |
| 33 | +} |
| 34 | + |
| 35 | +#include "Framework/runDataProcessing.h" |
| 36 | + |
| 37 | +template <o2::track::pid_constants::ID particle> |
| 38 | +struct Alice3LutMaker { |
| 39 | + static constexpr PDG_t PDGs[5] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton}; |
| 40 | + static_assert(particle < 5 && "Maximum of particles reached"); |
| 41 | + static constexpr int pdg = PDGs[particle]; |
| 42 | + // Configurable<int> pdg{"pdg", 2212, "PDG code of the particle of interest"}; |
| 43 | + Configurable<bool> selPrim{"sel-prim", false, "If true selects primaries, if not select all particles"}; |
| 44 | + Configurable<float> etaMin{"eta-min", -3.f, "Lower limit in eta"}; |
| 45 | + Configurable<float> etaMax{"eta-max", 3.f, "Upper limit in eta"}; |
| 46 | + Configurable<float> ptMin{"pt-min", 0.f, "Lower limit in pT"}; |
| 47 | + Configurable<float> ptMax{"pt-max", 100.f, "Upper limit in pT"}; |
| 48 | + Configurable<int> ptBins{"pt-bins", 1000, "Number of pT bins"}; |
| 49 | + Configurable<int> logPt{"log-pt", 0, "Flag to use a logarithmic pT axis"}; |
| 50 | + Configurable<int> etaBins{"eta-bins", 500, "Number of eta bins"}; |
| 51 | + HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 52 | + |
| 53 | + void init(InitContext&) |
| 54 | + { |
| 55 | + const TString commonTitle = Form(" PDG %i;#it{p}_{T};#eta", pdg); |
| 56 | + AxisSpec axisPt{ptBins, ptMin, ptMax}; |
| 57 | + AxisSpec axisEta{etaBins, etaMin, etaMax}; |
| 58 | + |
| 59 | + histos.add("pt", Form("pt PDG %i;#it{p}_{T}", pdg), kTH1F, {axisPt}); |
| 60 | + histos.add("eta", Form("eta PDG %i;#eta", pdg), kTH1F, {axisEta}); |
| 61 | + histos.add("CovMat_cYY", "cYY" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 62 | + histos.add("CovMat_cZY", "cZY" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 63 | + histos.add("CovMat_cZZ", "cZZ" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 64 | + histos.add("CovMat_cSnpY", "cSnpY" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 65 | + histos.add("CovMat_cSnpZ", "cSnpZ" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 66 | + histos.add("CovMat_cSnpSnp", "cSnpSnp" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 67 | + histos.add("CovMat_cTglY", "cTglY" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 68 | + histos.add("CovMat_cTglZ", "cTglZ" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 69 | + histos.add("CovMat_cTglSnp", "cTglSnp" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 70 | + histos.add("CovMat_cTglTgl", "cTglTgl" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 71 | + histos.add("CovMat_c1PtY", "c1PtY" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 72 | + histos.add("CovMat_c1PtZ", "c1PtZ" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 73 | + histos.add("CovMat_c1PtSnp", "c1PtSnp" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 74 | + histos.add("CovMat_c1PtTgl", "c1PtTgl" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 75 | + histos.add("CovMat_c1Pt21Pt2", "c1Pt21Pt2" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 76 | + |
| 77 | + histos.add("Efficiency", "Efficiency" + commonTitle, kTProfile2D, {axisPt, axisEta}); |
| 78 | + } |
| 79 | + |
| 80 | + void process(const soa::Join<aod::Tracks, aod::TracksCov, aod::McTrackLabels>& tracks, |
| 81 | + const aod::McParticles& mcParticles) |
| 82 | + { |
| 83 | + std::vector<int64_t> recoTracks(tracks.size()); |
| 84 | + int ntrks = 0; |
| 85 | + |
| 86 | + for (const auto& track : tracks) { |
| 87 | + const auto mcParticle = track.mcParticle(); |
| 88 | + if (mcParticle.pdgCode() != pdg) { |
| 89 | + continue; |
| 90 | + } |
| 91 | + if (selPrim.value && !MC::isPhysicalPrimary(mcParticles, mcParticle)) { // Requiring is physical primary |
| 92 | + continue; |
| 93 | + } |
| 94 | + |
| 95 | + recoTracks[ntrks++] = mcParticle.globalIndex(); |
| 96 | + |
| 97 | + histos.fill(HIST("pt"), mcParticle.pt()); |
| 98 | + histos.fill(HIST("eta"), mcParticle.eta()); |
| 99 | + histos.fill(HIST("CovMat_cYY"), mcParticle.pt(), mcParticle.eta(), track.cYY()); |
| 100 | + histos.fill(HIST("CovMat_cZY"), mcParticle.pt(), mcParticle.eta(), track.cZY()); |
| 101 | + histos.fill(HIST("CovMat_cZZ"), mcParticle.pt(), mcParticle.eta(), track.cZZ()); |
| 102 | + histos.fill(HIST("CovMat_cSnpY"), mcParticle.pt(), mcParticle.eta(), track.cSnpY()); |
| 103 | + histos.fill(HIST("CovMat_cSnpZ"), mcParticle.pt(), mcParticle.eta(), track.cSnpZ()); |
| 104 | + histos.fill(HIST("CovMat_cSnpSnp"), mcParticle.pt(), mcParticle.eta(), track.cSnpSnp()); |
| 105 | + histos.fill(HIST("CovMat_cTglY"), mcParticle.pt(), mcParticle.eta(), track.cTglY()); |
| 106 | + histos.fill(HIST("CovMat_cTglZ"), mcParticle.pt(), mcParticle.eta(), track.cTglZ()); |
| 107 | + histos.fill(HIST("CovMat_cTglSnp"), mcParticle.pt(), mcParticle.eta(), track.cTglSnp()); |
| 108 | + histos.fill(HIST("CovMat_cTglTgl"), mcParticle.pt(), mcParticle.eta(), track.cTglTgl()); |
| 109 | + histos.fill(HIST("CovMat_c1PtY"), mcParticle.pt(), mcParticle.eta(), track.c1PtY()); |
| 110 | + histos.fill(HIST("CovMat_c1PtZ"), mcParticle.pt(), mcParticle.eta(), track.c1PtZ()); |
| 111 | + histos.fill(HIST("CovMat_c1PtSnp"), mcParticle.pt(), mcParticle.eta(), track.c1PtSnp()); |
| 112 | + histos.fill(HIST("CovMat_c1PtTgl"), mcParticle.pt(), mcParticle.eta(), track.c1PtTgl()); |
| 113 | + histos.fill(HIST("CovMat_c1Pt21Pt2"), mcParticle.pt(), mcParticle.eta(), track.c1Pt21Pt2()); |
| 114 | + } |
| 115 | + |
| 116 | + for (const auto& mcParticle : mcParticles) { |
| 117 | + if (mcParticle.pdgCode() != pdg) { |
| 118 | + continue; |
| 119 | + } |
| 120 | + if (!MC::isPhysicalPrimary(mcParticles, mcParticle)) { // Requiring is physical primary |
| 121 | + continue; |
| 122 | + } |
| 123 | + |
| 124 | + if (std::find(recoTracks.begin(), recoTracks.end(), mcParticle.globalIndex()) != recoTracks.end()) { |
| 125 | + histos.fill(HIST("Efficiency"), mcParticle.pt(), mcParticle.eta(), 1.); |
| 126 | + } else { |
| 127 | + histos.fill(HIST("Efficiency"), mcParticle.pt(), mcParticle.eta(), 0.); |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | +}; |
| 132 | + |
| 133 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 134 | +{ |
| 135 | + WorkflowSpec w; |
| 136 | + if (cfgc.options().get<int>("lul-el")) { |
| 137 | + w.push_back(adaptAnalysisTask<Alice3LutMaker<o2::track::PID::Electron>>(cfgc, TaskName{"alice3-lutmaker-electron"})); |
| 138 | + } |
| 139 | + if (cfgc.options().get<int>("lut-mu")) { |
| 140 | + w.push_back(adaptAnalysisTask<Alice3LutMaker<o2::track::PID::Muon>>(cfgc, TaskName{"alice3-lutmaker-muon"})); |
| 141 | + } |
| 142 | + if (cfgc.options().get<int>("lut-pi")) { |
| 143 | + w.push_back(adaptAnalysisTask<Alice3LutMaker<o2::track::PID::Pion>>(cfgc, TaskName{"alice3-lutmaker-pion"})); |
| 144 | + } |
| 145 | + if (cfgc.options().get<int>("lut-ka")) { |
| 146 | + w.push_back(adaptAnalysisTask<Alice3LutMaker<o2::track::PID::Kaon>>(cfgc, TaskName{"alice3-lutmaker-kaon"})); |
| 147 | + } |
| 148 | + if (cfgc.options().get<int>("lut-pr")) { |
| 149 | + w.push_back(adaptAnalysisTask<Alice3LutMaker<o2::track::PID::Proton>>(cfgc, TaskName{"alice3-lutmaker-proton"})); |
| 150 | + } |
| 151 | + return w; |
| 152 | +} |
0 commit comments