Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-04 22:55:07

0001 /**
0002     @file PatJetHitFitTranslator.cc
0003 
0004     @brief Specialization of template class JetTranslatorBase in the
0005     package HitFit
0006 
0007     @author Haryo Sumowidagdo <Suharyo.Sumowidagdo@cern.ch>
0008 
0009     @par Created
0010     Sat Jun 27 17:49:21 2009 UTC
0011 
0012     @version $Id: PatJetHitFitTranslator.cc,v 1.2 2011/05/26 12:57:18 mseidel Exp $
0013  */
0014 
0015 #include <TopQuarkAnalysis/TopHitFit/interface/JetTranslatorBase.h>
0016 #include <DataFormats/PatCandidates/interface/Jet.h>
0017 
0018 namespace hitfit {
0019 
0020   template <>
0021   JetTranslatorBase<pat::Jet>::JetTranslatorBase() {
0022     [[clang::suppress]]
0023     std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0024     std::string resolution_filename =
0025         CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0026     udscResolution_ = EtaDepResolution(resolution_filename);
0027     bResolution_ = EtaDepResolution(resolution_filename);
0028     jetCorrectionLevel_ = "L7Parton";
0029     jes_ = 1.0;
0030     jesB_ = 1.0;
0031 
0032   }  // JetTranslatorBase<pat::Jet>::JetTranslatorBase()
0033 
0034   template <>
0035   JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& udscFile, const std::string& bFile) {
0036     [[clang::suppress]]
0037     std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0038     std::string udscResolution_filename;
0039     std::string bResolution_filename;
0040 
0041     if (udscFile.empty()) {
0042       udscResolution_filename =
0043           CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0044     } else {
0045       udscResolution_filename = udscFile;
0046     }
0047 
0048     if (bFile.empty()) {
0049       bResolution_filename = CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0050     } else {
0051       bResolution_filename = bFile;
0052     }
0053 
0054     udscResolution_ = EtaDepResolution(udscResolution_filename);
0055     bResolution_ = EtaDepResolution(bResolution_filename);
0056     jetCorrectionLevel_ = "L7Parton";
0057     jes_ = 1.0;
0058     jesB_ = 1.0;
0059 
0060   }  // JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& ifile)
0061 
0062   template <>
0063   JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& udscFile,
0064                                                  const std::string& bFile,
0065                                                  const std::string& jetCorrectionLevel,
0066                                                  double jes,
0067                                                  double jesB) {
0068     [[clang::suppress]]
0069     std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0070     std::string udscResolution_filename;
0071     std::string bResolution_filename;
0072 
0073     if (udscFile.empty()) {
0074       udscResolution_filename =
0075           CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/resolution/tqafUdscJetResolution.txt");
0076     } else {
0077       udscResolution_filename = udscFile;
0078     }
0079 
0080     if (bFile.empty()) {
0081       bResolution_filename =
0082           CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/resolution/tqafBJetResolution.txt");
0083     } else {
0084       bResolution_filename = bFile;
0085     }
0086 
0087     udscResolution_ = EtaDepResolution(udscResolution_filename);
0088     bResolution_ = EtaDepResolution(bResolution_filename);
0089     jetCorrectionLevel_ = jetCorrectionLevel;
0090     jes_ = jes;
0091     jesB_ = jesB;
0092 
0093   }  // JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& ifile)
0094 
0095   template <>
0096   JetTranslatorBase<pat::Jet>::~JetTranslatorBase() {}  // JetTranslatorBase<pat::Jet>::~JetTranslatorBase()
0097 
0098   template <>
0099   Lepjets_Event_Jet JetTranslatorBase<pat::Jet>::operator()(const pat::Jet& jet,
0100                                                             int type /*= hitfit::unknown_label */,
0101                                                             bool useObjEmbRes /* = false */) {
0102     Fourvec p;
0103 
0104     double jet_eta = jet.eta();
0105 
0106     if (jet.isCaloJet()) {
0107       jet_eta = static_cast<const reco::CaloJet*>(jet.originalObject())->detectorP4().eta();
0108     }
0109     if (jet.isPFJet()) {
0110       // do nothing at the moment!
0111     }
0112 
0113     Vector_Resolution jet_resolution;
0114 
0115     if (type == hitfit::hadb_label || type == hitfit::lepb_label || type == hitfit::higgs_label) {
0116       jet_resolution = bResolution_.GetResolution(jet_eta);
0117       pat::Jet bPartonCorrJet(jet.correctedJet(jetCorrectionLevel_, "BOTTOM"));
0118       bPartonCorrJet.scaleEnergy(jesB_);
0119       p = Fourvec(bPartonCorrJet.px(), bPartonCorrJet.py(), bPartonCorrJet.pz(), bPartonCorrJet.energy());
0120 
0121     } else {
0122       jet_resolution = udscResolution_.GetResolution(jet_eta);
0123       pat::Jet udsPartonCorrJet(jet.correctedJet(jetCorrectionLevel_, "UDS"));
0124       udsPartonCorrJet.scaleEnergy(jes_);
0125       p = Fourvec(udsPartonCorrJet.px(), udsPartonCorrJet.py(), udsPartonCorrJet.pz(), udsPartonCorrJet.energy());
0126     }
0127 
0128     Lepjets_Event_Jet retjet(p, type, jet_resolution);
0129     return retjet;
0130 
0131   }  // Lepjets_Event_Jet JetTranslatorBase<pat::Jet>::operator()(const pat::Jet& j,int type)
0132 
0133   template <>
0134   const EtaDepResolution& JetTranslatorBase<pat::Jet>::udscResolution() const {
0135     return udscResolution_;
0136   }
0137 
0138   template <>
0139   const EtaDepResolution& JetTranslatorBase<pat::Jet>::bResolution() const {
0140     return bResolution_;
0141   }
0142 
0143   template <>
0144   bool JetTranslatorBase<pat::Jet>::CheckEta(const pat::Jet& jet) const {
0145     double jet_eta = jet.eta();
0146 
0147     if (jet.isCaloJet()) {
0148       jet_eta = static_cast<const reco::CaloJet*>(jet.originalObject())->detectorP4().eta();
0149     }
0150     if (jet.isPFJet()) {
0151       // do nothing at the moment!
0152     }
0153     return bResolution_.CheckEta(jet_eta) && udscResolution_.CheckEta(jet_eta);
0154   }
0155 
0156   //
0157 
0158 }  // namespace hitfit