ATLAS Offline Software
Generic4VecCorrection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef JETCALIBTOOLS_GENERIC4VECCORRECTION_H
6 #define JETCALIBTOOLS_GENERIC4VECCORRECTION_H
7 
8 
9 #include "TString.h"
10 #include "TH1.h"
11 
13 
14 #include <nlohmann/json.hpp>
15 #include <map>
16 
17 class TEnv;
18 class TH2;
19 
21  : virtual public JetCalibrationStep
22 {
23 
24  public:
25 
26  // Enums for corrections supported by this tool
28  UNKNOWN = 0,
30  MC2MC = 2,
31  FASTSIM = 3
32  };
33 
34  // Constructor/destructor/init
36  Generic4VecCorrection(const std::string& name, TEnv* config, const TString & jetAlgo,
37  const TString & calibAreaTag, const TString & forceCalibFile,
38  JET_CORRTYPE correctionType, const TString & mcCampaign="", const TString & simFlavour="",
39  int mcDSID=-1, const TString & generatorsInfo="");
40  virtual ~Generic4VecCorrection();
41  virtual StatusCode initialize() override;
42  virtual StatusCode calibrate(xAOD::Jet& jet, JetEventInfo&) const override;
43 
44  private:
45  // Extract correction value from chosen 2D histogram
46  StatusCode readHisto(float& correctionFactor, TH2* h_correction_2D, float x, float y) const;
47 
48  // Dedicated initialize functions for supported corrections
51 
52  // For MC2MC, parse the calibration showerModel from sample metadata
53  StatusCode parse_showerModel(TString& showerModel, int mcDSID, TString generatorsInfo) const;
54 
55  StatusCode load_json(nlohmann::json& json_object, const std::string& json_filepath) const;
56 
57  // Class variables from constructor
58  TEnv* m_config;
59  const TString m_jetAlgo;
60  const TString m_calibAreaTag;
62  const TString m_simFlavour;
63 
64  // Variables for MC2MC Correction
65  int m_mcDSID{};
66  const TString m_generatorsInfo;
67  const TString m_mcCampaign;
68  const TString m_forceCalibFile;
69 
70  // Option to skip correction if input file does not conform to requested correction
72 
73  // Input and output jet scales
74  TString m_inJetScale;
75  TString m_outJetScale;
76 
77  // Correction histograms
79  std::map<int, TH2*> m_correctionHists; // If several possible corrections
80  TH2* m_only_correction_2D{}; // If only one correction
81  TAxis m_etaAxis; // For finding center of eta bins to avoid eta interpolation
82 
83 };
84 
85 #endif
Generic4VecCorrection::PTRESIDUAL
@ PTRESIDUAL
Definition: Generic4VecCorrection.h:29
Generic4VecCorrection::m_generatorsInfo
const TString m_generatorsInfo
Definition: Generic4VecCorrection.h:66
json
nlohmann::json json
Definition: HistogramDef.cxx:9
Generic4VecCorrection::m_jetAlgo
const TString m_jetAlgo
Definition: Generic4VecCorrection.h:59
Generic4VecCorrection::JET_CORRTYPE
JET_CORRTYPE
Definition: Generic4VecCorrection.h:27
Generic4VecCorrection::m_outJetScale
TString m_outJetScale
Definition: Generic4VecCorrection.h:75
Generic4VecCorrection::m_simFlavour
const TString m_simFlavour
Definition: Generic4VecCorrection.h:62
Generic4VecCorrection::UNKNOWN
@ UNKNOWN
Definition: Generic4VecCorrection.h:28
Generic4VecCorrection::initialize_MC2MC
StatusCode initialize_MC2MC()
Definition: Generic4VecCorrection.cxx:251
Generic4VecCorrection::m_config
TEnv * m_config
Definition: Generic4VecCorrection.h:58
x
#define x
Generic4VecCorrection::initialize
virtual StatusCode initialize() override
Definition: Generic4VecCorrection.cxx:34
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
Generic4VecCorrection::parse_showerModel
StatusCode parse_showerModel(TString &showerModel, int mcDSID, TString generatorsInfo) const
Definition: Generic4VecCorrection.cxx:334
Generic4VecCorrection::readHisto
StatusCode readHisto(float &correctionFactor, TH2 *h_correction_2D, float x, float y) const
Definition: Generic4VecCorrection.cxx:104
Generic4VecCorrection::m_inJetScale
TString m_inJetScale
Definition: Generic4VecCorrection.h:74
Generic4VecCorrection::m_calibAreaTag
const TString m_calibAreaTag
Definition: Generic4VecCorrection.h:60
JetEventInfo
Definition: JetEventInfo.h:8
Generic4VecCorrection::Generic4VecCorrection
Generic4VecCorrection()
Definition: Generic4VecCorrection.cxx:25
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
Generic4VecCorrection::m_forceCalibFile
const TString m_forceCalibFile
Definition: Generic4VecCorrection.h:68
Generic4VecCorrection::load_json
StatusCode load_json(nlohmann::json &json_object, const std::string &json_filepath) const
Definition: Generic4VecCorrection.cxx:238
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TestSUSYToolsAlg.mcCampaign
mcCampaign
Definition: TestSUSYToolsAlg.py:134
Generic4VecCorrection::m_correctionHists
std::map< int, TH2 * > m_correctionHists
Definition: Generic4VecCorrection.h:79
Generic4VecCorrection::m_correctionType
JET_CORRTYPE m_correctionType
Definition: Generic4VecCorrection.h:61
Generic4VecCorrection::m_mcCampaign
const TString m_mcCampaign
Definition: Generic4VecCorrection.h:67
Generic4VecCorrection::m_only_correction_2D
TH2 * m_only_correction_2D
Definition: Generic4VecCorrection.h:80
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Generic4VecCorrection::initialize_correctionResponse
StatusCode initialize_correctionResponse()
Definition: Generic4VecCorrection.cxx:186
Generic4VecCorrection::~Generic4VecCorrection
virtual ~Generic4VecCorrection()
Definition: Generic4VecCorrection.cxx:31
Generic4VecCorrection
Definition: Generic4VecCorrection.h:22
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
y
#define y
Generic4VecCorrection::m_mcDSID
int m_mcDSID
Definition: Generic4VecCorrection.h:65
Generic4VecCorrection::m_correctionFilePath
TString m_correctionFilePath
Definition: Generic4VecCorrection.h:78
JetCalibrationStep.h
Generic4VecCorrection::m_etaAxis
TAxis m_etaAxis
Definition: Generic4VecCorrection.h:81
Generic4VecCorrection::FASTSIM
@ FASTSIM
Definition: Generic4VecCorrection.h:31
Generic4VecCorrection::MC2MC
@ MC2MC
Definition: Generic4VecCorrection.h:30
Generic4VecCorrection::m_skipCorrection
bool m_skipCorrection
Definition: Generic4VecCorrection.h:71
Generic4VecCorrection::calibrate
virtual StatusCode calibrate(xAOD::Jet &jet, JetEventInfo &) const override
Definition: Generic4VecCorrection.cxx:127
JetCalibrationStep
Definition: JetCalibrationStep.h:20