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::AcceptInfo & getAcceptInfo () 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 , MV2c10 , DL1 , GN1 ,
  GN2 , GN3
}
typedef double(xAOD::BTagging::* tagWeight_member_t) () const
typedef ServiceHandle< StoreGateSvc > StoreGateSvc_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
bool m_usingOnlineTagger = false
bool m_taggerWithTauFractions = true
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::ConstAccessor< float > m_accessor_pb
SG::ConstAccessor< float > m_accessor_pc
SG::ConstAccessor< float > m_accessor_pu
SG::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 376 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::ConstAccessor< float > m_accessor_pc
SG::ConstAccessor< float > m_accessor_ptau
asg::AcceptInfo m_acceptinfo
Object used to store the last decision.
SG::ConstAccessor< float > m_accessor_pu
SG::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 483 of file BTaggingSelectionTool.cxx.

483 {
484
485 // Check if this is a jet:
486 if( p->type() != xAOD::Type::Jet ) {
487 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
488 return asg::AcceptData (&m_acceptinfo);
489 }
490
491 // Cast it to a jet:
492 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
493 if( ! jet ) {
494 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
495 return asg::AcceptData (&m_acceptinfo);
496 }
497
498 // Let the specific function do the work:
499 return accept( *jet );
500}
#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 502 of file BTaggingSelectionTool.cxx.

502 {
503 asg::AcceptData acceptData (&m_acceptinfo);
504
505 if (! m_initialised) {
506 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
507 return acceptData;
508 }
509
510 double pT = jet.pt();
511 double eta = jet.eta();
512
513 if(m_continuous2D){
514 double taggerweight_b(-100);
515 double taggerweight_c(-100);
516 if( (getTaggerWeight( jet, taggerweight_b, false)!=CorrectionCode::Ok) ||
517 (getTaggerWeight( jet, taggerweight_c, true )!=CorrectionCode::Ok) )
518 return acceptData;
519
520 return accept(pT, eta, taggerweight_b,taggerweight_c);
521 }
522 else{ //if here, we are in 1D mode
523 double taggerweight(-100);
524 if( getTaggerWeight( jet ,taggerweight, m_useCTag)!=CorrectionCode::Ok)
525 return acceptData;
526
527 return accept(pT, eta, taggerweight);
528 }
529}
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.

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

532{
533
534 asg::AcceptData acceptData (&m_acceptinfo);
535
536 if (! m_initialised) {
537 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
538 return acceptData;
539 }
540
541 eta = std::abs(eta);
542 if (! checkRange(pT, eta, acceptData))
543 return acceptData;
544
545 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
546 // Else, the initialization was incorrect and should be revisited
547 if(m_continuous){
548 for(size_t bin : m_tagger.benchmarks){
549 if(bin == 0){
550 throw std::logic_error("bin == 0 in the list of tagged bins. you should not be here. Wrong convention");
551 } else if ( bin == 1 ) {
552 if ( tag_weight < m_continuouscuts.at(bin-1) ) {
553 acceptData.setCutResult( "WorkingPoint", true );
554 }
555 } else if (bin > 1 && bin <= m_continuouscuts.size()){
556 if ( tag_weight > m_continuouscuts.at(bin-2) && tag_weight < m_continuouscuts.at(bin-1) ) {
557 acceptData.setCutResult( "WorkingPoint", true );
558 }
559 } else {
560 if ( tag_weight > m_continuouscuts.at(bin-2) ) {
561 acceptData.setCutResult( "WorkingPoint", true );
562 }
563 }
564 }
565 }
566 else{ //FixedCut
567 double cutvalue(DBL_MAX);
568 if( getCutValue(pT, cutvalue )!=CorrectionCode::Ok ){
569 return acceptData;
570 }
571
572 if ( tag_weight < cutvalue ){
573 return acceptData;
574 }
575
576 acceptData.setCutResult( "WorkingPoint", true );
577 }
578
579 // Return the result:
580 return acceptData;
581}
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 583 of file BTaggingSelectionTool.cxx.

584{
585 asg::AcceptData acceptData (&m_acceptinfo);
586
587 if (! m_initialised) {
588 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
589 return acceptData;
590 }
591
592 eta = std::abs(eta);
593
594 if (! checkRange(pT, eta, acceptData))
595 return acceptData;
596
597 for(auto bin : m_tagger.benchmarks){
598
599 ATH_MSG_DEBUG("bin" <<bin <<" taggerWeight_c "
600 <<taggerWeight_c <<" taggerWeight_b "
601 <<taggerWeight_b);
602
603 ATH_MSG_DEBUG(" c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
604 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
605 <<m_tagger.get2DCutValue(bin,2) <<" "
606 <<m_tagger.get2DCutValue(bin,3));
607
608 if (taggerWeight_c > m_tagger.get2DCutValue(bin,0) && //ctag low
609 taggerWeight_c <= m_tagger.get2DCutValue(bin,1) && //ctag max
610 taggerWeight_b > m_tagger.get2DCutValue(bin,2) && //btag low
611 taggerWeight_b <= m_tagger.get2DCutValue(bin,3) ) //btag max
612 {
613 acceptData.setCutResult( "WorkingPoint", true ); // IF we arrived here, the jet is tagged
614 break;
615 }
616 } //for loop
617
618 // Return the result:
619 return acceptData;
620}
#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 622 of file BTaggingSelectionTool.cxx.

623{
625 asg::AcceptData acceptData (&m_acceptinfo);
626 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)");
627 return acceptData;
628 } else {
629 return accept(pT, eta, pb, pc, pu, 0.);
630 }
631}

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

634 {
635 asg::AcceptData acceptData (&m_acceptinfo);
636
637 if (! m_initialised) {
638 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
639 return acceptData;
640 }
641
642 eta = std::abs(eta);
643 if (! checkRange(pT, eta, acceptData))
644 return acceptData;
645
646 // After initialization, either m_tagger.spline or m_tagger.constcut should be non-zero
647 // Else, the initialization was incorrect and should be revisited
648 double cutvalue(DBL_MAX);
649
650 if( getCutValue(pT, cutvalue)!=CorrectionCode::Ok){
651 return acceptData;
652 };
653
654 if(m_continuous2D){
655 double tagger_weight_b(-100);
656 double tagger_weight_c(-100);
657 if( ( getTaggerWeight(pb, pc, pu, tagger_weight_b, false, ptau)!=CorrectionCode::Ok) ||
658 ( getTaggerWeight(pb, pc, pu, tagger_weight_c, true, ptau)!=CorrectionCode::Ok) )
659 return acceptData;
660 return accept(pT, eta, tagger_weight_b, tagger_weight_c);
661 }
662 else{
663 double tagger_weight(-100);
664 if( getTaggerWeight(pb, pc, pu, tagger_weight, m_useCTag, ptau)!=CorrectionCode::Ok)
665 return acceptData;
666 if ( tagger_weight < cutvalue )
667 return acceptData;
668 }
669 //if you made it here, the jet is tagged
670 acceptData.setCutResult( "WorkingPoint", true );
671 return acceptData;
672 }

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

809{
810 // Do the |eta| cut:
811 if( std::abs(eta) > m_maxEta ) {
812 return false;
813 }
814 acceptData.setCutResult( "Eta", true );
815
816 // Do the pT cut:
817 ATH_MSG_VERBOSE( "Jet pT: " << pT );
818 if( pT < m_minPt ) {
819 return false;
820 }
821 acceptData.setCutResult( "Pt", true );
822
823 return true;
824}
#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 262 of file BTaggingSelectionTool.cxx.

262 {
263
264 TString cutname = OP;
265
266 //set the name
267 tagger.name = taggerName;
268
269 if ("FlatBEff"==cutname(0,8) || "HybBEff"==cutname(0,7) ){
270 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutprofile";
271 tagger.spline = dynamic_cast<TSpline3*> (m_inf->Get(cutname));
272 if (tagger.spline == nullptr){
273 ATH_MSG_ERROR( "Invalid operating point" );
274 return StatusCode::FAILURE;
275 }
276 tagger.constcut = nullptr;
277 }
278 else {
279 cutname = taggerName+"/"+m_jetAuthor+"/"+OP+"/cutvalue";
280 tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
281 if (tagger.constcut == nullptr){
282 ATH_MSG_ERROR( "Invalid operating point" );
283 return StatusCode::FAILURE;
284 }
285 tagger.spline = nullptr;
286 }
287
288 //retrieve the "fraction" used in the DL1 log likelihood from the CDI, if its not there, use the hard coded values
289 // (backwards compatibility)
291
292 double fraction_b = -1;
293 const TString basePath = taggerName + "/" + m_jetAuthor + "/" + OP;
294 TVector* fraction_b_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_b") );
295 if (fraction_b_data) {
296 fraction_b = (*fraction_b_data)(0);
297 }
298
299 TVector* fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction") );
300 if (!fraction_c_data) {
301 fraction_c_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_c") );
302 }
303 double fraction_c = -1;
304 if (fraction_c_data) {
305 fraction_c = (*fraction_c_data)(0);
306 } else{
307 if("DL1" ==taggerName){ fraction_c = 0.08; }
308 if("DL1mu" ==taggerName){ fraction_c = 0.08; }
309 if("DL1rnn" ==taggerName){ fraction_c = 0.03; }
310 else {
311 ATH_MSG_ERROR("Failed to retrieve fraction_c");
312 }
313 }
314
315 double fraction_tau = 0.;
316 double fraction_tau_cTag = 0.;
317 TVector* fraction_tau_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau") );
318 TVector* fraction_tau_cTag_data = dynamic_cast<TVector*>( m_inf->Get(basePath + "/fraction_tau_cTag") );
320 if( fraction_tau_data ) {
321 fraction_tau = fraction_tau_data[0](0);
322 }
323 if ( m_useCTag && !fraction_tau_cTag_data) {
324 ATH_MSG_ERROR("Runnint c-tagging WP, but failed to retrive fraction_tau_cTag");
325 return StatusCode::FAILURE;
326 }
327 fraction_tau_cTag = fraction_tau_cTag_data[0](0);
328
329 if (!fraction_tau_data && !fraction_tau_cTag){
330 // For all recent taggers GN2v01 or above, the tau fraction(s) should be saved in the CDI file and retrieved/set within the BTaggingSelectionTool
331 // Hence raising error and failure here as at least one of those fractions should not be a null pointer
332 ATH_MSG_ERROR("Tau-fraction(s) should have been retrieved for taggerName=" << taggerName << " but both fraction_tau_data and fraction_tau_cTag are null pointers");
333 return StatusCode::FAILURE;
334 }
335 }
336 tagger.fraction_b = fraction_b;
337 tagger.fraction_c = fraction_c;
338 tagger.fraction_tau = fraction_tau;
339 tagger.fraction_tau_cTag = fraction_tau_cTag;
340
341 delete fraction_b_data;
342 delete fraction_c_data;
343 delete fraction_tau_data;
344 delete fraction_tau_cTag_data;
345 }
346 return StatusCode::SUCCESS;
347}
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 826 of file BTaggingSelectionTool.cxx.

827{
828 cutval = DBL_MAX;
829
830 // flat cut for out of range pTs
831 if (pT>m_maxRangePt)
833
835
836 if (tagger.spline != nullptr && tagger.constcut == nullptr) {
837 pT = pT/1000.0;
838 double maxsplinept = tagger.spline->GetXmax();
839 if (pT>maxsplinept){ pT = maxsplinept; }
840 cutval = tagger.spline->Eval(pT);
841 }
842
843 else if (tagger.constcut != nullptr && tagger.spline == nullptr) {
844 cutval = tagger.constcut[0](0);
845 }
846 else{
847 ATH_MSG_ERROR( "Bad cut configuration!" );
849 }
850
851
852 ATH_MSG_VERBOSE( "Cut value " << cutval );
853
854 return CorrectionCode::Ok;
855}
#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 674 of file BTaggingSelectionTool.cxx.

674 {
675 // Check if this is a jet:
676
677
678 if( p->type() != xAOD::Type::Jet ) {
679 ATH_MSG_ERROR( "accept(...) Function received a non-jet" );
680 return -1;
681 }
682
683 // Cast it to a jet:
684 const xAOD::Jet* jet = dynamic_cast< const xAOD::Jet* >( p );
685 if( ! jet ) {
686 ATH_MSG_FATAL( "accept(...) Failed to cast particle to jet" );
687 return -1;
688 }
689
690 // Let the specific function do the work:
691 return getQuantile( *jet );
692}
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 694 of file BTaggingSelectionTool.cxx.

694 {
695 double pT = jet.pt();
696 double eta = std::abs( jet.eta() );
697 int quantile = -1;
698
699 if (m_continuous2D){
700 double tag_weight_b(-100.);
701 double tag_weight_c(-100.);
702 if ( (getTaggerWeight(jet, tag_weight_b, false) == CP::CorrectionCode::Error) ||
703 (getTaggerWeight(jet, tag_weight_c, true ) == CP::CorrectionCode::Error) ){
704 ATH_MSG_WARNING("getQuantile: Failed to retrieve tag weight for Continuous2D!");
705 return -1;
706 }
707 quantile = getQuantile(pT, eta, tag_weight_b, tag_weight_c );
708 }
709 else{
710 // Retrieve the tagger weight which was assigned to the jet
711 double tag_weight(-100.);
712 if (getTaggerWeight(jet, tag_weight, m_useCTag)==CorrectionCode::Error){
713 ATH_MSG_WARNING("getQuantile: Failed to retrieve "+m_taggerName+" weight!");
714 return -1;
715 }
716 ATH_MSG_VERBOSE( m_taggerName << " " << tag_weight);
717 quantile = getQuantile(pT, eta, tag_weight);
718 }
719 return quantile;
720}
#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 723 of file BTaggingSelectionTool.cxx.

724{
725 if (! m_initialised) {
726 ATH_MSG_ERROR("BTaggingSelectionTool has not been initialised");
727 }
729 // Cheatsheet:
730 // With n WPs, (from highest to lowest) A1 , A2, A3, ..., An
731 // return -1 if not in b-tagging acceptance
732 // return 1 if between 100% and A1 (untagged)
733 // return 2 if between A1 and A2 (tagged at the A1 WP)
734 // return 3 if between A2 and A3 (tagged at the A2 WP)
735 // ...
736 // return n if between An-1 and An (tagged at the An-1 WP)
737 // return n+1 if between An and 0% (tagged at the An WP)
739
740 int bin_index = -1;
741
742 // First, check if the jet is in acceptance
743 asg::AcceptData acceptData (&m_acceptinfo);
744 if (! checkRange(pT, eta,acceptData)) {
745 return bin_index;
746 }
747
748 // Now we need to check each threshold in the PCBT vector
749 // and return the maximum WP bin index (1,2,...,n).
750 // Instead of checking low<tag_weight<high for each bin,
751 // we simply check tag_weight<high and therefore range
752 // from vector indices 1 to vector.size()
753 bin_index = 1; // setting the ones that pass selection you have default as 1
754 for (std::size_t i=0; i<m_continuouscuts.size(); i++) {
755 if ( tag_weight > m_continuouscuts.at(i) ) {
756 bin_index++;
757 } else {
758 break;
759 }
760 }
761 return bin_index;
762}

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

765{
775
776 //More details here: https://indico.cern.ch/event/1116952/#4-mr49953-implements-the-conti
777
778 ATH_MSG_DEBUG("inside getQuantile 2D " <<pT <<" " <<eta <<" " <<tag_weight_b <<" " <<tag_weight_c);
779 int bin_index(-1);
780
781 asg::AcceptData acceptData (&m_acceptinfo);
782 if (! checkRange(pT, eta, acceptData)) return bin_index;
783
784 int ncuts = m_tagger.cuts2D->GetNrows();
785 ATH_MSG_VERBOSE("ncuts: " <<ncuts);
786
787 //loop over all the cuts
788 for(int i = 0; i < ncuts ; i++){
789 double c_cut_low = m_tagger.get2DCutValue(i,0);
790 double c_cut_hig = m_tagger.get2DCutValue(i,1);
791 double b_cut_low = m_tagger.get2DCutValue(i,2);
792 double b_cut_hig = m_tagger.get2DCutValue(i,3);
793
794 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);
795 if (tag_weight_c > c_cut_low &&
796 tag_weight_c <= c_cut_hig &&
797 tag_weight_b > b_cut_low &&
798 tag_weight_b <= b_cut_hig){
799 bin_index = i;
800 break;
801 }
802 }
803
804 ATH_MSG_VERBOSE("bin_index " <<bin_index);
805 return bin_index;
806}

◆ getTaggerWeight() [1/5]

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

Implements IBTaggingSelectionTool.

Definition at line 349 of file BTaggingSelectionTool.cxx.

349 {
350 return getTaggerWeight(jet, tagweight, m_useCTag);
351}

◆ getTaggerWeight() [2/5]

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

Implements IBTaggingSelectionTool.

Definition at line 353 of file BTaggingSelectionTool.cxx.

353 {
354
355 std::string taggerName = m_tagger.name;
356 // following taggerName change is needed given different name is used for GN2v00 in derivation and in CDI
357 if (taggerName == "GN2v00LegacyWP" || taggerName == "GN2v00NewAliasWP"){
358 taggerName = "GN2v00";
359 }
360
361 tagweight = -100.;
362
363 if(!m_continuous2D && (getCTagW != m_useCTag) ){
364 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
366 }
367
369
371
372 if ((!btag) || (!btag->MVx_discriminant(taggerName, tagweight))){
374 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
376 }else{
377 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
378 return CorrectionCode::Ok;
379 }
380 }
381 ATH_MSG_VERBOSE( taggerName << " " << tagweight );
382 return CorrectionCode::Ok;
383 } //MV2
384 else{
385 //DL1r or DL1 or GN2v01
386 double tagger_pb(-10.);
387 double tagger_pc(-10.);
388 double tagger_pu(-10.);
389 double tagger_ptau(0.);
390
391 const SG::AuxElement* btagInfo = &jet;
394
395 if(!btagInfo){
397 ATH_MSG_ERROR("Failed to retrieve "+taggerName+" weight!");
399 }else{
400 ATH_MSG_WARNING("Failed to retrieve "+taggerName+" weight!");
401 return CorrectionCode::Ok;
402 }
403 }
404
405 tagger_pb = m_accessor_pb(*btagInfo);
406 tagger_pc = m_accessor_pc(*btagInfo);
407 tagger_pu = m_accessor_pu(*btagInfo);
409 tagger_ptau = m_accessor_ptau(*btagInfo);
410 }
411
412 return getTaggerWeight(tagger_pb, tagger_pc, tagger_pu, tagweight, getCTagW, tagger_ptau);
413
414 }
415
416 //if we got here the tagger name is not configured properly
417 ATH_MSG_ERROR("BTaggingSelectionTool doesn't support tagger: "+m_taggerName);
419
420}
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 422 of file BTaggingSelectionTool.cxx.

422 {
424 ATH_MSG_ERROR("For GN2v01 or newer taggers, there is a new tau class in the NN output. Please update your getTaggerWeight() to getTaggerWeight( double pb, double pc, double pu, double & tagweight, double ptau)");
426 } else {
427 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, 0.);
428 }
429}

◆ getTaggerWeight() [4/5]

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

Implements IBTaggingSelectionTool.

Definition at line 431 of file BTaggingSelectionTool.cxx.

431 {
432 return getTaggerWeight(pb, pc, pu, tagweight, m_useCTag, ptau);
433}

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

435 {
436
437 std::string taggerName = m_tagger.name;
438
439 if(!m_continuous2D && (getCTagW != m_useCTag) ){
440 ATH_MSG_ERROR("Difference between initialisation and getTaggerWeight request! useCTagging property set to " <<m_useCTag <<" while getTaggerWeight use c-tag is set to " <<getCTagW <<".");
442 }
443
444 tagweight = -100.;
446
447 bool valid_input = (!std::isnan(pu) && pb>=0 && pc>=0 && pu>=0 && ptau>=0);
448
449 if (!valid_input){
451 ATH_MSG_ERROR("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
453 }else{
454 ATH_MSG_WARNING("Invalid inputs for "+taggerName+" pb " << pb << " pc " << pc << " pu " << pu << " ptau " << ptau << " ");
455 return CorrectionCode::Ok;
456 }
457 }
458
459 if(getCTagW){
460 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) );
461 }
462 else{
463 tagweight = log(pb / (m_tagger.fraction_c * pc + (1. - m_tagger.fraction_c - m_tagger.fraction_tau) * pu + m_tagger.fraction_tau * ptau) );
464 }
465
466 ATH_MSG_VERBOSE( "pb " << pb );
467 ATH_MSG_VERBOSE( "pc " << pc );
468 ATH_MSG_VERBOSE( "pu " << pu );
469 ATH_MSG_VERBOSE( "ptau" << ptau );
470 ATH_MSG_VERBOSE( "tagweight " << tagweight );
471
472 return CorrectionCode::Ok;
473 }
474
475 //if we got here the tagger name is not configured properly
476 ATH_MSG_ERROR("this call to getTaggerWeight only works for DL1/GNx taggers");
478
479}

◆ 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 // Online taggers i.e. b-jet trigger taggers
77 // may not have the same set of probabilities to be retrieved
78 // hence initializing this boolean
79 // In the selection tools the online taggers information should be retrieved
80 // either for online taggers, those taggers are called
81 // "Online{TaggerNameOnline}"
82 // or for the conditional online tagger which are called
83 // "ConditionalOnline{TaggerNameOnline}GivenOffline{TaggerNameOffline}WP{WorkingPoint}"
84 // as in this case the tagger to be used in the online tagger.
85 //
86 // NB: for the taggers called ConditionalOffline{TaggerNameOffline}GivenOnline{TaggerNameOnline}WP{WorkingPoint}
87 // i.e. tagger whose name starts with "ConditionalOffline"
88 // then tagger to be used is the offline tagger and NOT the online tagger
89 m_usingOnlineTagger = (m_taggerName.value().starts_with("Online") || m_taggerName.value().contains("ConditionalOnline"));
90
91 //set taggerEnum to avid string comparison:
93
94 // For all recent taggers (GN2v01 or above), the tau fraction(s) should be saved in the CDI file and retrieved/set within the BTaggingSelectionTool
95 // This boolean allows the tool knowing if we expect tau fractions or no for the tagger the user wants to use
96 // NB: all the online taggers so far (including the GN2 online tagger) do NOT have tau probabilities
98
99 // Change the minPt cut if the user didn't touch it
100 if (m_minPt < 0){
101 ATH_MSG_ERROR( "Tagger: "+m_taggerName+" and Jet Collection : "+m_jetAuthor+" do not have a minimum jet pT cut set.");
102 return StatusCode::FAILURE;
103 }
104
105 // Operating point reading
106 TString cutname = m_OP.value();
107 m_continuous = false;
108 m_continuous2D = false;
109
110 if(cutname.Contains("Continuous2D")){
111 ATH_MSG_INFO("Working with Continuous2D WP.");
112 m_continuous = true;
113 m_continuous2D = true;
114 m_useCTag = false; //important for backward compatibility in getTaggerWeight methods.
115 cutname = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/cutvalue";
116 m_tagger.name = m_taggerName;
117 TMatrixD* matrix = dynamic_cast<TMatrixD*> (m_inf->Get(cutname));
118 m_tagger.cuts2D = matrix;
119
120 for (int bin = 0; bin < m_tagger.cuts2D->GetNrows(); bin++)
121 ATH_MSG_DEBUG("INITIALIZATION c-cuts : " <<m_tagger.get2DCutValue(bin,0) <<" "
122 <<m_tagger.get2DCutValue(bin,1) <<" b-cuts : "
123 <<m_tagger.get2DCutValue(bin,2) <<" "
124 <<m_tagger.get2DCutValue(bin,3));
125
126 if (m_tagger.cuts2D == nullptr){
127 ATH_MSG_ERROR( "Invalid operating point" );
128 return StatusCode::FAILURE;
129 }
130
131 m_tagger.spline = nullptr;
132
133 TString fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_b";
134 TVector *fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
135 if(fraction_data!=nullptr){
136 m_tagger.fraction_b = fraction_data[0](0);
137 }
138 else{
139 ATH_MSG_ERROR("Tagger fraction_b in Continuous2D WP not available");
140 return StatusCode::FAILURE;
141 }
142
143 //now the c-fraction:
144 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_c";
145 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
146 if(fraction_data!=nullptr){
147 m_tagger.fraction_c = fraction_data[0](0);}
148 else{
149 ATH_MSG_ERROR("Tagger fraction_c in Continuous2D WP not available");
150 return StatusCode::FAILURE;
151 }
152 //now the tau-fraction if the tagger is GN2* or GN3*:
154 fraction_data_name = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau";
155 TString fraction_data_name_cTag = m_taggerName+"/"+m_jetAuthor+"/Continuous2D/fraction_tau_cTag";
156 fraction_data = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name));
157 TVector *fraction_data_cTag = dynamic_cast<TVector*> (m_inf->Get(fraction_data_name_cTag));
158 if(fraction_data!=nullptr){
159 m_tagger.fraction_tau = fraction_data[0](0);
160 }else{
161 ATH_MSG_ERROR("Tagger fraction_tau in Continuous2D WP not available");
162 return StatusCode::FAILURE;
163 }
164 if(fraction_data_cTag!=nullptr){
165 m_tagger.fraction_tau_cTag = fraction_data_cTag[0](0);
166 }else{
167 ATH_MSG_ERROR("Tagger fraction_tau_cTag in Continuous2D WP not available");
168 return StatusCode::FAILURE;
169 }
170 delete fraction_data_cTag;
171 }
172 delete fraction_data;
173 } //Continuous2D
174 else if ("Continuous"==cutname(0,10)){ // For continuous tagging load all flat-cut WPs
175 if(m_useCTag)
176 ATH_MSG_WARNING( "Running in Continuous WP and using 1D c-tagging");
177 m_continuous = true;
178
179 std::string subDirName = m_taggerName + "/" + m_jetAuthor;
180 // Get directory containing the cuts information
181 TDirectoryFile *tmpDir = dynamic_cast<TDirectoryFile*>( m_inf->Get(subDirName.c_str()) );
182 if (!tmpDir){
183 // Raise error if could not retrieve subdirectory
184 ATH_MSG_ERROR( "CDI file does not contain sub-directory: " << subDirName );
185 return StatusCode::FAILURE;
186 }
187
188 // Now retrieve the name of the b-tagging fixed cut efficiency working points
189 static const std::string fixedBCutPrefix = "FixedCutBEff_";
190 std::vector<std::string> workingpoints;
191
192 // Loop over keys in the sub directory and select the ones corresponding to fixed cuts
193 TIter next(tmpDir->GetListOfKeys());
194 TKey *key;
195 while ((key = (TKey*)next())) {
196 std::string keyName = key->GetName();
197 // Check if key begins with prefix in that case it's one of the working point
198 // Also make sure the key is not already in the vector as
199 // the list of keys from GetListOfKeys() can contain several times the same name
200 // because there can be several cycle number per objects
201 // since here we check the entry is not already in the vector it's fine
202 // See
203 // https://root-forum.cern.ch/t/tkey-tobject-and-getlistofkeys-for-only-newest-ttrees/25928/3
204 // https://root-forum.cern.ch/t/tkey-tobject-and-getlistofkeys-for-only-newest-ttrees/25928/7
205 if (keyName.starts_with(fixedBCutPrefix) &&
206 std::find(workingpoints.begin(), workingpoints.end(), keyName) == workingpoints.end()){
207 // Add efficiency working point to the vector
208 workingpoints.push_back( keyName );
209 }
210 }
211
212 // After having retrieved all b-tagging working points
213 // Sort vector then set descending order i.e. loosest working point first
214 std::sort(workingpoints.begin(), workingpoints.end());
215 std::reverse(workingpoints.begin(), workingpoints.end()); // put in descending order
216 for(const std::string& wp : workingpoints){
217 cutname = subDirName + "/" + wp + "/cutvalue";
218 m_tagger.constcut = dynamic_cast<TVector*> (m_inf->Get(cutname));
219 if (m_tagger.constcut != nullptr) {
220 m_continuouscuts.push_back(m_tagger.constcut[0](0));
221 } else {
222 ATH_MSG_ERROR( "Continuous tagging is trying to use an invalid operating point: " + wp );
223 return StatusCode::FAILURE;
224 }
225 }
226
227 //The WP is not important. This is just to retrieve the c-fraction.
229
230 } else {
231 if(m_useCTag){
232 ATH_MSG_WARNING( "Running in FixedCut WP for c-tagging, make sure to use b-veto to select c-tagged jet properly.");
233 }
235 }
236
237 //set the accept working points, jets in these pseudo-continuous bins will be accepted
238 if(m_continuous){
239 std::vector<std::string> tag_benchmarks_names = split(m_ContinuousBenchmarks, ',');
240 std::vector<int> tag_benchmarks;
241 for (const std::string& tagbin : tag_benchmarks_names){
242 tag_benchmarks.push_back(std::atoi(tagbin.c_str()));
243 ATH_MSG_INFO("adding " <<tag_benchmarks.back() <<" as tagged bin ");
244 }
245 m_tagger.benchmarks = tag_benchmarks;
246 }
247
248 m_inf->Close();
249
250 m_acceptinfo.addCut( "Eta", "Selection of jets according to their pseudorapidity" );
251 m_acceptinfo.addCut( "Pt", "Selection of jets according to their transverse momentum" );
252 m_acceptinfo.addCut( "WorkingPoint", "Working point for flavour-tagging of jets according to their b-tagging weight" );
253
254 m_accessor_pb = SG::ConstAccessor<float>(m_taggerName+ "_pb");
255 m_accessor_pc = SG::ConstAccessor<float>(m_taggerName+ "_pc");
256 m_accessor_pu = SG::ConstAccessor<float>(m_taggerName+ "_pu");
257 m_accessor_ptau = SG::ConstAccessor<float>(m_taggerName+ "_ptau");
258
259 return StatusCode::SUCCESS;
260}
#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)
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
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()

void asg::AsgTool::print ( ) const
virtualinherited

Print the state of the tool.

Implements asg::IAsgTool.

Reimplemented in AsgHelloTool, HI::HIPileupTool, JetFromPseudojet, JetPileupLabelingTool, JetPseudojetRetriever, JetSubStructureMomentToolsBase, JetTruthLabelingTool, and KtDeltaRTool.

Definition at line 131 of file AsgTool.cxx.

131 {
132
133 ATH_MSG_INFO( "AsgTool " << name() << " @ " << this );
134 return;
135 }

◆ renounce()

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

Definition at line 368 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ SetTaggerEnum()

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

Definition at line 134 of file BTaggingSelectionTool.h.

134 {
135
136 // For conditional taggers (related to b-jet trigger taggers)
137 // they have names such as
138 // ConditionalOnline{TaggerNameOnline}GivenOffline{TaggerNameOffline}WP{WorkingPoint}
139 // or
140 // ConditionalOffline{TaggerNameOffline}GivenOnline{TaggerNameOnline}WP{WorkingPoint}
141 // e.g.
142 // ConditionalOfflineGN2v01GivenOnlineDL1dWP60
143 // ConditionalOfflineGN2v01GivenOnlineMV2c10WP70
144 // ConditionalOnlineDL1dGivenOfflineGN2v01WP85
145 // In both cases they are of the form Conditional[Online|Offline]XXTaggerGiven[Offline|Online]YYTagger
146 // and the tagger to be used is the XXTagger
147 // hence this special checks for those taggers
148 const std::string conditionalOnline = "ConditionalOnline";
149 const std::string conditionalOffline = "ConditionalOffline";
150 const std::vector<std::string> vectMatchingTaggerNames({ "MV2c10", "DL1", "GN1", "GN2", "GN3" });
151
152 bool isConditionalTagger = taggerName.contains("Conditional");
153
154 for (const std::string & matchingTaggerName: vectMatchingTaggerNames){
155 bool foundMatchingName = false;
156 if (isConditionalTagger){
157 // If the tagger is a conditional tagger
158 // Check if name contains ConditionalOnline{Tagger} or ConditionalOffline{Tagger}
159 if (taggerName.contains(conditionalOnline+matchingTaggerName) ||
160 taggerName.contains(conditionalOffline+matchingTaggerName)) {
161 foundMatchingName = true;
162 }
163 }
164 else if (taggerName.contains(matchingTaggerName)){
165 // In that case it is NOT a conditional tagger
166 // check if name simply contains the tagger
167 foundMatchingName = true;
168 }
169
170 // If no matching found then the tagger does not corresponds to the the current matchingTaggerName
171 // On the other hand if matching was found
172 // it means the tagger name was matched with the current matchingTaggerName
173 if (foundMatchingName){
174 if (matchingTaggerName == "MV2c10") { return Tagger::MV2c10; }
175 else if (matchingTaggerName == "DL1" ) { return Tagger::DL1; }
176 else if (matchingTaggerName == "GN1" ) { return Tagger::GN1; }
177 else if (matchingTaggerName == "GN2" ) { return Tagger::GN2; }
178 else if (matchingTaggerName == "GN3" ) { return Tagger::GN3; }
179 else {
180 ATH_MSG_ERROR("Tagger name NOT supported: taggerName=" << taggerName);
181 return Tagger::UNKNOWN;
182 }
183 }
184 }
185
186 // If arriving here no matching was found raise an error
187 ATH_MSG_ERROR("Tagger name NOT supported: taggerName=" << taggerName);
188 return Tagger::UNKNOWN;
189 };

◆ split()

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

Definition at line 857 of file BTaggingSelectionTool.cxx.

857 {
858 std::vector<std::string> v;
859 std::istringstream buf(input);
860 for(std::string token; std::getline(buf, token, delimiter); )
861 v.push_back(token);
862 return v;
863}
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 >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 298 of file AthCommonDataStore.h.

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

Member Data Documentation

◆ m_acceptinfo

asg::AcceptInfo BTaggingSelectionTool::m_acceptinfo
private

Object used to store the last decision.

Definition at line 84 of file BTaggingSelectionTool.h.

◆ m_accessor_pb

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

Definition at line 105 of file BTaggingSelectionTool.h.

◆ m_accessor_pc

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

Definition at line 106 of file BTaggingSelectionTool.h.

◆ m_accessor_ptau

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

Definition at line 108 of file BTaggingSelectionTool.h.

◆ m_accessor_pu

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

Definition at line 107 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 94 of file BTaggingSelectionTool.h.

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

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

96{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 378 of file AthCommonDataStore.h.

◆ m_inf

TFile* BTaggingSelectionTool::m_inf {}
private

Definition at line 102 of file BTaggingSelectionTool.h.

102{};

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

93{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 87 of file BTaggingSelectionTool.h.

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

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

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

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

100{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 129 of file BTaggingSelectionTool.h.

◆ m_taggerEnum

Tagger BTaggingSelectionTool::m_taggerEnum {UNKNOWN}
private

Definition at line 132 of file BTaggingSelectionTool.h.

132{UNKNOWN};

◆ m_taggerName

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

Definition at line 91 of file BTaggingSelectionTool.h.

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

◆ m_taggerWithTauFractions

bool BTaggingSelectionTool::m_taggerWithTauFractions = true
private

Definition at line 81 of file BTaggingSelectionTool.h.

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

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

◆ m_usingOnlineTagger

bool BTaggingSelectionTool::m_usingOnlineTagger = false
private

Definition at line 77 of file BTaggingSelectionTool.h.

◆ m_varHandleArraysDeclared

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

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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