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

#include <BTaggingSelectionTool.h>

Inheritance diagram for BTaggingSelectionTool:
Collaboration diagram for BTaggingSelectionTool:

Classes

struct  taggerproperties

Public Member Functions

 BTaggingSelectionTool (const std::string &name)
 Create a proper constructor for Athena.
StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual asg::AcceptData accept (const xAOD::IParticle *p) const override
 Get the decision using a generic IParticle pointer.
virtual asg::AcceptData accept (const xAOD::Jet &jet) const override
virtual asg::AcceptData accept (double, double, double) const override
 Get the decision using thet jet's pt and tag weight values.
virtual asg::AcceptData accept (double, double, double, double) const override
virtual asg::AcceptData accept (double, double, double, double, double) const override
virtual asg::AcceptData accept (double, double, double, double, double, double) const override
virtual int getQuantile (const xAOD::IParticle *) const override
 Decide in which quantile of the tag weight distribution the jet belongs (continuous tagging) The return value represents the bin index of the quantile distribution.
virtual int getQuantile (const xAOD::Jet &) const override
virtual int getQuantile (double, double, double) const override
virtual int getQuantile (double, double, double, double) const override
virtual CP::CorrectionCode getCutValue (double, double &cutval) const override
virtual CP::CorrectionCode getTaggerWeight (const xAOD::Jet &jet, double &tagweight) const override
virtual CP::CorrectionCode getTaggerWeight (double pb, double pc, double pu, double &tagweight) const override
virtual CP::CorrectionCode getTaggerWeight (double pb, double pc, double pu, double &tagweight, double ptau) const override
virtual CP::CorrectionCode getTaggerWeight (const xAOD::Jet &jet, double &weight, bool getCTagW) const override
virtual CP::CorrectionCode getTaggerWeight (double, double, double, double &weight, bool getCTagW, double=0.) const override
const asg::AcceptInfogetAcceptInfo () const override
 Declare the interface ID for this pure-virtual interface class to the Athena framework.
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

enum  Tagger {
  UNKNOWN , DL1 , GN1 , GN2 ,
  MV2c10
}
typedef double(xAOD::BTagging::* tagWeight_member_t) () const
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

virtual bool checkRange (double, double, asg::AcceptData &) const
 Helper function that decides whether a jet belongs to the correct jet selection for b-tagging.
void InitializeTaggerVariables (std::string taggerName, std::string OP, TSpline3 *spline, TVector *constcut, double &fraction)
Tagger SetTaggerEnum (const std::string &taggerName)
StatusCode ExtractTaggerProperties (taggerproperties &tagger, const std::string &taggerName, const std::string &OP)
std::vector< std::string > split (const std::string &input, const char &delimiter)
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
bool m_continuous = false
bool m_continuous2D = false
asg::AcceptInfo m_acceptinfo
 Object used to store the last decision.
Gaudi::Property< double > m_minPt {this, "MinPt", 0 , "Minimum jet pT cut (in MeV)"}
Gaudi::Property< double > m_maxEta {this, "MaxEta", 2.5, "Maximum jet eta cut"}
Gaudi::Property< double > m_maxRangePt {this, "MaxRangePt", 3000000 , "Max pT range (in MeV)"}
Gaudi::Property< std::string > m_CutFileName {this, "FlvTagCutDefinitionsFileName", ftag::defaults::cdi_path, "name of the files containing official cut definitions (uses PathResolver)"}
Gaudi::Property< std::string > m_taggerName {this, "TaggerName", ftag::defaults::tagger, "tagging algorithm name"}
Gaudi::Property< std::string > m_OP {this, "OperatingPoint", "", "operating point"}
Gaudi::Property< std::string > m_jetAuthor {this, "JetAuthor", ftag::defaults::jet_collection, "jet collection"}
Gaudi::Property< std::string > m_ContinuousBenchmarks {this, "CutBenchmarksContinuousWP", "", "comma separated list of tag bins that will be accepted as tagged: 1,2,3 etc.. "}
Gaudi::Property< std::string > m_wps_raw {this, "WorkingPointDefinitions", "FixedCutBEff_85,FixedCutBEff_77,FixedCutBEff_70,FixedCutBEff_60", "Comma-separated list of tagger working points (in decreasing order of efficiency!) - required for 1D tagging purposes"}
Gaudi::Property< bool > m_ErrorOnTagWeightFailure {this, "ErrorOnTagWeightFailure", true, "optionally ignore cases where the tagweight cannot be retrieved. default behaviour is to give an error, switching to false will turn it into a warning"}
Gaudi::Property< bool > m_useCTag {this, "useCTagging", false, "Enabled only for FixedCut or Continuous WPs: define wether the cuts refer to b-tagging or c-tagging"}
Gaudi::Property< bool > m_readFromBTaggingObject {this, "readFromBTaggingObject", false, "Enabled to access btagging scores from xAOD::BTagging object; Can be disabled for GN2v01 to access the scores from the jet itself."}
TFile * m_inf {}
std::vector< double > m_continuouscuts
SG::AuxElement::ConstAccessor< float > m_accessor_pb
SG::AuxElement::ConstAccessor< float > m_accessor_pc
SG::AuxElement::ConstAccessor< float > m_accessor_pu
SG::AuxElement::ConstAccessor< float > m_accessor_ptau
taggerproperties m_tagger
Tagger m_taggerEnum {UNKNOWN}
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 26 of file BTaggingSelectionTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

◆ tagWeight_member_t

typedef double(xAOD::BTagging::* BTaggingSelectionTool::tagWeight_member_t) () const
private

Definition at line 29 of file BTaggingSelectionTool.h.

Member Enumeration Documentation

◆ Tagger

Constructor & Destructor Documentation

◆ BTaggingSelectionTool()

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

Create a proper constructor for Athena.

Create a constructor for standalone usage

Definition at line 42 of file BTaggingSelectionTool.cxx.

43 : asg::AsgTool( name ), m_acceptinfo( "JetSelection" ), m_accessor_pb( "pb" ), m_accessor_pc( "pc" ), m_accessor_pu( "pu" ), m_accessor_ptau( "ptau" )
44{
45 m_initialised = false;
46}
SG::AuxElement::ConstAccessor< float > m_accessor_pu
SG::AuxElement::ConstAccessor< float > m_accessor_ptau
SG::AuxElement::ConstAccessor< float > m_accessor_pc
asg::AcceptInfo m_acceptinfo
Object used to store the last decision.
SG::AuxElement::ConstAccessor< float > m_accessor_pb

Member Function Documentation

◆ accept() [1/6]

asg::AcceptData BTaggingSelectionTool::accept ( const xAOD::IParticle * p) const
overridevirtual

Get the decision using a generic IParticle pointer.

Implements IBTaggingSelectionTool.

Definition at line 424 of file BTaggingSelectionTool.cxx.

424 {
425
426 // Check if this is a jet:
427 if( p->type() != xAOD::Type::Jet ) {
428 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
429 return asg::AcceptData (&m_acceptinfo);
430 }
431
432 // Cast it to a jet:
433 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
434 if( ! jet ) {
435 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
436 return asg::AcceptData (&m_acceptinfo);
437 }
438
439 // Let the specific function do the work:
440 return accept( *jet );
441}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
virtual asg::AcceptData accept(const xAOD::IParticle *p) const override
Get the decision using a generic IParticle pointer.
@ Jet
The object is a jet.
Definition ObjectType.h:40
Jet_v1 Jet
Definition of the current "jet version".

◆ accept() [2/6]

asg::AcceptData BTaggingSelectionTool::accept ( const xAOD::Jet & jet) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 443 of file BTaggingSelectionTool.cxx.

443 {
444 asg::AcceptData acceptData (&m_acceptinfo);
445
446 if (! m_initialised) {
447 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
448 return acceptData;
449 }
450
451 double pT = jet.pt();
452 double eta = jet.eta();
453
454 if(m_continuous2D){
455 double taggerweight_b(-100);
456 double taggerweight_c(-100);
457 if( (getTaggerWeight( jet, taggerweight_b, false)!=CorrectionCode::Ok) ||
458 (getTaggerWeight( jet, taggerweight_c, true )!=CorrectionCode::Ok) )
459 return acceptData;
460
461 return accept(pT, eta, taggerweight_b,taggerweight_c);
462 }
463 else{ //if here, we are in 1D mode
464 double taggerweight(-100);
465 if( getTaggerWeight( jet ,taggerweight, m_useCTag)!=CorrectionCode::Ok)
466 return acceptData;
467
468 return accept(pT, eta, taggerweight);
469 }
470}
Scalar eta() const
pseudorapidity method
virtual CP::CorrectionCode getTaggerWeight(const xAOD::Jet &jet, double &tagweight) const override
Gaudi::Property< bool > m_useCTag
@ Ok
The correction was done successfully.
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition Jet_v1.cxx:44
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition Jet_v1.cxx:49

◆ accept() [3/6]

asg::AcceptData BTaggingSelectionTool::accept ( double pT,
double eta,
double tag_weight ) const
overridevirtual

Get the decision using thet jet's pt and tag weight values.

Implements IBTaggingSelectionTool.

Definition at line 472 of file BTaggingSelectionTool.cxx.

473{
474
475 asg::AcceptData acceptData (&m_acceptinfo);
476
477 if (! m_initialised) {
478 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
479 return acceptData;
480 }
481
482 eta = std::abs(eta);
483 if (! checkRange(pT, eta, acceptData))
484 return acceptData;
485
486 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
487 // Else, the initialization was incorrect and should be revisited
488 if(m_continuous){
489 for(size_t bin : m_tagger.benchmarks){
490 if(bin == 0){
491 throw std::logic_error("bin == 0 in the list of tagged bins. you should not be here. Wrong convention");
492 } else if ( bin == 1 ) {
493 if ( tag_weight < m_continuouscuts.at(bin-1) ) {
494 acceptData.setCutResult( "WorkingPoint", true );
495 }
496 } else if (bin > 1 && bin <= m_continuouscuts.size()){
497 if ( tag_weight > m_continuouscuts.at(bin-2) && tag_weight < m_continuouscuts.at(bin-1) ) {
498 acceptData.setCutResult( "WorkingPoint", true );
499 }
500 } else {
501 if ( tag_weight > m_continuouscuts.at(bin-2) ) {
502 acceptData.setCutResult( "WorkingPoint", true );
503 }
504 }
505 }
506 }
507 else{ //FixedCut
508 double cutvalue(DBL_MAX);
509 if( getCutValue(pT, cutvalue )!=CorrectionCode::Ok ){
510 return acceptData;
511 }
512
513 if ( tag_weight < cutvalue ){
514 return acceptData;
515 }
516
517 acceptData.setCutResult( "WorkingPoint", true );
518 }
519
520 // Return the result:
521 return acceptData;
522}
virtual CP::CorrectionCode getCutValue(double, double &cutval) const override
std::vector< double > m_continuouscuts
virtual bool checkRange(double, double, asg::AcceptData &) const
Helper function that decides whether a jet belongs to the correct jet selection for b-tagging.

◆ accept() [4/6]

asg::AcceptData BTaggingSelectionTool::accept ( double pT,
double eta,
double taggerWeight_b,
double taggerWeight_c ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 524 of file BTaggingSelectionTool.cxx.

525{
526 asg::AcceptData acceptData (&m_acceptinfo);
527
528 if (! m_initialised) {
529 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
530 return acceptData;
531 }
532
533 eta = std::abs(eta);
534
535 if (! checkRange(pT, eta, acceptData))
536 return acceptData;
537
538 for(auto bin : m_tagger.benchmarks){
539
540 ATH_MSG_DEBUG("bin" <<bin <<" taggerWeight_c "
541 <<taggerWeight_c <<" taggerWeight_b "
542 <<taggerWeight_b);
543
544 ATH_MSG_DEBUG(" c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
545 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
546 <<m_tagger.get2DCutValue(bin,2) <<" "
547 <<m_tagger.get2DCutValue(bin,3));
548
549 if (taggerWeight_c > m_tagger.get2DCutValue(bin,0) && //ctag low
550 taggerWeight_c <= m_tagger.get2DCutValue(bin,1) && //ctag max
551 taggerWeight_b > m_tagger.get2DCutValue(bin,2) && //btag low
552 taggerWeight_b <= m_tagger.get2DCutValue(bin,3) ) //btag max
553 {
554 acceptData.setCutResult( "WorkingPoint", true ); // IF we arrived here, the jet is tagged
555 break;
556 }
557 } //for loop
558
559 // Return the result:
560 return acceptData;
561}
#define ATH_MSG_DEBUG(x)

◆ accept() [5/6]

asg::AcceptData BTaggingSelectionTool::accept ( double pT,
double eta,
double pb,
double pc,
double pu ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 563 of file BTaggingSelectionTool.cxx.

564{
565 if (m_tagger.name == "GN2v01"){
566 asg::AcceptData acceptData (&m_acceptinfo);
567 ATH_MSG_ERROR("For GN2v01 tagger, there is a new tau claass in the NN output. Please update the accept() to accept(double pT, double eta, double pb, double pc, double pu, double ptau)");
568 return acceptData;
569 } else {
570 return accept(pT, eta, pb, pc, pu, 0.);
571 }
572}

◆ accept() [6/6]

asg::AcceptData BTaggingSelectionTool::accept ( double pT,
double eta,
double pb,
double pc,
double pu,
double ptau ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 574 of file BTaggingSelectionTool.cxx.

575 {
576 asg::AcceptData acceptData (&m_acceptinfo);
577
578 if (! m_initialised) {
579 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
580 return acceptData;
581 }
582
583 eta = std::abs(eta);
584 if (! checkRange(pT, eta, acceptData))
585 return acceptData;
586
587 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
588 // Else, the initialization was incorrect and should be revisited
589 double cutvalue(DBL_MAX);
590
591 if( getCutValue(pT, cutvalue)!=CorrectionCode::Ok){
592 return acceptData;
593 };
594
595 if(m_continuous2D){
596 double tagger_weight_b(-100);
597 double tagger_weight_c(-100);
598 if( ( getTaggerWeight(pb, pc, pu, tagger_weight_b, false, ptau)!=CorrectionCode::Ok) ||
599 ( getTaggerWeight(pb, pc, pu, tagger_weight_c, true, ptau)!=CorrectionCode::Ok) )
600 return acceptData;
601 return accept(pT, eta, tagger_weight_b, tagger_weight_c);
602 }
603 else{
604 double tagger_weight(-100);
605 if( getTaggerWeight(pb, pc, pu, tagger_weight, m_useCTag, ptau)!=CorrectionCode::Ok)
606 return acceptData;
607 if ( tagger_weight < cutvalue )
608 return acceptData;
609 }
610 //if you made it here, the jet is tagged
611 acceptData.setCutResult( "WorkingPoint", true );
612 return acceptData;
613 }

◆ checkRange()

bool BTaggingSelectionTool::checkRange ( double pT,
double eta,
asg::AcceptData & acceptData ) const
privatevirtual

Helper function that decides whether a jet belongs to the correct jet selection for b-tagging.

Definition at line 749 of file BTaggingSelectionTool.cxx.

750{
751 // Do the |eta| cut:
752 if( std::abs(eta) > m_maxEta ) {
753 return false;
754 }
755 acceptData.setCutResult( "Eta", true );
756
757 // Do the pT cut:
758 ATH_MSG_VERBOSE( "Jet pT: " << pT );
759 if( pT < m_minPt ) {
760 return false;
761 }
762 acceptData.setCutResult( "Pt", true );
763
764 return true;
765}
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< double > m_maxEta
Gaudi::Property< double > m_minPt
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition AcceptData.h:134

◆ 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.

◆ ExtractTaggerProperties()

StatusCode BTaggingSelectionTool::ExtractTaggerProperties ( taggerproperties & tagger,
const std::string & taggerName,
const std::string & OP )
private

Definition at line 209 of file BTaggingSelectionTool.cxx.

209 {
210
211 TString cutname = OP;
212
213 //set the name
214 tagger.name = taggerName;
215
216 if ("FlatBEff"==cutname(0,8) || "HybBEff"==cutname(0,7) ){
217 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutprofile";
218 tagger.spline = dynamic_cast<TSpline3*> (m_inf->Get(cutname));
219 if (tagger.spline == nullptr){
220 ATH_MSG_ERROR( "Invalid operating point" );
221 return StatusCode::FAILURE;
222 }
223 tagger.constcut = nullptr;
224 }
225 else {
226 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutvalue";
227 tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
228 if (tagger.constcut == nullptr){
229 ATH_MSG_ERROR( "Invalid operating point" );
230 return StatusCode::FAILURE;
231 }
232 tagger.spline = nullptr;
233 }
234
235 //retrieve the "fraction" used in the DL1 log likelihood from the CDI, if its not there, use the hard coded values
236 // (backwards compatibility)
238
239 double fraction_b = -1;
240 const TString basePath = taggerName + "/" + m_jetAuthor + "/" + OP;
241 TVector* fraction_b_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_b") );
242 if (fraction_b_data) {
243 fraction_b = (*fraction_b_data)(0);
244 }
245
246 TVector* fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction") );
247 if (!fraction_c_data) {
248 fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_c") );
249 }
250 double fraction_c = -1;
251 if (fraction_c_data) {
252 fraction_c = (*fraction_c_data)(0);
253 } else{
254 if("DL1" ==taggerName){ fraction_c = 0.08; }
255 if("DL1mu" ==taggerName){ fraction_c = 0.08; }
256 if("DL1rnn" ==taggerName){ fraction_c = 0.03; }
257 else {
258 ATH_MSG_ERROR("Failed to retrieve fraction_c");
259 }
260 }
261
262 double fraction_tau = 0.;
263 double fraction_tau_cTag = 0.;
264 TVector* fraction_tau_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau") );
265 TVector* fraction_tau_cTag_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau_cTag") );
266 if (m_taggerEnum == Tagger::GN2 && !(taggerName.find("GN2v00") != std::string::npos)){
267 if( fraction_tau_data ) {
268 fraction_tau = fraction_tau_data[0](0);
269 }
270 if ( m_useCTag && !fraction_tau_cTag_data) {
271 ATH_MSG_ERROR("Runnint c-tagging WP, but failed to retrive fraction_tau_cTag");
272 return StatusCode::FAILURE;
273 }
274 fraction_tau_cTag = fraction_tau_cTag_data[0](0);
275 }
276
277 tagger.fraction_b = fraction_b;
278 tagger.fraction_c = fraction_c;
279 tagger.fraction_tau = fraction_tau;
280 tagger.fraction_tau_cTag = fraction_tau_cTag;
281
282 delete fraction_b_data;
283 delete fraction_c_data;
284 delete fraction_tau_data;
285 delete fraction_tau_cTag_data;
286 }
287 return StatusCode::SUCCESS;
288}
Gaudi::Property< std::string > m_jetAuthor
const std::string tagger

◆ 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

◆ getAcceptInfo()

const asg::AcceptInfo & BTaggingSelectionTool::getAcceptInfo ( ) const
inlineoverridevirtual

Declare the interface ID for this pure-virtual interface class to the Athena framework.

Method to get the AcceptInfo to query what cuts are defined.

Implements IAsgSelectionTool.

Definition at line 65 of file BTaggingSelectionTool.h.

65{return m_acceptinfo;}

◆ getCutValue()

CorrectionCode BTaggingSelectionTool::getCutValue ( double pT,
double & cutval ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 767 of file BTaggingSelectionTool.cxx.

768{
769 cutval = DBL_MAX;
770
771 // flat cut for out of range pTs
772 if (pT>m_maxRangePt)
774
776
777 if (tagger.spline != nullptr && tagger.constcut == nullptr) {
778 pT = pT/1000.0;
779 double maxsplinept = tagger.spline->GetXmax();
780 if (pT>maxsplinept){ pT = maxsplinept; }
781 cutval = tagger.spline->Eval(pT);
782 }
783
784 else if (tagger.constcut != nullptr && tagger.spline == nullptr) {
785 cutval = tagger.constcut[0](0);
786 }
787 else{
788 ATH_MSG_ERROR( "Bad cut configuration!" );
790 }
791
792
793 ATH_MSG_VERBOSE( "Cut value " << cutval );
794
795 return CorrectionCode::Ok;
796}
#define ATLAS_THREAD_SAFE
Gaudi::Property< double > m_maxRangePt
@ Error
Some error happened during the object correction.

◆ 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::TEvent 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::TEvent, 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::TEvent 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::TEvent, 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.

◆ getQuantile() [1/4]

int BTaggingSelectionTool::getQuantile ( const xAOD::IParticle * p) const
overridevirtual

Decide in which quantile of the tag weight distribution the jet belongs (continuous tagging) The return value represents the bin index of the quantile distribution.

Implements IBTaggingSelectionTool.

Definition at line 615 of file BTaggingSelectionTool.cxx.

615 {
616 // Check if this is a jet:
617
618
619 if( p->type() != xAOD::Type::Jet ) {
620 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
621 return -1;
622 }
623
624 // Cast it to a jet:
625 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
626 if( ! jet ) {
627 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
628 return -1;
629 }
630
631 // Let the specific function do the work:
632 return getQuantile( *jet );
633}
virtual int getQuantile(const xAOD::IParticle *) const override
Decide in which quantile of the tag weight distribution the jet belongs (continuous tagging) The retu...

◆ getQuantile() [2/4]

int BTaggingSelectionTool::getQuantile ( const xAOD::Jet & jet) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 635 of file BTaggingSelectionTool.cxx.

635 {
636 double pT = jet.pt();
637 double eta = std::abs( jet.eta() );
638 int quantile = -1;
639
640 if (m_continuous2D){
641 double tag_weight_b(-100.);
642 double tag_weight_c(-100.);
643 if ( (getTaggerWeight(jet, tag_weight_b, false) == CP::CorrectionCode::Error) ||
644 (getTaggerWeight(jet, tag_weight_c, true ) == CP::CorrectionCode::Error) ){
645 ATH_MSG_WARNING("getQuantile: Failed to retrieve tag weight for Continuous2D!");
646 return -1;
647 }
648 quantile = getQuantile(pT, eta, tag_weight_b, tag_weight_c );
649 }
650 else{
651 // Retrieve the tagger weight which was assigned to the jet
652 double tag_weight(-100.);
653 if (getTaggerWeight(jet, tag_weight, m_useCTag)==CorrectionCode::Error){
654 ATH_MSG_WARNING("getQuantile: Failed to retrieve "+m_taggerName+" weight!");
655 return -1;
656 }
657 ATH_MSG_VERBOSE( m_taggerName << " " << tag_weight);
658 quantile = getQuantile(pT, eta, tag_weight);
659 }
660 return quantile;
661}
#define ATH_MSG_WARNING(x)
Gaudi::Property< std::string > m_taggerName
@ Error
Some error happened during the object correction.

◆ getQuantile() [3/4]

int BTaggingSelectionTool::getQuantile ( double pT,
double eta,
double tag_weight ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 664 of file BTaggingSelectionTool.cxx.

665{
666 if (! m_initialised) {
667 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
668 }
670 // Cheatsheet:
671 // With n WPs, (from highest to lowest) A1 , A2, A3, ..., An
672 // return -1 if not in b-tagging acceptance
673 // return 1 if between 100% and A1 (untagged)
674 // return 2 if between A1 and A2 (tagged at the A1 WP)
675 // return 3 if between A2 and A3 (tagged at the A2 WP)
676 // ...
677 // return n if between An-1 and An (tagged at the An-1 WP)
678 // return n+1 if between An and 0% (tagged at the An WP)
680
681 int bin_index = -1;
682
683 // First, check if the jet is in acceptance
684 asg::AcceptData acceptData (&m_acceptinfo);
685 if (! checkRange(pT, eta,acceptData)) {
686 return bin_index;
687 }
688
689 // Now we need to check each threshold in the PCBT vector
690 // and return the maximum WP bin index (1,2,...,n).
691 // Instead of checking low<tag_weight<high for each bin,
692 // we simply check tag_weight<high and therefore range
693 // from vector indices 1 to vector.size()
694 bin_index = 1; // setting the ones that pass selection you have default as 1
695 for (std::size_t i=0; i<m_continuouscuts.size(); i++) {
696 if ( tag_weight > m_continuouscuts.at(i) ) {
697 bin_index++;
698 } else {
699 break;
700 }
701 }
702 return bin_index;
703}

◆ getQuantile() [4/4]

int BTaggingSelectionTool::getQuantile ( double pT,
double eta,
double tag_weight_b,
double tag_weight_c ) const
overridevirtual

Cheatsheet: returns 4 if pass B_tight (?) returns 3 if pass B_loose returns 2 if pass C_tight + fail B_loose returns 1 if pass C_loose + fail C_tight + fail B_loose returns 0 if fail C_loose + fail B_loose return -1 not in b-tagging acceptance

Implements IBTaggingSelectionTool.

Definition at line 705 of file BTaggingSelectionTool.cxx.

706{
716
717 //More details here: https://indico.cern.ch/event/1116952/#4-mr49953-implements-the-conti
718
719 ATH_MSG_DEBUG("inside getQuantile 2D " <<pT <<" " <<eta <<" " <<tag_weight_b <<" " <<tag_weight_c);
720 int bin_index(-1);
721
722 asg::AcceptData acceptData (&m_acceptinfo);
723 if (! checkRange(pT, eta, acceptData)) return bin_index;
724
725 int ncuts = m_tagger.cuts2D->GetNrows();
726 ATH_MSG_VERBOSE("ncuts: " <<ncuts);
727
728 //loop over all the cuts
729 for(int i = 0; i < ncuts ; i++){
730 double c_cut_low = m_tagger.get2DCutValue(i,0);
731 double c_cut_hig = m_tagger.get2DCutValue(i,1);
732 double b_cut_low = m_tagger.get2DCutValue(i,2);
733 double b_cut_hig = m_tagger.get2DCutValue(i,3);
734
735 ATH_MSG_DEBUG("bin " <<i <<" c_cut low " <<c_cut_low <<" c_cut hig " <<c_cut_hig <<" c_cut low " <<b_cut_low <<" b_ct hig" <<b_cut_hig);
736 if (tag_weight_c > c_cut_low &&
737 tag_weight_c <= c_cut_hig &&
738 tag_weight_b > b_cut_low &&
739 tag_weight_b <= b_cut_hig){
740 bin_index = i;
741 break;
742 }
743 }
744
745 ATH_MSG_VERBOSE("bin_index " <<bin_index);
746 return bin_index;
747}

◆ getTaggerWeight() [1/5]

CorrectionCode BTaggingSelectionTool::getTaggerWeight ( const xAOD::Jet & jet,
double & tagweight ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 290 of file BTaggingSelectionTool.cxx.

290 {
291 return getTaggerWeight(jet, tagweight, m_useCTag);
292}

◆ getTaggerWeight() [2/5]

CorrectionCode BTaggingSelectionTool::getTaggerWeight ( const xAOD::Jet & jet,
double & weight,
bool getCTagW ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 294 of file BTaggingSelectionTool.cxx.

294 {
295
296 std::string taggerName = m_tagger.name;
297 // following taggerName change is needed given different name is used for GN2v00 in derivation and in CDI
298 if (taggerName == "GN2v00LegacyWP" || taggerName == "GN2v00NewAliasWP"){
299 taggerName = "GN2v00";
300 }
301
302 tagweight = -100.;
303
304 if(!m_continuous2D && (getCTagW != m_useCTag) ){
305 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
307 }
308
310
312
313 if ((!btag) || (!btag->MVx_discriminant(taggerName, tagweight))){
315 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
317 }else{
318 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
319 return CorrectionCode::Ok;
320 }
321 }
322 ATH_MSG_VERBOSE( taggerName << " " << tagweight );
323 return CorrectionCode::Ok;
324 } //MV2
325 else{
326 //DL1r or DL1 or GN2v01
327 double tagger_pb(-10.);
328 double tagger_pc(-10.);
329 double tagger_pu(-10.);
330 double tagger_ptau(0.);
331
332 const SG::AuxElement* btagInfo = &jet;
335
336 if(!btagInfo){
338 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
340 }else{
341 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
342 return CorrectionCode::Ok;
343 }
344 }
345
346 tagger_pb = m_accessor_pb(*btagInfo);
347 tagger_pc = m_accessor_pc(*btagInfo);
348 tagger_pu = m_accessor_pu(*btagInfo);
349 if(m_taggerName == "GN2v01")
350 tagger_ptau = m_accessor_ptau(*btagInfo);
351
352
353 return getTaggerWeight(tagger_pb, tagger_pc, tagger_pu, tagweight, getCTagW, tagger_ptau);
354
355 }
356
357 //if we got here the tagger name is not configured properly
358 ATH_MSG_ERROR("BTaggingSelectionTool doesn't support tagger: "+m_taggerName);
360
361}
Gaudi::Property< bool > m_readFromBTaggingObject
Gaudi::Property< bool > m_ErrorOnTagWeightFailure
bool MVx_discriminant(const std::string &taggername, double &value) const
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
BTagging_v1 BTagging
Definition of the current "BTagging version".
Definition BTagging.h:17

◆ getTaggerWeight() [3/5]

CorrectionCode BTaggingSelectionTool::getTaggerWeight ( double pb,
double pc,
double pu,
double & tagweight ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 363 of file BTaggingSelectionTool.cxx.

363 {
364 if (m_tagger.name == "GN2v01"){
365 ATH_MSG_ERROR("For GN2v01 tagger, there is a new tau claass in the NN output. Please update your getTaggerWeight() to getTaggerWeight( double pb, double pc, double pu, double & tagweight, double ptau)");
367 } else {
368 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, 0.);
369 }
370}

◆ getTaggerWeight() [4/5]

CorrectionCode BTaggingSelectionTool::getTaggerWeight ( double pb,
double pc,
double pu,
double & tagweight,
double ptau ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 372 of file BTaggingSelectionTool.cxx.

372 {
373 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, ptau);
374}

◆ getTaggerWeight() [5/5]

CorrectionCode BTaggingSelectionTool::getTaggerWeight ( double pb,
double pc,
double pu,
double & weight,
bool getCTagW,
double ptau = 0. ) const
overridevirtual

Implements IBTaggingSelectionTool.

Definition at line 376 of file BTaggingSelectionTool.cxx.

376 {
377
378 std::string taggerName = m_tagger.name;
379
380 if(!m_continuous2D && (getCTagW != m_useCTag) ){
381 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
383 }
384
385 tagweight = -100.;
387
388 bool valid_input = (!std::isnan(pu) && pb>=0 && pc>=0 && pu>=0 && ptau>=0);
389
390 if (!valid_input){
392 ATH_MSG_ERROR("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
394 }else{
395 ATH_MSG_WARNING("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
396 return CorrectionCode::Ok;
397 }
398 }
399
400 if(getCTagW){
401 tagweight = log(pc / (m_tagger.fraction_b * pb + (1. - m_tagger.fraction_b - m_tagger.fraction_tau_cTag) * pu + m_tagger.fraction_tau_cTag * ptau) );
402 }
403 else{
404 tagweight = log(pb / (m_tagger.fraction_c * pc + (1. - m_tagger.fraction_c - m_tagger.fraction_tau) * pu + m_tagger.fraction_tau * ptau) );
405 }
406
407 ATH_MSG_VERBOSE( "pb " << pb );
408 ATH_MSG_VERBOSE( "pc " << pc );
409 ATH_MSG_VERBOSE( "pu " << pu );
410 ATH_MSG_VERBOSE( "ptau" << ptau );
411 ATH_MSG_VERBOSE( "tagweight " << tagweight );
412
413 return CorrectionCode::Ok;
414 }
415
416 //if we got here the tagger name is not configured properly
417 ATH_MSG_ERROR("this call to getTaggerWeight only works for DL1/GNx taggers");
419
420}

◆ initialize()

StatusCode BTaggingSelectionTool::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 48 of file BTaggingSelectionTool.cxx.

48 {
49 m_initialised = true;
50
51 if (m_OP == ""){
52 ATH_MSG_ERROR( "BTaggingSelectionTool wasn't given a working point name" );
53 return StatusCode::FAILURE;
54 }
55
56 TString pathtofile = PathResolverFindCalibFile(m_CutFileName);
57 m_inf = TFile::Open(pathtofile, "read");
58 if (0==m_inf) {
59 ATH_MSG_ERROR( "BTaggingSelectionTool couldn't access the CDI file" );
60 return StatusCode::FAILURE;
61 }
62
63 // check the CDI file for the selected tagger and jet collection
64 TString check_CDI = m_taggerName.value();
65 if(!m_inf->Get(check_CDI)){
66 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" not found in this CDI file: "+m_CutFileName);
67 return StatusCode::FAILURE;
68 }
69 check_CDI = m_taggerName+"/"+m_jetAuthor;
70 if(!m_inf->Get(check_CDI)){
71 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" and Jet Collection : "+m_jetAuthor+" not found in this CDI file: "+m_CutFileName);
72 return StatusCode::FAILURE;
73 }
74
75 //set taggerEnum to avid string comparison:
77
78 // Change the minPt cut if the user didn't touch it
79 if (m_minPt < 0){
80 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" and Jet Collection : "+m_jetAuthor+" do not have a minimum jet pT cut set.");
81 return StatusCode::FAILURE;
82 }
83
84 // Operating point reading
85 TString cutname = m_OP.value();
86 m_continuous = false;
87 m_continuous2D = false;
88
89 if(cutname.Contains("Continuous2D")){
90 ATH_MSG_INFO("Working with Continuous2D WP.");
91 m_continuous = true;
92 m_continuous2D = true;
93 m_useCTag = false; //important for backward compatibility in getTaggerWeight methods.
94 cutname = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/cutvalue";
96 TMatrixD* matrix = dynamic_cast<TMatrixD*> (m_inf->Get(cutname));
97 m_tagger.cuts2D = matrix;
98
99 for (int bin = 0; bin < m_tagger.cuts2D->GetNrows(); bin++)
100 ATH_MSG_DEBUG("INITIALIZATION c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
101 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
102 <<m_tagger.get2DCutValue(bin,2) <<" "
103 <<m_tagger.get2DCutValue(bin,3));
104
105 if (m_tagger.cuts2D == nullptr){
106 ATH_MSG_ERROR( "Invalid operating point" );
107 return StatusCode::FAILURE;
108 }
109
110 m_tagger.spline = nullptr;
111
112 TString fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_b";
113 TVector *fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
114 if(fraction_data!=nullptr){
115 m_tagger.fraction_b = fraction_data[0](0);
116 }
117 else{
118 ATH_MSG_ERROR("Tagger fraction_b in Continuous2D WP not available");
119 return StatusCode::FAILURE;
120 }
121
122 //now the c-fraction:
123 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_c";
124 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
125 if(fraction_data!=nullptr){
126 m_tagger.fraction_c = fraction_data[0](0);}
127 else{
128 ATH_MSG_ERROR("Tagger fraction_c in Continuous2D WP not available");
129 return StatusCode::FAILURE;
130 }
131 //now the tau-fraction if the tagger is GN2*:
132 if ( m_taggerName == "GN2v01" ){
133 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau";
134 TString fraction_data_name_cTag = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau_cTag";
135 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
136 TVector *fraction_data_cTag = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name_cTag));
137 if(fraction_data!=nullptr){
138 m_tagger.fraction_tau = fraction_data[0](0);
139 }else{
140 ATH_MSG_ERROR("Tagger fraction_tau in Continuous2D WP not available");
141 return StatusCode::FAILURE;
142 }
143 if(fraction_data_cTag!=nullptr){
144 m_tagger.fraction_tau_cTag = fraction_data_cTag[0](0);
145 }else{
146 ATH_MSG_ERROR("Tagger fraction_tau_cTag in Continuous2D WP not available");
147 return StatusCode::FAILURE;
148 }
149 delete fraction_data_cTag;
150 }
151 delete fraction_data;
152 } //Continuous2D
153 else if ("Continuous"==cutname(0,10)){ // For continuous tagging load all flat-cut WPs
154 if(m_useCTag)
155 ATH_MSG_WARNING( "Running in Continuous WP and using 1D c-tagging");
156 m_continuous = true;
157 // For GN2v01, we have different WPs than the default ones.
158 if ( m_taggerName == "GN2v01" )
159 m_wps_raw="FixedCutBEff_90,FixedCutBEff_85,FixedCutBEff_77,FixedCutBEff_70,FixedCutBEff_65";
160 std::vector<std::string> workingpoints = split(m_wps_raw, ',');
161 std::sort(workingpoints.begin(), workingpoints.end());
162 std::reverse(workingpoints.begin(), workingpoints.end()); // put in descending order
163 for(const std::string& wp : workingpoints){
164 cutname = m_taggerName + "/" + m_jetAuthor + "/" + wp + "/cutvalue";
165 m_tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
166 if (m_tagger.constcut != nullptr) {
167 m_continuouscuts.push_back(m_tagger.constcut[0](0));
168 } else {
169 ATH_MSG_ERROR( "Continuous tagging is trying to use an invalid operating point: " + wp );
170 return StatusCode::FAILURE;
171 }
172 }
173
174 //The WP is not important. This is just to retrieve the c-fraction.
176
177 } else {
178 if(m_useCTag){
179 ATH_MSG_WARNING( "Running in FixedCut WP for c-tagging, make sure to use b-veto to select c-tagged jet properly.");
180 }
182 }
183
184 //set the accept working points, jets in these pseudo-continuous bins will be accepted
185 if(m_continuous){
186 std::vector<std::string> tag_benchmarks_names = split(m_ContinuousBenchmarks, ',');
187 std::vector<int> tag_benchmarks;
188 for (const std::string& tagbin : tag_benchmarks_names){
189 tag_benchmarks.push_back(std::atoi(tagbin.c_str()));
190 ATH_MSG_INFO("adding " <<tag_benchmarks.back() <<" as tagged bin ");
191 }
192 m_tagger.benchmarks = tag_benchmarks;
193 }
194
195 m_inf->Close();
196
197 m_acceptinfo.addCut( "Eta", "Selection of jets according to their pseudorapidity" );
198 m_acceptinfo.addCut( "Pt", "Selection of jets according to their transverse momentum" );
199 m_acceptinfo.addCut( "WorkingPoint", "Working point for flavour-tagging of jets according to their b-tagging weight" );
200
201 m_accessor_pb = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pb");
202 m_accessor_pc = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pc");
203 m_accessor_pu = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pu");
204 m_accessor_ptau = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_ptau");
205
206 return StatusCode::SUCCESS;
207}
#define ATH_MSG_INFO(x)
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< std::string > m_CutFileName
StatusCode ExtractTaggerProperties(taggerproperties &tagger, const std::string &taggerName, const std::string &OP)
Gaudi::Property< std::string > m_OP
Gaudi::Property< std::string > m_ContinuousBenchmarks
std::vector< std::string > split(const std::string &input, const char &delimiter)
Gaudi::Property< std::string > m_wps_raw
Tagger SetTaggerEnum(const std::string &taggerName)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.

◆ InitializeTaggerVariables()

void BTaggingSelectionTool::InitializeTaggerVariables ( std::string taggerName,
std::string OP,
TSpline3 * spline,
TVector * constcut,
double & fraction )
private

◆ 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.

◆ 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 }

◆ SetTaggerEnum()

Tagger BTaggingSelectionTool::SetTaggerEnum ( const std::string & taggerName)
inlineprivate

Definition at line 127 of file BTaggingSelectionTool.h.

127 {
128 if(taggerName.find("DL1") != std::string::npos) return Tagger::DL1;
129 else if(taggerName.find("GN1") != std::string::npos) return Tagger::GN1;
130 else if(taggerName.find("GN2") != std::string::npos) return Tagger::GN2;
131 else if(taggerName == "MV2c10") return Tagger::MV2c10;
132 else
133 ATH_MSG_ERROR("Tagger Name NOT supported.");
134 return Tagger::UNKNOWN;
135 };

◆ split()

std::vector< std::string > BTaggingSelectionTool::split ( const std::string & input,
const char & delimiter )
private

Definition at line 798 of file BTaggingSelectionTool.cxx.

798 {
799 std::vector<std::string> v;
800 std::istringstream buf(input);
801 for(std::string token; std::getline(buf, token, delimiter); )
802 v.push_back(token);
803 return v;
804}

◆ 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 >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ 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_acceptinfo

asg::AcceptInfo BTaggingSelectionTool::m_acceptinfo
private

Object used to store the last decision.

Definition at line 76 of file BTaggingSelectionTool.h.

◆ m_accessor_pb

SG::AuxElement::ConstAccessor<float> BTaggingSelectionTool::m_accessor_pb
private

Definition at line 98 of file BTaggingSelectionTool.h.

◆ m_accessor_pc

SG::AuxElement::ConstAccessor<float> BTaggingSelectionTool::m_accessor_pc
private

Definition at line 99 of file BTaggingSelectionTool.h.

◆ m_accessor_ptau

SG::AuxElement::ConstAccessor<float> BTaggingSelectionTool::m_accessor_ptau
private

Definition at line 101 of file BTaggingSelectionTool.h.

◆ m_accessor_pu

SG::AuxElement::ConstAccessor<float> BTaggingSelectionTool::m_accessor_pu
private

Definition at line 100 of file BTaggingSelectionTool.h.

◆ m_continuous

bool BTaggingSelectionTool::m_continuous = false
private

Definition at line 73 of file BTaggingSelectionTool.h.

◆ m_continuous2D

bool BTaggingSelectionTool::m_continuous2D = false
private

Definition at line 74 of file BTaggingSelectionTool.h.

◆ m_ContinuousBenchmarks

Gaudi::Property<std::string> BTaggingSelectionTool::m_ContinuousBenchmarks {this, "CutBenchmarksContinuousWP", "", "comma separated list of tag bins that will be accepted as tagged: 1,2,3 etc.. "}
private

Definition at line 86 of file BTaggingSelectionTool.h.

86{this, "CutBenchmarksContinuousWP", "", "comma separated list of tag bins that will be accepted as tagged: 1,2,3 etc.. "};

◆ m_continuouscuts

std::vector<double> BTaggingSelectionTool::m_continuouscuts
private

Definition at line 96 of file BTaggingSelectionTool.h.

◆ m_CutFileName

Gaudi::Property<std::string> BTaggingSelectionTool::m_CutFileName {this, "FlvTagCutDefinitionsFileName", ftag::defaults::cdi_path, "name of the files containing official cut definitions (uses PathResolver)"}
private

Definition at line 82 of file BTaggingSelectionTool.h.

82{this, "FlvTagCutDefinitionsFileName", ftag::defaults::cdi_path, "name of the files containing official cut definitions (uses PathResolver)"};
const std::string cdi_path

◆ 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_ErrorOnTagWeightFailure

Gaudi::Property<bool> BTaggingSelectionTool::m_ErrorOnTagWeightFailure {this, "ErrorOnTagWeightFailure", true, "optionally ignore cases where the tagweight cannot be retrieved. default behaviour is to give an error, switching to false will turn it into a warning"}
private

Definition at line 89 of file BTaggingSelectionTool.h.

89{this, "ErrorOnTagWeightFailure", true, "optionally ignore cases where the tagweight cannot be retrieved. default behaviour is to give an error, switching to false will turn it into a warning"};

◆ 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_inf

TFile* BTaggingSelectionTool::m_inf {}
private

Definition at line 95 of file BTaggingSelectionTool.h.

95{};

◆ m_initialised

bool BTaggingSelectionTool::m_initialised = false
private

Definition at line 72 of file BTaggingSelectionTool.h.

◆ m_jetAuthor

Gaudi::Property<std::string> BTaggingSelectionTool::m_jetAuthor {this, "JetAuthor", ftag::defaults::jet_collection, "jet collection"}
private

Definition at line 85 of file BTaggingSelectionTool.h.

85{this, "JetAuthor", ftag::defaults::jet_collection, "jet collection"};
const std::string jet_collection

◆ m_maxEta

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

Definition at line 79 of file BTaggingSelectionTool.h.

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

◆ m_maxRangePt

Gaudi::Property<double> BTaggingSelectionTool::m_maxRangePt {this, "MaxRangePt", 3000000 , "Max pT range (in MeV)"}
private

Definition at line 80 of file BTaggingSelectionTool.h.

80{this, "MaxRangePt", 3000000 /*MeV*/, "Max pT range (in MeV)"};

◆ m_minPt

Gaudi::Property<double> BTaggingSelectionTool::m_minPt {this, "MinPt", 0 , "Minimum jet pT cut (in MeV)"}
private

Definition at line 78 of file BTaggingSelectionTool.h.

78{this, "MinPt", 0 /*MeV*/, "Minimum jet pT cut (in MeV)"};

◆ m_OP

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

Definition at line 84 of file BTaggingSelectionTool.h.

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

◆ m_readFromBTaggingObject

Gaudi::Property<bool> BTaggingSelectionTool::m_readFromBTaggingObject {this, "readFromBTaggingObject", false, "Enabled to access btagging scores from xAOD::BTagging object; Can be disabled for GN2v01 to access the scores from the jet itself."}
private

Definition at line 93 of file BTaggingSelectionTool.h.

93{this, "readFromBTaggingObject", false, "Enabled to access btagging scores from xAOD::BTagging object; Can be disabled for GN2v01 to access the scores from the jet itself."};

◆ m_tagger

taggerproperties BTaggingSelectionTool::m_tagger
private

Definition at line 122 of file BTaggingSelectionTool.h.

◆ m_taggerEnum

Tagger BTaggingSelectionTool::m_taggerEnum {UNKNOWN}
private

Definition at line 125 of file BTaggingSelectionTool.h.

125{UNKNOWN};

◆ m_taggerName

Gaudi::Property<std::string> BTaggingSelectionTool::m_taggerName {this, "TaggerName", ftag::defaults::tagger, "tagging algorithm name"}
private

Definition at line 83 of file BTaggingSelectionTool.h.

83{this, "TaggerName", ftag::defaults::tagger, "tagging algorithm name"};

◆ m_useCTag

Gaudi::Property<bool> BTaggingSelectionTool::m_useCTag {this, "useCTagging", false, "Enabled only for FixedCut or Continuous WPs: define wether the cuts refer to b-tagging or c-tagging"}
private

Definition at line 91 of file BTaggingSelectionTool.h.

91{this, "useCTagging", false, "Enabled only for FixedCut or Continuous WPs: define wether the cuts refer to b-tagging or c-tagging"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_wps_raw

Gaudi::Property<std::string> BTaggingSelectionTool::m_wps_raw {this, "WorkingPointDefinitions", "FixedCutBEff_85,FixedCutBEff_77,FixedCutBEff_70,FixedCutBEff_60", "Comma-separated list of tagger working points (in decreasing order of efficiency!) - required for 1D tagging purposes"}
private

Definition at line 87 of file BTaggingSelectionTool.h.

87{this, "WorkingPointDefinitions", "FixedCutBEff_85,FixedCutBEff_77,FixedCutBEff_70,FixedCutBEff_60", "Comma-separated list of tagger working points (in decreasing order of efficiency!) - required for 1D tagging purposes"};

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