ATLAS Offline Software
FFJetSmearingTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #ifndef FFJETSMEARINGTOOL_FFJETSMEARINGTOOL_H
7 #define FFJETSMEARINGTOOL_FFJETSMEARINGTOOL_H
8 
9 
10 // Framework includes
11 #include "AsgTools/AsgTool.h"
12 #include "AsgTools/ToolHandle.h"
14 
15 
16 //includes for systematics ATLAS structure
17 #include "PATInterfaces/SystematicsTool.h"//To set the systematics as it is done in JetJvtEfficiency
18 
22 
23 
24 //xAOD EDM classes
25 #include "xAODJet/JetContainer.h"
26 
27 
28 // Other packages includes
30 
31 // Local includes
34 
35 
36 // Other includes
37 #include <TFile.h>
38 #include <TH2.h>
39 #include <TH3.h>
40 #include "TEnv.h"
41 
42 #include <memory> //to use make_unique
43 #include <string>
44 #include <map>
45 
55 
56 
57 
58 namespace JetTools{
60  {
61  Calo,
62  TA,
63  Comb,
64  };
66  {
67  if (name.EqualTo("Calo",TString::kIgnoreCase)){
69  return StatusCode::SUCCESS;
70  }
71  if (name.EqualTo("TA",TString::kIgnoreCase)){
73  return StatusCode::SUCCESS;
74  }
75  if (name.EqualTo("Comb",TString::kIgnoreCase)){
77  return StatusCode::SUCCESS;
78  }
79  return StatusCode::FAILURE;
80  }
82  {
83  switch (type)
84  {
85  case FFJetAllowedMassDefEnum::Calo: return "Calo";
86  case FFJetAllowedMassDefEnum::TA: return "TA";
87  case FFJetAllowedMassDefEnum::Comb: return "Comb";
88  default: return "";
89  }
90  }
91 
92 }
93 
94 namespace CP {
95  class FFJetSmearingTool : public asg::AsgTool, virtual public ICPJetCorrectionTool
96  {
97 
100 
101  public:
102  // Constructor/destructor/init
103  FFJetSmearingTool(const std::string& name);
104  virtual ~FFJetSmearingTool();
105 
106  virtual StatusCode initialize() override;
107 
108 
109 
110  //New systematic functions
113 
115  virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const override;
116 
118  virtual CP::SystematicSet affectingSystematics() const override;
119 
121  virtual CP::SystematicSet recommendedSystematics() const override;
122 
125  (const CP::SystematicSet& systematics) override;
126 
128 
129 
130  virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet_reco) const override;// The user has to use this function to smear it's jet mass
131  virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const override;
133 
134  StatusCode getMatchedTruthJet( xAOD::Jet& jet_reco, xAOD::Jet& jet_truth_matched) const;
135 
136  private:
137 
138 
140 
141  StatusCode getJMSJMR( xAOD::Jet& jet_reco, double jet_mass, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst ,const std::string& jetTopology, double& JMS_err, double& JMR_err) const;
142 
143  StatusCode getJetTopology( xAOD::Jet& jet_reco, std::string& jetTopology) const;
144 
145  double Read3DHistogram(const TH3* histo, double x, double y, double z) const;
146  double Interpolate2D(const TH2* histo, double x, double y) const;
147 
148 
149  // Private members
150  bool m_isInit{};
151  std::string m_release;
152  std::string m_truth_jetColl;
153  std::string m_truthlabelaccessor;
154  float m_EtaRange{};
155  float m_MaxMass{};
156  float m_MaxPt{};
157  std::string m_calibArea;
158  std::string m_histFileName;
159  std::string m_MassDef_string;
161  std::string m_configFile;
162  std::string m_path;
163  std::string m_HistogramsFilePath;
164 
165  //Response matrix
166  std::unique_ptr<TH2> m_CALO_ResponseMap;
167  std::unique_ptr<TH2> m_TA_ResponseMap;
168 
169  //Two histograms to extract the Calo and TA weights in the Combined mass of the jet
170  std::unique_ptr<TH3F> m_caloMassWeight;
171  std::unique_ptr<TH3F> m_TAMassWeight;
172 
173 
174  //The list of systemaics
176 
177  //Maps that relates the systematic name with some of its caracteristics
178  std::map<std::string,std::string> m_Syst_MassDefAffected_map;
179  std::map<std::string,std::string> m_Syst_TopologyAffected_map;
180  std::map<std::string,std::string> m_Syst_HistPath_map;
181  std::map<std::string,std::unique_ptr<TH2>> m_Syst_Hist_map;
182  std::map<std::string,std::string> m_Syst_HistTAPath_map;
183  std::map<std::string,std::unique_ptr<TH2>> m_Syst_HistTA_map;
184  std::map<std::string,std::string> m_Syst_Affects_JMSorJMR;
185 
186  //The current systematic configuration
187  struct SysData final
188  {
189  std::string SysBaseName {"None"};
190  float SysParameter {0};
191  };
192  std::unordered_map<CP::SystematicSet,SysData> m_sysData;
195 
196  static constexpr float m_MeVtoGeV = 1.e-3;
197 
198  }; // Class FFJetSmearingTool
199 
200 } // namespace CP
201 
202 #endif
CP::FFJetSmearingTool::m_path
std::string m_path
Definition: FFJetSmearingTool.h:162
CP::FFJetSmearingTool::applyContainerCorrection
virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer &inputs) const override
Definition: FFJetSmearingTool.cxx:836
CorrectionTool.h
CP::FFJetSmearingTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: FFJetSmearingTool.cxx:49
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
JetTools::FFJetAllowedMassDefEnum
FFJetAllowedMassDefEnum
Definition: FFJetSmearingTool.h:60
CP::FFJetSmearingTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
List of all systematics affecting this tool.
Definition: FFJetSmearingTool.cxx:181
CP::FFJetSmearingTool::SysData
Definition: FFJetSmearingTool.h:188
get_generator_info.result
result
Definition: get_generator_info.py:21
CP::FFJetSmearingTool::m_Syst_Hist_map
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_Hist_map
Definition: FFJetSmearingTool.h:181
CP::FFJetSmearingTool::m_SysList
CP::SystematicSet m_SysList
Definition: FFJetSmearingTool.h:175
CP::FFJetSmearingTool::SysData::SysBaseName
std::string SysBaseName
Definition: FFJetSmearingTool.h:189
CP::FFJetSmearingTool::m_Syst_HistTAPath_map
std::map< std::string, std::string > m_Syst_HistTAPath_map
Definition: FFJetSmearingTool.h:182
CP::FFJetSmearingTool::m_sysData
std::unordered_map< CP::SystematicSet, SysData > m_sysData
Definition: FFJetSmearingTool.h:192
CP::FFJetSmearingTool::m_isInit
bool m_isInit
Definition: FFJetSmearingTool.h:150
CP::FFJetSmearingTool::m_CALO_ResponseMap
std::unique_ptr< TH2 > m_CALO_ResponseMap
Definition: FFJetSmearingTool.h:166
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
JetTools::enumToString
TString enumToString(const FFJetAllowedMassDefEnum type)
Definition: FFJetSmearingTool.h:81
CP::FFJetSmearingTool::m_histFileName
std::string m_histFileName
Definition: FFJetSmearingTool.h:158
CP::FFJetSmearingTool::m_Syst_HistPath_map
std::map< std::string, std::string > m_Syst_HistPath_map
Definition: FFJetSmearingTool.h:180
CP::FFJetSmearingTool::applyCorrection
virtual CP::CorrectionCode applyCorrection(xAOD::Jet &jet_reco) const override
Apply a systematic variation of get a new copy.
Definition: FFJetSmearingTool.cxx:587
CP::FFJetSmearingTool::m_currentSysData
SysData * m_currentSysData
Points to the current systematic configuration.
Definition: FFJetSmearingTool.h:194
CP::SystematicVariation
Definition: SystematicVariation.h:47
CP::FFJetSmearingTool::readFFJetSmearingToolSimplifiedData
StatusCode readFFJetSmearingToolSimplifiedData(TEnv &settings)
Definition: FFJetSmearingTool.cxx:276
JetHelpers.h
x
#define x
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::FFJetSmearingTool::m_truth_jetColl
std::string m_truth_jetColl
Definition: FFJetSmearingTool.h:152
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
Helpers.h
CP::FFJetSmearingTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
Specify whether tool is affected by provided systematic.
Definition: FFJetSmearingTool.cxx:172
CP::FFJetSmearingTool::m_MaxPt
float m_MaxPt
Definition: FFJetSmearingTool.h:156
CP::FFJetSmearingTool::~FFJetSmearingTool
virtual ~FFJetSmearingTool()
CP::FFJetSmearingTool::m_Syst_MassDefAffected_map
std::map< std::string, std::string > m_Syst_MassDefAffected_map
Definition: FFJetSmearingTool.h:178
CP::FFJetSmearingTool::m_MeVtoGeV
static constexpr float m_MeVtoGeV
Definition: FFJetSmearingTool.h:196
z
#define z
SystematicRegistry.h
CP::FFJetSmearingTool::m_MassDef_string
std::string m_MassDef_string
Definition: FFJetSmearingTool.h:159
CP::FFJetSmearingTool::m_HistogramsFilePath
std::string m_HistogramsFilePath
Definition: FFJetSmearingTool.h:163
CP::FFJetSmearingTool::getMatchedTruthJet
StatusCode getMatchedTruthJet(xAOD::Jet &jet_reco, xAOD::Jet &jet_truth_matched) const
Definition: FFJetSmearingTool.cxx:425
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ICPJetCorrectionTool
class ICPJetCorrectionTool
Definition: ICPJetCorrectionTool.h:28
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TH3
Definition: rootspy.cxx:440
CP::FFJetSmearingTool::Interpolate2D
double Interpolate2D(const TH2 *histo, double x, double y) const
Definition: FFJetSmearingTool.cxx:889
CP::FFJetSmearingTool::m_Syst_TopologyAffected_map
std::map< std::string, std::string > m_Syst_TopologyAffected_map
Definition: FFJetSmearingTool.h:179
CP::FFJetSmearingTool::correctedCopy
virtual CP::CorrectionCode correctedCopy(const xAOD::Jet &input, xAOD::Jet *&output) const override
Definition: FFJetSmearingTool.cxx:820
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TH2
Definition: rootspy.cxx:373
CP::FFJetSmearingTool::m_EtaRange
float m_EtaRange
Definition: FFJetSmearingTool.h:154
CP::FFJetSmearingTool::m_truthlabelaccessor
std::string m_truthlabelaccessor
Definition: FFJetSmearingTool.h:153
SystematicsTool.h
CP::FFJetSmearingTool::m_Syst_HistTA_map
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_HistTA_map
Definition: FFJetSmearingTool.h:183
StatusCode.h
JetTools::FFJetAllowedMassDefEnum::Calo
@ Calo
merge.output
output
Definition: merge.py:17
CP::FFJetSmearingTool::m_MaxMass
float m_MaxMass
Definition: FFJetSmearingTool.h:155
ICPJetCorrectionTool.h
CheckAppliedSFs.systematics
def systematics
Definition: CheckAppliedSFs.py:231
JetTools::FFJetAllowedMassDefEnum::TA
@ TA
Calorimeter.
CP::FFJetSmearingTool::getJetTopology
StatusCode getJetTopology(xAOD::Jet &jet_reco, std::string &jetTopology) const
Definition: FFJetSmearingTool.cxx:458
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
JetTools::stringToEnum
StatusCode stringToEnum(const TString &name, FFJetAllowedMassDefEnum &result)
Definition: FFJetSmearingTool.h:65
CP::FFJetSmearingTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systematics) override
Configure tool to apply systematic variation.
Definition: FFJetSmearingTool.cxx:224
CP::FFJetSmearingTool::m_release
std::string m_release
Definition: FFJetSmearingTool.h:151
CP::FFJetSmearingTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
List of all systematics recommended for this tool.
Definition: FFJetSmearingTool.cxx:189
CP::FFJetSmearingTool::m_Syst_Affects_JMSorJMR
std::map< std::string, std::string > m_Syst_Affects_JMSorJMR
Definition: FFJetSmearingTool.h:184
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::FFJetSmearingTool::m_configFile
std::string m_configFile
Definition: FFJetSmearingTool.h:161
CP::FFJetSmearingTool::FFJetSmearingTool
FFJetSmearingTool(const std::string &name)
Proper constructor for Athena.
Definition: FFJetSmearingTool.cxx:28
y
#define y
JetContainer.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ASG_TOOL_CLASS
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
Definition: AsgToolMacros.h:68
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::FFJetSmearingTool
Definition: FFJetSmearingTool.h:96
CP::FFJetSmearingTool::getJMSJMR
StatusCode getJMSJMR(xAOD::Jet &jet_reco, double jet_mass, JetTools::FFJetAllowedMassDefEnum MassDef_of_syst, const std::string &jetTopology, double &JMS_err, double &JMR_err) const
Definition: FFJetSmearingTool.cxx:510
CP::FFJetSmearingTool::m_TA_ResponseMap
std::unique_ptr< TH2 > m_TA_ResponseMap
Definition: FFJetSmearingTool.h:167
CP::FFJetSmearingTool::m_caloMassWeight
std::unique_ptr< TH3F > m_caloMassWeight
Definition: FFJetSmearingTool.h:170
JetTools
Implementation of the Forward Folding (FF) Jet smearing tool interface.
Definition: FFJetSmearingTool.h:58
ToolHandle.h
CP::FFJetSmearingTool::m_calibArea
std::string m_calibArea
Definition: FFJetSmearingTool.h:157
JetTools::FFJetAllowedMassDefEnum::Comb
@ Comb
Track Assisted.
AsgTool.h
CP::FFJetSmearingTool::SysData::SysParameter
float SysParameter
Definition: FFJetSmearingTool.h:190
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
CP::FFJetSmearingTool::Read3DHistogram
double Read3DHistogram(const TH3 *histo, double x, double y, double z) const
Definition: FFJetSmearingTool.cxx:856
CP::FFJetSmearingTool::m_MassDef
JetTools::FFJetAllowedMassDefEnum m_MassDef
Definition: FFJetSmearingTool.h:160
SystematicVariation.h
CP::FFJetSmearingTool::m_TAMassWeight
std::unique_ptr< TH3F > m_TAMassWeight
Definition: FFJetSmearingTool.h:171