From 92cc456c5c4ec8f52a745dfb3c9e332c681e066f Mon Sep 17 00:00:00 2001 From: Marco Vanadia <marco.vanadia@cern.ch> Date: Mon, 3 May 2021 18:17:36 +0200 Subject: [PATCH 1/2] first implementation of test option for muon OR --- .../TopAnalysis/Root/EventSaverFlatNtuple.cxx | 12 +++++++ .../TopAnalysis/EventSaverFlatNtuple.h | 1 + .../Root/ConfigurationSettings.cxx | 2 ++ .../xAOD/TopConfiguration/Root/TopConfig.cxx | 7 ++++ .../TopConfiguration/TopConfig.h | 10 ++++++ .../Root/TopObjectSelection.cxx | 34 +++++++++++++++++++ 6 files changed, 66 insertions(+) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx index 73f270f4e1eb..dcbed053f12b 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx @@ -881,6 +881,10 @@ namespace top { systematicTree->makeOutputVariable(m_mu_true_IFFclass, "mu_true_IFFclass"); systematicTree->makeOutputVariable(m_mu_true_isPrompt, "mu_true_isPrompt"); } + if(m_config->noORForMuons()) + { + systematicTree->makeOutputVariable(m_mu_passOR, "mu_passOR"); + } if (m_config->enablePromptLeptonImprovedVetoStudies()) { systematicTree->makeOutputVariable(m_PLIV_mu_PromptLeptonRNN_non_prompt_b, "PLIV_mu_PromptLeptonRNN_non_prompt_b"); systematicTree->makeOutputVariable(m_PLIV_mu_PromptLeptonRNN_non_prompt_c, "PLIV_mu_PromptLeptonRNN_non_prompt_c"); @@ -2292,6 +2296,8 @@ namespace top { m_mu_topoetcone20.resize(n_muons); m_mu_ptvarcone30.resize(n_muons); m_mu_isTight.resize(n_muons); + m_mu_passOR.resize(n_muons); + for (const auto& trigger : m_mu_trigMatched) m_mu_trigMatched[trigger.first].resize(n_muons); m_mu_d0sig.resize(n_muons); @@ -2342,6 +2348,12 @@ namespace top { m_mu_isTight[i] = muPtr->auxdataConst<char>("passPreORSelection"); } } + + if(m_config->noORForMuons()) + { + m_mu_passOR[i]=muPtr->auxdataConst<char>("passOverlapRemoval"); + } + for (const auto& trigger : m_mu_trigMatched) { std::string trig = "TRIGMATCH_" + trigger.first; m_mu_trigMatched[trigger.first][i] = muPtr->auxdataConst<char>(trig); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h index 690ce14a4659..0e0d2a09267d 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/TopAnalysis/EventSaverFlatNtuple.h @@ -559,6 +559,7 @@ namespace top { std::vector<float> m_mu_prodVtx_z; std::vector<float> m_mu_prodVtx_perp; std::vector<float> m_mu_prodVtx_phi; + std::vector<char> m_mu_passOR; //soft muons std::vector<float> m_softmu_pt; diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx index 8ea43be3df7d..2cea988db60d 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx @@ -665,6 +665,8 @@ namespace top { " noPhotonMuOR, noPhotonMuOrJetOR", "recommended" ); + + registerParameter("NoOverlapRemovalForMuons", "For tests: do not remove muons due to OR, instead store a flag with the OR result for them in the output. True or False (default: False).", "False"); registerParameter("OverlapRemovalSlidingInnerDRel", "Overlap removal inner radius to be used for electron SlidingDR ,", "0.2"); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx index 9e0526341558..b64190347224 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx @@ -96,6 +96,8 @@ namespace top { m_writeMETBuiltWithLooseObjects(false), // Apply overlap removal on loose lepton definitons - not the top recommendation, for studies only m_doOverlapRemovalOnLooseLeptonDef(false), + //test option for muons OR + m_noORForMuons(false), // do overlap removal also with large-R jets // (using whatever procedure is used in the official tools) m_doLargeJetOverlapRemoval(false), @@ -1487,6 +1489,11 @@ namespace top { if (settings->value("OverlapRemovalLeptonDef") == "Loose") this->setOverlapRemovalOnLooseLeptonDef(); m_overlap_removal_procedure = settings->value("OverlapRemovalProcedure"); + + //test option for muon OR + bool noORForMuons = false; + settings->retrieve("NoOverlapRemovalForMuons", noORForMuons); + this->setNoORForMuons(noORForMuons); // do overlap removal also with large-R jets // (using whatever procedure is used in the official tools) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h index 7b291e1e1074..40401fb166d5 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h @@ -301,6 +301,13 @@ namespace top { inline float overlapRemovalSlidingInnerDRmu() const {return m_overlapRemovalSlidingInnerDRmu;} + + //test option for muon OR + inline void setNoORForMuons(bool in){ + if (!m_configFixed) m_noORForMuons=in; + } + + inline bool noORForMuons() const{ return m_noORForMuons;} // do overlap removal also with large-R jets // (using whatever procedure is used in the official tools) @@ -2214,6 +2221,9 @@ namespace top { float m_overlapRemovalSlidingInnerDRel = 0.2; float m_overlapRemovalSlidingInnerDRmu = 0.2; + + //test option for muon OR + bool m_noORForMuons; // do overlap removal also with large-R jets // (using whatever procedure is used in the official tools) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx index 74f3957ea327..ec430c37f4e2 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx @@ -964,6 +964,40 @@ void TopObjectSelection::applySelectionPreOverlapRemovalJetGhostTracks() { goodPhotons, goodElectrons, goodMuons, goodTaus, goodJets, goodLargeRJets, looseLeptonOR); + //test option for muons to store them also if they are removed from OR, saving a flag with the OR result for them + if(m_config->noORForMuons()) + { + std::string passTopCuts(""); + if (!looseLeptonOR) { + passTopCuts = "passPreORSelection"; + } + if (looseLeptonOR) { + passTopCuts = "passPreORSelectionLoose"; + } + std::vector<unsigned int> goodMuonsTemp; + unsigned int iMu=0; + for (const xAOD::Muon* x: *xaod_mu) { + bool passTopSelection=false; + if(x->auxdataConst< char >(passTopCuts) == 1) + { + goodMuonsTemp.push_back(iMu); + } + bool passOR=false; + for(unsigned int isGoodMu : goodMuons) + { + if(iMu == isGoodMu) + { + passOR=true; + break; + } + } + x->auxdecor<char>("passOverlapRemoval") = passOR; + iMu++; + } + goodMuons = goodMuonsTemp; + + } + // Additonal lepton information std::vector<unsigned int> overlapsEl, overlapsMu; if (m_overlapRemovalToolPostSelection->overlapsEl(overlapsEl)) { -- GitLab From 82daf76b1dcdab3fcb1b121ae6ae887a44b7ab6e Mon Sep 17 00:00:00 2001 From: Marco Vanadia <marco.vanadia@cern.ch> Date: Tue, 4 May 2021 11:15:30 +0200 Subject: [PATCH 2/2] fixing compilation warning --- .../xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx index ec430c37f4e2..6965daf3cbf7 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopObjectSelectionTools/Root/TopObjectSelection.cxx @@ -976,8 +976,8 @@ void TopObjectSelection::applySelectionPreOverlapRemovalJetGhostTracks() { } std::vector<unsigned int> goodMuonsTemp; unsigned int iMu=0; - for (const xAOD::Muon* x: *xaod_mu) { - bool passTopSelection=false; + for (const xAOD::Muon* x: *xaod_mu) + { if(x->auxdataConst< char >(passTopCuts) == 1) { goodMuonsTemp.push_back(iMu); -- GitLab