test
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 //
3 
20 #include <cstdlib>
21 #include "CLHEP/Vector/LorentzVector.h"
22 
26 
27 namespace hitfit {
28 
29 template<>
31 {
32 
33  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
34  std::string resolution_filename = CMSSW_BASE +
35  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
36  resolution_ = EtaDepResolution(resolution_filename);
37 
38 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
39 
40 
41 template<>
43 {
44 
45  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
46  std::string resolution_filename;
47 
48  if (ifile.empty()) {
49  resolution_filename = CMSSW_BASE +
50  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
51  } else {
52  resolution_filename = ifile ;
53  }
54 
55  resolution_ = EtaDepResolution(resolution_filename);
56 
57 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
58 
59 
60 template<>
62 {
63 }
64 
65 
66 template<>
68 LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton,
69  int type /* = hitfit::lepton_label */,
70  bool useObjEmbRes /* = false */)
71 {
72 
73  Fourvec p(lepton.px(),lepton.py(),lepton.pz(),lepton.e());
74 
75  double lepton_eta(lepton.eta());
76  Vector_Resolution lepton_resolution = resolution_.GetResolution(lepton_eta);
77  Lepjets_Event_Lep retlep(p,
78  type,
79  lepton_resolution);
80  return retlep;
81 
82 } // Lepjets_Event_Lep LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton)
83 
84 
85 template<>
86 const EtaDepResolution&
88 {
89  return resolution_;
90 }
91 
92 
93 template<>
94 bool
95 LeptonTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& lepton) const
96 {
97  return resolution_.CheckEta(lepton.eta());
98 }
99 
100 
101 template<>
103 {
104 
105  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
106  std::string udsc_resolution_filename = CMSSW_BASE +
107  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
108  std::string b_resolution_filename = udsc_resolution_filename;
109 
110  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
111  bResolution_ = EtaDepResolution(b_resolution_filename);
112 
113 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
114 
115 
116 template<>
118  const std::string& bFile)
119 {
120 
121  std::string CMSSW_BASE(getenv("CMSSW_BASE"));
122  std::string udsc_resolution_filename;
123  std::string b_resolution_filename;
124 
125  if (udscFile.empty()) {
126  udsc_resolution_filename = CMSSW_BASE +
127  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
128  } else {
129  udsc_resolution_filename = udscFile;
130  }
131 
132  if (bFile.empty()) {
133  b_resolution_filename = CMSSW_BASE +
134  std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
135  } else {
136  b_resolution_filename = bFile;
137  }
138 
139  udscResolution_ = EtaDepResolution(udsc_resolution_filename);
140  bResolution_ = EtaDepResolution(b_resolution_filename);
141 
142 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,const std::string& bFile)
143 
144 
145 template<>
147 {
148 } // JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
149 
150 
151 template<>
154  int type /* = hitfit::unknown_label */,
155  bool useObjEmbRes /* = false */)
156 {
157 
158  Fourvec p(jet.px(),jet.py(),jet.pz(),jet.e());
159 
160  double jet_eta = jet.eta();
161  Vector_Resolution jet_resolution;
162 
163  if (type == hitfit::lepb_label||type == hitfit::hadb_label||type== hitfit::higgs_label) {
164  jet_resolution = bResolution_.GetResolution(jet_eta);
165  } else {
166  jet_resolution = udscResolution_.GetResolution(jet_eta);
167  }
168 
169  Lepjets_Event_Jet retjet(p,
170  type,
171  jet_resolution);
172  return retjet;
173 
174 } // Lepjets_Event_Jet JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& j,int type)
175 
176 
177 template<>
178 const EtaDepResolution&
180 {
181  return udscResolution_;
182 }
183 
184 
185 template<>
186 const EtaDepResolution&
188 {
189  return bResolution_;
190 }
191 
192 
193 template<>
194 bool
195 JetTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& jet) const
196 {
197  return udscResolution_.CheckEta(jet.eta()) && bResolution_.CheckEta(jet.eta());
198 }
199 
200 
201 template<>
203 {
204  resolution_ = Resolution(std::string("0,0,12"));
205 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
206 
207 
208 template<>
210 {
211  const Defaults_Text defs(ifile);
212  std::string resolution_string(defs.get_string("met_resolution"));
213  resolution_ = Resolution(resolution_string);
214 
215 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
216 
217 
218 template<>
220 {
221 } // METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
222 
223 
224 template<>
225 Fourvec
227  bool useObjEmbRes /* = false */)
228 {
229 
230  return Fourvec (m.px(),m.py(),0.0,m.e());
231 
232 } // Fourvec METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m)
233 
234 
235 
236 template<>
239  bool useObjEmbRes /* = false */) const
240 {
241  return resolution_;
242 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m)
243 
244 
245 
246 template<>
249  bool useObjEmbRes /* = false */) const
250 {
251  return KtResolution(m,useObjEmbRes);
252 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m)
253 
254 
255 } // 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:102
~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:57
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.