From 964685bbdb36cc8956ae0fe7be953b8f483ed72d Mon Sep 17 00:00:00 2001
From: Claudia Merlassino <claudia.merlassino@cern.ch>
Date: Wed, 19 May 2021 12:02:00 +0100
Subject: [PATCH] new cdi and MC/MC SF

---
 .../SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx       |  3 +--
 .../SUSYPhys/SUSYTools/Root/SUSYToolsInit.cxx         | 11 ++++++++++-
 .../SUSYTools/SUSYTools/ISUSYObjDef_xAODTool.h        |  7 +++++--
 .../SUSYPhys/SUSYTools/data/SUSYTools_Default.conf    |  3 ++-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx b/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx
index 669f146f1c8a..133f8adf1513 100644
--- a/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx
+++ b/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYObjDef_xAOD.cxx
@@ -1434,8 +1434,7 @@ StatusCode SUSYObjDef_xAOD::readConfig()
   configFromFile(m_BtagWP, "Btag.WP", rEnv, "FixedCutBEff_77");
   configFromFile(m_BtagMinPt, "Btag.MinPt", rEnv, -1.); // Not calibrated below 20
   configFromFile(m_BtagTimeStamp, "Btag.TimeStamp", rEnv, "201810", true);
-  
-  configFromFile(m_bTaggingCalibrationFilePath, "Btag.CalibPath", rEnv, "xAODBTaggingEfficiency/13TeV/2020-21-13TeV-MC16-CDI-2020-03-11_v3.root");
+  configFromFile(m_bTaggingCalibrationFilePath, "Btag.CalibPath", rEnv, "xAODBTaggingEfficiency/13TeV/2020-21-13TeV-MC16-CDI-2021-04-16_v1.root");
   configFromFile(m_BtagSystStrategy, "Btag.SystStrategy", rEnv, "Envelope");
 
   configFromFile(m_useBtagging_trkJet, "BtagTrkJet.enable", rEnv, true);
diff --git a/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYToolsInit.cxx b/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYToolsInit.cxx
index 49718a1debb5..8d04635770fb 100644
--- a/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYToolsInit.cxx
+++ b/PhysicsAnalysis/SUSYPhys/SUSYTools/Root/SUSYToolsInit.cxx
@@ -1512,8 +1512,11 @@ StatusCode SUSYObjDef_xAOD::SUSYToolsInit()
   std::string MCshowerID = "410470";                 // Powheg+Pythia8 (default)
   if (m_showerType == 1) MCshowerID = "410558";      // Powheg+Herwig7
   else if (m_showerType == 2) MCshowerID = "426131"; // Sherpa 2.1
-  else if (m_showerType == 3) MCshowerID = "410250"; // Sherpa 2.2
+  else if (m_showerType == 3) MCshowerID = "410250"; // Sherpa 221 or 222
   else if (m_showerType == 4) MCshowerID = "410464"; // aMC@NLO+Pythia8
+  else if (m_showerType == 5) MCshowerID = "421152"; // Sherpa 228
+  else if (m_showerType == 6) MCshowerID = "700122"; // Sherpa 228
+
 
   // btagEfficiencyTool
   if (m_useBtagging && !m_btagEffTool.isUserConfigured() && !m_BtagWP.empty()) {
@@ -1528,6 +1531,12 @@ StatusCode SUSYObjDef_xAOD::SUSYToolsInit()
       jetcollBTag = "AntiKt4EMTopoJets";
     }
 
+    // AntiKt4EMTopoJets MC/MC SF doesn't support sherpa 2.2.8 and sherpa 2.2.10
+    if (jetcollBTag == "AntiKt4EMTopoJets" && (MCshowerID == "421152" || MCshowerID == "700122")) { // sherpa 2.1 isn't available
+      ATH_MSG_WARNING ("MC/MC SFs for AntiKt4EMPFlowJets are not available yet! Falling back to Sherpa2.2.1 for the SFs.");
+      MCshowerID == "410250";
+    }
+
     toolName = "BTagSF_" + jetcollBTag + m_BtagTagger + m_BtagWP;
     m_btagEffTool.setTypeAndName("BTaggingEfficiencyTool/"+toolName);
     ATH_CHECK( m_btagEffTool.setProperty("TaggerName",     m_BtagTagger ) );
diff --git a/PhysicsAnalysis/SUSYPhys/SUSYTools/SUSYTools/ISUSYObjDef_xAODTool.h b/PhysicsAnalysis/SUSYPhys/SUSYTools/SUSYTools/ISUSYObjDef_xAODTool.h
index 7e52b1f87e2b..887aa46c6906 100644
--- a/PhysicsAnalysis/SUSYPhys/SUSYTools/SUSYTools/ISUSYObjDef_xAODTool.h
+++ b/PhysicsAnalysis/SUSYPhys/SUSYTools/SUSYTools/ISUSYObjDef_xAODTool.h
@@ -162,7 +162,7 @@ namespace ST {
   static inline int getMCShowerType(const std::string& sample_name) {
     /** Get MC generator index for the b-tagging efficiency maps*/
     // This needs VERY careful syncing with m_showerType in SUSYToolsInit!  Change with care!
-    const static std::vector<TString> gen_mc_generator_keys = {"PYTHIA8EVTGEN", "HERWIG", "SHERPA_CT", "SHERPA", "AMCATNLO"};
+    const static std::vector<TString> gen_mc_generator_keys = {"HERWIG", "SHERPA_CT", "SHERPA", "AMCATNLO", "SH_228", "SH_2210"};
     //This was the 20.7 vector... {"PYTHIAEVTGEN", "HERWIGPPEVTGEN", "PYTHIA8EVTGEN", "SHERPA_CT10", "SHERPA"};
 
     //pre-process sample name
@@ -170,6 +170,8 @@ namespace ST {
     tmp_name.ReplaceAll("Py8EG","PYTHIA8EVTGEN");
     if(tmp_name.Contains("Pythia") && !tmp_name.Contains("Pythia8") && !tmp_name.Contains("EvtGen")) tmp_name.ReplaceAll("Pythia","PYTHIA8EVTGEN");
     if(tmp_name.Contains("Pythia8") && !tmp_name.Contains("EvtGen")) tmp_name.ReplaceAll("Pythia8","PYTHIA8EVTGEN");
+    if(tmp_name.Contains("Py8") && !tmp_name.Contains("EG")) tmp_name.ReplaceAll("Py8","PYTHIA8EVTGEN");
+    if(tmp_name.Contains("H7")) tmp_name.ReplaceAll("H7","HERWIG");
 
     //capitalize the entire sample name
     tmp_name.ToUpper();
@@ -177,9 +179,10 @@ namespace ST {
     //find shower type in name
     unsigned int ishower = 0;
     for( const auto & gen : gen_mc_generator_keys ){
-      if( tmp_name.Contains(gen) ){ return ishower; }
+      if( tmp_name.Contains(gen) ){ return ishower+1; }
       ishower++;
     }
+    if( tmp_name.Contains("PYTHIA8EVTGEN") ) return 0;
 
     // See if they are doing something really unwise, just in case
     TRegexp is_data("^data1[5-9]_13TeV");
diff --git a/PhysicsAnalysis/SUSYPhys/SUSYTools/data/SUSYTools_Default.conf b/PhysicsAnalysis/SUSYPhys/SUSYTools/data/SUSYTools_Default.conf
index 4de22173c11b..6607167d9ba0 100644
--- a/PhysicsAnalysis/SUSYPhys/SUSYTools/data/SUSYTools_Default.conf
+++ b/PhysicsAnalysis/SUSYPhys/SUSYTools/data/SUSYTools_Default.conf
@@ -53,7 +53,8 @@ Tau.Id: Medium
 Jet.Pt: 20000.
 Jet.Eta: 2.8
 Jet.InputType: 9 # EMTopo 1, PFlow: 9. PFlow is new recommended for everything beyond Winter.  
-Jet.UncertConfig: rel21/Summer2019/R4_CategoryReduction_SimpleJER.config # This is the uncertainty for analyses going to perform combinations. Otherwise rel21/Summer2019/R4_SR_Scenario1_SimpleJER.conf can be used if insensitive to JES. If you are wanting to do the fullJER (with PDSmear) please use : rel21/Summer2019/R4_CategoryReduction_FullJER.config and PDSmearing below set to true).
+Jet.UncertConfig: rel21/Summer2019/R4_CategoryReduction_SimpleJER.config # This is the uncertainty for analyses going to perform combinations. Otherwise rel21/Summer2019/R4_SR_Scenario1_SimpleJER.conf can be used if insensitive to JES. If you are wanting to do the fullJER (with PDSmear) please use : rel21/Summer2019/R4_CategoryReduction_FullJER.config and PDSmearing below set to true). If your analysis is sensitive to small-R jet masses, please use rel21/Spring2021/R4_JMS_frozen.config, where XX is your JER and JES configuration. For example: rel21/Spring2021/R4_CategoryReduction_FullJER_JMS_frozen.config 
+
 Jet.JvtWP: Default # EMTopo recommended = Default (= Medium), PFlow recommended = Default (= Tight)
 Jet.JvtPtMax: 60.0e3
 Jet.JMSCalib: false 
-- 
GitLab