File indexing completed on 2024-04-06 12:31:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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 std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0023 std::string resolution_filename =
0024 CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0025 udscResolution_ = EtaDepResolution(resolution_filename);
0026 bResolution_ = EtaDepResolution(resolution_filename);
0027 jetCorrectionLevel_ = "L7Parton";
0028 jes_ = 1.0;
0029 jesB_ = 1.0;
0030
0031 }
0032
0033 template <>
0034 JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& udscFile, const std::string& bFile) {
0035 std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0036 std::string udscResolution_filename;
0037 std::string bResolution_filename;
0038
0039 if (udscFile.empty()) {
0040 udscResolution_filename =
0041 CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0042 } else {
0043 udscResolution_filename = udscFile;
0044 }
0045
0046 if (bFile.empty()) {
0047 bResolution_filename = CMSSW_BASE + std::string("/src/TopQuarkAnalysis/PatHitFit/data/exampleJetResolution.txt");
0048 } else {
0049 bResolution_filename = bFile;
0050 }
0051
0052 udscResolution_ = EtaDepResolution(udscResolution_filename);
0053 bResolution_ = EtaDepResolution(bResolution_filename);
0054 jetCorrectionLevel_ = "L7Parton";
0055 jes_ = 1.0;
0056 jesB_ = 1.0;
0057
0058 }
0059
0060 template <>
0061 JetTranslatorBase<pat::Jet>::JetTranslatorBase(const std::string& udscFile,
0062 const std::string& bFile,
0063 const std::string& jetCorrectionLevel,
0064 double jes,
0065 double jesB) {
0066 std::string CMSSW_BASE(std::getenv("CMSSW_BASE"));
0067 std::string udscResolution_filename;
0068 std::string bResolution_filename;
0069
0070 if (udscFile.empty()) {
0071 udscResolution_filename =
0072 CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/resolution/tqafUdscJetResolution.txt");
0073 } else {
0074 udscResolution_filename = udscFile;
0075 }
0076
0077 if (bFile.empty()) {
0078 bResolution_filename =
0079 CMSSW_BASE + std::string("/src/TopQuarkAnalysis/TopHitFit/data/resolution/tqafBJetResolution.txt");
0080 } else {
0081 bResolution_filename = bFile;
0082 }
0083
0084 udscResolution_ = EtaDepResolution(udscResolution_filename);
0085 bResolution_ = EtaDepResolution(bResolution_filename);
0086 jetCorrectionLevel_ = jetCorrectionLevel;
0087 jes_ = jes;
0088 jesB_ = jesB;
0089
0090 }
0091
0092 template <>
0093 JetTranslatorBase<pat::Jet>::~JetTranslatorBase() {}
0094
0095 template <>
0096 Lepjets_Event_Jet JetTranslatorBase<pat::Jet>::operator()(const pat::Jet& jet,
0097 int type ,
0098 bool useObjEmbRes ) {
0099 Fourvec p;
0100
0101 double jet_eta = jet.eta();
0102
0103 if (jet.isCaloJet()) {
0104 jet_eta = static_cast<const reco::CaloJet*>(jet.originalObject())->detectorP4().eta();
0105 }
0106 if (jet.isPFJet()) {
0107
0108 }
0109
0110 Vector_Resolution jet_resolution;
0111
0112 if (type == hitfit::hadb_label || type == hitfit::lepb_label || type == hitfit::higgs_label) {
0113 jet_resolution = bResolution_.GetResolution(jet_eta);
0114 pat::Jet bPartonCorrJet(jet.correctedJet(jetCorrectionLevel_, "BOTTOM"));
0115 bPartonCorrJet.scaleEnergy(jesB_);
0116 p = Fourvec(bPartonCorrJet.px(), bPartonCorrJet.py(), bPartonCorrJet.pz(), bPartonCorrJet.energy());
0117
0118 } else {
0119 jet_resolution = udscResolution_.GetResolution(jet_eta);
0120 pat::Jet udsPartonCorrJet(jet.correctedJet(jetCorrectionLevel_, "UDS"));
0121 udsPartonCorrJet.scaleEnergy(jes_);
0122 p = Fourvec(udsPartonCorrJet.px(), udsPartonCorrJet.py(), udsPartonCorrJet.pz(), udsPartonCorrJet.energy());
0123 }
0124
0125 Lepjets_Event_Jet retjet(p, type, jet_resolution);
0126 return retjet;
0127
0128 }
0129
0130 template <>
0131 const EtaDepResolution& JetTranslatorBase<pat::Jet>::udscResolution() const {
0132 return udscResolution_;
0133 }
0134
0135 template <>
0136 const EtaDepResolution& JetTranslatorBase<pat::Jet>::bResolution() const {
0137 return bResolution_;
0138 }
0139
0140 template <>
0141 bool JetTranslatorBase<pat::Jet>::CheckEta(const pat::Jet& jet) const {
0142 double jet_eta = jet.eta();
0143
0144 if (jet.isCaloJet()) {
0145 jet_eta = static_cast<const reco::CaloJet*>(jet.originalObject())->detectorP4().eta();
0146 }
0147 if (jet.isPFJet()) {
0148
0149 }
0150 return bResolution_.CheckEta(jet_eta) && udscResolution_.CheckEta(jet_eta);
0151 }
0152
0153
0154
0155 }