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 , GN3EPCLV01 , GN3PflowMuonsV00
}
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< 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 43 of file BTaggingSelectionTool.cxx.

44 : asg::AsgTool( name ), m_acceptinfo( "JetSelection" ), m_accessor_pb( "pb" ), m_accessor_pc( "pc" ), m_accessor_pu( "pu" ), m_accessor_ptau( "ptau" )
45{
46 m_initialised = false;
47}
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 457 of file BTaggingSelectionTool.cxx.

457 {
458
459 // Check if this is a jet:
460 if( p->type() != xAOD::Type::Jet ) {
461 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
462 return asg::AcceptData (&m_acceptinfo);
463 }
464
465 // Cast it to a jet:
466 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
467 if( ! jet ) {
468 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
469 return asg::AcceptData (&m_acceptinfo);
470 }
471
472 // Let the specific function do the work:
473 return accept( *jet );
474}
#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 476 of file BTaggingSelectionTool.cxx.

476 {
477 asg::AcceptData acceptData (&m_acceptinfo);
478
479 if (! m_initialised) {
480 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
481 return acceptData;
482 }
483
484 double pT = jet.pt();
485 double eta = jet.eta();
486
487 if(m_continuous2D){
488 double taggerweight_b(-100);
489 double taggerweight_c(-100);
490 if( (getTaggerWeight( jet, taggerweight_b, false)!=CorrectionCode::Ok) ||
491 (getTaggerWeight( jet, taggerweight_c, true )!=CorrectionCode::Ok) )
492 return acceptData;
493
494 return accept(pT, eta, taggerweight_b,taggerweight_c);
495 }
496 else{ //if here, we are in 1D mode
497 double taggerweight(-100);
498 if( getTaggerWeight( jet ,taggerweight, m_useCTag)!=CorrectionCode::Ok)
499 return acceptData;
500
501 return accept(pT, eta, taggerweight);
502 }
503}
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 505 of file BTaggingSelectionTool.cxx.

506{
507
508 asg::AcceptData acceptData (&m_acceptinfo);
509
510 if (! m_initialised) {
511 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
512 return acceptData;
513 }
514
515 eta = std::abs(eta);
516 if (! checkRange(pT, eta, acceptData))
517 return acceptData;
518
519 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
520 // Else, the initialization was incorrect and should be revisited
521 if(m_continuous){
522 for(size_t bin : m_tagger.benchmarks){
523 if(bin == 0){
524 throw std::logic_error("bin == 0 in the list of tagged bins. you should not be here. Wrong convention");
525 } else if ( bin == 1 ) {
526 if ( tag_weight < m_continuouscuts.at(bin-1) ) {
527 acceptData.setCutResult( "WorkingPoint", true );
528 }
529 } else if (bin > 1 && bin <= m_continuouscuts.size()){
530 if ( tag_weight > m_continuouscuts.at(bin-2) && tag_weight < m_continuouscuts.at(bin-1) ) {
531 acceptData.setCutResult( "WorkingPoint", true );
532 }
533 } else {
534 if ( tag_weight > m_continuouscuts.at(bin-2) ) {
535 acceptData.setCutResult( "WorkingPoint", true );
536 }
537 }
538 }
539 }
540 else{ //FixedCut
541 double cutvalue(DBL_MAX);
542 if( getCutValue(pT, cutvalue )!=CorrectionCode::Ok ){
543 return acceptData;
544 }
545
546 if ( tag_weight < cutvalue ){
547 return acceptData;
548 }
549
550 acceptData.setCutResult( "WorkingPoint", true );
551 }
552
553 // Return the result:
554 return acceptData;
555}
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 557 of file BTaggingSelectionTool.cxx.

558{
559 asg::AcceptData acceptData (&m_acceptinfo);
560
561 if (! m_initialised) {
562 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
563 return acceptData;
564 }
565
566 eta = std::abs(eta);
567
568 if (! checkRange(pT, eta, acceptData))
569 return acceptData;
570
571 for(auto bin : m_tagger.benchmarks){
572
573 ATH_MSG_DEBUG("bin" <<bin <<" taggerWeight_c "
574 <<taggerWeight_c <<" taggerWeight_b "
575 <<taggerWeight_b);
576
577 ATH_MSG_DEBUG(" c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
578 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
579 <<m_tagger.get2DCutValue(bin,2) <<" "
580 <<m_tagger.get2DCutValue(bin,3));
581
582 if (taggerWeight_c > m_tagger.get2DCutValue(bin,0) && //ctag low
583 taggerWeight_c <= m_tagger.get2DCutValue(bin,1) && //ctag max
584 taggerWeight_b > m_tagger.get2DCutValue(bin,2) && //btag low
585 taggerWeight_b <= m_tagger.get2DCutValue(bin,3) ) //btag max
586 {
587 acceptData.setCutResult( "WorkingPoint", true ); // IF we arrived here, the jet is tagged
588 break;
589 }
590 } //for loop
591
592 // Return the result:
593 return acceptData;
594}
#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 596 of file BTaggingSelectionTool.cxx.

597{
598 if (m_tagger.name == "GN2v01" || m_tagger.name.find("GN3") != std::string::npos ){
599 asg::AcceptData acceptData (&m_acceptinfo);
600 ATH_MSG_ERROR("For GN2v01 and GN3 taggers, there is a new tau class in the NN output. Please update the accept() to accept(double pT, double eta, double pb, double pc, double pu, double ptau)");
601 return acceptData;
602 } else {
603 return accept(pT, eta, pb, pc, pu, 0.);
604 }
605}

◆ 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 607 of file BTaggingSelectionTool.cxx.

608 {
609 asg::AcceptData acceptData (&m_acceptinfo);
610
611 if (! m_initialised) {
612 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
613 return acceptData;
614 }
615
616 eta = std::abs(eta);
617 if (! checkRange(pT, eta, acceptData))
618 return acceptData;
619
620 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
621 // Else, the initialization was incorrect and should be revisited
622 double cutvalue(DBL_MAX);
623
624 if( getCutValue(pT, cutvalue)!=CorrectionCode::Ok){
625 return acceptData;
626 };
627
628 if(m_continuous2D){
629 double tagger_weight_b(-100);
630 double tagger_weight_c(-100);
631 if( ( getTaggerWeight(pb, pc, pu, tagger_weight_b, false, ptau)!=CorrectionCode::Ok) ||
632 ( getTaggerWeight(pb, pc, pu, tagger_weight_c, true, ptau)!=CorrectionCode::Ok) )
633 return acceptData;
634 return accept(pT, eta, tagger_weight_b, tagger_weight_c);
635 }
636 else{
637 double tagger_weight(-100);
638 if( getTaggerWeight(pb, pc, pu, tagger_weight, m_useCTag, ptau)!=CorrectionCode::Ok)
639 return acceptData;
640 if ( tagger_weight < cutvalue )
641 return acceptData;
642 }
643 //if you made it here, the jet is tagged
644 acceptData.setCutResult( "WorkingPoint", true );
645 return acceptData;
646 }

◆ 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 782 of file BTaggingSelectionTool.cxx.

783{
784 // Do the |eta| cut:
785 if( std::abs(eta) > m_maxEta ) {
786 return false;
787 }
788 acceptData.setCutResult( "Eta", true );
789
790 // Do the pT cut:
791 ATH_MSG_VERBOSE( "Jet pT: " << pT );
792 if( pT < m_minPt ) {
793 return false;
794 }
795 acceptData.setCutResult( "Pt", true );
796
797 return true;
798}
#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:135

◆ 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 242 of file BTaggingSelectionTool.cxx.

242 {
243
244 TString cutname = OP;
245
246 //set the name
247 tagger.name = taggerName;
248
249 if ("FlatBEff"==cutname(0,8) || "HybBEff"==cutname(0,7) ){
250 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutprofile";
251 tagger.spline = dynamic_cast<TSpline3*> (m_inf->Get(cutname));
252 if (tagger.spline == nullptr){
253 ATH_MSG_ERROR( "Invalid operating point" );
254 return StatusCode::FAILURE;
255 }
256 tagger.constcut = nullptr;
257 }
258 else {
259 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutvalue";
260 tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
261 if (tagger.constcut == nullptr){
262 ATH_MSG_ERROR( "Invalid operating point" );
263 return StatusCode::FAILURE;
264 }
265 tagger.spline = nullptr;
266 }
267
268 //retrieve the "fraction" used in the DL1 log likelihood from the CDI, if its not there, use the hard coded values
269 // (backwards compatibility)
271
272 double fraction_b = -1;
273 const TString basePath = taggerName + "/" + m_jetAuthor + "/" + OP;
274 TVector* fraction_b_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_b") );
275 if (fraction_b_data) {
276 fraction_b = (*fraction_b_data)(0);
277 }
278
279 TVector* fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction") );
280 if (!fraction_c_data) {
281 fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_c") );
282 }
283 double fraction_c = -1;
284 if (fraction_c_data) {
285 fraction_c = (*fraction_c_data)(0);
286 } else{
287 if("DL1" ==taggerName){ fraction_c = 0.08; }
288 if("DL1mu" ==taggerName){ fraction_c = 0.08; }
289 if("DL1rnn" ==taggerName){ fraction_c = 0.03; }
290 else {
291 ATH_MSG_ERROR("Failed to retrieve fraction_c");
292 }
293 }
294
295 double fraction_tau = 0.;
296 double fraction_tau_cTag = 0.;
297 TVector* fraction_tau_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau") );
298 TVector* fraction_tau_cTag_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau_cTag") );
299 if (m_taggerEnum == Tagger::GN2 && !(taggerName.find("GN2v00") != std::string::npos)){
300 if( fraction_tau_data ) {
301 fraction_tau = fraction_tau_data[0](0);
302 }
303 if ( m_useCTag && !fraction_tau_cTag_data) {
304 ATH_MSG_ERROR("Runnint c-tagging WP, but failed to retrive fraction_tau_cTag");
305 return StatusCode::FAILURE;
306 }
307 fraction_tau_cTag = fraction_tau_cTag_data[0](0);
308 }
309
310 tagger.fraction_b = fraction_b;
311 tagger.fraction_c = fraction_c;
312 tagger.fraction_tau = fraction_tau;
313 tagger.fraction_tau_cTag = fraction_tau_cTag;
314
315 delete fraction_b_data;
316 delete fraction_c_data;
317 delete fraction_tau_data;
318 delete fraction_tau_cTag_data;
319 }
320 return StatusCode::SUCCESS;
321}
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 800 of file BTaggingSelectionTool.cxx.

801{
802 cutval = DBL_MAX;
803
804 // flat cut for out of range pTs
805 if (pT>m_maxRangePt)
807
809
810 if (tagger.spline != nullptr && tagger.constcut == nullptr) {
811 pT = pT/1000.0;
812 double maxsplinept = tagger.spline->GetXmax();
813 if (pT>maxsplinept){ pT = maxsplinept; }
814 cutval = tagger.spline->Eval(pT);
815 }
816
817 else if (tagger.constcut != nullptr && tagger.spline == nullptr) {
818 cutval = tagger.constcut[0](0);
819 }
820 else{
821 ATH_MSG_ERROR( "Bad cut configuration!" );
823 }
824
825
826 ATH_MSG_VERBOSE( "Cut value " << cutval );
827
828 return CorrectionCode::Ok;
829}
#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::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.

◆ 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 648 of file BTaggingSelectionTool.cxx.

648 {
649 // Check if this is a jet:
650
651
652 if( p->type() != xAOD::Type::Jet ) {
653 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
654 return -1;
655 }
656
657 // Cast it to a jet:
658 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
659 if( ! jet ) {
660 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
661 return -1;
662 }
663
664 // Let the specific function do the work:
665 return getQuantile( *jet );
666}
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 668 of file BTaggingSelectionTool.cxx.

668 {
669 double pT = jet.pt();
670 double eta = std::abs( jet.eta() );
671 int quantile = -1;
672
673 if (m_continuous2D){
674 double tag_weight_b(-100.);
675 double tag_weight_c(-100.);
676 if ( (getTaggerWeight(jet, tag_weight_b, false) == CP::CorrectionCode::Error) ||
677 (getTaggerWeight(jet, tag_weight_c, true ) == CP::CorrectionCode::Error) ){
678 ATH_MSG_WARNING("getQuantile: Failed to retrieve tag weight for Continuous2D!");
679 return -1;
680 }
681 quantile = getQuantile(pT, eta, tag_weight_b, tag_weight_c );
682 }
683 else{
684 // Retrieve the tagger weight which was assigned to the jet
685 double tag_weight(-100.);
686 if (getTaggerWeight(jet, tag_weight, m_useCTag)==CorrectionCode::Error){
687 ATH_MSG_WARNING("getQuantile: Failed to retrieve "+m_taggerName+" weight!");
688 return -1;
689 }
690 ATH_MSG_VERBOSE( m_taggerName << " " << tag_weight);
691 quantile = getQuantile(pT, eta, tag_weight);
692 }
693 return quantile;
694}
#define ATH_MSG_WARNING(x)
Gaudi::Property< std::string > m_taggerName

◆ getQuantile() [3/4]

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

Implements IBTaggingSelectionTool.

Definition at line 697 of file BTaggingSelectionTool.cxx.

698{
699 if (! m_initialised) {
700 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
701 }
703 // Cheatsheet:
704 // With n WPs, (from highest to lowest) A1 , A2, A3, ..., An
705 // return -1 if not in b-tagging acceptance
706 // return 1 if between 100% and A1 (untagged)
707 // return 2 if between A1 and A2 (tagged at the A1 WP)
708 // return 3 if between A2 and A3 (tagged at the A2 WP)
709 // ...
710 // return n if between An-1 and An (tagged at the An-1 WP)
711 // return n+1 if between An and 0% (tagged at the An WP)
713
714 int bin_index = -1;
715
716 // First, check if the jet is in acceptance
717 asg::AcceptData acceptData (&m_acceptinfo);
718 if (! checkRange(pT, eta,acceptData)) {
719 return bin_index;
720 }
721
722 // Now we need to check each threshold in the PCBT vector
723 // and return the maximum WP bin index (1,2,...,n).
724 // Instead of checking low<tag_weight<high for each bin,
725 // we simply check tag_weight<high and therefore range
726 // from vector indices 1 to vector.size()
727 bin_index = 1; // setting the ones that pass selection you have default as 1
728 for (std::size_t i=0; i<m_continuouscuts.size(); i++) {
729 if ( tag_weight > m_continuouscuts.at(i) ) {
730 bin_index++;
731 } else {
732 break;
733 }
734 }
735 return bin_index;
736}

◆ 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 738 of file BTaggingSelectionTool.cxx.

739{
749
750 //More details here: https://indico.cern.ch/event/1116952/#4-mr49953-implements-the-conti
751
752 ATH_MSG_DEBUG("inside getQuantile 2D " <<pT <<" " <<eta <<" " <<tag_weight_b <<" " <<tag_weight_c);
753 int bin_index(-1);
754
755 asg::AcceptData acceptData (&m_acceptinfo);
756 if (! checkRange(pT, eta, acceptData)) return bin_index;
757
758 int ncuts = m_tagger.cuts2D->GetNrows();
759 ATH_MSG_VERBOSE("ncuts: " <<ncuts);
760
761 //loop over all the cuts
762 for(int i = 0; i < ncuts ; i++){
763 double c_cut_low = m_tagger.get2DCutValue(i,0);
764 double c_cut_hig = m_tagger.get2DCutValue(i,1);
765 double b_cut_low = m_tagger.get2DCutValue(i,2);
766 double b_cut_hig = m_tagger.get2DCutValue(i,3);
767
768 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);
769 if (tag_weight_c > c_cut_low &&
770 tag_weight_c <= c_cut_hig &&
771 tag_weight_b > b_cut_low &&
772 tag_weight_b <= b_cut_hig){
773 bin_index = i;
774 break;
775 }
776 }
777
778 ATH_MSG_VERBOSE("bin_index " <<bin_index);
779 return bin_index;
780}

◆ getTaggerWeight() [1/5]

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

Implements IBTaggingSelectionTool.

Definition at line 323 of file BTaggingSelectionTool.cxx.

323 {
324 return getTaggerWeight(jet, tagweight, m_useCTag);
325}

◆ getTaggerWeight() [2/5]

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

Implements IBTaggingSelectionTool.

Definition at line 327 of file BTaggingSelectionTool.cxx.

327 {
328
329 std::string taggerName = m_tagger.name;
330 // following taggerName change is needed given different name is used for GN2v00 in derivation and in CDI
331 if (taggerName == "GN2v00LegacyWP" || taggerName == "GN2v00NewAliasWP"){
332 taggerName = "GN2v00";
333 }
334
335 tagweight = -100.;
336
337 if(!m_continuous2D && (getCTagW != m_useCTag) ){
338 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
340 }
341
343
345
346 if ((!btag) || (!btag->MVx_discriminant(taggerName, tagweight))){
348 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
350 }else{
351 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
352 return CorrectionCode::Ok;
353 }
354 }
355 ATH_MSG_VERBOSE( taggerName << " " << tagweight );
356 return CorrectionCode::Ok;
357 } //MV2
358 else{
359 //DL1r or DL1 or GN2v01
360 double tagger_pb(-10.);
361 double tagger_pc(-10.);
362 double tagger_pu(-10.);
363 double tagger_ptau(0.);
364
365 const SG::AuxElement* btagInfo = &jet;
368
369 if(!btagInfo){
371 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
373 }else{
374 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
375 return CorrectionCode::Ok;
376 }
377 }
378
379 tagger_pb = m_accessor_pb(*btagInfo);
380 tagger_pc = m_accessor_pc(*btagInfo);
381 tagger_pu = m_accessor_pu(*btagInfo);
383 tagger_ptau = m_accessor_ptau(*btagInfo);
384 }
385
386 return getTaggerWeight(tagger_pb, tagger_pc, tagger_pu, tagweight, getCTagW, tagger_ptau);
387
388 }
389
390 //if we got here the tagger name is not configured properly
391 ATH_MSG_ERROR("BTaggingSelectionTool doesn't support tagger: "+m_taggerName);
393
394}
Gaudi::Property< bool > m_readFromBTaggingObject
Gaudi::Property< bool > m_ErrorOnTagWeightFailure
bool MVx_discriminant(const std::string &taggername, double &value) const
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
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 396 of file BTaggingSelectionTool.cxx.

396 {
397 if (m_tagger.name == "GN2v01"){
398 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)");
400 } else {
401 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, 0.);
402 }
403}

◆ getTaggerWeight() [4/5]

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

Implements IBTaggingSelectionTool.

Definition at line 405 of file BTaggingSelectionTool.cxx.

405 {
406 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, ptau);
407}

◆ 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 409 of file BTaggingSelectionTool.cxx.

409 {
410
411 std::string taggerName = m_tagger.name;
412
413 if(!m_continuous2D && (getCTagW != m_useCTag) ){
414 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
416 }
417
418 tagweight = -100.;
420
421 bool valid_input = (!std::isnan(pu) && pb>=0 && pc>=0 && pu>=0 && ptau>=0);
422
423 if (!valid_input){
425 ATH_MSG_ERROR("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
427 }else{
428 ATH_MSG_WARNING("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
429 return CorrectionCode::Ok;
430 }
431 }
432
433 if(getCTagW){
434 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) );
435 }
436 else{
437 tagweight = log(pb / (m_tagger.fraction_c * pc + (1. - m_tagger.fraction_c - m_tagger.fraction_tau) * pu + m_tagger.fraction_tau * ptau) );
438 }
439
440 ATH_MSG_VERBOSE( "pb " << pb );
441 ATH_MSG_VERBOSE( "pc " << pc );
442 ATH_MSG_VERBOSE( "pu " << pu );
443 ATH_MSG_VERBOSE( "ptau" << ptau );
444 ATH_MSG_VERBOSE( "tagweight " << tagweight );
445
446 return CorrectionCode::Ok;
447 }
448
449 //if we got here the tagger name is not configured properly
450 ATH_MSG_ERROR("this call to getTaggerWeight only works for DL1/GNx taggers");
452
453}

◆ 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 49 of file BTaggingSelectionTool.cxx.

49 {
50 m_initialised = true;
51
52 if (m_OP == ""){
53 ATH_MSG_ERROR( "BTaggingSelectionTool wasn't given a working point name" );
54 return StatusCode::FAILURE;
55 }
56
57 TString pathtofile = PathResolverFindCalibFile(m_CutFileName);
58 m_inf = TFile::Open(pathtofile, "read");
59 if (0==m_inf) {
60 ATH_MSG_ERROR( "BTaggingSelectionTool couldn't access the CDI file" );
61 return StatusCode::FAILURE;
62 }
63
64 // check the CDI file for the selected tagger and jet collection
65 TString check_CDI = m_taggerName.value();
66 if(!m_inf->Get(check_CDI)){
67 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" not found in this CDI file: "+m_CutFileName);
68 return StatusCode::FAILURE;
69 }
70 check_CDI = m_taggerName+"/"+m_jetAuthor;
71 if(!m_inf->Get(check_CDI)){
72 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" and Jet Collection : "+m_jetAuthor+" not found in this CDI file: "+m_CutFileName);
73 return StatusCode::FAILURE;
74 }
75
76 //set taggerEnum to avid string comparison:
78
79 // Change the minPt cut if the user didn't touch it
80 if (m_minPt < 0){
81 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" and Jet Collection : "+m_jetAuthor+" do not have a minimum jet pT cut set.");
82 return StatusCode::FAILURE;
83 }
84
85 // Operating point reading
86 TString cutname = m_OP.value();
87 m_continuous = false;
88 m_continuous2D = false;
89
90 if(cutname.Contains("Continuous2D")){
91 ATH_MSG_INFO("Working with Continuous2D WP.");
92 m_continuous = true;
93 m_continuous2D = true;
94 m_useCTag = false; //important for backward compatibility in getTaggerWeight methods.
95 cutname = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/cutvalue";
97 TMatrixD* matrix = dynamic_cast<TMatrixD*> (m_inf->Get(cutname));
98 m_tagger.cuts2D = matrix;
99
100 for (int bin = 0; bin < m_tagger.cuts2D->GetNrows(); bin++)
101 ATH_MSG_DEBUG("INITIALIZATION c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
102 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
103 <<m_tagger.get2DCutValue(bin,2) <<" "
104 <<m_tagger.get2DCutValue(bin,3));
105
106 if (m_tagger.cuts2D == nullptr){
107 ATH_MSG_ERROR( "Invalid operating point" );
108 return StatusCode::FAILURE;
109 }
110
111 m_tagger.spline = nullptr;
112
113 TString fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_b";
114 TVector *fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
115 if(fraction_data!=nullptr){
116 m_tagger.fraction_b = fraction_data[0](0);
117 }
118 else{
119 ATH_MSG_ERROR("Tagger fraction_b in Continuous2D WP not available");
120 return StatusCode::FAILURE;
121 }
122
123 //now the c-fraction:
124 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_c";
125 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
126 if(fraction_data!=nullptr){
127 m_tagger.fraction_c = fraction_data[0](0);}
128 else{
129 ATH_MSG_ERROR("Tagger fraction_c in Continuous2D WP not available");
130 return StatusCode::FAILURE;
131 }
132 //now the tau-fraction if the tagger is GN2* or GN3*:
133 if ( m_taggerName.value().find("GN2") != std::string::npos || m_taggerName.value().find("GN3") != std::string::npos ){
134 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau";
135 TString fraction_data_name_cTag = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau_cTag";
136 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
137 TVector *fraction_data_cTag = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name_cTag));
138 if(fraction_data!=nullptr){
139 m_tagger.fraction_tau = fraction_data[0](0);
140 }else{
141 ATH_MSG_ERROR("Tagger fraction_tau in Continuous2D WP not available");
142 return StatusCode::FAILURE;
143 }
144 if(fraction_data_cTag!=nullptr){
145 m_tagger.fraction_tau_cTag = fraction_data_cTag[0](0);
146 }else{
147 ATH_MSG_ERROR("Tagger fraction_tau_cTag in Continuous2D WP not available");
148 return StatusCode::FAILURE;
149 }
150 delete fraction_data_cTag;
151 }
152 delete fraction_data;
153 } //Continuous2D
154 else if ("Continuous"==cutname(0,10)){ // For continuous tagging load all flat-cut WPs
155 if(m_useCTag)
156 ATH_MSG_WARNING( "Running in Continuous WP and using 1D c-tagging");
157 m_continuous = true;
158
159 std::string subDirName = m_taggerName + "/" + m_jetAuthor;
160 // Get directory containing the cuts information
161 TDirectoryFile *tmpDir = dynamic_cast<TDirectoryFile*>( m_inf->Get(subDirName.c_str()) );
162 if (!tmpDir){
163 // Raise error if could not retrieve subdirectory
164 ATH_MSG_ERROR( "CDI file does not contain sub-directory: " << subDirName );
165 return StatusCode::FAILURE;
166 }
167
168 // Now retrieve the name of the b-tagging fixed cut efficiency working points
169 static const std::string fixedBCutPrefix = "FixedCutBEff_";
170 std::vector<std::string> workingpoints;
171
172 // Loop over keys in the sub directory and select the ones corresponding to fixed cuts
173 TIter next(tmpDir->GetListOfKeys());
174 TKey *key;
175 while ((key = (TKey*)next())) {
176 std::string keyName = key->GetName();
177 // Check if key begins with prefix in that case it's one of the working point
178 // Also make sure the key is not already in the vector as
179 // the list of keys from GetListOfKeys() can contain several times the same name
180 // because there can be several cycle number per objects
181 // since here we check the entry is not already in the vector it's fine
182 // See
183 // https://root-forum.cern.ch/t/tkey-tobject-and-getlistofkeys-for-only-newest-ttrees/25928/3
184 // https://root-forum.cern.ch/t/tkey-tobject-and-getlistofkeys-for-only-newest-ttrees/25928/7
185 if (keyName.starts_with(fixedBCutPrefix) &&
186 std::find(workingpoints.begin(), workingpoints.end(), keyName) == workingpoints.end()){
187 // Add efficiency working point to the vector
188 workingpoints.push_back( keyName );
189 }
190 }
191
192 // After having retrieved all b-tagging working points
193 // Sort vector then set descending order i.e. loosest working point first
194 std::sort(workingpoints.begin(), workingpoints.end());
195 std::reverse(workingpoints.begin(), workingpoints.end()); // put in descending order
196 for(const std::string& wp : workingpoints){
197 cutname = subDirName + "/" + wp + "/cutvalue";
198 m_tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
199 if (m_tagger.constcut != nullptr) {
200 m_continuouscuts.push_back(m_tagger.constcut[0](0));
201 } else {
202 ATH_MSG_ERROR( "Continuous tagging is trying to use an invalid operating point: " + wp );
203 return StatusCode::FAILURE;
204 }
205 }
206
207 //The WP is not important. This is just to retrieve the c-fraction.
209
210 } else {
211 if(m_useCTag){
212 ATH_MSG_WARNING( "Running in FixedCut WP for c-tagging, make sure to use b-veto to select c-tagged jet properly.");
213 }
215 }
216
217 //set the accept working points, jets in these pseudo-continuous bins will be accepted
218 if(m_continuous){
219 std::vector<std::string> tag_benchmarks_names = split(m_ContinuousBenchmarks, ',');
220 std::vector<int> tag_benchmarks;
221 for (const std::string& tagbin : tag_benchmarks_names){
222 tag_benchmarks.push_back(std::atoi(tagbin.c_str()));
223 ATH_MSG_INFO("adding " <<tag_benchmarks.back() <<" as tagged bin ");
224 }
225 m_tagger.benchmarks = tag_benchmarks;
226 }
227
228 m_inf->Close();
229
230 m_acceptinfo.addCut( "Eta", "Selection of jets according to their pseudorapidity" );
231 m_acceptinfo.addCut( "Pt", "Selection of jets according to their transverse momentum" );
232 m_acceptinfo.addCut( "WorkingPoint", "Working point for flavour-tagging of jets according to their b-tagging weight" );
233
234 m_accessor_pb = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pb");
235 m_accessor_pc = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pc");
236 m_accessor_pu = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_pu");
237 m_accessor_ptau = SG::AuxElement::ConstAccessor<float>(m_taggerName+ "_ptau");
238
239 return StatusCode::SUCCESS;
240}
#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)
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 126 of file BTaggingSelectionTool.h.

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

◆ split()

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

Definition at line 831 of file BTaggingSelectionTool.cxx.

831 {
832 std::vector<std::string> v;
833 std::istringstream buf(input);
834 for(std::string token; std::getline(buf, token, delimiter); )
835 v.push_back(token);
836 return v;
837}
static const std::string delimiter("/")

◆ 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 97 of file BTaggingSelectionTool.h.

◆ m_accessor_pc

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

Definition at line 98 of file BTaggingSelectionTool.h.

◆ m_accessor_ptau

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

Definition at line 100 of file BTaggingSelectionTool.h.

◆ m_accessor_pu

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

Definition at line 99 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 95 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 88 of file BTaggingSelectionTool.h.

88{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 94 of file BTaggingSelectionTool.h.

94{};

◆ 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 92 of file BTaggingSelectionTool.h.

92{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 121 of file BTaggingSelectionTool.h.

◆ m_taggerEnum

Tagger BTaggingSelectionTool::m_taggerEnum {UNKNOWN}
private

Definition at line 124 of file BTaggingSelectionTool.h.

124{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 90 of file BTaggingSelectionTool.h.

90{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.


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