Commit 133a3627 authored by Christopher Andrew Garner's avatar Christopher Andrew Garner Committed by Nils Erik Krumnack
Browse files

Fixes correlations between large- and small-R jet uncertainties. Adds support...

Fixes correlations between large- and small-R jet uncertainties. Adds support for JER (pseudo-)data smearing of large-R jets.
parent 6b8c4f59
......@@ -235,6 +235,9 @@ namespace top {
registerParameter("JetJERSmearingModel",
"All (inc. data smearing), All_PseudoData (use MC as pseudo-data), Full (inc. data smearing), Full_PseudoData (use MC as pseudo-data) or Simple (MC only - default)",
"Simple");
registerParameter("LargeRSysts_TreatMCasPseudodata",
"If set to True, treat MC as pseudo-data; only apply JER smearing, and only when FullJER/AllJER is specified with LargeRJetUncertainties_JESJERJMS_NPModel.",
"False",{"True", "False"});
registerParameter("JetCalibSequence", "Jet calibaration sequence.", "GSC", {"GSC", "JMS"});
registerParameter("AllowJMSforAFII", "Enable use of UNSUPPORTED small-R jet JMS calibration use on AFII samples.", "False", {"True", "False"});
registerParameter("StoreJetTruthLabels", "Flag to store truth labels for jets - True (default) or False", "True");
......
......@@ -263,6 +263,7 @@ namespace top {
m_jetUncertainties_QGHistPatterns(),
m_doMultipleJES(false),
m_jetJERSmearingModel("Simple"),
m_largeRSysts_TreatMCasPseudodata(false),
m_jetCalibSequence("GSC"),
m_allowSmallRJMSforAFII(false),
m_jetStoreTruthLabels("True"),
......@@ -1361,6 +1362,11 @@ namespace top {
this->jetUncertainties_QGFracFile(settings->value("JetUncertainties_QGFracFile"));
this->jetUncertainties_QGHistPatterns(settings->value("JetUncertainties_QGHistPatterns"));
this->jetJERSmearingModel(settings->value("JetJERSmearingModel"));
if (settings->value("LargeRSysts_TreatMCasPseudodata") == "False") {
this->largeRSysts_TreatMCasPseudodata(false);
} else if (settings->value("LargeRSysts_TreatMCasPseudodata") == "True") {
this->largeRSysts_TreatMCasPseudodata(true);
}
this->jetCalibSequence(settings->value("JetCalibSequence"));
this->allowSmallRJMSforAFII(settings->value("AllowJMSforAFII") == "True");
this->doJVTinMET(settings->retrieve("JVTinMETCalculation"));
......
......@@ -1401,9 +1401,7 @@ namespace top {
inline bool doMultipleJES() const {return m_doMultipleJES;}
inline virtual const std::string& jetUncertainties_NPModel() const {return m_jetUncertainties_NPModel;}
inline virtual const std::string& jetUncertainties_QGFracFile() const {return m_jetUncertainties_QGFracFile;}
inline virtual const std::vector<std::string>& jetUncertainties_QGHistPatterns() const {
return m_jetUncertainties_QGHistPatterns;
}
inline virtual const std::vector<std::string>& jetUncertainties_QGHistPatterns() const {return m_jetUncertainties_QGHistPatterns;}
inline virtual void jetJERSmearingModel(const std::string& s) {
if (!m_configFixed) {
......@@ -1413,6 +1411,14 @@ namespace top {
inline virtual const std::string& jetJERSmearingModel() const {return m_jetJERSmearingModel;}
inline virtual void largeRSysts_TreatMCasPseudodata(const bool& b) {
if (!m_configFixed) {
m_largeRSysts_TreatMCasPseudodata = b;
}
}
inline virtual bool largeRSysts_TreatMCasPseudodata() const {return m_largeRSysts_TreatMCasPseudodata;}
inline virtual void jetCalibSequence(const std::string& s) {
if (!m_configFixed) {
m_jetCalibSequence = s;
......@@ -2399,6 +2405,7 @@ namespace top {
// more flexibility
bool m_doMultipleJES;
std::string m_jetJERSmearingModel; // Full or Simple
bool m_largeRSysts_TreatMCasPseudodata; // True or False
std::string m_jetCalibSequence; // GCC or JMS
bool m_allowSmallRJMSforAFII; // JMS is not supported on AFII so we crash, unless people override this option
bool m_jetStoreTruthLabels; // True or False
......
......@@ -24,9 +24,9 @@ namespace top {
JetObjectCollectionMaker::JetObjectCollectionMaker(const std::string& name) :
asg::AsgTool(name),
m_config(nullptr),
m_doJER(false),
m_doFull_JER(false),
m_doFull_JER_Pseudodata(false),
m_doOnly_JER_largeR(false),
m_isMC(false),
m_doMultipleJES(false),
......@@ -103,21 +103,25 @@ namespace top {
m_truthJetCollForHS = "AntiKt4TruthDressedWZJets";
}
///-- JER uncertainties model --///
///-- Small-R JER (Pseudo-)Data Smearing Config --///
if (m_config->jetJERSmearingModel() == "Full" || m_config->jetJERSmearingModel() == "All") m_doFull_JER = true;
if (m_config->jetJERSmearingModel() == "Simple") m_doFull_JER = false;
if (m_config->jetJERSmearingModel() == "Full_PseudoData" ||
m_config->jetJERSmearingModel() == "All_PseudoData") m_doFull_JER_Pseudodata = true;
else m_doFull_JER_Pseudodata = false;
///-- Large-R JER (Pseudo-)Data Smearing Config --///
if ((!m_config->isMC() || m_config->largeRSysts_TreatMCasPseudodata())
&& (m_config->largeRJetUncertainties_NPModel()).find("_SimpleJER_") == std::string::npos) m_doOnly_JER_largeR = true;
else m_doOnly_JER_largeR = false;
bool skip_systs = false;
if (m_config->largeRSysts_TreatMCasPseudodata()
&& (m_config->largeRJetUncertainties_NPModel()).find("_SimpleJER_") != std::string::npos) skip_systs = true;
m_isMC = m_config->isMC();
m_doMultipleJES = m_config->doMultipleJES();
///-- Are we doing JER? Let's not repeat this logic over and over --///
if (m_isMC) m_doJER = true;
if (!m_isMC && m_doFull_JER) m_doJER = true;
/// NB: for "Full_PseudoData", no need to smear the data, so m_doJER is false on data unless it's "Full"
if (m_isMC || m_doFull_JER) {
if (!m_doMultipleJES) {
......@@ -139,10 +143,6 @@ namespace top {
}
top::check(m_jetUpdateJvtTool.retrieve(), "Failed to retrieve JetUpdateJvtTool");
//fJVT tool isn't setup unless requested
if (m_config->doForwardJVTinMET() || m_config->getfJVTWP() != "None") {
......@@ -181,7 +181,7 @@ namespace top {
///-- JES systematics --///
if (m_isMC || m_doFull_JER) {
std::string allNP(m_config->jetUncertainties_NPModel() + "_"),
std::string allNP(""),
np1("SR_Scenario1_"), np2("SR_Scenario2_"), np3("SR_Scenario3_"), np4("SR_Scenario4_");
bool onlyJER = ((!m_isMC) && m_doFull_JER) || (m_isMC && m_doFull_JER_Pseudodata);
......@@ -205,24 +205,15 @@ namespace top {
}
///-- Large-R JES systematics --///
std::string largeRModName = getLargeRModName(m_config->largeRJetUncertainties_NPModel());
std::string largeRModNameJMR = getLargeRModName(m_config->largeRJetUncertainties_JMR_NPModel());
///-- Large-R JES/JER/JMS/JMR systematics --///
CP::SystematicSet largeRsysts;
if (m_config->useLargeRJets() && m_config->isMC()) { //No JES uncertainties for Data at the moment
if ((m_config->largeRJESJMSConfig() == "CombMass") || (m_config->largeRJESJMSConfig() == "TCCMass")) { //TA mass
// and
// combined
// mass not
// supported
// for
// JMS/JMR
// for now
if ((m_config->isMC() || m_doOnly_JER_largeR) && m_config->useLargeRJets()) {
if (m_config->largeRJESJMSConfig() == "CombMass") { // Only CombMass is supported for large-R JES/JER/JMS/JMR systematics at the moment
largeRsysts.insert(m_jetUncertaintiesToolLargeR->recommendedSystematics());
largeRsysts.insert(m_FFJetSmearingTool->recommendedSystematics());
} else {
ATH_MSG_WARNING(
"TA Mass & Calo Mass & UFO SD Mass are not supported for large-R jet uncertainties at the moment. Large-R jet systemtatics skipped!");
"TA Mass & Calo Mass & TCCMass & UFO SD Mass are not supported for large-R jet uncertainties at the moment. Large-R jet systemtatics skipped!");
}
}
......@@ -265,8 +256,10 @@ namespace top {
// add the merged set of systematics for large-R jets including the tagging SF systs
addSystematics(systLargeR, largeRsysts, m_systMap_LargeR, largeRModName, true, false, largeRModNameJMR);
if ((m_config->isMC() || m_doOnly_JER_largeR) && (m_config->useLargeRJets()) && (!skip_systs)) {
std::string allNPlargeR("");
addSystematics(systLargeR, largeRsysts, m_systMap_LargeR, allNPlargeR, true, m_doOnly_JER_largeR);
}
///-- Large R jet substructure --///
if (m_config->jetSubstructureName() == "Trimmer") m_jetSubstructure.reset(new top::LargeJetTrimmer);
......@@ -384,7 +377,7 @@ namespace top {
// tag calibrated (nominal) jets -- the tagging information will be available
// for systematically-shifted shallow copies as well
top::check(tagNominalLargeRJets(), "Failed to tag large-R jets");
if (m_config->isMC()) {
if (m_isMC || m_doOnly_JER_largeR) {
top::check(applyTaggingSFSystematic(),"Failed to apply large-R tagging SFs syst.");
top::check(applySystematic(m_jetUncertaintiesToolLargeR, m_systMap_LargeR,
true), "Failed to apply large-R syst.");
......@@ -649,8 +642,8 @@ namespace top {
///-- Only large R jets with the following properties can be calibrated.--///
bool calibratable_jet = (std::fabs(jet->eta()) <= 2.0
&& jet->pt() > 175e3 //lower than 200e3 to allow studying on migration
&& jet->pt() < 3000e3
&& jet->m() < 600e3);
&& jet->pt() < 6500e3
&& jet->m() < 700e3);
std::string jetCalibrationNameLargeR = m_config->sgKeyLargeRJets();
if (jetCalibrationNameLargeR.find("TrackCaloCluster") != std::string::npos) { //TCC jet
calibratable_jet = (jet->m() / jet->pt() <= 1.
......@@ -678,10 +671,8 @@ namespace top {
///-- Apply Corrrection --///
if (!(isLargeR && !m_config->isMC())) { //Large-R jet uncertainties don't apply to Data
if (!isJMR) top::check(tool->applyCorrection(*jet), "Failed to applyCorrection");
else top::check(m_FFJetSmearingTool->applyCorrection(*jet), "Failed to applyCorrection");
}
if (!isJMR) top::check(tool->applyCorrection(*jet), "Failed to applyCorrection");
else top::check(m_FFJetSmearingTool->applyCorrection(*jet), "Failed to applyCorrection");
///-- Update JVT --///
......@@ -806,7 +797,7 @@ namespace top {
void JetObjectCollectionMaker::addSystematics(const std::set<std::string>& specifiedSystematics,
const CP::SystematicSet& recommendedSysts,
std::unordered_map<CP::SystematicSet, CP::SystematicSet>& map,
const std::string& modName, bool isLargeR, bool onlyJER, std::string modNameJMR) {
const std::string& modName, bool isLargeR, bool onlyJER) {
///-- Get the recommended systematics from the tool, in std::vector format --///
const std::vector<CP::SystematicSet> systList = CP::make_systematics_vector(recommendedSysts);
......@@ -814,13 +805,12 @@ namespace top {
for (const CP::SystematicSet& s : systList) {
if (s.size() == 1) {
CP::SystematicSet::const_iterator ss = s.begin();
std::string nameMod = modName; ///
if (ss->name().find("JMR") != std::string::npos) nameMod = modNameJMR;
if(!m_config->getTreeFilter()->filterTree(nameMod + ss->name())) continue; // Applying tree filter
if(!m_config->getTreeFilter()->filterTree(modName + ss->name())) continue; // Applying tree filter
if (onlyJER && ss->name().find("JER") == std::string::npos) continue;
CP::SystematicSet modSet(nameMod + ss->name());
CP::SystematicSet modSet(modName + ss->name());
m_recommendedSystematics.push_back(modSet);
if (!m_config->isSystNominal(m_config->systematics())) {
......
......@@ -94,7 +94,7 @@ namespace top {
const CP::SystematicSet& recommendedSysts, std::unordered_map<CP::SystematicSet,
CP::SystematicSet>& map,
const std::string& modName, bool isLargeR = false,
bool onlyJER = false, std::string modNameJMR = "SimpleJMR_");
bool onlyJER = false);
StatusCode execute(const bool isLargeR, bool executeNominal);
......@@ -110,9 +110,9 @@ namespace top {
private:
std::shared_ptr<top::TopConfig> m_config;
bool m_doJER;
bool m_doFull_JER;
bool m_doFull_JER_Pseudodata;
bool m_doOnly_JER_largeR;
bool m_isMC;
bool m_doMultipleJES;
bool m_do_fjvt = false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment