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

#include <EtaJESCalibStep.h>

Inheritance diagram for EtaJESCalibStep:
Collaboration diagram for EtaJESCalibStep:

Public Member Functions

 EtaJESCalibStep (const std::string &name="EtaJESCalibStep")
virtual StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual StatusCode calibrate (xAOD::JetContainer &) const override
 Apply calibration to a jet container.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
virtual StatusCode getNominalResolutionData (const xAOD::Jet &, const JetHelper::JetContext &, double &) const
virtual StatusCode getNominalResolutionMC (const xAOD::Jet &, const JetHelper::JetContext &, double &) const
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

double getLogPolN (const double *factors, double x) const
double getLogPolNSlope (const double *factors, double x) const
int getEtaBin (double eta_det) const
bool readMCJESFromText ()
bool readMCJESFromHists ()
void loadSplineHists (const std::string &fileName, const std::string &etajes_name)
double getJES (const double X, const double Y=0, const double Emax=-1) const
 return MCJES calibration factor
double getEtaCorr (double X, double Y=0) const
 return Eta correction
double getEmaxJES (const double Y) const
 return Emax
double getLowPtJES (double E_uncorr, double eta_det) const
 deal with low pt jets
double getSplineCorr (const int etaBin, double E) const
double getSplineSlope (const int ieta, const double minE) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Gaudi::Property< std::string > m_jetInScale {this, "InScale", "JetPileupScaleMomentum", "Starting jet scale"}
Gaudi::Property< std::string > m_jetOutScale {this, "OutScale", "JetEtaJESScaleMomentum", "Ending jet scale"}
Gaudi::Property< std::string > m_constantFileName { this, "CalibConstantFile", "", "text file containing constants" }
 name of the text file
Gaudi::Property< std::string > m_jetAlgo { this, "JetAlgo", "AntiKt4EMPFlow", "jet collection" }
 jet collection to be calibrated
Gaudi::Property< bool > m_freezeJESatHighE = {this, "FreezeJEScorrectionatHighE",false, " freeze at high e"}
Gaudi::Property< int > m_lowPtExtrap = {this, "LowPtJESExtrapolationMethod", 0, " low pt etrap"}
Gaudi::Property< float > m_lowPtMinR = {this, "LowPtJESExtrapolationMinimumResponse", 0.25, " low pt etrap min"}
Gaudi::Property< float > m_minPt_JES = {this, "MinPtForETAJES",15, "min pT"}
Gaudi::Property< bool > m_useSecondaryminPt_JES = {this, "UseSecondaryMinPtForETAJES", false, "min pT dependent on eta?"}
 Allowing to use different minPt_JES depending on eta (only for extrapolation methon 1).
Gaudi::Property< double > m_etaSecondaryminPt_JES = {this, "EtaSecondaryMinPtForETAJES", 1.9, "eta value for second min pT cut"}
 Starting eta for secondary minPt_JES (Default |eta|>=1.9) (Used only if UseSecondaryMinPtForETAJES is true).
Gaudi::Property< float > m_secondaryminPt_JES = {this, "SecondaryMinPtForETAJES", 7.0, "pt value for second min pT cut"}
 SecondaryminPt_JES (Default 7 GeV) (Used only if UseSecondaryMinPtForETAJES is true).
Gaudi::Property< float > m_minPt_EtaCorr = {this, "MinPtForEtaCorr" ,8. , ""}
Gaudi::Property< float > m_maxE_EtaCorr = {this, "MaxEForEtaCorr" ,2500. , ""}
Gaudi::Property< std::string > m_histoFileName { this, "HistoFile", "none", "root file containing histos for spline calib" }
Gaudi::Property< bool > m_useSpline = {this, "UseSpline",false, " use spline"}
Gaudi::Property< std::vector< double > > m_etaBins {this, "EtaBins", {} ,""}
 Eta bins if other than 0.1 steps from -4.5 to 4.5.
ToolHandle< JetHelper::IVarToolm_vartoolE {this, "VarToolE", "VarTool", "InputVariable instance E (or pT?)" }
ToolHandle< JetHelper::IVarToolm_vartoolEta {this, "VarToolEta", "VarTool", "InputVariable instance eta (or rapididty?)" }
 interface for xAOD::jet variable to be defined by user, this must correspond to jet Eta in currect version of jet calibration files
unsigned int m_nPar {}
double m_JESFactors [s_nEtaBins][s_nParMax] {}
double m_etaCorrFactors [s_nEtaBins][s_nParMax] {}
double m_energyFreezeJES [s_nEtaBins] {}
double m_JES_MinPt_Slopes [s_nEtaBins] ={}
double m_JES_MinPt_E [s_nEtaBins] ={}
double m_JES_MinPt_R [s_nEtaBins] ={}
TAxis * m_etaBinAxis {}
std::vector< std::unique_ptr< TH1 > > m_etajesFactors
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

Static Private Attributes

static const unsigned int s_nEtaBins = 90
static const unsigned int s_nParMax = 9

Detailed Description

Definition at line 31 of file EtaJESCalibStep.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ EtaJESCalibStep()

EtaJESCalibStep::EtaJESCalibStep ( const std::string & name = "EtaJESCalibStep")

Definition at line 18 of file EtaJESCalibStep.cxx.

19 : asg::AsgTool( name ){ }

Member Function Documentation

◆ calibrate()

StatusCode EtaJESCalibStep::calibrate ( xAOD::JetContainer & jets) const
overridevirtual

Apply calibration to a jet container.

Implements IJetCalibStep.

Definition at line 45 of file EtaJESCalibStep.cxx.

45 {
46 ATH_MSG_DEBUG("Calibrating jet collection with EtaJES.");
47
48
49 const xAOD::JetAttributeAccessor::AccessorWrapper<xAOD::JetFourMom_t> jesScaleMomAcc(m_jetOutScale);
50
51 for(xAOD::Jet* jet: jets){
52
53 const xAOD::JetFourMom_t jetStartP4 = jet->getAttribute<xAOD::JetFourMom_t>(m_jetInScale);
54 jet->setJetP4(jetStartP4);
55
56 // Extract the maximum energy, and store in the context
57 JetHelper::JetContext jc;
58 double varE {m_vartoolE->getValue(*jet,jc)};
59 double varEta {m_vartoolEta->getValue(*jet,jc)};
60 double Emax = 14000;
62 Emax = getEmaxJES(varEta);
63 }
64
65 // Extract JES from the text handling tool
66 double jesCorrection = getJES(varE, varEta, Emax);
67 int ieta=getEtaBin(varEta);
68
69
70 xAOD::JetFourMom_t calibP4 = jetStartP4 * jesCorrection;
71
72
73 const float etaCorr = calibP4.eta() + getEtaCorr(jesCorrection*varE, varEta) ; //m_textTool_Eta->getValue(*jet, jc);
74 ATH_MSG_DEBUG("eta = "<<etaCorr);
75
76 // Apply the eta correction, use TLV from ROOT to do some math for us
77 TLorentzVector TLVjet;
78 TLVjet.SetPtEtaPhiM( calibP4.P()/cosh(etaCorr), etaCorr, calibP4.phi(), calibP4.M() );
79 calibP4.SetPxPyPzE( TLVjet.Px(), TLVjet.Py(), TLVjet.Pz(), TLVjet.E() );
80 ATH_MSG_DEBUG("JES = "<<jesCorrection << " e="<<varE << " eta="<<jetStartP4.Eta()<< " ieta="<< ieta << " post_pt= ="<< calibP4.Pt() << " etaCorr="<< etaCorr);
81
82 // Set the decorations of this scale
83 jesScaleMomAcc.setAttribute(*jet, calibP4);
84 jet->setJetP4(calibP4);
85 }
86
87 return StatusCode::SUCCESS;
88}
#define ATH_MSG_DEBUG(x)
double getEmaxJES(const double Y) const
return Emax
ToolHandle< JetHelper::IVarTool > m_vartoolEta
interface for xAOD::jet variable to be defined by user, this must correspond to jet Eta in currect ve...
Gaudi::Property< std::string > m_jetInScale
double getEtaCorr(double X, double Y=0) const
return Eta correction
Gaudi::Property< bool > m_freezeJESatHighE
Gaudi::Property< std::string > m_jetOutScale
double getJES(const double X, const double Y=0, const double Emax=-1) const
return MCJES calibration factor
ToolHandle< JetHelper::IVarTool > m_vartoolE
int getEtaBin(double eta_det) const
Jet_v1 Jet
Definition of the current "jet version".
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ 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

◆ getEmaxJES()

double EtaJESCalibStep::getEmaxJES ( const double Y) const
private

return Emax

Definition at line 302 of file EtaJESCalibStep.cxx.

303{
304 int binEta = getEtaBin(Y);
305 double emaxJES = m_energyFreezeJES[binEta];
306
307 return emaxJES;
308}
double m_energyFreezeJES[s_nEtaBins]
@ binEta
Definition BinningType.h:54

◆ getEtaBin()

int EtaJESCalibStep::getEtaBin ( double eta_det) const
private

Definition at line 320 of file EtaJESCalibStep.cxx.

321{
322 int bin = std::as_const(m_etaBinAxis)->FindBin(eta_det);
323 if (bin<=0) return 0;
324 if (bin>m_etaBinAxis->GetNbins()) return bin-2; // overflow
325 return bin-1;
326}

◆ getEtaCorr()

double EtaJESCalibStep::getEtaCorr ( double X,
double Y = 0 ) const
private

return Eta correction

Definition at line 288 of file EtaJESCalibStep.cxx.

289{
290 int binEta = getEtaBin(Y);
291 const double *factors = m_etaCorrFactors[binEta];
292
293 if ( X < m_minPt_EtaCorr*cosh(Y) )
294 X = m_minPt_EtaCorr*cosh(Y);
296
297 double eta_corr = getLogPolN(factors,X);
298
299 return -eta_corr;
300}
double m_etaCorrFactors[s_nEtaBins][s_nParMax]
Gaudi::Property< float > m_maxE_EtaCorr
double getLogPolN(const double *factors, double x) const
Gaudi::Property< float > m_minPt_EtaCorr

◆ getJES()

double EtaJESCalibStep::getJES ( const double X,
const double Y = 0,
const double Emax = -1 ) const
private

return MCJES calibration factor

Definition at line 223 of file EtaJESCalibStep.cxx.

224{
225
227 if ( X/cosh(Y) < m_minPt_JES ) { // WARNING !! Won't work if X is actually pT
228 double R = getLowPtJES(X,Y);
229 return 1.0/R;
230 }
231 }
232 else{
233 if(std::abs(Y) < m_etaSecondaryminPt_JES && X/cosh(Y) < m_minPt_JES){
234 double R = getLowPtJES(X,Y);
235 return 1.0/R;
236 }
237 if(std::abs(Y) >= m_etaSecondaryminPt_JES && X/cosh(Y) < m_secondaryminPt_JES){
238 double R = getLowPtJES(X,Y);
239 return 1.0/R;
240 }
241 }
242
243 double JES_R;
244 int binEta = getEtaBin(Y);
245 const double *factors = m_JESFactors[binEta];
246
247
248 double E = X;
249 if( m_freezeJESatHighE && (E>Emax) && (Emax!=-1)) {
250 E = Emax;
251 }
252
253 double R = 1.;
254
255 if(m_useSpline){
256 R = getSplineCorr(binEta, E);
257 return 1.0/R;
258 } else {
259 R = getLogPolN(factors,E);
260 }
261
262 JES_R = 1/R;
263
264 return JES_R;
265}
double getSplineCorr(const int etaBin, double E) const
Gaudi::Property< double > m_etaSecondaryminPt_JES
Starting eta for secondary minPt_JES (Default |eta|>=1.9) (Used only if UseSecondaryMinPtForETAJES is...
Gaudi::Property< float > m_minPt_JES
double m_JESFactors[s_nEtaBins][s_nParMax]
Gaudi::Property< float > m_secondaryminPt_JES
SecondaryminPt_JES (Default 7 GeV) (Used only if UseSecondaryMinPtForETAJES is true).
double getLowPtJES(double E_uncorr, double eta_det) const
deal with low pt jets
Gaudi::Property< bool > m_useSpline
Gaudi::Property< bool > m_useSecondaryminPt_JES
Allowing to use different minPt_JES depending on eta (only for extrapolation methon 1).
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)

◆ getKey()

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

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

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

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

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

Definition at line 119 of file AsgTool.cxx.

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

◆ getLogPolN()

double EtaJESCalibStep::getLogPolN ( const double * factors,
double x ) const
private

Definition at line 310 of file EtaJESCalibStep.cxx.

311{
312 double y=0;
313 for ( uint i=0; i<m_nPar; ++i )
314 y += factors[i]*TMath::Power(log(x),Int_t(i));
315 return y;
316}
unsigned int uint
#define y
#define x
unsigned int m_nPar

◆ getLogPolNSlope()

double EtaJESCalibStep::getLogPolNSlope ( const double * factors,
double x ) const
private

Definition at line 328 of file EtaJESCalibStep.cxx.

328 {
329 double y=0;
330 const double inv_x = 1. / x;
331 for ( uint i=0; i<m_nPar; ++i )
332 y += i*factors[i]*TMath::Power(log(x),Int_t(i-1))*inv_x;
333 return y;
334}

◆ getLowPtJES()

double EtaJESCalibStep::getLowPtJES ( double E_uncorr,
double eta_det ) const
private

deal with low pt jets

Definition at line 268 of file EtaJESCalibStep.cxx.

268 {
269 int ieta = getEtaBin(eta_det);
270 double R=1;
271 // This correspond to m_lowPtExtrap == 0 in the old EtaJESCorrection tool. Not supporting other cases yet.
272 if (m_lowPtExtrap == 0) {
273 const double *factors = m_JESFactors[ieta];
274 double E = m_minPt_JES*cosh(eta_det);
275 R= getLogPolN(factors,E);
276 } else if (m_lowPtExtrap == 1) {
277 double Ecutoff = m_JES_MinPt_E[ieta];
278 double Rcutoff = m_JES_MinPt_R[ieta];
279 double slope = m_JES_MinPt_Slopes[ieta];
280 R = slope*(E_uncorr-Ecutoff)+Rcutoff;
281 }
282 else ATH_MSG_WARNING("Incorrect specification of low Pt JES extrapolation, please check the value of the LowPtJESExtrapolationMethod config flag.");
283
284 return R;
285}
#define ATH_MSG_WARNING(x)
double m_JES_MinPt_Slopes[s_nEtaBins]
double m_JES_MinPt_R[s_nEtaBins]
double m_JES_MinPt_E[s_nEtaBins]
Gaudi::Property< int > m_lowPtExtrap

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

◆ getNominalResolutionData()

virtual StatusCode IJetCalibStep::getNominalResolutionData ( const xAOD::Jet & ,
const JetHelper::JetContext & ,
double &  ) const
inlinevirtualinherited

Reimplemented in SmearingCalibStep.

Definition at line 38 of file IJetCalibStep.h.

38{ return StatusCode::FAILURE; }

◆ getNominalResolutionMC()

virtual StatusCode IJetCalibStep::getNominalResolutionMC ( const xAOD::Jet & ,
const JetHelper::JetContext & ,
double &  ) const
inlinevirtualinherited

Reimplemented in SmearingCalibStep.

Definition at line 39 of file IJetCalibStep.h.

39{ return StatusCode::FAILURE; }

◆ getProperty()

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

Get one of the tool's properties.

◆ getSplineCorr()

double EtaJESCalibStep::getSplineCorr ( const int etaBin,
double E ) const
private

Definition at line 370 of file EtaJESCalibStep.cxx.

370 {
371 double R = m_etajesFactors[ etaBin ]->Interpolate(E);
372 return R;
373}
std::vector< std::unique_ptr< TH1 > > m_etajesFactors
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin

◆ getSplineSlope()

double EtaJESCalibStep::getSplineSlope ( const int ieta,
const double minE ) const
private

Definition at line 357 of file EtaJESCalibStep.cxx.

357 {
358 // Don't want to use interpolation here, so instead just use the values at the bin centers near the cutoff
359 int minBin = m_etajesFactors[ieta]->FindBin(minE);
360
361 double rFirst = m_etajesFactors[ ieta ]->GetBinContent(minBin);
362 double rSecond = m_etajesFactors[ ieta ]->GetBinContent(minBin+1);
363 double binWidth = m_etajesFactors[ ieta ]->GetBinCenter(minBin+1) - m_etajesFactors[ ieta ]->GetBinCenter(minBin);
364 double slope = (rSecond - rFirst) / binWidth;
365
366 return slope;
367}
void binWidth(TH1 *h)
Definition listroot.cxx:80

◆ initialize()

StatusCode EtaJESCalibStep::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 22 of file EtaJESCalibStep.cxx.

22 {
23 ATH_MSG_DEBUG ("Initializing " << name() << " Use spline="<<m_useSpline);
24
25 ATH_MSG_DEBUG("Reading from " << m_jetInScale << " and writing to " << m_jetOutScale);
26
27 if(! m_useSpline){
28 if(!readMCJESFromText()) {
29 ATH_MSG_ERROR("Problem when reading constant file : "<< m_constantFileName);
30 return StatusCode::FAILURE;
31 }
32 } else { // use spline
33 if(!readMCJESFromHists()) {
34 ATH_MSG_ERROR("Problem when reading constant file : "<< m_histoFileName);
35 return StatusCode::FAILURE;
36 }
37 }
38
39 ATH_CHECK( m_vartoolE.retrieve() );
40 ATH_CHECK( m_vartoolEta.retrieve() );
41
42 return StatusCode::SUCCESS;
43}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
Gaudi::Property< std::string > m_histoFileName
Gaudi::Property< std::string > m_constantFileName
name of the text file

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

◆ loadSplineHists()

void EtaJESCalibStep::loadSplineHists ( const std::string & fileName,
const std::string & etajes_name )
private

Definition at line 337 of file EtaJESCalibStep.cxx.

338{
339 std::unique_ptr<TFile> tmpF(TFile::Open( fileName.c_str() ));
340 TList *etajes_l = static_cast<TList*>( tmpF->Get(etajes_name.c_str()));
341
342 m_etajesFactors.resize( etajes_l->GetSize() );
343 if(etajes_l->GetSize() != m_etaBinAxis->GetNbins()+1){
344 ATH_MSG_WARNING("Do not have the correct number of eta bins for " << fileName << "\t" << etajes_name << "\t" << etajes_l->GetSize() );
345 }
346
347 for(int i=0 ; i<m_etaBinAxis->GetNbins(); i++){
348 auto *pTH1 = dynamic_cast<TH1*>(etajes_l->At(i));
349 if (not pTH1) continue;
350 m_etajesFactors[i].reset(pTH1);
351 m_etajesFactors[i]->SetDirectory(nullptr);
352 }
353 tmpF->Close();
354}

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg_level_name()

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

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

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

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

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

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

Definition at line 101 of file AsgTool.cxx.

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

◆ msgLvl()

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

Definition at line 30 of file AthCommonMsg.h.

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

◆ outputHandles()

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

Return this algorithm's output handles.

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

◆ print()

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

◆ readMCJESFromHists()

bool EtaJESCalibStep::readMCJESFromHists ( )
private

Definition at line 161 of file EtaJESCalibStep.cxx.

162{
163 // Open the input file
164 std::string local_path=static_cast<std::string> (m_constantFileName);
166
167 TEnv config(fileName.c_str());
168 if(fileName=="") return false;
169
170 std::string jetAlgo=static_cast<std::string> (m_jetAlgo);
171
172 std::vector<double> etaBins = static_cast<std::vector<double>> (m_etaBins);
173 if (etaBins.size()==0){ // default binning
174 for (int i=0;i<=90; i++)
175 etaBins.push_back(0.1*i-4.5);
176 }
177
178 ATH_MSG_DEBUG("Number eta bins: " << etaBins.size());
179
180 m_etaBinAxis = new TAxis(etaBins.size()-1,&etaBins[0]);// this is to search for eta bin
181
182 std::string calibHistFile = PathResolverFindCalibFile(m_histoFileName);
183 loadSplineHists(calibHistFile, "etaJes");
184
185 //Protections for high order extrapolation methods at low Et (Et < _minPt_JES)
186 if(m_lowPtExtrap != 1) {
187 ATH_MSG_ERROR("Only linear extrapolations are supported for p-splines currently. Please change the config file to reflect this");
188 return false;
189 }
190
191 for (uint ieta=0;ieta<etaBins.size()-1;++ieta) {
192 //Calculate the slope of the response curve at the minPt for each eta bin
193 //Used in the GetLowPtJES method when Pt < minPt
194 double Ecutoff= m_minPt_JES*cosh(etaBins[ieta]);
195 if(m_useSecondaryminPt_JES && std::abs(etaBins[ieta]) >= m_etaSecondaryminPt_JES) Ecutoff = m_secondaryminPt_JES*cosh(etaBins[ieta]);
196 const double Rcutoff = getSplineCorr(ieta, Ecutoff);
197 const double Slope = getSplineSlope(ieta, Ecutoff);
198 if(Slope > Rcutoff/Ecutoff) ATH_MSG_WARNING("Slope of calibration curve at minimum ET is too steep for the JES factors of etabin " << ieta << ", eta = " << etaBins[ieta] );
199
200 m_JES_MinPt_E[ieta] = Ecutoff;
201 m_JES_MinPt_R[ieta] = Rcutoff;
202 m_JES_MinPt_Slopes[ieta] = Slope;
203
204 TString key=Form("EtaCorr.%s_Bin%d",jetAlgo.c_str(),ieta);
205 ATH_MSG_VERBOSE("reading: " << key << " = "<< config.GetValue(key,""));
206 std::vector<double> params = VectorizeD(config.GetValue(key,"")," ");
207 m_nPar = params.size();
208 ATH_MSG_VERBOSE("Number of parameters: " << m_nPar);
209 for (uint ipar=0;ipar<m_nPar;++ipar) m_etaCorrFactors[ieta][ipar] = params[ipar];
210
212 key=Form("EmaxJES.%s_Bin%d",jetAlgo.c_str(),ieta);
213 ATH_MSG_VERBOSE("reading: " << key << " = "<< config.GetValue(key,""));
214 params = VectorizeD(config.GetValue(key,"")," ");
215 m_energyFreezeJES[ieta] = params[0];
216 }
217
218 }
219 return true;
220}
#define ATH_MSG_VERBOSE(x)
VecD VectorizeD(const TString &str, const TString &sep=" ")
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Gaudi::Property< std::vector< double > > m_etaBins
Eta bins if other than 0.1 steps from -4.5 to 4.5.
Gaudi::Property< std::string > m_jetAlgo
jet collection to be calibrated
double getSplineSlope(const int ieta, const double minE) const
void loadSplineHists(const std::string &fileName, const std::string &etajes_name)

◆ readMCJESFromText()

bool EtaJESCalibStep::readMCJESFromText ( )
private

Definition at line 91 of file EtaJESCalibStep.cxx.

92{
93 // Open the input file
94 std::string local_path=static_cast<std::string> (m_constantFileName);
96 if(fileName=="") return false;
97
98 TEnv config(fileName.c_str());
99
100 std::string jetAlgo=static_cast<std::string> (m_jetAlgo);
101
102 std::vector<double> etaBins = static_cast<std::vector<double>> (m_etaBins);
103 if (etaBins.size()==0){ // default binning
104 for (int i=0;i<=90; i++)
105 etaBins.push_back(0.1*i-4.5);
106 }
107
108 ATH_MSG_DEBUG("Number eta bins: " << etaBins.size());
109
110 m_etaBinAxis = new TAxis(etaBins.size()-1,&etaBins[0]);// this is to search for eta bin
111
112 for (uint ieta=0; ieta<etaBins.size()-1; ++ieta)
113 {
114 TString key=Form("JES.%s_Bin%d",jetAlgo.c_str(),ieta);
115 ATH_MSG_VERBOSE("reading: " << key << " = "<< config.GetValue(key,""));
116 std::vector<double> params = VectorizeD(config.GetValue(key,"")," ");
117 m_nPar = params.size();
118 ATH_MSG_VERBOSE("Number of parameters: " << m_nPar);
119 for (uint ipar=0;ipar<m_nPar;++ipar) m_JESFactors[ieta][ipar] = params[ipar];
120 if(m_lowPtExtrap > 0) {
121 //Calculate the slope of the response curve at the minPt for each eta bin
122 //Used in the GetLowPtJES method when Pt < minPt
123 const double *factors = m_JESFactors[ieta];
124 double Ecutoff = m_minPt_JES*cosh(etaBins[ieta]);
125 if(m_useSecondaryminPt_JES && std::abs(etaBins[ieta]) >= m_etaSecondaryminPt_JES) Ecutoff = m_secondaryminPt_JES*cosh(etaBins[ieta]);
126 const double Rcutoff = getLogPolN(factors,Ecutoff);
127 const double Slope = getLogPolNSlope(factors,Ecutoff);
128 if(Slope > Rcutoff/Ecutoff) ATH_MSG_FATAL("Slope of calibration curve at minimum ET is too steep for the JES factors of etabin " << ieta << ", eta = " << etaBins[ieta] );
129
130 m_JES_MinPt_E[ieta] = Ecutoff;
131 m_JES_MinPt_R[ieta] = Rcutoff;
132 m_JES_MinPt_Slopes[ieta] = Slope;
133
134 //Calculate the parameters for a 2nd order polynomial extension to the calibration curve below minimum ET
135 //Used in the GetLowPtJES method when Pt < minPt
136 if(m_lowPtExtrap == 2) {
137 ATH_MSG_ERROR("LowPtJESExtrapolationMethod==2 not supported yet");
138 return false;
139 }
140 }
141
142 key=Form("EtaCorr.%s_Bin%d",jetAlgo.c_str(),ieta);
143 ATH_MSG_VERBOSE("reading: " << key << " = "<< config.GetValue(key,""));
144 params = VectorizeD(config.GetValue(key,"")," ");
145 m_nPar = params.size();
146 ATH_MSG_VERBOSE("Number of parameters: " << m_nPar);
147 for (uint ipar=0;ipar<m_nPar;++ipar) m_etaCorrFactors[ieta][ipar] = params[ipar];
148
150 key=Form("EmaxJES.%s_Bin%d",jetAlgo.c_str(),ieta);
151 ATH_MSG_VERBOSE("reading: " << key << " = "<< config.GetValue(key,""));
152 params = VectorizeD(config.GetValue(key,"")," ");
153 m_energyFreezeJES[ieta] = params[0];
154 }
155 }
156 return true;
157}
#define ATH_MSG_FATAL(x)
double getLogPolNSlope(const double *factors, double x) const

◆ renounce()

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

Definition at line 380 of file AthCommonDataStore.h.

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

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

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

Perform system initialization for an algorithm.

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

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

◆ sysStart()

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

Handle START transition.

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

◆ updateVHKA()

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

Definition at line 308 of file AthCommonDataStore.h.

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

Member Data Documentation

◆ m_constantFileName

Gaudi::Property< std::string > EtaJESCalibStep::m_constantFileName { this, "CalibConstantFile", "", "text file containing constants" }
private

name of the text file

Definition at line 68 of file EtaJESCalibStep.h.

68{ this, "CalibConstantFile", "", "text file containing constants" };

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_energyFreezeJES

double EtaJESCalibStep::m_energyFreezeJES[s_nEtaBins] {}
private

Definition at line 102 of file EtaJESCalibStep.h.

102{};

◆ m_etaBinAxis

TAxis* EtaJESCalibStep::m_etaBinAxis {}
private

Definition at line 108 of file EtaJESCalibStep.h.

108{};

◆ m_etaBins

Gaudi::Property<std::vector<double> > EtaJESCalibStep::m_etaBins {this, "EtaBins", {} ,""}
private

Eta bins if other than 0.1 steps from -4.5 to 4.5.

Definition at line 90 of file EtaJESCalibStep.h.

90{this, "EtaBins", {} ,""};

◆ m_etaCorrFactors

double EtaJESCalibStep::m_etaCorrFactors[s_nEtaBins][s_nParMax] {}
private

Definition at line 101 of file EtaJESCalibStep.h.

101{};

◆ m_etajesFactors

std::vector<std::unique_ptr<TH1> > EtaJESCalibStep::m_etajesFactors
private

Definition at line 110 of file EtaJESCalibStep.h.

◆ m_etaSecondaryminPt_JES

Gaudi::Property< double > EtaJESCalibStep::m_etaSecondaryminPt_JES = {this, "EtaSecondaryMinPtForETAJES", 1.9, "eta value for second min pT cut"}
private

Starting eta for secondary minPt_JES (Default |eta|>=1.9) (Used only if UseSecondaryMinPtForETAJES is true).

Definition at line 79 of file EtaJESCalibStep.h.

79{this, "EtaSecondaryMinPtForETAJES", 1.9, "eta value for second min pT cut"};

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_freezeJESatHighE

Gaudi::Property< bool > EtaJESCalibStep::m_freezeJESatHighE = {this, "FreezeJEScorrectionatHighE",false, " freeze at high e"}
private

Definition at line 71 of file EtaJESCalibStep.h.

71{this, "FreezeJEScorrectionatHighE",false, " freeze at high e"};

◆ m_histoFileName

Gaudi::Property< std::string > EtaJESCalibStep::m_histoFileName { this, "HistoFile", "none", "root file containing histos for spline calib" }
private

Definition at line 86 of file EtaJESCalibStep.h.

86{ this, "HistoFile", "none", "root file containing histos for spline calib" };

◆ m_JES_MinPt_E

double EtaJESCalibStep::m_JES_MinPt_E[s_nEtaBins] ={}
private

Definition at line 104 of file EtaJESCalibStep.h.

◆ m_JES_MinPt_R

double EtaJESCalibStep::m_JES_MinPt_R[s_nEtaBins] ={}
private

Definition at line 105 of file EtaJESCalibStep.h.

◆ m_JES_MinPt_Slopes

double EtaJESCalibStep::m_JES_MinPt_Slopes[s_nEtaBins] ={}
private

Definition at line 103 of file EtaJESCalibStep.h.

◆ m_JESFactors

double EtaJESCalibStep::m_JESFactors[s_nEtaBins][s_nParMax] {}
private

Definition at line 100 of file EtaJESCalibStep.h.

100{};

◆ m_jetAlgo

Gaudi::Property< std::string > EtaJESCalibStep::m_jetAlgo { this, "JetAlgo", "AntiKt4EMPFlow", "jet collection" }
private

jet collection to be calibrated

Definition at line 70 of file EtaJESCalibStep.h.

70{ this, "JetAlgo", "AntiKt4EMPFlow", "jet collection" };

◆ m_jetInScale

Gaudi::Property<std::string> EtaJESCalibStep::m_jetInScale {this, "InScale", "JetPileupScaleMomentum", "Starting jet scale"}
private

Definition at line 64 of file EtaJESCalibStep.h.

64{this, "InScale", "JetPileupScaleMomentum", "Starting jet scale"};

◆ m_jetOutScale

Gaudi::Property<std::string> EtaJESCalibStep::m_jetOutScale {this, "OutScale", "JetEtaJESScaleMomentum", "Ending jet scale"}
private

Definition at line 65 of file EtaJESCalibStep.h.

65{this, "OutScale", "JetEtaJESScaleMomentum", "Ending jet scale"};

◆ m_lowPtExtrap

Gaudi::Property< int > EtaJESCalibStep::m_lowPtExtrap = {this, "LowPtJESExtrapolationMethod", 0, " low pt etrap"}
private

Definition at line 72 of file EtaJESCalibStep.h.

72{this, "LowPtJESExtrapolationMethod", 0, " low pt etrap"};

◆ m_lowPtMinR

Gaudi::Property< float > EtaJESCalibStep::m_lowPtMinR = {this, "LowPtJESExtrapolationMinimumResponse", 0.25, " low pt etrap min"}
private

Definition at line 73 of file EtaJESCalibStep.h.

73{this, "LowPtJESExtrapolationMinimumResponse", 0.25, " low pt etrap min"};

◆ m_maxE_EtaCorr

Gaudi::Property< float > EtaJESCalibStep::m_maxE_EtaCorr = {this, "MaxEForEtaCorr" ,2500. , ""}
private

Definition at line 84 of file EtaJESCalibStep.h.

84{this, "MaxEForEtaCorr" ,2500. , ""};

◆ m_minPt_EtaCorr

Gaudi::Property< float > EtaJESCalibStep::m_minPt_EtaCorr = {this, "MinPtForEtaCorr" ,8. , ""}
private

Definition at line 83 of file EtaJESCalibStep.h.

83{this, "MinPtForEtaCorr" ,8. , ""};

◆ m_minPt_JES

Gaudi::Property< float > EtaJESCalibStep::m_minPt_JES = {this, "MinPtForETAJES",15, "min pT"}
private

Definition at line 75 of file EtaJESCalibStep.h.

75{this, "MinPtForETAJES",15, "min pT"};

◆ m_nPar

unsigned int EtaJESCalibStep::m_nPar {}
private

Definition at line 97 of file EtaJESCalibStep.h.

97{}; // number of parameters in config file

◆ m_secondaryminPt_JES

Gaudi::Property< float > EtaJESCalibStep::m_secondaryminPt_JES = {this, "SecondaryMinPtForETAJES", 7.0, "pt value for second min pT cut"}
private

SecondaryminPt_JES (Default 7 GeV) (Used only if UseSecondaryMinPtForETAJES is true).

Definition at line 81 of file EtaJESCalibStep.h.

81{this, "SecondaryMinPtForETAJES", 7.0, "pt value for second min pT cut"};

◆ m_useSecondaryminPt_JES

Gaudi::Property< bool > EtaJESCalibStep::m_useSecondaryminPt_JES = {this, "UseSecondaryMinPtForETAJES", false, "min pT dependent on eta?"}
private

Allowing to use different minPt_JES depending on eta (only for extrapolation methon 1).

Definition at line 77 of file EtaJESCalibStep.h.

77{this, "UseSecondaryMinPtForETAJES", false, "min pT dependent on eta?"};

◆ m_useSpline

Gaudi::Property< bool > EtaJESCalibStep::m_useSpline = {this, "UseSpline",false, " use spline"}
private

Definition at line 87 of file EtaJESCalibStep.h.

87{this, "UseSpline",false, " use spline"};

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vartoolE

ToolHandle<JetHelper::IVarTool> EtaJESCalibStep::m_vartoolE {this, "VarToolE", "VarTool", "InputVariable instance E (or pT?)" }
private

Definition at line 92 of file EtaJESCalibStep.h.

92{this, "VarToolE", "VarTool", "InputVariable instance E (or pT?)" };

◆ m_vartoolEta

ToolHandle<JetHelper::IVarTool> EtaJESCalibStep::m_vartoolEta {this, "VarToolEta", "VarTool", "InputVariable instance eta (or rapididty?)" }
private

interface for xAOD::jet variable to be defined by user, this must correspond to jet Eta in currect version of jet calibration files

Definition at line 94 of file EtaJESCalibStep.h.

94{this, "VarToolEta", "VarTool", "InputVariable instance eta (or rapididty?)" };

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ s_nEtaBins

const unsigned int EtaJESCalibStep::s_nEtaBins = 90
staticprivate

Definition at line 98 of file EtaJESCalibStep.h.

◆ s_nParMax

const unsigned int EtaJESCalibStep::s_nParMax = 9
staticprivate

Definition at line 99 of file EtaJESCalibStep.h.


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