5#ifndef ElectronPhotonVariableCorrectionBase_H
6#define ElectronPhotonVariableCorrectionBase_H
27#include "boost/thread/tss.hpp"
226 const StatusCode
getEtaPtBinningsFromConf(
const bool getEtaBins,
const bool getPtBins,
const TString& binValues,
const TString&
interpolate, TEnv& env,
const int parameter_number);
237 const StatusCode
getObjectFromRootFile(TEnv& env,
const int parameter_number,
const TString& filePathKey,
const TString& nameKey, std::unique_ptr<TObject>& return_object);
248 std::vector<float>& properties)
const;
256 const StatusCode
get1DBinnedParameter(
float& return_parameter_value,
const float evalPoint,
const std::vector<float>& binning,
const int parameter_number)
const;
264 const StatusCode
get2DBinnedParameter(
float& return_parameter_value,
const float etaEvalPoint,
const float ptEvalPoint,
const int parameter_number)
const;
272 const StatusCode
get2DHistParameter(
float& return_parameter_value,
const float etaEvalPoint,
const float phiEvalPoint,
const int parameter_number)
const;
279 static const StatusCode
findBin(
int& return_bin,
const float evalPoint,
const std::vector<float>& binning) ;
294 const StatusCode
interpolate(
float& return_parameter_value,
const float evalPoint,
const int bin,
const std::vector<float>& binning,
const std::vector<float>& binValues)
const;
301 const StatusCode
getBinCenter(
float& return_bin_center,
const std::vector<float>& binning,
const int bin_int)
const;
310 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) ;
316 const StatusCode
getDensity(
float& value,
const std::string& eventShapeContainer)
const;
333 void correct(
float& return_corrected_variable,
const float original_variable,
334 const std::vector<float>& properties,
unsigned int rndSeed = 0)
const;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Return value from object correction CP tools.
std::unique_ptr< TFormula > m_correctionFunctionTFormula
The actual TFormula correction function.
std::vector< std::vector< float > > m_binValues
List of eta/pt dependent values, stored if needed by the respective correction function parameter.
boost::thread_specific_ptr< TRandom3 > m_TRandom_tls
thread-safe TRandom3 for setting seed of random smearing correction
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.
bool m_retrievedPtBinning
Store if already retrieved pt binning.
bool m_doGaussianSmearing
Whether to apply normal correction or smearing correction.
bool applyToConvertedPhotons() const
Check if the ApplyTo flag passed in the conf file is compatible with converted photons.
const StatusCode getDensity(float &value, const std::string &eventShapeContainer) const
Get the events energy density from the eventShape.
std::vector< float > m_useAbsEtaTH2
Store the lowest eta bin boundary: used for checking if the respective TH2 needs the eta or abs(eta) ...
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 applyToUnconvertedPhotons() const
Check if the ApplyTo flag passed in the conf file is compatible with uconverted photons.
std::vector< float > m_ptBins
List of bin boundaries in pT, stored if needed by any correction function parameter.
bool m_retrievedEtaBinning
Store if already retrieved eta binning.
bool isEqualToUncorrectedDiscontinuity(const float value) const
Check if the value passed is equal to one of the values passed via the UncorrectedDiscontinuites flag...
parameterType
Use enum and not string for type of function parameter in order to do faster comparisons.
const StatusCode getObjectFromRootFile(TEnv &env, const int parameter_number, const TString &filePathKey, const TString &nameKey, std::unique_ptr< TObject > &return_object)
Get a TObject storing corrections (i.e.
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::vector< TGraph * > m_graphCopies
Copy of the TGraph from the root file, stored if needed by the respective correction function paramet...
std::string m_correctionFunctionString
Function to use for the variable correction, TFormula style.
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.
const std::string & getCorrectionVariable()
Returns the variable which should be corrected according to the passed configuration file.
std::vector< parameterType > m_ParameterTypeVector
Map of the correction function parameter number to the parameter type.
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.
std::string m_configFile
The name of the configuration file.
TRandom3 * getTLSRandomGen(unsigned int seed) const
Getting thread safe random number generator (and resetting its seed)
ElectronPhotonVariableCorrectionBase::EGammaObjects isAppliedTo()
Returns the type of EGamma object to which the correction should be applied.
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 CP::CorrectionCode applyCorrection(xAOD::Photon &photon) const
Apply the correction given in the conf file to the passed photon.
std::vector< float > m_uncorrectedDiscontinuities
Values of discontinuities in the variable which should not be corrected.
virtual StatusCode initialize() override
Initialize the class instance.
~ElectronPhotonVariableCorrectionBase()
Standard destructor.
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.
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::unique_ptr< SG::AuxElement::Accessor< float > > m_variableToCorrect
Accessor for the variable to be corrected.
std::vector< float > m_etaBins
List of bin boundaries in eta, stored if needed by any correction function parameter.
ElectronPhotonVariableCorrectionBase::parameterType stringToParameterType(const std::string &input) const
Convert input string to a parameter function type.
bool getInterpolationFlag(const int parameter_number) const
Return the interpolation flag of parameter parameter_number as a boolean.
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.
ElectronPhotonVariableCorrectionBase::EGammaObjects stringToEGammaObject(const std::string &input) const
Convert input string to egamma object type.
int m_numberOfFunctionParameters
Number of parameters of the variable correction function.
bool applyToElectrons() const
Check if the ApplyTo flag passed in the conf file is compatible with electrons.
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.
std::string m_correctionVariable
The name of the variable to correct.
ElectronPhotonVariableCorrectionBase(const std::string &myname)
Standard constructor.
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.
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 getKinematicProperties(const xAOD::Egamma &egamma_object, float &pt, float &eta, float &phi) const
Get the e/y kinematic properties.
EGammaObjects
Define the categories of EGamma objects tool can be applied to.
std::vector< TH2 * > m_TH2Copies
Copy of the TH2 from the root file, stored if needed by the respective correction function parameter.
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 ...
bool m_useAbsEtaBinned
Store if the eta binned parameters need the eta or abs(eta) value for evaluation.
ElectronPhotonVariableCorrectionBase::EGammaObjects m_applyToObjects
The type of objects to which the specific conf file settings are allowed to be applied to.
std::unique_ptr< SG::AuxElement::Accessor< float > > m_originalVariable
Accessor to store the original value of the corrected variable.
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.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".