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

#include <BTaggingLargeRSelectionJsonTool.h>

Inheritance diagram for BTaggingLargeRSelectionJsonTool:
Collaboration diagram for BTaggingLargeRSelectionJsonTool:

Classes

struct  BinConfig
struct  FractionAccessor

Public Member Functions

 BTaggingLargeRSelectionJsonTool (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< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode loadBinConfig (const json &pT_mass_2d_cutvalue, BinConfig &config) const
std::vector< FractionAccessor > loadFractionValues (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 getJetMassInGeV (const xAOD::Jet &jet) const
float getJetPtInGeV (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::ConstAccessor< float > > m_massAcc
std::unique_ptr< SG::ConstAccessor< float > > m_ptAcc
json m_json_config
BinConfig m_BinConfig
BinConfig m_VetoBinConfig
std::vector< FractionAccessor > m_fractionAccessors
std::vector< FractionAccessor > m_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 BTaggingLargeRSelectionJsonTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ BTaggingLargeRSelectionJsonTool()

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

Definition at line 14 of file BTaggingLargeRSelectionJsonTool.cxx.

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

Member Function Documentation

◆ accept()

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

Implements IBTaggingLargeRSelectionJsonTool.

Definition at line 236 of file BTaggingLargeRSelectionJsonTool.cxx.

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

◆ acceptOnlyForXbbCalibrationUsage()

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

Implements IBTaggingLargeRSelectionJsonTool.

Definition at line 284 of file BTaggingLargeRSelectionJsonTool.cxx.

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

◆ 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 BTaggingLargeRSelectionJsonTool::findBin ( const std::vector< float > & bins,
float value ) const
private

Definition at line 303 of file BTaggingLargeRSelectionJsonTool.cxx.

304{
305 for (size_t i = 0; i < bins.size() - 1; i++) {
306 if ((std::min(bins[i], bins[i + 1]) <= value && value < std::max(bins[i], bins[i + 1]))) {
307 return i;
308 }
309 }
310 return -1;
311}
static const std::vector< std::string > bins

◆ getJetMassInGeV()

float BTaggingLargeRSelectionJsonTool::getJetMassInGeV ( const xAOD::Jet & jet) const
private

Definition at line 313 of file BTaggingLargeRSelectionJsonTool.cxx.

314{
315 // Convert mass from MeV to GeV
316 if (!m_massAcc) {
317 return jet.m() * BTaggingToolUtil::MeVToGeV;
318 }
319 if (!m_massAcc->isAvailable(jet)) {
320 ATH_MSG_ERROR("Decorated mass '" << SG::AuxTypeRegistry::instance().getName( m_massAcc->auxid() ) << "' not available on jet. Cannot proceed.");
321 throw std::runtime_error("Decorated mass not available on jet.");
322 }
324}
#define ATH_MSG_ERROR(x,...)
std::unique_ptr< SG::ConstAccessor< float > > m_massAcc
static constexpr double MeVToGeV
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

◆ getJetPtInGeV()

float BTaggingLargeRSelectionJsonTool::getJetPtInGeV ( const xAOD::Jet & jet) const
private

Definition at line 326 of file BTaggingLargeRSelectionJsonTool.cxx.

327{
328 // Convert pT from MeV to GeV
329 if (!m_ptAcc) {
330 return jet.pt() * BTaggingToolUtil::MeVToGeV;
331 }
332 if (!m_ptAcc->isAvailable(jet)) {
333 ATH_MSG_ERROR("Decorated pT '" << SG::AuxTypeRegistry::instance().getName( m_ptAcc->auxid() ) << "' not available on jet. Cannot proceed.");
334 throw std::runtime_error("Decorated pT not available on jet.");
335 }
337}
std::unique_ptr< SG::ConstAccessor< float > > m_ptAcc

◆ 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 BTaggingLargeRSelectionJsonTool::getTaggerDiscriminant ( const xAOD::Jet & jet) const
overridevirtual

Implements IBTaggingLargeRSelectionJsonTool.

Definition at line 226 of file BTaggingLargeRSelectionJsonTool.cxx.

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

◆ getTaggerDiscriminantInternal()

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

Definition at line 203 of file BTaggingLargeRSelectionJsonTool.cxx.

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

◆ getVetoDiscriminant()

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

Definition at line 231 of file BTaggingLargeRSelectionJsonTool.cxx.

232{
234}
std::vector< FractionAccessor > m_vetoFractionAccessors

◆ initialize()

StatusCode BTaggingLargeRSelectionJsonTool::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 BTaggingLargeRSelectionJsonTool.cxx.

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

Definition at line 115 of file BTaggingLargeRSelectionJsonTool.cxx.

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

◆ loadFractionValues()

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

Definition at line 177 of file BTaggingLargeRSelectionJsonTool.cxx.

178{
179 std::string taggerName;
180 if (meta.contains("TaggerName")) {
181 taggerName = meta["TaggerName"];
182 } else {
183 ATH_MSG_INFO("No 'TaggerName' section found in the meta data for " + m_outputName +
184 " tagger. Using " + m_outputName + " as the tagger name.");
185 taggerName = m_outputName;
186 }
187
188 std::string target = meta["TaggingTarget"];
189 std::vector<BTaggingLargeRSelectionJsonTool::FractionAccessor> fractionAccessors;
190
191 // Pre-load fraction values
192 for (const json& outclass : meta["categories"]) {
193 std::string outclassStr = std::string(outclass);
194 float fraction = meta["fraction_" + outclassStr].get<float>();
195 SG::ConstAccessor<float> accessor(taggerName + "_p" + outclassStr);
196 bool isTarget = (outclassStr == target);
197 fractionAccessors.emplace_back(fraction, accessor, isTarget);
198 }
199
200 return fractionAccessors;
201}
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 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
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 352 of file AthCommonDataStore.h.

352 {
354 }

◆ 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 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_allowBinCountMismatch

Gaudi::Property<bool> BTaggingLargeRSelectionJsonTool::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 41 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_BinConfig

BinConfig BTaggingLargeRSelectionJsonTool::m_BinConfig
private

Definition at line 65 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_fractionAccessors

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

Definition at line 68 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_initialised

bool BTaggingLargeRSelectionJsonTool::m_initialised = false
private

Definition at line 31 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_jetAuthor

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

Definition at line 38 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_json_config

json BTaggingLargeRSelectionJsonTool::m_json_config
private

Definition at line 48 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_json_config_path

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

Definition at line 40 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_massAcc

std::unique_ptr<SG::ConstAccessor<float> > BTaggingLargeRSelectionJsonTool::m_massAcc
private

Definition at line 45 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_maxEta

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

Definition at line 34 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_minPt

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

Definition at line 33 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_OP

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

Definition at line 39 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_outputName

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

Definition at line 37 of file BTaggingLargeRSelectionJsonTool.h.

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

◆ m_ptAcc

std::unique_ptr<SG::ConstAccessor<float> > BTaggingLargeRSelectionJsonTool::m_ptAcc
private

Definition at line 46 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 387 of file AthCommonDataStore.h.

◆ m_veto

bool BTaggingLargeRSelectionJsonTool::m_veto = false
private

Definition at line 71 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_VetoBinConfig

BinConfig BTaggingLargeRSelectionJsonTool::m_VetoBinConfig
private

Definition at line 66 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_vetoFractionAccessors

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

Definition at line 69 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_vetoOP

std::string BTaggingLargeRSelectionJsonTool::m_vetoOP
private

Definition at line 74 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_vetoTagger

std::string BTaggingLargeRSelectionJsonTool::m_vetoTagger
private

Definition at line 73 of file BTaggingLargeRSelectionJsonTool.h.

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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