ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
top::FlavorTaggingCPTools Class Referencefinal

#include <TopFlavorTaggingCPTools.h>

Inheritance diagram for top::FlavorTaggingCPTools:
Collaboration diagram for top::FlavorTaggingCPTools:

Public Member Functions

 FlavorTaggingCPTools (const std::string &name)
 
virtual ~FlavorTaggingCPTools ()
 
StatusCode initialize ()
 Dummy implementation of the initialisation function. More...
 
virtual void print () const
 Print the state of the tool. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

StatusCode setupBtagSelectionTool (const std::pair< std::string, std::string > &btag_algo_WP, const std::string &jetCollection, double jetPtCut, double jetEtaCut, bool trackJets=false)
 Setup BTaggingSelectionTool for a given WP. More...
 
StatusCode setupBtagEfficiencyTool (const std::pair< std::string, std::string > &btag_algo_WP, const std::string &jetCollection, double jetPtCut, bool trackJets=false)
 
std::string erasePV0fromJetsName (std::string jetCollectionName)
 
StatusCode checkExcludedSysts (BTaggingEfficiencyTool *, const std::string &)
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

std::shared_ptr< top::TopConfigm_config
 
std::string m_cdi_file
 
std::string m_calib_file_path
 
std::string m_excluded_systs
 
std::string m_efficiency_maps
 
const std::vector< std::string > m_jet_flavors
 
ToolHandleArray< IBTaggingEfficiencyToolm_btagging_efficiency_tools
 
ToolHandleArray< IBTaggingSelectionToolm_btagging_selection_tools
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 30 of file TopFlavorTaggingCPTools.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ FlavorTaggingCPTools()

top::FlavorTaggingCPTools::FlavorTaggingCPTools ( const std::string &  name)
explicit

Definition at line 24 of file TopFlavorTaggingCPTools.cxx.

24  :
26  declareProperty("config", m_config);
27  }

◆ ~FlavorTaggingCPTools()

virtual top::FlavorTaggingCPTools::~FlavorTaggingCPTools ( )
inlinevirtual

Definition at line 33 of file TopFlavorTaggingCPTools.h.

33 {}

Member Function Documentation

◆ checkExcludedSysts()

StatusCode top::FlavorTaggingCPTools::checkExcludedSysts ( BTaggingEfficiencyTool btageff,
const std::string &  excludedSysts 
)
private

Definition at line 207 of file TopFlavorTaggingCPTools.cxx.

207  {
208  // We pass the pointer to the btagging efficiency tool which is being created and also the excludedSysts string
209  // which will be used
210  // If the string is empty, then nothing to check
211  if (excludedSysts == "") return StatusCode::SUCCESS;
212 
213  // Split by a semi-colon delimiter and then check the individual syst strings against the list from the CDI
214  std::vector<std::string> listOfExcludedSysts;
215  top::tokenize(excludedSysts, listOfExcludedSysts, ";");
216  ATH_MSG_INFO(" ------------------------------------------------ ");
217  ATH_MSG_INFO(" ------------- EXPERIMENTAL FEATURE ------------- ");
218  ATH_MSG_INFO(" ------ Please provide feedback to TopReco ------ ");
219  ATH_MSG_INFO(" ------------- EXPERIMENTAL FEATURE ------------- ");
220  ATH_MSG_INFO(" ------------------------------------------------ ");
221  ATH_MSG_INFO(" AnalysisTop - Checking excludedSysts for flavour tagging EV");
222  ATH_MSG_INFO(" This has been split on the semi-colon delimiter to find...");
223  for (const auto& s : listOfExcludedSysts) ATH_MSG_INFO("... " + s);
224  // Get the map(string, vector<string>) from the CDI tool
225  // Don't care about the flavours (this will be handled in the CDI)
226  std::vector<std::string> listOfScaleFactorSystematics;
227  for (auto flavour : btageff->listScaleFactorSystematics(false)) {
228  for (auto sys : flavour.second) {
229  listOfScaleFactorSystematics.push_back(sys);
230  }
231  }
232  // Make this a unique set and then we need to check that all systematics provided by the user are expected by the
233  // CDI
234  std::set<std::string> setOfExcludedSysts, setOfScaleFactorSystematics;
235 
236  for (auto sys : listOfExcludedSysts) {
237  setOfExcludedSysts.insert(sys);
238  }
239 
240  for (auto sys : listOfScaleFactorSystematics) {
241  setOfScaleFactorSystematics.insert(sys);
242  }
243 
244  //
245  std::vector<std::string> unionOfSystematics;
246  std::set_intersection(setOfExcludedSysts.begin(), setOfExcludedSysts.end(),
247  setOfScaleFactorSystematics.begin(), setOfScaleFactorSystematics.end(),
248  std::back_inserter(unionOfSystematics));
249  // Check we have the same systematics listed in unionOfSystematics
250  if (unionOfSystematics.size() != listOfExcludedSysts.size()) {
251  ATH_MSG_WARNING("Have not found all systematics listed to be excluded from b-tagging eigenvector method");
252  ATH_MSG_INFO("Permitted values are...");
253  for (const auto& sys : setOfScaleFactorSystematics) {
254  ATH_MSG_INFO(" ... " + sys);
255  }
256  return StatusCode::FAILURE;
257  } else {
258  ATH_MSG_INFO(" Summary of EV impact ");
259  for (const auto& sysRemove : listOfExcludedSysts) {
260  std::string flavourAffected = "";
261  for (auto flavour : btageff->listScaleFactorSystematics(false)) {
262  for (auto sysCDI : flavour.second) {
263  if (sysRemove == sysCDI) flavourAffected += flavour.first;
264  }
265  }
266  ATH_MSG_INFO(" ... " + sysRemove + " -> Removed from calibration(s) : [" + flavourAffected + "]");
267  }
268  ATH_MSG_INFO(" These will be dynamically matched to systematic tree names (if available)");
269  ATH_MSG_INFO(" All systematics are accepted by CDI file ");
270  }
271  // We have passed all the tests so now we store the systematics removed from the EV method and use a mapping to
272  // ASG/AT naming and return
273  ATH_MSG_INFO(" ------------------------------------------------ ");
274  return StatusCode::SUCCESS;
275  }

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

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

95 { return m_detStore; }

◆ erasePV0fromJetsName()

std::string top::FlavorTaggingCPTools::erasePV0fromJetsName ( std::string  jetCollectionName)
private

Definition at line 199 of file TopFlavorTaggingCPTools.cxx.

199  {
200  const std::string pv0 = "PV0";
201  auto it = jetCollectionName.find(pv0);
202  if (it == std::string::npos) return jetCollectionName;
203  jetCollectionName.erase(it, pv0.length());
204  return jetCollectionName;
205  }

◆ evtStore() [1/2]

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.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ 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

◆ getKey()

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

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

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

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

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

Definition at line 119 of file AsgTool.cxx.

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

◆ getName()

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

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

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

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

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

Definition at line 106 of file AsgTool.cxx.

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

◆ getProperty()

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

Get one of the tool's properties.

◆ initialize()

StatusCode top::FlavorTaggingCPTools::initialize ( )
virtual

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 29 of file TopFlavorTaggingCPTools.cxx.

29  {
30  ATH_MSG_INFO("top::FlavorTaggingCPTools initialize...");
31 
32  if (m_config->isTruthDxAOD()) {
33  ATH_MSG_INFO("top::FlavorTaggingCPTools: no need to initialise anything on truth DxAOD");
34  return StatusCode::SUCCESS;
35  }
36 
37  if (!m_config->useJets()) {
38  ATH_MSG_INFO("top::FlavorTaggingCPTools: no need to initialise anything since not using jets");
39  return StatusCode::SUCCESS;
40  }
41 
42  // see https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/BTagRecommendationsRelease22#Calibration_pre_recommendations
43  static const std::string cdi_file_default_MC20 =
44  "xAODBTaggingEfficiency/13TeV/2023-22-13TeV-MC20-CDI-2023-09-13_v1.root ";
45  static const std::string cdi_file_default_MC21 =
46  "xAODBTaggingEfficiency/13p6TeV/2023-22-13TeV-MC21-CDI-2023-09-13_v1.root";
47 
48  if (m_config->bTaggingCDIPath() != "Default") {
49  if (m_config->isRun3()) {
50  if (m_config->bTaggingCDIPath() != cdi_file_default_MC21) {
51  m_config->setPrintCDIpathWarning(true);
52  }
53  }
54  else {
55  if (m_config->bTaggingCDIPath() != cdi_file_default_MC20) {
56  m_config->setPrintCDIpathWarning(true);
57  }
58  }
59  m_cdi_file = m_config->bTaggingCDIPath();
60  } else {
61  if (m_config->isRun3()) {
62  m_cdi_file = cdi_file_default_MC21;
63  }
64  else {
65  m_cdi_file = cdi_file_default_MC20;
66  }
67  }
68  // This ordering needs to match the indexing in TDP (for missing cases, we use default which gives a MC/MC of 1 as
69  // its the same as the eff used in the calibration
70  // Pythia6;Herwigpp;Pythia8;Sherpa(2.2.1);Sherpa(2.1);aMC@NLO+Pythia8;Herwig7.1.3;Sherpa228;Sherpa2210;Herwigpp721;Sherpa2212;aMC@NLO+Herwig7
71  // based of https://twiki.cern.ch/twiki/bin/view/AtlasProtected/BTagRecommendationsRelease22
72 
73  // Run2
74  m_efficiency_maps = "default;default;410470;410250;default;410464;411233;default;700122;600666;700660;412116";
75  // Run3
76  if (m_config->isRun3()) {
77  m_efficiency_maps = "default;default;601229;doesnotexist;doesnotexist;doesnotexist;601414;doesnotexist;doesnotexist;doesnotexist;700660;doesnotexist";
78  }
79 
80  const std::string caloJets_collection = m_config->sgKeyJets();
81  const std::string trackJets_collection = m_config->sgKeyTrackJets();
82 
84  m_excluded_systs = m_config->bTagSystsExcludedFromEV() == "none" ? "" : m_config->bTagSystsExcludedFromEV();
85 
86  //------------------------------------------------------------
87  // Loop through all the different working points we have and create a
88  // BTaggingSelectionTool and corresponding BTaggingEfficiencyTool if the working point is calibrated.
89  //------------------------------------------------------------
90 
91  // initialize selection tools, for both calibrated and uncalibrated WPs
92  for (const auto& TaggerBtagWP : m_config->bTagAlgoWP()) {
93  top::check(setupBtagSelectionTool(TaggerBtagWP, m_config->sgKeyJets(), m_config->jetPtcut(), m_config->jetEtacut()),
94  "Failed to initialize btag selection tool");
95  }
96  for (const auto& TaggerBtagWP : m_config->bTagAlgoWP_calib()) {
97  top::check(setupBtagEfficiencyTool(TaggerBtagWP, m_config->sgKeyJets(), m_config->jetPtcut()),
98  "Failed to initialize btag selection tool");
99  }
100 
101  if (m_config->useTrackJets()) {
102  for (const auto& TaggerBtagWP : m_config->bTagAlgoWP_trkJet()) {
103  top::check(setupBtagSelectionTool(TaggerBtagWP, m_config->sgKeyTrackJets(), m_config->trackJetPtcut(), m_config->trackJetEtacut(), true),
104  "Failed to initialize btag selection tool");
105  }
106  for (const auto& TaggerBtagWP : m_config->bTagAlgoWP_calib_trkJet()) {
107  top::check(setupBtagEfficiencyTool(TaggerBtagWP, m_config->sgKeyTrackJets(), m_config->trackJetPtcut(), true),
108  "Failed to initialize btag selection tool");
109  }
110  }
111 
112  return StatusCode::SUCCESS;
113  }

◆ 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() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

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

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

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

◆ 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

◆ 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();
383  PBASE::renounce (h);
384  }

◆ 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  {
365  handlesArray.renounce();
366  }

◆ setupBtagEfficiencyTool()

StatusCode top::FlavorTaggingCPTools::setupBtagEfficiencyTool ( const std::pair< std::string, std::string > &  btag_algo_WP,
const std::string &  jetCollection,
double  jetPtCut,
bool  trackJets = false 
)
private

Definition at line 151 of file TopFlavorTaggingCPTools.cxx.

154  {
155  const std::string bTagWPName = btag_algo_WP.first + "_" + btag_algo_WP.second;
156  std::string btageff_tool_name = "BTaggingEfficiencyTool_" + bTagWPName + "_" + jetCollection;
157  // due to a bug in the CDI files, track jets names are missing PV0 in the name
158  const std::string jetAuthor = (trackJets ? erasePV0fromJetsName(jetCollection) : jetCollection);
159 
160  BTaggingEfficiencyTool* btageff = new BTaggingEfficiencyTool(btageff_tool_name);
161  top::check(btageff->setProperty("TaggerName", btag_algo_WP.first),
162  "Failed to set b-tagging TaggerName");
163  top::check(btageff->setProperty("OperatingPoint", btag_algo_WP.second),
164  "Failed to set b-tagging OperatingPoint");
165  top::check(btageff->setProperty("JetAuthor", jetAuthor),
166  "Failed to set b-tagging JetAuthor");
167  top::check(btageff->setProperty("MinPt", jetPtCut),
168  "Failed to set b-tagging selection tool MinPt");
169  top::check(btageff->setProperty("EfficiencyFileName", m_calib_file_path),
170  "Failed to set path to b-tagging CDI file");
171  top::check(btageff->setProperty("ScaleFactorFileName", m_calib_file_path),
172  "Failed to set path to b-tagging CDI file");
173  top::check(btageff->setProperty("ScaleFactorBCalibration", m_config->bTaggingCalibration_B()),
174  "Failed to set b-tagging calibration (B): " + m_config->bTaggingCalibration_B());
175  top::check(btageff->setProperty("ScaleFactorCCalibration", m_config->bTaggingCalibration_C()),
176  "Failed to set b-tagging calibration (C): " + m_config->bTaggingCalibration_C());
177  // using same calibration for T as for C
178  top::check(btageff->setProperty("ScaleFactorTCalibration", m_config->bTaggingCalibration_C()),
179  "Failed to set b-tagging calibration (T): " + m_config->bTaggingCalibration_C());
180  top::check(btageff->setProperty("ScaleFactorLightCalibration", m_config->bTaggingCalibration_Light()),
181  "Failed to set b-tagging calibration (Light): " + m_config->bTaggingCalibration_Light());
182  for (auto jet_flav : m_jet_flavors) {
183  // 09/02/18 IC: The pseudo-continuous does not have MC/MC SF so we need to only apply default for this case
184  // 08/05/18 Francesco La Ruffa: The pseudo-continuous has now its own MC/MC SFs, no needed to set default
185  top::check(btageff->setProperty("Efficiency" + jet_flav + "Calibrations", m_efficiency_maps),
186  "Failed to set " + jet_flav + "-calibrations efficiency maps");
187  }
188  top::check(btageff->setProperty("ExcludeFromEigenVectorTreatment", m_excluded_systs),
189  "Failed to set b-tagging systematics to exclude from EV treatment");
190  top::check(btageff->initialize(), "Failed to initialize " + bTagWPName);
191  // Check the excludedSysts - Cannot check before the tool is initialised
192  if (this->checkExcludedSysts(btageff, m_excluded_systs) != StatusCode::SUCCESS) {
193  ATH_MSG_WARNING("Incorrect excluded systematics have been provided.");
194  }
195  m_btagging_efficiency_tools.push_back(btageff);
196  return StatusCode::SUCCESS;
197  }

◆ setupBtagSelectionTool()

StatusCode top::FlavorTaggingCPTools::setupBtagSelectionTool ( const std::pair< std::string, std::string > &  btag_algo_WP,
const std::string &  jetCollection,
double  jetPtCut,
double  jetEtaCut,
bool  trackJets = false 
)
private

Setup BTaggingSelectionTool for a given WP.

Parameters
btag_algo_WPpair of tagger (e.g. DL1r) and WP name (e.g. FixedCutBEff77)
jetCollectionname of the jet collection for the btagging tool
jetPtCutminimum pT cut used for jets
jetEtaCutmaximum |eta| cut used for jets
trackJetstrue, if btagging for track jets is to be initialized, otherwise false

Definition at line 115 of file TopFlavorTaggingCPTools.cxx.

118  {
119  const std::string bTagWPName = btag_algo_WP.first + "_" + btag_algo_WP.second;
120  //------------------------------------------------------------
121  // Setup BTaggingSelectionTool
122  //------------------------------------------------------------
123  std::string btagsel_tool_name = "BTaggingSelectionTool_" + bTagWPName + "_" + jetCollection;
124  // due to a bug in the CDI files, track jets names are missing PV0 in the name
125  const std::string jetAuthor = (trackJets ? erasePV0fromJetsName(jetCollection) : jetCollection);
126 
127  BTaggingSelectionTool* btagsel = new BTaggingSelectionTool(btagsel_tool_name);
128  top::check(btagsel->setProperty("TaggerName", btag_algo_WP.first),
129  "Failed to set b-tagging selecton tool TaggerName");
130  top::check(btagsel->setProperty("JetAuthor", jetAuthor),
131  "Failed to set b-tagging selection JetAuthor");
132  top::check(btagsel->setProperty("FlvTagCutDefinitionsFileName", m_cdi_file),
133  "Failed to set b-tagging selection tool CDI file");
134  top::check(btagsel->setProperty("OperatingPoint", btag_algo_WP.second),
135  "Failed to set b-tagging selection tool OperatingPoint");
136  top::check(btagsel->setProperty("MinPt", jetPtCut),
137  "Failed to set b-tagging selection tool MinPt");
138  top::check(btagsel->setProperty("MaxEta", jetEtaCut),
139  "Failed to set b-tagging selection tool MaxEta");
140  top::check(btagsel->initialize(),
141  "Failed to initialize b-tagging selection tool: " + btagsel_tool_name);
142  m_btagging_selection_tools.push_back(btagsel);
143 
144  // for each algorithm (DL1r, DL1d, etc...) keep one selection tool instance for creating pb,pc,pu decorations
145  // internally use map to make sure only one tool for each algorithm is stored
146  m_config->addBTagAlgo(btag_algo_WP.first, btagsel_tool_name, trackJets);
147 
148  return StatusCode::SUCCESS;
149  }

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

◆ 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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_btagging_efficiency_tools

ToolHandleArray<IBTaggingEfficiencyTool> top::FlavorTaggingCPTools::m_btagging_efficiency_tools
private

Definition at line 46 of file TopFlavorTaggingCPTools.h.

◆ m_btagging_selection_tools

ToolHandleArray<IBTaggingSelectionTool> top::FlavorTaggingCPTools::m_btagging_selection_tools
private

Definition at line 47 of file TopFlavorTaggingCPTools.h.

◆ m_calib_file_path

std::string top::FlavorTaggingCPTools::m_calib_file_path
private

Definition at line 39 of file TopFlavorTaggingCPTools.h.

◆ m_cdi_file

std::string top::FlavorTaggingCPTools::m_cdi_file
private

Definition at line 38 of file TopFlavorTaggingCPTools.h.

◆ m_config

std::shared_ptr<top::TopConfig> top::FlavorTaggingCPTools::m_config
private

Definition at line 37 of file TopFlavorTaggingCPTools.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_efficiency_maps

std::string top::FlavorTaggingCPTools::m_efficiency_maps
private

Definition at line 41 of file TopFlavorTaggingCPTools.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_excluded_systs

std::string top::FlavorTaggingCPTools::m_excluded_systs
private

Definition at line 40 of file TopFlavorTaggingCPTools.h.

◆ m_jet_flavors

const std::vector<std::string> top::FlavorTaggingCPTools::m_jet_flavors
private
Initial value:
= {
"B", "C", "T", "Light"
}

Definition at line 42 of file TopFlavorTaggingCPTools.h.

◆ 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:
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
BTaggingEfficiencyTool
Definition: BTaggingEfficiencyTool.h:33
BTaggingSelectionTool::initialize
StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: BTaggingSelectionTool.cxx:59
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
top::FlavorTaggingCPTools::m_excluded_systs
std::string m_excluded_systs
Definition: TopFlavorTaggingCPTools.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
top::FlavorTaggingCPTools::m_btagging_selection_tools
ToolHandleArray< IBTaggingSelectionTool > m_btagging_selection_tools
Definition: TopFlavorTaggingCPTools.h:47
top::tokenize
void tokenize(const std::string &input, Container &output, const std::string &delimiters=" ", bool trim_empty=false)
Tokenize an input string using a set of delimiters.
Definition: Tokenize.h:24
skel.it
it
Definition: skel.GENtoEVGEN.py:423
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
top::FlavorTaggingCPTools::m_cdi_file
std::string m_cdi_file
Definition: TopFlavorTaggingCPTools.h:38
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
top::FlavorTaggingCPTools::setupBtagEfficiencyTool
StatusCode setupBtagEfficiencyTool(const std::pair< std::string, std::string > &btag_algo_WP, const std::string &jetCollection, double jetPtCut, bool trackJets=false)
Definition: TopFlavorTaggingCPTools.cxx:151
top::FlavorTaggingCPTools::checkExcludedSysts
StatusCode checkExcludedSysts(BTaggingEfficiencyTool *, const std::string &)
Definition: TopFlavorTaggingCPTools.cxx:207
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
BTaggingEfficiencyTool::initialize
StatusCode initialize()
Initialise the tool.
Definition: BTaggingEfficiencyTool.cxx:213
top::FlavorTaggingCPTools::m_calib_file_path
std::string m_calib_file_path
Definition: TopFlavorTaggingCPTools.h:39
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
top::FlavorTaggingCPTools::m_jet_flavors
const std::vector< std::string > m_jet_flavors
Definition: TopFlavorTaggingCPTools.h:42
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
BTaggingSelectionTool
Definition: BTaggingSelectionTool.h:25
BTaggingEfficiencyTool::listScaleFactorSystematics
std::map< std::string, std::vector< std::string > > listScaleFactorSystematics(bool named=false) const
This merely passes on the request to the underlying CDI object (listSystematics() cannot be used here...
Definition: BTaggingEfficiencyTool.cxx:1192
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
python.xAODType.dummy
dummy
Definition: xAODType.py:4
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
top::FlavorTaggingCPTools::m_btagging_efficiency_tools
ToolHandleArray< IBTaggingEfficiencyTool > m_btagging_efficiency_tools
Definition: TopFlavorTaggingCPTools.h:46
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
top::FlavorTaggingCPTools::erasePV0fromJetsName
std::string erasePV0fromJetsName(std::string jetCollectionName)
Definition: TopFlavorTaggingCPTools.cxx:199
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
top::FlavorTaggingCPTools::m_config
std::shared_ptr< top::TopConfig > m_config
Definition: TopFlavorTaggingCPTools.h:37
a
TList * a
Definition: liststreamerinfos.cxx:10
h
PhysDESDM_VH_DV.jetCollectionName
jetCollectionName
Definition: PhysDESDM_VH_DV.py:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
top::FlavorTaggingCPTools::m_efficiency_maps
std::string m_efficiency_maps
Definition: TopFlavorTaggingCPTools.h:41
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
set_intersection
Set * set_intersection(Set *set1, Set *set2)
Perform an intersection of two sets.
SG::DataProxy
Definition: DataProxy.h:44
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
fitman.k
k
Definition: fitman.py:528
top::FlavorTaggingCPTools::setupBtagSelectionTool
StatusCode setupBtagSelectionTool(const std::pair< std::string, std::string > &btag_algo_WP, const std::string &jetCollection, double jetPtCut, double jetEtaCut, bool trackJets=false)
Setup BTaggingSelectionTool for a given WP.
Definition: TopFlavorTaggingCPTools.cxx:115