ATLAS Offline Software
Loading...
Searching...
No Matches
BTaggingSelectionJsonTool Class Reference

#include <BTaggingSelectionJsonTool.h>

Inheritance diagram for BTaggingSelectionJsonTool:
Collaboration diagram for BTaggingSelectionJsonTool:

Classes

struct  BinConfig
struct  FractionAccessor

Public Member Functions

 BTaggingSelectionJsonTool (const std::string &name)
StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual int accept (const xAOD::Jet &jet) const override
virtual int acceptOnlyForXbbCalibrationUsage (double pt, double eta, double mass, double tagger_discriminant) const override
virtual double getTaggerDiscriminant (const xAOD::Jet &jet) const override
virtual double getVetoDiscriminant (const xAOD::Jet &jet) const
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode loadBinConfig (const json &pT_mass_2d_cutvalue, BinConfig &config) const
std::vector< FractionAccessorloadFractionValues (const json &meta) const
double getTaggerDiscriminantInternal (const xAOD::Jet &jet, const std::vector< FractionAccessor > &fractionAccessors) const
int findBin (const std::vector< float > &bins, float value) const
float getJetMass (const xAOD::Jet &jet) const
float getJetPt (const xAOD::Jet &jet) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

bool m_initialised = false
Gaudi::Property< float > m_minPt {this, "MinPt", -1 , "Minimum jet pT cut (in MeV)"}
Gaudi::Property< float > m_maxEta {this, "MaxEta", 2.5, "Maximum jet eta cut"}
Gaudi::Property< std::string > m_outputName {this, "OutputName", "", "output name of the tagger"}
Gaudi::Property< std::string > m_jetAuthor {this, "JetAuthor", "", "jet collection"}
Gaudi::Property< std::string > m_OP {this, "OperatingPoint", "", "operating point"}
Gaudi::Property< std::string > m_json_config_path {this, "JsonConfigFile", "", "Path to JSON config file"}
Gaudi::Property< bool > m_allowBinCountMismatch
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_massAcc
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_ptAcc
json m_json_config
BinConfig m_BinConfig
BinConfig m_VetoBinConfig
std::vector< FractionAccessorm_fractionAccessors
std::vector< FractionAccessorm_vetoFractionAccessors
bool m_veto = false
std::string m_vetoTagger
std::string m_vetoOP
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 14 of file BTaggingSelectionJsonTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ BTaggingSelectionJsonTool()

BTaggingSelectionJsonTool::BTaggingSelectionJsonTool ( const std::string & name)

Definition at line 14 of file BTaggingSelectionJsonTool.cxx.

15 : asg::AsgTool(name)
16{
17 m_initialised = false;
18}

Member Function Documentation

◆ accept()

int BTaggingSelectionJsonTool::accept ( const xAOD::Jet & jet) const
overridevirtual

Implements IBTaggingSelectionJsonTool.

Definition at line 231 of file BTaggingSelectionJsonTool.cxx.

232{
233 if (!m_initialised) throw std::runtime_error("BTaggingSelectionJsonTool has not been initialised.");
234
235 double pt = getJetPt(jet);
236 double eta = jet.eta();
237 double mass = getJetMass(jet);
238 double tagger_discriminant = getTaggerDiscriminant(jet);
239 int index = 0;
240
241 if (std::abs(eta) > m_maxEta || pt < m_minPt) return index;
242
243 int pt_bin_index = findBin(m_BinConfig.pTbins, pt / 1000.);
244 if (pt_bin_index == -1) return index;
245
246 int mass_bin_index = findBin(m_BinConfig.massbins[pt_bin_index], mass / 1000.);
247 if (mass_bin_index == -1) return index;
248
249 float cutvalue = m_BinConfig.OPCutValues[pt_bin_index][mass_bin_index];
250
251 // Check if 1D or 2D boosted flavour tagging is needed
252 if (!m_veto) {
253 index = (tagger_discriminant > cutvalue) ? 1 : 0;
254 } else {
255 // If jet fails tagging requirement
256 // there is no need to check against veto requirement
257 if (tagger_discriminant <= cutvalue) {
258 return index;
259 }
260
261 // Check if the jet does not pass the veto requirement
262 double veto_discriminant = getVetoDiscriminant(jet);
263
264 int pt_veto_bin_index = findBin(m_VetoBinConfig.pTbins, pt / 1000.);
265 if (pt_veto_bin_index == -1) return index;
266
267 int mass_veto_bin_index = findBin(m_VetoBinConfig.massbins[pt_veto_bin_index], mass / 1000.);
268 if (mass_veto_bin_index == -1) return index;
269
270 float veto_cutvalue = m_VetoBinConfig.OPCutValues[pt_veto_bin_index][mass_veto_bin_index];
271
272 index = (veto_discriminant < veto_cutvalue) ? 1 : 0;
273 }
274
275 return index;
276}
Scalar eta() const
pseudorapidity method
Gaudi::Property< float > m_maxEta
float getJetMass(const xAOD::Jet &jet) const
virtual double getTaggerDiscriminant(const xAOD::Jet &jet) const override
Gaudi::Property< float > m_minPt
int findBin(const std::vector< float > &bins, float value) const
float getJetPt(const xAOD::Jet &jet) const
virtual double getVetoDiscriminant(const xAOD::Jet &jet) const
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49
str index
Definition DeMoScan.py:362

◆ acceptOnlyForXbbCalibrationUsage()

int BTaggingSelectionJsonTool::acceptOnlyForXbbCalibrationUsage ( double pt,
double eta,
double mass,
double tagger_discriminant ) const
overridevirtual

Implements IBTaggingSelectionJsonTool.

Definition at line 279 of file BTaggingSelectionJsonTool.cxx.

280{
281 if (!m_initialised) throw std::runtime_error("BTaggingSelectionJsonTool has not been initialised.");
282
283 int index = 0;
284 if (std::abs(eta) > m_maxEta || pt < m_minPt) return index;
285
286 int pt_bin_index = findBin(m_BinConfig.pTbins, pt / 1000.);
287 if (pt_bin_index == -1) return index;
288
289 int mass_bin_index = findBin(m_BinConfig.massbins[pt_bin_index], mass / 1000.);
290 if (mass_bin_index == -1) return index;
291
292 float cutvalue = m_BinConfig.OPCutValues[pt_bin_index][mass_bin_index];
293 index = (tagger_discriminant > cutvalue) ? 1 : 0;
294
295 return index;
296}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ findBin()

int BTaggingSelectionJsonTool::findBin ( const std::vector< float > & bins,
float value ) const
private

Definition at line 298 of file BTaggingSelectionJsonTool.cxx.

299{
300 for (size_t i = 0; i < bins.size() - 1; i++) {
301 if ((std::min(bins[i], bins[i + 1]) <= value && value < std::max(bins[i], bins[i + 1]))) {
302 return i;
303 }
304 }
305 return -1;
306}
static const std::vector< std::string > bins

◆ getJetMass()

float BTaggingSelectionJsonTool::getJetMass ( const xAOD::Jet & jet) const
private

Definition at line 308 of file BTaggingSelectionJsonTool.cxx.

309{
310 if (!m_massAcc) return jet.m();
311 if (!m_massAcc->isAvailable(jet)) {
312 ATH_MSG_ERROR("Decorated mass '" << SG::AuxTypeRegistry::instance().getName( m_massAcc->auxid() ) << "' not available on jet. Cannot proceed.");
313 throw std::runtime_error("Decorated mass not available on jet.");
314 }
315 return (*m_massAcc)(jet);
316}
#define ATH_MSG_ERROR(x)
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_massAcc
static AuxTypeRegistry & instance()
Return the singleton registry instance.
const std::string & getName(const void *ptr) const
Get the name of an object that is / should be in the event store.
Definition AsgTool.cxx:106
virtual double m() const
The invariant mass of the particle.
Definition Jet_v1.cxx:59

◆ getJetPt()

float BTaggingSelectionJsonTool::getJetPt ( const xAOD::Jet & jet) const
private

Definition at line 318 of file BTaggingSelectionJsonTool.cxx.

319{
320 if (!m_ptAcc) return jet.pt();
321 if (!m_ptAcc->isAvailable(jet)) {
322 ATH_MSG_ERROR("Decorated pT '" << SG::AuxTypeRegistry::instance().getName( m_ptAcc->auxid() ) << "' not available on jet. Cannot proceed.");
323 throw std::runtime_error("Decorated pT not available on jet.");
324 }
325 return (*m_ptAcc)(jet);
326}
std::unique_ptr< SG::AuxElement::ConstAccessor< float > > m_ptAcc
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getTaggerDiscriminant()

double BTaggingSelectionJsonTool::getTaggerDiscriminant ( const xAOD::Jet & jet) const
overridevirtual

Implements IBTaggingSelectionJsonTool.

Definition at line 221 of file BTaggingSelectionJsonTool.cxx.

222{
224}
std::vector< FractionAccessor > m_fractionAccessors
double getTaggerDiscriminantInternal(const xAOD::Jet &jet, const std::vector< FractionAccessor > &fractionAccessors) const

◆ getTaggerDiscriminantInternal()

double BTaggingSelectionJsonTool::getTaggerDiscriminantInternal ( const xAOD::Jet & jet,
const std::vector< FractionAccessor > & fractionAccessors ) const
private

Definition at line 198 of file BTaggingSelectionJsonTool.cxx.

199{
200 float numerator = 0.;
201 float denominator = 0.;
202
203 for (const auto& frac : fractionAccessors) {
204 float p_output = frac.accessor(jet);
205 if (frac.isTarget) {
206 numerator += frac.fraction * p_output;
207 } else {
208 denominator += frac.fraction * p_output;
209 }
210 }
211
212 // Smallest positive normal float; below this, reciprocals may overflow.
213 const float ep = std::numeric_limits<float>::min();
214 //coverity[DIVIDE_BY_ZERO]
215 const float ratio = (std::abs(denominator) < ep ? std::numeric_limits<float>::infinity() : numerator / denominator);
216 const double tagger_discriminant = (std::abs(ratio) < ep ? -std::numeric_limits<double>::infinity() : std::log( ratio ));
217
218 return tagger_discriminant;
219}

◆ getVetoDiscriminant()

double BTaggingSelectionJsonTool::getVetoDiscriminant ( const xAOD::Jet & jet) const
virtual

Definition at line 226 of file BTaggingSelectionJsonTool.cxx.

227{
229}
std::vector< FractionAccessor > m_vetoFractionAccessors

◆ initialize()

StatusCode BTaggingSelectionJsonTool::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 20 of file BTaggingSelectionJsonTool.cxx.

20 {
21 m_initialised = true;
22
23 std::string pathToJsonConfigFile = PathResolverFindCalibFile(m_json_config_path);
24 std::ifstream jsonFile(pathToJsonConfigFile);
25 if (!jsonFile.is_open()) {
26 ATH_MSG_ERROR("JSON file " + m_json_config_path + " does not exist. Please put the correct path of the file.");
27 return StatusCode::FAILURE;
28 }
29
30 m_json_config = json::parse(jsonFile);
31 jsonFile.close();
32
33 if (m_outputName.empty()) {
34 ATH_MSG_ERROR("Must specify the output name property for the tagger");
35 return StatusCode::FAILURE;
36 }
37
38 if (!m_json_config.contains(m_outputName)) {
39 ATH_MSG_ERROR("The output name " + m_outputName + " not found in JSON file: " + m_json_config_path);
40 return StatusCode::FAILURE;
41 }
42
43 if (m_jetAuthor.empty() || !m_json_config[m_outputName].contains(m_jetAuthor)) {
44 ATH_MSG_ERROR("Tagger: " + m_outputName + " and Jet Collection: " + m_jetAuthor +
45 " not found in JSON file: " + m_json_config_path);
46 return StatusCode::FAILURE;
47 }
48
49 if (m_OP.empty() || !m_json_config[m_outputName][m_jetAuthor].contains(m_OP)) {
50 ATH_MSG_ERROR("OP " + m_OP + " not available for " + m_outputName + " tagger.");
51 return StatusCode::FAILURE;
52 }
53
54 const json& meta = m_json_config[m_outputName][m_jetAuthor]["meta"];
56
57 // Pre-load cut values
58 json& pT_mass_2d_tagger_cutvalue = m_json_config[m_outputName][m_jetAuthor][m_OP]["pT_mass_2d_cutvalue"];
59 ATH_CHECK(loadBinConfig(pT_mass_2d_tagger_cutvalue, m_BinConfig));
60
61 // Get mass decorator if specified
62 if (meta.contains("Mass")) {
63 std::string massDecoratorName = meta["Mass"].get<std::string>();
64 if (massDecoratorName != "default") {
65 m_massAcc = std::make_unique<SG::AuxElement::ConstAccessor<float>>(massDecoratorName);
66 ATH_MSG_INFO("Using decorated mass '" << massDecoratorName << "' for Xbb FM WP.");
67 }
68 }
69
70 // Get pT decorator if specified
71 if (meta.contains("PT")) {
72 std::string ptDecoratorName = meta["PT"].get<std::string>();
73 if (ptDecoratorName != "default") {
74 m_ptAcc = std::make_unique<SG::AuxElement::ConstAccessor<float>>(ptDecoratorName);
75 ATH_MSG_INFO("Using decorated pT '" << ptDecoratorName << "' for Xbb FM WP.");
76 }
77 }
78
79 // Veto setup
80 m_veto = meta.contains("Veto");
81 if (m_veto) {
82 if (!meta["Veto"].contains("VetoTagger")) {
83 ATH_MSG_ERROR("Specific veto tagger not found in JSON file: " + m_json_config_path);
84 return StatusCode::FAILURE;
85 }
86 m_vetoTagger = meta["Veto"]["VetoTagger"];
87 if (!meta["Veto"].contains("OperatingPoint")) {
88 ATH_MSG_ERROR("Specific operating point not found in JSON file: " + m_json_config_path);
89 return StatusCode::FAILURE;
90 }
91 m_vetoOP = meta["Veto"]["OperatingPoint"];
92
93 if (!m_json_config.contains(m_vetoTagger) ||
96 ATH_MSG_ERROR("Veto tagger configuration missing in JSON: " + m_json_config_path);
97 return StatusCode::FAILURE;
98 }
99
100 const json& veto_meta = m_json_config[m_vetoTagger][m_jetAuthor]["meta"];
102
103 json& pT_mass_2d_veto_cutvalue = m_json_config[m_vetoTagger][m_jetAuthor][m_vetoOP]["pT_mass_2d_cutvalue"];
104 ATH_CHECK(loadBinConfig(pT_mass_2d_veto_cutvalue, m_VetoBinConfig));
105 }
106
107 return StatusCode::SUCCESS;
108}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
nlohmann::json json
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
std::vector< FractionAccessor > loadFractionValues(const json &meta) const
Gaudi::Property< std::string > m_json_config_path
StatusCode loadBinConfig(const json &pT_mass_2d_cutvalue, BinConfig &config) const
Gaudi::Property< std::string > m_jetAuthor
Gaudi::Property< std::string > m_outputName
Gaudi::Property< std::string > m_OP
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ loadBinConfig()

StatusCode BTaggingSelectionJsonTool::loadBinConfig ( const json & pT_mass_2d_cutvalue,
BinConfig & config ) const
private

Definition at line 110 of file BTaggingSelectionJsonTool.cxx.

111{
112 // pTbins defines the bin edges, so there must be exactly one fewer pT bin (WP entry) than
113 // there are edges. The pT_mass_2d_cutvalue dict holds the "pTbins" edge list plus one entry
114 // per pT bin, so its total size must equal the number of pT bin edges.
115 if (pT_mass_2d_cutvalue["pTbins"].size() != pT_mass_2d_cutvalue.size()) {
116 const std::string binCountMsg = "We expect N bin edges for N-1 bins, but there are " +
117 std::to_string(pT_mass_2d_cutvalue["pTbins"].size()) + " pT bin edges but " +
118 std::to_string(pT_mass_2d_cutvalue.size() - 1) +
119 " entries in the pT_mass_2d_cutvalue dict. Please check the JSON file: " + m_json_config_path;
121 ATH_MSG_WARNING(binCountMsg + " Continuing because AllowBinCountMismatch is set.");
122 } else {
123 ATH_MSG_ERROR(binCountMsg);
124 return StatusCode::FAILURE;
125 }
126 }
127
128 for (unsigned int ipT = 0; ipT < pT_mass_2d_cutvalue["pTbins"].size(); ++ipT) {
129 const json& pt = pT_mass_2d_cutvalue["pTbins"][ipT];
130 config.pTbins.push_back(BTaggingToolUtil::getExtendedFloat(pt));
131
132 if (ipT != pT_mass_2d_cutvalue["pTbins"].size() - 1) {
133 const json& ptUp = pT_mass_2d_cutvalue["pTbins"][ipT + 1];
134 std::string pT_key = "pT_" + BTaggingToolUtil::getExtendedString(pt) +
136
137 auto itr = pT_mass_2d_cutvalue.find(pT_key);
138 if (itr == pT_mass_2d_cutvalue.end()) {
139 ATH_MSG_ERROR("pT_key=" + pT_key + " not found in JSON file: " + m_json_config_path);
140 return StatusCode::FAILURE;
141 }
142
143 std::vector<float> mass_values;
144 for (const auto& m : itr->at("mass")) {
145 mass_values.push_back(BTaggingToolUtil::getExtendedFloat(m));
146 }
147 std::vector<float> cut_values = itr->at("cutvalues").get<std::vector<float>>();
148
149 config.massbins.push_back(std::move(mass_values));
150 config.OPCutValues.push_back(std::move(cut_values));
151
152 // We expect N mass bins (edges) and N-1 cut values for each pT bin. Accessing the
153 // cut value for a jet in the final mass bin would otherwise read outside the vector.
154 if (config.massbins.back().size() != config.OPCutValues.back().size() + 1) {
155 const std::string binCountMsg = "Expected to have N mass bins and N-1 cut values for pT bin " +
156 pT_key + " Instead found " + std::to_string(config.massbins.back().size()) +
157 " mass bins and " + std::to_string(config.OPCutValues.back().size()) + " cut values.";
159 ATH_MSG_WARNING(binCountMsg + " Continuing because AllowBinCountMismatch is set.");
160 } else {
161 ATH_MSG_ERROR(binCountMsg);
162 return StatusCode::FAILURE;
163 }
164 }
165 }
166 }
167
168 return StatusCode::SUCCESS;
169}
#define ATH_MSG_WARNING(x)
size_t size() const
Number of registered mappings.
Gaudi::Property< bool > m_allowBinCountMismatch
static float getExtendedFloat(const nlohmann::json &pt)
static std::string getExtendedString(const nlohmann::json &pt)

◆ loadFractionValues()

std::vector< BTaggingSelectionJsonTool::FractionAccessor > BTaggingSelectionJsonTool::loadFractionValues ( const json & meta) const
private

Definition at line 172 of file BTaggingSelectionJsonTool.cxx.

173{
174 std::string taggerName;
175 if (meta.contains("TaggerName")) {
176 taggerName = meta["TaggerName"];
177 } else {
178 ATH_MSG_INFO("No 'TaggerName' section found in the meta data for " + m_outputName +
179 " tagger. Using " + m_outputName + " as the tagger name.");
180 taggerName = m_outputName;
181 }
182
183 std::string target = meta["TaggingTarget"];
184 std::vector<BTaggingSelectionJsonTool::FractionAccessor> fractionAccessors;
185
186 // Pre-load fraction values
187 for (const json& outclass : meta["categories"]) {
188 std::string outclassStr = std::string(outclass);
189 float fraction = meta["fraction_" + outclassStr].get<float>();
190 SG::AuxElement::ConstAccessor<float> accessor(taggerName + "_p" + outclassStr);
191 bool isTarget = (outclassStr == target);
192 fractionAccessors.emplace_back(fraction, accessor, isTarget);
193 }
194
195 return fractionAccessors;
196}
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_allowBinCountMismatch

Gaudi::Property<bool> BTaggingSelectionJsonTool::m_allowBinCountMismatch
private
Initial value:
{this, "AllowBinCountMismatch", false,
"If true, downgrade inconsistent pT/mass bin counts in loadBinConfig() from an ERROR "
"(initialisation failure) to a WARNING and continue. Default false (fail on inconsistency)."}

Definition at line 40 of file BTaggingSelectionJsonTool.h.

40 {this, "AllowBinCountMismatch", false,
41 "If true, downgrade inconsistent pT/mass bin counts in loadBinConfig() from an ERROR "
42 "(initialisation failure) to a WARNING and continue. Default false (fail on inconsistency)."};

◆ m_BinConfig

BinConfig BTaggingSelectionJsonTool::m_BinConfig
private

Definition at line 64 of file BTaggingSelectionJsonTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_fractionAccessors

std::vector<FractionAccessor> BTaggingSelectionJsonTool::m_fractionAccessors
private

Definition at line 67 of file BTaggingSelectionJsonTool.h.

◆ m_initialised

bool BTaggingSelectionJsonTool::m_initialised = false
private

Definition at line 31 of file BTaggingSelectionJsonTool.h.

◆ m_jetAuthor

Gaudi::Property<std::string> BTaggingSelectionJsonTool::m_jetAuthor {this, "JetAuthor", "", "jet collection"}
private

Definition at line 37 of file BTaggingSelectionJsonTool.h.

37{this, "JetAuthor", "", "jet collection"};

◆ m_json_config

json BTaggingSelectionJsonTool::m_json_config
private

Definition at line 47 of file BTaggingSelectionJsonTool.h.

◆ m_json_config_path

Gaudi::Property<std::string> BTaggingSelectionJsonTool::m_json_config_path {this, "JsonConfigFile", "", "Path to JSON config file"}
private

Definition at line 39 of file BTaggingSelectionJsonTool.h.

39{this, "JsonConfigFile", "", "Path to JSON config file"};

◆ m_massAcc

std::unique_ptr<SG::AuxElement::ConstAccessor<float> > BTaggingSelectionJsonTool::m_massAcc
private

Definition at line 44 of file BTaggingSelectionJsonTool.h.

◆ m_maxEta

Gaudi::Property<float> BTaggingSelectionJsonTool::m_maxEta {this, "MaxEta", 2.5, "Maximum jet eta cut"}
private

Definition at line 33 of file BTaggingSelectionJsonTool.h.

33{this, "MaxEta", 2.5, "Maximum jet eta cut"};

◆ m_minPt

Gaudi::Property<float> BTaggingSelectionJsonTool::m_minPt {this, "MinPt", -1 , "Minimum jet pT cut (in MeV)"}
private

Definition at line 32 of file BTaggingSelectionJsonTool.h.

32{this, "MinPt", -1 /*MeV*/, "Minimum jet pT cut (in MeV)"};

◆ m_OP

Gaudi::Property<std::string> BTaggingSelectionJsonTool::m_OP {this, "OperatingPoint", "", "operating point"}
private

Definition at line 38 of file BTaggingSelectionJsonTool.h.

38{this, "OperatingPoint", "", "operating point"};

◆ m_outputName

Gaudi::Property<std::string> BTaggingSelectionJsonTool::m_outputName {this, "OutputName", "", "output name of the tagger"}
private

Definition at line 36 of file BTaggingSelectionJsonTool.h.

36{this, "OutputName", "", "output name of the tagger"};

◆ m_ptAcc

std::unique_ptr<SG::AuxElement::ConstAccessor<float> > BTaggingSelectionJsonTool::m_ptAcc
private

Definition at line 45 of file BTaggingSelectionJsonTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_veto

bool BTaggingSelectionJsonTool::m_veto = false
private

Definition at line 70 of file BTaggingSelectionJsonTool.h.

◆ m_VetoBinConfig

BinConfig BTaggingSelectionJsonTool::m_VetoBinConfig
private

Definition at line 65 of file BTaggingSelectionJsonTool.h.

◆ m_vetoFractionAccessors

std::vector<FractionAccessor> BTaggingSelectionJsonTool::m_vetoFractionAccessors
private

Definition at line 68 of file BTaggingSelectionJsonTool.h.

◆ m_vetoOP

std::string BTaggingSelectionJsonTool::m_vetoOP
private

Definition at line 73 of file BTaggingSelectionJsonTool.h.

◆ m_vetoTagger

std::string BTaggingSelectionJsonTool::m_vetoTagger
private

Definition at line 72 of file BTaggingSelectionJsonTool.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: