ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
Jet
JetCalibTools
src
JMSCalibStep.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
JetCalibTools/JMSCalibStep.h
"
6
#include "
JetToolHelpers/HistoInputBase.h
"
7
8
JMSCalibStep::JMSCalibStep
(
const
std::string& name)
9
:
asg
::
AsgTool
( name ){ }
10
11
StatusCode
JMSCalibStep::initialize
() {
12
13
ATH_MSG_DEBUG
(
"Initializing the JMS Calibration tool"
);
14
15
ATH_MSG_DEBUG
(
"Reading from "
<<
m_jetInScale
<<
" and writing to "
<<
m_jetOutScale
);
16
17
ATH_CHECK
(
m_histTool
.retrieve());
18
19
// Determine the maximum value on the z-azis for which the calibration will be applied, this should be eta
20
JetHelper::HistoInputBase
* histoTool =
dynamic_cast<
JetHelper::HistoInputBase
*
>
( &(*m_histTool) );
21
if
(histoTool){
22
TH1 *
h
= &histoTool->
getHistogram
();
23
m_maxEta
=
h
->GetZaxis()->GetBinLowEdge(
h
->GetNbinsZ()+1);
24
}
25
else
{
26
ATH_MSG_ERROR
(
"Dynamic cast to JetHelper::HistoInputBase failed in JMSCalibStep!"
);
27
}
28
29
return
StatusCode::SUCCESS;
30
31
}
32
33
StatusCode
JMSCalibStep::calibrate
(
xAOD::JetContainer
& jets)
const
{
34
35
ATH_MSG_DEBUG
(
"Calibrating jet mass"
);
36
37
const
xAOD::JetAttributeAccessor::AccessorWrapper<xAOD::JetFourMom_t>
jmsScaleMomAcc(
m_jetOutScale
);
38
39
for
(
xAOD::Jet
*
jet
: jets){
40
41
const
xAOD::JetFourMom_t
jetStartP4 =
jet
->getAttribute<
xAOD::JetFourMom_t
>(
m_jetInScale
);
42
jet
->setJetP4(jetStartP4);
43
44
// Get the calibration factor (only for jets if the pT or energy is above threshold and eta within the histogram z-axis range)
45
double
massFactor = 1.0;
46
JetHelper::JetContext
jc;
47
if
(
m_varToolX
->getValue(*
jet
,jc) >=
m_minValue_JMS
){
48
if
(
m_varToolZ
->getValue(*
jet
,jc) <=
m_maxEta
){
49
massFactor =
m_histTool
->getValue(*
jet
, jc);
50
}
51
}
52
53
// Calculate the corrected mass
54
double
mass_corr = jetStartP4.mass();
55
56
if
(massFactor != 0){
57
mass_corr = jetStartP4.mass()/massFactor;
58
}
59
// Protection for very large masses
60
if
(mass_corr >
jet
->e()){
61
mass_corr =
jet
->m();
62
}
63
64
double
pT_corr = jetStartP4.pt();
65
// For small-R jet mass calibrations, keep the pT value fixed
66
if
(!
m_pTfixed
){
67
pT_corr = std::sqrt(jetStartP4.e()*jetStartP4.e()-mass_corr*mass_corr)/std::cosh( jetStartP4.eta() );
68
}
69
70
// Set the four-vector to the calibrated values
71
xAOD::JetFourMom_t
calibP4 =
xAOD::JetFourMom_t
(pT_corr, jetStartP4.eta(), jetStartP4.phi(), mass_corr);
72
jmsScaleMomAcc.
setAttribute
(*
jet
, calibP4);
73
jet
->setJetP4(calibP4);
74
}
75
76
return
StatusCode::SUCCESS;
77
78
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
HistoInputBase.h
JMSCalibStep.h
h
Header file for AthHistogramAlgorithm.
JMSCalibStep::m_varToolZ
ToolHandle< JetHelper::IVarTool > m_varToolZ
Variable used to enforce eta threshold.
Definition
JMSCalibStep.h:50
JMSCalibStep::m_histTool
ToolHandle< JetHelper::IVarTool > m_histTool
3D histogram containing mass calibration values
Definition
JMSCalibStep.h:46
JMSCalibStep::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition
JMSCalibStep.cxx:11
JMSCalibStep::m_jetInScale
Gaudi::Property< std::string > m_jetInScale
Definition
JMSCalibStep.h:38
JMSCalibStep::m_pTfixed
Gaudi::Property< bool > m_pTfixed
Definition
JMSCalibStep.h:43
JMSCalibStep::m_maxEta
float m_maxEta
Definition
JMSCalibStep.h:52
JMSCalibStep::m_jetOutScale
Gaudi::Property< std::string > m_jetOutScale
Definition
JMSCalibStep.h:39
JMSCalibStep::JMSCalibStep
JMSCalibStep(const std::string &name="JMSCalibStep")
Definition
JMSCalibStep.cxx:8
JMSCalibStep::m_varToolX
ToolHandle< JetHelper::IVarTool > m_varToolX
Variable used to enforce minimum pT or energy for calibration.
Definition
JMSCalibStep.h:48
JMSCalibStep::calibrate
virtual StatusCode calibrate(xAOD::JetContainer &) const override
Apply calibration to a jet container.
Definition
JMSCalibStep.cxx:33
JMSCalibStep::m_minValue_JMS
Gaudi::Property< float > m_minValue_JMS
Properties.
Definition
JMSCalibStep.h:42
JetHelper::HistoInputBase
Class HistoInputBase This class implement common function used by HistoInput1D and HistoInput2D.
Definition
HistoInputBase.h:25
JetHelper::HistoInputBase::getHistogram
TH1 & getHistogram()
Returns the underlying histogram.
Definition
HistoInputBase.h:38
JetHelper::JetContext
Class JetContext Designed to read AOD information related to the event, N vertices,...
Definition
JetContext.h:27
asg::AsgTool::AsgTool
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition
AsgTool.cxx:58
xAOD::JetAttributeAccessor::AccessorWrapper
Definition
JetAccessors.h:49
xAOD::JetAttributeAccessor::AccessorWrapper::setAttribute
void setAttribute(SG::AuxElement &p, const TYPE &v) const
Definition
JetAccessors.h:54
asg
Definition
DataHandleTestTool.h:28
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::JetContainer
JetContainer_v1 JetContainer
Definition of the current "jet container version".
Definition
JetContainer.h:17
xAOD::JetFourMom_t
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition
JetTypes.h:17
Generated on
for ATLAS Offline Software by
1.17.0