ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::InDetTrackBiasingTool Class Referenceabstract

This class biases tracks to emulate systematic distortions of the tracking geometry. More...

#include <InDetTrackBiasingTool.h>

Inheritance diagram for InDet::InDetTrackBiasingTool:
Collaboration diagram for InDet::InDetTrackBiasingTool:

Public Types

typedef xAOD::TrackParticleContainer xAODContainerType
 description: the type of xAOD container used
typedef xAODContainerType::base_value_type xAODObjectType
 description: the type of xAOD object used

Public Member Functions

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
virtual CorrectionCode applyCorrection (xAODObjectType &inputObject)=0
 effects: apply the correction and store the output in the object returns: success
CorrectionCode correctedCopy (const xAODObjectType &inputObject, xAODObjectType *&outputObject)
 effects: make a clone of the input object, apply the correction to it and store the output in the object returns: success rationale: the interface class provides a default implementation in terms of applyCorrection, that the derived classes can override for efficiency
CorrectionCode applyContainerCorrection (xAODContainerType &inputContainer)
 effects: apply the correction to all the members of the container returns: overall success rationale: this will apply the correction to every single member (even if some members fail) rationale: the interface class provides a default implementation in terms of applyCorrection, that the derived classes can override for efficiency
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

StatusCode initHistograms ()
CP::CorrectionCode applyBiasWithSyst (xAOD::TrackParticle &track, const CP::SystematicSet &filtered) const
 Core biasing logic; delegates from both applyCorrection overloads.
float readHistogram (float fDefault, TH2 *histogram, float phi, float eta) const
std::unique_ptr< TFile > getFile (const std::string &) const
 open and return a file with the given name.
template<class T>
StatusCode initObject (std::unique_ptr< T > &obj, const std::string &rootFileName, const std::string &objName) const
 a function to initialize an object from a root file
bool isActive (TrackSystematic) const
bool isActive (TrackSystematic syst, const CP::SystematicSet &filtered) const
 Reentrant variant of isActive(): checks syst against a caller-provided filtered set rather than the shared m_activeSysts.
const CP::SystematicSet * getFilteredSysts (const CP::SystematicSet &syst) const
 Look up the pre-filtered systematic set for syst.
uint64_t activeVariationMask () const
 variationMask() of the set activated by applySystematicVariation()
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 uint64_t variationMask (const CP::SystematicSet &filtered)
 Extra per-track PRNG seed term so each variation draws independent random numbers: one bit per active TrackSystematic (enum value as bit index).

Protected Attributes

std::vector< std::unique_ptr< TH2 > > m_biasD0Histograms
std::vector< std::unique_ptr< TH2 > > m_biasZ0Histograms
std::vector< std::unique_ptr< TH2 > > m_biasQoverPsagittaHistograms
std::string m_d0_nominal_histName = "d0/d0_theNominal"
std::string m_z0_nominal_histName = "z0/z0_theNominal"
std::string m_sagitta_nominal_histName = "sagitta/sagitta_theNominal"
Gaudi::Property< float > m_biasD0 {this, "biasD0", 0.f, "Overall d0 bias (mm)."}
Gaudi::Property< float > m_biasZ0 {this, "biasZ0", 0.f, "Overall z0 bias (mm)."}
Gaudi::Property< float > m_biasQoverPsagitta {this, "biasQoverPsagitta", 0.f, "Overall QoverP sagitta bias (TeV^-1)."}
Gaudi::Property< bool > m_applyD0Bias {this, "applyD0Bias", true, "Whether to apply the d0 bias from the calibration map."}
Gaudi::Property< bool > m_applyZ0Bias {this, "applyZ0Bias", true, "Whether to apply the z0 bias from the calibration map."}
Gaudi::Property< bool > m_applyQoverPBias {this, "applyQoverPBias", true, "Whether to apply the q/p sagitta bias from the calibration map."}
Gaudi::Property< bool > m_isMC {this, "isMC", true}
Gaudi::Property< uint32_t > m_runNumber {this, "runNumber", 0, "Manually override the run number used to select the calibration period."}
Gaudi::Property< std::vector< std::string > > m_calibFiles {this, "calibFiles", {}, "Calibration files, one per run period."}
Gaudi::Property< std::vector< unsigned int > > m_runNumberBounds {this, "runNumberBounds", {}, "Run number boundaries: {lower0, upper0, upper1, ...}. May be omitted when only one calibration file is configured."}
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey {this, "EvtInfo", "EventInfo", "EventInfo name"}
SG::ReadDecorHandleKey< xAOD::EventInfo > m_randomRunNumberKey
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap
const CP::SystematicSet * m_activeSysts = nullptr

Private Types

typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

virtual ASG_TOOL_CLASS(InDetTrackBiasingTool, InDet::IInDetTrackBiasingTool) public ~InDetTrackBiasingTool ()
virtual StatusCode initialize () override
virtual void prepare () override
virtual CP::CorrectionCode applyCorrection (xAOD::TrackParticle &track) override
 Computes the tracks origin.
virtual CP::CorrectionCode correctedCopy (const xAOD::TrackParticle &in, xAOD::TrackParticle *&out) override
virtual CP::CorrectionCode applyContainerCorrection (xAOD::TrackParticleContainer &cont) override
virtual CP::CorrectionCode applyCorrection (xAOD::TrackParticle &track, const CP::SystematicSet &syst) const override
 Reentrant biasing (see IInDetTrackBiasingTool).
virtual bool isAffectedBySystematic (const CP::SystematicVariation &) const override
 returns: whether the tool is affected by the systematic
virtual CP::SystematicSet affectingSystematics () const override
 returns: list of systematics this tool can be affected by
virtual CP::SystematicSet recommendedSystematics () const override
 returns: list of recommended systematics to use with this tool
virtual StatusCode applySystematicVariation (const CP::SystematicSet &) override
 configure the tool to apply a given list of systematic variations
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

This class biases tracks to emulate systematic distortions of the tracking geometry.

Author
Pawel Bruckman (pawel.nosp@m..bru.nosp@m.ckman.nosp@m..de..nosp@m.renst.nosp@m.rom@.nosp@m.cern..nosp@m.ch)
Felix Clark (micha.nosp@m.el.r.nosp@m.yan.c.nosp@m.lark.nosp@m.@cern.nosp@m..ch)

In data, it corrects the biases. In simulation, it applys the biases in the same direction they are observed in the data.

Author
Pawel Bruckman (pawel.nosp@m..bru.nosp@m.ckman.nosp@m..de..nosp@m.renst.nosp@m.rom@.nosp@m.cern..nosp@m.ch)
Felix Clark (micha.nosp@m.el.r.nosp@m.yan.c.nosp@m.lark.nosp@m.@cern.nosp@m..ch)

Definition at line 40 of file InDetTrackBiasingTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

◆ xAODContainerType

description: the type of xAOD container used

Definition at line 46 of file CorrectionTool.h.

◆ xAODObjectType

description: the type of xAOD object used

Definition at line 48 of file CorrectionTool.h.

Member Function Documentation

◆ activeVariationMask()

uint64_t InDet::InDetTrackSystematicsTool::activeVariationMask ( ) const
protectedinherited

variationMask() of the set activated by applySystematicVariation()

Definition at line 131 of file InDetTrackSystematicsTool.cxx.

132 {
134 }
static uint64_t variationMask(const CP::SystematicSet &filtered)
Extra per-track PRNG seed term so each variation draws independent random numbers: one bit per active...

◆ affectingSystematics()

CP::SystematicSet InDet::InDetTrackBiasingTool::affectingSystematics ( ) const
overrideprivatevirtual

returns: list of systematics this tool can be affected by

Implements InDet::IInDetTrackBiasingTool.

Definition at line 238 of file InDetTrackBiasingTool.cxx.

239 {
240 CP::SystematicSet result;
241 if (m_applyD0Bias) result.insert(InDet::TrackSystematicMap.at(TRK_BIAS_D0_WM));
242 if (m_applyZ0Bias) result.insert(InDet::TrackSystematicMap.at(TRK_BIAS_Z0_WM));
243 if (m_applyQoverPBias) result.insert(InDet::TrackSystematicMap.at(TRK_BIAS_QOVERP_SAGITTA_WM));
244 return result;
245 }
Gaudi::Property< bool > m_applyQoverPBias
Gaudi::Property< bool > m_applyZ0Bias
Gaudi::Property< bool > m_applyD0Bias
mapped_type at(key_type key) const
Look up an element in the map.

◆ applyBiasWithSyst()

CP::CorrectionCode InDet::InDetTrackBiasingTool::applyBiasWithSyst ( xAOD::TrackParticle & track,
const CP::SystematicSet & filtered ) const
protected

Core biasing logic; delegates from both applyCorrection overloads.

Definition at line 79 of file InDetTrackBiasingTool.cxx.

81 {
82 if ( !m_isMC ) {
83 ATH_MSG_ERROR( "InDetTrackBiasingTool should only be run on MC." );
85 }
86
87 // determine which run number to use
88 SG::ReadHandle<xAOD::EventInfo> eventInfo(m_evtInfoKey);
89 SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> randomRunNumber(m_randomRunNumberKey);
90 const unsigned int runNumber = randomRunNumber(*eventInfo);
91
92 if (runNumber <= 0) {
93 ATH_MSG_WARNING( "Run number not set." );
94 }
95 // 5 TeV and heavy-ion runs have no biasing maps
96 if (runNumber >= 286282 && runNumber <= 287931) {
97 ATH_MSG_ERROR( "The 5 TeV and heavy ion runs do not have biasing maps for release 22. "
98 "Contact the tracking CP group to discuss the derivation of these maps." );
100 }
101
102 // find which configured period this run belongs to
103 size_t periodIdx = m_calibFiles.size(); // sentinel: no match
104 if (m_runNumberBounds.empty()) {
105 periodIdx = 0; // single period, accept all run numbers
106 } else {
107 for (size_t i = 0; i + 1 < m_runNumberBounds.size(); ++i) {
108 if (runNumber > m_runNumberBounds[i] && runNumber <= m_runNumberBounds[i+1]) {
109 periodIdx = i;
110 break;
111 }
112 }
113 }
114 if (periodIdx >= m_calibFiles.size()) {
115 ATH_MSG_ERROR( "Run number = " << runNumber << " does not fall within any configured calibration period." );
117 }
118
119 // select histograms for the matched period
120 TH2* biasD0Histogram = m_biasD0Histograms[periodIdx].get();
121 TH2* biasZ0Histogram = m_biasZ0Histograms[periodIdx].get();
122 TH2* biasQoverPsagittaHistogram = m_biasQoverPsagittaHistograms[periodIdx].get();
123
124 bool doD0Bias = m_applyD0Bias && biasD0Histogram != nullptr;
125 bool doZ0Bias = m_applyZ0Bias && biasZ0Histogram != nullptr;
126 bool doQoverPBias = m_applyQoverPBias && biasQoverPsagittaHistogram != nullptr;
127
128 if (m_applyD0Bias && !biasD0Histogram) ATH_MSG_WARNING( "d0 bias histogram is nullptr. Will not perform d0 bias." );
129 if (m_applyZ0Bias && !biasZ0Histogram) ATH_MSG_WARNING( "z0 bias histogram is nullptr. Will not perform z0 bias." );
130 if (m_applyQoverPBias && !biasQoverPsagittaHistogram) ATH_MSG_WARNING( "q/p bias histogram is nullptr. Will not perform q/p sagitta bias." );
131
132 // declare static accessors to avoid repeating string lookups
133 static const SG::Accessor< float > accD0( "d0" );
134 static const SG::Accessor< float > accZ0( "z0" );
135 static const SG::Accessor< float > accQOverP( "qOverP" );
136
137 const float phi = track.phi0();
138 const float eta = track.eta();
139
140 // do the biasing
141 // Always apply the correction to the nominal; undo it for systematic variations
142 if ( doD0Bias ) {
143 const float d0Corr = readHistogram(m_biasD0, biasD0Histogram, phi, eta);
144 accD0( track ) += d0Corr;
145 if ( isActive( TRK_BIAS_D0_WM, filtered ) ) {
146 accD0( track ) -= d0Corr;
147 }
148 }
149 if ( doZ0Bias ) {
150 const float z0Corr = readHistogram(m_biasZ0, biasZ0Histogram, phi, eta);
151 accZ0( track ) += z0Corr;
152 if ( isActive( TRK_BIAS_Z0_WM, filtered ) ) {
153 accZ0( track ) -= z0Corr;
154 }
155 }
156 if ( doQoverPBias ) {
157 auto sinTheta = 1.0 / std::cosh(eta);
158 const float qOverPCorr = 1.e-6*sinTheta*readHistogram(m_biasQoverPsagitta, biasQoverPsagittaHistogram, phi, eta);
159 accQOverP( track ) += qOverPCorr;
160 if ( isActive( TRK_BIAS_QOVERP_SAGITTA_WM, filtered ) ) {
161 accQOverP( track ) -= qOverPCorr;
162 }
163 }
164
166 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
float readHistogram(float fDefault, TH2 *histogram, float phi, float eta) const
Gaudi::Property< float > m_biasQoverPsagitta
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
std::vector< std::unique_ptr< TH2 > > m_biasD0Histograms
Gaudi::Property< std::vector< std::string > > m_calibFiles
Gaudi::Property< float > m_biasZ0
Gaudi::Property< float > m_biasD0
Gaudi::Property< std::vector< unsigned int > > m_runNumberBounds
std::vector< std::unique_ptr< TH2 > > m_biasQoverPsagittaHistograms
std::vector< std::unique_ptr< TH2 > > m_biasZ0Histograms
SG::ReadDecorHandleKey< xAOD::EventInfo > m_randomRunNumberKey

◆ applyContainerCorrection() [1/2]

effects: apply the correction to all the members of the container returns: overall success rationale: this will apply the correction to every single member (even if some members fail) rationale: the interface class provides a default implementation in terms of applyCorrection, that the derived classes can override for efficiency

◆ applyContainerCorrection() [2/2]

CP::CorrectionCode InDet::InDetTrackBiasingTool::applyContainerCorrection ( xAOD::TrackParticleContainer & cont)
overrideprivatevirtual

Implements InDet::IInDetTrackBiasingTool.

Definition at line 228 of file InDetTrackBiasingTool.cxx.

229 {
230 return TrackCorrTool_t::applyContainerCorrection(cont);
231 }

◆ applyCorrection() [1/3]

effects: apply the correction and store the output in the object returns: success

◆ applyCorrection() [2/3]

CP::CorrectionCode InDet::InDetTrackBiasingTool::applyCorrection ( xAOD::TrackParticle & track)
overrideprivatevirtual

Computes the tracks origin.

Implements InDet::IInDetTrackBiasingTool.

Definition at line 63 of file InDetTrackBiasingTool.cxx.

63 {
64 if (m_activeSysts == nullptr) {
65 ATH_MSG_ERROR( "applySystematicVariation() was not called before applyCorrection()." );
67 }
68 return applyBiasWithSyst(track, *m_activeSysts);
69 }
CP::CorrectionCode applyBiasWithSyst(xAOD::TrackParticle &track, const CP::SystematicSet &filtered) const
Core biasing logic; delegates from both applyCorrection overloads.

◆ applyCorrection() [3/3]

CP::CorrectionCode InDet::InDetTrackBiasingTool::applyCorrection ( xAOD::TrackParticle & track,
const CP::SystematicSet & syst ) const
overrideprivatevirtual

Reentrant biasing (see IInDetTrackBiasingTool).

Implements InDet::IInDetTrackBiasingTool.

Definition at line 71 of file InDetTrackBiasingTool.cxx.

73 {
74 const CP::SystematicSet* filtered = getFilteredSysts(syst);
75 if (filtered == nullptr) return CP::CorrectionCode::Error;
76 return applyBiasWithSyst(track, *filtered);
77 }
const CP::SystematicSet * getFilteredSysts(const CP::SystematicSet &syst) const
Look up the pre-filtered systematic set for syst.

◆ applySystematicVariation()

StatusCode InDet::InDetTrackBiasingTool::applySystematicVariation ( const CP::SystematicSet & systs)
overrideprivatevirtual

configure the tool to apply a given list of systematic variations

Implements InDet::IInDetTrackBiasingTool.

Definition at line 252 of file InDetTrackBiasingTool.cxx.

253 {
255 }
virtual StatusCode applySystematicVariation(const CP::SystematicSet &) override
configure the tool to apply a given list of systematic variations

◆ correctedCopy() [1/2]

effects: make a clone of the input object, apply the correction to it and store the output in the object returns: success rationale: the interface class provides a default implementation in terms of applyCorrection, that the derived classes can override for efficiency

◆ correctedCopy() [2/2]

CP::CorrectionCode InDet::InDetTrackBiasingTool::correctedCopy ( const xAOD::TrackParticle & in,
xAOD::TrackParticle *& out )
overrideprivatevirtual

Implements InDet::IInDetTrackBiasingTool.

Definition at line 222 of file InDetTrackBiasingTool.cxx.

224 {
225 return TrackCorrTool_t::correctedCopy(in, out);
226 }

◆ 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

◆ getFile()

std::unique_ptr< TFile > InDet::InDetTrackSystematicsTool::getFile ( const std::string & filename) const
protectedinherited

open and return a file with the given name.

Definition at line 136 of file InDetTrackSystematicsTool.cxx.

137 {
138 // now the files are stored in the calibration area
139 // filename is configurable in each tool and should include the path starting from the package name
140 // but defaults to recommendation for current release
141 std::string filenameWithFullPath = PathResolverFindCalibFile(filename);
142
143 return std::unique_ptr<TFile>(TFile::Open(filenameWithFullPath.data(), "READ"));;
144 }
std::string PathResolverFindCalibFile(const std::string &logical_file_name)

◆ getFilteredSysts()

const CP::SystematicSet * InDet::InDetTrackSystematicsTool::getFilteredSysts ( const CP::SystematicSet & syst) const
protectedinherited

Look up the pre-filtered systematic set for syst.

Returns nullptr if syst was never passed to applySystematicVariation() (e.g. not called during initialize()). Safe to call concurrently from execute() since m_sysFilterMap is read-only after initialize().

Definition at line 100 of file InDetTrackSystematicsTool.cxx.

102 {
103 // m_sysFilterMap is populated during initialize() (single-threaded)
104 // and is read-only during execute(), so no lock is required.
105 auto it = m_sysFilterMap.find(syst);
106 if (it == m_sysFilterMap.end()) {
107 ATH_MSG_ERROR( "Systematic set '" << syst.name()
108 << "' was not pre-registered. "
109 "Call applySystematicVariation() during initialize()." );
110 return nullptr;
111 }
112 return &it->second;
113 }
const std::string & name() const
returns: the systematics joined into a single string.
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_sysFilterMap

◆ getKey()

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

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

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

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

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

Definition at line 119 of file AsgTool.cxx.

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

◆ getName()

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

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

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

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

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

Definition at line 106 of file AsgTool.cxx.

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

◆ getProperty()

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

Get one of the tool's properties.

◆ initHistograms()

StatusCode InDet::InDetTrackBiasingTool::initHistograms ( )
protected

Definition at line 168 of file InDetTrackBiasingTool.cxx.

169 {
170
171 if (m_calibFiles.empty()) {
172 ATH_MSG_ERROR( "No calibration files configured. Set 'calibFiles' and (for multiple periods) "
173 "'runNumberBounds' for the relevant MC campaign via the python configuration." );
174 return StatusCode::FAILURE;
175 }
176 if (!m_runNumberBounds.empty() && m_runNumberBounds.size() != m_calibFiles.size() + 1) {
177 ATH_MSG_ERROR( "'runNumberBounds' (size " << m_runNumberBounds.size() << ") must have "
178 "calibFiles.size() + 1 = " << (m_calibFiles.size() + 1) << " entries." );
179 return StatusCode::FAILURE;
180 }
181 if (m_runNumberBounds.empty() && m_calibFiles.size() > 1) {
182 ATH_MSG_ERROR( "'runNumberBounds' must be set when multiple calibration files are configured." );
183 return StatusCode::FAILURE;
184 }
185
186 for (size_t i = 0; i < m_calibFiles.size(); ++i) {
187 if (m_runNumberBounds.empty()) {
188 ATH_MSG_INFO( "Calibration period 0 (all run numbers): file: "
190 } else {
191 ATH_MSG_INFO( "Calibration period " << i << ": run range ["
192 << m_runNumberBounds[i] << ", " << m_runNumberBounds[i+1]
193 << "], file: " << PathResolverFindCalibFile(m_calibFiles[i]) );
194 }
195 m_biasD0Histograms.emplace_back(nullptr);
197 m_biasZ0Histograms.emplace_back(nullptr);
199 m_biasQoverPsagittaHistograms.emplace_back(nullptr);
201 }
202
203 return StatusCode::SUCCESS;
204 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
StatusCode initObject(std::unique_ptr< T > &obj, const std::string &rootFileName, const std::string &objName) const
a function to initialize an object from a root file

◆ initialize()

StatusCode InDet::InDetTrackBiasingTool::initialize ( void )
overrideprivatevirtual

Implements InDet::IInDetTrackBiasingTool.

Definition at line 30 of file InDetTrackBiasingTool.cxx.

31 {
32 if (m_biasD0 != 0.) {
33 ATH_MSG_INFO( "overall d0 bias added = " << m_biasD0
34 << " mm (not part of an official recommendation)" );
35 }
36 if (m_biasZ0 != 0.) {
37 ATH_MSG_INFO( "overall z0 bias added = " << m_biasZ0
38 << " mm (not part of an official recommendation)" );
39 }
40 if (m_biasQoverPsagitta != 0.) {
41 ATH_MSG_INFO( "overall QoverP sagitta bias added = " << m_biasQoverPsagitta
42 << " TeV^-1 (not part of an official recommendation)" );
43 }
44
45 if (m_runNumber > 0) {
46 ATH_MSG_WARNING( "Using manually-set run number (" << m_runNumber << ") to determine which calibration file to use." );
47 }
48
50
51 ATH_CHECK(m_evtInfoKey.initialize());
52 ATH_CHECK(m_randomRunNumberKey.initialize(m_isMC.value()));
53
55
56 return StatusCode::SUCCESS;
57 }
Gaudi::Property< uint32_t > m_runNumber
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.

◆ initObject()

template<class T>
StatusCode InDet::InDetTrackSystematicsTool::initObject ( std::unique_ptr< T > & obj,
const std::string & rootFileName,
const std::string & objName ) const
protectedinherited

a function to initialize an object from a root file

Definition at line 84 of file InDetTrackSystematicsTool.h.

85{
86 if (obj != nullptr) ATH_MSG_WARNING( obj->GetName() << " is not null, yet we are now attempting to initialize from " << rootFileName );
87 std::unique_ptr<TFile> F = getFile(rootFileName);
88 if(!F || F->IsZombie()) {
89 ATH_MSG_ERROR( "Could not open file " << rootFileName );
90 return StatusCode::FAILURE;
91 }
92 T* tempObj = nullptr;
93 F->GetObject(objName.data(), tempObj);
94 if(tempObj==nullptr) {
95 ATH_MSG_ERROR( "Could not retrieve " << objName << " from file " << rootFileName );
96 return StatusCode::FAILURE;
97 }
98 obj = std::unique_ptr<T>(static_cast<T*>(tempObj->Clone()));
99 obj->SetDirectory(0);
100 F->Clear();
101 F->Close();
102 return StatusCode::SUCCESS;
103}
#define F(x, y, z)
Definition MD5.cxx:112
std::unique_ptr< TFile > getFile(const std::string &) const
open and return a file with the given name.
unsigned long long T

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

◆ isActive() [1/2]

bool InDet::InDetTrackSystematicsTool::isActive ( TrackSystematic syst,
const CP::SystematicSet & filtered ) const
protectedinherited

Reentrant variant of isActive(): checks syst against a caller-provided filtered set rather than the shared m_activeSysts.

Definition at line 115 of file InDetTrackSystematicsTool.cxx.

117 {
118 return filtered.find(InDet::TrackSystematicMap.at(syst))
119 != filtered.end();
120 }
const_iterator end() const
description: const iterator to the end of the set
iterator find(const SystematicVariation &sys) const
description: find an element in the set

◆ isActive() [2/2]

bool InDet::InDetTrackSystematicsTool::isActive ( TrackSystematic syst) const
protectedinherited

Definition at line 89 of file InDetTrackSystematicsTool.cxx.

90 {
91 if (m_activeSysts == nullptr) {
92 ATH_MSG_DEBUG( "applySystematicsVariation() has not been successfully called." );
93 return false;
94 }
95 const auto it_syst = m_activeSysts->find(InDet::TrackSystematicMap.at(syst));
96 return it_syst != m_activeSysts->end();
97 }
#define ATH_MSG_DEBUG(x,...)

◆ isAffectedBySystematic()

bool InDet::InDetTrackBiasingTool::isAffectedBySystematic ( const CP::SystematicVariation & syst) const
overrideprivatevirtual

returns: whether the tool is affected by the systematic

Implements InDet::IInDetTrackBiasingTool.

Definition at line 233 of file InDetTrackBiasingTool.cxx.

234 {
236 }
virtual bool isAffectedBySystematic(const CP::SystematicVariation &) const override
returns: whether the tool is affected by the systematic

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

◆ prepare()

virtual void InDet::InDetTrackBiasingTool::prepare ( )
inlineoverrideprivatevirtual

Implements InDet::IInDetTrackBiasingTool.

Definition at line 55 of file InDetTrackBiasingTool.h.

55{};

◆ print()

◆ readHistogram()

float InDet::InDetTrackBiasingTool::readHistogram ( float fDefault,
TH2 * histogram,
float phi,
float eta ) const
protected

Definition at line 206 of file InDetTrackBiasingTool.cxx.

206 {
207 if (histogram == nullptr) {
208 ATH_MSG_ERROR( "Configuration histogram is invalid. Check the run number and systematic configuration combination.");
209 throw std::runtime_error( "invalid configuration" );
210 }
211
212 // safety measure:
213 if( eta>2.499 ) eta= 2.499;
214 if( eta<-2.499 ) eta=-2.499;
215
216 float f = histogram->GetBinContent(histogram->FindBin(eta, phi));
217 f += fDefault; // should be zero unless a manual override is provided
218
219 return f;
220 }
std::string histogram
Definition chains.cxx:52

◆ recommendedSystematics()

CP::SystematicSet InDet::InDetTrackBiasingTool::recommendedSystematics ( ) const
overrideprivatevirtual

returns: list of recommended systematics to use with this tool

Implements InDet::IInDetTrackBiasingTool.

Definition at line 247 of file InDetTrackBiasingTool.cxx.

248 {
250 }
virtual CP::SystematicSet recommendedSystematics() const override
returns: list of recommended systematics to use with this tool

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

◆ sysInitialize()

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

Perform system initialization for an algorithm.

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

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

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 298 of file AthCommonDataStore.h.

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

◆ variationMask()

uint64_t InDet::InDetTrackSystematicsTool::variationMask ( const CP::SystematicSet & filtered)
staticprotectedinherited

Extra per-track PRNG seed term so each variation draws independent random numbers: one bit per active TrackSystematic (enum value as bit index).

Definition at line 122 of file InDetTrackSystematicsTool.cxx.

123 {
124 uint64_t mask = 0;
125 for (const auto& [syst, var] : InDet::TrackSystematicMap) {
126 if (filtered.find(var) != filtered.end()) mask |= (uint64_t{1} << syst);
127 }
128 return mask;
129 }

◆ ~InDetTrackBiasingTool()

InDet::InDetTrackBiasingTool::~InDetTrackBiasingTool ( )
privatevirtual

Definition at line 59 of file InDetTrackBiasingTool.cxx.

59 {
60 m_runNumber = -1;
61 }

Member Data Documentation

◆ m_activeSysts

const CP::SystematicSet* InDet::InDetTrackSystematicsTool::m_activeSysts = nullptr
protectedinherited

Definition at line 55 of file InDetTrackSystematicsTool.h.

◆ m_applyD0Bias

Gaudi::Property<bool> InDet::InDetTrackBiasingTool::m_applyD0Bias {this, "applyD0Bias", true, "Whether to apply the d0 bias from the calibration map."}
protected

Definition at line 99 of file InDetTrackBiasingTool.h.

99{this, "applyD0Bias", true, "Whether to apply the d0 bias from the calibration map."};

◆ m_applyQoverPBias

Gaudi::Property<bool> InDet::InDetTrackBiasingTool::m_applyQoverPBias {this, "applyQoverPBias", true, "Whether to apply the q/p sagitta bias from the calibration map."}
protected

Definition at line 101 of file InDetTrackBiasingTool.h.

101{this, "applyQoverPBias", true, "Whether to apply the q/p sagitta bias from the calibration map."};

◆ m_applyZ0Bias

Gaudi::Property<bool> InDet::InDetTrackBiasingTool::m_applyZ0Bias {this, "applyZ0Bias", true, "Whether to apply the z0 bias from the calibration map."}
protected

Definition at line 100 of file InDetTrackBiasingTool.h.

100{this, "applyZ0Bias", true, "Whether to apply the z0 bias from the calibration map."};

◆ m_biasD0

Gaudi::Property<float> InDet::InDetTrackBiasingTool::m_biasD0 {this, "biasD0", 0.f, "Overall d0 bias (mm)."}
protected

Definition at line 95 of file InDetTrackBiasingTool.h.

95{this, "biasD0", 0.f, "Overall d0 bias (mm)."};

◆ m_biasD0Histograms

std::vector<std::unique_ptr<TH2> > InDet::InDetTrackBiasingTool::m_biasD0Histograms
protected

Definition at line 86 of file InDetTrackBiasingTool.h.

◆ m_biasQoverPsagitta

Gaudi::Property<float> InDet::InDetTrackBiasingTool::m_biasQoverPsagitta {this, "biasQoverPsagitta", 0.f, "Overall QoverP sagitta bias (TeV^-1)."}
protected

Definition at line 97 of file InDetTrackBiasingTool.h.

97{this, "biasQoverPsagitta", 0.f, "Overall QoverP sagitta bias (TeV^-1)."};

◆ m_biasQoverPsagittaHistograms

std::vector<std::unique_ptr<TH2> > InDet::InDetTrackBiasingTool::m_biasQoverPsagittaHistograms
protected

Definition at line 88 of file InDetTrackBiasingTool.h.

◆ m_biasZ0

Gaudi::Property<float> InDet::InDetTrackBiasingTool::m_biasZ0 {this, "biasZ0", 0.f, "Overall z0 bias (mm)."}
protected

Definition at line 96 of file InDetTrackBiasingTool.h.

96{this, "biasZ0", 0.f, "Overall z0 bias (mm)."};

◆ m_biasZ0Histograms

std::vector<std::unique_ptr<TH2> > InDet::InDetTrackBiasingTool::m_biasZ0Histograms
protected

Definition at line 87 of file InDetTrackBiasingTool.h.

◆ m_calibFiles

Gaudi::Property<std::vector<std::string> > InDet::InDetTrackBiasingTool::m_calibFiles {this, "calibFiles", {}, "Calibration files, one per run period."}
protected

Definition at line 110 of file InDetTrackBiasingTool.h.

110{this, "calibFiles", {}, "Calibration files, one per run period."};

◆ m_d0_nominal_histName

std::string InDet::InDetTrackBiasingTool::m_d0_nominal_histName = "d0/d0_theNominal"
protected

Definition at line 91 of file InDetTrackBiasingTool.h.

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

SG::ReadHandleKey<xAOD::EventInfo> InDet::InDetTrackBiasingTool::m_evtInfoKey {this, "EvtInfo", "EventInfo", "EventInfo name"}
protected

Definition at line 113 of file InDetTrackBiasingTool.h.

113{this, "EvtInfo", "EventInfo", "EventInfo name"};

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

Gaudi::Property<bool> InDet::InDetTrackBiasingTool::m_isMC {this, "isMC", true}
protected

Definition at line 103 of file InDetTrackBiasingTool.h.

103{this, "isMC", true};

◆ m_randomRunNumberKey

SG::ReadDecorHandleKey<xAOD::EventInfo> InDet::InDetTrackBiasingTool::m_randomRunNumberKey
protected
Initial value:
{this, "RandomRunNumber",
m_evtInfoKey, "RandomRunNumber", "Random run number decoration from the pileup reweighting"}

Definition at line 114 of file InDetTrackBiasingTool.h.

114 {this, "RandomRunNumber",
115 m_evtInfoKey, "RandomRunNumber", "Random run number decoration from the pileup reweighting"};

◆ m_runNumber

Gaudi::Property<uint32_t> InDet::InDetTrackBiasingTool::m_runNumber {this, "runNumber", 0, "Manually override the run number used to select the calibration period."}
protected

Definition at line 104 of file InDetTrackBiasingTool.h.

104{this, "runNumber", 0, "Manually override the run number used to select the calibration period."};

◆ m_runNumberBounds

Gaudi::Property<std::vector<unsigned int> > InDet::InDetTrackBiasingTool::m_runNumberBounds {this, "runNumberBounds", {}, "Run number boundaries: {lower0, upper0, upper1, ...}. May be omitted when only one calibration file is configured."}
protected

Definition at line 111 of file InDetTrackBiasingTool.h.

111{this, "runNumberBounds", {}, "Run number boundaries: {lower0, upper0, upper1, ...}. May be omitted when only one calibration file is configured."};

◆ m_sagitta_nominal_histName

std::string InDet::InDetTrackBiasingTool::m_sagitta_nominal_histName = "sagitta/sagitta_theNominal"
protected

Definition at line 93 of file InDetTrackBiasingTool.h.

◆ m_sysFilterMap

std::unordered_map< CP::SystematicSet, CP::SystematicSet > InDet::InDetTrackSystematicsTool::m_sysFilterMap
protectedinherited

Definition at line 53 of file InDetTrackSystematicsTool.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.

◆ m_z0_nominal_histName

std::string InDet::InDetTrackBiasingTool::m_z0_nominal_histName = "z0/z0_theNominal"
protected

Definition at line 92 of file InDetTrackBiasingTool.h.


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