CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/TopQuarkAnalysis/TopHitFit/src/CLHEPHitFitTranslator.cc

Go to the documentation of this file.
00001 //
00002 //  $Id: CLHEPHitFitTranslator.cc,v 1.1 2011/05/26 09:46:59 mseidel Exp $
00003 //
00004 
00021 #include <cstdlib>
00022 #include "CLHEP/Vector/LorentzVector.h"
00023 
00024 #include "TopQuarkAnalysis/TopHitFit/interface/LeptonTranslatorBase.h"
00025 #include "TopQuarkAnalysis/TopHitFit/interface/JetTranslatorBase.h"
00026 #include "TopQuarkAnalysis/TopHitFit/interface/METTranslatorBase.h"
00027 
00028 namespace hitfit {
00029 
00030 template<>
00031 LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
00032 {
00033 
00034     std::string CMSSW_BASE(getenv("CMSSW_BASE"));
00035     std::string resolution_filename = CMSSW_BASE +
00036         std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
00037     resolution_ = EtaDepResolution(resolution_filename);
00038 
00039 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase()
00040 
00041 
00042 template<>
00043 LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
00044 {
00045 
00046     std::string CMSSW_BASE(getenv("CMSSW_BASE"));
00047     std::string resolution_filename;
00048 
00049     if (ifile.empty()) {
00050         resolution_filename = CMSSW_BASE +
00051         std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleElectronResolution.txt");
00052     } else {
00053         resolution_filename = ifile ;
00054     }
00055 
00056     resolution_ = EtaDepResolution(resolution_filename);
00057 
00058 } // LeptonTranslatorBase<CLHEP::HepLorentzVector>::LeptonTranslatorBase(const std::string& ifile)
00059 
00060 
00061 template<>
00062 LeptonTranslatorBase<CLHEP::HepLorentzVector>::~LeptonTranslatorBase()
00063 {
00064 }
00065 
00066 
00067 template<>
00068 Lepjets_Event_Lep
00069 LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton,
00070                                                           int type /* = hitfit::lepton_label */,
00071                                                           bool useObjEmbRes /* = false */)
00072 {
00073 
00074     Fourvec p(lepton.px(),lepton.py(),lepton.pz(),lepton.e());
00075 
00076     double lepton_eta(lepton.eta());
00077     Vector_Resolution lepton_resolution = resolution_.GetResolution(lepton_eta);
00078     Lepjets_Event_Lep retlep(p,
00079                              type,
00080                              lepton_resolution);
00081     return retlep;
00082 
00083 } // Lepjets_Event_Lep LeptonTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& lepton)
00084 
00085 
00086 template<>
00087 const EtaDepResolution&
00088 LeptonTranslatorBase<CLHEP::HepLorentzVector>::resolution() const
00089 {
00090     return resolution_;
00091 }
00092 
00093 
00094 template<>
00095 bool
00096 LeptonTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& lepton) const
00097 {
00098     return resolution_.CheckEta(lepton.eta());
00099 }
00100 
00101 
00102 template<>
00103 JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
00104 {
00105 
00106     std::string CMSSW_BASE(getenv("CMSSW_BASE"));
00107     std::string udsc_resolution_filename = CMSSW_BASE +
00108         std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
00109     std::string b_resolution_filename = udsc_resolution_filename;
00110 
00111     udscResolution_ = EtaDepResolution(udsc_resolution_filename);
00112     bResolution_    = EtaDepResolution(b_resolution_filename);
00113 
00114 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase()
00115 
00116 
00117 template<>
00118 JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,
00119                                                               const std::string& bFile)
00120 {
00121 
00122     std::string CMSSW_BASE(getenv("CMSSW_BASE"));
00123     std::string udsc_resolution_filename;
00124     std::string b_resolution_filename;
00125 
00126     if (udscFile.empty()) {
00127         udsc_resolution_filename = CMSSW_BASE +
00128             std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
00129     } else {
00130         udsc_resolution_filename = udscFile;
00131     }
00132 
00133     if (bFile.empty()) {
00134         b_resolution_filename = CMSSW_BASE +
00135             std::string("/src/TopQuarkAnalysis/TopHitFit/data/exampleJetResolution.txt");
00136     } else {
00137         b_resolution_filename = bFile;
00138     }
00139 
00140     udscResolution_ = EtaDepResolution(udsc_resolution_filename);
00141     bResolution_    = EtaDepResolution(b_resolution_filename);
00142 
00143 } // JetTranslatorBase<CLHEP::HepLorentzVector>::JetTranslatorBase(const std::string& udscFile,const std::string& bFile)
00144 
00145 
00146 template<>
00147 JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
00148 {
00149 } // JetTranslatorBase<CLHEP::HepLorentzVector>::~JetTranslatorBase()
00150 
00151 
00152 template<>
00153 Lepjets_Event_Jet
00154 JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& jet,
00155                                                        int type /* = hitfit::unknown_label */,
00156                                                        bool useObjEmbRes /* = false */)
00157 {
00158 
00159     Fourvec p(jet.px(),jet.py(),jet.pz(),jet.e());
00160 
00161     double            jet_eta        = jet.eta();
00162     Vector_Resolution jet_resolution;
00163 
00164     if (type == hitfit::lepb_label||type == hitfit::hadb_label||type== hitfit::higgs_label) {
00165         jet_resolution = bResolution_.GetResolution(jet_eta);
00166     } else {
00167         jet_resolution = udscResolution_.GetResolution(jet_eta);
00168     }
00169 
00170     Lepjets_Event_Jet retjet(p,
00171                              type,
00172                              jet_resolution);
00173     return retjet;
00174 
00175 } // Lepjets_Event_Jet JetTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& j,int type)
00176 
00177 
00178 template<>
00179 const EtaDepResolution&
00180 JetTranslatorBase<CLHEP::HepLorentzVector>::udscResolution() const
00181 {
00182     return udscResolution_;
00183 }
00184 
00185 
00186 template<>
00187 const EtaDepResolution&
00188 JetTranslatorBase<CLHEP::HepLorentzVector>::bResolution() const
00189 {
00190     return bResolution_;
00191 }
00192 
00193 
00194 template<>
00195 bool
00196 JetTranslatorBase<CLHEP::HepLorentzVector>::CheckEta(const CLHEP::HepLorentzVector& jet) const
00197 {
00198     return udscResolution_.CheckEta(jet.eta()) && bResolution_.CheckEta(jet.eta());
00199 }
00200 
00201 
00202 template<>
00203 METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
00204 {
00205     resolution_ = Resolution(std::string("0,0,12"));
00206 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase()
00207 
00208 
00209 template<>
00210 METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
00211 {
00212     const Defaults_Text defs(ifile);
00213     std::string resolution_string(defs.get_string("met_resolution"));
00214     resolution_ = Resolution(resolution_string);
00215 
00216 } // METTranslatorBase<CLHEP::HepLorentzVector>::METTranslatorBase(const std::string& ifile)
00217 
00218 
00219 template<>
00220 METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
00221 {
00222 } // METTranslatorBase<CLHEP::HepLorentzVector>::~METTranslatorBase()
00223 
00224 
00225 template<>
00226 Fourvec
00227 METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m,
00228                                                        bool useObjEmbRes /* = false */)
00229 {
00230 
00231     return Fourvec (m.px(),m.py(),0.0,m.e());
00232 
00233 } // Fourvec METTranslatorBase<CLHEP::HepLorentzVector>::operator()(const CLHEP::HepLorentzVector& m)
00234 
00235 
00236 
00237 template<>
00238 Resolution
00239 METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m,
00240                                                          bool useObjEmbRes /* = false */) const
00241 {
00242     return resolution_;
00243 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::KtResolution(const CLHEP::HepLorentzVector& m)
00244 
00245 
00246 
00247 template<>
00248 Resolution
00249 METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m,
00250                                                           bool useObjEmbRes /* = false */) const
00251 {
00252     return KtResolution(m,useObjEmbRes);
00253 } // Resolution METTranslatorBase<CLHEP::HepLorentzVector>::METResolution(const CLHEP::HepLorentzVector& m)
00254 
00255 
00256 } // namespace hitfit