From bd63c4e3ee1f3e9e2a8f3ca09f983508a20e3fc0 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 02:10:48 +0100 Subject: [PATCH 01/68] Outsource bbtautau trigger selection and matching to decorator alg --- bbttAnalysis/CMakeLists.txt | 6 +- bbttAnalysis/src/HHbbttChannels.h | 16 +++ bbttAnalysis/src/HHbbttSelectorAlg.cxx | 59 ++++++----- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 122 ++++++++++------------- 4 files changed, 108 insertions(+), 95 deletions(-) diff --git a/bbttAnalysis/CMakeLists.txt b/bbttAnalysis/CMakeLists.txt index 4c16cd3b0..8c1668304 100644 --- a/bbttAnalysis/CMakeLists.txt +++ b/bbttAnalysis/CMakeLists.txt @@ -9,7 +9,11 @@ add_compile_options(-Werror) # Build the Athena component library atlas_add_component(bbttAnalysis - src/*.cxx + src/BaselineVarsbbttAlg.cxx + src/MMCDecoratorAlg.cxx + src/MMCSelectorAlg.cxx + src/HHbbttSelectorAlg.cxx + src/TriggerDecoratorAlg.cxx src/components/bbttAnalysis_entries.cxx LINK_LIBRARIES AthenaBaseComps diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index 4d67b441b..fd757e802 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -30,6 +30,22 @@ namespace HHBBTT DTT_L1Topo, }; + enum TriggerChannel + { + SLT, + LTT, + ETT, + ETT_4J12, + MTT_2016, + MTT_high, + MTT_low, + STT, + DTT, + DTT_2016, + DTT_4J12, + DTT_L1Topo, + }; + } #endif diff --git a/bbttAnalysis/src/HHbbttSelectorAlg.cxx b/bbttAnalysis/src/HHbbttSelectorAlg.cxx index 5481e453c..5edc44fc7 100644 --- a/bbttAnalysis/src/HHbbttSelectorAlg.cxx +++ b/bbttAnalysis/src/HHbbttSelectorAlg.cxx @@ -71,47 +71,54 @@ namespace HHBBTT ATH_CHECK(m_trigPass_DecorKey.at(channel).initialize()); } - SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_SLT; - mu_SLT = m_muonHandle.getNamePattern() + ".trigMatch_SLT"; + for (const auto& [channel, name] : m_triggerChannels){ + SG::WriteDecorHandleKey<xAOD::EventInfo> deco + {this, "pass_"+name, "EventInfo.pass_trigger_"+name}; + m_trigPass_DecorKey.emplace(channel, deco); + ATH_CHECK(m_trigPass_DecorKey.at(channel).initialize()); + } + + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT + {this, "mu_SLT", m_muonHandle.getNamePattern() + ".trigMatch_SLT"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::SLT, mu_SLT); - SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_LTT; - mu_LTT = m_muonHandle.getNamePattern() + ".trigMatch_LTT"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT + {this, "mu_LTT", m_muonHandle.getNamePattern() + ".trigMatch_LTT"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::LTT, mu_LTT); - SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016; - mu_MTT_2016 = m_muonHandle.getNamePattern() + ".trigMatch_MTT_2016"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016 + {this, "mu_MTT_2016", m_muonHandle.getNamePattern() + ".trigMatch_MTT_2016"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_2016, mu_MTT_2016); - SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_high; - mu_MTT_high = m_muonHandle.getNamePattern() + ".trigMatch_MTT_high"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high + {this, "mu_MTT_high", m_muonHandle.getNamePattern() + ".trigMatch_MTT_high"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_high, mu_MTT_high); - SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_low; - mu_MTT_low = m_muonHandle.getNamePattern() + ".trigMatch_MTT_low"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low + {this, "mu_MTT_low", m_muonHandle.getNamePattern() + ".trigMatch_MTT_low"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_low, mu_MTT_low); for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ ATH_CHECK(m_mu_trigMatch_DecorKey.at(channel).initialize()); } - - SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_SLT; - ele_SLT = m_electronHandle.getNamePattern() + ".trigMatch_SLT"; + + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT + {this, "ele_SLT", m_electronHandle.getNamePattern() + ".trigMatch_SLT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::SLT, ele_SLT); - SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_LTT; - ele_LTT = m_electronHandle.getNamePattern() + ".trigMatch_LTT"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT + {this, "ele_LTT", m_electronHandle.getNamePattern() + ".trigMatch_LTT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::LTT, ele_LTT); - SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT; - ele_ETT = m_electronHandle.getNamePattern() + ".trigMatch_ETT"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT + {this, "ele_ETT", m_electronHandle.getNamePattern() + ".trigMatch_ETT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT, ele_ETT); - SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; - ele_ETT_4J12 = m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12 + {this, "ele_ETT_4J12", m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); - + for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ATH_CHECK(m_ele_trigMatch_DecorKey.at(channel).initialize()); } for (const auto& [channel, name] : m_triggerChannels){ if(channel==HHBBTT::SLT) continue; - SG::ReadDecorHandleKey<xAOD::TauJetContainer> deco; - deco = m_tauHandle.getNamePattern() + ".trigMatch_"+name; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco + {this, "tau_trigMatch_"+name, m_tauHandle.getNamePattern() + ".trigMatch_"+name}; m_tau_trigMatch_DecorKey.emplace(channel, deco); ATH_CHECK(m_tau_trigMatch_DecorKey.at(channel).initialize()); } @@ -194,22 +201,22 @@ namespace HHBBTT SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleWPDecorHandle(m_eleWPDecorKey); SG::ReadDecorHandle<xAOD::MuonContainer, char> muonWPDecorHandle(m_muonWPDecorKey); - trigPassReadDecoMap trigPass_decos; + std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::EventInfo, bool> > trigPass_decos; for (const auto& [channel, key] : m_trigPass_DecorKey){ trigPass_decos.emplace(channel, key); } - muTrigMatchReadDecoMap mu_trigMatchDecos; + std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::MuonContainer, bool> > mu_trigMatchDecos; for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ mu_trigMatchDecos.emplace(channel, key); } - eleTrigMatchReadDecoMap ele_trigMatchDecos; + std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::ElectronContainer, bool> > ele_trigMatchDecos; for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ele_trigMatchDecos.emplace(channel, key); } - tauTrigMatchReadDecoMap tau_trigMatchDecos; + std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::TauJetContainer, bool> > tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 487ec8a86..c75d7a0db 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -25,50 +25,50 @@ namespace HHBBTT // make trigger decorators for (const auto& trig : m_triggers){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco; - deco = "EventInfo." + trig; - m_triggerdecoKeys.emplace(trig, deco); + SG::ReadDecorHandleKey<xAOD::EventInfo> deco + {this, "trig"+trig, "EventInfo."+trig}; + m_triggerdecoKeys.emplace(trig, deco); ATH_CHECK(m_triggerdecoKeys.at(trig).initialize()); } for (const auto& [channel, name] : m_triggerChannels){ - SG::WriteDecorHandleKey<xAOD::EventInfo> deco; - deco = "EventInfo.pass_trigger_"+name; + SG::WriteDecorHandleKey<xAOD::EventInfo> deco + {this, "pass_"+name, "EventInfo.pass_trigger_"+name}; m_pass_DecorKey.emplace(channel, deco); ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); } - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT; - mu_SLT = m_muonsKey.key() + ".trigMatch_SLT"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT + {this, "mu_SLT", m_muonsKey.key() + ".trigMatch_SLT"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::SLT, mu_SLT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT; - mu_LTT = m_muonsKey.key() + ".trigMatch_LTT"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT + {this, "mu_LTT", m_muonsKey.key() + ".trigMatch_LTT"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::LTT, mu_LTT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016; - mu_MTT_2016 = m_muonsKey.key() + ".trigMatch_MTT_2016"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016 + {this, "mu_MTT_2016", m_muonsKey.key() + ".trigMatch_MTT_2016"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_2016, mu_MTT_2016); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high; - mu_MTT_high = m_muonsKey.key() + ".trigMatch_MTT_high"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high + {this, "mu_MTT_high", m_muonsKey.key() + ".trigMatch_MTT_high"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_high, mu_MTT_high); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low; - mu_MTT_low = m_muonsKey.key() + ".trigMatch_MTT_low"; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low + {this, "mu_MTT_low", m_muonsKey.key() + ".trigMatch_MTT_low"}; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_low, mu_MTT_low); for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ ATH_CHECK(m_mu_trigMatch_DecorKey.at(channel).initialize()); } - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT; - ele_SLT = m_elesKey.key() + ".trigMatch_SLT"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT + {this, "ele_SLT", m_elesKey.key() + ".trigMatch_SLT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::SLT, ele_SLT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT; - ele_LTT = m_elesKey.key() + ".trigMatch_LTT"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT + {this, "ele_LTT", m_elesKey.key() + ".trigMatch_LTT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::LTT, ele_LTT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT; - ele_ETT = m_elesKey.key() + ".trigMatch_ETT"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT + {this, "ele_ETT", m_elesKey.key() + ".trigMatch_ETT"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT, ele_ETT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; - ele_ETT_4J12 = m_elesKey.key() + ".trigMatch_ETT_4J12"; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12 + {this, "ele_ETT_4J12", m_elesKey.key() + ".trigMatch_ETT_4J12"}; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ @@ -77,8 +77,8 @@ namespace HHBBTT for (const auto& [channel, name] : m_triggerChannels){ if(channel==HHBBTT::SLT) continue; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco; - deco = m_tausKey.key() + ".trigMatch_"+name; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco + {this, "tau_trigMatch_"+name, m_tausKey.key() + ".trigMatch_"+name}; m_tau_trigMatch_DecorKey.emplace(channel, deco); ATH_CHECK(m_tau_trigMatch_DecorKey.at(channel).initialize()); } @@ -140,7 +140,7 @@ namespace HHBBTT for(const xAOD::TauJet* tau : *taus){ tau_trigMatchDecos.at(channel)(*tau) = false; } - } + } unsigned int runNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); @@ -218,7 +218,7 @@ namespace HHBBTT runBoolMap.at(HHBBTT::is23_75bunches) = 450360 <= runNumber && runNumber < 450894; runBoolMap.at(HHBBTT::is23_400bunches) = - 450894 <= runNumber && runNumber < 451094; + 450894 <= rdmNumber && rdmNumber < 451094; runBoolMap.at(HHBBTT::l1topo_disabled) = (runNumber == 336506) || (runNumber == 336548) || (runNumber == 336567); @@ -227,7 +227,7 @@ namespace HHBBTT } void TriggerDecoratorAlg::checkSingleMuTriggers - (int year, std::unordered_map<HHBBTT::RunBooleans, bool> runBoolMap, + (int year, std::unordered_map<HHBBTT::RunBooleans, bool> /*runBoolMap*/, const xAOD::EventInfo* eventInfo, const trigReadDecoMap& triggerdecos, passWriteDecoMap& pass_decos, const xAOD::MuonContainer* muons, @@ -241,10 +241,7 @@ namespace HHBBTT else if(2016<=year && year<=2018){ single_mu_paths = {"HLT_mu26_ivarmedium", "HLT_mu50"}; } - else if(2022<=year && year<=2023 && - !runBoolMap.at(HHBBTT::is22_75bunches) && - !runBoolMap.at(HHBBTT::is23_75bunches) && - !runBoolMap.at(HHBBTT::is23_400bunches)){ + else if(2022<=year && year<=2023){ single_mu_paths = { "HLT_mu24_ivarmedium_L1MU14FCH", "HLT_mu50_L1MU14FCH", "HLT_mu60_0eta105_msonly_L1MU14FCH", "HLT_mu60_L1MU14FCH", @@ -266,11 +263,11 @@ namespace HHBBTT } pass_decos.at(HHBBTT::SLT)(*eventInfo) |= trigPassed_SMT; - + } void TriggerDecoratorAlg::checkSingleEleTriggers - (int year, std::unordered_map<HHBBTT::RunBooleans, bool> runBoolMap, + (int year, std::unordered_map<HHBBTT::RunBooleans, bool> /*runBoolMap*/, const xAOD::EventInfo* eventInfo, const trigReadDecoMap& triggerdecos, passWriteDecoMap& pass_decos, const xAOD::ElectronContainer* electrons, @@ -283,37 +280,32 @@ namespace HHBBTT "HLT_e24_lhmedium_L1EM20VH", "HLT_e60_lhmedium", "HLT_e120_lhloose" }; - } - else if(2016<=year && year<=2018){ - single_ele_paths = { - "HLT_e26_lhtight_nod0_ivarloose", "HLT_e60_lhmedium_nod0", - "HLT_e140_lhloose_nod0" + + { + "trigPassed_HLT_e24_lhmedium_L1EM20VH", + "trigPassed_HLT_e60_lhmedium", + "trigPassed_HLT_e120_lhloose" }; } - else if(runBoolMap.at(HHBBTT::is22_75bunches)){ + else if(2016<=year && year<=2018){ single_ele_paths = { - "HLT_e17_lhvloose_L1EM15VHI", "HLT_e20_lhvloose_L1EM15VH", - "HLT_e250_etcut_L1EM22VHI" + "trigPassed_HLT_e26_lhtight_nod0_ivarloose", + "trigPassed_HLT_e60_lhmedium_nod0", + "trigPassed_HLT_e140_lhloose_nod0" }; } else if(year==2022){ single_ele_paths = { - "HLT_e26_lhtight_ivarloose_L1EM22VHI", "HLT_e60_lhmedium_L1EM22VHI", - "HLT_e140_lhloose_L1EM22VHI", "HLT_e300_etcut_L1EM22VHI" - }; - } - else if(runBoolMap.at(HHBBTT::is23_75bunches)){ - single_ele_paths = { - "HLT_e26_lhtight_ivarloose_L1EM22VHI", "HLT_e60_lhmedium_L1EM22VHI", - "HLT_e140_lhloose_L1EM22VHI", "HLT_e140_lhloose_noringer_L1EM22VHI", - "HLT_e300_etcut_L1EM22VHI" + "trigPassed_HLT_e26_lhtight_ivarloose_L1EM22VHI", + "trigPassed_HLT_e60_lhmedium_L1EM22VHI", + "trigPassed_HLT_e140_lhloose_L1EM22VHI" }; } else if(year==2023){ single_ele_paths = { - "HLT_e26_lhtight_ivarloose_L1eEM26M", "HLT_e60_lhmedium_L1eEM26M", - "HLT_e140_lhloose_L1eEM26M", "HLT_e140_lhloose_noringer_L1eEM26M", - "HLT_e300_etcut_L1eEM26M" + "trigPassed_HLT_e26_lhtight_ivarloose_L1eEM26M", + "trigPassed_HLT_e60_lhmedium_L1eEM26M", + "trigPassed_HLT_e140_lhloose_L1eEM26M" }; } @@ -384,19 +376,17 @@ namespace HHBBTT mapDecisions.emplace(HHBBTT::MTT_low, false); for(const auto& [channel, paths] : mapPaths){ - for(const auto& trig: paths){ + for(const auto& trigg: paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); mapDecisions.at(channel) |= pass; if(pass){ for(const xAOD::Muon* mu : *muons){ bool match = m_matchingTool->match(*mu, trig); mu_trigMatchDecos.at(channel)(*mu) |= match; - mu_trigMatchDecos.at(HHBBTT::LTT)(*mu) |= match; } for(const xAOD::TauJet* tau : *taus){ bool match = m_matchingTool->match(*tau, trig, 0.2); tau_trigMatchDecos.at(channel)(*tau) |= match; - tau_trigMatchDecos.at(HHBBTT::LTT)(*tau) |= match; } } } @@ -458,19 +448,17 @@ namespace HHBBTT mapDecisions.emplace(HHBBTT::ETT_4J12, false); for(const auto& [channel, paths] : mapPaths){ - for(const auto& trig : paths){ + for(const auto& path : paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); mapDecisions.at(channel) |= pass; if(pass){ for(const xAOD::Electron* ele : *electrons){ bool match = m_matchingTool->match(*ele, trig); ele_trigMatchDecos.at(channel)(*ele) |= match; - ele_trigMatchDecos.at(HHBBTT::LTT)(*ele) |= match; } for(const xAOD::TauJet* tau : *taus){ bool match = m_matchingTool->match(*tau, trig, 0.2); tau_trigMatchDecos.at(channel)(*tau) |= match; - tau_trigMatchDecos.at(HHBBTT::LTT)(*tau) |= match; } } } @@ -520,7 +508,7 @@ namespace HHBBTT bool trigPassed_STT = false; - for(const auto& trig : single_tau_paths){ + for(const auto& path : single_tau_paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); trigPassed_STT |= pass; if(pass){ @@ -606,19 +594,17 @@ namespace HHBBTT mapDecisions.at(channel) |= pass; if(pass){ // Naming altered for matching - std::string trig2 = trig; if(channel==HHBBTT::DTT_4J12) - trig2 = std::regex_replace(trig, std::regex("4J12p0ETA"), + trig = std::regex_replace(trig, std::regex("4J12p0ETA"), "4J12_0ETA"); else if(channel==HHBBTT::DTT_L1Topo) - trig2 = std::regex_replace(trig, - std::regex("L1DR_TAU20ITAU12I_J25"), - "L1DR-TAU20ITAU12I-J25"); + trig = std::regex_replace(trig, + std::regex("L1DR_TAU20ITAU12I_J25"), + "L1DR-TAU20ITAU12I-J25"); for(const xAOD::TauJet* tau : *taus){ - bool match = m_matchingTool->match(*tau, trig2, 0.2); + bool match = m_matchingTool->match(*tau, trig, 0.2); if(!m_useDiTauTrigMatch) match = true; tau_trigMatchDecos.at(channel)(*tau) |= match; - tau_trigMatchDecos.at(HHBBTT::DTT)(*tau) |= match; } } } -- GitLab From 08fdf5445915434487762b0a0b652e5f24266ce0 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 10:59:01 +0100 Subject: [PATCH 02/68] Updated configs for bbtt TriggerDecorator --- EasyjetHub/src/TauDecoratorAlg.cxx | 46 ++++++++++--------- bbttAnalysis/CMakeLists.txt | 6 +-- bbttAnalysis/python/TriggerDecoratorConfig.py | 8 ++-- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 75714e2c7..5ac7da7ea 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -28,20 +28,22 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); + if(m_doAntiTauDecor){ + // Muons + ele stuff to be cleaned up after trigger matching is used + ATH_CHECK (m_muonsInKey.initialize()); + ATH_CHECK (m_elesInKey.initialize()); - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -62,17 +64,6 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); int nidtau = 0; for(const xAOD::TauJet* tau : *tausIn) { @@ -92,6 +83,17 @@ namespace Easyjet } if(m_doAntiTauDecor){ + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + ATH_CHECK (elesIn.isValid()); + + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); + SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + + SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + int nlepton = 0; for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; diff --git a/bbttAnalysis/CMakeLists.txt b/bbttAnalysis/CMakeLists.txt index 8c1668304..4c16cd3b0 100644 --- a/bbttAnalysis/CMakeLists.txt +++ b/bbttAnalysis/CMakeLists.txt @@ -9,11 +9,7 @@ add_compile_options(-Werror) # Build the Athena component library atlas_add_component(bbttAnalysis - src/BaselineVarsbbttAlg.cxx - src/MMCDecoratorAlg.cxx - src/MMCSelectorAlg.cxx - src/HHbbttSelectorAlg.cxx - src/TriggerDecoratorAlg.cxx + src/*.cxx src/components/bbttAnalysis_entries.cxx LINK_LIBRARIES AthenaBaseComps diff --git a/bbttAnalysis/python/TriggerDecoratorConfig.py b/bbttAnalysis/python/TriggerDecoratorConfig.py index ec401b7b2..dccb58847 100644 --- a/bbttAnalysis/python/TriggerDecoratorConfig.py +++ b/bbttAnalysis/python/TriggerDecoratorConfig.py @@ -3,11 +3,10 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory - def HHbbttTriggerDecoratorCfg(flags): cfg = ComponentAccumulator() - + from EasyjetHub.algs.postprocessing.trigger_matching import TriggerMatchingToolCfg from AthenaConfiguration.Enums import LHCPeriod @@ -29,8 +28,9 @@ def HHbbttTriggerDecoratorCfg(flags): trigMatchingTool=cfg.popToolsAndMerge(TriggerMatchingToolCfg(flags)), # Not available in current Run2 PHYSLITE diTauTrigMatch=not (flags.Input.isPHYSLITE and \ - flags.GeoModel.Run == LHCPeriod.Run2) + flags.GeoModel.Run == LHCPeriod.Run2)) ) - ) return cfg + + -- GitLab From 676f4bbea4a3be5d68ef6d09d3d385f4e9d11354 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 13:57:19 +0100 Subject: [PATCH 03/68] Updated initialization --- bbttAnalysis/python/TriggerDecoratorConfig.py | 8 +-- bbttAnalysis/src/HHbbttSelectorAlg.cxx | 61 ++++++++----------- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 40 ++++++------ 3 files changed, 51 insertions(+), 58 deletions(-) diff --git a/bbttAnalysis/python/TriggerDecoratorConfig.py b/bbttAnalysis/python/TriggerDecoratorConfig.py index dccb58847..ec401b7b2 100644 --- a/bbttAnalysis/python/TriggerDecoratorConfig.py +++ b/bbttAnalysis/python/TriggerDecoratorConfig.py @@ -3,10 +3,11 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory + def HHbbttTriggerDecoratorCfg(flags): cfg = ComponentAccumulator() - + from EasyjetHub.algs.postprocessing.trigger_matching import TriggerMatchingToolCfg from AthenaConfiguration.Enums import LHCPeriod @@ -28,9 +29,8 @@ def HHbbttTriggerDecoratorCfg(flags): trigMatchingTool=cfg.popToolsAndMerge(TriggerMatchingToolCfg(flags)), # Not available in current Run2 PHYSLITE diTauTrigMatch=not (flags.Input.isPHYSLITE and \ - flags.GeoModel.Run == LHCPeriod.Run2)) + flags.GeoModel.Run == LHCPeriod.Run2) ) + ) return cfg - - diff --git a/bbttAnalysis/src/HHbbttSelectorAlg.cxx b/bbttAnalysis/src/HHbbttSelectorAlg.cxx index 5edc44fc7..1f450160c 100644 --- a/bbttAnalysis/src/HHbbttSelectorAlg.cxx +++ b/bbttAnalysis/src/HHbbttSelectorAlg.cxx @@ -65,60 +65,53 @@ namespace HHBBTT ATH_CHECK(m_selected_tau.initialize(m_systematicsList, m_tauHandle)); for (const auto& [channel, name] : m_triggerChannels){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco; - deco = "EventInfo.pass_trigger_"+name; - m_trigPass_DecorKey.emplace(channel, deco); - ATH_CHECK(m_trigPass_DecorKey.at(channel).initialize()); - } - - for (const auto& [channel, name] : m_triggerChannels){ - SG::WriteDecorHandleKey<xAOD::EventInfo> deco + SG::ReadDecorHandleKey<xAOD::EventInfo> deco {this, "pass_"+name, "EventInfo.pass_trigger_"+name}; m_trigPass_DecorKey.emplace(channel, deco); ATH_CHECK(m_trigPass_DecorKey.at(channel).initialize()); } - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT - {this, "mu_SLT", m_muonHandle.getNamePattern() + ".trigMatch_SLT"}; + SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_SLT; + mu_SLT = m_muonHandle.getNamePattern() + ".trigMatch_SLT"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::SLT, mu_SLT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT - {this, "mu_LTT", m_muonHandle.getNamePattern() + ".trigMatch_LTT"}; + SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_LTT; + mu_LTT = m_muonHandle.getNamePattern() + ".trigMatch_LTT"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::LTT, mu_LTT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016 - {this, "mu_MTT_2016", m_muonHandle.getNamePattern() + ".trigMatch_MTT_2016"}; + SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016; + mu_MTT_2016 = m_muonHandle.getNamePattern() + ".trigMatch_MTT_2016"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_2016, mu_MTT_2016); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high - {this, "mu_MTT_high", m_muonHandle.getNamePattern() + ".trigMatch_MTT_high"}; + SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_high; + mu_MTT_high = m_muonHandle.getNamePattern() + ".trigMatch_MTT_high"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_high, mu_MTT_high); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low - {this, "mu_MTT_low", m_muonHandle.getNamePattern() + ".trigMatch_MTT_low"}; + SG::ReadDecorHandleKey<xAOD::MuonContainer> mu_MTT_low; + mu_MTT_low = m_muonHandle.getNamePattern() + ".trigMatch_MTT_low"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_low, mu_MTT_low); for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ ATH_CHECK(m_mu_trigMatch_DecorKey.at(channel).initialize()); } - - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT - {this, "ele_SLT", m_electronHandle.getNamePattern() + ".trigMatch_SLT"}; + + SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_SLT; + ele_SLT = m_electronHandle.getNamePattern() + ".trigMatch_SLT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::SLT, ele_SLT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT - {this, "ele_LTT", m_electronHandle.getNamePattern() + ".trigMatch_LTT"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT; + ele_LTT = m_electronHandle.getNamePattern() + ".trigMatch_LTT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::LTT, ele_LTT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT - {this, "ele_ETT", m_electronHandle.getNamePattern() + ".trigMatch_ETT"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT; + ele_ETT = m_electronHandle.getNamePattern() + ".trigMatch_ETT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT, ele_ETT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12 - {this, "ele_ETT_4J12", m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; + ele_ETT_4J12 = m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); - + for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ATH_CHECK(m_ele_trigMatch_DecorKey.at(channel).initialize()); } for (const auto& [channel, name] : m_triggerChannels){ if(channel==HHBBTT::SLT) continue; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco - {this, "tau_trigMatch_"+name, m_tauHandle.getNamePattern() + ".trigMatch_"+name}; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> deco; + deco = m_tauHandle.getNamePattern() + ".trigMatch_"+name; m_tau_trigMatch_DecorKey.emplace(channel, deco); ATH_CHECK(m_tau_trigMatch_DecorKey.at(channel).initialize()); } @@ -201,22 +194,22 @@ namespace HHBBTT SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleWPDecorHandle(m_eleWPDecorKey); SG::ReadDecorHandle<xAOD::MuonContainer, char> muonWPDecorHandle(m_muonWPDecorKey); - std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::EventInfo, bool> > trigPass_decos; + trigPassReadDecoMap trigPass_decos; for (const auto& [channel, key] : m_trigPass_DecorKey){ trigPass_decos.emplace(channel, key); } - std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::MuonContainer, bool> > mu_trigMatchDecos; + muTrigMatchReadDecoMap mu_trigMatchDecos; for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ mu_trigMatchDecos.emplace(channel, key); } - std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::ElectronContainer, bool> > ele_trigMatchDecos; + eleTrigMatchReadDecoMap ele_trigMatchDecos; for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ele_trigMatchDecos.emplace(channel, key); } - std::unordered_map<HHBBTT::TriggerChannel, SG::ReadDecorHandle<xAOD::TauJetContainer, bool> > tau_trigMatchDecos; + tauTrigMatchReadDecoMap tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index c75d7a0db..80cbc3ffe 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -38,37 +38,37 @@ namespace HHBBTT ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); } - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT - {this, "mu_SLT", m_muonsKey.key() + ".trigMatch_SLT"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_SLT; + mu_SLT = m_muonsKey.key() + ".trigMatch_SLT"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::SLT, mu_SLT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT - {this, "mu_LTT", m_muonsKey.key() + ".trigMatch_LTT"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_LTT; + mu_LTT = m_muonsKey.key() + ".trigMatch_LTT"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::LTT, mu_LTT); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016 - {this, "mu_MTT_2016", m_muonsKey.key() + ".trigMatch_MTT_2016"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_2016; + mu_MTT_2016 = m_muonsKey.key() + ".trigMatch_MTT_2016"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_2016, mu_MTT_2016); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high - {this, "mu_MTT_high", m_muonsKey.key() + ".trigMatch_MTT_high"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_high; + mu_MTT_high = m_muonsKey.key() + ".trigMatch_MTT_high"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_high, mu_MTT_high); - SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low - {this, "mu_MTT_low", m_muonsKey.key() + ".trigMatch_MTT_low"}; + SG::WriteDecorHandleKey<xAOD::MuonContainer> mu_MTT_low; + mu_MTT_low = m_muonsKey.key() + ".trigMatch_MTT_low"; m_mu_trigMatch_DecorKey.emplace(HHBBTT::MTT_low, mu_MTT_low); for (const auto& [channel, key] : m_mu_trigMatch_DecorKey){ ATH_CHECK(m_mu_trigMatch_DecorKey.at(channel).initialize()); } - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT - {this, "ele_SLT", m_elesKey.key() + ".trigMatch_SLT"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_SLT; + ele_SLT = m_elesKey.key() + ".trigMatch_SLT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::SLT, ele_SLT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT - {this, "ele_LTT", m_elesKey.key() + ".trigMatch_LTT"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT; + ele_LTT = m_elesKey.key() + ".trigMatch_LTT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::LTT, ele_LTT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT - {this, "ele_ETT", m_elesKey.key() + ".trigMatch_ETT"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT; + ele_ETT = m_elesKey.key() + ".trigMatch_ETT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT, ele_ETT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12 - {this, "ele_ETT_4J12", m_elesKey.key() + ".trigMatch_ETT_4J12"}; + SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; + ele_ETT_4J12 = m_elesKey.key() + ".trigMatch_ETT_4J12"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ @@ -77,8 +77,8 @@ namespace HHBBTT for (const auto& [channel, name] : m_triggerChannels){ if(channel==HHBBTT::SLT) continue; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco - {this, "tau_trigMatch_"+name, m_tausKey.key() + ".trigMatch_"+name}; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> deco; + deco = m_tausKey.key() + ".trigMatch_"+name; m_tau_trigMatch_DecorKey.emplace(channel, deco); ATH_CHECK(m_tau_trigMatch_DecorKey.at(channel).initialize()); } -- GitLab From f21a3b58c78f8c286a7558fde2c75efebb0b35cd Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 16:14:09 +0100 Subject: [PATCH 04/68] Fix lltt test --- EasyjetHub/src/TauDecoratorAlg.cxx | 46 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 5ac7da7ea..75714e2c7 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -28,22 +28,20 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - if(m_doAntiTauDecor){ - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); + // Muons + ele stuff to be cleaned up after trigger matching is used + ATH_CHECK (m_muonsInKey.initialize()); + ATH_CHECK (m_elesInKey.initialize()); - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - } + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -64,6 +62,17 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); + + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + ATH_CHECK (elesIn.isValid()); + + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); + SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + + SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); int nidtau = 0; for(const xAOD::TauJet* tau : *tausIn) { @@ -83,17 +92,6 @@ namespace Easyjet } if(m_doAntiTauDecor){ - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - int nlepton = 0; for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; -- GitLab From 8de507393b27a4764b4610d38c8158780486e6bf Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Fri, 23 Feb 2024 14:10:48 +0100 Subject: [PATCH 05/68] Post rebase fixes --- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 80cbc3ffe..9edf42cc0 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -218,7 +218,7 @@ namespace HHBBTT runBoolMap.at(HHBBTT::is23_75bunches) = 450360 <= runNumber && runNumber < 450894; runBoolMap.at(HHBBTT::is23_400bunches) = - 450894 <= rdmNumber && rdmNumber < 451094; + 450894 <= runNumber && runNumber < 451094; runBoolMap.at(HHBBTT::l1topo_disabled) = (runNumber == 336506) || (runNumber == 336548) || (runNumber == 336567); @@ -280,12 +280,6 @@ namespace HHBBTT "HLT_e24_lhmedium_L1EM20VH", "HLT_e60_lhmedium", "HLT_e120_lhloose" }; - - { - "trigPassed_HLT_e24_lhmedium_L1EM20VH", - "trigPassed_HLT_e60_lhmedium", - "trigPassed_HLT_e120_lhloose" - }; } else if(2016<=year && year<=2018){ single_ele_paths = { @@ -376,7 +370,7 @@ namespace HHBBTT mapDecisions.emplace(HHBBTT::MTT_low, false); for(const auto& [channel, paths] : mapPaths){ - for(const auto& trigg: paths){ + for(const auto& trig: paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); mapDecisions.at(channel) |= pass; if(pass){ @@ -448,7 +442,7 @@ namespace HHBBTT mapDecisions.emplace(HHBBTT::ETT_4J12, false); for(const auto& [channel, paths] : mapPaths){ - for(const auto& path : paths){ + for(const auto& trig : paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); mapDecisions.at(channel) |= pass; if(pass){ @@ -508,7 +502,7 @@ namespace HHBBTT bool trigPassed_STT = false; - for(const auto& path : single_tau_paths){ + for(const auto& trig : single_tau_paths){ bool pass = triggerdecos.at("trigPassed_"+trig)(*eventInfo); trigPassed_STT |= pass; if(pass){ @@ -594,15 +588,16 @@ namespace HHBBTT mapDecisions.at(channel) |= pass; if(pass){ // Naming altered for matching + std::string trig2 = trig; if(channel==HHBBTT::DTT_4J12) - trig = std::regex_replace(trig, std::regex("4J12p0ETA"), + trig2 = std::regex_replace(trig, std::regex("4J12p0ETA"), "4J12_0ETA"); else if(channel==HHBBTT::DTT_L1Topo) - trig = std::regex_replace(trig, + trig2 = std::regex_replace(trig, std::regex("L1DR_TAU20ITAU12I_J25"), "L1DR-TAU20ITAU12I-J25"); for(const xAOD::TauJet* tau : *taus){ - bool match = m_matchingTool->match(*tau, trig, 0.2); + bool match = m_matchingTool->match(*tau, trig2, 0.2); if(!m_useDiTauTrigMatch) match = true; tau_trigMatchDecos.at(channel)(*tau) |= match; } -- GitLab From 213a586a7dfed727d0aee00ecd50a78154fec323 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Fri, 23 Feb 2024 19:11:30 +0100 Subject: [PATCH 06/68] Final fixes to get running --- bbttAnalysis/src/HHbbttSelectorAlg.cxx | 10 ++--- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 56 +++++++++++++++--------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/bbttAnalysis/src/HHbbttSelectorAlg.cxx b/bbttAnalysis/src/HHbbttSelectorAlg.cxx index 1f450160c..5481e453c 100644 --- a/bbttAnalysis/src/HHbbttSelectorAlg.cxx +++ b/bbttAnalysis/src/HHbbttSelectorAlg.cxx @@ -65,8 +65,8 @@ namespace HHBBTT ATH_CHECK(m_selected_tau.initialize(m_systematicsList, m_tauHandle)); for (const auto& [channel, name] : m_triggerChannels){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco - {this, "pass_"+name, "EventInfo.pass_trigger_"+name}; + SG::ReadDecorHandleKey<xAOD::EventInfo> deco; + deco = "EventInfo.pass_trigger_"+name; m_trigPass_DecorKey.emplace(channel, deco); ATH_CHECK(m_trigPass_DecorKey.at(channel).initialize()); } @@ -94,13 +94,13 @@ namespace HHBBTT SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_SLT; ele_SLT = m_electronHandle.getNamePattern() + ".trigMatch_SLT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::SLT, ele_SLT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_LTT; + SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_LTT; ele_LTT = m_electronHandle.getNamePattern() + ".trigMatch_LTT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::LTT, ele_LTT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT; + SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT; ele_ETT = m_electronHandle.getNamePattern() + ".trigMatch_ETT"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT, ele_ETT); - SG::WriteDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; + SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; ele_ETT_4J12 = m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 9edf42cc0..425716c19 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -25,15 +25,15 @@ namespace HHBBTT // make trigger decorators for (const auto& trig : m_triggers){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco - {this, "trig"+trig, "EventInfo."+trig}; - m_triggerdecoKeys.emplace(trig, deco); + SG::ReadDecorHandleKey<xAOD::EventInfo> deco; + deco = "EventInfo." + trig; + m_triggerdecoKeys.emplace(trig, deco); ATH_CHECK(m_triggerdecoKeys.at(trig).initialize()); } for (const auto& [channel, name] : m_triggerChannels){ - SG::WriteDecorHandleKey<xAOD::EventInfo> deco - {this, "pass_"+name, "EventInfo.pass_trigger_"+name}; + SG::WriteDecorHandleKey<xAOD::EventInfo> deco; + deco = "EventInfo.pass_trigger_"+name; m_pass_DecorKey.emplace(channel, deco); ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); } @@ -140,7 +140,7 @@ namespace HHBBTT for(const xAOD::TauJet* tau : *taus){ tau_trigMatchDecos.at(channel)(*tau) = false; } - } + } unsigned int runNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); @@ -227,7 +227,7 @@ namespace HHBBTT } void TriggerDecoratorAlg::checkSingleMuTriggers - (int year, std::unordered_map<HHBBTT::RunBooleans, bool> /*runBoolMap*/, + (int year, std::unordered_map<HHBBTT::RunBooleans, bool> runBoolMap, const xAOD::EventInfo* eventInfo, const trigReadDecoMap& triggerdecos, passWriteDecoMap& pass_decos, const xAOD::MuonContainer* muons, @@ -241,7 +241,10 @@ namespace HHBBTT else if(2016<=year && year<=2018){ single_mu_paths = {"HLT_mu26_ivarmedium", "HLT_mu50"}; } - else if(2022<=year && year<=2023){ + else if(2022<=year && year<=2023 && + !runBoolMap.at(HHBBTT::is22_75bunches) && + !runBoolMap.at(HHBBTT::is23_75bunches) && + !runBoolMap.at(HHBBTT::is23_400bunches)){ single_mu_paths = { "HLT_mu24_ivarmedium_L1MU14FCH", "HLT_mu50_L1MU14FCH", "HLT_mu60_0eta105_msonly_L1MU14FCH", "HLT_mu60_L1MU14FCH", @@ -263,11 +266,11 @@ namespace HHBBTT } pass_decos.at(HHBBTT::SLT)(*eventInfo) |= trigPassed_SMT; - + } void TriggerDecoratorAlg::checkSingleEleTriggers - (int year, std::unordered_map<HHBBTT::RunBooleans, bool> /*runBoolMap*/, + (int year, std::unordered_map<HHBBTT::RunBooleans, bool> runBoolMap, const xAOD::EventInfo* eventInfo, const trigReadDecoMap& triggerdecos, passWriteDecoMap& pass_decos, const xAOD::ElectronContainer* electrons, @@ -283,23 +286,34 @@ namespace HHBBTT } else if(2016<=year && year<=2018){ single_ele_paths = { - "trigPassed_HLT_e26_lhtight_nod0_ivarloose", - "trigPassed_HLT_e60_lhmedium_nod0", - "trigPassed_HLT_e140_lhloose_nod0" + "HLT_e26_lhtight_nod0_ivarloose", "HLT_e60_lhmedium_nod0", + "HLT_e140_lhloose_nod0" + }; + } + else if(runBoolMap.at(HHBBTT::is22_75bunches)){ + single_ele_paths = { + "HLT_e17_lhvloose_L1EM15VHI", "HLT_e20_lhvloose_L1EM15VH", + "HLT_e250_etcut_L1EM22VHI" }; } else if(year==2022){ single_ele_paths = { - "trigPassed_HLT_e26_lhtight_ivarloose_L1EM22VHI", - "trigPassed_HLT_e60_lhmedium_L1EM22VHI", - "trigPassed_HLT_e140_lhloose_L1EM22VHI" + "HLT_e26_lhtight_ivarloose_L1EM22VHI", "HLT_e60_lhmedium_L1EM22VHI", + "HLT_e140_lhloose_L1EM22VHI", "HLT_e300_etcut_L1EM22VHI" + }; + } + else if(runBoolMap.at(HHBBTT::is23_75bunches)){ + single_ele_paths = { + "HLT_e26_lhtight_ivarloose_L1EM22VHI", "HLT_e60_lhmedium_L1EM22VHI", + "HLT_e140_lhloose_L1EM22VHI", "HLT_e140_lhloose_noringer_L1EM22VHI", + "HLT_e300_etcut_L1EM22VHI" }; } else if(year==2023){ single_ele_paths = { - "trigPassed_HLT_e26_lhtight_ivarloose_L1eEM26M", - "trigPassed_HLT_e60_lhmedium_L1eEM26M", - "trigPassed_HLT_e140_lhloose_L1eEM26M" + "HLT_e26_lhtight_ivarloose_L1eEM26M", "HLT_e60_lhmedium_L1eEM26M", + "HLT_e140_lhloose_L1eEM26M", "HLT_e140_lhloose_noringer_L1eEM26M", + "HLT_e300_etcut_L1eEM26M" }; } @@ -594,8 +608,8 @@ namespace HHBBTT "4J12_0ETA"); else if(channel==HHBBTT::DTT_L1Topo) trig2 = std::regex_replace(trig, - std::regex("L1DR_TAU20ITAU12I_J25"), - "L1DR-TAU20ITAU12I-J25"); + std::regex("L1DR_TAU20ITAU12I_J25"), + "L1DR-TAU20ITAU12I-J25"); for(const xAOD::TauJet* tau : *taus){ bool match = m_matchingTool->match(*tau, trig2, 0.2); if(!m_useDiTauTrigMatch) match = true; -- GitLab From 1e23075d4007769512ea859e4933223af7fc1b36 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Mon, 26 Feb 2024 16:32:11 +0100 Subject: [PATCH 07/68] Add inclusive trigMatchDecos --- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 425716c19..487ec8a86 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -391,10 +391,12 @@ namespace HHBBTT for(const xAOD::Muon* mu : *muons){ bool match = m_matchingTool->match(*mu, trig); mu_trigMatchDecos.at(channel)(*mu) |= match; + mu_trigMatchDecos.at(HHBBTT::LTT)(*mu) |= match; } for(const xAOD::TauJet* tau : *taus){ bool match = m_matchingTool->match(*tau, trig, 0.2); tau_trigMatchDecos.at(channel)(*tau) |= match; + tau_trigMatchDecos.at(HHBBTT::LTT)(*tau) |= match; } } } @@ -463,10 +465,12 @@ namespace HHBBTT for(const xAOD::Electron* ele : *electrons){ bool match = m_matchingTool->match(*ele, trig); ele_trigMatchDecos.at(channel)(*ele) |= match; + ele_trigMatchDecos.at(HHBBTT::LTT)(*ele) |= match; } for(const xAOD::TauJet* tau : *taus){ bool match = m_matchingTool->match(*tau, trig, 0.2); tau_trigMatchDecos.at(channel)(*tau) |= match; + tau_trigMatchDecos.at(HHBBTT::LTT)(*tau) |= match; } } } @@ -614,6 +618,7 @@ namespace HHBBTT bool match = m_matchingTool->match(*tau, trig2, 0.2); if(!m_useDiTauTrigMatch) match = true; tau_trigMatchDecos.at(channel)(*tau) |= match; + tau_trigMatchDecos.at(HHBBTT::DTT)(*tau) |= match; } } } -- GitLab From 1d971dac5347a5ca436d6b88f70927308f3b59ec Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 16:43:18 +0100 Subject: [PATCH 08/68] Add inclusice DTT trigger decoration --- EasyjetHub/src/TauDecoratorAlg.cxx | 137 ++++++++++++++--------- EasyjetHub/src/TauDecoratorAlg.h | 27 ++++- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 5 +- 3 files changed, 111 insertions(+), 58 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 75714e2c7..73b737826 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -28,20 +28,27 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); + if(m_doAntiTauDecor){ + // Muons + ele stuff to be cleaned up after trigger matching is used + ATH_CHECK (m_muonsInKey.initialize()); + ATH_CHECK (m_elesInKey.initialize()); + + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); + + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + + m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; + ATH_CHECK (m_eventCategoryDecorKey.initialize()); + } - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -56,70 +63,90 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { - + SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); + ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - - int nidtau = 0; - for(const xAOD::TauJet* tau : *tausIn) { - - nProngDecorHandle(*tau) = tau->nTracks(); - bool isTauID = tau->isTau(m_tauIDWP); - if(isTauID) nidtau++; - idTauDecorHandle(*tau) = isTauID; - - } + //SG::ReadDecorHandle<xAOD::TauJetContainer, char> triggerMatched(m_triggerMatchDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { - truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); + truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } - + int nlepton = 0; if(m_doAntiTauDecor){ - int nlepton = 0; + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + ATH_CHECK (elesIn.isValid()); + + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); + SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; + if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele)) nlepton++; + if(eleIdDecorHandle(*ele)) nlepton++; } - - int nantitau = 0; - int nantitau_max = -1; - if(nlepton>0) nantitau_max = 1 - nidtau; - else nantitau_max = 2 - nidtau; - - for(const xAOD::TauJet* tau : *tausIn) { - bool isAntiTau = false; - - // Trigger matching to be added here - if(nantitau < nantitau_max){ - bool isTauID = idTauDecorHandle(*tau); - float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - isAntiTau = !isTauID && RNNScore>0.01; - } - if (isAntiTau) nantitau++; - - antiTauDecorHandle(*tau) = isAntiTau; + } + int nidtau = 0; + int nantitau = 0; + for(const xAOD::TauJet* tau : *tausIn) { + nProngDecorHandle(*tau) = tau->nTracks(); + bool isTauID = tau->isTau(m_tauIDWP); + idTauDecorHandle(*tau) = isTauID; + if(isTauID) nidtau++; + //} + //bool antiIDTauRequired = (nidtau==0) || (nidtau==2 && isHadHad) || (nidtau==1 && isLepHad); + //bool antiIDTauRequired = true; + // for(const xAOD::TauJet* tau : *tausIn) { + if(m_doAntiTauDecor){//} && antiIDTauRequired){ + bool isTauID = tau->isTau(m_tauIDWP); + float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); + + // for SLT no anti-tau trigger matching is possible + // or two offline-taus might be matched to same trigger-tau + + bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; + + //bool isTriggerMatched = true; //TODO: triggerMatched(*tau) once !500 is merged + /* + bool STT = isSTT(ctx); + bool DTT = isDTT(ctx); + bool LTT = isLTT(ctx); + if (STT && nidtau == 0) isAntiTau &= triggerMatched(*tau); + else if (DTT) isAntiTau &= triggerMatched(*tau); + else if (LTT) isAntiTau &= triggerMatched(*tau); + else { + ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); + return StatusCode::FAILURE; + } + */ + if (isAntiTau) nantitau++; + int antiTauCategory = 0; + if (nlepton > 0 && isAntiTau) { + antiTauCategory = 1; + } + if (nlepton==0 && isAntiTau) { + antiTauCategory = 2; + } + + antiTauDecorHandle(*tau) = isAntiTau; + eventCategoryDecorHandle(*tau) = antiTauCategory; } } - + return StatusCode::SUCCESS; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 1b767de14..d06865446 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -93,15 +93,40 @@ private: SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_IDTauDecorKey; Gaudi::Property<bool> m_doAntiTauDecor - { this, "doAntiTauDecor", false, "Add anti-tau decoration" }; + { this, "doAntiTauDecor", true, "Add anti-tau decoration" }; Gaudi::Property<std::string> m_antiTauDecorName{ this, "antiTauDecorKey", "isAntiTau", "Decoration for anti-taus" }; + Gaudi::Property<double> m_antiTauRNNThreshold{ + this, "antiTauRNNThreshold", 0.01, "Lower threshold of RNN score for Anti-Id taus" + }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; + Gaudi::Property<std::string> m_eventCategoryDecorName{ + this, "eventCategoryDecorName", "antiTauEventCategory", "Decoration for (anti-Id) taus in hadhad events, 0 is for no anti-Tau, 1 for anti-Tau in lephad and 2 for anti-Tau in hadhad" + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_eventCategoryDecorKey; + + /* + Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ + this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTDecorName; + + Gaudi::Property<std::string> m_triggerMatchLTTDecorName{ + this, "triggerMatchLTTDecorName", "pass_trigger_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTDecorName; + + Gaudi::Property<std::string> m_triggerMatchDTTDecorName{ + this, "triggerMatchDTTDecorName", "pass_trigger_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTDecorName; + + */ }; } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 487ec8a86..c32a56d07 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -130,15 +130,16 @@ namespace HHBBTT for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ele_trigMatchDecos.emplace(channel, key); for(const xAOD::Electron* ele : *electrons){ - ele_trigMatchDecos.at(channel)(*ele) = false; + ele_trigMatchDecos.at(channel)(*ele) = false; } } tauTrigMatchWriteDecoMap tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); + std::cout << key << std::endl; for(const xAOD::TauJet* tau : *taus){ - tau_trigMatchDecos.at(channel)(*tau) = false; + tau_trigMatchDecos.at(channel)(*tau) = false; } } -- GitLab From 20b2155142bc3818b0b6835ef232686e14540130 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 17:20:42 +0100 Subject: [PATCH 09/68] Show test implementation for feedback --- EasyjetHub/src/TauDecoratorAlg.cxx | 42 +++++++++++++++++++----------- EasyjetHub/src/TauDecoratorAlg.h | 17 +++++++----- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 73b737826..6b20780ff 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -46,9 +46,18 @@ namespace Easyjet m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; ATH_CHECK (m_eventCategoryDecorKey.initialize()); - } + m_triggerMatchSLTKey = m_tausInKey.key() + "." + m_triggerMatchSLTDecorName; + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + + ATH_CHECK (m_triggerMatchSLTKey.initialize()); + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -107,11 +116,13 @@ namespace Easyjet bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(isTauID) nidtau++; - //} - //bool antiIDTauRequired = (nidtau==0) || (nidtau==2 && isHadHad) || (nidtau==1 && isLepHad); - //bool antiIDTauRequired = true; - // for(const xAOD::TauJet* tau : *tausIn) { - if(m_doAntiTauDecor){//} && antiIDTauRequired){ + + if(m_doAntiTauDecor){ + SG::ReadDecorHandle<xAOD::TauContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isSLTMatched(m_triggerMatchSLTKey); + bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); @@ -120,19 +131,20 @@ namespace Easyjet bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - //bool isTriggerMatched = true; //TODO: triggerMatched(*tau) once !500 is merged - /* - bool STT = isSTT(ctx); - bool DTT = isDTT(ctx); - bool LTT = isLTT(ctx); - if (STT && nidtau == 0) isAntiTau &= triggerMatched(*tau); - else if (DTT) isAntiTau &= triggerMatched(*tau); - else if (LTT) isAntiTau &= triggerMatched(*tau); + + bool STT = isSTTMatched(*tau); + bool DTT = isDTTMatched(*tau); + bool LTT = isLTTMatched(*tau); + bool SLT = isSLTMatched(*tau); + if (STT && nidtau == 0) isAntiTau &= isSTTMatched(*tau); + else if (DTT) isAntiTau &= isDTTMatched(*tau); + else if (LTT) isAntiTau &= isLTTMatched(*tau); + else if (STT || SLT) ; else { ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); return StatusCode::FAILURE; } - */ + if (isAntiTau) nantitau++; int antiTauCategory = 0; if (nlepton > 0 && isAntiTau) { diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index d06865446..9b0982b17 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -112,19 +112,24 @@ private: /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchSLTDecorName", "trigMatch_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTKey; + + Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ + this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSTTKey; Gaudi::Property<std::string> m_triggerMatchLTTDecorName{ - this, "triggerMatchLTTDecorName", "pass_trigger_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchLTTDecorName", "trigMatch_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTKey; Gaudi::Property<std::string> m_triggerMatchDTTDecorName{ - this, "triggerMatchDTTDecorName", "pass_trigger_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchDTTDecorName", "trigMatch_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; */ }; -- GitLab From 1fb1c91be8599d20339b4a8e8b2db97f84892e28 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 19:39:29 +0100 Subject: [PATCH 10/68] Remove lepton container from TauDecoratorAlg, implement trigger matching --- .../python/output/ttree/tau_decor_config.py | 8 +- EasyjetHub/src/TauDecoratorAlg.cxx | 109 ++++++------------ EasyjetHub/src/TauDecoratorAlg.h | 43 +------ bbttAnalysis/src/TriggerDecoratorAlg.cxx | 1 - 4 files changed, 45 insertions(+), 116 deletions(-) diff --git a/EasyjetHub/python/output/ttree/tau_decor_config.py b/EasyjetHub/python/output/ttree/tau_decor_config.py index 0162aa9f8..8c76b876b 100644 --- a/EasyjetHub/python/output/ttree/tau_decor_config.py +++ b/EasyjetHub/python/output/ttree/tau_decor_config.py @@ -4,8 +4,8 @@ from AthenaConfiguration.ComponentFactory import CompFactory def tau_decor_cfg(flags, **kwargs): # Could make this configurable - muoncoll = flags.Analysis.container_names.input.muons - elecoll = flags.Analysis.container_names.input.electrons + #muoncoll = flags.Analysis.container_names.input.muons + #elecoll = flags.Analysis.container_names.input.electrons taucoll = flags.Analysis.container_names.input.taus cfg = ComponentAccumulator() @@ -23,8 +23,8 @@ def tau_decor_cfg(flags, **kwargs): isMC=flags.Input.isMC, tauIDWP=flags.Analysis.Tau.ID, doAntiTauDecor=flags.Analysis.do_bbtt_analysis, - muonsIn=muoncoll, - elesIn=elecoll, + #muonsIn=muoncoll, + #elesIn=elecoll, tausIn=taucoll, **kwargs ) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 6b20780ff..cae2e10f5 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -18,6 +18,7 @@ namespace Easyjet StatusCode TauDecoratorAlg ::initialize() { + ATH_CHECK (m_eventInfoKey.initialize()); ATH_CHECK (m_tausInKey.initialize()); m_nProngDecorKey = m_tausInKey.key() + "." + m_nProngDecorName; @@ -28,36 +29,20 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - if(m_doAntiTauDecor){ - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); - - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); - - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - - m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; - ATH_CHECK (m_eventCategoryDecorKey.initialize()); - - m_triggerMatchSLTKey = m_tausInKey.key() + "." + m_triggerMatchSLTDecorName; - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - - ATH_CHECK (m_triggerMatchSLTKey.initialize()); - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - - } + //if(m_doAntiTauDecor){ + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + //SLT needs to be read from Ele or Mu, or event info + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + //} + + m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; + ATH_CHECK (m_triggerSLTKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -79,10 +64,7 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - //SG::ReadDecorHandle<xAOD::TauJetContainer, char> triggerMatched(m_triggerMatchDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); if(m_isMC){ @@ -91,71 +73,50 @@ namespace Easyjet truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } - int nlepton = 0; - if(m_doAntiTauDecor){ - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - - for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; - } - for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele)) nlepton++; - } - } - int nidtau = 0; + + int nIdTauSTT = 0; int nantitau = 0; + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_triggerSLTKey); for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; - if(isTauID) nidtau++; - if(m_doAntiTauDecor){ - SG::ReadDecorHandle<xAOD::TauContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isDTTMatched(m_triggerMatchDTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isLTTMatched(m_triggerMatchLTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isSLTMatched(m_triggerMatchSLTKey); - + if(isTauID && isSTTMatched(*tau)) nIdTauSTT++; + } + } + if(m_doAntiTauDecor){ + for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - // for SLT no anti-tau trigger matching is possible - // or two offline-taus might be matched to same trigger-tau - bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - bool STT = isSTTMatched(*tau); bool DTT = isDTTMatched(*tau); bool LTT = isLTTMatched(*tau); - bool SLT = isSLTMatched(*tau); - if (STT && nidtau == 0) isAntiTau &= isSTTMatched(*tau); + //bool SLT = isSLT(*eventInfo); + + // for SLT no anti-tau trigger matching is possible + // or two offline-taus might be matched to same trigger-tau + if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - else if (STT || SLT) ; + /* + else if (SLT || STT) ; else { ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); return StatusCode::FAILURE; } + */ + if (isAntiTau) nantitau++; - int antiTauCategory = 0; - if (nlepton > 0 && isAntiTau) { - antiTauCategory = 1; - } - if (nlepton==0 && isAntiTau) { - antiTauCategory = 2; - } antiTauDecorHandle(*tau) = isAntiTau; - eventCategoryDecorHandle(*tau) = antiTauCategory; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 9b0982b17..c8e9f86c2 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -17,9 +17,9 @@ #include <AsgDataHandles/WriteDecorHandleKey.h> #include <AthenaBaseComps/AthReentrantAlgorithm.h> + +#include <xAODEventInfo/EventInfo.h> #include <xAODTau/TauJetContainer.h> -#include <xAODMuon/MuonContainer.h> -#include <xAODEgamma/ElectronContainer.h> namespace Easyjet @@ -43,35 +43,11 @@ public: private: // Members for configurable properties - + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey + { this, "event", "EventInfo", "EventInfo to read" }; Gaudi::Property<bool> m_isMC { this, "isMC", false, "Is this simulation?" }; - // Muons - SG::ReadHandleKey<xAOD::MuonContainer> m_muonsInKey{ - this, "muonsIn", "", "containerName to read" - }; - - Gaudi::Property<std::string> m_muonIdDecorName - { this, "muonIdDecorKey", "DFCommonMuonPassIDCuts", - "Decoration for muon ID cuts" }; - SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonIdDecorKey; - - Gaudi::Property<std::string> m_muonPreselDecorName - { this, "muonPreselDecorKey", "DFCommonMuonPassPreselection", - "Decoration for muon preselection" }; - SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonPreselDecorKey; - - // Electrons - SG::ReadHandleKey<xAOD::ElectronContainer> m_elesInKey{ - this, "elesIn", "", "containerName to read" - }; - - Gaudi::Property<std::string> m_eleIdDecorName - { this, "eleIdDecorKey", "DFCommonElectronsLHTight", - "Decoration for electron ID working point" }; - SG::ReadDecorHandleKey<xAOD::ElectronContainer> m_eleIdDecorKey; - // Taus SG::ReadHandleKey<xAOD::TauJetContainer> m_tausInKey{ this, "tausIn", "", "containerName to read" @@ -105,16 +81,10 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; - Gaudi::Property<std::string> m_eventCategoryDecorName{ - this, "eventCategoryDecorName", "antiTauEventCategory", "Decoration for (anti-Id) taus in hadhad events, 0 is for no anti-Tau, 1 for anti-Tau in lephad and 2 for anti-Tau in hadhad" - }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_eventCategoryDecorKey; - - /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "trigMatch_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? }; - SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTKey; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? @@ -131,7 +101,6 @@ private: }; SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; - */ }; } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index c32a56d07..2f6bcd228 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -137,7 +137,6 @@ namespace HHBBTT tauTrigMatchWriteDecoMap tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); - std::cout << key << std::endl; for(const xAOD::TauJet* tau : *taus){ tau_trigMatchDecos.at(channel)(*tau) = false; } -- GitLab From df381e11e1227ab246ec8410fa4ec78e3d09b257 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Tue, 27 Feb 2024 17:37:17 +0100 Subject: [PATCH 11/68] Get trigger decoration to not crash for now --- EasyjetHub/src/TauDecoratorAlg.cxx | 85 ++++++++++++++++++++++-------- EasyjetHub/src/TauDecoratorAlg.h | 28 +++++++++- 2 files changed, 90 insertions(+), 23 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index cae2e10f5..8d73eb795 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -36,13 +36,39 @@ namespace Easyjet m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + std::cout << m_triggerMatchDTTKey << std::endl; ATH_CHECK (m_triggerMatchSTTKey.initialize()); ATH_CHECK (m_triggerMatchLTTKey.initialize()); ATH_CHECK (m_triggerMatchDTTKey.initialize()); + std::cout << m_triggerMatchDTTKey << std::endl; //} - - m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; - ATH_CHECK (m_triggerSLTKey.initialize()); + std::cout << "Start initializing the event trigger category keys" << std::endl; + /* + for (const auto& [channel, name] : m_triggerChannels){ + SG::ReadDecorHandleKey<xAOD::EventInfo> deco; + //std::cout << name << std::endl; + deco = "EventInfo.pass_trigger_"+name; + //ATH_CHECK(deco.initialize()); + m_pass_DecorKey.emplace(channel, deco); + std::cout << m_pass_DecorKey.at(channel) << std::endl; + ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); + }*/ + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); +/* + for (int i = 0; i < 4; ++i){ + std::cout << m_pass_DecorKey.at(i) << std::endl; + } + */ + //m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; + //ATH_CHECK (m_triggerSLTKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -57,8 +83,10 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { + std::cout << "Start exec" << std::endl; SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); + std::cout << "Event info handle set up" << std::endl; SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); @@ -66,7 +94,30 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + +/* + for (int i = 0; i < 4; ++i){ + std::cout << m_pass_DecorKey.at(i) << std::endl; + } +*/ + std::cout << "Start getting trigger category handles" << std::endl; + std::cout << m_triggerChannels_inverted.at("SLT") << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); + std::cout << "Got SLT category handles" << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); + /* + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("SLT"))); + std::cout << "Got SLT category handles" << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("LTT"))); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("STT"))); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("DTT"))); + */ if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -76,10 +127,7 @@ namespace Easyjet int nIdTauSTT = 0; int nantitau = 0; - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_triggerSLTKey); + for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); @@ -89,33 +137,28 @@ namespace Easyjet } } if(m_doAntiTauDecor){ + bool STT = isSTT(*eventInfo); + bool DTT = isDTT(*eventInfo); + bool LTT = isLTT(*eventInfo); + std::cout << "SLT event decoration" << std::endl; + bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - - bool STT = isSTTMatched(*tau); - bool DTT = isDTTMatched(*tau); - bool LTT = isLTTMatched(*tau); - //bool SLT = isSLT(*eventInfo); - + // for SLT no anti-tau trigger matching is possible // or two offline-taus might be matched to same trigger-tau if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - /* - else if (SLT || STT) ; + else if (STT || SLT) ; else { - ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); - return StatusCode::FAILURE; + std::cout << "Weired stuff is going on (if trig_bypass is on)" << std::endl; } - */ - - - if (isAntiTau) nantitau++; + if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index c8e9f86c2..709b56449 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -16,6 +16,7 @@ #include <utility> #include <AsgDataHandles/WriteDecorHandleKey.h> +#include <AsgDataHandles/ReadDecorHandleKey.h> #include <AthenaBaseComps/AthReentrantAlgorithm.h> #include <xAODEventInfo/EventInfo.h> @@ -41,7 +42,29 @@ public: private: - + std::unordered_map<int, std::string> m_triggerChannels = + { + {0, "SLT"}, + {1, "LTT"}, + {2, "STT"}, + {3, "DTT"}, + }; + + std::unordered_map<std::string, int> m_triggerChannels_inverted = + { + {"SLT", 0}, + {"LTT", 1}, + {"STT", 2}, + {"DTT", 3}, + }; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyDTT; + std::unordered_map<int, + SG::WriteDecorHandleKey<xAOD::EventInfo> > m_pass_DecorKey; + std::unordered_map<std::string, SG::ReadDecorHandleKey<xAOD::EventInfo> > + m_triggerdecoKeys; // Members for configurable properties SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey { this, "event", "EventInfo", "EventInfo to read" }; @@ -81,11 +104,12 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; + /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? }; SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; - +*/ Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? }; -- GitLab From b75c0f43d0d3135dfaf28397244bda12873ba265 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 13:10:43 +0100 Subject: [PATCH 12/68] Make trigger decoration for events possible --- EasyjetHub/src/TauDecoratorAlg.cxx | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 8d73eb795..4dca894c3 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -36,13 +36,10 @@ namespace Easyjet m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - std::cout << m_triggerMatchDTTKey << std::endl; ATH_CHECK (m_triggerMatchSTTKey.initialize()); ATH_CHECK (m_triggerMatchLTTKey.initialize()); ATH_CHECK (m_triggerMatchDTTKey.initialize()); - std::cout << m_triggerMatchDTTKey << std::endl; //} - std::cout << "Start initializing the event trigger category keys" << std::endl; /* for (const auto& [channel, name] : m_triggerChannels){ SG::ReadDecorHandleKey<xAOD::EventInfo> deco; @@ -83,10 +80,8 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { - std::cout << "Start exec" << std::endl; SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); - std::cout << "Event info handle set up" << std::endl; SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); @@ -103,11 +98,8 @@ namespace Easyjet std::cout << m_pass_DecorKey.at(i) << std::endl; } */ - std::cout << "Start getting trigger category handles" << std::endl; - std::cout << m_triggerChannels_inverted.at("SLT") << std::endl; SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); - std::cout << "Got SLT category handles" << std::endl; SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); @@ -140,7 +132,6 @@ namespace Easyjet bool STT = isSTT(*eventInfo); bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); - std::cout << "SLT event decoration" << std::endl; bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); @@ -153,11 +144,7 @@ namespace Easyjet if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - else if (STT || SLT) ; - else { - std::cout << "Weired stuff is going on (if trig_bypass is on)" << std::endl; - } - + if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } -- GitLab From 292d7ff21494640eb1e5b171286d6cf8009842c0 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:19:37 +0100 Subject: [PATCH 13/68] Clean code from comments and developement artifacts --- EasyjetHub/src/TauDecoratorAlg.cxx | 84 +++++++++++------------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 4dca894c3..28d0056e1 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -29,43 +29,26 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - //if(m_doAntiTauDecor){ - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - //SLT needs to be read from Ele or Mu, or event info - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - //} - /* - for (const auto& [channel, name] : m_triggerChannels){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco; - //std::cout << name << std::endl; - deco = "EventInfo.pass_trigger_"+name; - //ATH_CHECK(deco.initialize()); - m_pass_DecorKey.emplace(channel, deco); - std::cout << m_pass_DecorKey.at(channel) << std::endl; - ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); - }*/ - m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; - m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; - m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; - m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - - ATH_CHECK(m_pass_DecorKeySLT.initialize()); - ATH_CHECK(m_pass_DecorKeyLTT.initialize()); - ATH_CHECK(m_pass_DecorKeySTT.initialize()); - ATH_CHECK(m_pass_DecorKeyDTT.initialize()); -/* - for (int i = 0; i < 4; ++i){ - std::cout << m_pass_DecorKey.at(i) << std::endl; - } - */ - //m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; - //ATH_CHECK (m_triggerSLTKey.initialize()); + if(m_doAntiTauDecor){ + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); + } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -80,36 +63,27 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { + // input handles SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); - SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - + // trigger tau decorators SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); -/* - for (int i = 0; i < 4; ++i){ - std::cout << m_pass_DecorKey.at(i) << std::endl; - } -*/ - + // trigger event decorators SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); - /* - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("SLT"))); - std::cout << "Got SLT category handles" << std::endl; - SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("LTT"))); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("STT"))); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("DTT"))); - */ + + SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -132,7 +106,7 @@ namespace Easyjet bool STT = isSTT(*eventInfo); bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); - bool SLT = isSLT(*eventInfo); + //bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); -- GitLab From 814c764c7eb35592aa3f78f590524849998e9ed8 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:23:17 +0100 Subject: [PATCH 14/68] Remove unsed counter for antitaus --- EasyjetHub/src/TauDecoratorAlg.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 28d0056e1..1ba2c7c7f 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -91,15 +91,14 @@ namespace Easyjet } } - int nIdTauSTT = 0; - int nantitau = 0; + int nIDTauSTT = 0; for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(m_doAntiTauDecor){ - if(isTauID && isSTTMatched(*tau)) nIdTauSTT++; + if(isTauID && isSTTMatched(*tau)) nIDTauSTT++; } } if(m_doAntiTauDecor){ @@ -115,11 +114,10 @@ namespace Easyjet // for SLT no anti-tau trigger matching is possible // or two offline-taus might be matched to same trigger-tau - if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); + if (STT && nIDTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } } -- GitLab From 31458cdfdbe6f76c04c1bf6c2e06b63bbe9f0c16 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:24:33 +0100 Subject: [PATCH 15/68] Clean up TauDecoratorAlg.h --- EasyjetHub/src/TauDecoratorAlg.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 709b56449..598cc7481 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -42,21 +42,6 @@ public: private: - std::unordered_map<int, std::string> m_triggerChannels = - { - {0, "SLT"}, - {1, "LTT"}, - {2, "STT"}, - {3, "DTT"}, - }; - - std::unordered_map<std::string, int> m_triggerChannels_inverted = - { - {"SLT", 0}, - {"LTT", 1}, - {"STT", 2}, - {"DTT", 3}, - }; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; @@ -104,12 +89,6 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; - /* - Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? - }; - SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; -*/ Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? }; -- GitLab From 706216281835ba0c9886dd70afe034a027960803 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 17:00:54 +0100 Subject: [PATCH 16/68] Get current status from bbttTrigDecoratorAlg --- bbttAnalysis/src/HHbbttChannels.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index fd757e802..deef5372b 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -46,6 +46,22 @@ namespace HHBBTT DTT_L1Topo, }; + enum TriggerChannel + { + SLT, + LTT, + ETT, + ETT_4J12, + MTT_2016, + MTT_high, + MTT_low, + STT, + DTT, + DTT_2016, + DTT_4J12, + DTT_L1Topo, + }; + } #endif -- GitLab From b70c5c3f290949888744f3249e8e4b26dcfdd09c Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 1 Mar 2024 10:57:02 +0100 Subject: [PATCH 17/68] Add some output variables for verification studies and explicit STT check for ID tau matched to STT counting --- EasyjetHub/python/output/ttree/taus.py | 2 +- EasyjetHub/src/TauDecoratorAlg.cxx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 9707f5ef5..66b1ff686 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,7 +19,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau"] + tau_branches.variables += ["isAntiTau", "RNNJetScoreSigTrans", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 1ba2c7c7f..90999bf8e 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -71,8 +71,8 @@ namespace Easyjet // trigger tau decorators SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); // trigger event decorators SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); @@ -98,7 +98,8 @@ namespace Easyjet bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(m_doAntiTauDecor){ - if(isTauID && isSTTMatched(*tau)) nIDTauSTT++; + bool STT = isSTT(*eventInfo); + if(isTauID && isSTTMatched(*tau) && STT) nIDTauSTT++; } } if(m_doAntiTauDecor){ -- GitLab From 7e20aab3be1015f1b2beabcfabe65e10b6e843c7 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 1 Mar 2024 13:21:04 +0100 Subject: [PATCH 18/68] Remove unneded member variables --- EasyjetHub/src/TauDecoratorAlg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 598cc7481..d4fc8e1a3 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -46,10 +46,7 @@ private: SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyDTT; - std::unordered_map<int, - SG::WriteDecorHandleKey<xAOD::EventInfo> > m_pass_DecorKey; - std::unordered_map<std::string, SG::ReadDecorHandleKey<xAOD::EventInfo> > - m_triggerdecoKeys; + // Members for configurable properties SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey { this, "event", "EventInfo", "EventInfo to read" }; -- GitLab From ee7dd4176036ba6225769926b44d27c2a723fb88 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 02:10:48 +0100 Subject: [PATCH 19/68] Outsource bbtautau trigger selection and matching to decorator alg --- bbttAnalysis/src/HHbbttChannels.h | 16 ++++++++++++++++ bbttAnalysis/src/HHbbttSelectorAlg.cxx | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index 4d67b441b..fd757e802 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -30,6 +30,22 @@ namespace HHBBTT DTT_L1Topo, }; + enum TriggerChannel + { + SLT, + LTT, + ETT, + ETT_4J12, + MTT_2016, + MTT_high, + MTT_low, + STT, + DTT, + DTT_2016, + DTT_4J12, + DTT_L1Topo, + }; + } #endif diff --git a/bbttAnalysis/src/HHbbttSelectorAlg.cxx b/bbttAnalysis/src/HHbbttSelectorAlg.cxx index 8f44f33bf..2526fb92c 100644 --- a/bbttAnalysis/src/HHbbttSelectorAlg.cxx +++ b/bbttAnalysis/src/HHbbttSelectorAlg.cxx @@ -103,7 +103,7 @@ namespace HHBBTT SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; ele_ETT_4J12 = m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); - + for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ATH_CHECK(m_ele_trigMatch_DecorKey.at(channel).initialize()); } -- GitLab From 4708d35bad8fd73e207f839cc6f253de60b8e2de Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Thu, 22 Feb 2024 13:57:19 +0100 Subject: [PATCH 20/68] Updated initialization --- bbttAnalysis/src/HHbbttSelectorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbttAnalysis/src/HHbbttSelectorAlg.cxx b/bbttAnalysis/src/HHbbttSelectorAlg.cxx index 2526fb92c..8f44f33bf 100644 --- a/bbttAnalysis/src/HHbbttSelectorAlg.cxx +++ b/bbttAnalysis/src/HHbbttSelectorAlg.cxx @@ -103,7 +103,7 @@ namespace HHBBTT SG::ReadDecorHandleKey<xAOD::ElectronContainer> ele_ETT_4J12; ele_ETT_4J12 = m_electronHandle.getNamePattern() + ".trigMatch_ETT_4J12"; m_ele_trigMatch_DecorKey.emplace(HHBBTT::ETT_4J12, ele_ETT_4J12); - + for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ATH_CHECK(m_ele_trigMatch_DecorKey.at(channel).initialize()); } -- GitLab From ecc4063532ef1a24994f5eddcf225e1522df3c3a Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 16:43:18 +0100 Subject: [PATCH 21/68] Add inclusice DTT trigger decoration --- EasyjetHub/src/TauDecoratorAlg.cxx | 137 ++++++++++++++--------- EasyjetHub/src/TauDecoratorAlg.h | 27 ++++- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 5 +- 3 files changed, 111 insertions(+), 58 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 75714e2c7..73b737826 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -28,20 +28,27 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); + if(m_doAntiTauDecor){ + // Muons + ele stuff to be cleaned up after trigger matching is used + ATH_CHECK (m_muonsInKey.initialize()); + ATH_CHECK (m_elesInKey.initialize()); + + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); + + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + + m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; + ATH_CHECK (m_eventCategoryDecorKey.initialize()); + } - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -56,70 +63,90 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { - + SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); + ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - - int nidtau = 0; - for(const xAOD::TauJet* tau : *tausIn) { - - nProngDecorHandle(*tau) = tau->nTracks(); - bool isTauID = tau->isTau(m_tauIDWP); - if(isTauID) nidtau++; - idTauDecorHandle(*tau) = isTauID; - - } + //SG::ReadDecorHandle<xAOD::TauJetContainer, char> triggerMatched(m_triggerMatchDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { - truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); + truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } - + int nlepton = 0; if(m_doAntiTauDecor){ - int nlepton = 0; + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + ATH_CHECK (elesIn.isValid()); + + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); + SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; + if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele)) nlepton++; + if(eleIdDecorHandle(*ele)) nlepton++; } - - int nantitau = 0; - int nantitau_max = -1; - if(nlepton>0) nantitau_max = 1 - nidtau; - else nantitau_max = 2 - nidtau; - - for(const xAOD::TauJet* tau : *tausIn) { - bool isAntiTau = false; - - // Trigger matching to be added here - if(nantitau < nantitau_max){ - bool isTauID = idTauDecorHandle(*tau); - float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - isAntiTau = !isTauID && RNNScore>0.01; - } - if (isAntiTau) nantitau++; - - antiTauDecorHandle(*tau) = isAntiTau; + } + int nidtau = 0; + int nantitau = 0; + for(const xAOD::TauJet* tau : *tausIn) { + nProngDecorHandle(*tau) = tau->nTracks(); + bool isTauID = tau->isTau(m_tauIDWP); + idTauDecorHandle(*tau) = isTauID; + if(isTauID) nidtau++; + //} + //bool antiIDTauRequired = (nidtau==0) || (nidtau==2 && isHadHad) || (nidtau==1 && isLepHad); + //bool antiIDTauRequired = true; + // for(const xAOD::TauJet* tau : *tausIn) { + if(m_doAntiTauDecor){//} && antiIDTauRequired){ + bool isTauID = tau->isTau(m_tauIDWP); + float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); + + // for SLT no anti-tau trigger matching is possible + // or two offline-taus might be matched to same trigger-tau + + bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; + + //bool isTriggerMatched = true; //TODO: triggerMatched(*tau) once !500 is merged + /* + bool STT = isSTT(ctx); + bool DTT = isDTT(ctx); + bool LTT = isLTT(ctx); + if (STT && nidtau == 0) isAntiTau &= triggerMatched(*tau); + else if (DTT) isAntiTau &= triggerMatched(*tau); + else if (LTT) isAntiTau &= triggerMatched(*tau); + else { + ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); + return StatusCode::FAILURE; + } + */ + if (isAntiTau) nantitau++; + int antiTauCategory = 0; + if (nlepton > 0 && isAntiTau) { + antiTauCategory = 1; + } + if (nlepton==0 && isAntiTau) { + antiTauCategory = 2; + } + + antiTauDecorHandle(*tau) = isAntiTau; + eventCategoryDecorHandle(*tau) = antiTauCategory; } } - + return StatusCode::SUCCESS; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 1b767de14..d06865446 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -93,15 +93,40 @@ private: SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_IDTauDecorKey; Gaudi::Property<bool> m_doAntiTauDecor - { this, "doAntiTauDecor", false, "Add anti-tau decoration" }; + { this, "doAntiTauDecor", true, "Add anti-tau decoration" }; Gaudi::Property<std::string> m_antiTauDecorName{ this, "antiTauDecorKey", "isAntiTau", "Decoration for anti-taus" }; + Gaudi::Property<double> m_antiTauRNNThreshold{ + this, "antiTauRNNThreshold", 0.01, "Lower threshold of RNN score for Anti-Id taus" + }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; + Gaudi::Property<std::string> m_eventCategoryDecorName{ + this, "eventCategoryDecorName", "antiTauEventCategory", "Decoration for (anti-Id) taus in hadhad events, 0 is for no anti-Tau, 1 for anti-Tau in lephad and 2 for anti-Tau in hadhad" + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_eventCategoryDecorKey; + + /* + Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ + this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTDecorName; + + Gaudi::Property<std::string> m_triggerMatchLTTDecorName{ + this, "triggerMatchLTTDecorName", "pass_trigger_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTDecorName; + + Gaudi::Property<std::string> m_triggerMatchDTTDecorName{ + this, "triggerMatchDTTDecorName", "pass_trigger_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTDecorName; + + */ }; } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 487ec8a86..c32a56d07 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -130,15 +130,16 @@ namespace HHBBTT for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ele_trigMatchDecos.emplace(channel, key); for(const xAOD::Electron* ele : *electrons){ - ele_trigMatchDecos.at(channel)(*ele) = false; + ele_trigMatchDecos.at(channel)(*ele) = false; } } tauTrigMatchWriteDecoMap tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); + std::cout << key << std::endl; for(const xAOD::TauJet* tau : *taus){ - tau_trigMatchDecos.at(channel)(*tau) = false; + tau_trigMatchDecos.at(channel)(*tau) = false; } } -- GitLab From 77738ef2719837d69c5c9268ce4e0fd0876dbfd8 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 17:20:42 +0100 Subject: [PATCH 22/68] Show test implementation for feedback --- EasyjetHub/src/TauDecoratorAlg.cxx | 42 +++++++++++++++++++----------- EasyjetHub/src/TauDecoratorAlg.h | 17 +++++++----- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 73b737826..6b20780ff 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -46,9 +46,18 @@ namespace Easyjet m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; ATH_CHECK (m_eventCategoryDecorKey.initialize()); - } + m_triggerMatchSLTKey = m_tausInKey.key() + "." + m_triggerMatchSLTDecorName; + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + + ATH_CHECK (m_triggerMatchSLTKey.initialize()); + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -107,11 +116,13 @@ namespace Easyjet bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(isTauID) nidtau++; - //} - //bool antiIDTauRequired = (nidtau==0) || (nidtau==2 && isHadHad) || (nidtau==1 && isLepHad); - //bool antiIDTauRequired = true; - // for(const xAOD::TauJet* tau : *tausIn) { - if(m_doAntiTauDecor){//} && antiIDTauRequired){ + + if(m_doAntiTauDecor){ + SG::ReadDecorHandle<xAOD::TauContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::TauContainer, bool> isSLTMatched(m_triggerMatchSLTKey); + bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); @@ -120,19 +131,20 @@ namespace Easyjet bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - //bool isTriggerMatched = true; //TODO: triggerMatched(*tau) once !500 is merged - /* - bool STT = isSTT(ctx); - bool DTT = isDTT(ctx); - bool LTT = isLTT(ctx); - if (STT && nidtau == 0) isAntiTau &= triggerMatched(*tau); - else if (DTT) isAntiTau &= triggerMatched(*tau); - else if (LTT) isAntiTau &= triggerMatched(*tau); + + bool STT = isSTTMatched(*tau); + bool DTT = isDTTMatched(*tau); + bool LTT = isLTTMatched(*tau); + bool SLT = isSLTMatched(*tau); + if (STT && nidtau == 0) isAntiTau &= isSTTMatched(*tau); + else if (DTT) isAntiTau &= isDTTMatched(*tau); + else if (LTT) isAntiTau &= isLTTMatched(*tau); + else if (STT || SLT) ; else { ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); return StatusCode::FAILURE; } - */ + if (isAntiTau) nantitau++; int antiTauCategory = 0; if (nlepton > 0 && isAntiTau) { diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index d06865446..9b0982b17 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -112,19 +112,24 @@ private: /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchSLTDecorName", "trigMatch_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTKey; + + Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ + this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? + }; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSTTKey; Gaudi::Property<std::string> m_triggerMatchLTTDecorName{ - this, "triggerMatchLTTDecorName", "pass_trigger_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchLTTDecorName", "trigMatch_LTT", "Decoration for LTT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchLTTKey; Gaudi::Property<std::string> m_triggerMatchDTTDecorName{ - this, "triggerMatchDTTDecorName", "pass_trigger_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchDTTDecorName", "trigMatch_DTT", "Decoration for DTT trigger matched (anti-Id) taus" //or maybe general objects? }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTDecorName; + SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; */ }; -- GitLab From fc705485523455602dacd581f336c00c9a700dbb Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 26 Feb 2024 19:39:29 +0100 Subject: [PATCH 23/68] Remove lepton container from TauDecoratorAlg, implement trigger matching --- .../python/output/ttree/tau_decor_config.py | 8 +- EasyjetHub/src/TauDecoratorAlg.cxx | 109 ++++++------------ EasyjetHub/src/TauDecoratorAlg.h | 43 +------ bbttAnalysis/src/TriggerDecoratorAlg.cxx | 1 - 4 files changed, 45 insertions(+), 116 deletions(-) diff --git a/EasyjetHub/python/output/ttree/tau_decor_config.py b/EasyjetHub/python/output/ttree/tau_decor_config.py index 0162aa9f8..8c76b876b 100644 --- a/EasyjetHub/python/output/ttree/tau_decor_config.py +++ b/EasyjetHub/python/output/ttree/tau_decor_config.py @@ -4,8 +4,8 @@ from AthenaConfiguration.ComponentFactory import CompFactory def tau_decor_cfg(flags, **kwargs): # Could make this configurable - muoncoll = flags.Analysis.container_names.input.muons - elecoll = flags.Analysis.container_names.input.electrons + #muoncoll = flags.Analysis.container_names.input.muons + #elecoll = flags.Analysis.container_names.input.electrons taucoll = flags.Analysis.container_names.input.taus cfg = ComponentAccumulator() @@ -23,8 +23,8 @@ def tau_decor_cfg(flags, **kwargs): isMC=flags.Input.isMC, tauIDWP=flags.Analysis.Tau.ID, doAntiTauDecor=flags.Analysis.do_bbtt_analysis, - muonsIn=muoncoll, - elesIn=elecoll, + #muonsIn=muoncoll, + #elesIn=elecoll, tausIn=taucoll, **kwargs ) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 6b20780ff..cae2e10f5 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -18,6 +18,7 @@ namespace Easyjet StatusCode TauDecoratorAlg ::initialize() { + ATH_CHECK (m_eventInfoKey.initialize()); ATH_CHECK (m_tausInKey.initialize()); m_nProngDecorKey = m_tausInKey.key() + "." + m_nProngDecorName; @@ -28,36 +29,20 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - if(m_doAntiTauDecor){ - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); - - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); - - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - - m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; - ATH_CHECK (m_eventCategoryDecorKey.initialize()); - - m_triggerMatchSLTKey = m_tausInKey.key() + "." + m_triggerMatchSLTDecorName; - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - - ATH_CHECK (m_triggerMatchSLTKey.initialize()); - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - - } + //if(m_doAntiTauDecor){ + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + //SLT needs to be read from Ele or Mu, or event info + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + //} + + m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; + ATH_CHECK (m_triggerSLTKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -79,10 +64,7 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - //SG::ReadDecorHandle<xAOD::TauJetContainer, char> triggerMatched(m_triggerMatchDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); if(m_isMC){ @@ -91,71 +73,50 @@ namespace Easyjet truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } - int nlepton = 0; - if(m_doAntiTauDecor){ - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); - - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); - SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); - SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); - - for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) nlepton++; - } - for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele)) nlepton++; - } - } - int nidtau = 0; + + int nIdTauSTT = 0; int nantitau = 0; + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_triggerSLTKey); for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; - if(isTauID) nidtau++; - if(m_doAntiTauDecor){ - SG::ReadDecorHandle<xAOD::TauContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isDTTMatched(m_triggerMatchDTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isLTTMatched(m_triggerMatchLTTKey); - SG::ReadDecorHandle<xAOD::TauContainer, bool> isSLTMatched(m_triggerMatchSLTKey); - + if(isTauID && isSTTMatched(*tau)) nIdTauSTT++; + } + } + if(m_doAntiTauDecor){ + for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - // for SLT no anti-tau trigger matching is possible - // or two offline-taus might be matched to same trigger-tau - bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - bool STT = isSTTMatched(*tau); bool DTT = isDTTMatched(*tau); bool LTT = isLTTMatched(*tau); - bool SLT = isSLTMatched(*tau); - if (STT && nidtau == 0) isAntiTau &= isSTTMatched(*tau); + //bool SLT = isSLT(*eventInfo); + + // for SLT no anti-tau trigger matching is possible + // or two offline-taus might be matched to same trigger-tau + if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - else if (STT || SLT) ; + /* + else if (SLT || STT) ; else { ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); return StatusCode::FAILURE; } + */ + if (isAntiTau) nantitau++; - int antiTauCategory = 0; - if (nlepton > 0 && isAntiTau) { - antiTauCategory = 1; - } - if (nlepton==0 && isAntiTau) { - antiTauCategory = 2; - } antiTauDecorHandle(*tau) = isAntiTau; - eventCategoryDecorHandle(*tau) = antiTauCategory; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 9b0982b17..c8e9f86c2 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -17,9 +17,9 @@ #include <AsgDataHandles/WriteDecorHandleKey.h> #include <AthenaBaseComps/AthReentrantAlgorithm.h> + +#include <xAODEventInfo/EventInfo.h> #include <xAODTau/TauJetContainer.h> -#include <xAODMuon/MuonContainer.h> -#include <xAODEgamma/ElectronContainer.h> namespace Easyjet @@ -43,35 +43,11 @@ public: private: // Members for configurable properties - + SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey + { this, "event", "EventInfo", "EventInfo to read" }; Gaudi::Property<bool> m_isMC { this, "isMC", false, "Is this simulation?" }; - // Muons - SG::ReadHandleKey<xAOD::MuonContainer> m_muonsInKey{ - this, "muonsIn", "", "containerName to read" - }; - - Gaudi::Property<std::string> m_muonIdDecorName - { this, "muonIdDecorKey", "DFCommonMuonPassIDCuts", - "Decoration for muon ID cuts" }; - SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonIdDecorKey; - - Gaudi::Property<std::string> m_muonPreselDecorName - { this, "muonPreselDecorKey", "DFCommonMuonPassPreselection", - "Decoration for muon preselection" }; - SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonPreselDecorKey; - - // Electrons - SG::ReadHandleKey<xAOD::ElectronContainer> m_elesInKey{ - this, "elesIn", "", "containerName to read" - }; - - Gaudi::Property<std::string> m_eleIdDecorName - { this, "eleIdDecorKey", "DFCommonElectronsLHTight", - "Decoration for electron ID working point" }; - SG::ReadDecorHandleKey<xAOD::ElectronContainer> m_eleIdDecorKey; - // Taus SG::ReadHandleKey<xAOD::TauJetContainer> m_tausInKey{ this, "tausIn", "", "containerName to read" @@ -105,16 +81,10 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; - Gaudi::Property<std::string> m_eventCategoryDecorName{ - this, "eventCategoryDecorName", "antiTauEventCategory", "Decoration for (anti-Id) taus in hadhad events, 0 is for no anti-Tau, 1 for anti-Tau in lephad and 2 for anti-Tau in hadhad" - }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_eventCategoryDecorKey; - - /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "trigMatch_SLT", "Decoration for SLT trigger matched (anti-Id) taus" //or maybe general objects? + this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? }; - SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchSLTKey; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? @@ -131,7 +101,6 @@ private: }; SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; - */ }; } diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index c32a56d07..2f6bcd228 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -137,7 +137,6 @@ namespace HHBBTT tauTrigMatchWriteDecoMap tau_trigMatchDecos; for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); - std::cout << key << std::endl; for(const xAOD::TauJet* tau : *taus){ tau_trigMatchDecos.at(channel)(*tau) = false; } -- GitLab From 32098b185e1b8ac12e6247e3955362292381c04d Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Tue, 27 Feb 2024 17:37:17 +0100 Subject: [PATCH 24/68] Get trigger decoration to not crash for now --- EasyjetHub/src/TauDecoratorAlg.cxx | 85 ++++++++++++++++++++++-------- EasyjetHub/src/TauDecoratorAlg.h | 28 +++++++++- 2 files changed, 90 insertions(+), 23 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index cae2e10f5..8d73eb795 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -36,13 +36,39 @@ namespace Easyjet m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + std::cout << m_triggerMatchDTTKey << std::endl; ATH_CHECK (m_triggerMatchSTTKey.initialize()); ATH_CHECK (m_triggerMatchLTTKey.initialize()); ATH_CHECK (m_triggerMatchDTTKey.initialize()); + std::cout << m_triggerMatchDTTKey << std::endl; //} - - m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; - ATH_CHECK (m_triggerSLTKey.initialize()); + std::cout << "Start initializing the event trigger category keys" << std::endl; + /* + for (const auto& [channel, name] : m_triggerChannels){ + SG::ReadDecorHandleKey<xAOD::EventInfo> deco; + //std::cout << name << std::endl; + deco = "EventInfo.pass_trigger_"+name; + //ATH_CHECK(deco.initialize()); + m_pass_DecorKey.emplace(channel, deco); + std::cout << m_pass_DecorKey.at(channel) << std::endl; + ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); + }*/ + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); +/* + for (int i = 0; i < 4; ++i){ + std::cout << m_pass_DecorKey.at(i) << std::endl; + } + */ + //m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; + //ATH_CHECK (m_triggerSLTKey.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -57,8 +83,10 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { + std::cout << "Start exec" << std::endl; SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); + std::cout << "Event info handle set up" << std::endl; SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); @@ -66,7 +94,30 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + +/* + for (int i = 0; i < 4; ++i){ + std::cout << m_pass_DecorKey.at(i) << std::endl; + } +*/ + std::cout << "Start getting trigger category handles" << std::endl; + std::cout << m_triggerChannels_inverted.at("SLT") << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); + std::cout << "Got SLT category handles" << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); + /* + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("SLT"))); + std::cout << "Got SLT category handles" << std::endl; + SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("LTT"))); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("STT"))); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("DTT"))); + */ if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -76,10 +127,7 @@ namespace Easyjet int nIdTauSTT = 0; int nantitau = 0; - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_triggerSLTKey); + for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); @@ -89,33 +137,28 @@ namespace Easyjet } } if(m_doAntiTauDecor){ + bool STT = isSTT(*eventInfo); + bool DTT = isDTT(*eventInfo); + bool LTT = isLTT(*eventInfo); + std::cout << "SLT event decoration" << std::endl; + bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - - bool STT = isSTTMatched(*tau); - bool DTT = isDTTMatched(*tau); - bool LTT = isLTTMatched(*tau); - //bool SLT = isSLT(*eventInfo); - + // for SLT no anti-tau trigger matching is possible // or two offline-taus might be matched to same trigger-tau if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - /* - else if (SLT || STT) ; + else if (STT || SLT) ; else { - ATH_MSG_ERROR("Anti-Id tau selection not implemented for this trigger category"); - return StatusCode::FAILURE; + std::cout << "Weired stuff is going on (if trig_bypass is on)" << std::endl; } - */ - - - if (isAntiTau) nantitau++; + if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index c8e9f86c2..709b56449 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -16,6 +16,7 @@ #include <utility> #include <AsgDataHandles/WriteDecorHandleKey.h> +#include <AsgDataHandles/ReadDecorHandleKey.h> #include <AthenaBaseComps/AthReentrantAlgorithm.h> #include <xAODEventInfo/EventInfo.h> @@ -41,7 +42,29 @@ public: private: - + std::unordered_map<int, std::string> m_triggerChannels = + { + {0, "SLT"}, + {1, "LTT"}, + {2, "STT"}, + {3, "DTT"}, + }; + + std::unordered_map<std::string, int> m_triggerChannels_inverted = + { + {"SLT", 0}, + {"LTT", 1}, + {"STT", 2}, + {"DTT", 3}, + }; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyDTT; + std::unordered_map<int, + SG::WriteDecorHandleKey<xAOD::EventInfo> > m_pass_DecorKey; + std::unordered_map<std::string, SG::ReadDecorHandleKey<xAOD::EventInfo> > + m_triggerdecoKeys; // Members for configurable properties SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey { this, "event", "EventInfo", "EventInfo to read" }; @@ -81,11 +104,12 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; + /* Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? }; SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; - +*/ Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? }; -- GitLab From d49c1cdb442d13aec40313dfafeec0e0b06e3175 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 13:10:43 +0100 Subject: [PATCH 25/68] Make trigger decoration for events possible --- EasyjetHub/src/TauDecoratorAlg.cxx | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 8d73eb795..4dca894c3 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -36,13 +36,10 @@ namespace Easyjet m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - std::cout << m_triggerMatchDTTKey << std::endl; ATH_CHECK (m_triggerMatchSTTKey.initialize()); ATH_CHECK (m_triggerMatchLTTKey.initialize()); ATH_CHECK (m_triggerMatchDTTKey.initialize()); - std::cout << m_triggerMatchDTTKey << std::endl; //} - std::cout << "Start initializing the event trigger category keys" << std::endl; /* for (const auto& [channel, name] : m_triggerChannels){ SG::ReadDecorHandleKey<xAOD::EventInfo> deco; @@ -83,10 +80,8 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { - std::cout << "Start exec" << std::endl; SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); - std::cout << "Event info handle set up" << std::endl; SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); @@ -103,11 +98,8 @@ namespace Easyjet std::cout << m_pass_DecorKey.at(i) << std::endl; } */ - std::cout << "Start getting trigger category handles" << std::endl; - std::cout << m_triggerChannels_inverted.at("SLT") << std::endl; SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); - std::cout << "Got SLT category handles" << std::endl; SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); @@ -140,7 +132,6 @@ namespace Easyjet bool STT = isSTT(*eventInfo); bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); - std::cout << "SLT event decoration" << std::endl; bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); @@ -153,11 +144,7 @@ namespace Easyjet if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - else if (STT || SLT) ; - else { - std::cout << "Weired stuff is going on (if trig_bypass is on)" << std::endl; - } - + if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } -- GitLab From b841a6b3ad851d935ddecab3355a2b77643aa283 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:19:37 +0100 Subject: [PATCH 26/68] Clean code from comments and developement artifacts --- EasyjetHub/src/TauDecoratorAlg.cxx | 84 +++++++++++------------------- 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 4dca894c3..28d0056e1 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -29,43 +29,26 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - //if(m_doAntiTauDecor){ - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - //SLT needs to be read from Ele or Mu, or event info - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - //} - /* - for (const auto& [channel, name] : m_triggerChannels){ - SG::ReadDecorHandleKey<xAOD::EventInfo> deco; - //std::cout << name << std::endl; - deco = "EventInfo.pass_trigger_"+name; - //ATH_CHECK(deco.initialize()); - m_pass_DecorKey.emplace(channel, deco); - std::cout << m_pass_DecorKey.at(channel) << std::endl; - ATH_CHECK(m_pass_DecorKey.at(channel).initialize()); - }*/ - m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; - m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; - m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; - m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - - ATH_CHECK(m_pass_DecorKeySLT.initialize()); - ATH_CHECK(m_pass_DecorKeyLTT.initialize()); - ATH_CHECK(m_pass_DecorKeySTT.initialize()); - ATH_CHECK(m_pass_DecorKeyDTT.initialize()); -/* - for (int i = 0; i < 4; ++i){ - std::cout << m_pass_DecorKey.at(i) << std::endl; - } - */ - //m_triggerSLTKey = m_eventInfoKey.key() + "." + m_triggerMatchSLTDecorName; - //ATH_CHECK (m_triggerSLTKey.initialize()); + if(m_doAntiTauDecor){ + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); + } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -80,36 +63,27 @@ namespace Easyjet StatusCode TauDecoratorAlg ::execute(const EventContext& ctx) const { + // input handles SG::ReadHandle<xAOD::EventInfo> eventInfo(m_eventInfoKey,ctx); ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); - SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - + // trigger tau decorators SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); -/* - for (int i = 0; i < 4; ++i){ - std::cout << m_pass_DecorKey.at(i) << std::endl; - } -*/ - + // trigger event decorators SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); - /* - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("SLT"))); - std::cout << "Got SLT category handles" << std::endl; - SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("LTT"))); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("STT"))); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKey.at(m_triggerChannels_inverted.at("DTT"))); - */ + + SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -132,7 +106,7 @@ namespace Easyjet bool STT = isSTT(*eventInfo); bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); - bool SLT = isSLT(*eventInfo); + //bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); -- GitLab From 9dfc963a30b9f5b47561b16a0e2719a15bd90f3d Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:23:17 +0100 Subject: [PATCH 27/68] Remove unsed counter for antitaus --- EasyjetHub/src/TauDecoratorAlg.cxx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 28d0056e1..1ba2c7c7f 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -91,15 +91,14 @@ namespace Easyjet } } - int nIdTauSTT = 0; - int nantitau = 0; + int nIDTauSTT = 0; for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(m_doAntiTauDecor){ - if(isTauID && isSTTMatched(*tau)) nIdTauSTT++; + if(isTauID && isSTTMatched(*tau)) nIDTauSTT++; } } if(m_doAntiTauDecor){ @@ -115,11 +114,10 @@ namespace Easyjet // for SLT no anti-tau trigger matching is possible // or two offline-taus might be matched to same trigger-tau - if (STT && nIdTauSTT == 0) isAntiTau &= isSTTMatched(*tau); + if (STT && nIDTauSTT == 0) isAntiTau &= isSTTMatched(*tau); else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (LTT) isAntiTau &= isLTTMatched(*tau); - if (isAntiTau) nantitau++; antiTauDecorHandle(*tau) = isAntiTau; } } -- GitLab From 2122af489e372c829caa60169370a123b211a871 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 14:24:33 +0100 Subject: [PATCH 28/68] Clean up TauDecoratorAlg.h --- EasyjetHub/src/TauDecoratorAlg.h | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 709b56449..598cc7481 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -42,21 +42,6 @@ public: private: - std::unordered_map<int, std::string> m_triggerChannels = - { - {0, "SLT"}, - {1, "LTT"}, - {2, "STT"}, - {3, "DTT"}, - }; - - std::unordered_map<std::string, int> m_triggerChannels_inverted = - { - {"SLT", 0}, - {"LTT", 1}, - {"STT", 2}, - {"DTT", 3}, - }; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; @@ -104,12 +89,6 @@ private: Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; - /* - Gaudi::Property<std::string> m_triggerMatchSLTDecorName{ - this, "triggerMatchSLTDecorName", "pass_trigger_SLT", "Decoration for events triggered by" //or maybe general objects? - }; - SG::ReadDecorHandleKey<xAOD::EventInfo> m_triggerSLTKey; -*/ Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? }; -- GitLab From ff83fedc539151dfeb8f27858dd9a5b87d34a44a Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 28 Feb 2024 17:00:54 +0100 Subject: [PATCH 29/68] Get current status from bbttTrigDecoratorAlg --- bbttAnalysis/src/HHbbttChannels.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index fd757e802..deef5372b 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -46,6 +46,22 @@ namespace HHBBTT DTT_L1Topo, }; + enum TriggerChannel + { + SLT, + LTT, + ETT, + ETT_4J12, + MTT_2016, + MTT_high, + MTT_low, + STT, + DTT, + DTT_2016, + DTT_4J12, + DTT_L1Topo, + }; + } #endif -- GitLab From 10435516d2eac6e2905045007ea9726ca6ce2614 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 1 Mar 2024 10:57:02 +0100 Subject: [PATCH 30/68] Add some output variables for verification studies and explicit STT check for ID tau matched to STT counting --- EasyjetHub/python/output/ttree/taus.py | 2 +- EasyjetHub/src/TauDecoratorAlg.cxx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 9707f5ef5..66b1ff686 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,7 +19,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau"] + tau_branches.variables += ["isAntiTau", "RNNJetScoreSigTrans", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 1ba2c7c7f..90999bf8e 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -71,8 +71,8 @@ namespace Easyjet // trigger tau decorators SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); // trigger event decorators SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); @@ -98,7 +98,8 @@ namespace Easyjet bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; if(m_doAntiTauDecor){ - if(isTauID && isSTTMatched(*tau)) nIDTauSTT++; + bool STT = isSTT(*eventInfo); + if(isTauID && isSTTMatched(*tau) && STT) nIDTauSTT++; } } if(m_doAntiTauDecor){ -- GitLab From 91bafa7bc3e9193bee4e82f9c15bc54575e99de5 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 1 Mar 2024 13:21:04 +0100 Subject: [PATCH 31/68] Remove unneded member variables --- EasyjetHub/src/TauDecoratorAlg.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 598cc7481..d4fc8e1a3 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -46,10 +46,7 @@ private: SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyDTT; - std::unordered_map<int, - SG::WriteDecorHandleKey<xAOD::EventInfo> > m_pass_DecorKey; - std::unordered_map<std::string, SG::ReadDecorHandleKey<xAOD::EventInfo> > - m_triggerdecoKeys; + // Members for configurable properties SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey { this, "event", "EventInfo", "EventInfo to read" }; -- GitLab From 23726b274d31b3a032e5dc617b39e8cfc17f84f0 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Wed, 6 Mar 2024 18:38:08 +0100 Subject: [PATCH 32/68] Post rebase fixes --- bbttAnalysis/src/HHbbttChannels.h | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index deef5372b..4d67b441b 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -30,38 +30,6 @@ namespace HHBBTT DTT_L1Topo, }; - enum TriggerChannel - { - SLT, - LTT, - ETT, - ETT_4J12, - MTT_2016, - MTT_high, - MTT_low, - STT, - DTT, - DTT_2016, - DTT_4J12, - DTT_L1Topo, - }; - - enum TriggerChannel - { - SLT, - LTT, - ETT, - ETT_4J12, - MTT_2016, - MTT_high, - MTT_low, - STT, - DTT, - DTT_2016, - DTT_4J12, - DTT_L1Topo, - }; - } #endif -- GitLab From 1bf7fede8abeb521e47ea6c9e7a1de76915895e6 Mon Sep 17 00:00:00 2001 From: tstreble <thomas.strebler@cern.ch> Date: Wed, 6 Mar 2024 19:08:17 +0100 Subject: [PATCH 33/68] Fix CI tests --- .../python/output/ttree/tau_decor_config.py | 4 -- EasyjetHub/src/TauDecoratorAlg.cxx | 38 +++++++++---------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/EasyjetHub/python/output/ttree/tau_decor_config.py b/EasyjetHub/python/output/ttree/tau_decor_config.py index 8c76b876b..94e710fa7 100644 --- a/EasyjetHub/python/output/ttree/tau_decor_config.py +++ b/EasyjetHub/python/output/ttree/tau_decor_config.py @@ -4,8 +4,6 @@ from AthenaConfiguration.ComponentFactory import CompFactory def tau_decor_cfg(flags, **kwargs): # Could make this configurable - #muoncoll = flags.Analysis.container_names.input.muons - #elecoll = flags.Analysis.container_names.input.electrons taucoll = flags.Analysis.container_names.input.taus cfg = ComponentAccumulator() @@ -23,8 +21,6 @@ def tau_decor_cfg(flags, **kwargs): isMC=flags.Input.isMC, tauIDWP=flags.Analysis.Tau.ID, doAntiTauDecor=flags.Analysis.do_bbtt_analysis, - #muonsIn=muoncoll, - #elesIn=elecoll, tausIn=taucoll, **kwargs ) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 90999bf8e..a26aed002 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -29,26 +29,24 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - if(m_doAntiTauDecor){ - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - - m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; - m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; - m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; - m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - - ATH_CHECK(m_pass_DecorKeySLT.initialize()); - ATH_CHECK(m_pass_DecorKeyLTT.initialize()); - ATH_CHECK(m_pass_DecorKeySTT.initialize()); - ATH_CHECK(m_pass_DecorKeyDTT.initialize()); - } + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; -- GitLab From 7acb1c4db6db710162cfef19943f3d78007338f6 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Wed, 6 Mar 2024 23:19:27 +0100 Subject: [PATCH 34/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/python/output/ttree/taus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 66b1ff686..00356eac7 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,7 +19,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau", "RNNJetScoreSigTrans", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] + tau_branches.variables += ["isAntiTau", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: -- GitLab From ab207931eab58d7724d989d547defc3a08263e69 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 6 Mar 2024 23:23:56 +0100 Subject: [PATCH 35/68] Remove duplicated variable in output --- EasyjetHub/python/output/ttree/taus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 66b1ff686..00356eac7 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,7 +19,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau", "RNNJetScoreSigTrans", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] + tau_branches.variables += ["isAntiTau", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: -- GitLab From 27cf01030046cf086a272edb4af5b9c697b1dd64 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Thu, 7 Mar 2024 11:41:15 +0100 Subject: [PATCH 36/68] Fix Channel duplication --- bbttAnalysis/src/HHbbttChannels.h | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/bbttAnalysis/src/HHbbttChannels.h b/bbttAnalysis/src/HHbbttChannels.h index deef5372b..4d67b441b 100644 --- a/bbttAnalysis/src/HHbbttChannels.h +++ b/bbttAnalysis/src/HHbbttChannels.h @@ -30,38 +30,6 @@ namespace HHBBTT DTT_L1Topo, }; - enum TriggerChannel - { - SLT, - LTT, - ETT, - ETT_4J12, - MTT_2016, - MTT_high, - MTT_low, - STT, - DTT, - DTT_2016, - DTT_4J12, - DTT_L1Topo, - }; - - enum TriggerChannel - { - SLT, - LTT, - ETT, - ETT_4J12, - MTT_2016, - MTT_high, - MTT_low, - STT, - DTT, - DTT_2016, - DTT_4J12, - DTT_L1Topo, - }; - } #endif -- GitLab From 700b31221698363b9876d54f054c94c81117f011 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 11 Mar 2024 09:28:49 +0100 Subject: [PATCH 37/68] Fix linter problem --- EasyjetHub/python/output/ttree/taus.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 00356eac7..39d9138f5 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,7 +19,8 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] + tau_branches.variables += ["isAntiTau", "trigMatch_STT", + "trigMatch_LTT", "trigMatch_DTT"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: -- GitLab From 26563a10ed5a2db1a4b224811987d4c209f76403 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 11 Mar 2024 12:46:25 +0100 Subject: [PATCH 38/68] Exclude athena from easyjet flake8 checks --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index df061de05..9b2b52ea7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,5 +3,5 @@ ignore = E203, E241, E266, W503 max-line-length = 88 select = B,C,E,F,W,T4 darglint-ignore-regex = * -exclude = .gitlab, BJetCalibrationTool, KinematicFitTool +exclude = .gitlab, BJetCalibrationTool, KinematicFitTool, athena per-file-ignores = hub.py:F401 -- GitLab From b4505803a7e2dbef0e5033c5f72105e1fe94caa1 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 11 Mar 2024 18:34:21 +0100 Subject: [PATCH 39/68] Put uncalibrated pt into output and add a few intermediate comments --- EasyjetHub/python/output/ttree/taus.py | 2 +- EasyjetHub/src/TauDecoratorAlg.cxx | 29 ++++++++++++++++++++------ EasyjetHub/src/TauDecoratorAlg.h | 5 +++++ bbttAnalysis/share/RunConfig-bbtt.yaml | 4 +++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 39d9138f5..857712457 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -17,7 +17,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.syst_only_for = ["pt"] tau_branches.add_four_mom_branches(do_mass=False) - tau_branches.variables += ["charge", "nProng", "isIDTau"] + tau_branches.variables += ["charge", "nProng", "isIDTau", "ptUncal"] if flags.Analysis.do_bbtt_analysis: tau_branches.variables += ["isAntiTau", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT"] diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 90999bf8e..561fc4434 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -29,6 +29,9 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); + m_ptUncalTauDecorKey = m_tausInKey.key() + "." + m_ptUncalTauDecorName; + ATH_CHECK (m_ptUncalTauDecorKey.initialize()); + if(m_doAntiTauDecor){ m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; ATH_CHECK (m_antiTauDecorKey.initialize()); @@ -84,6 +87,8 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> ptUncalTauDecorHandle(m_ptUncalTauDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -91,22 +96,24 @@ namespace Easyjet } } - int nIDTauSTT = 0; + int nIDMatchedTauSTT = 0; for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; + double ptUncalibrated = tau->pt(); + ptUncalTauDecorHandle(*tau) = ptUncalibrated; if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); - if(isTauID && isSTTMatched(*tau) && STT) nIDTauSTT++; + if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; } } if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); - //bool SLT = isSLT(*eventInfo); + bool SLT = isSLT(*eventInfo); for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); @@ -115,11 +122,21 @@ namespace Easyjet // for SLT no anti-tau trigger matching is possible // or two offline-taus might be matched to same trigger-tau - if (STT && nIDTauSTT == 0) isAntiTau &= isSTTMatched(*tau); - else if (DTT) isAntiTau &= isDTTMatched(*tau); - else if (LTT) isAntiTau &= isLTTMatched(*tau); + if (STT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); + else if (DTT && !STT) isAntiTau &= isDTTMatched(*tau); //prioritize STT over DTT + else if (LTT && !SLT) isAntiTau &= isLTTMatched(*tau); //prioritize SLT over LTT antiTauDecorHandle(*tau) = isAntiTau; + /* + decorate taus with PHYS level pt (uncalibrated) to compare with offline + check this in case of overlap of STT and DTT + OR tool works based on calibrated objects, so it can properly apply + trigger categories + + antiIDTau selection in TauSelectorAlg based on the Triggers and event category? + Take last OR loop from TauAntiTauJetOR and run it after tau selection + as a analysis specific function + */ } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index d4fc8e1a3..0d2a2f3aa 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -73,6 +73,11 @@ private: }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_IDTauDecorKey; + Gaudi::Property<std::string> m_ptUncalTauDecorName{ + this, "ptUncalTauDecorName", "ptUncal", "Decoration for the uncalibrated pt" + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_ptUncalTauDecorKey; + Gaudi::Property<bool> m_doAntiTauDecor { this, "doAntiTauDecor", true, "Add anti-tau decoration" }; Gaudi::Property<std::string> m_antiTauDecorName{ diff --git a/bbttAnalysis/share/RunConfig-bbtt.yaml b/bbttAnalysis/share/RunConfig-bbtt.yaml index d1837d72e..118e1f2f1 100644 --- a/bbttAnalysis/share/RunConfig-bbtt.yaml +++ b/bbttAnalysis/share/RunConfig-bbtt.yaml @@ -10,12 +10,14 @@ ttree_output: small_R_jets: 'container_names.output.reco4PFlowJet' # muons: 'container_names.output.muons' # electrons: 'container_names.output.electrons' - # taus: 'container_names.output.taus' + taus: 'container_names.output.taus' met : 'container_names.output.met' collection_options: small_R_jets: btag_info: true higgs_parent_info: true + taus: + RNN_branches: true truth_outputs: small_R_jets: 'container_names.input.truth4Jet' higgs_particle: 'container_names.output.truthHHParticles' -- GitLab From bc963f34511a308c216f45c53da2ce4456914c82 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Tue, 12 Mar 2024 10:23:14 +0100 Subject: [PATCH 40/68] Add pT thresholds checks for assigning the event category --- EasyjetHub/src/TauDecoratorAlg.cxx | 17 ++++++++++------- EasyjetHub/src/TauDecoratorAlg.h | 7 +++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 561fc4434..c27898b5b 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -87,7 +87,7 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> ptUncalTauDecorHandle(m_ptUncalTauDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, double> ptUncalTauDecorHandle(m_ptUncalTauDecorKey); if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); @@ -102,8 +102,7 @@ namespace Easyjet nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; - double ptUncalibrated = tau->pt(); - ptUncalTauDecorHandle(*tau) = ptUncalibrated; + ptUncalTauDecorHandle(*tau) = tau->pt(); if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; @@ -117,14 +116,16 @@ namespace Easyjet for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - + double tauPt = tau->pt(); bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; // for SLT no anti-tau trigger matching is possible - // or two offline-taus might be matched to same trigger-tau - if (STT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); + // or two offline-taus might be matched to same trigger-tau + bool passPtThresholdSTT = tauPt > m_tauPtThresholdSTT; + bool passPtThresholdLTT = tauPt > m_tauPtThresholdLTT; + if (STT && nIDMatchedTauSTT == 0 && passPtThresholdSTT) isAntiTau &= isSTTMatched(*tau); else if (DTT && !STT) isAntiTau &= isDTTMatched(*tau); //prioritize STT over DTT - else if (LTT && !SLT) isAntiTau &= isLTTMatched(*tau); //prioritize SLT over LTT + else if (LTT && !SLT && passPtThresholdLTT) isAntiTau &= isLTTMatched(*tau); //prioritize SLT over LTT antiTauDecorHandle(*tau) = isAntiTau; /* @@ -136,6 +137,8 @@ namespace Easyjet antiIDTau selection in TauSelectorAlg based on the Triggers and event category? Take last OR loop from TauAntiTauJetOR and run it after tau selection as a analysis specific function + + Check offline pT threshold together with the event trigger */ } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 0d2a2f3aa..108ee23ae 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -88,6 +88,13 @@ private: }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; + Gaudi::Property<double> m_tauPtThresholdSTT{ + this, "tauPtThresholdSTT", 180, "STT tau pt threshold" + }; + Gaudi::Property<double> m_tauPtThresholdLTT{ + this, "tauPtThresholdLTT", 30, "LTT tau pt threshold" + }; + Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; -- GitLab From 973f5fc33fe70baa0b763b5883ba7865a8facc17 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Tue, 12 Mar 2024 16:57:02 +0100 Subject: [PATCH 41/68] Bring back leptons and refine event categories from fired triggers --- .../python/output/ttree/tau_decor_config.py | 4 + EasyjetHub/python/output/ttree/taus.py | 4 +- EasyjetHub/src/TauDecoratorAlg.cxx | 109 ++++++++++++++++-- EasyjetHub/src/TauDecoratorAlg.h | 39 ++++++- 4 files changed, 144 insertions(+), 12 deletions(-) diff --git a/EasyjetHub/python/output/ttree/tau_decor_config.py b/EasyjetHub/python/output/ttree/tau_decor_config.py index 94e710fa7..39303fb6b 100644 --- a/EasyjetHub/python/output/ttree/tau_decor_config.py +++ b/EasyjetHub/python/output/ttree/tau_decor_config.py @@ -4,6 +4,8 @@ from AthenaConfiguration.ComponentFactory import CompFactory def tau_decor_cfg(flags, **kwargs): # Could make this configurable + muoncoll = flags.Analysis.container_names.input.muons + elecoll = flags.Analysis.container_names.input.electrons taucoll = flags.Analysis.container_names.input.taus cfg = ComponentAccumulator() @@ -22,6 +24,8 @@ def tau_decor_cfg(flags, **kwargs): tauIDWP=flags.Analysis.Tau.ID, doAntiTauDecor=flags.Analysis.do_bbtt_analysis, tausIn=taucoll, + muonsIn=muoncoll, + elesIn=elecoll, **kwargs ) ) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 857712457..ea0a1a61b 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -20,7 +20,9 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.variables += ["charge", "nProng", "isIDTau", "ptUncal"] if flags.Analysis.do_bbtt_analysis: tau_branches.variables += ["isAntiTau", "trigMatch_STT", - "trigMatch_LTT", "trigMatch_DTT"] + "trigMatch_LTT", "trigMatch_DTT", + "antiTauEventCategory", + ] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index c27898b5b..208ebffe8 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -33,6 +33,18 @@ namespace Easyjet ATH_CHECK (m_ptUncalTauDecorKey.initialize()); if(m_doAntiTauDecor){ + // Muons + ele stuff to be cleaned up after trigger matching is used + ATH_CHECK (m_muonsInKey.initialize()); + ATH_CHECK (m_elesInKey.initialize()); + + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; ATH_CHECK (m_antiTauDecorKey.initialize()); m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; @@ -51,6 +63,9 @@ namespace Easyjet ATH_CHECK(m_pass_DecorKeyLTT.initialize()); ATH_CHECK(m_pass_DecorKeySTT.initialize()); ATH_CHECK(m_pass_DecorKeyDTT.initialize()); + + m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; + ATH_CHECK (m_eventCategoryDecorKey.initialize()); } if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; @@ -83,6 +98,8 @@ namespace Easyjet SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); + SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); @@ -96,6 +113,36 @@ namespace Easyjet } } + int nlepton = 0; + bool passLeptonPtSLTThreshold = false; + bool passTauPtSTTThreshold = false; + + if(m_doAntiTauDecor){ + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + ATH_CHECK (elesIn.isValid()); + + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); + SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); + SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + + for(const xAOD::Muon* muon : *muonsIn) { + if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) { + nlepton++; + passLeptonPtSLTThreshold |= muon->pt() > 21000; + } + } + for(const xAOD::Electron* ele : *elesIn) { + if(eleIdDecorHandle(*ele)) { + nlepton++; + passLeptonPtSLTThreshold |= ele->pt() > 25000; + } + } + //std::cout << "nLepton: " << nlepton << std::endl; + //std::cout << "passLeptonPtSLTThreshold: " << passLeptonPtSLTThreshold << std::endl; + } + int nIDMatchedTauSTT = 0; for(const xAOD::TauJet* tau : *tausIn) { @@ -106,6 +153,7 @@ namespace Easyjet if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; + if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > m_tauPtThresholdSTT; } } if(m_doAntiTauDecor){ @@ -113,20 +161,38 @@ namespace Easyjet bool DTT = isDTT(*eventInfo); bool LTT = isLTT(*eventInfo); bool SLT = isSLT(*eventInfo); + // use the "trigger fired flag" as category flag in lephad now + if (SLT && LTT && passLeptonPtSLTThreshold) LTT = false; // set also other categories to false to prioritize SLT? + else if (SLT && LTT && !passLeptonPtSLTThreshold) SLT = false; + bool isLepHad = SLT || LTT; + + // use the "trigger fired flag" as category flag in hadhad now + if (STT && DTT && passTauPtSTTThreshold) DTT = false; + else if (STT && DTT && !passTauPtSTTThreshold) STT = false; + bool isHadHad = STT || DTT; + + if (isLepHad && isHadHad) { + std::cout << "Category unclear" << std::endl; + } + for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); - double tauPt = tau->pt(); bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; // for SLT no anti-tau trigger matching is possible - // or two offline-taus might be matched to same trigger-tau - bool passPtThresholdSTT = tauPt > m_tauPtThresholdSTT; - bool passPtThresholdLTT = tauPt > m_tauPtThresholdLTT; - if (STT && nIDMatchedTauSTT == 0 && passPtThresholdSTT) isAntiTau &= isSTTMatched(*tau); - else if (DTT && !STT) isAntiTau &= isDTTMatched(*tau); //prioritize STT over DTT - else if (LTT && !SLT && passPtThresholdLTT) isAntiTau &= isLTTMatched(*tau); //prioritize SLT over LTT - + if (LTT) isAntiTau &= isSTTMatched(*tau); // in LTT anti-tau needs to be trig matched + else if (SLT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); // if ID tau not trig matched anti tau needs be matched to trigger + + int antiTauCategory = 0; + if (nlepton > 0 && isAntiTau) { + antiTauCategory = 1; + } + if (nlepton==0 && isAntiTau) { + antiTauCategory = 2; + } + eventCategoryDecorHandle(*tau) = antiTauCategory; + antiTauDecorHandle(*tau) = isAntiTau; /* decorate taus with PHYS level pt (uncalibrated) to compare with offline @@ -139,7 +205,32 @@ namespace Easyjet as a analysis specific function Check offline pT threshold together with the event trigger - */ + */ + /* + if(m_year==2015) + m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 25. * Athena::Units::GeV; + // 2022 75 bunches + else if(427882 <= runNumber && runNumber < 428071) + m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 18. * Athena::Units::GeV; + else + m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 27. * Athena::Units::GeV; + + if(m_year==2015) + m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 21. * Athena::Units::GeV; + else if(m_year<=2016 && m_year<=2018) + m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 27. * Athena::Units::GeV; + else + m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 25. * Athena::Units::GeV; + + // Single tau triggers + float min_tau_STT = 180. * Athena::Units::GeV; + // 2015 + 2016 period A + if(m_year==2015 || (296939 <= runNumber && runNumber <= 300287)) + min_tau_STT = 100. * Athena::Units::GeV; + // 2016 period B-D3 + else if(300345 <= runNumber && runNumber <= 302872) + min_tau_STT = 140. * Athena::Units::GeV; +*/ } } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 108ee23ae..ac1317760 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -20,7 +20,12 @@ #include <AthenaBaseComps/AthReentrantAlgorithm.h> #include <xAODEventInfo/EventInfo.h> + #include <xAODTau/TauJetContainer.h> +#include <xAODMuon/MuonContainer.h> +#include <xAODEgamma/ElectronContainer.h> + +#include <AthenaKernel/Units.h> namespace Easyjet @@ -53,6 +58,30 @@ private: Gaudi::Property<bool> m_isMC { this, "isMC", false, "Is this simulation?" }; + // Muons + SG::ReadHandleKey<xAOD::MuonContainer> m_muonsInKey{ + this, "muonsIn", "", "containerName to read" + }; + Gaudi::Property<std::string> m_muonIdDecorName + { this, "muonIdDecorKey", "DFCommonMuonPassIDCuts", + "Decoration for muon ID cuts" }; + SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonIdDecorKey; + + Gaudi::Property<std::string> m_muonPreselDecorName + { this, "muonPreselDecorKey", "DFCommonMuonPassPreselection", + "Decoration for muon preselection" }; + SG::ReadDecorHandleKey<xAOD::MuonContainer> m_muonPreselDecorKey; + + // Electrons + SG::ReadHandleKey<xAOD::ElectronContainer> m_elesInKey{ + this, "elesIn", "", "containerName to read" + }; + + Gaudi::Property<std::string> m_eleIdDecorName + { this, "eleIdDecorKey", "DFCommonElectronsLHTight", + "Decoration for electron ID working point" }; + SG::ReadDecorHandleKey<xAOD::ElectronContainer> m_eleIdDecorKey; + // Taus SG::ReadHandleKey<xAOD::TauJetContainer> m_tausInKey{ this, "tausIn", "", "containerName to read" @@ -89,15 +118,21 @@ private: SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; Gaudi::Property<double> m_tauPtThresholdSTT{ - this, "tauPtThresholdSTT", 180, "STT tau pt threshold" + this, "tauPtThresholdSTT", 180.*Athena::Units::GeV, "STT tau pt threshold" }; Gaudi::Property<double> m_tauPtThresholdLTT{ - this, "tauPtThresholdLTT", 30, "LTT tau pt threshold" + this, "tauPtThresholdLTT", 30.*Athena::Units::GeV, "LTT tau pt threshold" }; Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; + Gaudi::Property<std::string> m_eventCategoryDecorName{ + this, "eventCategoryDecorName", "antiTauEventCategory", "Decoration for (anti-Id) taus in hadhad events, 0 is for no anti-Tau, 1 for anti-Tau in lephad and 2 for anti-Tau in hadhad" + }; + SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_eventCategoryDecorKey; + + Gaudi::Property<std::string> m_triggerMatchSTTDecorName{ this, "triggerMatchSTTDecorName", "trigMatch_STT", "Decoration for STT trigger matched (anti-Id) taus" //or maybe general objects? }; -- GitLab From 1734dbb3da20dd3dbfe9245902d0faedd6fc599e Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 13 Mar 2024 14:31:11 +0100 Subject: [PATCH 42/68] Handle overlap of lephad and hadhad category --- EasyjetHub/src/TauDecoratorAlg.cxx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 208ebffe8..a716a2871 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -114,6 +114,7 @@ namespace Easyjet } int nlepton = 0; + bool leptonVetoForHadHad = false; bool passLeptonPtSLTThreshold = false; bool passTauPtSTTThreshold = false; @@ -131,12 +132,14 @@ namespace Easyjet if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) { nlepton++; passLeptonPtSLTThreshold |= muon->pt() > 21000; + leptonVetoForHadHad |= muon->pt() > 8000; } } for(const xAOD::Electron* ele : *elesIn) { if(eleIdDecorHandle(*ele)) { nlepton++; passLeptonPtSLTThreshold |= ele->pt() > 25000; + leptonVetoForHadHad |= ele->pt() > 8000; } } //std::cout << "nLepton: " << nlepton << std::endl; @@ -172,7 +175,15 @@ namespace Easyjet bool isHadHad = STT || DTT; if (isLepHad && isHadHad) { - std::cout << "Category unclear" << std::endl; + std::cout << "Category unclear, vetoed: " << leptonVetoForHadHad << std::endl; + if (leptonVetoForHadHad) { + STT = false; + DTT = false; + } + else { + SLT = false; + LTT = false; + } } for(const xAOD::TauJet* tau : *tausIn) { @@ -180,15 +191,15 @@ namespace Easyjet float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; - // for SLT no anti-tau trigger matching is possible + // for SLT no anti-tau trigger matching is required if (LTT) isAntiTau &= isSTTMatched(*tau); // in LTT anti-tau needs to be trig matched - else if (SLT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); // if ID tau not trig matched anti tau needs be matched to trigger + else if (STT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); // in STT if ID tau not trig matched anti tau needs be matched to trigger int antiTauCategory = 0; - if (nlepton > 0 && isAntiTau) { + if (!leptonVetoForHadHad && isAntiTau) { antiTauCategory = 1; } - if (nlepton==0 && isAntiTau) { + if (leptonVetoForHadHad && isAntiTau) { antiTauCategory = 2; } eventCategoryDecorHandle(*tau) = antiTauCategory; -- GitLab From 801016d4a2c63fa5bf1b38b744e129a4e872a314 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Wed, 13 Mar 2024 18:22:08 +0100 Subject: [PATCH 43/68] Make pT thrsholds for event categories period dependent --- EasyjetHub/src/TauDecoratorAlg.cxx | 71 +++++++++++++++++++++++------- EasyjetHub/src/TauDecoratorAlg.h | 21 ++++++--- 2 files changed, 69 insertions(+), 23 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index a716a2871..431afefab 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -19,6 +19,9 @@ namespace Easyjet StatusCode TauDecoratorAlg ::initialize() { ATH_CHECK (m_eventInfoKey.initialize()); + ATH_CHECK (m_runNumberKey.initialize()); + ATH_CHECK (m_rdmRunNumberKey.initialize()); + ATH_CHECK (m_tausInKey.initialize()); m_nProngDecorKey = m_tausInKey.key() + "." + m_nProngDecorName; @@ -92,6 +95,12 @@ namespace Easyjet SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_runNumberHandle + (m_runNumberKey); + SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_rdmRunNumberHandle + (m_rdmRunNumberKey); + + // trigger event decorators SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); @@ -119,6 +128,9 @@ namespace Easyjet bool passTauPtSTTThreshold = false; if(m_doAntiTauDecor){ + unsigned int rdmNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); + setRunNumberQuantities(rdmNumber); + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); ATH_CHECK (muonsIn.isValid()); @@ -131,19 +143,17 @@ namespace Easyjet for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) { nlepton++; - passLeptonPtSLTThreshold |= muon->pt() > 21000; + passLeptonPtSLTThreshold |= muon->pt() > m_ptThresholds.at("SLT").at("mu"); leptonVetoForHadHad |= muon->pt() > 8000; } } for(const xAOD::Electron* ele : *elesIn) { if(eleIdDecorHandle(*ele)) { nlepton++; - passLeptonPtSLTThreshold |= ele->pt() > 25000; + passLeptonPtSLTThreshold |= ele->pt() > m_ptThresholds.at("SLT").at("ele"); leptonVetoForHadHad |= ele->pt() > 8000; } } - //std::cout << "nLepton: " << nlepton << std::endl; - //std::cout << "passLeptonPtSLTThreshold: " << passLeptonPtSLTThreshold << std::endl; } int nIDMatchedTauSTT = 0; @@ -156,7 +166,7 @@ namespace Easyjet if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; - if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > m_tauPtThresholdSTT; + if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > m_ptThresholds.at("STT").at("leadingTau"); } } if(m_doAntiTauDecor){ @@ -218,20 +228,48 @@ namespace Easyjet Check offline pT threshold together with the event trigger */ /* - if(m_year==2015) - m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 25. * Athena::Units::GeV; + + // Single tau triggers + float min_tau_STT = 180. * Athena::Units::GeV; + // 2015 + 2016 period A + if(m_year==2015 || (296939 <= runNumber && runNumber <= 300287)) + min_tau_STT = 100. * Athena::Units::GeV; + // 2016 period B-D3 + else if(300345 <= runNumber && runNumber <= 302872) + min_tau_STT = 140. * Athena::Units::GeV; +*/ + } + } + + return StatusCode::SUCCESS; + } + void TauDecoratorAlg::setRunNumberQuantities(unsigned int runNumber) { + // References: + // https://atlas-tagservices.cern.ch/tagservices/RunBrowser/runBrowserReport/rBR_Period_Report.php + // https://twiki.cern.ch/twiki/bin/view/Atlas/LowestUnprescaled + + m_year = 0; + if(m_years.size()==1) m_year = m_years[0]; + else{ + if(266904 <= runNumber && runNumber <= 284484) m_year = 2015; + else if(296939 <= runNumber && runNumber <= 311481) m_year = 2016; + } + + // Single-lepton triggers + if(m_year==2015) + m_ptThresholds.at("SLT").at("ele") = 25. * Athena::Units::GeV; // 2022 75 bunches else if(427882 <= runNumber && runNumber < 428071) - m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 18. * Athena::Units::GeV; + m_ptThresholds.at("SLT").at("ele") = 18. * Athena::Units::GeV; else - m_pt_threshold[HHBBTT::SLT][HHBBTT::ele] = 27. * Athena::Units::GeV; + m_ptThresholds.at("SLT").at("ele") = 27. * Athena::Units::GeV; if(m_year==2015) - m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 21. * Athena::Units::GeV; + m_ptThresholds.at("SLT").at("mu") = 21. * Athena::Units::GeV; else if(m_year<=2016 && m_year<=2018) - m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 27. * Athena::Units::GeV; + m_ptThresholds.at("SLT").at("mu") = 27. * Athena::Units::GeV; else - m_pt_threshold[HHBBTT::SLT][HHBBTT::mu] = 25. * Athena::Units::GeV; + m_ptThresholds.at("SLT").at("mu") = 25. * Athena::Units::GeV; // Single tau triggers float min_tau_STT = 180. * Athena::Units::GeV; @@ -241,11 +279,10 @@ namespace Easyjet // 2016 period B-D3 else if(300345 <= runNumber && runNumber <= 302872) min_tau_STT = 140. * Athena::Units::GeV; -*/ - } - } - - return StatusCode::SUCCESS; + + m_ptThresholds.at("STT").at("leadingTau") = min_tau_STT; } + + } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index ac1317760..bfaf1b36c 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -14,6 +14,8 @@ #include <vector> #include <utility> +#include <string> +#include <unordered_map> #include <AsgDataHandles/WriteDecorHandleKey.h> #include <AsgDataHandles/ReadDecorHandleKey.h> @@ -58,6 +60,17 @@ private: Gaudi::Property<bool> m_isMC { this, "isMC", false, "Is this simulation?" }; + + Gaudi::Property<std::vector<int>> m_years + { this, "Years", false, "which years are running" }; + int m_year; + + + SG::ReadDecorHandleKey<xAOD::EventInfo> m_runNumberKey{ + this, "runNumberDecorKey", "EventInfo.runNumber", "Run number"}; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_rdmRunNumberKey{ + this, "RandomRunNumberDecorKey", "EventInfo.RandomRunNumber", "Random run number"}; + // Muons SG::ReadHandleKey<xAOD::MuonContainer> m_muonsInKey{ this, "muonsIn", "", "containerName to read" @@ -117,12 +130,7 @@ private: }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; - Gaudi::Property<double> m_tauPtThresholdSTT{ - this, "tauPtThresholdSTT", 180.*Athena::Units::GeV, "STT tau pt threshold" - }; - Gaudi::Property<double> m_tauPtThresholdLTT{ - this, "tauPtThresholdLTT", 30.*Athena::Units::GeV, "LTT tau pt threshold" - }; + std::unordered_map<std::string, std::unordered_map<std::string, float>> m_ptThresholds; Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; @@ -148,6 +156,7 @@ private: }; SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; + void setRunNumberQuantities(unsigned int runNumber) ; }; } -- GitLab From f7ca2a97883fbffe5bc44659462f6091529fe864 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Thu, 14 Mar 2024 15:07:01 +0100 Subject: [PATCH 44/68] Make thresholds year dependent --- EasyjetHub/src/TauDecoratorAlg.cxx | 69 ++++++++----------- EasyjetHub/src/TauDecoratorAlg.h | 9 ++- EasyjetHub/src/ThresholdHelper.h | 37 ++++++++++ .../src/components/EasyjetHub_entries.cxx | 1 + 4 files changed, 70 insertions(+), 46 deletions(-) create mode 100644 EasyjetHub/src/ThresholdHelper.h diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 431afefab..32cacc5d0 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -10,6 +10,11 @@ #include <AsgDataHandles/WriteDecorHandle.h> #include "TauAnalysisTools/HelperFunctions.h" +#include <AthenaKernel/Units.h> + +#include <unordered_map> + + namespace Easyjet { TauDecoratorAlg ::TauDecoratorAlg(const std::string &name, @@ -126,10 +131,13 @@ namespace Easyjet bool leptonVetoForHadHad = false; bool passLeptonPtSLTThreshold = false; bool passTauPtSTTThreshold = false; + std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; if(m_doAntiTauDecor){ unsigned int rdmNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); - setRunNumberQuantities(rdmNumber); + int year = 0; + + setRunNumberQuantities(rdmNumber, year, ptThresholds); SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); @@ -143,14 +151,14 @@ namespace Easyjet for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) { nlepton++; - passLeptonPtSLTThreshold |= muon->pt() > m_ptThresholds.at("SLT").at("mu"); + passLeptonPtSLTThreshold |= muon->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu]; leptonVetoForHadHad |= muon->pt() > 8000; } } for(const xAOD::Electron* ele : *elesIn) { if(eleIdDecorHandle(*ele)) { nlepton++; - passLeptonPtSLTThreshold |= ele->pt() > m_ptThresholds.at("SLT").at("ele"); + passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; leptonVetoForHadHad |= ele->pt() > 8000; } } @@ -166,7 +174,7 @@ namespace Easyjet if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo); if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; - if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > m_ptThresholds.at("STT").at("leadingTau"); + if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; } } if(m_doAntiTauDecor){ @@ -175,7 +183,7 @@ namespace Easyjet bool LTT = isLTT(*eventInfo); bool SLT = isSLT(*eventInfo); // use the "trigger fired flag" as category flag in lephad now - if (SLT && LTT && passLeptonPtSLTThreshold) LTT = false; // set also other categories to false to prioritize SLT? + if (SLT && LTT && passLeptonPtSLTThreshold) LTT = false; else if (SLT && LTT && !passLeptonPtSLTThreshold) SLT = false; bool isLepHad = SLT || LTT; @@ -185,7 +193,7 @@ namespace Easyjet bool isHadHad = STT || DTT; if (isLepHad && isHadHad) { - std::cout << "Category unclear, vetoed: " << leptonVetoForHadHad << std::endl; + // set also other categories to false to prioritize SLT if (leptonVetoForHadHad) { STT = false; DTT = false; @@ -215,61 +223,39 @@ namespace Easyjet eventCategoryDecorHandle(*tau) = antiTauCategory; antiTauDecorHandle(*tau) = isAntiTau; - /* - decorate taus with PHYS level pt (uncalibrated) to compare with offline - check this in case of overlap of STT and DTT - OR tool works based on calibrated objects, so it can properly apply - trigger categories - - antiIDTau selection in TauSelectorAlg based on the Triggers and event category? - Take last OR loop from TauAntiTauJetOR and run it after tau selection - as a analysis specific function - - Check offline pT threshold together with the event trigger - */ - /* - - // Single tau triggers - float min_tau_STT = 180. * Athena::Units::GeV; - // 2015 + 2016 period A - if(m_year==2015 || (296939 <= runNumber && runNumber <= 300287)) - min_tau_STT = 100. * Athena::Units::GeV; - // 2016 period B-D3 - else if(300345 <= runNumber && runNumber <= 302872) - min_tau_STT = 140. * Athena::Units::GeV; -*/ } } return StatusCode::SUCCESS; } - void TauDecoratorAlg::setRunNumberQuantities(unsigned int runNumber) { + void TauDecoratorAlg::setRunNumberQuantities(unsigned int runNumber, int& year, std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>>& ptThresholds) const{ + // References: // https://atlas-tagservices.cern.ch/tagservices/RunBrowser/runBrowserReport/rBR_Period_Report.php // https://twiki.cern.ch/twiki/bin/view/Atlas/LowestUnprescaled - m_year = 0; - if(m_years.size()==1) m_year = m_years[0]; + year = 0; + if(m_years.size()==1) year = m_years[0]; else{ - if(266904 <= runNumber && runNumber <= 284484) m_year = 2015; - else if(296939 <= runNumber && runNumber <= 311481) m_year = 2016; + if(266904 <= runNumber && runNumber <= 284484) year = 2015; + else if(296939 <= runNumber && runNumber <= 311481) year = 2016; } // Single-lepton triggers if(m_year==2015) - m_ptThresholds.at("SLT").at("ele") = 25. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele] = 25. * Athena::Units::GeV; // 2022 75 bunches else if(427882 <= runNumber && runNumber < 428071) - m_ptThresholds.at("SLT").at("ele") = 18. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele] = 18. * Athena::Units::GeV; else - m_ptThresholds.at("SLT").at("ele") = 27. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele] = 27. * Athena::Units::GeV; if(m_year==2015) - m_ptThresholds.at("SLT").at("mu") = 21. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 21. * Athena::Units::GeV; else if(m_year<=2016 && m_year<=2018) - m_ptThresholds.at("SLT").at("mu") = 27. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 27. * Athena::Units::GeV; else - m_ptThresholds.at("SLT").at("mu") = 25. * Athena::Units::GeV; + ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 25. * Athena::Units::GeV; // Single tau triggers float min_tau_STT = 180. * Athena::Units::GeV; @@ -280,9 +266,10 @@ namespace Easyjet else if(300345 <= runNumber && runNumber <= 302872) min_tau_STT = 140. * Athena::Units::GeV; - m_ptThresholds.at("STT").at("leadingTau") = min_tau_STT; + ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau] = min_tau_STT; } + } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index bfaf1b36c..41f7c34f3 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -28,7 +28,7 @@ #include <xAODEgamma/ElectronContainer.h> #include <AthenaKernel/Units.h> - +#include "ThresholdHelper.h" namespace Easyjet { @@ -47,6 +47,7 @@ public: StatusCode execute(const EventContext& ctx) const override; /// We use default finalize() -- this is for cleanup, and we don't do any + private: SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; @@ -121,7 +122,7 @@ private: SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_ptUncalTauDecorKey; Gaudi::Property<bool> m_doAntiTauDecor - { this, "doAntiTauDecor", true, "Add anti-tau decoration" }; + { this, "doAntiTauDecor", false, "Add anti-tau decoration" }; Gaudi::Property<std::string> m_antiTauDecorName{ this, "antiTauDecorKey", "isAntiTau", "Decoration for anti-taus" }; @@ -130,8 +131,6 @@ private: }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_antiTauDecorKey; - std::unordered_map<std::string, std::unordered_map<std::string, float>> m_ptThresholds; - Gaudi::Property<std::string> m_tauIDWP_name {this, "tauIDWP", "", "Name of the Tau ID WP"}; xAOD::TauJetParameters::IsTauFlag m_tauIDWP; @@ -156,7 +155,7 @@ private: }; SG::ReadDecorHandleKey<xAOD::TauJetContainer> m_triggerMatchDTTKey; - void setRunNumberQuantities(unsigned int runNumber) ; + void setRunNumberQuantities(unsigned int runNumber, int& year, std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>>& ptThresholdMap) const; }; } diff --git a/EasyjetHub/src/ThresholdHelper.h b/EasyjetHub/src/ThresholdHelper.h new file mode 100644 index 000000000..e0a06165a --- /dev/null +++ b/EasyjetHub/src/ThresholdHelper.h @@ -0,0 +1,37 @@ +#ifndef TAUTRIGGERDECORATOR_HELPER +#define TAUTRIGGERDECORATOR_HELPER + +namespace Easyjet +{ + + enum Channel + { + LepHad = 0, + HadHad = 1, + LepHad1B = 2, + HadHad1B = 3, + ZCR = 4, + TopEMuCR = 5, + }; + + enum TriggerChannel + { + SLT, + LTT, + STT, + DTT, + }; + + enum Var + { + ele = 0, + mu = 1, + leadingtau = 2, + leadingtaumax = 3, + subleadingtau = 4, + leadingjet = 5, + subleadingjet = 6, + }; +} + +#endif \ No newline at end of file diff --git a/EasyjetHub/src/components/EasyjetHub_entries.cxx b/EasyjetHub/src/components/EasyjetHub_entries.cxx index 3b3822388..030c99397 100644 --- a/EasyjetHub/src/components/EasyjetHub_entries.cxx +++ b/EasyjetHub/src/components/EasyjetHub_entries.cxx @@ -14,6 +14,7 @@ #include "../EventInfoGlobalAlg.h" #include "../OrthogonalityAlg.h" #include "../SumOfWeightsAlg.h" +#include "../ThresholdHelper.h" using namespace Easyjet; -- GitLab From 175db772bb49b0bb188aa675fac035ef0bb482bc Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Thu, 14 Mar 2024 21:22:24 +0100 Subject: [PATCH 45/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/python/output/ttree/taus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index ea0a1a61b..0e9650bdf 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -17,7 +17,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.syst_only_for = ["pt"] tau_branches.add_four_mom_branches(do_mass=False) - tau_branches.variables += ["charge", "nProng", "isIDTau", "ptUncal"] + tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: tau_branches.variables += ["isAntiTau", "trigMatch_STT", "trigMatch_LTT", "trigMatch_DTT", -- GitLab From cbdf6c16a0d2aa511f66d56ea7afa329bfd14034 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:42:20 +0100 Subject: [PATCH 46/68] Apply 1 suggestion(s) to 1 file(s) --- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index 2f6bcd228..f157df226 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -138,7 +138,7 @@ namespace HHBBTT for (const auto& [channel, key] : m_tau_trigMatch_DecorKey){ tau_trigMatchDecos.emplace(channel, key); for(const xAOD::TauJet* tau : *taus){ - tau_trigMatchDecos.at(channel)(*tau) = false; + tau_trigMatchDecos.at(channel)(*tau) = false; } } -- GitLab From 312c8626a73406605a868627d85081931e4b4e12 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:42:34 +0100 Subject: [PATCH 47/68] Apply 1 suggestion(s) to 1 file(s) --- bbttAnalysis/src/TriggerDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bbttAnalysis/src/TriggerDecoratorAlg.cxx b/bbttAnalysis/src/TriggerDecoratorAlg.cxx index f157df226..487ec8a86 100644 --- a/bbttAnalysis/src/TriggerDecoratorAlg.cxx +++ b/bbttAnalysis/src/TriggerDecoratorAlg.cxx @@ -130,7 +130,7 @@ namespace HHBBTT for (const auto& [channel, key] : m_ele_trigMatch_DecorKey){ ele_trigMatchDecos.emplace(channel, key); for(const xAOD::Electron* ele : *electrons){ - ele_trigMatchDecos.at(channel)(*ele) = false; + ele_trigMatchDecos.at(channel)(*ele) = false; } } -- GitLab From aad9c8dd236c0d39186f7ef3058325fc091569b4 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:43:31 +0100 Subject: [PATCH 48/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 32cacc5d0..10445312c 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -210,7 +210,8 @@ namespace Easyjet bool isAntiTau = !isTauID && RNNScore>m_antiTauRNNThreshold; // for SLT no anti-tau trigger matching is required - if (LTT) isAntiTau &= isSTTMatched(*tau); // in LTT anti-tau needs to be trig matched + if (LTT) isAntiTau &= isLTTMatched(*tau); + else if (DTT) isAntiTau &= isDTTMatched(*tau); else if (STT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); // in STT if ID tau not trig matched anti tau needs be matched to trigger int antiTauCategory = 0; -- GitLab From b3c1b8faa10808bc6a7472c8746f27c9c6b28855 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:44:59 +0100 Subject: [PATCH 49/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 10445312c..35f53b8aa 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -37,8 +37,6 @@ namespace Easyjet ATH_CHECK (m_truthTypeDecorKey.initialize(m_isMC)); ATH_CHECK (m_IDTauDecorKey.initialize()); - m_ptUncalTauDecorKey = m_tausInKey.key() + "." + m_ptUncalTauDecorName; - ATH_CHECK (m_ptUncalTauDecorKey.initialize()); if(m_doAntiTauDecor){ // Muons + ele stuff to be cleaned up after trigger matching is used -- GitLab From 694b09e9ce9841a3b2aa8906ffe6199b2800e815 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:45:24 +0100 Subject: [PATCH 50/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 35f53b8aa..212748571 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -121,7 +121,7 @@ namespace Easyjet if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { - truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); + truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } -- GitLab From 771cb43ac849cb280eb6bf34e2b74152cfa7d123 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:47:21 +0100 Subject: [PATCH 51/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 212748571..2c3c5fe7b 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -147,7 +147,8 @@ namespace Easyjet SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon)) { + if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon) && + muon->pt() > 7 * Athena::Units::GeV) { nlepton++; passLeptonPtSLTThreshold |= muon->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu]; leptonVetoForHadHad |= muon->pt() > 8000; -- GitLab From 126eb21b8b003c665962c3a6589582ed318ce2bd Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:47:34 +0100 Subject: [PATCH 52/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 41f7c34f3..787e483f1 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -64,7 +64,6 @@ private: Gaudi::Property<std::vector<int>> m_years { this, "Years", false, "which years are running" }; - int m_year; SG::ReadDecorHandleKey<xAOD::EventInfo> m_runNumberKey{ -- GitLab From 2ca732936f15b80d2bcf4a855f2cef0b9f01e4ab Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:47:47 +0100 Subject: [PATCH 53/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 2c3c5fe7b..c63e9c237 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -250,7 +250,7 @@ namespace Easyjet else ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele] = 27. * Athena::Units::GeV; - if(m_year==2015) + if(year==2015) ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 21. * Athena::Units::GeV; else if(m_year<=2016 && m_year<=2018) ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 27. * Athena::Units::GeV; -- GitLab From 0b62ceb144a8a62f2f347770107ab03f955d2d45 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:47:59 +0100 Subject: [PATCH 54/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index c63e9c237..1c79895d5 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -252,7 +252,7 @@ namespace Easyjet if(year==2015) ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 21. * Athena::Units::GeV; - else if(m_year<=2016 && m_year<=2018) + else if(year>=2016 && year<=2018) ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 27. * Athena::Units::GeV; else ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu] = 25. * Athena::Units::GeV; -- GitLab From c8cd374de835444978a23db8103ea0b9fad039ff Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:48:13 +0100 Subject: [PATCH 55/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 1c79895d5..c158dd583 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -260,7 +260,7 @@ namespace Easyjet // Single tau triggers float min_tau_STT = 180. * Athena::Units::GeV; // 2015 + 2016 period A - if(m_year==2015 || (296939 <= runNumber && runNumber <= 300287)) + if(year==2015 || (296939 <= runNumber && runNumber <= 300287)) min_tau_STT = 100. * Athena::Units::GeV; // 2016 period B-D3 else if(300345 <= runNumber && runNumber <= 302872) -- GitLab From 288cb7f2bce551a4b485c99eddb56eb754df143d Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:48:34 +0100 Subject: [PATCH 56/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index c158dd583..7d8614785 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -151,7 +151,6 @@ namespace Easyjet muon->pt() > 7 * Athena::Units::GeV) { nlepton++; passLeptonPtSLTThreshold |= muon->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu]; - leptonVetoForHadHad |= muon->pt() > 8000; } } for(const xAOD::Electron* ele : *elesIn) { -- GitLab From cb99d4dd7f6e4c1c0c64f01c41eb8ea917853299 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:48:49 +0100 Subject: [PATCH 57/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 7d8614785..dae929f79 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -154,7 +154,7 @@ namespace Easyjet } } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele)) { + if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV) nlepton++; passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; leptonVetoForHadHad |= ele->pt() > 8000; -- GitLab From fd1550bdff596da5c332a3a44dd4a93676a1e961 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:48:56 +0100 Subject: [PATCH 58/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index dae929f79..5e6a83a6b 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -157,7 +157,6 @@ namespace Easyjet if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV) nlepton++; passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; - leptonVetoForHadHad |= ele->pt() > 8000; } } } -- GitLab From 0353a510075b5c2ecc7d31c13b18d067284ac49a Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Fri, 15 Mar 2024 10:50:08 +0100 Subject: [PATCH 59/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 5e6a83a6b..4d1d035a2 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -168,10 +168,9 @@ namespace Easyjet bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; ptUncalTauDecorHandle(*tau) = tau->pt(); - if(m_doAntiTauDecor){ - bool STT = isSTT(*eventInfo); - if(isTauID && isSTTMatched(*tau) && STT) nIDMatchedTauSTT++; - if (isSTTMatched(*tau) && STT) passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; + if(m_doAntiTauDecor && isSTTMatched(*tau)){ + if(isTauID) nIDMatchedTauSTT++; + passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; } } if(m_doAntiTauDecor){ -- GitLab From e62ab8bedf36a3a7d9c13b4a6fa4cdc46b59c797 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 15 Mar 2024 11:56:58 +0100 Subject: [PATCH 60/68] Clean up code and apply most remaining suggestions --- EasyjetHub/src/TauDecoratorAlg.cxx | 64 +++++++------------------- EasyjetHub/src/TauDecoratorAlg.h | 4 -- bbttAnalysis/share/RunConfig-bbtt.yaml | 4 +- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 4d1d035a2..575d0568a 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -53,6 +53,7 @@ namespace Easyjet m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; ATH_CHECK (m_antiTauDecorKey.initialize()); + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; @@ -64,7 +65,6 @@ namespace Easyjet m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - ATH_CHECK(m_pass_DecorKeySLT.initialize()); ATH_CHECK(m_pass_DecorKeyLTT.initialize()); ATH_CHECK(m_pass_DecorKeySTT.initialize()); @@ -116,8 +116,6 @@ namespace Easyjet SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, double> ptUncalTauDecorHandle(m_ptUncalTauDecorKey); - if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { @@ -125,8 +123,7 @@ namespace Easyjet } } - int nlepton = 0; - bool leptonVetoForHadHad = false; + int nLeptons = 0; bool passLeptonPtSLTThreshold = false; bool passTauPtSTTThreshold = false; std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; @@ -149,13 +146,13 @@ namespace Easyjet for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon) && muon->pt() > 7 * Athena::Units::GeV) { - nlepton++; + nLeptons++; passLeptonPtSLTThreshold |= muon->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu]; } } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV) - nlepton++; + if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV){ + nLeptons++; passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; } } @@ -167,38 +164,17 @@ namespace Easyjet nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; - ptUncalTauDecorHandle(*tau) = tau->pt(); if(m_doAntiTauDecor && isSTTMatched(*tau)){ if(isTauID) nIDMatchedTauSTT++; passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; } } if(m_doAntiTauDecor){ - bool STT = isSTT(*eventInfo); - bool DTT = isDTT(*eventInfo); - bool LTT = isLTT(*eventInfo); - bool SLT = isSLT(*eventInfo); - // use the "trigger fired flag" as category flag in lephad now - if (SLT && LTT && passLeptonPtSLTThreshold) LTT = false; - else if (SLT && LTT && !passLeptonPtSLTThreshold) SLT = false; - bool isLepHad = SLT || LTT; - - // use the "trigger fired flag" as category flag in hadhad now - if (STT && DTT && passTauPtSTTThreshold) DTT = false; - else if (STT && DTT && !passTauPtSTTThreshold) STT = false; - bool isHadHad = STT || DTT; - - if (isLepHad && isHadHad) { - // set also other categories to false to prioritize SLT - if (leptonVetoForHadHad) { - STT = false; - DTT = false; - } - else { - SLT = false; - LTT = false; - } - } + bool STT = isSTT(*eventInfo) && passTauPtSTTThreshold && nLeptons==0; + bool DTT = isDTT(*eventInfo) && !passTauPtSTTThreshold && nLeptons==0; + bool LTT = isLTT(*eventInfo) && !passLeptonPtSLTThreshold && nLeptons>0; + bool SLT = isSLT(*eventInfo) && passLeptonPtSLTThreshold && nLeptons>0; + for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); @@ -211,11 +187,9 @@ namespace Easyjet else if (STT && nIDMatchedTauSTT == 0) isAntiTau &= isSTTMatched(*tau); // in STT if ID tau not trig matched anti tau needs be matched to trigger int antiTauCategory = 0; - if (!leptonVetoForHadHad && isAntiTau) { - antiTauCategory = 1; - } - if (leptonVetoForHadHad && isAntiTau) { - antiTauCategory = 2; + if (isAntiTau) { + if( SLT || LTT ) antiTauCategory = 1; + else if ( STT || DTT ) antiTauCategory = 2; } eventCategoryDecorHandle(*tau) = antiTauCategory; @@ -232,14 +206,11 @@ namespace Easyjet // https://twiki.cern.ch/twiki/bin/view/Atlas/LowestUnprescaled year = 0; - if(m_years.size()==1) year = m_years[0]; - else{ - if(266904 <= runNumber && runNumber <= 284484) year = 2015; - else if(296939 <= runNumber && runNumber <= 311481) year = 2016; - } - + if(266904 <= runNumber && runNumber <= 284484) year = 2015; + else if(296939 <= runNumber && runNumber <= 311481) year = 2016; + // Single-lepton triggers - if(m_year==2015) + if(year==2015) ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele] = 25. * Athena::Units::GeV; // 2022 75 bunches else if(427882 <= runNumber && runNumber < 428071) @@ -267,6 +238,5 @@ namespace Easyjet } - } diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 787e483f1..1620b9d96 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -62,10 +62,6 @@ private: { this, "isMC", false, "Is this simulation?" }; - Gaudi::Property<std::vector<int>> m_years - { this, "Years", false, "which years are running" }; - - SG::ReadDecorHandleKey<xAOD::EventInfo> m_runNumberKey{ this, "runNumberDecorKey", "EventInfo.runNumber", "Run number"}; SG::ReadDecorHandleKey<xAOD::EventInfo> m_rdmRunNumberKey{ diff --git a/bbttAnalysis/share/RunConfig-bbtt.yaml b/bbttAnalysis/share/RunConfig-bbtt.yaml index 118e1f2f1..d1837d72e 100644 --- a/bbttAnalysis/share/RunConfig-bbtt.yaml +++ b/bbttAnalysis/share/RunConfig-bbtt.yaml @@ -10,14 +10,12 @@ ttree_output: small_R_jets: 'container_names.output.reco4PFlowJet' # muons: 'container_names.output.muons' # electrons: 'container_names.output.electrons' - taus: 'container_names.output.taus' + # taus: 'container_names.output.taus' met : 'container_names.output.met' collection_options: small_R_jets: btag_info: true higgs_parent_info: true - taus: - RNN_branches: true truth_outputs: small_R_jets: 'container_names.input.truth4Jet' higgs_particle: 'container_names.output.truthHHParticles' -- GitLab From 45999028ca569399e6fc30274332e49b0e4fa1a1 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Fri, 15 Mar 2024 11:59:22 +0100 Subject: [PATCH 61/68] Fix config back to default --- EasyjetHub/python/output/ttree/tau_decor_config.py | 2 +- EasyjetHub/python/output/ttree/taus.py | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/EasyjetHub/python/output/ttree/tau_decor_config.py b/EasyjetHub/python/output/ttree/tau_decor_config.py index 39303fb6b..0162aa9f8 100644 --- a/EasyjetHub/python/output/ttree/tau_decor_config.py +++ b/EasyjetHub/python/output/ttree/tau_decor_config.py @@ -23,9 +23,9 @@ def tau_decor_cfg(flags, **kwargs): isMC=flags.Input.isMC, tauIDWP=flags.Analysis.Tau.ID, doAntiTauDecor=flags.Analysis.do_bbtt_analysis, - tausIn=taucoll, muonsIn=muoncoll, elesIn=elecoll, + tausIn=taucoll, **kwargs ) ) diff --git a/EasyjetHub/python/output/ttree/taus.py b/EasyjetHub/python/output/ttree/taus.py index 0e9650bdf..9707f5ef5 100644 --- a/EasyjetHub/python/output/ttree/taus.py +++ b/EasyjetHub/python/output/ttree/taus.py @@ -19,10 +19,7 @@ def get_tau_branches(flags, tree_flags, input_container, output_prefix): tau_branches.add_four_mom_branches(do_mass=False) tau_branches.variables += ["charge", "nProng", "isIDTau"] if flags.Analysis.do_bbtt_analysis: - tau_branches.variables += ["isAntiTau", "trigMatch_STT", - "trigMatch_LTT", "trigMatch_DTT", - "antiTauEventCategory", - ] + tau_branches.variables += ["isAntiTau"] if flags.Input.isMC: for tau_id in [flags.Analysis.Tau.ID]: -- GitLab From da43f6e8c18a869fa4e3f3c13a34db8e898cda43 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Mon, 18 Mar 2024 10:25:17 +0100 Subject: [PATCH 62/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 575d0568a..3a144b202 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -38,10 +38,8 @@ namespace Easyjet ATH_CHECK (m_IDTauDecorKey.initialize()); - if(m_doAntiTauDecor){ - // Muons + ele stuff to be cleaned up after trigger matching is used - ATH_CHECK (m_muonsInKey.initialize()); - ATH_CHECK (m_elesInKey.initialize()); + ATH_CHECK (m_muonsInKey.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_elesInKey.initialize(m_doAntiTauDecor)); m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; -- GitLab From 384b6e44eb611a0204c02e286b18c426146eef0d Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Mon, 18 Mar 2024 10:25:30 +0100 Subject: [PATCH 63/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 1620b9d96..f15aac0a9 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -111,11 +111,6 @@ private: }; SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_IDTauDecorKey; - Gaudi::Property<std::string> m_ptUncalTauDecorName{ - this, "ptUncalTauDecorName", "ptUncal", "Decoration for the uncalibrated pt" - }; - SG::WriteDecorHandleKey<xAOD::TauJetContainer> m_ptUncalTauDecorKey; - Gaudi::Property<bool> m_doAntiTauDecor { this, "doAntiTauDecor", false, "Add anti-tau decoration" }; Gaudi::Property<std::string> m_antiTauDecorName{ -- GitLab From a41611b3b25eff93789fa16bfc4ca800c8f7d1a5 Mon Sep 17 00:00:00 2001 From: Thomas Strebler <thomas.strebler@cern.ch> Date: Mon, 18 Mar 2024 10:54:38 +0100 Subject: [PATCH 64/68] Apply 1 suggestion(s) to 1 file(s) --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 3a144b202..e4cb974d7 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -149,7 +149,7 @@ namespace Easyjet } } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV){ + if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV){ nLeptons++; passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; } -- GitLab From 42d079c053aeb853f3fd3ba7321fcfb86d4f50be Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 18 Mar 2024 10:56:51 +0100 Subject: [PATCH 65/68] Apply suggestions --- EasyjetHub/src/TauDecoratorAlg.cxx | 2 -- EasyjetHub/src/TauDecoratorAlg.h | 1 - 2 files changed, 3 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 575d0568a..3b6c31078 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -12,8 +12,6 @@ #include <AthenaKernel/Units.h> -#include <unordered_map> - namespace Easyjet { diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index 1620b9d96..cbb63773c 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -27,7 +27,6 @@ #include <xAODMuon/MuonContainer.h> #include <xAODEgamma/ElectronContainer.h> -#include <AthenaKernel/Units.h> #include "ThresholdHelper.h" namespace Easyjet -- GitLab From d9adf75b9cedcbf3014f12721a612a623dd66884 Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 18 Mar 2024 16:03:05 +0100 Subject: [PATCH 66/68] Clean up code --- EasyjetHub/src/TauDecoratorAlg.cxx | 113 ++++++++++++++--------------- 1 file changed, 53 insertions(+), 60 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 73b4ab625..43c51c8fa 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -39,36 +39,32 @@ namespace Easyjet ATH_CHECK (m_muonsInKey.initialize(m_doAntiTauDecor)); ATH_CHECK (m_elesInKey.initialize(m_doAntiTauDecor)); - m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; - m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; - m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); - - m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); - - m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; - m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; - m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); - - m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; - m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; - m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; - m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - ATH_CHECK(m_pass_DecorKeySLT.initialize()); - ATH_CHECK(m_pass_DecorKeyLTT.initialize()); - ATH_CHECK(m_pass_DecorKeySTT.initialize()); - ATH_CHECK(m_pass_DecorKeyDTT.initialize()); - - m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; - ATH_CHECK (m_eventCategoryDecorKey.initialize()); - } + m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; + m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; + m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; + ATH_CHECK (m_muonIdDecorKey.initialize()); + ATH_CHECK (m_muonPreselDecorKey.initialize()); + ATH_CHECK (m_eleIdDecorKey.initialize()); + m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; + ATH_CHECK (m_antiTauDecorKey.initialize()); + + m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; + m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; + m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; + ATH_CHECK (m_triggerMatchSTTKey.initialize()); + ATH_CHECK (m_triggerMatchLTTKey.initialize()); + ATH_CHECK (m_triggerMatchDTTKey.initialize()); + m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; + m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; + m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; + m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; + ATH_CHECK(m_pass_DecorKeySLT.initialize()); + ATH_CHECK(m_pass_DecorKeyLTT.initialize()); + ATH_CHECK(m_pass_DecorKeySTT.initialize()); + ATH_CHECK(m_pass_DecorKeyDTT.initialize()); + m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; + ATH_CHECK (m_eventCategoryDecorKey.initialize()); + if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; else if(m_tauIDWP_name=="Medium") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigMedium; @@ -88,6 +84,10 @@ namespace Easyjet ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (elesIn.isValid()); // trigger tau decorators SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); @@ -119,59 +119,51 @@ namespace Easyjet } } - int nLeptons = 0; - bool passLeptonPtSLTThreshold = false; - bool passTauPtSTTThreshold = false; - std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; - - if(m_doAntiTauDecor){ + std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; unsigned int rdmNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); - int year = 0; + int year = 0; - setRunNumberQuantities(rdmNumber, year, ptThresholds); + setRunNumberQuantities(rdmNumber, year, ptThresholds); - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - ATH_CHECK (elesIn.isValid()); + int nIDMatchedTauSTT = 0; + bool passTauPtSTTThreshold = false; + + for(const xAOD::TauJet* tau : *tausIn) { + nProngDecorHandle(*tau) = tau->nTracks(); + bool isTauID = tau->isTau(m_tauIDWP); + idTauDecorHandle(*tau) = isTauID; + if(m_doAntiTauDecor && isSTTMatched(*tau)){ + if(isTauID) nIDMatchedTauSTT++; + passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; + } + } + if(m_doAntiTauDecor){ + int nLeptons = 0; + bool passLeptonPtSLTThreshold = false; SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); for(const xAOD::Muon* muon : *muonsIn) { - if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon) && - muon->pt() > 7 * Athena::Units::GeV) { + if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon) && + muon->pt() > 7 * Athena::Units::GeV) { nLeptons++; passLeptonPtSLTThreshold |= muon->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::mu]; } } for(const xAOD::Electron* ele : *elesIn) { - if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV){ + if(eleIdDecorHandle(*ele) && ele->pt() > 7 * Athena::Units::GeV){ nLeptons++; passLeptonPtSLTThreshold |= ele->pt() > ptThresholds[Easyjet::TriggerChannel::SLT][Easyjet::Var::ele]; } } - } - int nIDMatchedTauSTT = 0; - - for(const xAOD::TauJet* tau : *tausIn) { - nProngDecorHandle(*tau) = tau->nTracks(); - bool isTauID = tau->isTau(m_tauIDWP); - idTauDecorHandle(*tau) = isTauID; - if(m_doAntiTauDecor && isSTTMatched(*tau)){ - if(isTauID) nIDMatchedTauSTT++; - passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; - } - } - if(m_doAntiTauDecor){ bool STT = isSTT(*eventInfo) && passTauPtSTTThreshold && nLeptons==0; bool DTT = isDTT(*eventInfo) && !passTauPtSTTThreshold && nLeptons==0; bool LTT = isLTT(*eventInfo) && !passLeptonPtSLTThreshold && nLeptons>0; bool SLT = isSLT(*eventInfo) && passLeptonPtSLTThreshold && nLeptons>0; - for(const xAOD::TauJet* tau : *tausIn) { bool isTauID = tau->isTau(m_tauIDWP); float RNNScore = tau->discriminant(xAOD::TauJetParameters::RNNJetScoreSigTrans); @@ -187,14 +179,15 @@ namespace Easyjet if( SLT || LTT ) antiTauCategory = 1; else if ( STT || DTT ) antiTauCategory = 2; } + eventCategoryDecorHandle(*tau) = antiTauCategory; - antiTauDecorHandle(*tau) = isAntiTau; } } return StatusCode::SUCCESS; } + void TauDecoratorAlg::setRunNumberQuantities(unsigned int runNumber, int& year, std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>>& ptThresholds) const{ // References: -- GitLab From 2c417cdab7591e92f31ddfd766848c6c8673859b Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 18 Mar 2024 17:19:20 +0100 Subject: [PATCH 67/68] Fix errors for jobs that do not use anti-ID taus --- EasyjetHub/src/TauDecoratorAlg.cxx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index 43c51c8fa..eac327b9e 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -42,28 +42,28 @@ namespace Easyjet m_muonIdDecorKey = m_muonsInKey.key() + "." + m_muonIdDecorName; m_muonPreselDecorKey = m_muonsInKey.key() + "." + m_muonPreselDecorName; m_eleIdDecorKey = m_elesInKey.key() + "." + m_eleIdDecorName; - ATH_CHECK (m_muonIdDecorKey.initialize()); - ATH_CHECK (m_muonPreselDecorKey.initialize()); - ATH_CHECK (m_eleIdDecorKey.initialize()); + ATH_CHECK (m_muonIdDecorKey.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_muonPreselDecorKey.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_eleIdDecorKey.initialize(m_doAntiTauDecor)); m_antiTauDecorKey = m_tausInKey.key() + "." + m_antiTauDecorName; - ATH_CHECK (m_antiTauDecorKey.initialize()); + ATH_CHECK (m_antiTauDecorKey.initialize(m_doAntiTauDecor)); m_triggerMatchSTTKey = m_tausInKey.key() + "." + m_triggerMatchSTTDecorName; m_triggerMatchLTTKey = m_tausInKey.key() + "." + m_triggerMatchLTTDecorName; m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; - ATH_CHECK (m_triggerMatchSTTKey.initialize()); - ATH_CHECK (m_triggerMatchLTTKey.initialize()); - ATH_CHECK (m_triggerMatchDTTKey.initialize()); + ATH_CHECK (m_triggerMatchSTTKey.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_triggerMatchLTTKey.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_triggerMatchDTTKey.initialize(m_doAntiTauDecor)); m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - ATH_CHECK(m_pass_DecorKeySLT.initialize()); - ATH_CHECK(m_pass_DecorKeyLTT.initialize()); - ATH_CHECK(m_pass_DecorKeySTT.initialize()); - ATH_CHECK(m_pass_DecorKeyDTT.initialize()); + ATH_CHECK(m_pass_DecorKeySLT.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_pass_DecorKeyLTT.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_pass_DecorKeySTT.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_pass_DecorKeyDTT.initialize(m_doAntiTauDecor)); m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; - ATH_CHECK (m_eventCategoryDecorKey.initialize()); + ATH_CHECK (m_eventCategoryDecorKey.initialize(m_doAntiTauDecor)); if(m_tauIDWP_name=="Loose") m_tauIDWP = xAOD::TauJetParameters::JetRNNSigLoose; -- GitLab From 4d3ef67b687b35646e8c9bea0cc92d73a93c118f Mon Sep 17 00:00:00 2001 From: Philipp Rincke <philipp.rincke@studium.uni-hamburg.de> Date: Mon, 18 Mar 2024 18:23:54 +0100 Subject: [PATCH 68/68] Improve naming of DecorKeys and attempt to avoid varhandle init error --- EasyjetHub/src/TauDecoratorAlg.cxx | 104 +++++++++++++++-------------- EasyjetHub/src/TauDecoratorAlg.h | 8 +-- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/EasyjetHub/src/TauDecoratorAlg.cxx b/EasyjetHub/src/TauDecoratorAlg.cxx index eac327b9e..fc9145728 100644 --- a/EasyjetHub/src/TauDecoratorAlg.cxx +++ b/EasyjetHub/src/TauDecoratorAlg.cxx @@ -53,15 +53,17 @@ namespace Easyjet m_triggerMatchDTTKey = m_tausInKey.key() + "." + m_triggerMatchDTTDecorName; ATH_CHECK (m_triggerMatchSTTKey.initialize(m_doAntiTauDecor)); ATH_CHECK (m_triggerMatchLTTKey.initialize(m_doAntiTauDecor)); - ATH_CHECK (m_triggerMatchDTTKey.initialize(m_doAntiTauDecor)); - m_pass_DecorKeySLT = "EventInfo.pass_trigger_SLT"; - m_pass_DecorKeyLTT = "EventInfo.pass_trigger_LTT"; - m_pass_DecorKeySTT = "EventInfo.pass_trigger_STT"; - m_pass_DecorKeyDTT = "EventInfo.pass_trigger_DTT"; - ATH_CHECK(m_pass_DecorKeySLT.initialize(m_doAntiTauDecor)); - ATH_CHECK(m_pass_DecorKeyLTT.initialize(m_doAntiTauDecor)); - ATH_CHECK(m_pass_DecorKeySTT.initialize(m_doAntiTauDecor)); - ATH_CHECK(m_pass_DecorKeyDTT.initialize(m_doAntiTauDecor)); + ATH_CHECK (m_triggerMatchDTTKey.initialize(m_doAntiTauDecor)); + + m_passSLTDecorKey = "EventInfo.pass_trigger_SLT"; + m_passLTTDecorKey = "EventInfo.pass_trigger_LTT"; + m_passSTTDecorKey = "EventInfo.pass_trigger_STT"; + m_passDTTDecorKey = "EventInfo.pass_trigger_DTT"; + ATH_CHECK(m_passSLTDecorKey.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_passLTTDecorKey.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_passSTTDecorKey.initialize(m_doAntiTauDecor)); + ATH_CHECK(m_passDTTDecorKey.initialize(m_doAntiTauDecor)); + m_eventCategoryDecorKey = m_tausInKey.key() + "." + m_eventCategoryDecorName; ATH_CHECK (m_eventCategoryDecorKey.initialize(m_doAntiTauDecor)); @@ -84,66 +86,70 @@ namespace Easyjet ATH_CHECK (eventInfo.isValid()); SG::ReadHandle<xAOD::TauJetContainer> tausIn(m_tausInKey,ctx); ATH_CHECK (tausIn.isValid()); - SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); - ATH_CHECK (muonsIn.isValid()); - SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); - ATH_CHECK (elesIn.isValid()); - - // trigger tau decorators - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); - SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); - - SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_runNumberHandle - (m_runNumberKey); - SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_rdmRunNumberHandle - (m_rdmRunNumberKey); - - - // trigger event decorators - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_pass_DecorKeySLT); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_pass_DecorKeyLTT); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_pass_DecorKeySTT); - SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_pass_DecorKeyDTT); - - SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); + SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_runNumberHandle(m_runNumberKey); + SG::ReadDecorHandle<xAOD::EventInfo, unsigned int> m_rdmRunNumberHandle(m_rdmRunNumberKey); SG::WriteDecorHandle<xAOD::TauJetContainer, int> nProngDecorHandle(m_nProngDecorKey); SG::WriteDecorHandle<xAOD::TauJetContainer, char> idTauDecorHandle(m_IDTauDecorKey); - SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + if(m_isMC){ SG::WriteDecorHandle<xAOD::TauJetContainer, int> truthTypeDecorHandle(m_truthTypeDecorKey); for(const xAOD::TauJet* tau : *tausIn) { - truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); + truthTypeDecorHandle(*tau) = int(TauAnalysisTools::getTruthParticleType(*tau)); } } - std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; - unsigned int rdmNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); - int year = 0; - - setRunNumberQuantities(rdmNumber, year, ptThresholds); - - int nIDMatchedTauSTT = 0; - bool passTauPtSTTThreshold = false; - for(const xAOD::TauJet* tau : *tausIn) { nProngDecorHandle(*tau) = tau->nTracks(); bool isTauID = tau->isTau(m_tauIDWP); idTauDecorHandle(*tau) = isTauID; - if(m_doAntiTauDecor && isSTTMatched(*tau)){ - if(isTauID) nIDMatchedTauSTT++; - passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; } - } + if(m_doAntiTauDecor){ - int nLeptons = 0; - bool passLeptonPtSLTThreshold = false; + // lepton read handles + SG::ReadHandle<xAOD::MuonContainer> muonsIn(m_muonsInKey,ctx); + ATH_CHECK (muonsIn.isValid()); + SG::ReadHandle<xAOD::ElectronContainer> elesIn(m_elesInKey,ctx); + ATH_CHECK (elesIn.isValid()); SG::ReadDecorHandle<xAOD::MuonContainer, char> muonIdDecorHandle(m_muonIdDecorKey); SG::ReadDecorHandle<xAOD::MuonContainer, char> muonPreselDecorHandle(m_muonPreselDecorKey); SG::ReadDecorHandle<xAOD::ElectronContainer, char> eleIdDecorHandle(m_eleIdDecorKey); + + // trigger tau read handles + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isSTTMatched(m_triggerMatchSTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isLTTMatched(m_triggerMatchLTTKey); + SG::ReadDecorHandle<xAOD::TauJetContainer, bool> isDTTMatched(m_triggerMatchDTTKey); + + // tau write decorators + SG::WriteDecorHandle<xAOD::TauJetContainer, int> eventCategoryDecorHandle(m_eventCategoryDecorKey); + SG::WriteDecorHandle<xAOD::TauJetContainer, char> antiTauDecorHandle(m_antiTauDecorKey); + + // trigger event read handles + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSLT(m_passSLTDecorKey); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isLTT(m_passLTTDecorKey); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isSTT(m_passSTTDecorKey); + SG::ReadDecorHandle<xAOD::EventInfo, bool> isDTT(m_passDTTDecorKey); + + std::unordered_map<Easyjet::TriggerChannel, std::unordered_map<Easyjet::Var, float>> ptThresholds; + unsigned int rdmNumber = m_isMC ? m_rdmRunNumberHandle(*eventInfo) : m_runNumberHandle(*eventInfo); + int year = 0; + setRunNumberQuantities(rdmNumber, year, ptThresholds); + + int nIDMatchedTauSTT = 0; + bool passTauPtSTTThreshold = false; + + for(const xAOD::TauJet* tau : *tausIn) { + bool isTauID = tau->isTau(m_tauIDWP); + if(m_doAntiTauDecor && isSTTMatched(*tau)){ + if(isTauID) nIDMatchedTauSTT++; + passTauPtSTTThreshold |= tau->pt() > ptThresholds[Easyjet::TriggerChannel::STT][Easyjet::Var::leadingtau]; + } + } + + int nLeptons = 0; + bool passLeptonPtSLTThreshold = false; for(const xAOD::Muon* muon : *muonsIn) { if(muonIdDecorHandle(*muon) && muonPreselDecorHandle(*muon) && diff --git a/EasyjetHub/src/TauDecoratorAlg.h b/EasyjetHub/src/TauDecoratorAlg.h index d80d3239e..9e8fd3c39 100644 --- a/EasyjetHub/src/TauDecoratorAlg.h +++ b/EasyjetHub/src/TauDecoratorAlg.h @@ -49,10 +49,10 @@ public: private: - SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySLT; - SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyLTT; - SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeySTT; - SG::ReadDecorHandleKey<xAOD::EventInfo> m_pass_DecorKeyDTT; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_passSLTDecorKey; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_passLTTDecorKey; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_passSTTDecorKey; + SG::ReadDecorHandleKey<xAOD::EventInfo> m_passDTTDecorKey; // Members for configurable properties SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey -- GitLab