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

#include <CommonDiTauSmearingTool.h>

Inheritance diagram for TauAnalysisTools::CommonDiTauSmearingTool:
Collaboration diagram for TauAnalysisTools::CommonDiTauSmearingTool:

Public Types

Definition of the StoreGate-like object's definition
typedef ServiceHandle< StoreGateSvcMetaStore_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

 CommonDiTauSmearingTool (const std::string &sName)
 Create a proper constructor for Athena.
virtual StatusCode initialize ()
 Dummy implementation of the initialisation function.
virtual CP::CorrectionCode applyCorrection (xAOD::DiTauJet &xDiTau) const
 Apply the correction on a modifiable object.
virtual CP::CorrectionCode correctedCopy (const xAOD::DiTauJet &xDiTau, xAOD::DiTauJet *&xDiTauCopy) const
 Create a corrected copy from a constant ditau.
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

template<class T>
void ReadInputs (TFile *fFile, std::map< std::string, T > &mMap)
virtual CP::CorrectionCode getValue (const std::string &sHistName, const xAOD::DiTauJet &xDiTau, double &dCorrectionFactor) 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/TEvent.
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 beginEvent ()
 Function called when a new events is loaded.
virtual StatusCode metaDataStop ()
 Function called when the tool should write out its metadata.

Protected Attributes

std::map< std::string, TH3 * > m_mDTSF
std::unordered_map< CP::SystematicSet, std::string > m_mSystematicSets
const CP::SystematicSetm_sSystematicSet
std::map< std::string, int > m_mSystematics
std::map< std::string, std::string > m_mSystematicsHistNames
double(* m_fX )(const xAOD::DiTauJet &xDiTau)
double(* m_fY )(const xAOD::DiTauJet &xDiTau)
double(* m_fZ )(const xAOD::DiTauJet &xDiTau)
Gaudi::Property< std::string > m_sInputFilePath {this, "InputFilePath", ""}
Gaudi::Property< bool > m_bSkipTruthMatchCheck {this, "SkipTruthMatchCheck", false}
bool m_bIsData
TruthMatchedParticleType m_eCheckTruth
CP::SystematicSet m_sAffectingSystematics
CP::SystematicSet m_sRecommendedSystematics

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

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 33 of file CommonDiTauSmearingTool.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 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ CommonDiTauSmearingTool()

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

Create a proper constructor for Athena.

Definition at line 21 of file CommonDiTauSmearingTool.cxx.

22 : asg::AsgMetadataTool( sName )
23 , m_sSystematicSet(nullptr)
27 , m_bIsData(false)
29{}
double(* m_fY)(const xAOD::DiTauJet &xDiTau)
double(* m_fX)(const xAOD::DiTauJet &xDiTau)
double(* m_fZ)(const xAOD::DiTauJet &xDiTau)
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.

Member Function Documentation

◆ affectingSystematics()

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

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

Implements CP::IReentrantSystematicsTool.

Definition at line 173 of file CommonDiTauSmearingTool.cxx.

◆ applyCorrection()

CP::CorrectionCode CommonDiTauSmearingTool::applyCorrection ( xAOD::DiTauJet & xDiTau) const
virtual

Apply the correction on a modifiable object.

Implements TauAnalysisTools::IDiTauSmearingTool.

Definition at line 69 of file CommonDiTauSmearingTool.cxx.

70{
71 // step out here if we run on data
72 if (m_bIsData)
74
75 // check which true state is requested
77 {
79 }
80
81 double dCorrection = 1.;
82 // get standard scale factor
83 CP::CorrectionCode tmpCorrectionCode = getValue("sf",
84 xDiTau,
85 dCorrection);
86 // return correction code if histogram is not available
87 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
88 return tmpCorrectionCode;
89
90 // skip further process if systematic set is empty
91 if (m_sSystematicSet->size() > 0)
92 {
93 // get uncertainties summed in quadrature
94 double dTotalSystematic2 = 0;
95 double dDirection = 0;
96 for (auto syst : *m_sSystematicSet)
97 {
98 // check if systematic is available
99 auto it = m_mSystematicsHistNames.find(syst.basename());
100
101 // get uncertainty value
102 double dUncertaintySyst = 0;
103 tmpCorrectionCode = getValue(it->second,
104 xDiTau,
105 dUncertaintySyst);
106
107 // return correction code if histogram is not available
108 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
109 return tmpCorrectionCode;
110
111 // needed for up/down decision
112 dDirection = syst.parameter();
113
114 // scale uncertainty with direction, i.e. +/- n*sigma
115 dUncertaintySyst *= dDirection;
116
117 // square uncertainty and add to total uncertainty
118 dTotalSystematic2 += dUncertaintySyst * dUncertaintySyst;
119 }
120
121 // now use dDirection to use up/down uncertainty
122 dDirection = (dDirection > 0) ? +1 : -1;
123
124 // finally apply uncertainty (eff * ( 1 +/- \sum )
125 dCorrection *= 1 + dDirection * std::sqrt(dTotalSystematic2);
126 }
127
128 // finally apply correction
129 xDiTau.setP4( xDiTau.pt() * dCorrection,
130 xDiTau.eta(), xDiTau.phi(), xDiTau.m());
132}
@ Ok
The correction was done successfully.
std::map< std::string, std::string > m_mSystematicsHistNames
virtual CP::CorrectionCode getValue(const std::string &sHistName, const xAOD::DiTauJet &xDiTau, double &dCorrectionFactor) const
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double m() const
The invariant mass of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
TruthMatchedParticleType getTruthParticleType(const xAOD::TauJet &xTau)
return TauJet match type

◆ applySystematicVariation()

StatusCode CommonDiTauSmearingTool::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 198 of file CommonDiTauSmearingTool.cxx.

199{
200 // first check if we already know this systematic configuration
201 auto itSystematicSet = m_mSystematicSets.find(sSystematicSet);
202 if (itSystematicSet != m_mSystematicSets.end())
203 {
204 m_sSystematicSet = &itSystematicSet->first;
205 return StatusCode::SUCCESS;
206 }
207
208 // sanity checks if systematic set is supported
209 double dDirection = 0.;
210 CP::SystematicSet sSystematicSetAvailable;
211 for (auto& sSyst : sSystematicSet)
212 {
213 // check if systematic is available
214 auto it = m_mSystematicsHistNames.find(sSyst.basename());
215 if (it == m_mSystematicsHistNames.end())
216 {
217 ATH_MSG_VERBOSE("unsupported systematic variation: "<< sSyst.basename()<<"; skipping this one");
218 continue;
219 }
220
221 if (sSyst.parameter() * dDirection < 0)
222 {
223 ATH_MSG_ERROR("unsupported set of systematic variations, you should either use only \"UP\" or only \"DOWN\" systematics in one set!");
224 ATH_MSG_ERROR("systematic set will not be applied");
225 return StatusCode::FAILURE;
226 }
227 dDirection = sSyst.parameter();
228
229 if ((m_sRecommendedSystematics.find(sSyst.basename()) != m_sRecommendedSystematics.end()) and sSystematicSet.size() > 1)
230 {
231 ATH_MSG_ERROR("unsupported set of systematic variations, you should not combine \"TAUS_{TRUE|FAKE}_SME_TOTAL\" with other systematic variations!");
232 ATH_MSG_ERROR("systematic set will not be applied");
233 return StatusCode::FAILURE;
234 }
235
236 // finally add the systematic to the set of systematics to process
237 sSystematicSetAvailable.insert(sSyst);
238 }
239
240 // store this calibration for future use, and make it current
241 m_sSystematicSet = &m_mSystematicSets.insert(std::pair<CP::SystematicSet,std::string>(sSystematicSetAvailable, sSystematicSet.name())).first->first;
242
243 return StatusCode::SUCCESS;
244}
#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 asg::AsgMetadataTool::beginEvent ( )
protectedvirtualinherited

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

◆ correctedCopy()

CP::CorrectionCode CommonDiTauSmearingTool::correctedCopy ( const xAOD::DiTauJet & xDiTau,
xAOD::DiTauJet *& xDiTauCopy ) const
virtual

Create a corrected copy from a constant ditau.

Implements TauAnalysisTools::IDiTauSmearingTool.

Definition at line 139 of file CommonDiTauSmearingTool.cxx.

141{
142
143 // A sanity check:
144 if( xDiTauCopy )
145 {
146 ATH_MSG_WARNING( "Non-null pointer received. "
147 "There's a possible memory leak!" );
148 }
149
150 // Create a new object:
151 xDiTauCopy = new xAOD::DiTauJet();
152 xDiTauCopy->makePrivateStore( xDiTau );
153
154 // Use the other function to modify this object:
155 return applyCorrection( *xDiTauCopy );
156}
#define ATH_MSG_WARNING(x)
virtual CP::CorrectionCode applyCorrection(xAOD::DiTauJet &xDiTau) const
Apply the correction on a modifiable object.
DiTauJet_v1 DiTauJet
Definition of the current version.
Definition DiTauJet.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, 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 CommonDiTauSmearingTool::generateSystematicSets ( )
protected

Definition at line 274 of file CommonDiTauSmearingTool.cxx.

275{
276 std::vector<std::string> vInputFilePath;
277 split(m_sInputFilePath,'/',vInputFilePath);
278 std::string sInputFileName = vInputFilePath.back();
279
280 // creation of basic string for all NPs, e.g. "TAUS_TRUEHADTAU_SME_TES_"
281 std::vector<std::string> vSplitInputFilePath = {};
282 split(sInputFileName,'_',vSplitInputFilePath);
283 std::string sEfficiencyType = vSplitInputFilePath.at(0);
284 std::string sTruthType = vSplitInputFilePath.at(1);
285 std::transform(sEfficiencyType.begin(), sEfficiencyType.end(), sEfficiencyType.begin(), toupper);
286 std::transform(sTruthType.begin(), sTruthType.end(), sTruthType.begin(), toupper);
287 std::string sSystematicBaseString = "TAUS_"+sTruthType+"_SME_"+sEfficiencyType+"_";
288
289 // set truth type to check for in truth matching
290 if (sTruthType=="TRUEHADTAU") m_eCheckTruth = TauAnalysisTools::TruthHadronicTau;
291 if (sTruthType=="TRUEHADDITAU") m_eCheckTruth = TauAnalysisTools::TruthHadronicDiTau;
292
293 for (auto mSF : m_mDTSF)
294 {
295 // parse for nuisance parameter in histogram name
296 std::vector<std::string> vSplitNP = {};
297 split(mSF.first,'_',vSplitNP);
298 std::string sNP = vSplitNP.at(0);
299 std::string sNPUppercase = vSplitNP.at(0);
300
301 // skip nominal scale factors
302 if (sNP == "sf") continue;
303
304 // test if NP starts with a capital letter indicating that this should be recommended
305 bool bIsRecommended = false;
306 if (isupper(sNP.at(0)))
307 bIsRecommended = true;
308
309 // make sNP uppercase and build final NP entry name
310 std::transform(sNPUppercase.begin(), sNPUppercase.end(), sNPUppercase.begin(), toupper);
311 std::string sSystematicString = sSystematicBaseString+sNPUppercase;
312
313 // add all found systematics to the AffectingSystematics
314 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
315 m_sAffectingSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
316 // only add found uppercase systematics to the RecommendedSystematics
317 if (bIsRecommended)
318 {
319 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, 1));
320 m_sRecommendedSystematics.insert(CP::SystematicVariation (sSystematicString, -1));
321 }
322
323 ATH_MSG_DEBUG("connected histogram base name " << sNP << " with systematic " <<sSystematicString);
324 m_mSystematicsHistNames.insert({sSystematicString,sNP});
325 }
326}
#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::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 CommonDiTauSmearingTool::getValue ( const std::string & sHistName,
const xAOD::DiTauJet & xDiTau,
double & dCorrectionFactor ) const
protectedvirtual

Definition at line 329 of file CommonDiTauSmearingTool.cxx.

332{
333 TH3* hHist = m_mDTSF.at(sHistName);
334 if (!hHist)
335 {
336 ATH_MSG_ERROR("Histogram with name "<<sHistName<<" was not found in input file.");
338 }
339
340 double dX = m_fX(xDiTau);
341 double dY = m_fY(xDiTau);
342 double dZ = m_fZ(xDiTau);
343
344 // protect values from underflow bins
345 dX = std::max(dX,hHist->GetXaxis()->GetXmin());
346 dY = std::max(dY,hHist->GetYaxis()->GetXmin());
347 dZ = std::max(dZ,hHist->GetZaxis()->GetXmin());
348 // protect values from overflow bins (times .999 to keep it inside last bin)
349 dX = std::min(dX,hHist->GetXaxis()->GetXmax() * .999);
350 dY = std::min(dY,hHist->GetYaxis()->GetXmax() * .999);
351 dZ = std::min(dZ,hHist->GetZaxis()->GetXmax() * .999);
352
353 int iBin = hHist->FindFixBin(dX,dY,dZ);
354 dEfficiencyScaleFactor = hHist->GetBinContent(iBin);
355
357}
@ Error
Some error happened during the object correction.

◆ handle()

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

Function receiving incidents from IncidentSvc/TEvent.

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 CommonDiTauSmearingTool::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 36 of file CommonDiTauSmearingTool.cxx.

37{
38 ATH_MSG_INFO( "Initializing CommonDiTauSmearingTool" );
39
40 // only read in histograms once
41 if (m_mDTSF.empty())
42 {
43 std::string sInputFilePath = PathResolverFindCalibFile(m_sInputFilePath);
44 std::unique_ptr< TFile > fSF( TFile::Open(sInputFilePath.c_str(), "READ") );
45 if(fSF == nullptr)
46 {
47 ATH_MSG_FATAL("Could not open file " << sInputFilePath.c_str());
48 return StatusCode::FAILURE;
49 }
50 ReadInputs(fSF.get(), m_mDTSF);
51 fSF->Close();
52 }
53
55
56 // load empty systematic variation by default
57 if (applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS )
58 return StatusCode::FAILURE;
59
60 return StatusCode::SUCCESS;
61}
#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 CommonDiTauSmearingTool::isAffectedBySystematic ( const CP::SystematicVariation & systematic) const
virtual

returns: whether this tool is affected by the given systematics

Implements CP::ISystematicsTool.

Definition at line 162 of file CommonDiTauSmearingTool.cxx.

163{
164 CP::SystematicSet sys = affectingSystematics();
165 return sys.find(systematic) != sys.end();
166}
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 CommonDiTauSmearingTool::ReadInputs ( TFile * fFile,
std::map< std::string, T > & mMap )
protected

Definition at line 249 of file CommonDiTauSmearingTool.cxx.

250{
251 // initialize function pointer
252 m_fX = &TruthLeadPt;
254 m_fZ = &TruthDeltaR;
255
256 TKey *kKey;
257 TIter itNext(fFile->GetListOfKeys());
258 while ((kKey = (TKey*)itNext()))
259 {
260 TClass *cClass = gROOT->GetClass(kKey->GetClassName());
261 std::string sKeyName = kKey->GetName();
262
263 if (!cClass->InheritsFrom("TH3"))
264 continue;
265
266 T tObj = (T)kKey->ReadObj();
267 tObj->SetDirectory(0);
268 mMap[sKeyName] = tObj;
269 }
270 ATH_MSG_INFO("data loaded from " << fFile->GetName());
271}
unsigned long long T

◆ recommendedSystematics()

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

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

Implements CP::IReentrantSystematicsTool.

Definition at line 182 of file CommonDiTauSmearingTool.cxx.

183{
185}

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

◆ 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 }
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ 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_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_bIsData

bool TauAnalysisTools::CommonDiTauSmearingTool::m_bIsData
protected

Definition at line 87 of file CommonDiTauSmearingTool.h.

◆ m_bSkipTruthMatchCheck

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

Definition at line 85 of file CommonDiTauSmearingTool.h.

85{this, "SkipTruthMatchCheck", false};

◆ 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::CommonDiTauSmearingTool::m_eCheckTruth
protected

Definition at line 89 of file CommonDiTauSmearingTool.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_fX

double(* TauAnalysisTools::CommonDiTauSmearingTool::m_fX) (const xAOD::DiTauJet &xDiTau)
protected

Definition at line 73 of file CommonDiTauSmearingTool.h.

◆ m_fY

double(* TauAnalysisTools::CommonDiTauSmearingTool::m_fY) (const xAOD::DiTauJet &xDiTau)
protected

Definition at line 74 of file CommonDiTauSmearingTool.h.

◆ m_fZ

double(* TauAnalysisTools::CommonDiTauSmearingTool::m_fZ) (const xAOD::DiTauJet &xDiTau)
protected

Definition at line 75 of file CommonDiTauSmearingTool.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_mDTSF

std::map<std::string, TH3*> TauAnalysisTools::CommonDiTauSmearingTool::m_mDTSF
protected

Definition at line 67 of file CommonDiTauSmearingTool.h.

◆ m_mSystematics

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

Definition at line 70 of file CommonDiTauSmearingTool.h.

◆ m_mSystematicSets

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

Definition at line 68 of file CommonDiTauSmearingTool.h.

◆ m_mSystematicsHistNames

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

Definition at line 71 of file CommonDiTauSmearingTool.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::CommonDiTauSmearingTool::m_sAffectingSystematics
protected

Definition at line 90 of file CommonDiTauSmearingTool.h.

◆ m_sInputFilePath

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

Definition at line 84 of file CommonDiTauSmearingTool.h.

84{this, "InputFilePath", ""};

◆ m_sRecommendedSystematics

CP::SystematicSet TauAnalysisTools::CommonDiTauSmearingTool::m_sRecommendedSystematics
protected

Definition at line 91 of file CommonDiTauSmearingTool.h.

◆ m_sSystematicSet

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

Definition at line 69 of file CommonDiTauSmearingTool.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 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: