ATLAS Offline Software
JetSmearingCorrection.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef JETCALIBTOOLS_JETSMEARINGCORRECTION_H
6 #define JETCALIBTOOLS_JETSMEARINGCORRECTION_H
7 
8 
10 
11 #include <memory>
12 #include <vector>
13 
14 #include "boost/thread/tss.hpp"
15 
16 #include "TRandom3.h"
17 #include "TEnv.h"
18 #include "TH1.h"
19 #include "TH2.h"
20 #include "TFile.h"
21 
23  : virtual public JetCalibrationStep
24 {
25 
26  public:
28  JetSmearingCorrection(const std::string& name, TEnv* config, TString jetAlgo, TString calibAreaTag, bool dev);
30 
31  virtual StatusCode initialize() override;
32  virtual StatusCode calibrate(xAOD::Jet& jet, JetEventInfo&) const override;
33 
34  virtual StatusCode getNominalResolutionData(const xAOD::Jet& jet, double& resolution) const override;
35  virtual StatusCode getNominalResolutionMC( const xAOD::Jet& jet, double& resolution) const override;
36 
37  private:
38  // Helper methods
39  StatusCode getSigmaSmear(xAOD::Jet& jet, double& sigmaSmear) const;
40  StatusCode getNominalResolution(const xAOD::Jet& jet, const TH1* histo, const std::vector< std::unique_ptr<TH1> >& projections, double& resolution) const;
41  StatusCode readHisto(double& returnValue, const TH1* histo, double x) const;
42  StatusCode readHisto(double& returnValue, const TH1* histo, const std::vector< std::unique_ptr<TH1> >& projections, double x, double y) const;
43  StatusCode cacheProjections(TH1* fullHistogram, std::vector< std::unique_ptr<TH1> >& cacheLocation, const std::string& type);
44  TRandom3* getTLSRandomGen(unsigned long seed) const;
45 
46  // Private enums
47  enum class SmearType
48  {
49  UNKNOWN=0, // Unknown/unset/etc
50  Pt, // pT smearing (JpTR)
51  Mass, // Mass smearing (JMR)
52  FourVec // Four-vector smearing (JER)
53  };
54  enum class HistType
55  {
56  UNKNOWN=0, // Unknown/unset/etc
57  Pt, // 1D histogram, binned in pT
58  PtEta, // 2D histogram, binned in x=pT y=eta
59  PtAbsEta // 2D histogram, binned in x=pT y=|eta|
60  };
61  enum class InterpType
62  {
63  UNKNOWN=0, // Unknown/unset/etc
64  Full, // Full interpolation
65  None, // No interpolation
66  OnlyX, // Interpolate only in the x dimension
67  OnlyY // Interpolate only in the y dimension
68  };
69 
70  // Class variables from constructor
71  TEnv* m_config;
72  const TString m_jetAlgo;
73  const TString m_calibAreaTag;
74  const bool m_dev;
75  mutable boost::thread_specific_ptr<TRandom3> m_rand_tls; // thread-specific random number generator
76 
77  // Class variables read in from the config file
78  TString m_jetOutScale;
82  std::unique_ptr<TH1> m_smearResolutionMC;
83  std::unique_ptr<TH1> m_smearResolutionData;
84 
85  // Variables to cache projections in case of 1-D interpolaton in 2-D or 3-D histograms
86  std::vector< std::unique_ptr<TH1> > m_cachedProjResMC;
87  std::vector< std::unique_ptr<TH1> > m_cachedProjResData;
88 };
89 
90 
91 #endif
92 
JetSmearingCorrection::calibrate
virtual StatusCode calibrate(xAOD::Jet &jet, JetEventInfo &) const override
Definition: JetSmearingCorrection.cxx:424
JetSmearingCorrection::m_cachedProjResMC
std::vector< std::unique_ptr< TH1 > > m_cachedProjResMC
Definition: JetSmearingCorrection.h:86
JetSmearingCorrection::m_calibAreaTag
const TString m_calibAreaTag
Definition: JetSmearingCorrection.h:73
JetSmearingCorrection::getTLSRandomGen
TRandom3 * getTLSRandomGen(unsigned long seed) const
Definition: JetSmearingCorrection.cxx:413
JetSmearingCorrection::m_jetOutScale
TString m_jetOutScale
Definition: JetSmearingCorrection.h:78
JetSmearingCorrection::InterpType::OnlyY
@ OnlyY
JetSmearingCorrection::HistType::PtEta
@ PtEta
JetSmearingCorrection::SmearType::FourVec
@ FourVec
JetSmearingCorrection::HistType
HistType
Definition: JetSmearingCorrection.h:55
JetSmearingCorrection::m_histType
HistType m_histType
Definition: JetSmearingCorrection.h:80
JetSmearingCorrection::JetSmearingCorrection
JetSmearingCorrection()
Definition: JetSmearingCorrection.cxx:11
JetSmearingCorrection::InterpType::OnlyX
@ OnlyX
JetSmearingCorrection::m_config
TEnv * m_config
Definition: JetSmearingCorrection.h:71
x
#define x
Dedxcorrection::resolution
double resolution[nGasTypes][nParametersResolution]
Definition: TRT_ToT_Corrections.h:46
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
JetSmearingCorrection::m_smearType
SmearType m_smearType
Definition: JetSmearingCorrection.h:79
JetSmearingCorrection::m_cachedProjResData
std::vector< std::unique_ptr< TH1 > > m_cachedProjResData
Definition: JetSmearingCorrection.h:87
JetEventInfo
Definition: JetEventInfo.h:8
JetSmearingCorrection::SmearType::UNKNOWN
@ UNKNOWN
JetSmearingCorrection::~JetSmearingCorrection
virtual ~JetSmearingCorrection()
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JetSmearingCorrection::cacheProjections
StatusCode cacheProjections(TH1 *fullHistogram, std::vector< std::unique_ptr< TH1 > > &cacheLocation, const std::string &type)
Definition: JetSmearingCorrection.cxx:476
JetSmearingCorrection::m_rand_tls
boost::thread_specific_ptr< TRandom3 > m_rand_tls
Definition: JetSmearingCorrection.h:75
JetSmearingCorrection::HistType::UNKNOWN
@ UNKNOWN
JetSmearingCorrection::m_smearResolutionData
std::unique_ptr< TH1 > m_smearResolutionData
Definition: JetSmearingCorrection.h:83
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
JetSmearingCorrection::SmearType::Mass
@ Mass
JetSmearingCorrection::readHisto
StatusCode readHisto(double &returnValue, const TH1 *histo, double x) const
Definition: JetSmearingCorrection.cxx:232
JetSmearingCorrection::initialize
virtual StatusCode initialize() override
Definition: JetSmearingCorrection.cxx:46
JetSmearingCorrection::getNominalResolution
StatusCode getNominalResolution(const xAOD::Jet &jet, const TH1 *histo, const std::vector< std::unique_ptr< TH1 > > &projections, double &resolution) const
Definition: JetSmearingCorrection.cxx:371
JetSmearingCorrection::SmearType::Pt
@ Pt
JetSmearingCorrection::SmearType
SmearType
Definition: JetSmearingCorrection.h:48
JetSmearingCorrection::m_interpType
InterpType m_interpType
Definition: JetSmearingCorrection.h:81
JetSmearingCorrection::getNominalResolutionMC
virtual StatusCode getNominalResolutionMC(const xAOD::Jet &jet, double &resolution) const override
Definition: JetSmearingCorrection.cxx:408
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
JetSmearingCorrection::InterpType::None
@ None
JetSmearingCorrection
Definition: JetSmearingCorrection.h:24
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
JetSmearingCorrection::InterpType::Full
@ Full
y
#define y
JetSmearingCorrection::getNominalResolutionData
virtual StatusCode getNominalResolutionData(const xAOD::Jet &jet, double &resolution) const override
Definition: JetSmearingCorrection.cxx:403
JetSmearingCorrection::m_jetAlgo
const TString m_jetAlgo
Definition: JetSmearingCorrection.h:72
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
JetSmearingCorrection::InterpType::UNKNOWN
@ UNKNOWN
JetSmearingCorrection::InterpType
InterpType
Definition: JetSmearingCorrection.h:62
JetCalibrationStep.h
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
JetSmearingCorrection::m_smearResolutionMC
std::unique_ptr< TH1 > m_smearResolutionMC
Definition: JetSmearingCorrection.h:82
JetSmearingCorrection::HistType::Pt
@ Pt
JetSmearingCorrection::HistType::PtAbsEta
@ PtAbsEta
JetSmearingCorrection::m_dev
const bool m_dev
Definition: JetSmearingCorrection.h:74
JetSmearingCorrection::getSigmaSmear
StatusCode getSigmaSmear(xAOD::Jet &jet, double &sigmaSmear) const
Definition: JetSmearingCorrection.cxx:336
JetCalibrationStep
Definition: JetCalibrationStep.h:20