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

#include <CommonSmearingTool.h>

Inheritance diagram for TauAnalysisTools::CommonSmearingTool:
Collaboration diagram for TauAnalysisTools::CommonSmearingTool:

Public Types

Definition of the StoreGate-like object's definition
typedef ServiceHandle< StoreGateSvc > MetaStore_t
 Type of the metadata store object in Athena.
typedef const ServiceHandle< StoreGateSvc > & MetaStorePtr_t
 Type of the metadata store pointer in standalone mode.

Public Member Functions

 CommonSmearingTool (const std::string &sName)
 Create a proper constructor for Athena.
 ~CommonSmearingTool ()
virtual StatusCode initialize ()
 Dummy implementation of the initialisation function.
virtual CP::CorrectionCode applyCorrection (xAOD::TauJet &xTau) const
 Apply the correction on a modifyable object.
virtual CP::CorrectionCode correctedCopy (const xAOD::TauJet &xTau, xAOD::TauJet *&xTauCopy) const
 Create a corrected copy from a constant tau.
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 StatusCode sysInitialize ()
 Function initialising the tool in the correct way in Athena.
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 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
Functions providing access to the input/output metadata
MetaStorePtr_t inputMetaStore () const
 Accessor for the input metadata store.
MetaStorePtr_t outputMetaStore () const
 Accessor for the output metadata store.
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

std::string ConvertProngToString (const int iProngness) const
template<class T>
void ReadInputs (TFile *fFile, std::map< std::string, T > &mMap)
virtual CP::CorrectionCode getValue (const std::string &sHistName, const xAOD::TauJet &xTau, double &dEfficiencyScaleFactor) const
void generateSystematicSets ()
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.
Callback functions helping in metadata reading/writing
void setUseIncidents (const bool flag)
virtual void handle (const Incident &inc)
 Function receiving incidents from IncidentSvc/Event.
virtual StatusCode beginInputFile ()
 Function called when a new input file is opened.
virtual StatusCode endInputFile ()
 Function called when the currently open input file got completely processed.
virtual StatusCode metaDataStop ()
 Function called when the tool should write out its metadata.

Protected Attributes

std::map< std::string, TH1 * > m_mSF
std::unordered_map< CP::SystematicSet, std::string > m_mSystematicSets
const CP::SystematicSet * m_sSystematicSet
std::map< std::string, int > m_mSystematics
std::map< std::string, std::string > m_mSystematicsHistNames
double(* m_fX )(const xAOD::TauJet &xTau)
double(* m_fY )(const xAOD::TauJet &xTau)
Gaudi::Property< std::string > m_sInputFilePath {this, "InputFilePath", ""}
Gaudi::Property< bool > m_bSkipTruthMatchCheck {this, "SkipTruthMatchCheck", false}
Gaudi::Property< bool > m_bApplyFading {this, "ApplyFading", true}
Gaudi::Property< bool > m_bMVATESQualityCheck {this, "MVATESQualityCheck", true}
Gaudi::Property< bool > m_bApplyInsituCorrection {this, "ApplyInsituCorrection", true}
bool m_bIsData
bool m_bIsConfigured
asg::AnaToolHandle< ITauToolBase > m_tTauCombinedTES
TruthMatchedParticleType m_eCheckTruth
CP::SystematicSet m_sAffectingSystematics
CP::SystematicSet m_sRecommendedSystematics

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

virtual StatusCode beginEvent ()
 Function called when a new events is loaded.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

CxxUtils::CachedValue< bool > m_bIsTESCompatibilityCheckAvailable
MetaStore_t m_inputMetaStore
 Object accessing the input metadata store.
MetaStore_t m_outputMetaStore
 Object accessing the output metadata store.
bool m_beginInputFileCalled
 Flag helping to discover when the tool misses the opening of the first input file.
bool m_useIncidents
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 40 of file CommonSmearingTool.h.

Member Typedef Documentation

◆ MetaStore_t

Type of the metadata store object in Athena.

Definition at line 66 of file AsgMetadataTool.h.

◆ MetaStorePtr_t

Type of the metadata store pointer in standalone mode.

Definition at line 68 of file AsgMetadataTool.h.

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CommonSmearingTool()

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

Create a proper constructor for Athena.

Definition at line 75 of file CommonSmearingTool.cxx.

76 : asg::AsgMetadataTool( sName )
77 , m_sSystematicSet(nullptr)
80 , m_bIsData(false)
81 , m_bIsConfigured(false)
82 , m_tTauCombinedTES("TauCombinedTES", this)
84{
85}
double(* m_fX)(const xAOD::TauJet &xTau)
asg::AnaToolHandle< ITauToolBase > m_tTauCombinedTES
double(* m_fY)(const xAOD::TauJet &xTau)
const CP::SystematicSet * m_sSystematicSet
double finalTauEta(const xAOD::TauJet &xTau)
return MVA based tau eta
double finalTauPt(const xAOD::TauJet &xTau)
return MVA based tau pt in GeV

◆ ~CommonSmearingTool()

CommonSmearingTool::~CommonSmearingTool ( )

Definition at line 90 of file CommonSmearingTool.cxx.

91{
92 for (auto& mEntry : m_mSF)
93 delete mEntry.second;
94}
std::map< std::string, TH1 * > m_mSF

Member Function Documentation

◆ affectingSystematics()

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

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

Implements CP::IReentrantSystematicsTool.

Definition at line 287 of file CommonSmearingTool.cxx.

288{
290}

◆ applyCorrection()

CP::CorrectionCode CommonSmearingTool::applyCorrection ( xAOD::TauJet & xTau) const
virtual

Apply the correction on a modifyable object.

Implements TauAnalysisTools::ITauSmearingTool.

Definition at line 144 of file CommonSmearingTool.cxx.

145{
146 // consistency check between calo-only pt ("ptTauEnergyScale") and MVA pt ("ptFinalCalib", the default calibration)
147 // MVA TES always has better resolution than calo-only TES for true taus
148 // this check helpsts mostly to discard muons faking taus with large track momentum but little energy deposit in the calorimeter:
149
150 // check if decorations were already added to the first passed tau
152 static const SG::ConstAccessor<char> caccTESCompatibility("TESCompatibility");
153 m_bIsTESCompatibilityCheckAvailable.set (caccTESCompatibility.isAvailable(xTau));
154 }
155
157 // if decoration is not available on derivations, calculate it on the fly
158 bool compatibility = true;
159 static const SG::ConstAccessor<float> accPtTauEnergyScale ("ptTauEnergyScale");
160 if(accPtTauEnergyScale.isAvailable(xTau)) {
161 const auto combinedTEStool = dynamic_cast<const TauCombinedTES*>(m_tTauCombinedTES.get());
162 if (!combinedTEStool)[[unlikely]]{
163 throw std::runtime_error("CommonSmearingTool::applyCorrection: combinedTEStool is null");
164 }
165 compatibility = combinedTEStool->getTESCompatibility(xTau);
166 }
167 static const SG::Accessor<char> accTESCompatibility("TESCompatibility");
168 accTESCompatibility(xTau) = char(compatibility);
169 }
170
171 // step out here if we run on data
172 if (m_bIsData)
174
175 // check which true state is requested
178 }
179
180 // skip taus which are not 1 or 3 prong
181 if( xTau.nTracks() != 1 && xTau.nTracks() != 3) {
183 }
184
185 // get prong extension for histogram name
186 std::string sProng = ConvertProngToString(xTau.nTracks());
187
188 double dCorrection = 1.;
189 CP::CorrectionCode tmpCorrectionCode;
191 {
192 // get standard scale factor
193 tmpCorrectionCode = getValue("sf"+sProng,
194 xTau,
195 dCorrection);
196 // return correction code if histogram is not available
197 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
198 return tmpCorrectionCode;
199 }
200
201 // skip further process if systematic set is empty
202 if (!m_sSystematicSet->empty())
203 {
204 // get uncertainties summed in quadrature
205 double dTotalSystematic2 = 0.;
206 double dDirection = 0.;
207 for (auto& syst : *m_sSystematicSet)
208 {
209 // check if systematic is available
210 auto it = m_mSystematicsHistNames.find(syst.basename());
211 if (it == m_mSystematicsHistNames.end())[[unlikely]]{
212 continue;
213 }
214 // get uncertainty value
215 double dUncertaintySyst = 0.;
216 tmpCorrectionCode = getValue(it->second+sProng,
217 xTau,
218 dUncertaintySyst);
219 // return correction code if histogram is not available
220 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
221 return tmpCorrectionCode;
222
223 // needed for up/down decision
224 dDirection = syst.parameter();
225
226 // scale uncertainty with direction, i.e. +/- n*sigma
227 dUncertaintySyst *= dDirection;
228
229 // square uncertainty and add to total uncertainty
230 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
231 }
232
233 // now use dDirection to use up/down uncertainty
234 dDirection = (dDirection > 0.) ? 1. : -1.;
235
236 // finally apply uncertainty (eff * ( 1 +/- \sum )
237 dCorrection *= 1 + dDirection * std::sqrt(dTotalSystematic2);
238 }
239
240 // finally apply correction
241 // in-situ TES is applied w.r.t. ptFinalCalib, use explicit calibration for pt to avoid irreproducibility upon re-calibration (PHYSLITE)
242 // not required for eta/phi/m that we don't correct (only ptFinalCalib and etaFinalCalib are stored in DAODs)
243 xTau.setP4( xTau.ptFinalCalib() * dCorrection,
244 xTau.eta(), xTau.phi(), xTau.m());
246}
@ Ok
The correction was done successfully.
virtual CP::CorrectionCode getValue(const std::string &sHistName, const xAOD::TauJet &xTau, double &dEfficiencyScaleFactor) const
CxxUtils::CachedValue< bool > m_bIsTESCompatibilityCheckAvailable
Gaudi::Property< bool > m_bMVATESQualityCheck
Gaudi::Property< bool > m_bSkipTruthMatchCheck
std::string ConvertProngToString(const int iProngness) const
Gaudi::Property< bool > m_bApplyInsituCorrection
std::map< std::string, std::string > m_mSystematicsHistNames
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
double ptFinalCalib() const
virtual double m() const
The invariant mass of the particle.
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
TruthMatchedParticleType getTruthParticleType(const xAOD::TauJet &xTau)
return TauJet match type
#define unlikely(x)

◆ applySystematicVariation()

StatusCode CommonSmearingTool::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 312 of file CommonSmearingTool.cxx.

313{
314 // first check if we already know this systematic configuration
315 auto itSystematicSet = m_mSystematicSets.find(sSystematicSet);
316 if (itSystematicSet != m_mSystematicSets.end())
317 {
318 m_sSystematicSet = &itSystematicSet->first;
319 return StatusCode::SUCCESS;
320 }
321
322 // sanity checks if systematic set is supported
323 double dDirection = 0.;
324 CP::SystematicSet sSystematicSetAvailable;
325 for (auto& sSyst : sSystematicSet)
326 {
327 // check if systematic is available
328 auto it = m_mSystematicsHistNames.find(sSyst.basename());
329 if (it == m_mSystematicsHistNames.end())
330 {
331 ATH_MSG_VERBOSE("unsupported systematic variation: "<< sSyst.basename()<<"; skipping this one");
332 continue;
333 }
334
335 if (sSyst.parameter() * dDirection < 0)
336 {
337 ATH_MSG_ERROR("unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
338 ATH_MSG_ERROR("systematic set will not be applied");
339 return StatusCode::FAILURE;
340 }
341 dDirection = sSyst.parameter();
342
343 if ((m_sRecommendedSystematics.find(sSyst.basename()) != m_sRecommendedSystematics.end()) and sSystematicSet.size() > 1)
344 {
345 ATH_MSG_ERROR("unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_SME_TOTAL\" with other systematic variations!");
346 ATH_MSG_ERROR("systematic set will not be applied");
347 return StatusCode::FAILURE;
348 }
349
350 // finally add the systematic to the set of systematics to process
351 sSystematicSetAvailable.insert(sSyst);
352 }
353
354 // store this calibration for future use, and make it current
355 m_sSystematicSet = &m_mSystematicSets.insert(std::pair<CP::SystematicSet,std::string>(sSystematicSetAvailable, sSystematicSet.name())).first->first;
356
357 return StatusCode::SUCCESS;
358}
#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

◆ beginEvent()

StatusCode CommonSmearingTool::beginEvent ( )
privatevirtual

Function called when a new events is loaded.

Dummy implementation that can be overridden by the derived tool.

Reimplemented from asg::AsgMetadataTool.

Definition at line 367 of file CommonSmearingTool.cxx.

368{
369 if (m_bIsConfigured)
370 return StatusCode::SUCCESS;
371
372 const xAOD::EventInfo* xEventInfo = nullptr;
373 ATH_CHECK(evtStore()->retrieve(xEventInfo,"EventInfo"));
375 m_bIsConfigured = true;
376
377 return StatusCode::SUCCESS;
378}
#define ATH_CHECK
Evaluate an expression and check for errors.
ServiceHandle< StoreGateSvc > & evtStore()
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ beginInputFile()

StatusCode asg::AsgMetadataTool::beginInputFile ( )
protectedvirtualinherited

Function called when a new input file is opened.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in AsgElectronEfficiencyCorrectionTool, BookkeeperDumperTool, BookkeeperTool, PMGTools::PMGTruthWeightTool, TauAnalysisTools::TauEfficiencyCorrectionsTool, TauAnalysisTools::TauSmearingTool, Trig::TrigDecisionTool, Trig::xAODBunchCrossingTool, TrigConf::xAODConfigTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 185 of file AsgMetadataTool.cxx.

185 {
186
187 // Return gracefully:
188 return StatusCode::SUCCESS;
189 }

◆ ConvertProngToString()

std::string CommonSmearingTool::ConvertProngToString ( const int iProngness) const
protected

Definition at line 381 of file CommonSmearingTool.cxx.

382{
383 return fProngness == 1 ? "_1p" : "_3p";
384}

◆ correctedCopy()

CP::CorrectionCode CommonSmearingTool::correctedCopy ( const xAOD::TauJet & xTau,
xAOD::TauJet *& xTauCopy ) const
virtual

Create a corrected copy from a constant tau.

Implements TauAnalysisTools::ITauSmearingTool.

Definition at line 253 of file CommonSmearingTool.cxx.

255{
256
257 // A sanity check:
258 if( xTauCopy )
259 {
260 ATH_MSG_WARNING( "Non-null pointer received. "
261 "There's a possible memory leak!" );
262 }
263
264 // Create a new object:
265 xTauCopy = new xAOD::TauJet();
266 xTauCopy->makePrivateStore( xTau );
267
268 // Use the other function to modify this object:
269 return applyCorrection( *xTauCopy );
270}
#define ATH_MSG_WARNING(x,...)
virtual CP::CorrectionCode applyCorrection(xAOD::TauJet &xTau) const
Apply the correction on a modifyable object.
TauJet_v3 TauJet
Definition of the current "tau version".
Definition TauJet.h:17

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

◆ endInputFile()

StatusCode asg::AsgMetadataTool::endInputFile ( )
protectedvirtualinherited

Function called when the currently open input file got completely processed.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, TrigConf::xAODConfigTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 193 of file AsgMetadataTool.cxx.

193 {
194
195 // Return gracefully:
196 return StatusCode::SUCCESS;
197 }

◆ 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 CommonSmearingTool::generateSystematicSets ( )
protected

Definition at line 435 of file CommonSmearingTool.cxx.

436{
437 std::vector<std::string> vInputFilePath;
438 split(m_sInputFilePath,'/',vInputFilePath);
439 std::string sInputFileName = vInputFilePath.back();
440
441 // creation of basic string for all NPs, e.g. "TAUS_TRUEHADTAU_SME_TES_"
442 std::vector<std::string> vSplitInputFilePath = {};
443 split(sInputFileName,'_',vSplitInputFilePath);
444 std::string sEfficiencyType = vSplitInputFilePath.at(0);
445 std::string sTruthType = vSplitInputFilePath.at(1);
446 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
447 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
448 std::string sSystematicBaseString = "TAUS_" + sTruthType + "_SME_" + sEfficiencyType + "_";
449
450 // set truth type to check for in truth matching - only true hadronic tau is supported at the moment
451 if (sTruthType=="TRUEHADTAU") m_eCheckTruth = TauAnalysisTools::TruthHadronicTau;
452
453
454 for (auto& mSF : m_mSF)
455 {
456 // parse for nuisance parameter in histogram name
457 std::vector<std::string> vSplitNP = {};
458 split(mSF.first,'_',vSplitNP);
459 std::string sNP;
460 std::string sNPUppercase;
461 if (vSplitNP.size() > 2)
462 {
463 sNP = vSplitNP.at(0)+'_'+vSplitNP.at(1);
464 sNPUppercase = vSplitNP.at(0) + '_' + vSplitNP.at(1);
465 } else {
466 sNP = vSplitNP.at(0);
467 sNPUppercase = vSplitNP.at(0);
468 }
469
470 // skip nominal scale factors
471 if (sNP == "sf") continue;
472 // skip if non 1p histogram to avoid duplications (TODO: come up with a better solution)
473 if (mSF.first.find("_1p") == std::string::npos) continue;
474
475 // test if NP starts with a capital letter indicating that this should be recommended
476 bool bIsRecommended = false;
477 if (isupper(sNP.at(0)))
478 bIsRecommended = true;
479
480 // make sNP uppercase and build final NP entry name
481 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
482 std::string sSystematicString = sSystematicBaseString + sNPUppercase;
483
484 // add all found systematics to the AffectingSystematics
485 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
486 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
487 // only add found uppercase systematics to the RecommendedSystematics
488 if (bIsRecommended)
489 {
490 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
491 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
492 }
493
494 ATH_MSG_DEBUG("connected histogram base name " << sNP << " with systematic " << sSystematicString);
495 m_mSystematicsHistNames.insert({sSystematicString,sNP});
496 }
497}
#define ATH_MSG_DEBUG(x,...)
Gaudi::Property< std::string > m_sInputFilePath
void split(const std::string &sInput, const char cDelim, std::vector< std::string > &vOut)

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

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

◆ getValue()

CP::CorrectionCode CommonSmearingTool::getValue ( const std::string & sHistName,
const xAOD::TauJet & xTau,
double & dEfficiencyScaleFactor ) const
protectedvirtual

Definition at line 500 of file CommonSmearingTool.cxx.

503{
504 TH1* hHist = m_mSF.at(sHistName);
505 if (hHist == nullptr)
506 {
507 ATH_MSG_ERROR("Histogram with name " << sHistName << " was not found in input file.");
509 }
510
511 double dPt = m_fX(xTau);
512 double dEta = m_fY(xTau);
513
514 // protect values from underflow bins
515 dPt = std::max(dPt,hHist->GetXaxis()->GetXmin());
516 dEta = std::max(dEta,hHist->GetYaxis()->GetXmin());
517 // protect values from overflow bins (times .999 to keep it inside last bin)
518 dPt = std::min(dPt,hHist->GetXaxis()->GetXmax() * .999);
519 dEta = std::min(dEta,hHist->GetYaxis()->GetXmax() * .999);
520
521 int iBin = hHist->FindFixBin(dPt,dEta);
522 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
523
524 if (m_bApplyFading)
525 {
526 std::string sTitle = hHist->GetTitle();
527 if (!sTitle.empty())
528 {
529 TF1 f("",sTitle.c_str(), 0, 1000);
530 if (sHistName.find("sf_") != std::string::npos)
531 dEfficiencyScaleFactor = (dEfficiencyScaleFactor -1.) *f.Eval(m_fX(xTau)) + 1.;
532 else
533 dEfficiencyScaleFactor *= f.Eval(m_fX(xTau));
534 }
535 }
537}
@ Error
Some error happened during the object correction.
bool dEta(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)

◆ handle()

void asg::AsgMetadataTool::handle ( const Incident & inc)
protectedvirtualinherited

Function receiving incidents from IncidentSvc/Event.

Reimplemented in Trig::TrigDecisionTool.

Definition at line 135 of file AsgMetadataTool.cxx.

135 {
136
137 // Tell the user what's happening:
138 ATH_MSG_VERBOSE( "Callback received with incident: " << inc.type() );
139
140 // Call the appropriate member function:
141 if( inc.type() == IncidentType::BeginInputFile ) {
143 if( beginInputFile().isFailure() ) {
144 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
145 throw std::runtime_error( "Couldn't call beginInputFile()" );
146 }
147 } else if( inc.type() == IncidentType::EndInputFile ) {
148 if( endInputFile().isFailure() ) {
149 ATH_MSG_FATAL( "Failed to call endInputFile()" );
150 throw std::runtime_error( "Couldn't call endInputFile()" );
151 }
152 } else if( inc.type() == IncidentType::BeginEvent ) {
153 // If the tool didn't catch the begin input file incident for the
154 // first input file of the job, then call the appropriate function
155 // now.
156 if( ! m_beginInputFileCalled ) {
158 if( beginInputFile().isFailure() ) {
159 ATH_MSG_FATAL( "Failed to call beginInputFile()" );
160 throw std::runtime_error( "Couldn't call beginInputFile()" );
161 }
162 }
163 if( beginEvent().isFailure() ) {
164 ATH_MSG_FATAL( "Failed to call beginEvent()" );
165 throw std::runtime_error( "Couldn't call beginEvent()" );
166 }
167
168 #ifdef XAOD_STANDALONE
169 } else if( inc.type() == IncidentType::MetaDataStop ) {
170 if( metaDataStop().isFailure() ) {
171 ATH_MSG_FATAL( "Failed to call metaDataStop()" );
172 throw std::runtime_error( "Couldn't call metaDataStop()" );
173 }
174
175 #endif // XAOD_STANDALONE
176 } else {
177 ATH_MSG_WARNING( "Unknown incident type received in AsgMetaDataTool: " << inc.type() );
178 }
179
180 return;
181 }
#define ATH_MSG_FATAL(x,...)
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
virtual StatusCode beginEvent()
Function called when a new events is loaded.
bool m_beginInputFileCalled
Flag helping to discover when the tool misses the opening of the first input file.
virtual StatusCode endInputFile()
Function called when the currently open input file got completely processed.
virtual StatusCode metaDataStop()
Function called when the tool should write out its metadata.

◆ initialize()

StatusCode CommonSmearingTool::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 103 of file CommonSmearingTool.cxx.

104{
105 ATH_MSG_INFO( "Initializing CommonSmearingTool" );
106
107 // FIXME: do we expect initialize() to be called several times?
108 // only read in histograms once
109 if (m_mSF.empty())
110 {
111 std::string sInputFilePath = PathResolverFindCalibFile(m_sInputFilePath);
112 std::unique_ptr<TFile> fSF( TFile::Open(sInputFilePath.c_str()) );
113 if(fSF == nullptr) {
114 ATH_MSG_FATAL("Could not open file " << sInputFilePath.c_str());
115 return StatusCode::FAILURE;
116 }
117 ReadInputs(fSF.get(), m_mSF);
118 fSF->Close();
119 }
120
122
123 // load empty systematic variation by default
124 if (applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS )
125 return StatusCode::FAILURE;
126
127 // TauCombinedTES tool must be set up when checking compatibility between calo TES and MVA TES
129 {
131 ATH_CHECK(m_tTauCombinedTES.setProperty("WeightFileName", "CombinedTES_R22_Round2.5_v2.root"));
132 ATH_CHECK(m_tTauCombinedTES.initialize());
133 }
134
135 return StatusCode::SUCCESS;
136}
#define ASG_MAKE_ANA_TOOL(handle, type)
create the tool in the given tool handle
#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 ReadInputs(TFile *fFile, std::map< std::string, T > &mMap)

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

◆ inputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::inputMetaStore ( ) const
inherited

Accessor for the input metadata store.

Definition at line 93 of file AsgMetadataTool.cxx.

93 {
94
95#ifdef XAOD_STANDALONE
96 return &m_inputMetaStore;
97#else // XAOD_STANDALONE
98 return m_inputMetaStore;
99#endif // XAOD_STANDALONE
100 }
MetaStore_t m_inputMetaStore
Object accessing the input metadata store.

◆ isAffectedBySystematic()

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

returns: whether this tool is affected by the given systematics

Implements CP::ISystematicsTool.

Definition at line 276 of file CommonSmearingTool.cxx.

277{
278 const CP::SystematicSet& sys = affectingSystematics();
279 return sys.find(systematic) != sys.end();
280}
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by

◆ metaDataStop()

StatusCode asg::AsgMetadataTool::metaDataStop ( )
protectedvirtualinherited

Function called when the tool should write out its metadata.

Dummy implementation that can be overridden by the derived tool.

Reimplemented in BookkeeperDumperTool, BookkeeperTool, xAODMaker::TriggerMenuMetaDataTool, and xAODMaker::TruthMetaDataTool.

Definition at line 209 of file AsgMetadataTool.cxx.

209 {
210
211 // Return gracefully:
212 return StatusCode::SUCCESS;
213 }

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

◆ outputMetaStore()

AsgMetadataTool::MetaStorePtr_t asg::AsgMetadataTool::outputMetaStore ( ) const
inherited

Accessor for the output metadata store.

Definition at line 102 of file AsgMetadataTool.cxx.

102 {
103
104#ifdef XAOD_STANDALONE
105 return &m_outputMetaStore;
106#else // XAOD_STANDALONE
107 return m_outputMetaStore;
108#endif // XAOD_STANDALONE
109 }
MetaStore_t m_outputMetaStore
Object accessing the output metadata store.

◆ print()

◆ ReadInputs()

template<class T>
void CommonSmearingTool::ReadInputs ( TFile * fFile,
std::map< std::string, T > & mMap )
protected

Definition at line 388 of file CommonSmearingTool.cxx.

389{
390 // initialize function pointer
391 m_fX = &finalTauPt;
392 m_fY = &finalTauEta;
393
394 TKey *kKey;
395 TIter itNext(fFile->GetListOfKeys());
396 while ((kKey = (TKey*)itNext()))
397 {
398 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
399
400 // parse file content for objects of type TNamed, check their title for
401 // known strings and reset funtion pointer
402 std::string sKeyName = kKey->GetName();
403 if (sKeyName == "Xaxis")
404 {
405 TNamed* tObj = (TNamed*)kKey->ReadObj();
406 std::string sTitle = tObj->GetTitle();
407 delete tObj;
408 if (sTitle == "pt")
409 {
410 m_fX = &finalTauPt;
411 ATH_MSG_DEBUG("using tau pt for x-axis");
412 }
413 }
414 if (sKeyName == "Yaxis")
415 {
416 TNamed* tObj = (TNamed*)kKey->ReadObj();
417 std::string sTitle = tObj->GetTitle();
418 delete tObj;
419 if (sTitle == "|eta|")
420 {
422 ATH_MSG_DEBUG("using absolute tau eta for y-axis");
423 }
424 }
425 if (!cClass->InheritsFrom("TH1"))
426 continue;
427 T tObj = (T)kKey->ReadObj();
428 tObj->SetDirectory(0);
429 mMap[sKeyName] = tObj;
430 }
431 ATH_MSG_INFO("data loaded from " << fFile->GetName());
432}
unsigned long long T
double finalTauAbsEta(const xAOD::TauJet &xTau)
return MVA based absolute tau eta

◆ recommendedSystematics()

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

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

Implements CP::IReentrantSystematicsTool.

Definition at line 296 of file CommonSmearingTool.cxx.

297{
299}

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

◆ setUseIncidents()

void asg::AsgMetadataTool::setUseIncidents ( const bool flag)
inlineprotectedinherited

Definition at line 132 of file AsgMetadataTool.h.

133 {
135 }
bool flag
Definition master.py:29

◆ sysInitialize()

StatusCode asg::AsgMetadataTool::sysInitialize ( )
virtualinherited

Function initialising the tool in the correct way in Athena.

This function is used to set up the callbacks from IncidentSvc in Athena at the right time during initialisation, without the user having to do anything special in his/her code.

Reimplemented from AthCommonDataStore< AthCommonMsg< AlgTool > >.

Definition at line 115 of file AsgMetadataTool.cxx.

115 {
116
117#ifndef XAOD_STANDALONE
118 if (m_useIncidents) {
119 // Connect to the IncidentSvc:
120 ServiceHandle< IIncidentSvc > incSvc( "IncidentSvc", name() );
121 ATH_CHECK( incSvc.retrieve() );
122
123 // Set up the right callbacks: don't rethrow exceptions, any failure and we should end
124 incSvc->addListener( this, IncidentType::BeginEvent, 0, false );
125 }
126 // Let the base class do its thing:
127 ATH_CHECK( AlgTool::sysInitialize() );
128
129#endif // not XAOD_STANDALONE
130
131 // Return gracefully:
132 return StatusCode::SUCCESS;
133 }

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

Gaudi::Property<bool> TauAnalysisTools::CommonSmearingTool::m_bApplyFading {this, "ApplyFading", true}
protected

Definition at line 103 of file CommonSmearingTool.h.

103{this, "ApplyFading", true};

◆ m_bApplyInsituCorrection

Gaudi::Property<bool> TauAnalysisTools::CommonSmearingTool::m_bApplyInsituCorrection {this, "ApplyInsituCorrection", true}
protected

Definition at line 105 of file CommonSmearingTool.h.

105{this, "ApplyInsituCorrection", true};

◆ m_beginInputFileCalled

bool asg::AsgMetadataTool::m_beginInputFileCalled
privateinherited

Flag helping to discover when the tool misses the opening of the first input file.

Definition at line 126 of file AsgMetadataTool.h.

◆ m_bIsConfigured

bool TauAnalysisTools::CommonSmearingTool::m_bIsConfigured
protected

Definition at line 108 of file CommonSmearingTool.h.

◆ m_bIsData

bool TauAnalysisTools::CommonSmearingTool::m_bIsData
protected

Definition at line 107 of file CommonSmearingTool.h.

◆ m_bIsTESCompatibilityCheckAvailable

CxxUtils::CachedValue<bool> TauAnalysisTools::CommonSmearingTool::m_bIsTESCompatibilityCheckAvailable
private

Definition at line 118 of file CommonSmearingTool.h.

◆ m_bMVATESQualityCheck

Gaudi::Property<bool> TauAnalysisTools::CommonSmearingTool::m_bMVATESQualityCheck {this, "MVATESQualityCheck", true}
protected

Definition at line 104 of file CommonSmearingTool.h.

104{this, "MVATESQualityCheck", true};

◆ m_bSkipTruthMatchCheck

Gaudi::Property<bool> TauAnalysisTools::CommonSmearingTool::m_bSkipTruthMatchCheck {this, "SkipTruthMatchCheck", false}
protected

Definition at line 102 of file CommonSmearingTool.h.

102{this, "SkipTruthMatchCheck", false};

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

TruthMatchedParticleType TauAnalysisTools::CommonSmearingTool::m_eCheckTruth
protected

Definition at line 112 of file CommonSmearingTool.h.

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

double(* TauAnalysisTools::CommonSmearingTool::m_fX) (const xAOD::TauJet &xTau)
protected

Definition at line 89 of file CommonSmearingTool.h.

◆ m_fY

double(* TauAnalysisTools::CommonSmearingTool::m_fY) (const xAOD::TauJet &xTau)
protected

Definition at line 90 of file CommonSmearingTool.h.

◆ m_inputMetaStore

MetaStore_t asg::AsgMetadataTool::m_inputMetaStore
privateinherited

Object accessing the input metadata store.

Definition at line 119 of file AsgMetadataTool.h.

◆ m_mSF

std::map<std::string, TH1*> TauAnalysisTools::CommonSmearingTool::m_mSF
protected

Definition at line 82 of file CommonSmearingTool.h.

◆ m_mSystematics

std::map<std::string, int> TauAnalysisTools::CommonSmearingTool::m_mSystematics
protected

Definition at line 85 of file CommonSmearingTool.h.

◆ m_mSystematicSets

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

Definition at line 83 of file CommonSmearingTool.h.

◆ m_mSystematicsHistNames

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

Definition at line 86 of file CommonSmearingTool.h.

◆ m_outputMetaStore

MetaStore_t asg::AsgMetadataTool::m_outputMetaStore
privateinherited

Object accessing the output metadata store.

Definition at line 121 of file AsgMetadataTool.h.

◆ m_sAffectingSystematics

CP::SystematicSet TauAnalysisTools::CommonSmearingTool::m_sAffectingSystematics
protected

Definition at line 113 of file CommonSmearingTool.h.

◆ m_sInputFilePath

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

Definition at line 101 of file CommonSmearingTool.h.

101{this, "InputFilePath", ""};

◆ m_sRecommendedSystematics

CP::SystematicSet TauAnalysisTools::CommonSmearingTool::m_sRecommendedSystematics
protected

Definition at line 114 of file CommonSmearingTool.h.

◆ m_sSystematicSet

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

Definition at line 84 of file CommonSmearingTool.h.

◆ m_tTauCombinedTES

asg::AnaToolHandle<ITauToolBase> TauAnalysisTools::CommonSmearingTool::m_tTauCombinedTES
protected

Definition at line 110 of file CommonSmearingTool.h.

◆ m_useIncidents

bool asg::AsgMetadataTool::m_useIncidents
privateinherited

Definition at line 128 of file AsgMetadataTool.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: