Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:18

0001 //
0002 //
0003 
0004 /**
0005     @file PatElectronHitFitTranslator.cc
0006 
0007     @brief Specialization of template class LeptonTranslatorBase in the
0008     package HitFit for pat::Electron.
0009 
0010     @author Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
0011 
0012     @par Created
0013     Sat Jun 27 17:49:06 2009 UTC
0014 
0015     @version $Id: PatElectronHitFitTranslator.cc,v 1.8 2010/08/06 22:02:52 haryo Exp $
0016  */
0017 
0018 #include "TopQuarkAnalysis/TopHitFit/interface/LeptonTranslatorBase.h"
0019 #include "DataFormats/PatCandidates/interface/Electron.h"
0020 
0021 namespace hitfit {
0022 
0023   template <>
0024   LeptonTranslatorBase<pat::Electron>::LeptonTranslatorBase() {
0025     std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0026     std::string resolution_filename =
0027         CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleElectronResolution.txt");
0028     resolution_ = EtaDepResolution(resolution_filename);
0029 
0030   }  // LeptonTranslatorBase<pat::Electron>::LeptonTranslatorBase()
0031 
0032   template <>
0033   LeptonTranslatorBase<pat::Electron>::LeptonTranslatorBase(const std::string& ifile) {
0034     std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0035     std::string resolution_filename;
0036 
0037     if (ifile.empty()) {
0038       resolution_filename =
0039           CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleElectronResolution.txt");
0040     } else {
0041       resolution_filename = ifile;
0042     }
0043 
0044     resolution_ = EtaDepResolution(resolution_filename);
0045 
0046   }  // LeptonTranslatorBase<pat::Electron>::LeptonTranslatorBase(const std::string& ifile)
0047 
0048   template <>
0049   LeptonTranslatorBase<pat::Electron>::~LeptonTranslatorBase() {}
0050 
0051   template <>
0052   Lepjets_Event_Lep LeptonTranslatorBase<pat::Electron>::operator()(const pat::Electron& lepton,
0053                                                                     int type /* = hitfit::lepton_label */,
0054                                                                     bool useObjEmbRes /* = false */) {
0055     Fourvec p(lepton.px(), lepton.py(), lepton.pz(), lepton.energy());
0056 
0057     double electron_eta = lepton.superCluster()->eta();
0058     Vector_Resolution electron_resolution = resolution_.GetResolution(electron_eta);
0059 
0060     Lepjets_Event_Lep electron(p, electron_label, electron_resolution);
0061     return electron;
0062 
0063   }  // Lepjets_Event_Lep LeptonTranslatorBase<pat::Electron>::operator()
0064 
0065   template <>
0066   const EtaDepResolution& LeptonTranslatorBase<pat::Electron>::resolution() const {
0067     return resolution_;
0068   }
0069 
0070   template <>
0071   bool LeptonTranslatorBase<pat::Electron>::CheckEta(const pat::Electron& lepton) const {
0072     double electron_eta = lepton.superCluster()->eta();
0073     return resolution_.CheckEta(electron_eta);
0074   }
0075 
0076 }  // namespace hitfit