double BTagWeight::getUDSGScaleFactor(const Jet& jet) const { double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); double eta = jet.eta(); double SF_udsg_mean(0), SF_udsg_min(0), SF_udsg_max(0); if (pt < 20) { return 0; } else if (pt > 800) { SF_udsg_mean = getMeanUDSGScaleFactor(800., eta); SF_udsg_min = getMinUDSGScaleFactor(800, eta); SF_udsg_max = getMaxUDSGScaleFactor(800, eta); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta); SF_udsg_min = getMinUDSGScaleFactor(pt, eta); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta); } if (LightJetSystematic_ == -1) return SF_udsg_min; else if (LightJetSystematic_ == 1) return SF_udsg_max; return SF_udsg_mean; }
double BTagWeight::getUDSGScaleFactor(const Jet& jet, std::string MCSampleTag) const { double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); double eta = jet.eta(); double SF_udsg_mean(0), SF_udsg_min(0), SF_udsg_max(0); if (MCSampleTag == "Summer12") { // 2012 if (pt < 20) { return 0; } else if (pt > 850 && eta >= 1.6 && eta <= 2.4) { SF_udsg_mean = getMeanUDSGScaleFactor(850., eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(850, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(850, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else if (pt > 1000) { SF_udsg_mean = getMeanUDSGScaleFactor(1000., eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(1000, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(1000, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); } } else if (MCSampleTag == "Summer11Leg") { // 2011 if (pt < 20) { return 0; } else if (pt > 670 && eta >= 0. && eta <= 2.4) { // Use integrated over all eta SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); //use twice the uncertainty SF_udsg_min -= (SF_udsg_mean - SF_udsg_min); SF_udsg_max += (SF_udsg_max - SF_udsg_mean); } else { SF_udsg_mean = getMeanUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_min = getMinUDSGScaleFactor(pt, eta, MCSampleTag); SF_udsg_max = getMaxUDSGScaleFactor(pt, eta, MCSampleTag); } } if (LightJetSystematic_ == -1) { return SF_udsg_min; } else if (LightJetSystematic_ == 1) { return SF_udsg_max; } return SF_udsg_mean; }
double BTagWeight::getBScaleFactor(const Jet& jet, double uncertaintyFactor) const { const boost::array<double, 16> SFb_error = { {0.0554504, 0.0209663, 0.0207019, 0.0230073, 0.0208719, 0.0200453, 0.0264232, 0.0240102, 0.0229375, 0.0184615, 0.0216242, 0.0248119, 0.0465748, 0.0474666, 0.0718173, 0.0717567 } }; const boost::array<double, 16> ptbins = { {20, 30, 40, 50, 60, 70, 80,100, 120, 160, 210, 260, 320, 400, 500, 600 } }; double SFb(0); double sf_error(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); if (pt < 20) { SFb = 0.726981*((1.+(0.253238*20))/(1.+(0.188389*20))); sf_error = 0.12; } else if (pt > 800) { SFb = 0.726981*((1.+(0.253238*800))/(1.+(0.188389*800))); //use twice the uncertainty sf_error = 2 * SFb_error[SFb_error.size() - 1]; } else { SFb = 0.726981*((1.+(0.253238*pt))/(1.+(0.188389*pt))); unsigned int ptbin(0); for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) { double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.; double lowerCut = ptbins.at(bin); if (pt > lowerCut && pt <= upperCut) { ptbin = bin; break; } } sf_error = SFb_error.at(ptbin); } SFb += sf_error * BJetSystematic_ * uncertaintyFactor; return SFb; }
double BTagWeight::getAverageUDSGEfficiency(const JetCollection& jets) const { std::vector<double> efficiencies; for (unsigned int index = 0; index < jets.size(); ++index) { const Jet jet(jets.at(index)); double efficiency(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); if (pt < 20) { continue; } else if (pt > 800) { efficiency = getMeanUDSGEfficiency(800.); } else { efficiency = getMeanUDSGEfficiency(pt); } efficiencies.push_back(efficiency); } double sumOfEfficiencies = std::accumulate(efficiencies.begin(), efficiencies.end(), 0.0); if (efficiencies.size() == 0) return 1.; else return sumOfEfficiencies / efficiencies.size(); }
double BTagWeight::getBScaleFactor(const Jet& jet, std::string MCSampleTag, double uncertaintyFactor) const { double SFb(0); double sf_error(0); //these numbers are for CSVM only double pt = getSmearedJetPtScale(jet, 0)*jet.pt(); double eta = jet.eta(); if (MCSampleTag == "Summer12") { // 2012 btag scale factors // From https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-pt_WITHttbar_payload_EPS13.txt, // which is linked from https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagPOG#2012_Data_and_MC_EPS13_prescript const boost::array<double, 16> SFb_error = { { 0.0415707, 0.0204209, 0.0223227, 0.0206655, 0.0199325, 0.0174121, 0.0202332, 0.0182446, 0.0159777, 0.0218531, 0.0204688, 0.0265191, 0.0313175, 0.0415417, 0.0740446, 0.0596716 } }; //2012 pt bins low edges const boost::array<double, 16> ptbins = { { 20, 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500, 600 } }; if (pt < 20) { SFb = (0.938887 + (0.00017124 * 20)) + (-2.76366e-07 * (20 * 20)); //use twice the uncertainty sf_error = 2 * SFb_error[0]; } else if (pt > 800) { SFb = (0.938887 + (0.00017124 * 800)) + (-2.76366e-07 * (800 * 800)); //use twice the uncertainty sf_error = 2 * SFb_error[SFb_error.size() - 1]; } else { SFb = (0.938887 + (0.00017124 * pt)) + (-2.76366e-07 * (pt * pt)); unsigned int ptbin(0); for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) { double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.; double lowerCut = ptbins.at(bin); if (pt > lowerCut && pt <= upperCut) { ptbin = bin; break; } } sf_error = SFb_error.at(ptbin); //use twice the uncertainty if outside the 0 to 2.4 eta range if (2.4 < eta && eta <= 2.6) { sf_error = 2 * SFb_error.at(ptbin); } } } else if (MCSampleTag == "Summer11Leg") { // 2011 btag scale factors // https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-mujet_payload.txt const boost::array<double, 14> SFb_error = { { 0.0295675, 0.0295095, 0.0210867, 0.0219349, 0.0227033, 0.0204062, 0.0185857, 0.0256242, 0.0383341, 0.0409675, 0.0420284, 0.0541299, 0.0578761, 0.0655432 } }; //2011 pt bins low edges const boost::array<double, 14> ptbins = { { 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500 } }; if (pt < 30) { SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * 30))); //absolute uncertainty of +/-0.12 sf_error = 0.12; } else if (pt > 670) { SFb = 0.6981 * ((1. + (0.414063 * 670)) / (1. + (0.300155 * 670))); //use twice the uncertainty sf_error = 2 * SFb_error[SFb_error.size() - 1]; } else { SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * pt))); unsigned int ptbin(0); for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) { double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 670.; double lowerCut = ptbins.at(bin); if (pt > lowerCut && pt <= upperCut) { ptbin = bin; break; } } sf_error = SFb_error.at(ptbin); } } SFb += sf_error * BJetSystematic_ * uncertaintyFactor; return SFb; }