TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
JetRecalibrator.h
1 #ifndef _TIMBER_JETRECALIBRATOR
2 #define _TIMBER_JETRECALIBRATOR
3 #include <string>
4 #include <map>
5 #include <vector>
6 #include <algorithm>
7 // #include <boost/filesystem.hpp>
8 #include "Collection.h"
9 #include "JME_common.h"
10 #include <ROOT/RVec.hxx>
11 #include "CondFormats/JetMETObjects/interface/FactorizedJetCorrector.h"
12 #include "CondFormats/JetMETObjects/interface/JetCorrectorParameters.h"
13 #include "CondFormats/JetMETObjects/interface/JetCorrectionUncertainty.h"
14 
15 typedef std::string str;
16 typedef ROOT::VecOps::RVec<float> rvec_f;
17 typedef std::vector<JetCorrectorParameters> vJCP;
24  private:
25  bool _doResidualJECs;//, _calculateSeparateCorrections, _calculateType1METCorrection;
26  str _jecTag, _jetType, _uncertType;
27  int _upToLevel;
28  // std::map<str, float> _type1METParams;
29  FactorizedJetCorrector* _JetCorrector;
30  float _correction;
31  float _uncertainty;
32  JetCorrectorParameters _L1JetPar, _L2JetPar, _L3JetPar, _ResJetPar;
33  JetCorrectionUncertainty* _JetUncertainty;
34  JESpaths _paths;
35 
36  public:
51  JetRecalibrator( str jecTag, str jetType, bool doResidualJECs,
52  str uncertType, int upToLevel=3
53  // bool calculateSeparateCorrections=false,
54  // bool calculateType1METCorrection=false,
55  // std::map<str, float> type1METParams = {
56  // {'jetPtThreshold', 15.},
57  // {'skipEMfractionThreshold', 0.9},
58  // {'skipMuons', 1} // True
59  // }
60  );
61  ~JetRecalibrator();
70  template <class T>
71  void CalculateCorrection(T jet, float fixedGridRhoFastjetAll){
72  _JetCorrector->setJetPhi(jet.phi);
73  _JetCorrector->setJetEta(jet.eta);
74  _JetCorrector->setJetPt(jet.pt * (1. - jet.rawFactor));
75  _JetCorrector->setJetA(jet.area);
76  _JetCorrector->setRho(fixedGridRhoFastjetAll);
77  _correction = _JetCorrector->getCorrection() * (1. - jet.rawFactor);
78  };
87  template <class T>
88  void CalculateUncertainty(T jet, float delta = 1){
89  if (delta != 0) {
90  _JetUncertainty->setJetPhi(jet.phi);
91  _JetUncertainty->setJetEta(jet.eta);
92  _JetUncertainty->setJetPt(_correction * jet.pt);
93  _uncertainty = delta*_JetUncertainty->getUncertainty(true);
94 
95  } else {
96  _uncertainty = 0;
97  }
98  };
105  float GetCorrection() {return _correction;};
112  float GetUncertainty() {return _uncertainty;};
113 };
114 #endif
void CalculateUncertainty(T jet, float delta=1)
Calculate the correction uncertainty for a given jet and store the value internally. WARNING: CalculateCorrection must be run first.
Definition: JetRecalibrator.h:88
C++ class to handle the extraction of JES objects (aka JEC) starting from the JEC tags and jet types...
Definition: JME_common.h:57
JetRecalibrator()
Construct a new Jet Recalibrator object.
Definition: JetRecalibrator.cc:3
float GetCorrection()
Return the internally stored correction value that was calculated during CalculateCorrection.
Definition: JetRecalibrator.h:105
C++ class to recalibrate the of jets. Initialized with basic parameters and calculations done on vec...
Definition: JetRecalibrator.h:23
void CalculateCorrection(T jet, float fixedGridRhoFastjetAll)
Calculate the correction for a given jet and rho and store the value internally.
Definition: JetRecalibrator.h:71
float GetUncertainty()
Return the internally stored uncertainty value that was calculated during CalculateUncertainty.
Definition: JetRecalibrator.h:112