CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CLHEPHitFitTranslator.cc
Go to the documentation of this file.
1 //
2 //
3 
20 #include <cstdlib>
21 #include "CLHEP/Vector/LorentzVector.h"
22 
26 
27 namespace hitfit {
28 
29  template <>
31  [[clang::suppress]]
32  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
33  std::string resolution_filename =
34  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
35  resolution_ = EtaDepResolution(resolution_filename);
36 
37  } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
38 
39  template <>
41  [[clang::suppress]]
42  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
43  std::string resolution_filename;
44 
45  if (ifile.empty()) {
46  resolution_filename =
47  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
48  } else {
49  resolution_filename = ifile;
50  }
51 
52  resolution_ = EtaDepResolution(resolution_filename);
53 
54  } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
55 
56  template <>
58 
59  template <>
61  int type /* = hitfit::lepton_label */,
62  bool useObjEmbRes /* = false */) {
63  Fourvec p(lepton.px(), lepton.py(), lepton.pz(), lepton.e());
64 
65  double lepton_eta(lepton.eta());
66  Vector_Resolution lepton_resolution = resolution_.GetResolution(lepton_eta);
67  Lepjets_Event_Lep retlep(p, type, lepton_resolution);
68  return retlep;
69 
70  } // Lepjets_Event_Lep LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton)
71 
72  template <>
74  return resolution_;
75  }
76 
77  template <>
78  bool LeptonTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& lepton) const {
79  return resolution_.CheckEta(lepton.eta());
80  }
81 
82  template <>
84  [[clang::suppress]]
85  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
86  std::string udsc_resolution_filename =
87  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
88  const std::string& b_resolution_filename = udsc_resolution_filename;
89 
90  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
91  bResolution_ = EtaDepResolution(b_resolution_filename);
92 
93  } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
94 
95  template <>
97  [[clang::suppress]]
98  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
99  std::string udsc_resolution_filename;
100  std::string b_resolution_filename;
101 
102  if (udscFile.empty()) {
103  udsc_resolution_filename =
104  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
105  } else {
106  udsc_resolution_filename = udscFile;
107  }
108 
109  if (bFile.empty()) {
110  b_resolution_filename = CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
111  } else {
112  b_resolution_filename = bFile;
113  }
114 
115  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
116  bResolution_ = EtaDepResolution(b_resolution_filename);
117 
118  } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,const std::string& bFile)
119 
120  template <>
122  } // JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
123 
124  template <>
126  int type /* = hitfit::unknown_label */,
127  bool useObjEmbRes /* = false */) {
128  Fourvec p(jet.px(), jet.py(), jet.pz(), jet.e());
129 
130  double jet_eta = jet.eta();
131  Vector_Resolution jet_resolution;
132 
134  jet_resolution = bResolution_.GetResolution(jet_eta);
135  } else {
136  jet_resolution = udscResolution_.GetResolution(jet_eta);
137  }
138 
139  Lepjets_Event_Jet retjet(p, type, jet_resolution);
140  return retjet;
141 
142  } // Lepjets_Event_Jet JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& j,int type)
143 
144  template <>
146  return udscResolution_;
147  }
148 
149  template <>
151  return bResolution_;
152  }
153 
154  template <>
155  bool JetTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& jet) const {
156  return udscResolution_.CheckEta(jet.eta()) && bResolution_.CheckEta(jet.eta());
157  }
158 
159  template <>
161  resolution_ = Resolution(std::string("0,0,12"));
162  } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
163 
164  template <>
166  const Defaults_Text defs(ifile);
167  std::string resolution_string(defs.get_string("met_resolution"));
168  resolution_ = Resolution(resolution_string);
169 
170  } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
171 
172  template <>
174  } // METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
175 
176  template <>
178  bool useObjEmbRes /* = false */) {
179  return Fourvec(m.px(), m.py(), 0.0, m.e());
180 
181  } // Fourvec METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m)
182 
183  template <>
185  bool useObjEmbRes /* = false */) const {
186  return resolution_;
187  } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m)
188 
189  template <>
191  bool useObjEmbRes /* = false */) const {
192  return KtResolution(m, useObjEmbRes);
193  } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m)
194 
195 } // namespace hitfit
Represent a lepton in an instance of Lepjets_Event class. This class hold the following information: ...
Fourvec operator()(const AMet &met, bool useObjEmbRes=false)
Convert a missing transverse energy object of type AMet into HitFit four-momentum object of type Four...
JetTranslatorBase()
Default constructor.
Calculate and represent resolution for a physical quantity.
Definition: Resolution.h:98
~METTranslatorBase()
Destructor.
std::string get_string(std::string name) const override
Lepjets_Event_Lep operator()(const ALepton &lepton, int type=hitfit::lepton_label, bool useObjEmbRes=false)
Convert a lepton physics object of type ALepton into HitFit lepton physics object of type Lepjets_Eve...
A lightweight implementation of the Defaults interface that uses simple ASCII text files...
~LeptonTranslatorBase()
Destructor.
Resolution KtResolution(const AMet &met, bool useObjEmbRes=false) const
Return the resolution corresponding to an instance of missing transverse energy object.
Hold on to -dependent resolution. This class acts as a function object and returns Vector_Resolution ...
const EtaDepResolution & bResolution() const
Return the dependent resolution for jets.
METTranslatorBase()
Default constructor.
Lepjets_Event_Jet operator()(const AJet &jet, int type=hitfit::unknown_label, bool useObjEmbRes=false)
Convert a jet physics object of type AJet into HitFit jet physics object of type Lepjets_Event_Jet. This operator must be able to apply the appropriate jet energy correction in accord with the type of the jet.
CLHEP::HepLorentzVector Fourvec
Typedef for a HepLorentzVector.
Definition: fourvec.h:55
Template class of function object to translate missing transverse energy object to HitFit&#39;s Fourvec o...
A class to represent a jet in an instance of Lepjets_Event class. The class is derived from the Lepje...
bool CheckEta(const AJet &jet) const
Check if a jet has value which is within the valid range of the resolution.
bool CheckEta(const ALepton &lepton) const
Check if a lepton has value which is within the valid range of the resolution.
Template class of function object to translate jet physics object to HitFit&#39;s Lepjets_Event_Jet objec...
~JetTranslatorBase()
Destructor.
Template class of function object to translate lepton physics object to HitFit&#39;s Lepjets_Event_Lep ob...
Resolution METResolution(const AMet &met, bool useObjEmbRes=false) const
Alias for KtResolution(AMet& met)
const EtaDepResolution & resolution() const
Return the dependent resolution of the lepton.
const EtaDepResolution & udscResolution() const
Return the dependent resolution for jets.
LeptonTranslatorBase()
Default constructor.
Calculate and represent resolution for a vector of , pseudorapidity , and azimuthal angle ...