ATLAS Offline Software
Loading...
Searching...
No Matches
JetIRCSafeLabelTool.cxx File Reference
#include "ParticleJetTools/JetIRCSafeLabelTool.h"
#include "ParticleJetTools/ParticleJetLabelCommon.h"
#include "xAODJet/Jet.h"
#include "xAODJet/JetContainer.h"
#include "xAODJet/JetAuxContainer.h"
#include "xAODTruth/TruthParticle.h"
#include "xAODTruth/TruthParticleContainer.h"
#include "xAODTruth/TruthParticleAuxContainer.h"
#include "AsgDataHandles/ReadHandle.h"
#include "AsgMessaging/Check.h"
#include "AsgTools/ToolHandle.h"
#include "fastjet/ClusterSequence.hh"
#include "fastjet/PseudoJet.hh"
#include "fastjet/JetDefinition.hh"
#include "fastjet/contrib/FlavInfo.hh"
#include "fastjet/contrib/IFNPlugin.hh"
#include "fastjet/contrib/CMPPlugin.hh"
#include "fastjet/contrib/GHSAlgo.hh"
#include "fastjet/contrib/SDFPlugin.hh"
#include <iostream>
#include <fstream>
#include <numbers>
#include <array>
#include <algorithm>
#include <cctype>
#include <unordered_set>
#include <cmath>

Go to the source code of this file.

Functions

static std::string toLower (const std::string &s)
template<size_t N>
constexpr std::array< int, N > negateID (const std::array< int, N > &in)
template<typename Container>
bool hit (const Container &ids, int pdgId)
template<typename PluginT, typename... Args>
std::unique_ptr< fastjet::JetDefinition > makeJetDefWithPlugin (Args &&... args)
static void extractTaggedJets (const std::vector< fastjet::PseudoJet > &pseudojets, std::vector< fastjet::PseudoJet > &btagged, std::vector< fastjet::PseudoJet > &ctagged)
FlavInfo HeavyFlavourContent (int pdgId)
void setJetIRCSafeLabels (const xAOD::Jet &jet, const ParticleJetTools::Tag_PseudoJets &tag_pjets, const ParticleJetTools::IRCSafeLabelDecorators &decs, bool doIFN, bool doCMP, bool doGHS, bool doSDF, bool doAKT)

Variables

static constexpr std::array< const char *, JetIRCSafeLabelTool::N_ALGOSALGO_NAMES

Function Documentation

◆ extractTaggedJets()

void extractTaggedJets ( const std::vector< fastjet::PseudoJet > & pseudojets,
std::vector< fastjet::PseudoJet > & btagged,
std::vector< fastjet::PseudoJet > & ctagged )
static

Definition at line 81 of file JetIRCSafeLabelTool.cxx.

83 {
84 for (const auto& p : pseudojets) {
85 if (p.user_info<fastjet::contrib::FlavHistory>().current_flavour()[5] != 0)
86 btagged.push_back(p);
87 if (p.user_info<fastjet::contrib::FlavHistory>().current_flavour()[4] != 0)
88 ctagged.push_back(p);
89 }
90}
@ btagged

◆ HeavyFlavourContent()

FlavInfo HeavyFlavourContent ( int pdgId)

Definition at line 92 of file JetIRCSafeLabelTool.cxx.

92 {
93 // Simply using the default FlavInfo-from-pdg_code constructor doesn't seem
94 // right as it gives way too many +c flavours. It might be because we remove the children
95 // and we might be left with quite exotic D hadrons with pdg codes of length larger than 4
96 // and that default constructor is unpredictable then.
97
98 // I'm tired of trying to be clever about this. The lists below should contain all
99 // hadrons containing a non-zero net b or c flavour, split into groups. The FlavInfo
100 // is then decided by checking whether the pdgId belongs to one of these groups.
101 // The codes are taken from https://pdg.lbl.gov/2007/reviews/montecarlorpp.pdf
102
103 static constexpr std::array<int, 33> one_b_Ids = {
104 // BOTTOM MESONS WITH NO C
105 -511, -521, -10511, -10521, -513, -523, -10513, -10523, -20513, -20523,
106 -515, -525, -531, -10531, -533, -10533, -20533,
107 -535,
108 // BOTTOM BARYONS WITH NO C
109 5122, 5112, 5212, 5222, 5114, 5214, 5224, 5132, 5232, 5312, 5322, 5314,
110 5324, 5332, 5334
111 };
112 static constexpr std::array<int,33> one_antib_Ids = negateID(one_b_Ids);
113 static constexpr std::array<int,6> one_b_one_antic_Ids = {
114 // BOTTOM MESONS WITH ONE B ONE ANTIC
115 -541, -10541, -543, -10543, -20543, -545
116 };
117 static constexpr std::array<int,6> one_antib_one_c_Ids = negateID(one_b_one_antic_Ids);
118 static constexpr std::array<int,9> one_b_one_c_Ids = {
119 // BOTTOM BARYONS WITH ONE B ONE C
120 5142, 5242, 5412, 5422, 5414, 5424, 5342, 5432, 5434
121 };
122 static constexpr std::array<int,9> one_antib_one_antic_Ids = negateID(one_b_one_c_Ids);
123 static constexpr std::array<int,2> one_b_two_cs_Ids = {
124 // BOTTOM BARYONS WITH ONE B TWO CS
125 5442, 5444
126 };
127 static constexpr std::array<int,2> one_antib_two_antics_Ids = negateID(one_b_two_cs_Ids);
128 static constexpr std::array<int,6> two_bs_Ids = {
129 // BOTTOM BARYONS WITH TWO BS AND NO C
130 5512, 5522, 5514, 5524, 5532, 5534
131 };
132 static constexpr std::array<int,6> two_antibs_Ids = negateID(two_bs_Ids);
133 static constexpr std::array<int,2> two_bs_one_c_Ids = {
134 // BOTTOM BARYONS WITH TWO BS AND ONE C
135 5542, 5544
136 };
137 static constexpr std::array<int,2> two_antibs_one_antic_Ids = negateID(two_bs_one_c_Ids);
138 static constexpr std::array<int,1> three_bs = {
139 // BOTTOM BARYON WITH THREE BS (OMEGA-)
140 5554
141 };
142 static constexpr std::array<int,1> three_antibs = negateID(three_bs);
143
144 static constexpr std::array<int,33> one_c_Ids = {
145 // CHARMED MESONS WITH NO B (all of them; if they have B they become bottom hadrons)
146 411, 421, 10411, 10421, 413, 423, 10413, 10423, 20413, 20423,
147 415, 425, 431, 10431, 433, 10433, 20433, 435,
148 // CHARMED BARYONS WITH ONE C AND NO B (all of them)
149 4122, 4222, 4212, 4112, 4224, 4214, 4114, 4232, 4132, 4322, 4312, 4324,
150 4314, 4332, 4334
151 };
152 static constexpr std::array<int,33> one_antic_Ids = negateID(one_c_Ids);
153 static constexpr std::array<int,6> two_c_Ids = {
154 // CHARMED BARYONS WITH TWO Cs
155 4412, 4422, 4414, 4424, 4432, 4434
156 };
157 static constexpr std::array<int,6> two_antic_Ids = negateID(two_c_Ids);
158 static constexpr std::array<int,1> three_c_Ids = {
159 4444
160 };
161 static constexpr std::array<int,1> three_antic_Ids = negateID(three_c_Ids);
162
163
164 int nb = 0, nc = 0;
165
166 // Check most specific categories first
167 if (hit(three_bs, pdgId)) { nb = 3; }
168 else if (hit(three_antibs, pdgId)) { nb = -3; }
169 else if (hit(two_bs_one_c_Ids, pdgId)) { nb = 2; nc = 1; }
170 else if (hit(two_antibs_one_antic_Ids, pdgId)) { nb = -2; nc = -1; }
171 else if (hit(two_bs_Ids, pdgId)) { nb = 2; }
172 else if (hit(two_antibs_Ids, pdgId)) { nb = -2; }
173 else if (hit(one_b_two_cs_Ids, pdgId)) { nb = 1; nc = 2; }
174 else if (hit(one_antib_two_antics_Ids, pdgId)) { nb = -1; nc = -2; }
175 else if (hit(one_b_one_c_Ids, pdgId)) { nb = 1; nc = 1; }
176 else if (hit(one_antib_one_antic_Ids, pdgId)) { nb = -1; nc = -1; }
177 else if (hit(one_b_one_antic_Ids, pdgId)) { nb = 1; nc = -1; }
178 else if (hit(one_antib_one_c_Ids, pdgId)) { nb = -1; nc = 1; }
179 // Then check more general categories
180 else if (hit(one_b_Ids, pdgId)) { nb = 1; }
181 else if (hit(one_antib_Ids, pdgId)) { nb = -1; }
182 else if (hit(three_c_Ids, pdgId)) { nc = 3; }
183 else if (hit(three_antic_Ids, pdgId)) { nc = -3; }
184 else if (hit(two_c_Ids, pdgId)) { nc = 2; }
185 else if (hit(two_antic_Ids, pdgId)) { nc = -2; }
186 else if (hit(one_c_Ids, pdgId)) { nc = 1; }
187 else if (hit(one_antic_Ids, pdgId)) { nc = -1; }
188
189 return FlavInfo(0,0,0,nc,nb,0,0);
190}
bool hit(const Container &ids, int pdgId)
constexpr std::array< int, N > negateID(const std::array< int, N > &in)

◆ hit()

template<typename Container>
bool hit ( const Container & ids,
int pdgId )
inline

Definition at line 64 of file JetIRCSafeLabelTool.cxx.

64 {
65 return std::ranges::any_of(ids, [pdgId](int id) {
66 return id == pdgId;
67 });
68}

◆ makeJetDefWithPlugin()

template<typename PluginT, typename... Args>
std::unique_ptr< fastjet::JetDefinition > makeJetDefWithPlugin ( Args &&... args)

Definition at line 72 of file JetIRCSafeLabelTool.cxx.

72 {
73 auto plugin = std::make_unique<PluginT>(std::forward<Args>(args)...);
74 auto jetDef = std::make_unique<fastjet::JetDefinition>(plugin.get());
75 jetDef->delete_plugin_when_unused();
76 plugin.release();
77 return jetDef;
78}

◆ negateID()

template<size_t N>
std::array< int, N > negateID ( const std::array< int, N > & in)
constexpr

Definition at line 54 of file JetIRCSafeLabelTool.cxx.

54 {
55 std::array<int, N> out{};
56 for (size_t i = 0; i < N; ++i) {
57 out[i] = -in[i];
58 }
59 return out;
60}
constexpr std::size_t N

◆ setJetIRCSafeLabels()

void setJetIRCSafeLabels ( const xAOD::Jet & jet,
const ParticleJetTools::Tag_PseudoJets & tag_pjets,
const ParticleJetTools::IRCSafeLabelDecorators & decs,
bool doIFN,
bool doCMP,
bool doGHS,
bool doSDF,
bool doAKT )

Definition at line 293 of file JetIRCSafeLabelTool.cxx.

296 {
297
298 int IFN_label = doIFN ? (tag_pjets.IFN_b.size() ? JetIRCSafeLabelTool::LABEL_B :
300 int CMP_label = doCMP ? (tag_pjets.CMP_b.size() ? JetIRCSafeLabelTool::LABEL_B :
302 int GHS_label = doGHS ? (tag_pjets.GHS_b.size() ? JetIRCSafeLabelTool::LABEL_B :
304 int SDF_label = doSDF ? (tag_pjets.SDF_b.size() ? JetIRCSafeLabelTool::LABEL_B :
306 int AKT_label = doAKT ? (tag_pjets.AKT_b.size() ? JetIRCSafeLabelTool::LABEL_B :
308
309 decs.IFNsingleint(jet) = IFN_label;
310 decs.CMPsingleint(jet) = CMP_label;
311 decs.GHSsingleint(jet) = GHS_label;
312 decs.SDFsingleint(jet) = SDF_label;
313 decs.AKTsingleint(jet) = AKT_label;
314}
static constexpr int LABEL_LIGHT
static constexpr int LABEL_B
static constexpr int LABEL_C
std::vector< const fastjet::PseudoJet * > CMP_b
std::vector< const fastjet::PseudoJet * > CMP_c
std::vector< const fastjet::PseudoJet * > AKT_b
std::vector< const fastjet::PseudoJet * > AKT_c
std::vector< const fastjet::PseudoJet * > IFN_b
std::vector< const fastjet::PseudoJet * > GHS_b
std::vector< const fastjet::PseudoJet * > SDF_c
std::vector< const fastjet::PseudoJet * > IFN_c
std::vector< const fastjet::PseudoJet * > SDF_b
std::vector< const fastjet::PseudoJet * > GHS_c

◆ toLower()

std::string toLower ( const std::string & s)
static

Definition at line 44 of file JetIRCSafeLabelTool.cxx.

44 {
45 std::string result;
46 result.reserve(s.size());
47 std::transform(s.begin(), s.end(), std::back_inserter(result),
48 [](unsigned char c){ return std::tolower(c); });
49 return result;
50}

Variable Documentation

◆ ALGO_NAMES

std::array<const char*, JetIRCSafeLabelTool::N_ALGOS> ALGO_NAMES
staticconstexpr
Initial value:
= {
"IFN", "CMP", "GHS", "SDF", "AKT"
}

Definition at line 39 of file JetIRCSafeLabelTool.cxx.

39 {
40 "IFN", "CMP", "GHS", "SDF", "AKT"
41};