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

Class to correct electron and photon MC variables. More...

#include <ElectronPhotonVariableCorrectionBase.h>

Inheritance diagram for ElectronPhotonVariableCorrectionBase:

Public Types

enum class  EGammaObjects {
  Failure = 0 , unconvertedPhotons = 1 , convertedPhotons , allPhotons ,
  allElectrons , allEGammaObjects
}
 Define the categories of EGamma objects tool can be applied to. More...

Public Member Functions

 ElectronPhotonVariableCorrectionBase (const std::string &myname)
 Standard constructor.
 ~ElectronPhotonVariableCorrectionBase ()
 Standard destructor.
virtual StatusCode initialize () override
 Initialize the class instance.
const CP::CorrectionCode applyCorrection (xAOD::Photon &photon) const
 Apply the correction given in the conf file to the passed photon.
const CP::CorrectionCode applyCorrection (xAOD::Electron &electron) const
 Apply the correction given in the conf file to the passed electron.
const CP::CorrectionCode correctedCopy (const xAOD::Photon &in_photon, xAOD::Photon *&out_photon) const
 Make a corrected copy of the passed photon according to the given conf file.
const CP::CorrectionCode correctedCopy (const xAOD::Electron &in_electron, xAOD::Electron *&out_electron) const
 Make a corrected copy of the passed electron according to the given conf file.
const std::string & getCorrectionVariable ()
 Returns the variable which should be corrected according to the passed configuration file.
ElectronPhotonVariableCorrectionBase::EGammaObjects isAppliedTo ()
 Returns the type of EGamma object to which the correction should be applied.
bool applyToConvertedPhotons () const
 Check if the ApplyTo flag passed in the conf file is compatible with converted photons.
bool applyToUnconvertedPhotons () const
 Check if the ApplyTo flag passed in the conf file is compatible with uconverted photons.
bool applyToElectrons () const
 Check if the ApplyTo flag passed in the conf file is compatible with electrons.
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

enum class  parameterType {
  Failure = 0 , EtaDependentTGraph = 1 , PtDependentTGraph , EtaBinned ,
  PtBinned , EtaTimesPtBinned , EtaTimesPhiTH2 , EventDensity
}
 Use enum and not string for type of function parameter in order to do faster comparisons. More...
typedef ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

ElectronPhotonVariableCorrectionBase::parameterType stringToParameterType (const std::string &input) const
 Convert input string to a parameter function type.
ElectronPhotonVariableCorrectionBase::EGammaObjects stringToEGammaObject (const std::string &input) const
 Convert input string to egamma object type.
bool passedCorrectPhotonType (const xAOD::Photon &photon) const
 Check if the photon which was passed to the tool has the correct type, if only (un)converted photons were requested to be corrected.
bool isEqualToUncorrectedDiscontinuity (const float value) const
 Check if the value passed is equal to one of the values passed via the UncorrectedDiscontinuites flag and should thus not be corrected.
const StatusCode getParameterInformationFromConf (TEnv &env, const int parameter_number, const ElectronPhotonVariableCorrectionBase::parameterType type)
 Get the relevant information for a correction function parameter from the given conf file.
const StatusCode getEtaPtBinningsFromConf (const bool getEtaBins, const bool getPtBins, const TString &binValues, const TString &interpolate, TEnv &env, const int parameter_number)
 Get the eta and pt binning as well as the respective correction values from the given conf file.
std::unique_ptr< TObject > getObjectFromRootFile (TEnv &env, const int parameter_number, const TString &filePathKey, const TString &nameKey)
 Get a TObject storing corrections (i.e.
const StatusCode getCorrectionParameters (const float pt, const float eta, const float ph, std::vector< float > &properties) const
 Get the actual parameters of the TF1 function used for the current e/y object to be corrected.
const StatusCode get1DBinnedParameter (float &return_parameter_value, const float evalPoint, const std::vector< float > &binning, const int parameter_number) const
 Get the correction function parameter value if its type is eta- or pT-binned.
const StatusCode get2DBinnedParameter (float &return_parameter_value, const float etaEvalPoint, const float ptEvalPoint, const int parameter_number) const
 Get the correction function parameter value if its type is eta- and pT-binned.
const StatusCode get2DHistParameter (float &return_parameter_value, const float etaEvalPoint, const float phiEvalPoint, const int parameter_number) const
 Get the correction function parameter value if its type is eta- and pT-binned.
bool getInterpolationFlag (const int parameter_number) const
 Return the interpolation flag of parameter parameter_number as a boolean.
const StatusCode interpolate (float &return_parameter_value, const float evalPoint, const int bin, const std::vector< float > &binning, const std::vector< float > &binValues) const
 Given a point x, approximates the value via linear interpolation based on the two nearest bin centers.
const StatusCode getBinCenter (float &return_bin_center, const std::vector< float > &binning, const int bin_int) const
 Get the bin center of a bin bin_int using the binning binning.
const StatusCode getDensity (float &value, const std::string &eventShapeContainer) const
 Get the events energy density from the eventShape.
const StatusCode getKinematicProperties (const xAOD::Egamma &egamma_object, float &pt, float &eta, float &phi) const
 Get the e/y kinematic properties.
void correct (float &return_corrected_variable, const float original_variable, const std::vector< float > &properties, unsigned int rndSeed=0) const
 Actual application of the correction to the variable.
TRandom3 * getTLSRandomGen (unsigned int seed) const
 Getting thread safe random number generator (and resetting its seed).
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static const StatusCode findBin (int &return_bin, const float evalPoint, const std::vector< float > &binning)
 Find the bin number in which the evalPoint is located in the binning binning.
static float interpolate_function (const float value, const float left_bin_center, const float left_bin_value, const float right_bin_center, const float right_bin_value)
 Returns the linearly intrpolated value of value given the bin centers and bin values.

Private Attributes

std::string m_configFile
 The name of the configuration file.
std::string m_correctionVariable
 The name of the variable to correct.
bool m_doGaussianSmearing = false
 Whether to apply normal correction or smearing correction.
boost::thread_specific_ptr< TRandom3 > m_TRandom_tls
 thread-safe TRandom3 for setting seed of random smearing correction
std::vector< float > m_uncorrectedDiscontinuities
 Values of discontinuities in the variable which should not be corrected.
std::string m_correctionFunctionString
 Function to use for the variable correction, TFormula style.
std::unique_ptr< TFormula > m_correctionFunctionTFormula
 The actual TFormula correction function.
int m_numberOfFunctionParameters {}
 Number of parameters of the variable correction function.
std::vector< parameterType > m_ParameterTypeVector
 Map of the correction function parameter number to the parameter type.
std::vector< std::unique_ptr< TGraph > > m_graphCopies
 Copy of the TGraph from the root file, stored if needed by the respective correction function parameter.
std::vector< std::unique_ptr< TH2 > > m_TH2Copies
 Copy of the TH2 from the root file, stored if needed by the respective correction function parameter.
std::vector< float > m_useAbsEtaTH2
 Store the lowest eta bin boundary: used for checking if the respective TH2 needs the eta or abs(eta) value for evaluation.
std::vector< std::vector< float > > m_binValues
 List of eta/pt dependent values, stored if needed by the respective correction function parameter.
std::vector< float > m_etaBins
 List of bin boundaries in eta, stored if needed by any correction function parameter.
bool m_useAbsEtaBinned {}
 Store if the eta binned parameters need the eta or abs(eta) value for evaluation.
std::vector< float > m_ptBins
 List of bin boundaries in pT, stored if needed by any correction function parameter.
std::vector< bool > m_interpolatePtFlags
 List of bools whether a parameter should use linear interpolation in pT if it's some kind of pT binned parameter.
ElectronPhotonVariableCorrectionBase::EGammaObjects m_applyToObjects {}
 The type of objects to which the specific conf file settings are allowed to be applied to.
bool m_retrievedEtaBinning = false
 Store if already retrieved eta binning.
bool m_retrievedPtBinning = false
 Store if already retrieved pt binning.
std::unique_ptr< SG::Accessor< float > > m_variableToCorrect
 Accessor for the variable to be corrected.
std::unique_ptr< SG::Accessor< float > > m_originalVariable
 Accessor to store the original value of the corrected variable.
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

Class to correct electron and photon MC variables.

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

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ EGammaObjects

Define the categories of EGamma objects tool can be applied to.

The tool can be applied to electrons and photons, but the latter could also have different corrections according to whether they are converted or unconverted photons. The categories are designed in such a way, that the analyzer can freely choose whether he_she_* wants all objects (i.e. e and y) to be corrected in the same way, or wheter he_she_* wants to apply different corrections to different types of objects.

Enumerator
Failure 
unconvertedPhotons 
convertedPhotons 
allPhotons 
allElectrons 
allEGammaObjects 

Definition at line 103 of file ElectronPhotonVariableCorrectionBase.h.

103 {
104 Failure = 0,
105 unconvertedPhotons = 1,
106 convertedPhotons,
107 allPhotons,
108 allElectrons,
109 allEGammaObjects
110 }; //end enum EGammaObjects

◆ parameterType

Use enum and not string for type of function parameter in order to do faster comparisons.

Enumerator
Failure 
EtaDependentTGraph 
PtDependentTGraph 
EtaBinned 
PtBinned 
EtaTimesPtBinned 
EtaTimesPhiTH2 
EventDensity 

Definition at line 132 of file ElectronPhotonVariableCorrectionBase.h.

132 {
133 Failure = 0,
134 EtaDependentTGraph = 1,
135 PtDependentTGraph,
136 EtaBinned,
137 PtBinned,
138 EtaTimesPtBinned,
139 EtaTimesPhiTH2,
140 EventDensity
141 }; // end enum ParameterType

Constructor & Destructor Documentation

◆ ElectronPhotonVariableCorrectionBase()

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

Standard constructor.

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

Definition at line 36 of file ElectronPhotonVariableCorrectionBase.cxx.

36 :
37 AsgTool(myname)
38{
39 //declare the needed properties
40 declareProperty("ConfigFile",m_configFile="","The configuration file to use");
41}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::string m_configFile
The name of the configuration file.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58

◆ ~ElectronPhotonVariableCorrectionBase()

ElectronPhotonVariableCorrectionBase::~ElectronPhotonVariableCorrectionBase ( )
inline

Standard destructor.

Definition at line 51 of file ElectronPhotonVariableCorrectionBase.h.

51{};

Member Function Documentation

◆ applyCorrection() [1/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection ( xAOD::Electron & electron) const

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.

Definition at line 255 of file ElectronPhotonVariableCorrectionBase.cxx.

256{
257 if (!applyToElectrons())
258 {
259 ATH_MSG_ERROR("You want to correct electrons, but passed a conf file with ApplyTo flag not set for electrons. Are you using the correct conf file?");
261 }
262
263 // From the object, get the variable value according to the variable from the conf file
264 // if variable not found, fail
265 float original_variable = 0.;
266
267 if (m_correctionVariable == "transformed_e_probability_ht") {
268 // this is a special case, since what we want to fudge is not the variable
269 // usually stoared in (D)xAOD, but a transformed version
270 // here we compute the transormed version
271 // this is code duplication from AsgElectronLikelihoodTool.cxx
272
273 const xAOD::TrackParticle* track = electron.trackParticle();
274 if (!track) {
275 ATH_MSG_ERROR("you are trying to fudge transformed_e_probability_ht but the electron has no track!");
277 }
278 float TRT_PID = 0.;
279 if (!track->summaryValue(TRT_PID, xAOD::eProbabilityHT)) {
280 ATH_MSG_ERROR("you are trying to fudge transformed_e_probability_ht but eProbabilityHT is not present");
282 }
283
284 const double tau = 15.0;
285 const double fEpsilon = 1.0e-30; // to avoid zero division
286 double pid_tmp = TRT_PID;
287 if (pid_tmp >= 1.0)
288 pid_tmp = 1.0 - 1.0e-15; // this number comes from TMVA
289 else if (pid_tmp <= fEpsilon)
290 pid_tmp = fEpsilon;
291 double trans_TRT_PID = -std::log(1.0 / pid_tmp - 1.0) * (1. / double(tau));
292
293 (*m_variableToCorrect)(electron) = (float)trans_TRT_PID;
294 }
295
296 if (m_variableToCorrect->isAvailable(electron))
297 {
298 original_variable = (*m_variableToCorrect)(electron);
299 //Save the original value to the photon under different name
300 (*m_originalVariable)(electron) = original_variable;
301 // check if tool should skip correcting this variable, as it's from some discontinuity
302 if (isEqualToUncorrectedDiscontinuity(original_variable))
303 {
305 }
306 }
307 else
308 {
309 ATH_MSG_ERROR("The correction variable \"" << m_correctionVariable << "\" provided in the conf file is not available.");
311 }
312
313 float eta; //safe value of eta of event
314 float pt; //safe pt of event
315 float phi; //safe phi of event
316
317 //Get all the properties from the electron and fill them to properties, eta, pt, phi
318 if (getKinematicProperties(electron, pt, eta, phi) != StatusCode::SUCCESS)
319 {
320 ATH_MSG_ERROR("Could not retrieve kinematic properties of this electron object.");
322 }
323 ATH_MSG_VERBOSE("Got the electron kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi);
324 std::vector<float> properties;
325 if (getCorrectionParameters(pt, eta, phi, properties) != StatusCode::SUCCESS)
326 {
327 ATH_MSG_ERROR("Could not get the correction parameters for this electron object.");
329 }
330
331 // If applying a Gaussian smearing correction, set the seed based on the
332 // electron properties
333 unsigned int rndSeed(0);
335 {
336 rndSeed = 1 + static_cast<unsigned int>(pt + std::abs(eta) * 1E3 + std::abs(phi) * 1E6);
337 }
338
339 // Apply the correction, write to the corrected AuxElement
340 correct((*m_variableToCorrect)(electron),original_variable, properties, rndSeed);
341
342 // everything worked out, so
344}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
bool m_doGaussianSmearing
Whether to apply normal correction or smearing correction.
bool isEqualToUncorrectedDiscontinuity(const float value) const
Check if the value passed is equal to one of the values passed via the UncorrectedDiscontinuites flag...
const StatusCode getCorrectionParameters(const float pt, const float eta, const float ph, std::vector< float > &properties) const
Get the actual parameters of the TF1 function used for the current e/y object to be corrected.
bool applyToElectrons() const
Check if the ApplyTo flag passed in the conf file is compatible with electrons.
std::string m_correctionVariable
The name of the variable to correct.
const StatusCode getKinematicProperties(const xAOD::Egamma &egamma_object, float &pt, float &eta, float &phi) const
Get the e/y kinematic properties.
std::unique_ptr< SG::Accessor< float > > m_variableToCorrect
Accessor for the variable to be corrected.
void correct(float &return_corrected_variable, const float original_variable, const std::vector< float > &properties, unsigned int rndSeed=0) const
Actual application of the correction to the variable.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ eProbabilityHT
Electron probability from High Threshold (HT) information [float].

◆ applyCorrection() [2/2]

const CP::CorrectionCode ElectronPhotonVariableCorrectionBase::applyCorrection ( xAOD::Photon & photon) const

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.

Definition at line 201 of file ElectronPhotonVariableCorrectionBase.cxx.

202{
203 // check if we should only deal with converted / unconverted photons
204 if (!passedCorrectPhotonType(photon))
205 {
206 ATH_MSG_ERROR("You specified in the conf file that the tool should only be used for (un-)converted photons, but passed the other conversion type.");
208 }
209
210 // From the object, get the variable value according to the variable from the conf file
211 // if variable not found, fail
212 float original_variable = 0.;
213 if( m_variableToCorrect->isAvailable(photon) )
214 {
215 original_variable = (*m_variableToCorrect)(photon);
216 //Save the original value to the photon under different name
217 (*m_originalVariable)(photon) = original_variable;
218 // check if tool should skip correcting this variable, as it's from some discontinuity
219 if (isEqualToUncorrectedDiscontinuity(original_variable))
220 {
222 }
223 }
224 else
225 {
226 ATH_MSG_ERROR("The correction variable \"" << m_correctionVariable << "\" provided in the conf file is not available.");
228 }
229
230 float eta; //safe value of eta of event
231 float pt; //safe pt of event
232 float phi; //safe phi of event
233
234 //Get all the properties from the photon and fill them to properties, eta, pt, phi
235 if (getKinematicProperties(photon, pt, eta, phi) != StatusCode::SUCCESS)
236 {
237 ATH_MSG_ERROR("Could not retrieve kinematic properties of this photon object.");
239 }
240 ATH_MSG_VERBOSE("Got the photon kinematics , pT = " << pt << " eta = " << eta << "phi = " << phi);
241 std::vector<float> properties;
242 if (getCorrectionParameters(pt, eta, phi, properties) != StatusCode::SUCCESS)
243 {
244 ATH_MSG_ERROR("Could not get the correction parameters for this photon object.");
246 }
247
248 // Apply the correction, write to the corrected AuxElement
249 correct((*m_variableToCorrect)(photon),original_variable, properties);
250
251 // everything worked out, so
253}
bool passedCorrectPhotonType(const xAOD::Photon &photon) const
Check if the photon which was passed to the tool has the correct type, if only (un)converted photons ...

◆ applyToConvertedPhotons()

bool ElectronPhotonVariableCorrectionBase::applyToConvertedPhotons ( ) const

Check if the ApplyTo flag passed in the conf file is compatible with converted photons.

Returns
True if the ApplyTo flag is compatible, False if not

Definition at line 1074 of file ElectronPhotonVariableCorrectionBase.cxx.

1075{
1079 return (applyToAllEGamma || applyToAllPhotons || applyToConvertedPhotons);
1080}
bool applyToConvertedPhotons() const
Check if the ApplyTo flag passed in the conf file is compatible with converted photons.
ElectronPhotonVariableCorrectionBase::EGammaObjects m_applyToObjects
The type of objects to which the specific conf file settings are allowed to be applied to.

◆ applyToElectrons()

bool ElectronPhotonVariableCorrectionBase::applyToElectrons ( ) const

Check if the ApplyTo flag passed in the conf file is compatible with electrons.

Returns
True if the ApplyTo flag is compatible, False if not

Definition at line 1090 of file ElectronPhotonVariableCorrectionBase.cxx.

◆ applyToUnconvertedPhotons()

bool ElectronPhotonVariableCorrectionBase::applyToUnconvertedPhotons ( ) const

Check if the ApplyTo flag passed in the conf file is compatible with uconverted photons.

Returns
True if the ApplyTo flag is compatible, False if not

Definition at line 1082 of file ElectronPhotonVariableCorrectionBase.cxx.

◆ correct()

void ElectronPhotonVariableCorrectionBase::correct ( float & return_corrected_variable,
const float original_variable,
const std::vector< float > & properties,
unsigned int rndSeed = 0 ) const
private

Actual application of the correction to the variable.

Parameters
return_corrected_variableThe corrected variable value is saved in this parameter
original_variableThe original value of the corrected variable
propertiesFunction parameters for the evaluation.
rndSeedA random seed determined from pT, eta and phi, in case a Gaussian smearing is used.

Definition at line 346 of file ElectronPhotonVariableCorrectionBase.cxx.

349{
350 ATH_MSG_VERBOSE("original var " << original_variable);
351
352 // If not smearing, apply correction in normal way
354 {
355 double x = original_variable;
356 std::vector<double> dpars (properties.begin(), properties.end());
357 return_corrected_variable = m_correctionFunctionTFormula->EvalPar(&x,
358 dpars.data());
359 }
360 else
361 {
362 // Get Gaussian mean and width from the parameters, to be used with
363 // TRandom::Gaus (assumes function given is a gaussian)
364 const double gaussMean = properties.at(0);
365 const double gaussAbsWidth = std::abs(properties.at(1));
366
367 // If the Gaussian width is 0, can't use TRandom::Gaus - just apply shift
368 if (gaussAbsWidth == 0.0)
369 {
370 return_corrected_variable = original_variable + gaussMean;
371 }
372 // Otherwise, can apply smear using TRandom::Gaus
373 else
374 {
375 return_corrected_variable = original_variable +
376 getTLSRandomGen(rndSeed)->Gaus(gaussMean, gaussAbsWidth);
377 }
378 }
379
380 ATH_MSG_VERBOSE("corrected var " << return_corrected_variable);
381}
#define x
std::unique_ptr< TFormula > m_correctionFunctionTFormula
The actual TFormula correction function.
TRandom3 * getTLSRandomGen(unsigned int seed) const
Getting thread safe random number generator (and resetting its seed).

◆ correctedCopy() [1/2]

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

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.

Definition at line 392 of file ElectronPhotonVariableCorrectionBase.cxx.

393{
394 out_electron = new xAOD::Electron(in_electron);
395 return applyCorrection(*out_electron);
396}
const CP::CorrectionCode applyCorrection(xAOD::Photon &photon) const
Apply the correction given in the conf file to the passed photon.
Electron_v1 Electron
Definition of the current "egamma version".
Definition Electron.h:17

◆ correctedCopy() [2/2]

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

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.

Definition at line 386 of file ElectronPhotonVariableCorrectionBase.cxx.

387{
388 out_photon = new xAOD::Photon(in_photon);
389 return applyCorrection(*out_photon);
390}
Photon_v1 Photon
Definition of the current "egamma version".
Definition Photon.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 }

◆ 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

◆ findBin()

const StatusCode ElectronPhotonVariableCorrectionBase::findBin ( int & return_bin,
const float evalPoint,
const std::vector< float > & binning )
staticprivate

Find the bin number in which the evalPoint is located in the binning binning.

Parameters
return_binThe respective bin number is saved in this parameter
evalPointThe evaluation point for which the bin number should be found
binningThe binning which should be evaluated

Definition at line 854 of file ElectronPhotonVariableCorrectionBase.cxx.

855{
856 // need to find the bin in which the evalPoint is
857 return_bin = -1;
858 // if the evalPoint is < lowest bin edge, interpolate to -inf and return leftmost value
859 if (evalPoint < binning.at(0))
860 {
861 return_bin = 0;
862 // found bin, no need to continue here
863 return StatusCode::SUCCESS;
864 }
865 // loop over bin boundaries
866 //run only up to binning.size()-1, as running to binning.size() will get a seg fault for the boundary check
867 for (unsigned int bin_itr = 0; bin_itr < binning.size()-1; bin_itr++)
868 {
869 // if the evaluation point is within the checked bins boundaries, this is the value we want
870 if (evalPoint > binning.at(bin_itr) && evalPoint < binning.at(bin_itr + 1))
871 {
872 // we found the according bin, so return the according value
873 return_bin = bin_itr;
874 // we can stop now
875 break;
876 }
877 }
878 //if this point is ever reached and bin == -1, the evaluation point is larger then the largest lowest bin edge
879 //if that's the case, return the value for the last bin
880 //the -1 is because the parameter numbering in a vector starts at 0
881 if (return_bin == -1)
882 {
883 return_bin = binning.size()-1;
884 }
885
886 // everythin went fine, so
887 return StatusCode::SUCCESS;
888}

◆ get1DBinnedParameter()

const StatusCode ElectronPhotonVariableCorrectionBase::get1DBinnedParameter ( float & return_parameter_value,
const float evalPoint,
const std::vector< float > & binning,
const int parameter_number ) const
private

Get the correction function parameter value if its type is eta- or pT-binned.

Parameters
return_parameter_valueThe respective correction function parameter value is saved in this parameter
evalPointpT or eta evaluation point - i.e., the eta or pT value of the current e/y object to be corrected. Used to find the correct eta/pT bin to use for the correction
binningThe eta or pT binning
parameter_numberThe number of the parameter with respect to the correction TF1. Needed in order to retrieve the correct values matching this parameter.

Definition at line 760 of file ElectronPhotonVariableCorrectionBase.cxx.

761{
762 ANA_MSG_VERBOSE("EvalPoint: " << evalPoint);
763 // need to find the bin in which the evalPoint is
764 int bin = -1;
765 ATH_CHECK(findBin(bin, evalPoint, binning));
766
767 // calculate return value
768 // if interpolation flag is true, interpolate
769 if (getInterpolationFlag(parameter_number))
770 {
771 ATH_CHECK(interpolate(return_parameter_value, evalPoint, bin, binning, m_binValues.at(parameter_number)));
772 }
773 else
774 {
775 return_parameter_value = m_binValues.at(parameter_number).at(bin);
776 }
777
778 // everything went fine, so
779 return StatusCode::SUCCESS;
780}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ANA_MSG_VERBOSE(xmsg,...)
Macro printing verbose messages.
std::vector< std::vector< float > > m_binValues
List of eta/pt dependent values, stored if needed by the respective correction function parameter.
static const StatusCode findBin(int &return_bin, const float evalPoint, const std::vector< float > &binning)
Find the bin number in which the evalPoint is located in the binning binning.
bool getInterpolationFlag(const int parameter_number) const
Return the interpolation flag of parameter parameter_number as a boolean.
const StatusCode interpolate(float &return_parameter_value, const float evalPoint, const int bin, const std::vector< float > &binning, const std::vector< float > &binValues) const
Given a point x, approximates the value via linear interpolation based on the two nearest bin centers...

◆ get2DBinnedParameter()

const StatusCode ElectronPhotonVariableCorrectionBase::get2DBinnedParameter ( float & return_parameter_value,
const float etaEvalPoint,
const float ptEvalPoint,
const int parameter_number ) const
private

Get the correction function parameter value if its type is eta- and pT-binned.

Parameters
return_parameter_valueThe respective correction function parameter value is saved in this parameter
etaEvalPointeta evaluation point - i.e., the eta value of the current e/y object to be corrected. Used to find the correct eta bin to use for the correction
ptEvalPointpT evaluation point - i.e., the pT value of the current e/y object to be corrected. Used to find the correct pT bin to use for the correction
parameter_numberThe number of the parameter with respect to the correction TF1. Needed in order to retrieve the correct values matching this parameter.

Definition at line 782 of file ElectronPhotonVariableCorrectionBase.cxx.

783{
784 //need to find eta bin, and need to find pt bin
785 //from this, calculate which parameter of the list is needed to be returned.
786 int etaBin = -1;
787 int ptBin = -1;
788
789 ATH_MSG_VERBOSE("eta = " << etaEvalPoint << " pt = " << ptEvalPoint);
790
791 ATH_CHECK(findBin(etaBin, etaEvalPoint, m_etaBins));
792 ATH_CHECK(findBin(ptBin, ptEvalPoint, m_ptBins));
793
794 // get the corresponding pt x eta bin found
795 /* Note: Assuming that the values are binned in pt x eta in the conf file:
796 * eta bin 0 | eta bin 1 | eta bin 2 | eta bin 3 | eta bin 4 | etc.
797 * pt bin 0 0 1 2 3 4
798 * pt bin 1 5 6 7 8 9
799 * pt bin 2 10 11 12 13 14
800 * pt bin 3 15 16 17 18 19
801 * pt bin 4 20 21 22 23 24
802 * etc.
803 * the correct parameter is saved in the vector at (number of eta bins) * ptBinNumber + etaBinNumber
804 * */
805
806 ATH_MSG_VERBOSE(" eta bin " << etaBin << " pT bin " << ptBin);
807
808 int bin_number_in_bin_values = m_etaBins.size() * ptBin + etaBin;
809
810 // calculate return value
811 // if interpolation flag is true, interpolate
812 if (getInterpolationFlag(parameter_number))
813 {
814 // create the vector of correction values binned in pT at the found eta bin
815 std::vector<float> tmp_binValuesAtEtaSlice;
816 // from the full binning vector, need to cut one of the columns
817 for (unsigned int binValue_itr = etaBin; binValue_itr < m_binValues.at(parameter_number).size(); binValue_itr += m_etaBins.size())
818 {
819 tmp_binValuesAtEtaSlice.push_back(m_binValues.at(parameter_number).at(binValue_itr));
820 }
821 // interpolate using the above slice of the correction values
822 ATH_CHECK(interpolate(return_parameter_value, ptEvalPoint, ptBin, m_ptBins, tmp_binValuesAtEtaSlice));
823 }
824 else
825 {
826 return_parameter_value = m_binValues.at(parameter_number).at(bin_number_in_bin_values);
827 }
828
829 // everything went fine, so
830 return StatusCode::SUCCESS;
831}
size_t size() const
Number of registered mappings.
std::vector< float > m_ptBins
List of bin boundaries in pT, stored if needed by any correction function parameter.
std::vector< float > m_etaBins
List of bin boundaries in eta, stored if needed by any correction function parameter.
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin

◆ get2DHistParameter()

const StatusCode ElectronPhotonVariableCorrectionBase::get2DHistParameter ( float & return_parameter_value,
const float etaEvalPoint,
const float phiEvalPoint,
const int parameter_number ) const
private

Get the correction function parameter value if its type is eta- and pT-binned.

Parameters
return_parameter_valueThe respective correction function parameter value is saved in this parameter
etaEvalPointeta evaluation point - i.e., the eta value of the current e/y object to be corrected. Used to find the correct eta bin to use for the correction
phiEvalPointphi evaluation point - i.e., the phi value of the current e/y object to be corrected. Used to find the correct phi bin to use for the correction
parameter_numberThe number of the parameter with respect to the correction TF1. Needed in order to retrieve the correct values matching this parameter.

Definition at line 833 of file ElectronPhotonVariableCorrectionBase.cxx.

834{
835 // might need to update eta evaluation point and can't update const float
836 float this_etaEvalPoint = etaEvalPoint;
837 ATH_MSG_VERBOSE("eta = " << this_etaEvalPoint << " phi = " << phiEvalPoint);
838 // make sure the eta eval point is inside the bounds of the histogram (i.e. pretend the lowest bin boundary is -infinity)
839 if (this_etaEvalPoint < m_useAbsEtaTH2.at(parameter_number))
840 {
841 this_etaEvalPoint = m_TH2Copies.at(parameter_number)->GetXaxis()->GetBinCenter(1);
842 ATH_MSG_VERBOSE("eta was out of bounds of TH2, corrected to eta = " << this_etaEvalPoint);
843 }
844 // get the value of the TH2 at the corresponding eta x phi pair
845 const int bin_number = m_TH2Copies.at(parameter_number)->FindBin(this_etaEvalPoint, phiEvalPoint);
846 return_parameter_value = m_TH2Copies.at(parameter_number)->GetBinContent(bin_number);
847 ATH_MSG_VERBOSE("Correction factor:" << return_parameter_value);
848
849 // everything went fine, so
850 return StatusCode::SUCCESS;
851}
std::vector< float > m_useAbsEtaTH2
Store the lowest eta bin boundary: used for checking if the respective TH2 needs the eta or abs(eta) ...
std::vector< std::unique_ptr< TH2 > > m_TH2Copies
Copy of the TH2 from the root file, stored if needed by the respective correction function parameter.

◆ getBinCenter()

const StatusCode ElectronPhotonVariableCorrectionBase::getBinCenter ( float & return_bin_center,
const std::vector< float > & binning,
const int bin_int ) const
private

Get the bin center of a bin bin_int using the binning binning.

Parameters
return_bin_centerThe bin center is saved in this parameter
binningThe binning which should be used to find the bin centers
bin_intThe bin for which the bin center should be found

Definition at line 964 of file ElectronPhotonVariableCorrectionBase.cxx.

965{
966 if (bin_int < 0)
967 {
968 ATH_MSG_ERROR("Bin number must be a non-negative integer.");
969 return StatusCode::FAILURE;
970 }
971
972 // implicitly convert to loong unsigend int for comparisons, to get rid of compiler warnings resulting from comparisons of int and unsigned int
973 long unsigned int bin = bin_int;
974
975 if (bin >= binning.size())
976 {
977 ATH_MSG_ERROR("The requested bin is out of range of the passed binning.");
978 return StatusCode::FAILURE;
979 }
980
981 // need special treatment for rightmost bin center:
982 // it goes up to infinity...assume it's as broad as the
983 // next to the rightmost bin for the interpolation
984 if (bin == binning.size()-1)
985 {
986 //calculate the width of the next to rightmost bin
987 float bin_width = binning.at(bin) - binning.at(bin-1);
988 return_bin_center = binning.at(bin) + 0.5 * bin_width;
989 }
990 // normal calculation
991 else
992 {
993 return_bin_center = 0.5 * (binning.at(bin) + binning.at(bin+1));
994 }
995
996 //everything went fine, so
997 return StatusCode::SUCCESS;
998}

◆ getCorrectionParameters()

const StatusCode ElectronPhotonVariableCorrectionBase::getCorrectionParameters ( const float pt,
const float eta,
const float ph,
std::vector< float > & properties ) const
private

Get the actual parameters of the TF1 function used for the current e/y object to be corrected.

Parameters
ptThe pT of the current e/y object to be corrected
etaThe eta of the current e/y object to be corrected
phiThe phi of the current e/y object to be corrected
propertiesVector of parameters to use.

As every electron/photon has different values of pT/eta, the correction function must be adapted accordingly for every e/y. The according values of each of the correction function parameters are updated with this function.

Definition at line 689 of file ElectronPhotonVariableCorrectionBase.cxx.

691{
693
694 // check if eta or abs(eta) is used for the binned variables
695 float etaForBinned = eta;
697 { etaForBinned = std::abs(eta); }
698 // if use eta, correct for cases where eta is smaller than lowest bin boundary
699 // i.e. treat lowest bin boundary as -inf!
700 else if (etaForBinned < m_etaBins.at(0))
701 {
702 // set eta to midpoint of lowest bin
703 etaForBinned = 0.5*(m_etaBins.at(0) + m_etaBins.at(1));
704 }
705
706 // according to the parameter type, get the actual parameter going to the correction function
707 // for this, loop over the parameter type vector
708 const std::string shapeStr{"TopoClusterIsoCentralEventShape"};
709 for (unsigned int parameter_itr = 0; parameter_itr < m_ParameterTypeVector.size(); parameter_itr++)
710 {
711 switch (m_ParameterTypeVector.at(parameter_itr))
712 {
714 // evaluate TGraph at eta
715 properties.at(parameter_itr) = m_graphCopies.at(parameter_itr)->Eval(etaForBinned);
716 break;
718 // evaluate TGraph at pt
719 properties.at(parameter_itr) = m_graphCopies.at(parameter_itr)->Eval(pt);
720 break;
722 // get value of correct eta bin
723 ATH_CHECK(get1DBinnedParameter(properties.at(parameter_itr),etaForBinned,m_etaBins,parameter_itr));
724 break;
726 // get value of correct pt bin
727 ATH_CHECK(get1DBinnedParameter(properties.at(parameter_itr),pt,m_ptBins,parameter_itr));
728 break;
730 // get value of correct eta x pt bin
731 ATH_CHECK(get2DBinnedParameter(properties.at(parameter_itr),etaForBinned,pt,parameter_itr));
732 break;
734 { // need curly brackets here to mark scope - since etaForThisTH2 is initialized (and only needed) here
735 // check if need to use eta or abseta for this parameter (depends on the respective TH2)
736 float etaForThisTH2 = eta;
737 if (m_useAbsEtaTH2.at(parameter_itr) == 0.)
738 { etaForThisTH2 = std::abs(eta); }
739 // get value of correct eta x phi bin
740 ATH_CHECK(get2DHistParameter(properties.at(parameter_itr),etaForThisTH2,phi,parameter_itr));
741 }
742 break;
744 // get event density
745 ATH_CHECK(getDensity(properties.at(parameter_itr), shapeStr));
746 break;
747 default:
748 {}//only adding default to omit compile time warnings for not including parameterType::Failure
749 // this case will never occur, since returning this case fails earlier
750 }
751 }
752
753 for (auto p : properties)
754 ATH_MSG_VERBOSE("prop " << p);
755
756 // everything went fine, so
757 return StatusCode::SUCCESS;
758}
const StatusCode getDensity(float &value, const std::string &eventShapeContainer) const
Get the events energy density from the eventShape.
const StatusCode get2DHistParameter(float &return_parameter_value, const float etaEvalPoint, const float phiEvalPoint, const int parameter_number) const
Get the correction function parameter value if its type is eta- and pT-binned.
std::vector< parameterType > m_ParameterTypeVector
Map of the correction function parameter number to the parameter type.
const StatusCode get1DBinnedParameter(float &return_parameter_value, const float evalPoint, const std::vector< float > &binning, const int parameter_number) const
Get the correction function parameter value if its type is eta- or pT-binned.
int m_numberOfFunctionParameters
Number of parameters of the variable correction function.
const StatusCode get2DBinnedParameter(float &return_parameter_value, const float etaEvalPoint, const float ptEvalPoint, const int parameter_number) const
Get the correction function parameter value if its type is eta- and pT-binned.
bool m_useAbsEtaBinned
Store if the eta binned parameters need the eta or abs(eta) value for evaluation.
std::vector< std::unique_ptr< TGraph > > m_graphCopies
Copy of the TGraph from the root file, stored if needed by the respective correction function paramet...

◆ getCorrectionVariable()

const std::string & ElectronPhotonVariableCorrectionBase::getCorrectionVariable ( )
inline

Returns the variable which should be corrected according to the passed configuration file.

Definition at line 96 of file ElectronPhotonVariableCorrectionBase.h.

96{ return m_correctionVariable; };

◆ getDensity()

const StatusCode ElectronPhotonVariableCorrectionBase::getDensity ( float & value,
const std::string & eventShapeContainer ) const
private

Get the events energy density from the eventShape.

Parameters
valueThe respective correction function parameter value is saved in this parameter
eventShapeContainerThe name of the respective event shape container to use

Definition at line 1005 of file ElectronPhotonVariableCorrectionBase.cxx.

1006{
1007 // retrieve the event shape container
1008 const xAOD::EventShape* evtShape = nullptr;
1009 if(evtStore()->retrieve(evtShape, eventShapeContainer).isFailure()){
1010 ATH_MSG_ERROR("Cannot retrieve density container " << eventShapeContainer);
1011 return StatusCode::FAILURE;
1012 }
1013 // get the density from the container
1015 return StatusCode::SUCCESS;
1016}
ServiceHandle< StoreGateSvc > & evtStore()
bool getDensity(EventDensityID id, double &v) const
Get a density variable from the object.
EventShape_v1 EventShape
Definition of the current event format version.
Definition EventShape.h:16

◆ getEtaPtBinningsFromConf()

const StatusCode ElectronPhotonVariableCorrectionBase::getEtaPtBinningsFromConf ( const bool getEtaBins,
const bool getPtBins,
const TString & binValues,
const TString & interpolate,
TEnv & env,
const int parameter_number )
private

Get the eta and pt binning as well as the respective correction values from the given conf file.

Parameters
getEtaBinsif to get the eta binning and bin values
getPtBinsif to get the pt binning and bin values
binValuesthe conf file key to retrieve the bin values
interpolatethe conf file key on wheather to interpolate the pt values
envThe given TEnv,, which is used to read out the current conf file
parameter_numberThe parameter number with respect to the m_correctionFunctionTF1

Definition at line 553 of file ElectronPhotonVariableCorrectionBase.cxx.

554{
555 // if needed and not already retrieved, get eta binning
556 if (getEtaBins && !m_retrievedEtaBinning)
557 {
558 // check if necessary information is in conf, else fail
559 if (env.Lookup("EtaBins"))
560 {
561 //get the eta binning (global!)
563 //force that the low bin edges are given by the conf file, starting with 0 or a negative value
564 if (m_etaBins.at(0) > 0.)
565 {
566 ATH_MSG_ERROR("Lowest bin edge given for parameter " << parameter_number << " is > 0. Please provide the lower bin edges of your correction binning in the conf file, starting with either 0 (for corrections symmetric in eta) or a negative number (being treated as -infinity).");
567 return StatusCode::FAILURE;
568 }
569 else
570 {
571 m_useAbsEtaBinned = m_etaBins.at(0) >= 0;
572 }
573 // don't want to retrieve the same thing twice from conf
575 }
576 else
577 {
578 ATH_MSG_ERROR("Could not retrieve eta binning.");
579 return StatusCode::FAILURE;
580 }
581 }
582 // if needed and not already retrieved, get pt binning
583 if (getPtBins && !m_retrievedPtBinning)
584 {
585 // check if necessary information is in conf, else fail
586 if (env.Lookup("PtBins"))
587 {
588 //get the pt binning (global!)
590 //force that the low bin edges are given by the conf file, starting with 0
591 if (m_ptBins.at(0) != 0.)
592 {
593 ATH_MSG_ERROR("Lowest bin edge given for parameter " << parameter_number << " is not 0. Please provide the lower bin edges of your correction binning in the conf file, starting with 0.");
594 return StatusCode::FAILURE;
595 }
596 // don't want to retrieve the same thing twice from conf
598 }
599 else
600 {
601 ATH_MSG_ERROR("Could not retrieve pt binning.");
602 return StatusCode::FAILURE;
603 }
604 }
605 //check if interpolation should be done
606 if (getPtBins)
607 {
608 // default is false
609 m_interpolatePtFlags.at(parameter_number) = env.GetValue(interpolate.Data(),false);
610 }
611 if ( getEtaBins || getPtBins)
612 {
613 // check if necessary information is in conf, else fail
614 if (env.Lookup(binValues))
615 {
616 //get the binned values of the eta/pt dependent parameter
617 m_binValues.at(parameter_number) = AsgConfigHelper::HelperFloat(binValues.Data(),env);
618 }
619 else
620 {
621 ATH_MSG_ERROR("Could not retrieve binned values.");
622 return StatusCode::FAILURE;
623 }
624 }
625
626 // everything went fine, so
627 return StatusCode::SUCCESS;
628}
bool m_retrievedPtBinning
Store if already retrieved pt binning.
bool m_retrievedEtaBinning
Store if already retrieved eta binning.
std::vector< bool > m_interpolatePtFlags
List of bools whether a parameter should use linear interpolation in pT if it's some kind of pT binne...
std::vector< float > HelperFloat(const std::string &input, TEnv &env)

◆ getInterpolationFlag()

bool ElectronPhotonVariableCorrectionBase::getInterpolationFlag ( const int parameter_number) const
private

Return the interpolation flag of parameter parameter_number as a boolean.

Parameters
parameter_numberNumber of the parameter for which the interpolation flag should be checked
Returns
The interpolation flag of parameter parameter_number (boolean)

Definition at line 890 of file ElectronPhotonVariableCorrectionBase.cxx.

891{
892 bool do_interpolation = false;
893 // get parameter number type
895 // check if parameter has a type for which we need to check if interpolation is wanted
897 {
898 // get the flag
899 do_interpolation = m_interpolatePtFlags.at(parameter_number);
900 }
901 return do_interpolation;
902}
parameterType
Use enum and not string for type of function parameter in order to do faster comparisons.

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

◆ getKinematicProperties()

const StatusCode ElectronPhotonVariableCorrectionBase::getKinematicProperties ( const xAOD::Egamma & egamma_object,
float & pt,
float & eta,
float & phi ) const
private

Get the e/y kinematic properties.

Parameters
egamma_objectThe e/y object to get the kinematic properties of
ptThe pT value is saved in this parameter
etaThe eta value is saved in this parameter

As every electron/photon has different values of pT/eta, the correction function must be adapted accordingly for every e/y. The according values of eta and pt are updated with this function.

Definition at line 423 of file ElectronPhotonVariableCorrectionBase.cxx.

424{
425 // just retrieving eta and pt is probably less expensive then checking if I need it and
426 // then retrieve it only if I actually need it
427
428 // protection against bad clusters
429 const xAOD::CaloCluster* cluster = egamma_object.caloCluster();
430 if ( cluster == nullptr )
431 {
432 ATH_MSG_ERROR("EGamma object calorimeter cluster is NULL: Cluster " << cluster);
433 return StatusCode::FAILURE;
434 }
435
436 // Fill variables
437 // eta position in second sampling
438 eta = cluster->etaBE(2);
439 // transverse energy in calorimeter (using eta position in second sampling)
440 const double energy = cluster->e();
441 double et = 0.;
442 if (eta<999.) {
443 const double cosheta = cosh(eta);
444 et = (cosheta != 0.) ? energy/cosheta : 0.;
445 }
446 pt = et;
447 // issue a warning if pT is unphysical - i.e. < 0
448 if (pt < 0)
449 {
450 ATH_MSG_WARNING("Encountered EGamma object with strange pT: " << pt << " MeV. Correcting as if it has a pT of 0.");
451 }
452 // phi
453 phi = cluster->phiBE(2);
454
455 // everything went fine, so
456 return StatusCode::SUCCESS;
457}
#define ATH_MSG_WARNING(x,...)
float et(const xAOD::jFexSRJetRoI *j)
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
virtual double e() const
The total energy of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
const xAOD::CaloCluster * caloCluster(size_t index=0) const
Pointer to the xAOD::CaloCluster/s that define the electron candidate.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

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

◆ getObjectFromRootFile()

std::unique_ptr< TObject > ElectronPhotonVariableCorrectionBase::getObjectFromRootFile ( TEnv & env,
const int parameter_number,
const TString & filePathKey,
const TString & nameKey )
private

Get a TObject storing corrections (i.e.

TGraph or TH2) from a root file

Parameters
envThe configuration file to search for the relevant information (file path, object name)
parameter_numberThe number of the respective parameter, used to display error messages correctly
filePathKeyThe key for finding the file path in env
nameKeyThe key for finding the object name in env
return_objectThe retrieved TObject will be saved in this variable

The TObject with the name matching the key nameKey stored in the file with path matching filePathKey in the configuration file env will be retrieved and saved in return_object.

Definition at line 631 of file ElectronPhotonVariableCorrectionBase.cxx.

632{
633 // helpers
634 TString filePath = "";
635 TString objectName = "";
636 // check if necessary information is in conf, else fail
637 if (env.Lookup(filePathKey))
638 {
639 //get the path to the root file where the graph is saved
640 filePath = PathResolverFindCalibFile(env.GetValue(filePathKey.Data(),""));
641 // fail if file not found
642 if (filePath == "")
643 {
644 ATH_MSG_ERROR("Could not locate Parameter" << parameter_number << " TObject file.");
645 return nullptr;
646 }
647 }
648 else
649 {
650 ATH_MSG_ERROR("Could not retrieve Parameter" << parameter_number << " file path.");
651 return nullptr;
652 }
653 // check if necessary information is in conf, else fail
654 if (env.Lookup(nameKey))
655 {
656 //get the name of the TGraph
657 objectName = env.GetValue(nameKey.Data(),"");
658 }
659 else
660 {
661 ATH_MSG_ERROR("Could not retrieve Parameter" << parameter_number << " object name.");
662 return nullptr;
663 }
664 // open file, if it works, try to find object, get object, store a copy, else warning + fail
665 auto file = std::make_unique<TFile>(filePath.Data(),"READ");
666 // check if file is open - if open, get graph, if not, fail
667 if (file->IsOpen())
668 {
669 TObject* object = file->Get(objectName.Data());
670 if (!object){
671 ATH_MSG_ERROR("Could not find TObject " << objectName << " in file " << filePath);
672 return nullptr;
673 }
674 //clone would not be required for THx objects, but we want this to work for TGraph also
675 auto returnObj = std::unique_ptr<TObject> (object->Clone());
676 // need to un-associate THx type objects from file directory, so they remain accessible
677 if (auto pHist = dynamic_cast<TH1*>(returnObj.get());pHist != nullptr)
678 {
679 pHist->SetDirectory(nullptr);
680 }
681 file->Close();
682 return returnObj;
683 }
684 ATH_MSG_ERROR("Could not open Parameter" << parameter_number << " TObject file " << filePath.Data());
685 return nullptr;
686}
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
str filePath
Definition hancool.py:27
TFile * file

◆ getParameterInformationFromConf()

const StatusCode ElectronPhotonVariableCorrectionBase::getParameterInformationFromConf ( TEnv & env,
const int parameter_number,
const ElectronPhotonVariableCorrectionBase::parameterType type )
private

Get the relevant information for a correction function parameter from the given conf file.

Parameters
envThe given TEnv, which is used to read out the current conf file
parameter_numberThe parameter number with respect to the m_correctionFunctionTF1
typeThe type of the respective parameter with this parameter_number

The relevant information for the parameter with the given parameter number and given parameter type is retrieved from the current configuration file, and saved in the according member variables of the class, i.e. m_graphCopies, m_binValues, m_etaBins, m_ptBins

Definition at line 459 of file ElectronPhotonVariableCorrectionBase.cxx.

460{
461 // don't want to write the same code multiple times, so set flags when to retrieve eta/pt bins
462 bool getEtaBins = false;
463 bool getPtBins = false;
464 // form strings according to which parameter to retrieve
465 TString filePathKey = TString::Format("Parameter%dFile",parameter_number);
466 TString graphNameKey = TString::Format("Parameter%dGraphName",parameter_number);
467 TString histNameKey = TString::Format("Parameter%dTH2Name",parameter_number);
468 TString binValues = TString::Format("Parameter%dValues",parameter_number);
469 TString interpolate = TString::Format("Parameter%dInterpolate",parameter_number);
470
471 // according to the parameter type, retrieve the information from conf
472 switch (type)
473 {
475 // this fallthrough is intentional!
477 {
478 auto object = getObjectFromRootFile(env, parameter_number, filePathKey, graphNameKey);
479 if (!object) {
480 return StatusCode::FAILURE;
481 }
482 auto* graph = dynamic_cast<TGraph*>(object.get());
483 if (!graph) {
484 ATH_MSG_ERROR("Object for parameter " << parameter_number << " is not a TGraph.");
485 return StatusCode::FAILURE;
486 }
487 m_graphCopies.at(parameter_number) = std::unique_ptr<TGraph>( static_cast<TGraph*>(object.release()));
488 }
489 break;
491 //get eta binning later
492 getEtaBins = true;
493 break;
495 //get pt binning later
496 getPtBins = true;
497 break;
499 //get eta and pt binning later
500 getEtaBins = true;
501 getPtBins = true;
502 break;
504 {
505 auto object = getObjectFromRootFile(env, parameter_number, filePathKey, histNameKey);
506 if (!object) [[unlikely]] {
507 ATH_MSG_ERROR("TH2 object is null.");
508 return StatusCode::FAILURE;
509 }
510 auto* th2 = dynamic_cast<TH2*>(object.get());
511 if (!th2) [[unlikely]] {
512 ATH_MSG_ERROR("Object for parameter " << parameter_number << " is not a TH2.");
513 return StatusCode::FAILURE;
514 }
515 // Bin 0 is the underflow bin, so use bin 1.
516 auto* axis = th2->GetXaxis();
517 if (!axis) [[unlikely]] {
518 ATH_MSG_ERROR("TH2 X axis is null.");
519 return StatusCode::FAILURE;
520 }
521 const float lowest_bin_boundary = axis->GetBinLowEdge(1);
522 if (lowest_bin_boundary > 0) {
524 "Lowest bin edge in TH2 for parameter "
525 << parameter_number
526 << " is > 0. Please provide the TH2 including corrections either "
527 "for the positive eta range (starting at 0), or the whole eta "
528 "range (starting with a negative dummy value which is treated "
529 "as -infinity.");
530 return StatusCode::FAILURE;
531 }
532 m_useAbsEtaTH2.at(parameter_number) = lowest_bin_boundary;
533 m_TH2Copies.at(parameter_number) =
534 std::unique_ptr<TH2>( static_cast<TH2*>(object.release()));
535 }
536 break;
538 // nothing has to be retrieved, no additional parameters for EventDensity currently
539 return StatusCode::SUCCESS;
540 default:
541 {}//only adding default to omit compile time warnings for not including parameterType::Failure
542 // this case will never occur, since returning this case fails earlier
543 }
544
545 //get the pt and eta binning from the conf file, if necessary
546 if (getEtaBins || getPtBins)
547 { ATH_CHECK(getEtaPtBinningsFromConf(getEtaBins, getPtBins, binValues, interpolate, env, parameter_number)); }
548
549 //everything went fine, so
550 return StatusCode::SUCCESS;
551}
const StatusCode getEtaPtBinningsFromConf(const bool getEtaBins, const bool getPtBins, const TString &binValues, const TString &interpolate, TEnv &env, const int parameter_number)
Get the eta and pt binning as well as the respective correction values from the given conf file.
std::unique_ptr< TObject > getObjectFromRootFile(TEnv &env, const int parameter_number, const TString &filePathKey, const TString &nameKey)
Get a TObject storing corrections (i.e.
static std::string release
Definition computils.h:54
#define unlikely(x)

◆ getProperty()

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

Get one of the tool's properties.

◆ getTLSRandomGen()

TRandom3 * ElectronPhotonVariableCorrectionBase::getTLSRandomGen ( unsigned int seed) const
private

Getting thread safe random number generator (and resetting its seed).

Definition at line 1098 of file ElectronPhotonVariableCorrectionBase.cxx.

1099{
1100 TRandom3* random = m_TRandom_tls.get();
1101 if (!random) {
1102 random = new TRandom3();
1103 m_TRandom_tls.reset(random);
1104 }
1105 random->SetSeed(seed);
1106 return random;
1107}
boost::thread_specific_ptr< TRandom3 > m_TRandom_tls
thread-safe TRandom3 for setting seed of random smearing correction

◆ initialize()

StatusCode ElectronPhotonVariableCorrectionBase::initialize ( void )
overridevirtual

Initialize the class instance.

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

Reimplemented from asg::AsgTool.

Definition at line 46 of file ElectronPhotonVariableCorrectionBase.cxx.

47{
48 // Locate configuration file, abort if not found
49 std::string configFile;
50 if (!m_configFile.empty())
51 {
53 if (configFile.empty())
54 {
55 ATH_MSG_ERROR("Could not locate configuration file " << m_configFile);
56 return StatusCode::FAILURE;
57 }
58 ATH_MSG_DEBUG("Use configuration file " << m_configFile << " " << configFile);
59 }
60 else
61 {
62 ATH_MSG_ERROR("Config file string is empty. Please provide a config file to the tool.");
63 return StatusCode::FAILURE;
64 }
65
66 // retrieve properties from configuration file, using TEnv class
67 TEnv env;
68 env.ReadFile(configFile.c_str(), kEnvLocal);
69 // Send warning if duplicates found in conf file
70 env.IgnoreDuplicates(false);
71
72 //retrieve variable to correct
73 if (env.Lookup("Variable"))
74 {
75 m_correctionVariable = env.GetValue("Variable","");
76 }
77 else
78 {
79 ATH_MSG_ERROR("Correction variable is empty or not in configuration file.");
80 return StatusCode::FAILURE;
81 }
82
83 // initialize the variable aux element accessors
84 // variable to be corrected
85 m_variableToCorrect = std::make_unique<SG::Accessor<float>>(m_correctionVariable);
86 // save original value under different name
87 m_originalVariable = std::make_unique<SG::Accessor<float>>(m_correctionVariable + "_original");
88
89 // Get whether to apply a pure correction or to smear the variable (shift by a random amount,
90 // determined using function as probability density function)
91 if (env.Lookup("doGaussianSmearing"))
92 {
93 m_doGaussianSmearing = env.GetValue("doGaussianSmearing", false); // Default is to not do smearing - keeps previous configs valid
94 }
95 // Get the function used to correct the variable
96 if (env.Lookup("Function"))
97 {
98 m_correctionFunctionString = env.GetValue("Function","failure");
99 // initialize the actual correction function TFormula
100 m_correctionFunctionTFormula = std::make_unique<TFormula>("m_correctionFunctionTF1",m_correctionFunctionString.c_str(), false);
101 }
102 else
103 {
104 ATH_MSG_ERROR("Correction function is empty or not in configuration file.");
105 return StatusCode::FAILURE;
106 }
107
108 // Get the number of parameters used in the correction function
109 if (env.Lookup("nFunctionParameters"))
110 {
111 m_numberOfFunctionParameters = env.GetValue("nFunctionParameters",-1);
112
113 // If doing the Gaussian smearing, there can only be two parameters
114 // so fail if there is more or less than this
116 {
117 ATH_MSG_ERROR("When using Gaussian smearing, there can only be two " <<
118 "function parameters, the Gaussian mean and the Gaussian width");
119 return StatusCode::FAILURE;
120 }
121
122 }
123 else
124 {
125 ATH_MSG_ERROR("You did not specify the number of parameters in the correction function.");
126 return StatusCode::FAILURE;
127 }
128
129 // resize all vectors used for getting parameters to m_numberOfFunctionParameters
136
137 // Save the type of all parameters in the correction function (assuming m_numberOfFunctionParameters parameters)
138 for (int parameter_itr = 0; parameter_itr < m_numberOfFunctionParameters; parameter_itr++)
139 {
140 // if the parameter #parameter_itr is in the conf file, save its type
141 TString parameterType = TString::Format("Parameter%dType",parameter_itr);
142 if (env.Lookup(parameterType))
143 {
144 // convert string to ParameterType, fail if non-existing type
147 {
148 ATH_MSG_ERROR("Parameter " << parameter_itr << " read-in failed, not an allowed parameter type.");
149 return StatusCode::FAILURE;
150 }
151 // save type, get according type information and save it
152 m_ParameterTypeVector.at(parameter_itr) = type;
153 ATH_CHECK(getParameterInformationFromConf(env, parameter_itr, type));
154 }
155 // else fail
156 else
157 {
158 ATH_MSG_ERROR("Did not find Parameter" << parameter_itr << ", although you specified there were " << m_numberOfFunctionParameters << " parameters for the correction function.");
159 return StatusCode::FAILURE;
160 }
161 } // end loop over all function parameters
162
163 // check to which EGamma object the conf file should be applied to, if flag is set
164 if (env.Lookup("ApplyTo"))
165 {
166 std::string applyToObjectsFlag = env.GetValue("ApplyTo","Failure");
167 m_applyToObjects = stringToEGammaObject(applyToObjectsFlag);
168 // fail if not passed a proper type
170 {
171 ATH_MSG_ERROR("You did not correctly specify the object type in the ApplyTo flag.");
172 return StatusCode::FAILURE;
173 }
174 }
175 // else fail
176 else
177 {
178 ATH_MSG_ERROR("You did not specify to which objects this conf file should be applied to (ApplyTo).");
179 return StatusCode::FAILURE;
180 }
181
182 // check if there are any (discrete) values which should be left uncorrected
183 if (env.Lookup("UncorrectedDiscontinuities"))
184 {
185 m_uncorrectedDiscontinuities = AsgConfigHelper::HelperFloat("UncorrectedDiscontinuities", env);
186 // if flag is given, but no values, fail
188 {
189 ATH_MSG_ERROR("Did not find any discontinuities to not correct, despite finding the flag UncorrectedDiscontinuities.");
190 return StatusCode::FAILURE;
191 }
192 }
193
194 //everything worked out, so
195 return StatusCode::SUCCESS;
196}
#define ATH_MSG_DEBUG(x,...)
std::unique_ptr< SG::Accessor< float > > m_originalVariable
Accessor to store the original value of the corrected variable.
std::string m_correctionFunctionString
Function to use for the variable correction, TFormula style.
std::vector< float > m_uncorrectedDiscontinuities
Values of discontinuities in the variable which should not be corrected.
const StatusCode getParameterInformationFromConf(TEnv &env, const int parameter_number, const ElectronPhotonVariableCorrectionBase::parameterType type)
Get the relevant information for a correction function parameter from the given conf file.
ElectronPhotonVariableCorrectionBase::parameterType stringToParameterType(const std::string &input) const
Convert input string to a parameter function type.
ElectronPhotonVariableCorrectionBase::EGammaObjects stringToEGammaObject(const std::string &input) const
Convert input string to egamma object type.

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

◆ interpolate()

const StatusCode ElectronPhotonVariableCorrectionBase::interpolate ( float & return_parameter_value,
const float evalPoint,
const int bin,
const std::vector< float > & binning,
const std::vector< float > & binValues ) const
private

Given a point x, approximates the value via linear interpolation based on the two nearest bin centers.

Re-implementation of Double_t TH1::Interpolate( Double_t x) const.

Parameters
return_parameter_valueThe interpolated parameter value is saved in this parameter
evalPointThe point for which the interpolation should be done
binThe bin in which the evalPoint is located with respect to binning
binningThe binning based on which the interpolation should be done
binValuesThe bin values according to the binning given in binning

Definition at line 904 of file ElectronPhotonVariableCorrectionBase.cxx.

905{
906 // check if passed binning is consistent
907 if (binning.size() != binValues.size())
908 {
909 ATH_MSG_ERROR("Binning and bin values have different sizes.");
910 return StatusCode::FAILURE;
911 }
912
913 // if evalPoint is left to the leftmost bin center, return the leftmost bin center without interpolation
914 float leftmost_bin_center = 0;
915 ANA_CHECK(getBinCenter(leftmost_bin_center, binning, 0));
916 if (evalPoint <= leftmost_bin_center)
917 {
918 return_parameter_value = binValues.at(0);
919 return StatusCode::SUCCESS;
920 }
921
922 // if evalPoint is right to the rightmost bin center, return the rightmost bin center without interpolation
923 float rightmost_bin_center = 0;
924 ANA_CHECK(getBinCenter(rightmost_bin_center, binning, binning.size()-1));
925 if (evalPoint >= rightmost_bin_center)
926 {
927 return_parameter_value = binValues.at(binValues.size()-1);
928 return StatusCode::SUCCESS;
929 }
930
931 float left_bin_center = 0;
932 float right_bin_center = 0;
933 float left_bin_value = 0;
934 float right_bin_value = 0;
935 float current_bin_center = 0;
936 ANA_CHECK(getBinCenter(current_bin_center, binning, bin));
937
938 // else interpolate using next left or next right bin
939 if (evalPoint <= current_bin_center)
940 {
941 //interpolate left
942 ANA_CHECK(getBinCenter(left_bin_center, binning, bin-1));
943 ANA_CHECK(getBinCenter(right_bin_center, binning, bin));
944 left_bin_value = binValues.at(bin-1);
945 right_bin_value = binValues.at(bin);
946 }
947 else // evalPoint is right from bin center
948 {
949 //interpolate right
950 ANA_CHECK(getBinCenter(left_bin_center, binning, bin));
951 ANA_CHECK(getBinCenter(right_bin_center, binning, bin+1));
952 left_bin_value = binValues.at(bin);
953 right_bin_value = binValues.at(bin+1);
954 }
955 ATH_MSG_VERBOSE("bin centers : " << left_bin_center << " " << right_bin_center << " current : " << current_bin_center << " values : " << left_bin_value << " " << right_bin_value);
956
957 // calculate return value
958 return_parameter_value = interpolate_function(evalPoint, left_bin_center, left_bin_value, right_bin_center, right_bin_value);
959
960 // everything went fine, so
961 return StatusCode::SUCCESS;
962}
#define ANA_CHECK(EXP)
check whether the given expression was successful
const StatusCode getBinCenter(float &return_bin_center, const std::vector< float > &binning, const int bin_int) const
Get the bin center of a bin bin_int using the binning binning.
static float interpolate_function(const float value, const float left_bin_center, const float left_bin_value, const float right_bin_center, const float right_bin_value)
Returns the linearly intrpolated value of value given the bin centers and bin values.

◆ interpolate_function()

float ElectronPhotonVariableCorrectionBase::interpolate_function ( const float value,
const float left_bin_center,
const float left_bin_value,
const float right_bin_center,
const float right_bin_value )
staticprivate

Returns the linearly intrpolated value of value given the bin centers and bin values.

Parameters
valueThe x-value at which the interpolation should be done
left_bin_centerThe x-value of the left bin center used for the interpolation
left_bin_valueThe y-value of the left bin at the left bin center
right_bin_centerThe x-value of the right bin center used for the interpolation
right_bin_valueThe y-value of the right bin at the right bin center

Definition at line 1000 of file ElectronPhotonVariableCorrectionBase.cxx.

1001{
1002 return left_bin_value + (value - left_bin_center) * (right_bin_value - left_bin_value) / (right_bin_center - left_bin_center);
1003}

◆ isAppliedTo()

ElectronPhotonVariableCorrectionBase::EGammaObjects ElectronPhotonVariableCorrectionBase::isAppliedTo ( )
inline

Returns the type of EGamma object to which the correction should be applied.

Definition at line 113 of file ElectronPhotonVariableCorrectionBase.h.

113{ return m_applyToObjects; };

◆ isEqualToUncorrectedDiscontinuity()

bool ElectronPhotonVariableCorrectionBase::isEqualToUncorrectedDiscontinuity ( const float value) const
private

Check if the value passed is equal to one of the values passed via the UncorrectedDiscontinuites flag and should thus not be corrected.

Parameters
valueThe value which should be checked

Definition at line 402 of file ElectronPhotonVariableCorrectionBase.cxx.

403{
404 // if no values set, return false as there is nothing to check
406 {
407 return false;
408 }
409
410 // check all discontinuities which where passed
411 for (unsigned int value_itr = 0; value_itr < m_uncorrectedDiscontinuities.size(); value_itr++)
412 {
413 if (value == m_uncorrectedDiscontinuities.at(value_itr))
414 {
415 // if the value is equal to one of the discontinuities, no need to check further
416 return true;
417 }
418 }
419 // if we eer get here, the value was never equal to a discontinuity
420 return false;
421}

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

◆ passedCorrectPhotonType()

bool ElectronPhotonVariableCorrectionBase::passedCorrectPhotonType ( const xAOD::Photon & photon) const
private

Check if the photon which was passed to the tool has the correct type, if only (un)converted photons were requested to be corrected.

Parameters
photonThe photon which was passed to the tool to be corrected

Definition at line 1064 of file ElectronPhotonVariableCorrectionBase.cxx.

1065{
1066 // retrieve if photon is converted or unconverted
1068 bool isUnconvertedPhoton = !isConvertedPhoton;
1069
1070 // check if conf file ApplyTo flag matches photon conversion type
1071 return ((applyToConvertedPhotons() && isConvertedPhoton) || (applyToUnconvertedPhotons() && isUnconvertedPhoton));
1072}
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

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

◆ stringToEGammaObject()

ElectronPhotonVariableCorrectionBase::EGammaObjects ElectronPhotonVariableCorrectionBase::stringToEGammaObject ( const std::string & input) const
private

Convert input string to egamma object type.

Parameters
inputThe string to convert to ElectronPhotonVariableCorrectionBase::EGammaObjects
Returns
ElectronPhotonVariableCorrectionBase::EGammaObjects, returns ElectronPhotonVariableCorrectionBase::EGammaObjects::Failure if no match found

Definition at line 1043 of file ElectronPhotonVariableCorrectionBase.cxx.

1044{
1045 // return object type which correction should be applied to
1046 if( input == "unconvertedPhotons" )
1048 else if( input == "convertedPhotons" )
1050 else if( input == "allPhotons" )
1052 else if( input == "allElectrons" )
1054 else if( input == "allEGammaObjects" )
1056 else
1057 {
1058 // if not a proper object type, return failure type - check and fail on this!
1059 ATH_MSG_ERROR(input.c_str() << " is not an allowed EGamma object type to apply corrections to.");
1061 }
1062}

◆ stringToParameterType()

ElectronPhotonVariableCorrectionBase::parameterType ElectronPhotonVariableCorrectionBase::stringToParameterType ( const std::string & input) const
private

Convert input string to a parameter function type.

Parameters
inputThe string to convert to ElectronPhotonVariableCorrectionBase::parameterType
Returns
ElectronPhotonVariableCorrectionBase::parameterType, returns ElectronPhotonVariableCorrectionBase::parameterType::Failure if no match found

Definition at line 1018 of file ElectronPhotonVariableCorrectionBase.cxx.

1019{
1020 // return parameter type according to string given in conf file
1021 if( input == "EtaDependentTGraph")
1023 else if( input == "PtDependentTGraph")
1025 else if( input == "EtaBinned")
1027 else if( input == "PtBinned")
1029 else if( input == "EtaTimesPtBinned")
1031 else if( input == "EtaTimesPhiTH2")
1033 else if( input == "EventDensity")
1035 else
1036 {
1037 // if not a proper type, return failure type - check and fail on this!
1038 ATH_MSG_ERROR(input.c_str() << " is not an allowed parameter type.");
1040 }
1041}

◆ 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

Member Data Documentation

◆ m_applyToObjects

ElectronPhotonVariableCorrectionBase::EGammaObjects ElectronPhotonVariableCorrectionBase::m_applyToObjects {}
private

The type of objects to which the specific conf file settings are allowed to be applied to.

Definition at line 177 of file ElectronPhotonVariableCorrectionBase.h.

177{};

◆ m_binValues

std::vector<std::vector<float> > ElectronPhotonVariableCorrectionBase::m_binValues
private

List of eta/pt dependent values, stored if needed by the respective correction function parameter.

Definition at line 167 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_configFile

std::string ElectronPhotonVariableCorrectionBase::m_configFile
private

The name of the configuration file.

Definition at line 143 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_correctionFunctionString

std::string ElectronPhotonVariableCorrectionBase::m_correctionFunctionString
private

Function to use for the variable correction, TFormula style.

Definition at line 153 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_correctionFunctionTFormula

std::unique_ptr<TFormula> ElectronPhotonVariableCorrectionBase::m_correctionFunctionTFormula
private

The actual TFormula correction function.

Definition at line 155 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_correctionVariable

std::string ElectronPhotonVariableCorrectionBase::m_correctionVariable
private

The name of the variable to correct.

Definition at line 145 of file ElectronPhotonVariableCorrectionBase.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_doGaussianSmearing

bool ElectronPhotonVariableCorrectionBase::m_doGaussianSmearing = false
private

Whether to apply normal correction or smearing correction.

Definition at line 147 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_etaBins

std::vector<float> ElectronPhotonVariableCorrectionBase::m_etaBins
private

List of bin boundaries in eta, stored if needed by any correction function parameter.

Definition at line 169 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_graphCopies

std::vector<std::unique_ptr<TGraph> > ElectronPhotonVariableCorrectionBase::m_graphCopies
private

Copy of the TGraph from the root file, stored if needed by the respective correction function parameter.

Definition at line 161 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_interpolatePtFlags

std::vector<bool> ElectronPhotonVariableCorrectionBase::m_interpolatePtFlags
private

List of bools whether a parameter should use linear interpolation in pT if it's some kind of pT binned parameter.

Definition at line 175 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_numberOfFunctionParameters

int ElectronPhotonVariableCorrectionBase::m_numberOfFunctionParameters {}
private

Number of parameters of the variable correction function.

Definition at line 157 of file ElectronPhotonVariableCorrectionBase.h.

157{};

◆ m_originalVariable

std::unique_ptr<SG::Accessor<float> > ElectronPhotonVariableCorrectionBase::m_originalVariable
private

Accessor to store the original value of the corrected variable.

Definition at line 185 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_ParameterTypeVector

std::vector<parameterType> ElectronPhotonVariableCorrectionBase::m_ParameterTypeVector
private

Map of the correction function parameter number to the parameter type.

Definition at line 159 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_ptBins

std::vector<float> ElectronPhotonVariableCorrectionBase::m_ptBins
private

List of bin boundaries in pT, stored if needed by any correction function parameter.

Definition at line 173 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_retrievedEtaBinning

bool ElectronPhotonVariableCorrectionBase::m_retrievedEtaBinning = false
private

Store if already retrieved eta binning.

Definition at line 179 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_retrievedPtBinning

bool ElectronPhotonVariableCorrectionBase::m_retrievedPtBinning = false
private

Store if already retrieved pt binning.

Definition at line 181 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_TH2Copies

std::vector<std::unique_ptr<TH2> > ElectronPhotonVariableCorrectionBase::m_TH2Copies
private

Copy of the TH2 from the root file, stored if needed by the respective correction function parameter.

Definition at line 163 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_TRandom_tls

boost::thread_specific_ptr<TRandom3> ElectronPhotonVariableCorrectionBase::m_TRandom_tls
mutableprivate

thread-safe TRandom3 for setting seed of random smearing correction

Definition at line 149 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_uncorrectedDiscontinuities

std::vector<float> ElectronPhotonVariableCorrectionBase::m_uncorrectedDiscontinuities
private

Values of discontinuities in the variable which should not be corrected.

Definition at line 151 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_useAbsEtaBinned

bool ElectronPhotonVariableCorrectionBase::m_useAbsEtaBinned {}
private

Store if the eta binned parameters need the eta or abs(eta) value for evaluation.

Definition at line 171 of file ElectronPhotonVariableCorrectionBase.h.

171{};

◆ m_useAbsEtaTH2

std::vector<float> ElectronPhotonVariableCorrectionBase::m_useAbsEtaTH2
private

Store the lowest eta bin boundary: used for checking if the respective TH2 needs the eta or abs(eta) value for evaluation.

Definition at line 165 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_variableToCorrect

std::unique_ptr<SG::Accessor<float> > ElectronPhotonVariableCorrectionBase::m_variableToCorrect
private

Accessor for the variable to be corrected.

Definition at line 183 of file ElectronPhotonVariableCorrectionBase.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 386 of file AthCommonDataStore.h.


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