ATLAS Offline Software
Loading...
Searching...
No Matches
ElectronPhotonVariableCorrectionTool Class Reference

Tool to correct electron and photon MC variables using the ElectronPhotonVariableCorrectionBase class. More...

#include <ElectronPhotonVariableCorrectionTool.h>

Inheritance diagram for ElectronPhotonVariableCorrectionTool:
Collaboration diagram for ElectronPhotonVariableCorrectionTool:

Public Member Functions

 ElectronPhotonVariableCorrectionTool (const std::string &myname)
 Declare the interface that the class provides.
 ~ElectronPhotonVariableCorrectionTool ()
 Standard destructor.
virtual StatusCode initialize () override
 Initialize the tool instance.
virtual const CP::CorrectionCode applyCorrection (xAOD::Photon &photon) const override
 Apply the correction given in the conf file to the passed photon.
virtual const CP::CorrectionCode applyCorrection (xAOD::Electron &electron) const override
 Apply the correction given in the conf file to the passed electron.
virtual const CP::CorrectionCode correctedCopy (const xAOD::Photon &in_photon, xAOD::Photon *&out_photon) const override
 Make a corrected copy of the passed photon according to the given conf file.
virtual const CP::CorrectionCode correctedCopy (const xAOD::Electron &in_electron, xAOD::Electron *&out_electron) const override
 Make a corrected copy of the passed electron according to the given conf file.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

const StatusCode initializeCorrectionTools ()
 Configure, initialize, and check the base class instances saved in the m_*Tools members.
const StatusCode initializeTools (const std::string &name, const std::vector< std::string > &confFiles, std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > &toolHolder)
 Initialize the base clase instances saved in the m_*Tools members.
const StatusCode getCorrectionVariableName (std::string &variableName, const std::string &confFile) const
 Get current name of the variable to be corrected by the current base class instance, in order to coherently name the base class instances.
const StatusCode findAllConfigFiles (std::vector< std::string > &confFiles)
 Locate all config files for the base class instances passed to the tool in m_configFile in the ATLAS file system.
const StatusCode applyToFlagMatchesToolHolder (const std::vector< std::string > &confFiles, const std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > &toolHolder, ElectronPhotonVariableCorrectionBase::EGammaObjects toolHolderType)
 Check if the ApplyTo flag from the base class conf file does match with the container type spcified in the tool conf file.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_configFile
 The configuration file for the tool.
std::vector< std::string > m_convertedPhotonConfFiles
 The configuration files for the base class - converted photons.
std::vector< std::string > m_unconvertedPhotonConfFiles
 The configuration files for the base class - unconverted photons.
std::vector< std::string > m_electronConfFiles
 The configuration files for the base class - electrons.
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_convertedPhotonTools
 The base class instances for single variable correction - converted photons.
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_unconvertedPhotonTools
 The base class instances for single variable correction - unconverted photons.
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_electronTools
 The base class instances for single variable correction - electrons.
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

Tool to correct electron and photon MC variables using the ElectronPhotonVariableCorrectionBase class.

Tool to correct electron and photon MC variables.

For a detailed documentation, please refer to the gitlab readme

Author
Nils Gillwald (DESY) nils..nosp@m.gill.nosp@m.wald@.nosp@m.desy.nosp@m..de
Date
February 2020
Author
Nils Gillwald (DESY) nils..nosp@m.gill.nosp@m.wald@.nosp@m.desy.nosp@m..de
Date
February 2020

Definition at line 29 of file ElectronPhotonVariableCorrectionTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ElectronPhotonVariableCorrectionTool()

ElectronPhotonVariableCorrectionTool::ElectronPhotonVariableCorrectionTool ( const std::string & myname)

Declare the interface that the class provides.

Standard constructor

Parameters
mynameInternal name of the tool instance, so they can be distinguished

Definition at line 21 of file ElectronPhotonVariableCorrectionTool.cxx.

21 :
22 AsgTool(myname)
23{
24 //declare the needed properties
25 declareProperty("ConfigFile",m_configFile="", "The configuration file to use");
26}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_configFile
The configuration file for the tool.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58

◆ ~ElectronPhotonVariableCorrectionTool()

ElectronPhotonVariableCorrectionTool::~ElectronPhotonVariableCorrectionTool ( )
inline

Standard destructor.

Definition at line 41 of file ElectronPhotonVariableCorrectionTool.h.

41{};

Member Function Documentation

◆ applyCorrection() [1/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionTool::applyCorrection ( xAOD::Electron & electron) const
overridevirtual

Apply the correction given in the conf file to the passed electron.

Parameters
electronThe electron which should be corrected

Pass an electron which should be corrected by the tool to this function. The tool gets the original electron variable value, corrects it according to the configuration file given, and overwrites the original value of the variable. The original variable is saved as <variable_name>_original. Note that the variable to be corrected should be an auxiliary variable, and that the electron or electron container, respectively, must not be const if you want to use this function. If you are running on const objects, please make a deep / shallow copy of the container or use the correctedCopy function of this class.

Implements IElectronPhotonShowerShapeFudgeTool.

Definition at line 201 of file ElectronPhotonVariableCorrectionTool.cxx.

202{
203 // correct variables on the electron
204 for (unsigned int electronTool_itr = 0; electronTool_itr < m_electronTools.size(); electronTool_itr++)
205 {
206 ATH_MSG_VERBOSE("Running tool " << m_electronTools.at(electronTool_itr)->name());
207 if ((m_electronTools.at(electronTool_itr)->applyCorrection(electron)) != CP::CorrectionCode::Ok)
208 {
209 ATH_MSG_ERROR("Could not apply correction to electron object.");
211 }
212 }
213 // everything worked out, so
215}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_electronTools
The base class instances for single variable correction - electrons.

◆ applyCorrection() [2/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionTool::applyCorrection ( xAOD::Photon & photon) const
overridevirtual

Apply the correction given in the conf file to the passed photon.

Parameters
photonThe photon which should be corrected

Pass a photon which should be corrected by the tool to this function. The tool gets the original photon variable value, corrects it according to the configuration file given, and overwrites the original value of the variable. The original variable is saved as <variable_name>_original. Note that the variable to be corrected should be an auxiliary variable, and that the photon or photon container, respectively, must not be const if you want to use this function. If you are running on const objects, please make a deep / shallow copy of the container or use the correctedCopy function of this class.

Implements IElectronPhotonShowerShapeFudgeTool.

Definition at line 166 of file ElectronPhotonVariableCorrectionTool.cxx.

167{
169
170 // check if need to run over converted or unconverted photons
171 if (isConvertedPhoton)
172 {
173 // correct variables on the converted photon
174 for (unsigned int convertedPhotonTool_itr = 0; convertedPhotonTool_itr < m_convertedPhotonTools.size(); convertedPhotonTool_itr++)
175 {
176 ATH_MSG_VERBOSE("Running tool " << m_convertedPhotonTools.at(convertedPhotonTool_itr)->name());
177 if ((m_convertedPhotonTools.at(convertedPhotonTool_itr)->applyCorrection(photon)) != CP::CorrectionCode::Ok)
178 {
179 ATH_MSG_ERROR("Could not apply correction to converted photon object.");
181 }
182 }
183 }
184 else
185 {
186 // correct variables on the converted photon
187 for (unsigned int unconvertedPhotonTool_itr = 0; unconvertedPhotonTool_itr < m_unconvertedPhotonTools.size(); unconvertedPhotonTool_itr++)
188 {
189 ATH_MSG_VERBOSE("Running tool " << m_unconvertedPhotonTools.at(unconvertedPhotonTool_itr)->name());
190 if ((m_unconvertedPhotonTools.at(unconvertedPhotonTool_itr)->applyCorrection(photon)) != CP::CorrectionCode::Ok)
191 {
192 ATH_MSG_ERROR("Could not apply correction to unconverted photon object.");
194 }
195 }
196 }
197
198 // everything worked out, so
200}
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_unconvertedPhotonTools
The base class instances for single variable correction - unconverted photons.
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > m_convertedPhotonTools
The base class instances for single variable correction - converted photons.
bool isConvertedPhoton(const bool excludeTRT, const float eta, const std::size_t nVertices, const ConversionType conversionType)
is the object a converted photon
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon

◆ applyToFlagMatchesToolHolder()

const StatusCode ElectronPhotonVariableCorrectionTool::applyToFlagMatchesToolHolder ( const std::vector< std::string > & confFiles,
const std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > & toolHolder,
ElectronPhotonVariableCorrectionBase::EGammaObjects toolHolderType )
private

Check if the ApplyTo flag from the base class conf file does match with the container type spcified in the tool conf file.

Parameters
confFilesThe conf files used to initialze the base class instances now stored in the respective toolHolder
toolHolderThe base class instances which were initialized using the respective confFiles
toolHolderTypeThe type of base class instances which should be stored in the respective toolHolder with respect to the tespectif confFiles

Definition at line 141 of file ElectronPhotonVariableCorrectionTool.cxx.

142{
143 // loop over conf file holder
144 for (unsigned int tool_itr = 0; tool_itr < toolHolder.size(); tool_itr++)
145 {
146 // get ApplyTo flag
147 ElectronPhotonVariableCorrectionBase::EGammaObjects confFileType = toolHolder.at(tool_itr)->isAppliedTo();
148 // skip all further tests if should be applied to all objects
150 // continue if ApplyTo flag matches toolholder
151 if (toolHolderType == ElectronPhotonVariableCorrectionBase::EGammaObjects::convertedPhotons && toolHolder.at(tool_itr)->applyToConvertedPhotons()) continue;
152 if (toolHolderType == ElectronPhotonVariableCorrectionBase::EGammaObjects::unconvertedPhotons && toolHolder.at(tool_itr)->applyToUnconvertedPhotons()) continue;
153 if (toolHolderType == ElectronPhotonVariableCorrectionBase::EGammaObjects::allElectrons && toolHolder.at(tool_itr)->applyToElectrons()) continue;
154 // if this point is reached, something is wrong, so
155 ATH_MSG_ERROR("In conf " << confFiles.at(tool_itr) << ": The ApplyTo flag does not match with the container type from the conf file.");
156 return StatusCode::FAILURE;
157 }
158 //everything worked out, so
159 return StatusCode::SUCCESS;
160}
EGammaObjects
Define the categories of EGamma objects tool can be applied to.

◆ correctedCopy() [1/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionTool::correctedCopy ( const xAOD::Electron & in_electron,
xAOD::Electron *& out_electron ) const
overridevirtual

Make a corrected copy of the passed electron according to the given conf file.

Parameters
in_electronThe original electron of which a corrected copy should be made
out_electronEmpty new electron where the corrected copy will be stored in

Makes a corrected copy of the passed electron object according to the correction provided in the configuration file. The in_electron is copied to the out_electron, which is then passed to the applyCorrection function.

Implements IElectronPhotonShowerShapeFudgeTool.

Definition at line 228 of file ElectronPhotonVariableCorrectionTool.cxx.

229{
230 ATH_MSG_VERBOSE("Will correct electron " << &in_electron << " of pT, eta = " << in_electron.pt() << " " << in_electron.eta());
231 out_electron = new xAOD::Electron(in_electron);
232 return applyCorrection(*out_electron);
233}
virtual const CP::CorrectionCode applyCorrection(xAOD::Photon &photon) const override
Apply the correction given in the conf file to the passed photon.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition Egamma_v1.cxx:66
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition Egamma_v1.cxx:71
Electron_v1 Electron
Definition of the current "egamma version".

◆ correctedCopy() [2/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionTool::correctedCopy ( const xAOD::Photon & in_photon,
xAOD::Photon *& out_photon ) const
overridevirtual

Make a corrected copy of the passed photon according to the given conf file.

Parameters
in_photonThe original photon of which a corrected copy should be made
out_photonEmpty new photon where the corrected copy will be stored in

Makes a corrected copy of the passed photon object according to the correction provided in the configuration file. The in_photon is copied to the out_photon, which is then passed to the applyCorrection function.

Implements IElectronPhotonShowerShapeFudgeTool.

Definition at line 221 of file ElectronPhotonVariableCorrectionTool.cxx.

222{
223 ATH_MSG_VERBOSE("Will correct photon " << &in_photon << " of pT, eta = " << in_photon.pt() << " " << in_photon.eta());
224 out_photon = new xAOD::Photon(in_photon);
225 return applyCorrection(*out_photon);
226}
Photon_v1 Photon
Definition of the current "egamma version".

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

◆ 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

◆ findAllConfigFiles()

const StatusCode ElectronPhotonVariableCorrectionTool::findAllConfigFiles ( std::vector< std::string > & confFiles)
private

Locate all config files for the base class instances passed to the tool in m_configFile in the ATLAS file system.

Parameters
confFilesThe conf files which shoud be used for the setup and initialization of the base class instances

Definition at line 102 of file ElectronPhotonVariableCorrectionTool.cxx.

103{
104 //loop over conf file vector, find conf file using path resolver
105 for( unsigned int confFile_itr = 0; confFile_itr < confFiles.size(); confFile_itr++ )
106 {
107 std::string tmp_confFile = confFiles.at(confFile_itr);
108 confFiles.at(confFile_itr) = PathResolverFindCalibFile(confFiles.at(confFile_itr));
109 if (confFiles.at(confFile_itr).empty())
110 {
111 ATH_MSG_ERROR("Could not locate configuration file " << tmp_confFile);
112 return StatusCode::FAILURE;
113 }
114 }
115 //everything worked out, so
116 return StatusCode::SUCCESS;
117}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)

◆ getCorrectionVariableName()

const StatusCode ElectronPhotonVariableCorrectionTool::getCorrectionVariableName ( std::string & variableName,
const std::string & confFile ) const
private

Get current name of the variable to be corrected by the current base class instance, in order to coherently name the base class instances.

Parameters
variableNameThe current correction variable name is saved in this parameter
confFileThe respective conf file of the current base class instance to be read-out

Definition at line 239 of file ElectronPhotonVariableCorrectionTool.cxx.

240{
241 // Retrieve properties from configuration file, using TEnv class
242 TEnv env;
243 env.ReadFile(confFile.c_str(), kEnvLocal);
244 // Send warning if duplicates found in conf file
245 env.IgnoreDuplicates(false);
246
247 // retrieve variable name
248 if (env.Lookup("Variable"))
249 {
250 variableName = env.GetValue("Variable", "");
251 }
252 else
253 {
254 ATH_MSG_ERROR("In conf file " << confFile << ": Correction variable is empty or not in configuration file.");
255 return StatusCode::FAILURE;
256 }
257 //everything worked out, so
258 return StatusCode::SUCCESS;
259}

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

◆ initialize()

StatusCode ElectronPhotonVariableCorrectionTool::initialize ( void )
overridevirtual

Initialize the tool instance.

Reads out the configuration file set via the setProperty(ConfigFile, "/path/to/conf/file.conf") function and sets up the tool instance accordingly

Reimplemented from asg::AsgTool.

Definition at line 28 of file ElectronPhotonVariableCorrectionTool.cxx.

29{
30 // Locate configuration file, abort if not found
31 std::string configFile;
32 if (!m_configFile.empty())
33 {
35 if (configFile.empty())
36 {
37 ATH_MSG_ERROR("Could not locate configuration file " << m_configFile);
38 return StatusCode::FAILURE;
39 }
40 ATH_MSG_DEBUG("Use configuration file " << m_configFile);
41 }
42 else
43 {
44 ATH_MSG_ERROR("Config file string is empty. Please provide a config file to the tool.");
45 return StatusCode::FAILURE;
46 }
47
48 // Retreive properties from configuration file, using TEnv class
49 TEnv env;
50 env.ReadFile(configFile.c_str(), kEnvLocal);
51 // Send warning if duplicates found in conf file
52 env.IgnoreDuplicates(false);
53
54 // retrieve different object type conf files
55 if (env.Lookup("ElectronConfigs"))
56 {
58 }
59 if (env.Lookup("ConvertedPhotonConfigs"))
60 {
61 m_convertedPhotonConfFiles = AsgConfigHelper::HelperString("ConvertedPhotonConfigs",env);
62 }
63 if (env.Lookup("UnconvertedPhotonConfigs"))
64 {
65 m_unconvertedPhotonConfFiles = AsgConfigHelper::HelperString("UnconvertedPhotonConfigs",env);
66 }
67
68 // check if any conf files were received
70 {
71 ANA_MSG_ERROR("You did not provide any config files for the ElectronPhotonVariableCorrectionBase to the ElectronPhotonVariableCorrectionTool.");
72 return StatusCode::FAILURE;
73 }
74
75 ATH_MSG_VERBOSE("number of files for the electron case : " << m_electronConfFiles.size());
76 for (const auto& fN : m_electronConfFiles)
77 ATH_MSG_VERBOSE("file " << fN);
78
79 // initialize the ElectronPhotonVariableCorrectionTools
81
82 ANA_MSG_INFO("Initialized tool " << name());
83 //everything worked out, so
84 return StatusCode::SUCCESS;
85}
#define ATH_MSG_DEBUG(x)
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::vector< std::string > m_electronConfFiles
The configuration files for the base class - electrons.
const StatusCode initializeCorrectionTools()
Configure, initialize, and check the base class instances saved in the m_*Tools members.
std::vector< std::string > m_unconvertedPhotonConfFiles
The configuration files for the base class - unconverted photons.
std::vector< std::string > m_convertedPhotonConfFiles
The configuration files for the base class - converted photons.
std::vector< std::string > HelperString(const std::string &input, TEnv &env)

◆ initializeCorrectionTools()

const StatusCode ElectronPhotonVariableCorrectionTool::initializeCorrectionTools ( )
private

Configure, initialize, and check the base class instances saved in the m_*Tools members.

Definition at line 87 of file ElectronPhotonVariableCorrectionTool.cxx.

88{
89 //initialize all tools
93 // check if ApplyTo Flag matches with the tool holder
97
98 //everything worked out, so
99 return StatusCode::SUCCESS;
100}
const StatusCode initializeTools(const std::string &name, const std::vector< std::string > &confFiles, std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > &toolHolder)
Initialize the base clase instances saved in the m_*Tools members.
const StatusCode applyToFlagMatchesToolHolder(const std::vector< std::string > &confFiles, const std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > &toolHolder, ElectronPhotonVariableCorrectionBase::EGammaObjects toolHolderType)
Check if the ApplyTo flag from the base class conf file does match with the container type spcified i...

◆ initializeTools()

const StatusCode ElectronPhotonVariableCorrectionTool::initializeTools ( const std::string & name,
const std::vector< std::string > & confFiles,
std::vector< std::unique_ptr< ElectronPhotonVariableCorrectionBase > > & toolHolder )
private

Initialize the base clase instances saved in the m_*Tools members.

Parameters
nameThe name of the tool holder which should be included in the base class instances names
confFilesThe conf files for the base class instances which should be created and initialized
toolHolderThe tool holder where the base class instances are created

Definition at line 119 of file ElectronPhotonVariableCorrectionTool.cxx.

120{
121 // adapt size of toolHolder
122 toolHolder.resize(confFiles.size());
123 // for each conf file, initialize one tool
124 for( unsigned int confFile_itr = 0; confFile_itr < confFiles.size(); confFile_itr++ )
125 {
126 // name: supertool name + type name + variable name
127 std::string variable = ""; //get the name of the variable to be corrected
128 std::string confFileWithFullPath = PathResolverFindCalibFile(confFiles.at(confFile_itr));
129 ANA_CHECK(getCorrectionVariableName(variable, confFileWithFullPath));
130 TString toolname = TString::Format("%s_%s_%s", this->name().c_str(), name.c_str(), variable.c_str());
131 ANA_MSG_DEBUG("Subtool name: " << toolname.Data());
132 toolHolder.at(confFile_itr) = std::make_unique<ElectronPhotonVariableCorrectionBase>(toolname.Data());
133 ANA_CHECK(toolHolder.at(confFile_itr)->setProperty("ConfigFile", confFiles.at(confFile_itr)));
134 ANA_CHECK(toolHolder.at(confFile_itr)->setProperty("OutputLevel", this->msg().level()));
135 ANA_CHECK(toolHolder.at(confFile_itr)->initialize());
136 }
137 //everything worked out, so
138 return StatusCode::SUCCESS;
139}
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
const StatusCode getCorrectionVariableName(std::string &variableName, const std::string &confFile) const
Get current name of the variable to be corrected by the current base class instance,...

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ renounce()

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

Definition at line 380 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

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

Perform system initialization for an algorithm.

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

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

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

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

Member Data Documentation

◆ m_configFile

std::string ElectronPhotonVariableCorrectionTool::m_configFile
private

The configuration file for the tool.

Definition at line 87 of file ElectronPhotonVariableCorrectionTool.h.

◆ m_convertedPhotonConfFiles

std::vector<std::string> ElectronPhotonVariableCorrectionTool::m_convertedPhotonConfFiles
private

The configuration files for the base class - converted photons.

Definition at line 89 of file ElectronPhotonVariableCorrectionTool.h.

◆ m_convertedPhotonTools

std::vector<std::unique_ptr<ElectronPhotonVariableCorrectionBase> > ElectronPhotonVariableCorrectionTool::m_convertedPhotonTools
private

The base class instances for single variable correction - converted photons.

Definition at line 95 of file ElectronPhotonVariableCorrectionTool.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_electronConfFiles

std::vector<std::string> ElectronPhotonVariableCorrectionTool::m_electronConfFiles
private

The configuration files for the base class - electrons.

Definition at line 93 of file ElectronPhotonVariableCorrectionTool.h.

◆ m_electronTools

std::vector<std::unique_ptr<ElectronPhotonVariableCorrectionBase> > ElectronPhotonVariableCorrectionTool::m_electronTools
private

The base class instances for single variable correction - electrons.

Definition at line 99 of file ElectronPhotonVariableCorrectionTool.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_unconvertedPhotonConfFiles

std::vector<std::string> ElectronPhotonVariableCorrectionTool::m_unconvertedPhotonConfFiles
private

The configuration files for the base class - unconverted photons.

Definition at line 91 of file ElectronPhotonVariableCorrectionTool.h.

◆ m_unconvertedPhotonTools

std::vector<std::unique_ptr<ElectronPhotonVariableCorrectionBase> > ElectronPhotonVariableCorrectionTool::m_unconvertedPhotonTools
private

The base class instances for single variable correction - unconverted photons.

Definition at line 97 of file ElectronPhotonVariableCorrectionTool.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: