ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
58namespace JetTools{
66 inline StatusCode stringToEnum(const TString& name, FFJetAllowedMassDefEnum& result)
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
100namespace CP {
102 {
103
106
107 public:
108 // Constructor/destructor/init
109 FFJetSmearingTool(const std::string& name);
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
130 virtual StatusCode applySystematicVariation
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;
138 virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer& inputs) const override;
139
140 StatusCode getMatchedTruthJet( xAOD::Jet& jet_reco, xAOD::Jet& jet_truth_matched) const;
141
142 private:
143
144
145 StatusCode readFFJetSmearingToolSimplifiedData(TEnv& settings);
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;
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;
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
#define ASG_TOOL_CLASS(CLASSNAME, INT1)
static const std::vector< std::string > systematics
#define y
#define x
#define z
Return value from object correction CP tools.
virtual CP::SystematicSet recommendedSystematics() const override
List of all systematics recommended for this tool.
std::map< std::string, std::string > m_Syst_uncertparam
std::unique_ptr< TH2 > m_TA_ResponseMap
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
std::map< std::string, std::string > m_Syst_HistPath_map
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systematics) override
Configure tool to apply systematic variation.
virtual CP::CorrectionCode applyContainerCorrection(xAOD::JetContainer &inputs) const override
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_Hist_map3d
StatusCode getMatchedTruthJet(xAOD::Jet &jet_reco, xAOD::Jet &jet_truth_matched) const
std::map< std::string, std::unique_ptr< TH3F > > m_Syst_HistTA_map3d
static constexpr float m_MeVtoGeV
virtual ~FFJetSmearingTool()
CP::SystematicSet m_SysList
StatusCode getJetTopology(xAOD::Jet &jet_reco, std::string &jetTopology) const
double Interpolate2D(const TH2 *histo, double x, double y) const
std::map< std::string, std::string > m_Syst_Affects_JMSorJMR
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
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
Specify whether tool is affected by provided systematic.
virtual CP::SystematicSet affectingSystematics() const override
List of all systematics affecting this tool.
std::unique_ptr< TH3F > m_caloMassWeight
SysData * m_currentSysData
Points to the current systematic configuration.
JetTools::FFJetAllowedMassDefEnum m_MassDef
void replaceAllOccurrences(std::string &str, const std::string &to_find, const std::string &to_replace)
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_HistTA_map
std::map< std::string, std::string > m_Syst_TopologyAffected_map
std::map< std::string, std::string > m_Syst_MassDefAffected_map
StatusCode readFFJetSmearingToolSimplifiedData(TEnv &settings)
std::unordered_map< CP::SystematicSet, SysData > m_sysData
std::unique_ptr< TH3F > m_TAMassWeight
std::unique_ptr< TH2 > m_CALO_ResponseMap
virtual CP::CorrectionCode correctedCopy(const xAOD::Jet &input, xAOD::Jet *&output) const override
std::unique_ptr< TH2 > m_UFO_ResponseMap
std::map< std::string, std::unique_ptr< TH2 > > m_Syst_Hist_map
double Read3DHistogram(const TH3 *histo, double x, double y, double z) const
virtual CP::CorrectionCode applyCorrection(xAOD::Jet &jet_reco) const override
Apply a systematic variation of get a new copy.
std::map< std::string, std::string > m_Syst_HistTAPath_map
FFJetSmearingTool(const std::string &name)
Proper constructor for Athena.
Class to wrap a set of SystematicVariations.
class ICPJetCorrectionTool
Base class for the dual-use tool implementation classes.
Definition AsgTool.h:47
Select isolated Photons, Electrons and Muons.
Implementation of the Forward Folding (FF) Jet smearing tool interface.
StatusCode stringToEnum(const TString &name, FFJetAllowedMassDefEnum &result)
TString enumToString(const FFJetAllowedMassDefEnum type)
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".