ATLAS Offline Software
Loading...
Searching...
No Matches
TauAnalysisTools::CommonDiTauEfficiencyTool Class Reference

#include <CommonDiTauEfficiencyTool.h>

Inheritance diagram for TauAnalysisTools::CommonDiTauEfficiencyTool:
Collaboration diagram for TauAnalysisTools::CommonDiTauEfficiencyTool:

Public Member Functions

 CommonDiTauEfficiencyTool (const std::string &sName)
 Create a proper constructor for Athena.
 ~CommonDiTauEfficiencyTool ()
virtual StatusCode initialize ()
 Dummy implementation of the initialisation function.
virtual CP::CorrectionCode getEfficiencyScaleFactor (const xAOD::DiTauJet &xDiTau, double &dEfficiencyScaleFactor)
 Get the Efficiency Scale Factor of ditau jet.
virtual CP::CorrectionCode applyEfficiencyScaleFactor (const xAOD::DiTauJet &xDiTau)
 Get the Efficiency Scale Factor of ditau jet.
virtual bool isAffectedBySystematic (const CP::SystematicVariation &systematic) const
 returns: whether this tool is affected by the given systematics
virtual CP::SystematicSet affectingSystematics () const
 returns: the list of all systematics this tool can be affected by
virtual CP::SystematicSet recommendedSystematics () const
 returns: the list of all systematics this tool recommends to use
virtual StatusCode applySystematicVariation (const CP::SystematicSet &sSystematicSet)
 configure this tool for the given list of systematic variations.
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.

Public Attributes

std::function< double(const xAOD::DiTauJet &xDiTau)> m_fXDiTau
std::function< double(const xAOD::DiTauJet &xDiTau)> m_fYDiTau
std::function< double(const xAOD::DiTauJet &xDiTau)> m_fZDiTau

Protected Types

typedef std::tuple< TObject *, CP::CorrectionCode(*)(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[]) > tTupleObjectFunc
typedef std::map< std::string, tTupleObjectFunctSFMAP

Protected Member Functions

void ReadInputs (std::unique_ptr< TFile > &fFile)
void addHistogramToSFMap (TKey *kKey, const std::string &sKeyName)
virtual CP::CorrectionCode getValue (const std::string &sHistName, const xAOD::DiTauJet &xDiTau, double &dEfficiencyScaleFactor) const
 Get the scale factor from a particular recommendations histogram.
void generateSystematicSets ()
 generate a set of relevant systematic variations to be applied
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.

Static Protected Member Functions

static CP::CorrectionCode getValueTH1 (const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
static CP::CorrectionCode getValueTH2 (const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])

Protected Attributes

std::unique_ptr< tSFMAPm_mSF
std::unordered_map< CP::SystematicSet, std::string > m_mSystematicSets
const CP::SystematicSetm_sSystematicSet
std::map< std::string, std::string > m_mSystematicsHistNames
bool m_bSFIsAvailableDiTau
 true if scale factor name is already decorated
bool m_bSFIsAvailableCheckedDiTau
 true if cale factor name is already decorated has already been checked
CP::SystematicSet m_sAffectingSystematics
CP::SystematicSet m_sRecommendedSystematics
Gaudi::Property< std::string > m_sInputFilePath {this, "InputFilePath", ""}
Gaudi::Property< std::string > m_sWP {this, "WP", ""}
Gaudi::Property< std::string > m_sVarName {this, "VarName", ""}
std::string m_sInputFileName
std::string m_sSFHistName
TruthMatchedParticleType m_eCheckTruth

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

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 42 of file CommonDiTauEfficiencyTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

◆ tSFMAP

typedef std::map<std::string, tTupleObjectFunc > TauAnalysisTools::CommonDiTauEfficiencyTool::tSFMAP
protected

Definition at line 100 of file CommonDiTauEfficiencyTool.h.

◆ tTupleObjectFunc

typedef std::tuple<TObject*, CP::CorrectionCode (*)(const TObject* oObject, double& dEfficiencyScaleFactor, double dVars[] ) > TauAnalysisTools::CommonDiTauEfficiencyTool::tTupleObjectFunc
protected

Definition at line 99 of file CommonDiTauEfficiencyTool.h.

Constructor & Destructor Documentation

◆ CommonDiTauEfficiencyTool()

CommonDiTauEfficiencyTool::CommonDiTauEfficiencyTool ( const std::string & sName)

Create a proper constructor for Athena.

Definition at line 21 of file CommonDiTauEfficiencyTool.cxx.

22 : asg::AsgTool( sName )
26 , m_sSystematicSet(nullptr)
30{
31}
std::function< double(const xAOD::DiTauJet &xDiTau)> m_fZDiTau
std::function< double(const xAOD::DiTauJet &xDiTau)> m_fXDiTau
bool m_bSFIsAvailableDiTau
true if scale factor name is already decorated
bool m_bSFIsAvailableCheckedDiTau
true if cale factor name is already decorated has already been checked
std::function< double(const xAOD::DiTauJet &xDiTau)> m_fYDiTau
double TruthSubleadPt(const xAOD::DiTauJet &xDiTau)
return the truth vis pT of the subleading pT matched particle.
double TruthDeltaR(const xAOD::DiTauJet &xDiTau)
return the dR of between the leading and subleading pT matched particle.
double TruthLeadPt(const xAOD::DiTauJet &xDiTau)
return the truth vis pT of the leading pT matched particle.

◆ ~CommonDiTauEfficiencyTool()

CommonDiTauEfficiencyTool::~CommonDiTauEfficiencyTool ( )

Definition at line 33 of file CommonDiTauEfficiencyTool.cxx.

34{
35 if (m_mSF)
36 for (auto mEntry : *m_mSF)
37 delete std::get<0>(mEntry.second);
38}

Member Function Documentation

◆ addHistogramToSFMap()

void CommonDiTauEfficiencyTool::addHistogramToSFMap ( TKey * kKey,
const std::string & sKeyName )
protected

Definition at line 327 of file CommonDiTauEfficiencyTool.cxx.

328{
329 // handling for the 3 different input types TH1F/TH1D/TF1, function pointer
330 // handle the access methods for the final scale factor retrieval
331 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
332 if (cClass->InheritsFrom("TH2"))
333 {
334 TH2* oObject = static_cast<TH2*>(kKey->ReadObj());
335 oObject->SetDirectory(0);
336 (*m_mSF)[sKeyName] = tTupleObjectFunc(oObject,&getValueTH2);
337 ATH_MSG_DEBUG("added histogram with name "<<sKeyName);
338 }
339 else if (cClass->InheritsFrom("TH1"))
340 {
341 TH1* oObject = static_cast<TH1*>(kKey->ReadObj());
342 oObject->SetDirectory(0);
343 (*m_mSF)[sKeyName] = tTupleObjectFunc(oObject,&getValueTH1);
344 ATH_MSG_DEBUG("added histogram with name "<<sKeyName);
345 }
346 else
347 {
348 ATH_MSG_DEBUG("ignored object with name "<<sKeyName);
349 }
350}
#define ATH_MSG_DEBUG(x)
std::tuple< TObject *, CP::CorrectionCode(*)(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[]) > tTupleObjectFunc
static CP::CorrectionCode getValueTH2(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])
static CP::CorrectionCode getValueTH1(const TObject *oObject, double &dEfficiencyScaleFactor, double dVars[])

◆ affectingSystematics()

CP::SystematicSet CommonDiTauEfficiencyTool::affectingSystematics ( ) const
virtual

returns: the list of all systematics this tool can be affected by

Implements CP::IReentrantSystematicsTool.

Definition at line 209 of file CommonDiTauEfficiencyTool.cxx.

◆ applyEfficiencyScaleFactor()

CP::CorrectionCode CommonDiTauEfficiencyTool::applyEfficiencyScaleFactor ( const xAOD::DiTauJet & xDiTau)
virtual

Get the Efficiency Scale Factor of ditau jet.

Parameters
xDiTau
Returns
CP::CorrectionCode

Implements TauAnalysisTools::IDiTauEfficiencyCorrectionsTool.

Definition at line 168 of file CommonDiTauEfficiencyTool.cxx.

169{
170 double dSf = 0.;
171
174 {
175 m_bSFIsAvailableDiTau = decor.isAvailable(xDiTau);
178 {
179 ATH_MSG_DEBUG(m_sVarName << " decoration is available on first ditau processed, switched of applyEfficiencyScaleFactor for further ditaus.");
180 ATH_MSG_DEBUG("If an application of efficiency scale factors needs to be redone, please pass a shallow copy of the original ditau.");
181 }
182 }
185
186 // retrieve scale factor
187 CP::CorrectionCode tmpCorrectionCode = getEfficiencyScaleFactor(xDiTau, dSf);
188 // adding scale factor to tau as decoration
189 decor(xDiTau) = dSf;
190
191 return tmpCorrectionCode;
192}
@ Ok
The correction was done successfully.
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::DiTauJet &xDiTau, double &dEfficiencyScaleFactor)
Get the Efficiency Scale Factor of ditau jet.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576

◆ applySystematicVariation()

StatusCode CommonDiTauEfficiencyTool::applySystematicVariation ( const CP::SystematicSet & sSystematicSet)
virtual

configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored

Implements CP::ISystematicsTool.

Definition at line 234 of file CommonDiTauEfficiencyTool.cxx.

235{
236
237 // first check if we already know this systematic configuration
238 auto itSystematicSet = m_mSystematicSets.find(sSystematicSet);
239 if (itSystematicSet != m_mSystematicSets.end())
240 {
241 m_sSystematicSet = &itSystematicSet->first;
242 return StatusCode::SUCCESS;
243 }
244
245 // sanity checks if systematic set is supported
246 double dDirection = 0.;
247 CP::SystematicSet sSystematicSetAvailable;
248 for (auto sSyst : sSystematicSet)
249 {
250 // check if systematic is available
251 auto it = m_mSystematicsHistNames.find(sSyst.basename());
252 if (it == m_mSystematicsHistNames.end())
253 {
254 ATH_MSG_VERBOSE("unsupported systematic variation: "<< sSyst.basename()<<"; skipping this one");
255 continue;
256 }
257
258
259 if (sSyst.parameter() * dDirection < 0)
260 {
261 ATH_MSG_ERROR("unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
262 ATH_MSG_ERROR("systematic set will not be applied");
263 return StatusCode::FAILURE;
264 }
265 dDirection = sSyst.parameter();
266
267 if ((m_sRecommendedSystematics.find(sSyst.basename()) != m_sRecommendedSystematics.end()) and sSystematicSet.size() > 1)
268 {
269 ATH_MSG_ERROR("unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_EFF_*_TOTAL\" with other systematic variations!");
270 ATH_MSG_ERROR("systematic set will not be applied");
271 return StatusCode::FAILURE;
272 }
273
274 // finally add the systematic to the set of systematics to process
275 sSystematicSetAvailable.insert(sSyst);
276 }
277
278 // store this calibration for future use, and make it current
279 m_sSystematicSet = &m_mSystematicSets.insert(std::pair<CP::SystematicSet,std::string>(sSystematicSetAvailable, sSystematicSet.name())).first->first;
280
281 return StatusCode::SUCCESS;
282}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
std::unordered_map< CP::SystematicSet, std::string > m_mSystematicSets
std::map< std::string, std::string > m_mSystematicsHistNames

◆ declareGaudiProperty()

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

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

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

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

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

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

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

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

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

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ generateSystematicSets()

void CommonDiTauEfficiencyTool::generateSystematicSets ( )
protected

generate a set of relevant systematic variations to be applied

Definition at line 366 of file CommonDiTauEfficiencyTool.cxx.

367{
368 // creation of basic string for all NPs, e.g. "TAUS_TRUEHADTAU_EFF_RECO_"
369 std::vector<std::string> vSplitInputFilePath = {};
370 split(m_sInputFileName,'_',vSplitInputFilePath);
371 std::string sEfficiencyType = vSplitInputFilePath.at(0);
372 std::string sTruthType = vSplitInputFilePath.at(1);
373 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
374 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
375 std::string sSystematicBaseString = "TAUS_"+sTruthType+"_EFF_"+sEfficiencyType+"_";
376 // set truth type to check for in truth matching
377 if (sTruthType=="TRUEHADTAU") m_eCheckTruth = TauAnalysisTools::TruthHadronicTau;
378 if (sTruthType=="TRUEHADDITAU") m_eCheckTruth = TauAnalysisTools::TruthHadronicDiTau;
379
380 for (auto mSF : *m_mSF)
381 {
382 // parse for nuisance parameter in histogram name
383 std::vector<std::string> vSplitNP = {};
384 split(mSF.first,'_',vSplitNP);
385 std::string sNP = vSplitNP.at(0);
386 std::string sNPUppercase = vSplitNP.at(0);
387 // skip nominal scale factors
388 if (sNP == "sf") continue;
389 // test if NP starts with a capital letter indicating that this should be recommended
390 bool bIsRecommended = false;
391 if (isupper(sNP.at(0)))
392 bIsRecommended = true;
393 // make sNP uppercase and build final NP entry name
394 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
395 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
396 // add all found systematics to the AffectingSystematics
397 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
398 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
399 // only add found uppercase systematics to the RecommendedSystematics
400 if (bIsRecommended)
401 {
402 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
403 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
404 }
405 ATH_MSG_DEBUG("connected base name " << sNP << " with systematic " <<sSystematicString);
406 m_mSystematicsHistNames.insert({sSystematicString,sNP});
407 }
408}
void split(const std::string &sInput, const char cDelim, std::vector< std::string > &vOut)

◆ getEfficiencyScaleFactor()

CP::CorrectionCode CommonDiTauEfficiencyTool::getEfficiencyScaleFactor ( const xAOD::DiTauJet & xDiTau,
double & dEfficiencyScaleFactor )
virtual

Get the Efficiency Scale Factor of ditau jet.

Parameters
xDiTau: reco DiTauJet
dEfficiencyScaleFactor: reference to output variable where efficiency is returned
Returns
CP::CorrectionCode

Implements TauAnalysisTools::IDiTauEfficiencyCorrectionsTool.

Definition at line 91 of file CommonDiTauEfficiencyTool.cxx.

93{
94 // check which true state is requestet
96 {
97 dEfficiencyScaleFactor = 1.;
99 }
100
101 CP::CorrectionCode tmpCorrectionCode = getValue(m_sSFHistName,
102 xDiTau,
103 dEfficiencyScaleFactor);
104 // return correction code if histogram is not available
105 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
106 return tmpCorrectionCode;
107
108 // skip further process if systematic set is empty
109 if (m_sSystematicSet->size() == 0)
111
112 // get uncertainties summed in quadrature
113 double dTotalSystematic2 = 0.;
114 double dDirection = 0.;
115 for (auto syst : *m_sSystematicSet)
116 {
117
118 // check if systematic is available
119 auto it = m_mSystematicsHistNames.find(syst.basename());
120
121 // get uncertainty value
122 double dUncertaintySyst = 0.;
123
124 // needed for up/down decision
125 dDirection = syst.parameter();
126
127 // build up histogram name
128 std::string sHistName = it->second;
129 if (dDirection>0) sHistName+="_up";
130 else sHistName+="_down";
131 if (!m_sWP.empty()) sHistName+="_"+m_sWP;
132
133 // get the uncertainty from the histogram
134 tmpCorrectionCode = getValue(sHistName,
135 xDiTau,
136 dUncertaintySyst);
137
138 // return correction code if histogram is not available
139 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
140 return tmpCorrectionCode;
141
142 // scale uncertainty with direction, i.e. +/- n*sigma
143 dUncertaintySyst *= dDirection;
144
145 // square uncertainty and add to total uncertainty
146 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
147 }
148
149 // now use dDirection to use up/down uncertainty
150 dDirection = (dDirection > 0.) ? 1. : -1.;
151
152 // finally apply uncertainty (eff * ( 1 +/- \sum )
153 dEfficiencyScaleFactor *= 1. + dDirection * std::sqrt(dTotalSystematic2);
154
156}
virtual CP::CorrectionCode getValue(const std::string &sHistName, const xAOD::DiTauJet &xDiTau, double &dEfficiencyScaleFactor) const
Get the scale factor from a particular recommendations histogram.
TruthMatchedParticleType getTruthParticleType(const xAOD::TauJet &xTau)
return TauJet match type

◆ getKey()

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

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

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

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

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

Definition at line 119 of file AsgTool.cxx.

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

◆ getName()

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

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

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

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

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

Definition at line 106 of file AsgTool.cxx.

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

◆ getProperty()

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

Get one of the tool's properties.

◆ getValue()

CP::CorrectionCode CommonDiTauEfficiencyTool::getValue ( const std::string & sHistName,
const xAOD::DiTauJet & xDiTau,
double & dEfficiencyScaleFactor ) const
protectedvirtual

Get the scale factor from a particular recommendations histogram.

Parameters
sHistName
xDiTau
dEfficiencyScaleFactor
Returns
CP::CorrectionCode

Definition at line 415 of file CommonDiTauEfficiencyTool.cxx.

418{
419 const tSFMAP& mSF = *m_mSF;
420 auto it = mSF.find (sHistName);
421 if (it == mSF.end())
422 {
423 ATH_MSG_ERROR("Object with name "<<sHistName<<" was not found in input file.");
424 ATH_MSG_DEBUG("Content of input file");
425 for (auto eEntry : mSF)
426 ATH_MSG_DEBUG(" Entry: "<<eEntry.first);
428 }
429
430 // get a tuple (TObject*,functionPointer) from the scale factor map
431 tTupleObjectFunc tTuple = it->second;
432
433 // get pt and eta (for x and y axis respectively)
434 double dX = m_fXDiTau(xDiTau);
435 double dY = m_fYDiTau(xDiTau);
436 double dZ = m_fZDiTau(xDiTau);
437
438 double dVars[3] = {dX, dY, dZ};
439 // finally obtain efficiency scale factor from TH1F/TH1D/TF1, by calling the
440 // function pointer stored in the tuple from the scale factor map
441 return (std::get<1>(tTuple))(std::get<0>(tTuple), dEfficiencyScaleFactor, dVars);
442}
@ Error
Some error happened during the object correction.
std::map< std::string, tTupleObjectFunc > tSFMAP

◆ getValueTH1()

CP::CorrectionCode CommonDiTauEfficiencyTool::getValueTH1 ( const TObject * oObject,
double & dEfficiencyScaleFactor,
double dVars[] )
staticprotected

Definition at line 474 of file CommonDiTauEfficiencyTool.cxx.

476{
477 double dPt = dVars[0];
478
479 const TH1* hHist = dynamic_cast<const TH1*>(oObject);
480
481 if (!hHist)
482 {
483 // ATH_MSG_ERROR("Problem with casting TObject of type "<<oObject->ClassName()<<" to TH2F");
485 }
486
487 // protect values from underflow bins
488 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
489 // protect values from overflow bins (times .999 to keep it inside last bin)
490 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
491
492 // get bin from TH2 depending on x and y values; finally set the scale factor
493 int iBin = hHist->FindFixBin(dPt);
494 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
496}

◆ getValueTH2()

CP::CorrectionCode CommonDiTauEfficiencyTool::getValueTH2 ( const TObject * oObject,
double & dEfficiencyScaleFactor,
double dVars[] )
staticprotected

Definition at line 504 of file CommonDiTauEfficiencyTool.cxx.

506{
507 double dPt = dVars[0];
508 double dEta = dVars[1];
509
510 const TH2* hHist = dynamic_cast<const TH2*>(oObject);
511
512 if (!hHist)
513 {
514 // ATH_MSG_ERROR("Problem with casting TObject of type "<<oObject->ClassName()<<" to TH2F");
516 }
517
518 // protect values from underflow bins
519 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
520 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
521 // protect values from overflow bins (times .999 to keep it inside last bin)
522 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
523 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
524
525 // get bin from TH2 depending on x and y values; finally set the scale factor
526 int iBin = hHist->FindFixBin(dPt,dEta);
527 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
529}
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)

◆ initialize()

StatusCode CommonDiTauEfficiencyTool::initialize ( void )
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 48 of file CommonDiTauEfficiencyTool.cxx.

49{
50 ATH_MSG_INFO( "Initializing CommonDiTauEfficiencyTool" );
51 // only read in histograms once
52 if (m_mSF==nullptr)
53 {
54 std::string sInputFilePath = PathResolverFindCalibFile(m_sInputFilePath);
55
56 m_mSF = std::make_unique< tSFMAP >();
57 std::unique_ptr< TFile > fSF( TFile::Open( sInputFilePath.c_str(), "READ" ) );
58 if(!fSF)
59 {
60 ATH_MSG_FATAL("Could not open file " << sInputFilePath.c_str());
61 return StatusCode::FAILURE;
62 }
63 ReadInputs(fSF);
64 fSF->Close();
65 }
66
67 // needed later on in generateSystematicSets(), maybe move it there
68 std::vector<std::string> vInputFilePath;
69 split(m_sInputFilePath,'/',vInputFilePath);
70 m_sInputFileName = vInputFilePath.back();
71
73
74 if (m_sWP.size()>0)
75 m_sSFHistName = "sf_"+m_sWP;
76
77 // load empty systematic variation by default
78 if (applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS )
79 return StatusCode::FAILURE;
80
81 return StatusCode::SUCCESS;
82}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
virtual StatusCode applySystematicVariation(const CP::SystematicSet &sSystematicSet)
configure this tool for the given list of systematic variations.
void generateSystematicSets()
generate a set of relevant systematic variations to be applied
void ReadInputs(std::unique_ptr< TFile > &fFile)

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

◆ isAffectedBySystematic()

bool CommonDiTauEfficiencyTool::isAffectedBySystematic ( const CP::SystematicVariation & systematic) const
virtual

returns: whether this tool is affected by the given systematics

Implements CP::ISystematicsTool.

Definition at line 198 of file CommonDiTauEfficiencyTool.cxx.

199{
200 CP::SystematicSet sys = affectingSystematics();
201 return sys.find(systematic) != sys.end();
202}
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by

◆ 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()

◆ ReadInputs()

void CommonDiTauEfficiencyTool::ReadInputs ( std::unique_ptr< TFile > & fFile)
protected

Definition at line 285 of file CommonDiTauEfficiencyTool.cxx.

286{
287 m_mSF->clear();
288
289 // initialize function pointer
293
294 TKey *kKey;
295 TIter itNext(fFile->GetListOfKeys());
296 while ((kKey = (TKey*)itNext()))
297 {
298 // parse file content for objects of type TNamed, check their title for
299 // known strings and reset funtion pointer
300 std::string sKeyName = kKey->GetName();
301
302 std::vector<std::string> vSplitName = {};
303 split(sKeyName,'_',vSplitName);
304 if (vSplitName[0] == "sf")
305 {
306 addHistogramToSFMap(kKey, sKeyName);
307 }
308 else
309 {
310 if (sKeyName.find("_up_") != std::string::npos or sKeyName.find("_down_") != std::string::npos)
311 addHistogramToSFMap(kKey, sKeyName);
312 else
313 {
314 size_t iPos = sKeyName.find('_');
315 addHistogramToSFMap(kKey, sKeyName.substr(0,iPos)+"_up"+sKeyName.substr(iPos));
316 addHistogramToSFMap(kKey, sKeyName.substr(0,iPos)+"_down"+sKeyName.substr(iPos));
317 }
318 }
319 }
320 ATH_MSG_INFO("data loaded from " << fFile->GetName());
321}
void addHistogramToSFMap(TKey *kKey, const std::string &sKeyName)

◆ recommendedSystematics()

CP::SystematicSet CommonDiTauEfficiencyTool::recommendedSystematics ( ) const
virtual

returns: the list of all systematics this tool recommends to use

Implements CP::IReentrantSystematicsTool.

Definition at line 218 of file CommonDiTauEfficiencyTool.cxx.

219{
221}

◆ renounce()

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

Definition at line 380 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

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

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_bSFIsAvailableCheckedDiTau

bool TauAnalysisTools::CommonDiTauEfficiencyTool::m_bSFIsAvailableCheckedDiTau
protected

true if cale factor name is already decorated has already been checked

Definition at line 140 of file CommonDiTauEfficiencyTool.h.

◆ m_bSFIsAvailableDiTau

bool TauAnalysisTools::CommonDiTauEfficiencyTool::m_bSFIsAvailableDiTau
protected

true if scale factor name is already decorated

Definition at line 138 of file CommonDiTauEfficiencyTool.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_eCheckTruth

TruthMatchedParticleType TauAnalysisTools::CommonDiTauEfficiencyTool::m_eCheckTruth
protected

Definition at line 152 of file CommonDiTauEfficiencyTool.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_fXDiTau

std::function<double(const xAOD::DiTauJet& xDiTau)> TauAnalysisTools::CommonDiTauEfficiencyTool::m_fXDiTau

Definition at line 87 of file CommonDiTauEfficiencyTool.h.

◆ m_fYDiTau

std::function<double(const xAOD::DiTauJet& xDiTau)> TauAnalysisTools::CommonDiTauEfficiencyTool::m_fYDiTau

Definition at line 88 of file CommonDiTauEfficiencyTool.h.

◆ m_fZDiTau

std::function<double(const xAOD::DiTauJet& xDiTau)> TauAnalysisTools::CommonDiTauEfficiencyTool::m_fZDiTau

Definition at line 89 of file CommonDiTauEfficiencyTool.h.

◆ m_mSF

std::unique_ptr< tSFMAP > TauAnalysisTools::CommonDiTauEfficiencyTool::m_mSF
protected

Definition at line 107 of file CommonDiTauEfficiencyTool.h.

◆ m_mSystematicSets

std::unordered_map< CP::SystematicSet, std::string > TauAnalysisTools::CommonDiTauEfficiencyTool::m_mSystematicSets
protected

Definition at line 110 of file CommonDiTauEfficiencyTool.h.

◆ m_mSystematicsHistNames

std::map<std::string, std::string> TauAnalysisTools::CommonDiTauEfficiencyTool::m_mSystematicsHistNames
protected

Definition at line 112 of file CommonDiTauEfficiencyTool.h.

◆ m_sAffectingSystematics

CP::SystematicSet TauAnalysisTools::CommonDiTauEfficiencyTool::m_sAffectingSystematics
protected

Definition at line 142 of file CommonDiTauEfficiencyTool.h.

◆ m_sInputFileName

std::string TauAnalysisTools::CommonDiTauEfficiencyTool::m_sInputFileName
protected

Definition at line 149 of file CommonDiTauEfficiencyTool.h.

◆ m_sInputFilePath

Gaudi::Property<std::string> TauAnalysisTools::CommonDiTauEfficiencyTool::m_sInputFilePath {this, "InputFilePath", ""}
protected

Definition at line 145 of file CommonDiTauEfficiencyTool.h.

145{this, "InputFilePath", ""};

◆ m_sRecommendedSystematics

CP::SystematicSet TauAnalysisTools::CommonDiTauEfficiencyTool::m_sRecommendedSystematics
protected

Definition at line 143 of file CommonDiTauEfficiencyTool.h.

◆ m_sSFHistName

std::string TauAnalysisTools::CommonDiTauEfficiencyTool::m_sSFHistName
protected

Definition at line 150 of file CommonDiTauEfficiencyTool.h.

◆ m_sSystematicSet

const CP::SystematicSet* TauAnalysisTools::CommonDiTauEfficiencyTool::m_sSystematicSet
protected

Definition at line 111 of file CommonDiTauEfficiencyTool.h.

◆ m_sVarName

Gaudi::Property<std::string> TauAnalysisTools::CommonDiTauEfficiencyTool::m_sVarName {this, "VarName", ""}
protected

Definition at line 147 of file CommonDiTauEfficiencyTool.h.

147{this, "VarName", ""};

◆ m_sWP

Gaudi::Property<std::string> TauAnalysisTools::CommonDiTauEfficiencyTool::m_sWP {this, "WP", ""}
protected

Definition at line 146 of file CommonDiTauEfficiencyTool.h.

146{this, "WP", ""};

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