CMS 3D CMS Logo

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  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
32  std::string resolution_filename =
33  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
34  resolution_ = EtaDepResolution(resolution_filename);
35 
36  } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
37 
38  template <>
40  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
41  std::string resolution_filename;
42 
43  if (ifile.empty()) {
44  resolution_filename =
45  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
46  } else {
47  resolution_filename = ifile;
48  }
49 
50  resolution_ = EtaDepResolution(resolution_filename);
51 
52  } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
53 
54  template <>
56 
57  template <>
59  int type /* = hitfit::lepton_label */,
60  bool useObjEmbRes /* = false */) {
61  Fourvec p(lepton.px(), lepton.py(), lepton.pz(), lepton.e());
62 
63  double lepton_eta(lepton.eta());
64  Vector_Resolution lepton_resolution = resolution_.GetResolution(lepton_eta);
65  Lepjets_Event_Lep retlep(p, type, lepton_resolution);
66  return retlep;
67 
68  } // Lepjets_Event_Lep LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton)
69 
70  template <>
72  return resolution_;
73  }
74 
75  template <>
76  bool LeptonTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& lepton) const {
77  return resolution_.CheckEta(lepton.eta());
78  }
79 
80  template <>
82  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
83  std::string udsc_resolution_filename =
84  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
85  const std::string& b_resolution_filename = udsc_resolution_filename;
86 
87  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
88  bResolution_ = EtaDepResolution(b_resolution_filename);
89 
90  } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
91 
92  template <>
94  std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
95  std::string udsc_resolution_filename;
96  std::string b_resolution_filename;
97 
98  if (udscFile.empty()) {
99  udsc_resolution_filename =
100  CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
101  } else {
102  udsc_resolution_filename = udscFile;
103  }
104 
105  if (bFile.empty()) {
106  b_resolution_filename = CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
107  } else {
108  b_resolution_filename = bFile;
109  }
110 
111  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
112  bResolution_ = EtaDepResolution(b_resolution_filename);
113 
114  } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,const std::string& bFile)
115 
116  template <>
118  } // JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
119 
120  template <>
122  int type /* = hitfit::unknown_label */,
123  bool useObjEmbRes /* = false */) {
124  Fourvec p(jet.px(), jet.py(), jet.pz(), jet.e());
125 
126  double jet_eta = jet.eta();
127  Vector_Resolution jet_resolution;
128 
130  jet_resolution = bResolution_.GetResolution(jet_eta);
131  } else {
132  jet_resolution = udscResolution_.GetResolution(jet_eta);
133  }
134 
135  Lepjets_Event_Jet retjet(p, type, jet_resolution);
136  return retjet;
137 
138  } // Lepjets_Event_Jet JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& j,int type)
139 
140  template <>
142  return udscResolution_;
143  }
144 
145  template <>
147  return bResolution_;
148  }
149 
150  template <>
151  bool JetTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& jet) const {
152  return udscResolution_.CheckEta(jet.eta()) && bResolution_.CheckEta(jet.eta());
153  }
154 
155  template <>
157  resolution_ = Resolution(std::string("0,0,12"));
158  } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
159 
160  template <>
162  const Defaults_Text defs(ifile);
163  std::string resolution_string(defs.get_string("met_resolution"));
164  resolution_ = Resolution(resolution_string);
165 
166  } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
167 
168  template <>
170  } // METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
171 
172  template <>
174  bool useObjEmbRes /* = false */) {
175  return Fourvec(m.px(), m.py(), 0.0, m.e());
176 
177  } // Fourvec METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m)
178 
179  template <>
181  bool useObjEmbRes /* = false */) const {
182  return resolution_;
183  } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m)
184 
185  template <>
187  bool useObjEmbRes /* = false */) const {
188  return KtResolution(m, useObjEmbRes);
189  } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m)
190 
191 } // 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 ...