CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CLHEPHitFitTranslator.cc
Go to the documentation of this file.
1 //
2 // $Id: CLHEPHitFitTranslator.cc,v 1.1 2011/05/26 09:46:59 mseidel Exp $
3 //
4 
21 #include <cstdlib>
22 #include "CLHEP/Vector/LorentzVector.h"
23 
27 
28 namespace hitfit {
29 
30 template<>
32 {
33 
34  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
35  std::string resolution_filename = CMSSW_BASE +
36  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
37  resolution_ = EtaDepResolution(resolution_filename);
38 
39 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
40 
41 
42 template<>
44 {
45 
46  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
47  std::string resolution_filename;
48 
49  if (ifile.empty()) {
50  resolution_filename = CMSSW_BASE +
51  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
52  } else {
53  resolution_filename = ifile ;
54  }
55 
56  resolution_ = EtaDepResolution(resolution_filename);
57 
58 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
59 
60 
61 template<>
63 {
64 }
65 
66 
67 template<>
69 LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton,
70  int type /* = hitfit::lepton_label */,
71  bool useObjEmbRes /* = false */)
72 {
73 
74  Fourvec p(lepton.px(),lepton.py(),lepton.pz(),lepton.e());
75 
76  double lepton_eta(lepton.eta());
77  Vector_Resolution lepton_resolution = resolution_.GetResolution(lepton_eta);
78  Lepjets_Event_Lep retlep(p,
79  type,
80  lepton_resolution);
81  return retlep;
82 
83 } // Lepjets_Event_Lep LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton)
84 
85 
86 template<>
87 const EtaDepResolution&
89 {
90  return resolution_;
91 }
92 
93 
94 template<>
95 bool
96 LeptonTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& lepton) const
97 {
98  return resolution_.CheckEta(lepton.eta());
99 }
100 
101 
102 template<>
104 {
105 
106  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
107  std::string udsc_resolution_filename = CMSSW_BASE +
108  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
109  std::string b_resolution_filename = udsc_resolution_filename;
110 
111  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
112  bResolution_ = EtaDepResolution(b_resolution_filename);
113 
114 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
115 
116 
117 template<>
119  const std::string& bFile)
120 {
121 
122  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
123  std::string udsc_resolution_filename;
124  std::string b_resolution_filename;
125 
126  if (udscFile.empty()) {
127  udsc_resolution_filename = CMSSW_BASE +
128  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
129  } else {
130  udsc_resolution_filename = udscFile;
131  }
132 
133  if (bFile.empty()) {
134  b_resolution_filename = CMSSW_BASE +
135  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
136  } else {
137  b_resolution_filename = bFile;
138  }
139 
140  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
141  bResolution_ = EtaDepResolution(b_resolution_filename);
142 
143 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,const std::string& bFile)
144 
145 
146 template<>
148 {
149 } // JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
150 
151 
152 template<>
155  int type /* = hitfit::unknown_label */,
156  bool useObjEmbRes /* = false */)
157 {
158 
159  Fourvec p(jet.px(),jet.py(),jet.pz(),jet.e());
160 
161  double jet_eta = jet.eta();
162  Vector_Resolution jet_resolution;
163 
164  if (type == hitfit::lepb_label||type == hitfit::hadb_label||type== hitfit::higgs_label) {
165  jet_resolution = bResolution_.GetResolution(jet_eta);
166  } else {
167  jet_resolution = udscResolution_.GetResolution(jet_eta);
168  }
169 
170  Lepjets_Event_Jet retjet(p,
171  type,
172  jet_resolution);
173  return retjet;
174 
175 } // Lepjets_Event_Jet JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& j,int type)
176 
177 
178 template<>
179 const EtaDepResolution&
181 {
182  return udscResolution_;
183 }
184 
185 
186 template<>
187 const EtaDepResolution&
189 {
190  return bResolution_;
191 }
192 
193 
194 template<>
195 bool
196 JetTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& jet) const
197 {
198  return udscResolution_.CheckEta(jet.eta()) && bResolution_.CheckEta(jet.eta());
199 }
200 
201 
202 template<>
204 {
205  resolution_ = Resolution(std::string("0,0,12"));
206 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
207 
208 
209 template<>
211 {
212  const Defaults_Text defs(ifile);
213  std::string resolution_string(defs.get_string("met_resolution"));
214  resolution_ = Resolution(resolution_string);
215 
216 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
217 
218 
219 template<>
221 {
222 } // METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
223 
224 
225 template<>
226 Fourvec
228  bool useObjEmbRes /* = false */)
229 {
230 
231  return Fourvec (m.px(),m.py(),0.0,m.e());
232 
233 } // Fourvec METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m)
234 
235 
236 
237 template<>
240  bool useObjEmbRes /* = false */) const
241 {
242  return resolution_;
243 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m)
244 
245 
246 
247 template<>
250  bool useObjEmbRes /* = false */) const
251 {
252  return KtResolution(m,useObjEmbRes);
253 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m)
254 
255 
256 } // namespace hitfit
type
Definition: HCALResponse.h:21
const EtaDepResolution & bResolution() const
Return the dependent resolution for jets.
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:103
~METTranslatorBase()
Destructor.
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.
bool CheckEta(const ALepton &lepton) const
Check if a lepton has value which is within the valid range of the resolution.
Resolution KtResolution(const AMet &met, bool useObjEmbRes=false) const
Return the resolution corresponding to an instance of missing transverse energy object.
const EtaDepResolution & resolution() const
Return the dependent resolution of the lepton.
const EtaDepResolution & udscResolution() const
Return the dependent resolution for jets.
Hold on to -dependent resolution. This class acts as a function object and returns Vector_Resolution ...
Resolution METResolution(const AMet &met, bool useObjEmbRes=false) const
Alias for KtResolution(AMet&amp; met)
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:58
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...
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...
virtual std::string get_string(std::string name) const
LeptonTranslatorBase()
Default constructor.
Calculate and represent resolution for a vector of , pseudorapidity , and azimuthal angle ...
bool CheckEta(const AJet &jet) const
Check if a jet has value which is within the valid range of the resolution.