ATLAS Offline Software
GlobalNNCalibration.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 JetCalibTools_GlobalNNCalibration_H
7 #define JetCalibTools_GlobalNNCalibration_H
8 
9 #include "TH1.h"
10 #include "TString.h"
11 #include "lwtnn/LightweightGraph.hh"
12 
13 // Local includes
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <memory>
19 
20 class JetEventInfo;
21 class TEnv;
22 
23 
35 class GlobalNNCalibration : virtual public ::JetCalibrationStep {
36 
37  public:
38  // Constructor/destructor/init
43 
48  GlobalNNCalibration(const std::string& name);
49 
58  GlobalNNCalibration(const std::string& name, TEnv * config, TString jetAlgo, const TString& calibAreaTag, bool dev);
59 
63  virtual ~GlobalNNCalibration() = default;
64 
69  virtual StatusCode initialize() override;
70 
71 
72  protected:
73  // @brief Calibrates the jet, and decorates it with the calibration using the name "JetGNNCScaleMomentum"
74  // @param jet_reco The jet
75  // @param jetEventInfo A set of information about the event and jet
76  virtual StatusCode calibrate(xAOD::Jet& jet, JetEventInfo&) const override;
77 
78  private:
79 
85  double getJetChargedFraction(const xAOD::Jet& jet_reco, int PVindex) const;
86 
91  double getJetDetEta(const xAOD::Jet& jet_reco) const;
92 
98  int getJetNtrk1000(const xAOD::Jet& jet_reco, int PVindex) const;
99 
105  double getJetWtrk1000(const xAOD::Jet& jet_reco, int PVindex) const;
106 
111  double getJESPt(const xAOD::Jet& jet_reco) const;
112 
118  std::map<std::string,double> getJetFeatures(const xAOD::Jet& jet_reco, JetEventInfo& jetEventInfo) const;
119 
125  double getSplineSlope(const int ieta, const double minPt) const;
126 
132  void loadSplineHists(const TString & fileName, const std::string &etajes_name = "etaJes");
133 
139  double getSplineCorr(const int etaBin, double E) const;
140 
141 
147  int getEtaBin(const xAOD::Jet& jet_reco, const std::vector<double>& etaBins) const;
148 
149 
150  std::vector<std::unique_ptr<lwt::LightweightGraph> > m_lwnns;
151  std::vector<std::unique_ptr<TH1> > m_ptCorrFactors;
152  std::vector<double> m_nnEtaBins;
153  std::vector<double> m_closureEtaBins;
154  std::vector<TString> m_NNInputs;
155 
156 
157  TEnv * m_config{};
158  TString m_jetAlgo;
159  std::string m_calibAreaTag;
160  bool m_dev{};
161  bool m_doSplineCorr{true};
165 
166  std::vector<double> m_JPtS_MinPt_Slopes;
167  std::vector<double> m_JPtS_MinPt_Pt;
168  std::vector<double> m_JPtS_MinPt_R;
169 
170 
171 }; // Class GlobalNNCalibration
172 
173 
174 #endif
175 
176 
GlobalNNCalibration::getSplineSlope
double getSplineSlope(const int ieta, const double minPt) const
Gets the slope of the spline histogram for a given eta bin, for extrapolation of the calibration.
Definition: GlobalNNCalibration.cxx:208
GlobalNNCalibration::m_JPtS_MinPt_Slopes
std::vector< double > m_JPtS_MinPt_Slopes
Definition: GlobalNNCalibration.h:166
GlobalNNCalibration::calibrate
virtual StatusCode calibrate(xAOD::Jet &jet, JetEventInfo &) const override
Definition: GlobalNNCalibration.cxx:126
GlobalNNCalibration::m_NNInputs
std::vector< TString > m_NNInputs
Definition: GlobalNNCalibration.h:154
GlobalNNCalibration::getEtaBin
int getEtaBin(const xAOD::Jet &jet_reco, const std::vector< double > &etaBins) const
Returns the eta bin, as determined by a list of bin edges.
Definition: GlobalNNCalibration.cxx:303
ConvertOldUJHistosToNewHistos.etaBins
list etaBins
Definition: ConvertOldUJHistosToNewHistos.py:145
GlobalNNCalibration::getJetChargedFraction
double getJetChargedFraction(const xAOD::Jet &jet_reco, int PVindex) const
Returns the charged fraction of a jet.
Definition: GlobalNNCalibration.cxx:313
GlobalNNCalibration::m_config
TEnv * m_config
Definition: GlobalNNCalibration.h:157
GlobalNNCalibration::getJetNtrk1000
int getJetNtrk1000(const xAOD::Jet &jet_reco, int PVindex) const
Returns the number of tracks with pT > 1 GeV associated to the jet.
Definition: GlobalNNCalibration.cxx:329
GlobalNNCalibration::m_JPtS_MinPt_Pt
std::vector< double > m_JPtS_MinPt_Pt
Definition: GlobalNNCalibration.h:167
GlobalNNCalibration::~GlobalNNCalibration
virtual ~GlobalNNCalibration()=default
The destructor.
GlobalNNCalibration::getJetFeatures
std::map< std::string, double > getJetFeatures(const xAOD::Jet &jet_reco, JetEventInfo &jetEventInfo) const
Returns a map of possible inputs to the NN, and their corresponding values for this jet.
Definition: GlobalNNCalibration.cxx:223
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
GlobalNNCalibration::m_calibAreaTag
std::string m_calibAreaTag
Definition: GlobalNNCalibration.h:159
JetEventInfo
Definition: JetEventInfo.h:8
GlobalNNCalibration::m_doSplineCorr
bool m_doSplineCorr
Definition: GlobalNNCalibration.h:161
GlobalNNCalibration::m_JPtS_MinPt_R
std::vector< double > m_JPtS_MinPt_R
Definition: GlobalNNCalibration.h:168
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
GlobalNNCalibration::m_ptCorrFactors
std::vector< std::unique_ptr< TH1 > > m_ptCorrFactors
Definition: GlobalNNCalibration.h:151
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
GlobalNNCalibration::m_nnEtaBins
std::vector< double > m_nnEtaBins
Definition: GlobalNNCalibration.h:152
GlobalNNCalibration::m_minNNCorrection
double m_minNNCorrection
Definition: GlobalNNCalibration.h:163
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
GlobalNNCalibration::getJetWtrk1000
double getJetWtrk1000(const xAOD::Jet &jet_reco, int PVindex) const
Returns the jet width.
Definition: GlobalNNCalibration.cxx:336
GlobalNNCalibration::m_doLogPtScaling
bool m_doLogPtScaling
Definition: GlobalNNCalibration.h:162
GlobalNNCalibration::m_jetAlgo
TString m_jetAlgo
Definition: GlobalNNCalibration.h:158
GlobalNNCalibration::getSplineCorr
double getSplineCorr(const int etaBin, double E) const
Returns the correction from spline histogram, which should be applied after the NN correction.
Definition: GlobalNNCalibration.cxx:190
GlobalNNCalibration::m_maxNNCorrection
double m_maxNNCorrection
Definition: GlobalNNCalibration.h:164
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
GlobalNNCalibration::initialize
virtual StatusCode initialize() override
Returns the charged fraction of a jet.
Definition: GlobalNNCalibration.cxx:52
GlobalNNCalibration::getJetDetEta
double getJetDetEta(const xAOD::Jet &jet_reco) const
Returns the detector eta of the jet.
Definition: GlobalNNCalibration.cxx:324
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
GlobalNNCalibration::m_lwnns
std::vector< std::unique_ptr< lwt::LightweightGraph > > m_lwnns
Definition: GlobalNNCalibration.h:150
GlobalNNCalibration::loadSplineHists
void loadSplineHists(const TString &fileName, const std::string &etajes_name="etaJes")
Reads the spline histograms from the file given in the config, and stores them in m_ptCorrFactors.
Definition: GlobalNNCalibration.cxx:164
GlobalNNCalibration::getJESPt
double getJESPt(const xAOD::Jet &jet_reco) const
Returns the jet pT after the MCJES calibration.
Definition: GlobalNNCalibration.cxx:344
GlobalNNCalibration::GlobalNNCalibration
GlobalNNCalibration()
The constructor.
Definition: GlobalNNCalibration.cxx:30
JetCalibrationStep.h
GlobalNNCalibration::m_closureEtaBins
std::vector< double > m_closureEtaBins
Definition: GlobalNNCalibration.h:153
GlobalNNCalibration
Tool to provide the global NN calibration for jets.
Definition: GlobalNNCalibration.h:35
JetCalibrationStep
Definition: JetCalibrationStep.h:20
GlobalNNCalibration::m_dev
bool m_dev
Definition: GlobalNNCalibration.h:160