From 182668827ff1ae9cd279ec03dac435caefdaf594 Mon Sep 17 00:00:00 2001 From: iconnell <ian.connelly@cern.ch> Date: Thu, 6 Sep 2018 16:26:25 +0100 Subject: [PATCH] Adding updates to run systs Former-commit-id: f8c2e6e5d4e900e0028fa2ed3c40ade13c0d67b6 --- .../TopPhys/xAOD/TopCPTools/CMakeLists.txt | 2 - .../xAOD/TopCPTools/Root/TopJetMETCPTools.cxx | 15 +-- .../TopCPTools/TopCPTools/TopJetMETCPTools.h | 2 +- .../Root/JetObjectCollectionMaker.cxx | 120 ++---------------- .../JetObjectCollectionMaker.h | 9 +- 5 files changed, 19 insertions(+), 129 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/CMakeLists.txt b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/CMakeLists.txt index a0d38e5f271..2d37183bf2b 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/CMakeLists.txt +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/CMakeLists.txt @@ -34,7 +34,6 @@ atlas_depends_on_subdirs( PUBLIC JetInterface JetMomentTools JetSelectorTools - JetResolution METInterface METUtilities IsolationSelection @@ -94,7 +93,6 @@ atlas_add_library( TopCPTools Root/*.cxx Root/*.h Root/*.icc JetInterface JetMomentToolsLib JetSelectorToolsLib - JetResolutionLib METInterface METUtilitiesLib IsolationSelectionLib diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopJetMETCPTools.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopJetMETCPTools.cxx index f7d27f2bcdc..fe2e49b60f6 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopJetMETCPTools.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopJetMETCPTools.cxx @@ -20,8 +20,6 @@ #include "JetMomentTools/JetVertexTaggerTool.h" #include "JetMomentTools/JetForwardJvtTool.h" #include "JetSelectorTools/JetCleaningTool.h" -#include "JetResolution/JERTool.h" -#include "JetResolution/JERSmearingTool.h" #include "JetJvtEfficiency/JetJvtEfficiency.h" #include "JetSelectorTools/EventCleaningTool.h" @@ -77,9 +75,6 @@ JetMETCPTools::JetMETCPTools(const std::string& name) : declareProperty( "JetEventCleaningToolLooseBad" , m_jetEventCleaningToolLooseBad ); declareProperty( "JetEventCleaningToolTightBad" , m_jetEventCleaningToolTightBad ); - //declareProperty( "JetJERTool" , m_jetJERTool ); - //declareProperty( "JetJERSmearingTool" , m_jetJERSmearingTool ); - declareProperty( "JETJERUncertaintiesTool", m_jetJERUncertaintiesTool), declareProperty( "JetUpdateJvtTool" , m_jetUpdateJvtTool ); declareProperty( "JES_data2016_data2015_Recommendation_Dec2016.config", m_jetAntiKt4_MCFS_ConfigFile); @@ -433,17 +428,17 @@ StatusCode JetMETCPTools::setupLargeRJetsCalibration() { m_jetUncertaintiesToolLargeR_strong = setupJetUncertaintiesTool("JetUncertaintiesToolLargeR_Strong", - jetCalibrationNameLargeR, MC_type, + jetCalibrationNameLargeR, MC_type, false, configDir+"/"+conference + "/R10_"+largeRJES_config+"_strong.config",variables,"",calibArea); m_jetUncertaintiesToolLargeR_medium = setupJetUncertaintiesTool("JetUncertaintiesToolLargeR_Medium", - jetCalibrationNameLargeR, MC_type, + jetCalibrationNameLargeR, MC_type, false, configDir+"/"+conference + "/R10_"+largeRJES_config+"_medium.config",variables,"",calibArea); m_jetUncertaintiesToolLargeR_weak = setupJetUncertaintiesTool("JetUncertaintiesToolLargeR_Weak", - jetCalibrationNameLargeR, MC_type, + jetCalibrationNameLargeR, MC_type, false, configDir+"/"+conference + "/R10_"+largeRJES_config+"_weak.config",variables,"",calibArea); @@ -534,7 +529,7 @@ ICPJetUncertaintiesTool* JetMETCPTools::setupJetUncertaintiesTool(const std::string& name, const std::string& jet_def, const std::string& mc_type, - const bool& isData, + const bool& isMC, const std::string& config_file, std::vector<std::string>* variables, const std::string& analysis_file, @@ -549,7 +544,7 @@ JetMETCPTools::setupJetUncertaintiesTool(const std::string& name, "Failed to set JetDefinition for " + name); top::check(asg::setProperty(tool, "MCType", mc_type), "Failed to set MCType for " + name); - top::check(asg::setProperty(tool, "IsData", isData), + top::check(asg::setProperty(tool, "IsData", !isMC), "Failed to set IsData (for JER only)"); top::check(asg::setProperty(tool, "ConfigFile", config_file), "Failed to set ConfigFile for " + name); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopJetMETCPTools.h b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopJetMETCPTools.h index e3f899f7e07..bfec8ed5d09 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopJetMETCPTools.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/TopCPTools/TopJetMETCPTools.h @@ -105,7 +105,7 @@ class JetMETCPTools final : public asg::AsgTool { setupJetUncertaintiesTool(const std::string& name, const std::string& jet_def, const std::string& mc_type, - const bool& isData, + const bool& isMC, const std::string& config_file, std::vector<std::string>* variables, const std::string& analysis_file = "", diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/Root/JetObjectCollectionMaker.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/Root/JetObjectCollectionMaker.cxx index d24ab58b242..2656889b663 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/Root/JetObjectCollectionMaker.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/Root/JetObjectCollectionMaker.cxx @@ -47,7 +47,6 @@ JetObjectCollectionMaker::JetObjectCollectionMaker( const std::string& name ) : m_jetUncertaintiesToolLargeR_medium("JetUncertaintiesToolLargeR_Medium"), m_jetUncertaintiesToolLargeR_weak("JetUncertaintiesToolLargeR_Weak"), - m_jetJERSmearingTool("JetJERSmearingTool"), m_jetUpdateJvtTool("JetUpdateJvtTool"), m_fjvtTool("fJVTTool"), @@ -59,8 +58,7 @@ JetObjectCollectionMaker::JetObjectCollectionMaker( const std::string& name ) : m_systMap_ReducedNPScenario2(), m_systMap_ReducedNPScenario3(), m_systMap_ReducedNPScenario4(), - m_systMap_LargeR_strong(), - m_systMap_JER() + m_systMap_LargeR_strong() { declareProperty( "config" , m_config ); @@ -75,7 +73,6 @@ JetObjectCollectionMaker::JetObjectCollectionMaker( const std::string& name ) : declareProperty( "JetUncertaintiesToolReducedNPScenario3" , m_jetUncertaintiesToolReducedNPScenario3 ); declareProperty( "JetUncertaintiesToolReducedNPScenario4" , m_jetUncertaintiesToolReducedNPScenario4 ); - declareProperty( "JetJERSmearingTool" , m_jetJERSmearingTool ); declareProperty( "JetUpdateJvtTool" , m_jetUpdateJvtTool ); declareProperty( "TruthJetCollectionForHSTagging" , m_truthJetCollForHS = "AntiKt4TruthJets" ); @@ -108,7 +105,7 @@ StatusCode JetObjectCollectionMaker::initialize() { // don't have any uncertainties so skip the retrieval. if (!m_config->useParticleFlowJets()) { ///-- JER uncertainties model --/// - if (m_config->jetJERSmearingModel() == "Full") + if (m_config->jetJERSmearingModel() == "Full" || m_config->jetJERSmearingModel() == "All") m_doFull_JER = true; if (m_config->jetJERSmearingModel() == "Simple") m_doFull_JER = false; @@ -123,9 +120,9 @@ StatusCode JetObjectCollectionMaker::initialize() { if (m_config->isMC()) { if (!m_config->doMultipleJES()) { - top::check( m_jetUncertaintiesTool.retrieve() , "Failed to retrieve JetUncertaintiesToolAllNP" ); + top::check( m_jetUncertaintiesTool.retrieve() , "Failed to retrieve JetUncertaintiesTool" ); if ( m_config->jetCalibSequence() == "JMS" ){ - top::check( m_jetUncertaintiesToolFrozenJMS.retrieve() , "Failed to retrieve JetUncertaintiesToolAllNP" ); + top::check( m_jetUncertaintiesToolFrozenJMS.retrieve() , "Failed to retrieve JetUncertaintiesTool (FrozenJMS)" ); } } if (m_config->doMultipleJES()) { @@ -135,8 +132,6 @@ StatusCode JetObjectCollectionMaker::initialize() { top::check( m_jetUncertaintiesToolReducedNPScenario4.retrieve() , "Failed to retrieve JetUncertaintiesToolReducedNPScenario4" ); } } - - top::check( m_jetJERSmearingTool.retrieve() , "Failed to retrieve JetJERSmearingTool" ); } top::check( m_jetUpdateJvtTool.retrieve() , "Failed to retrieve JetUpdateJvtTool" ); @@ -173,7 +168,8 @@ StatusCode JetObjectCollectionMaker::initialize() { if (!m_config->useParticleFlowJets()) { ///-- JES systematics --/// if (m_config->isMC()) { - std::string allNP("JET_"+m_config->jetUncertainties_NPModel()+"_"),np1("JET_SR_Scenario1_"),np2("JET_SR_Scenario2_"),np3("JET_SR_Scenario3_"),np4("JET_SR_Scenario4_"); + std::string allNP("JET_"+m_config->jetUncertainties_NPModel()+"_"), + np1("JET_SR_Scenario1_"),np2("JET_SR_Scenario2_"),np3("JET_SR_Scenario3_"),np4("JET_SR_Scenario4_"); std::string allNP_FrozenJMS("JET_"+m_config->jetUncertainties_NPModel()+"_FrozenJMS_"); std::string largeR_strong("LARGERJET_Strong_"), largeR_medium("LARGERJET_Medium_"), @@ -198,9 +194,6 @@ StatusCode JetObjectCollectionMaker::initialize() { } } - ///-- JER systematics --/// - if (m_doJER) - specifiedSystematics( syst , m_jetJERSmearingTool , m_systMap_JER ); } // See http://cern.ch/go/nHF6 for more information @@ -281,12 +274,7 @@ StatusCode JetObjectCollectionMaker::execute( const bool isLargeR, bool executeN } ///-- Systematics from here --/// - - // No uncertainties yet for pflow - // - return SUCCESS after calibration - if (m_config->useParticleFlowJets()) - return StatusCode::SUCCESS; - + ///-- JES, JER regular atk4 for now --/// if (!isLargeR) { ///-- JES --/// @@ -304,11 +292,8 @@ StatusCode JetObjectCollectionMaker::execute( const bool isLargeR, bool executeN top::check( applySystematic( m_jetUncertaintiesToolReducedNPScenario4 , m_systMap_ReducedNPScenario4 ) , "Failed to apply JES"); } } - - ///-- JER --/// - if (m_doJER) - top::check( applySystematic ( m_jetJERSmearingTool , m_systMap_JER ) , "Failed to apply JER" ); - } else { + } + else { if (m_config->isMC()) { top::check( applySystematic( m_jetUncertaintiesToolLargeR_strong , m_systMap_LargeR_strong, true ) , "Failed to apply large-R syst."); top::check( applySystematic( m_jetUncertaintiesToolLargeR_medium , m_systMap_LargeR_medium, true ) , "Failed to apply large-R syst."); @@ -511,56 +496,6 @@ StatusCode JetObjectCollectionMaker::applySystematic(ToolHandle<ICPJetUncertaint } - -StatusCode JetObjectCollectionMaker::applySystematic(ToolHandle<IJERSmearingTool>& tool, - const std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ) { - ///-- Get calibrated jets --/// - const xAOD::JetContainer* xaod(nullptr); - top::check( evtStore()->retrieve( xaod , m_config->sgKeyJetsStandAlone( m_nominalSystematicSet.hash() ) ) , "Failed to retrieve Jets" ); - - ///-- Loop over the systematics --/// - - for (Itr syst=map.begin();syst!=map.end();++syst) { - ///-- Don't do the nominal, we've already done that --/// - if ((*syst).second.hash() != m_nominalSystematicSet.hash()) { - - ///-- Tell the tool which systematic to use --/// - ///-- Here we use the second, original CP::SystematicSet --/// - top::check( tool->applySystematicVariation( (*syst).second ) , "Failed to apply systematic" ); - - ///-- Shallow copy of the xAOD --/// - std::pair< xAOD::JetContainer*, xAOD::ShallowAuxContainer* > shallow_xaod_copy = xAOD::shallowCopyContainer( *xaod ); - - ///-- Loop over the xAOD Container --/// - for( auto jet : *(shallow_xaod_copy.first) ){ - ///-- Apply Corrrection --/// - top::check( tool->applyCorrection( *jet ) , "Failed to applyCorrection" ); - ///-- Update JVT --/// - jet->auxdecor<float>("AnalysisTop_JVT") = m_jetUpdateJvtTool->updateJvt( *jet ); - } - - ///-- set links to original objects- needed for MET calculation --/// - bool setLinks = xAOD::setOriginalObjectLink( *xaod, *shallow_xaod_copy.first ); - if (!setLinks) - ATH_MSG_ERROR(" Cannot set original object links for jets, MET recalculation may struggle" ); - - ///-- Save corrected xAOD Container to StoreGate / TStore --/// - ///-- Here we use the first, AnalysisTop modified CP::SystematicSer --/// - ///-- This allows us to run multiple JES scenarios, which all have the same hash values --/// - std::string outputSGKey = m_config->sgKeyJetsStandAlone( (*syst).first.hash() ); - std::string outputSGKeyAux = outputSGKey + "Aux."; - - xAOD::TReturnCode save = evtStore()->tds()->record( shallow_xaod_copy.first , outputSGKey ); - xAOD::TReturnCode saveAux = evtStore()->tds()->record( shallow_xaod_copy.second , outputSGKeyAux ); - if( !save || !saveAux ){ - return StatusCode::FAILURE; - } - } - } - - return StatusCode::SUCCESS; -} - StatusCode JetObjectCollectionMaker::executeTrackJets(bool executeNominal) { ///-- No calibrations or systematics yet --/// ///-- Only run this on the nominal execution --/// @@ -669,43 +604,6 @@ void JetObjectCollectionMaker::specifiedSystematics(const std::set<std::string>& } - - -///-- Don't really need to do this, but would rather stay consistent with JetObjectCollectionMaker --/// -///-- This could be done like all the other xyzObjectCollectionMakers, but would need to change the way execute() works --/// -void JetObjectCollectionMaker::specifiedSystematics( const std::set<std::string>& specifiedSystematics, - const ToolHandle<IJERSmearingTool>& tool, - std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ) { - ///-- Get the recommended systematics from the tool, in std::vector format --/// - const std::vector<CP::SystematicSet> systList = CP::make_systematics_vector( tool->recommendedSystematics() ); - - for (auto s : systList) { - m_recommendedSystematics.push_back(s); - - ///-- Are we doing JER? Are we only doing Nominal? Did the user specify specific systematics to use? --/// - if (m_doJER) { - if (!m_config->isSystNominal( m_config->systematics() )) { - if (specifiedSystematics.size() == 0) { - m_specifiedSystematics.push_back(s); - map.insert( std::make_pair(s,s) ); - } - if (specifiedSystematics.size() > 0) { - for (auto i : specifiedSystematics) { - if ( i == s.name() ) { - m_specifiedSystematics.push_back(s); - map.insert( std::make_pair(s,s) ); - } - } - } - } - } - } - m_recommendedSystematics.sort(); - m_recommendedSystematics.unique(); - m_specifiedSystematics.sort(); - m_specifiedSystematics.unique(); -} - StatusCode JetObjectCollectionMaker::decorateBJets(xAOD::Jet& jet) { // initialise decorator and accessor static SG::AuxElement::Decorator<char> isbjet("IsBjet"); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/TopSystematicObjectMaker/JetObjectCollectionMaker.h b/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/TopSystematicObjectMaker/JetObjectCollectionMaker.h index 919339b48dc..a0317d1b46f 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/TopSystematicObjectMaker/JetObjectCollectionMaker.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopSystematicObjectMaker/TopSystematicObjectMaker/JetObjectCollectionMaker.h @@ -42,7 +42,6 @@ // CP Tool include(s): #include "JetCalibTools/IJetCalibrationTool.h" #include "JetCPInterfaces/ICPJetUncertaintiesTool.h" -#include "JetResolution/IJERSmearingTool.h" #include "JetInterface/IJetUpdateJvt.h" #include "TopJetSubstructure/TopJetSubstructure.h" @@ -88,13 +87,13 @@ namespace top{ protected: // specify Systematic virtual void specifiedSystematics( const std::set<std::string>& specifiedSystematics , const ToolHandle<ICPJetUncertaintiesTool>& tool , std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map , const std::string& modName , bool isLargeR = false); - virtual void specifiedSystematics( const std::set<std::string>& specifiedSystematics , const ToolHandle<IJERSmearingTool>& tool , std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ); + // virtual void specifiedSystematics( const std::set<std::string>& specifiedSystematics , const ToolHandle<IJERSmearingTool>& tool , std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ); StatusCode execute( const bool isLargeR, bool executeNominal ); StatusCode calibrate( const bool isLargeR ); virtual StatusCode applySystematic( ToolHandle<ICPJetUncertaintiesTool>& tool, const std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map , bool isLargeR = false); - virtual StatusCode applySystematic( ToolHandle<IJERSmearingTool>& tool, const std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ); + // virtual StatusCode applySystematic( ToolHandle<IJERSmearingTool>& tool, const std::unordered_map<CP::SystematicSet,CP::SystematicSet>& map ); StatusCode printout( const bool isLargeR ); @@ -137,7 +136,7 @@ namespace top{ ToolHandle<ICPJetUncertaintiesTool> m_jetUncertaintiesToolLargeR_medium; ToolHandle<ICPJetUncertaintiesTool> m_jetUncertaintiesToolLargeR_weak; - ToolHandle<IJERSmearingTool> m_jetJERSmearingTool; + // ToolHandle<IJERSmearingTool> m_jetJERSmearingTool; ToolHandle<IJetUpdateJvt> m_jetUpdateJvtTool; ToolHandle<IJetModifier> m_fjvtTool; @@ -154,7 +153,7 @@ namespace top{ systMap m_systMap_LargeR_strong; systMap m_systMap_LargeR_medium; systMap m_systMap_LargeR_weak; - systMap m_systMap_JER; + // systMap m_systMap_JER; typedef std::unordered_map<CP::SystematicSet,CP::SystematicSet>::const_iterator Itr; StatusCode decorateBJets(xAOD::Jet& jet); -- GitLab