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  UFO,
65  };
67  {
68  if (name.EqualTo("Calo",TString::kIgnoreCase)){
70  return StatusCode::SUCCESS;
71  }
72  if (name.EqualTo("TA",TString::kIgnoreCase)){
74  return StatusCode::SUCCESS;
75  }
76  if (name.EqualTo("Comb",TString::kIgnoreCase)){
78  return StatusCode::SUCCESS;
79  }
80  if (name.EqualTo("UFO",TString::kIgnoreCase)){
82  return StatusCode::SUCCESS;
83  }
84  return StatusCode::FAILURE;
85  }
87  {
88  switch (type)
89  {
90  case FFJetAllowedMassDefEnum::Calo: return "Calo";
91  case FFJetAllowedMassDefEnum::TA: return "TA";
92  case FFJetAllowedMassDefEnum::Comb: return "Comb";
93  case FFJetAllowedMassDefEnum::UFO: return "UFO";
94  default: return "";
95  }
96  }
97 
98 }
99 
100 namespace CP {
101  class FFJetSmearingTool : public asg::AsgTool, virtual public ICPJetCorrectionTool
102  {
103 
106 
107  public:
108  // Constructor/destructor/init
109  FFJetSmearingTool(const std::string& name);
110  virtual ~FFJetSmearingTool();
111 
112  virtual StatusCode initialize() override;
113 
114 
115 
116  //New systematic functions
119 
121  virtual bool isAffectedBySystematic(const CP::SystematicVariation& systematic) const override;
122 
124  virtual CP::SystematicSet affectingSystematics() const override;
125 
127  virtual CP::SystematicSet recommendedSystematics() const override;
128 
131  (const CP::SystematicSet& systematics) override;
132 
134 
135 
136  virtual CP::CorrectionCode applyCorrection(xAOD::Jet& jet_reco) const override;// The user has to use this function to smear it's jet mass
137  virtual CP::CorrectionCode correctedCopy(const xAOD::Jet& input, xAOD::Jet*& output) const override;
139 
140  StatusCode getMatchedTruthJet( xAOD::Jet& jet_reco, xAOD::Jet& jet_truth_matched) const;
141 
142  private:
143 
144 
146 
147  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;
148 
149  StatusCode getJetTopology( xAOD::Jet& jet_reco, std::string& jetTopology) const;
150 
151  double Read3DHistogram(const TH3* histo, double x, double y, double z) const;
152  double Interpolate2D(const TH2* histo, double x, double y) const;
153 
154  void replaceAllOccurrences(std::string& str, const std::string& to_find, const std::string& to_replace);
155 
156  // Private members
157  bool m_isInit{};
158  std::string m_release;
159  std::string m_truth_jetColl;
160  std::string m_truthlabelaccessor;
161  std::string m_supportedmctypes;
162  float m_EtaRange{};
163  float m_MaxMass{};
164  float m_MaxPt{};
165  std::string m_calibArea;
166  std::string m_histFileName;
167  std::string m_MassDef_string;
168  std::string m_MCType_string;
170  std::string m_configFile;
171  std::string m_path;
172  std::string m_HistogramsFilePath;
173 
174  //Response matrix
176  std::unique_ptr<TH2> m_CALO_ResponseMap;
177  std::unique_ptr<TH2> m_TA_ResponseMap;
178  std::unique_ptr<TH2> m_UFO_ResponseMap;
179 
180  //Two histograms to extract the Calo and TA weights in the Combined mass of the jet
181  std::unique_ptr<TH3F> m_caloMassWeight;
182  std::unique_ptr<TH3F> m_TAMassWeight;
183 
184 
185  //The list of systemaics
187 
188  //Maps that relates the systematic name with some of its caracteristics
189  std::map<std::string,std::string> m_Syst_MassDefAffected_map;
190  std::map<std::string,std::string> m_Syst_TopologyAffected_map;
191  std::map<std::string,std::string> m_Syst_HistPath_map;
192  std::map<std::string,std::unique_ptr<TH2>> m_Syst_Hist_map;
193  std::map<std::string,std::unique_ptr<TH3F>> m_Syst_Hist_map3d;
194  std::map<std::string,std::string> m_Syst_HistTAPath_map;
195  std::map<std::string,std::unique_ptr<TH2>> m_Syst_HistTA_map;
196  std::map<std::string,std::unique_ptr<TH3F>> m_Syst_HistTA_map3d;
197  std::map<std::string,std::string> m_Syst_Affects_JMSorJMR;
198  std::map<std::string,std::string> m_Syst_uncertparam;
199 
200  //The current systematic configuration
201  struct SysData final
202  {
203  std::string SysBaseName {"None"};
204  float SysParameter {0};
205  };
206  std::unordered_map<CP::SystematicSet,SysData> m_sysData;
209 
210  static constexpr float m_MeVtoGeV = 1.e-3;
211 
212  }; // Class FFJetSmearingTool
213 
214 } // namespace CP
215 
216 #endif
CP::FFJetSmearingTool::m_path
std::string m_path
Definition: FFJetSmearingTool.h:171
CP::FFJetSmearingTool::applyContainerCorrection
virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer &inputs) const override
Definition: FFJetSmearingTool.cxx:937
CorrectionTool.h
CP::FFJetSmearingTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: FFJetSmearingTool.cxx:54
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:197
CP::FFJetSmearingTool::SysData
Definition: FFJetSmearingTool.h:202
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:192
CP::FFJetSmearingTool::m_SysList
CP::SystematicSet m_SysList
Definition: FFJetSmearingTool.h:186
CP::FFJetSmearingTool::SysData::SysBaseName
std::string SysBaseName
Definition: FFJetSmearingTool.h:203
CP::FFJetSmearingTool::m_Syst_HistTAPath_map
std::map< std::string, std::string > m_Syst_HistTAPath_map
Definition: FFJetSmearingTool.h:194
CP::FFJetSmearingTool::m_sysData
std::unordered_map< CP::SystematicSet, SysData > m_sysData
Definition: FFJetSmearingTool.h:206
CP::FFJetSmearingTool::m_Syst_Hist_map3d
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_Hist_map3d
Definition: FFJetSmearingTool.h:193
CP::FFJetSmearingTool::m_isInit
bool m_isInit
Definition: FFJetSmearingTool.h:157
CP::FFJetSmearingTool::m_CALO_ResponseMap
std::unique_ptr< TH2 > m_CALO_ResponseMap
Definition: FFJetSmearingTool.h:176
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
JetTools::enumToString
TString enumToString(const FFJetAllowedMassDefEnum type)
Definition: FFJetSmearingTool.h:86
CP::FFJetSmearingTool::m_histFileName
std::string m_histFileName
Definition: FFJetSmearingTool.h:166
CP::FFJetSmearingTool::m_Syst_HistPath_map
std::map< std::string, std::string > m_Syst_HistPath_map
Definition: FFJetSmearingTool.h:191
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:657
CP::FFJetSmearingTool::m_currentSysData
SysData * m_currentSysData
Points to the current systematic configuration.
Definition: FFJetSmearingTool.h:208
CP::SystematicVariation
Definition: SystematicVariation.h:47
CP::FFJetSmearingTool::readFFJetSmearingToolSimplifiedData
StatusCode readFFJetSmearingToolSimplifiedData(TEnv &settings)
Definition: FFJetSmearingTool.cxx:304
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:159
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
CP::FFJetSmearingTool::m_Syst_HistTA_map3d
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_HistTA_map3d
Definition: FFJetSmearingTool.h:196
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:188
CP::FFJetSmearingTool::m_MCType_string
std::string m_MCType_string
Definition: FFJetSmearingTool.h:168
CP::FFJetSmearingTool::m_MaxPt
float m_MaxPt
Definition: FFJetSmearingTool.h:164
CP::FFJetSmearingTool::~FFJetSmearingTool
virtual ~FFJetSmearingTool()
CP::FFJetSmearingTool::m_Syst_MassDefAffected_map
std::map< std::string, std::string > m_Syst_MassDefAffected_map
Definition: FFJetSmearingTool.h:189
CP::FFJetSmearingTool::m_MeVtoGeV
static constexpr float m_MeVtoGeV
Definition: FFJetSmearingTool.h:210
z
#define z
SystematicRegistry.h
CP::FFJetSmearingTool::m_MassDef_string
std::string m_MassDef_string
Definition: FFJetSmearingTool.h:167
CP::FFJetSmearingTool::m_HistogramsFilePath
std::string m_HistogramsFilePath
Definition: FFJetSmearingTool.h:172
CP::FFJetSmearingTool::getMatchedTruthJet
StatusCode getMatchedTruthJet(xAOD::Jet &jet_reco, xAOD::Jet &jet_truth_matched) const
Definition: FFJetSmearingTool.cxx:491
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::FFJetSmearingTool::m_Syst_uncertparam
std::map< std::string, std::string > m_Syst_uncertparam
Definition: FFJetSmearingTool.h:198
ICPJetCorrectionTool
class ICPJetCorrectionTool
Definition: ICPJetCorrectionTool.h:28
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
CP::FFJetSmearingTool::Interpolate2D
double Interpolate2D(const TH2 *histo, double x, double y) const
Definition: FFJetSmearingTool.cxx:990
CP::FFJetSmearingTool::m_Syst_TopologyAffected_map
std::map< std::string, std::string > m_Syst_TopologyAffected_map
Definition: FFJetSmearingTool.h:190
CP::FFJetSmearingTool::correctedCopy
virtual CP::CorrectionCode correctedCopy(const xAOD::Jet &input, xAOD::Jet *&output) const override
Definition: FFJetSmearingTool.cxx:923
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CP::FFJetSmearingTool::m_EtaRange
float m_EtaRange
Definition: FFJetSmearingTool.h:162
CP::FFJetSmearingTool::m_truthlabelaccessor
std::string m_truthlabelaccessor
Definition: FFJetSmearingTool.h:160
SystematicsTool.h
CP::FFJetSmearingTool::m_Syst_HistTA_map
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_HistTA_map
Definition: FFJetSmearingTool.h:195
CP::FFJetSmearingTool::m_doGaussianSmearing
bool m_doGaussianSmearing
Definition: FFJetSmearingTool.h:175
StatusCode.h
JetTools::FFJetAllowedMassDefEnum::Calo
@ Calo
merge.output
output
Definition: merge.py:17
CP::FFJetSmearingTool::m_MaxMass
float m_MaxMass
Definition: FFJetSmearingTool.h:163
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:523
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::FFJetSmearingTool::m_UFO_ResponseMap
std::unique_ptr< TH2 > m_UFO_ResponseMap
Definition: FFJetSmearingTool.h:178
JetTools::stringToEnum
StatusCode stringToEnum(const TString &name, FFJetAllowedMassDefEnum &result)
Definition: FFJetSmearingTool.h:66
CP::FFJetSmearingTool::replaceAllOccurrences
void replaceAllOccurrences(std::string &str, const std::string &to_find, const std::string &to_replace)
Definition: FFJetSmearingTool.cxx:1008
CP::FFJetSmearingTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systematics) override
Configure tool to apply systematic variation.
Definition: FFJetSmearingTool.cxx:257
CP::FFJetSmearingTool::m_release
std::string m_release
Definition: FFJetSmearingTool.h:158
CP::FFJetSmearingTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
List of all systematics recommended for this tool.
Definition: FFJetSmearingTool.cxx:206
CP::FFJetSmearingTool::m_Syst_Affects_JMSorJMR
std::map< std::string, std::string > m_Syst_Affects_JMSorJMR
Definition: FFJetSmearingTool.h:197
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CP::FFJetSmearingTool::m_configFile
std::string m_configFile
Definition: FFJetSmearingTool.h:170
CP::FFJetSmearingTool::FFJetSmearingTool
FFJetSmearingTool(const std::string &name)
Proper constructor for Athena.
Definition: FFJetSmearingTool.cxx:33
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:102
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:558
CP::FFJetSmearingTool::m_TA_ResponseMap
std::unique_ptr< TH2 > m_TA_ResponseMap
Definition: FFJetSmearingTool.h:177
CP::FFJetSmearingTool::m_caloMassWeight
std::unique_ptr< TH3F > m_caloMassWeight
Definition: FFJetSmearingTool.h:181
JetTools
Implementation of the Forward Folding (FF) Jet smearing tool interface.
Definition: FFJetSmearingTool.h:58
CP::FFJetSmearingTool::m_supportedmctypes
std::string m_supportedmctypes
Definition: FFJetSmearingTool.h:161
str
Definition: BTagTrackIpAccessor.cxx:11
ToolHandle.h
CP::FFJetSmearingTool::m_calibArea
std::string m_calibArea
Definition: FFJetSmearingTool.h:165
JetTools::FFJetAllowedMassDefEnum::Comb
@ Comb
Track Assisted.
AsgTool.h
CP::FFJetSmearingTool::SysData::SysParameter
float SysParameter
Definition: FFJetSmearingTool.h:204
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:953
CP::FFJetSmearingTool::m_MassDef
JetTools::FFJetAllowedMassDefEnum m_MassDef
Definition: FFJetSmearingTool.h:169
JetTools::FFJetAllowedMassDefEnum::UFO
@ UFO
Combined.
SystematicVariation.h
CP::FFJetSmearingTool::m_TAMassWeight
std::unique_ptr< TH3F > m_TAMassWeight
Definition: FFJetSmearingTool.h:182