diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/ChargeSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/ChargeSelectorAlg.h index bf262ccbc111f997eb395d0fa257039ceb5f7c66..d766a990eb601890475ef1afd2c5d0f003c23250 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/ChargeSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/ChargeSelectorAlg.h @@ -19,6 +19,7 @@ // Framework includes #include <xAODEgamma/ElectronContainer.h> #include <xAODMuon/MuonContainer.h> +#include <xAODTruth/TruthParticleContainer.h> #include <xAODEventInfo/EventInfo.h> namespace CP { @@ -62,6 +63,26 @@ namespace CP { this, "muonSelection", "", "the selection on the input muons" }; + /// \brief the truth electron input handle + CP::SysReadHandle<xAOD::TruthParticleContainer> m_electronsTruthHandle { + this, "truthElectrons", "", "the truth electron container to use" + }; + + /// \brief the truth electron selection handle + CP::SysReadSelectionHandle m_electronTruthSelection { + this, "truthElectronSelection", "", "the selection on the input truth electrons" + }; + + /// \brief the truth muon input handle + CP::SysReadHandle<xAOD::TruthParticleContainer> m_muonsTruthHandle { + this, "truthMuons", "", "the truth muon container to use" + }; + + /// \brief the truth muon selection handle + CP::SysReadSelectionHandle m_muonTruthSelection { + this, "truthMuonSelection", "", "the selection on the input muons" + }; + /// \brief the event info handle CP::SysReadHandle<xAOD::EventInfo> m_eventInfoHandle { this, "eventInfo", "EventInfo", "the EventInfo container to read selection decisions from" diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassSelectorAlg.h index 14c7d8e33e6e775da773079a10aaa3160ce77613..79bb4d8df006f6967d39ffe83eb4026e70e70c8f 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassSelectorAlg.h @@ -17,8 +17,7 @@ #include <SystematicsHandles/SysWriteDecorHandle.h> // Framework includes -#include <xAODEgamma/ElectronContainer.h> -#include <xAODMuon/MuonContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODEventInfo/EventInfo.h> #include <EventSelectionAlgorithms/SignEnums.h> @@ -51,7 +50,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the electrons handle - CP::SysReadHandle<xAOD::ElectronContainer> m_electronsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_electronsHandle { this, "electrons", "", "the electron container to use" }; @@ -61,7 +60,7 @@ namespace CP { }; /// \brief the muons handle - CP::SysReadHandle<xAOD::MuonContainer> m_muonsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_muonsHandle { this, "muons", "", "the muon container to use" }; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassWindowSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassWindowSelectorAlg.h index 7a64df02a01f1dfdbc52d8345a228e85f2bd5129..6744c58f29b1370ead66d2a1964977663a6bc9e2 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassWindowSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonInvariantMassWindowSelectorAlg.h @@ -17,8 +17,7 @@ #include <SystematicsHandles/SysWriteDecorHandle.h> // Framework includes -#include <xAODEgamma/ElectronContainer.h> -#include <xAODMuon/MuonContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODEventInfo/EventInfo.h> namespace CP { @@ -50,7 +49,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the electrons handle - CP::SysReadHandle<xAOD::ElectronContainer> m_electronsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_electronsHandle { this, "electrons", "", "the electron container to use" }; @@ -60,7 +59,7 @@ namespace CP { }; /// \brief the muons handle - CP::SysReadHandle<xAOD::MuonContainer> m_muonsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_muonsHandle { this, "muons", "", "the muon container to use" }; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonOSSFInvariantMassWindowSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonOSSFInvariantMassWindowSelectorAlg.h index 99942e1864726a5e58b66c7b224a02f20cc2f77c..6625f3166ed03581e8dfdc22983cdeed33e5c02e 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonOSSFInvariantMassWindowSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/DileptonOSSFInvariantMassWindowSelectorAlg.h @@ -17,6 +17,7 @@ // Framework includes #include <xAODEgamma/ElectronContainer.h> #include <xAODMuon/MuonContainer.h> +#include <xAODTruth/TruthParticleContainer.h> #include <xAODEventInfo/EventInfo.h> namespace CP { @@ -49,6 +50,18 @@ namespace CP { CP::SysReadSelectionHandle m_muonSelection { this, "muonSelection", "", "the selection on the input muons" }; + CP::SysReadHandle<xAOD::TruthParticleContainer> m_electronsTruthHandle { + this, "truthElectrons", "", "the truth electron container to use" + }; + CP::SysReadSelectionHandle m_electronTruthSelection { + this, "truthElectronSelection", "", "the selection on the input truth electrons" + }; + CP::SysReadHandle<xAOD::TruthParticleContainer> m_muonsTruthHandle { + this, "truthMuons", "", "the truth muon container to use" + }; + CP::SysReadSelectionHandle m_muonTruthSelection { + this, "truthMuonSelection", "", "the selection on the input muons" + }; CP::SysReadHandle<xAOD::EventInfo> m_eventInfoHandle { this, "eventInfo", "EventInfo", "the EventInfo container to read selection decisions from" }; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETPlusTransverseMassSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETPlusTransverseMassSelectorAlg.h index edb76c7939443d42a08a4b5fa5e96048c8d9b5c8..621063738f64ec19a1634483bc24e870d3c4970c 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETPlusTransverseMassSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETPlusTransverseMassSelectorAlg.h @@ -17,8 +17,7 @@ #include <SystematicsHandles/SysWriteDecorHandle.h> // Framework includes -#include <xAODEgamma/ElectronContainer.h> -#include <xAODMuon/MuonContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODMissingET/MissingETContainer.h> #include <xAODEventInfo/EventInfo.h> @@ -52,7 +51,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the electron input handle - CP::SysReadHandle<xAOD::ElectronContainer> m_electronsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_electronsHandle { this, "electrons", "", "the electron container to use" }; @@ -62,7 +61,7 @@ namespace CP { }; /// \brief the muon input handle - CP::SysReadHandle<xAOD::MuonContainer> m_muonsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_muonsHandle { this, "muons", "", "the muon container to use" }; @@ -76,6 +75,9 @@ namespace CP { this, "met", "SetMe", "the MET container to use" }; + /// \brief the MET term + Gaudi::Property<std::string> m_metTerm {this, "metTerm", "Final", "the MET term to use"}; + /// \brief the event info handle CP::SysReadHandle<xAOD::EventInfo> m_eventInfoHandle { this, "eventInfo", "EventInfo", "the EventInfo container to read selection decisions from" diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETSelectorAlg.h index 155b60c1c5aad444ba6616f357984dd429ffcda5..a4ac2960e3e91866502dd5db8d7ea3d55fc3d09f 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/MissingETSelectorAlg.h @@ -54,6 +54,9 @@ namespace CP { this, "met", "SetMe", "the MET container to use" }; + /// \brief the MET term + Gaudi::Property<std::string> m_metTerm {this, "metTerm", "Final", "the MET term to use"}; + /// \brief the event info handle CP::SysReadHandle<xAOD::EventInfo> m_eventInfoHandle { this, "eventInfo", "EventInfo", "the EventInfo container to read selection decisions from" diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/NLargeRJetMassWindowSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/NLargeRJetMassWindowSelectorAlg.h index ce51c498c006bf47f9bf4c8efd4b2b4e9467d6df..4853123155fbd077f1068589b9cedf344edc8823 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/NLargeRJetMassWindowSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/NLargeRJetMassWindowSelectorAlg.h @@ -17,7 +17,7 @@ #include <SystematicsHandles/SysWriteDecorHandle.h> // Framework includes -#include <xAODJet/JetContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODEventInfo/EventInfo.h> #include <EventSelectionAlgorithms/SignEnums.h> @@ -60,7 +60,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the large-R jet handle - CP::SysReadHandle<xAOD::JetContainer> m_ljetsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_ljetsHandle { this, "ljets", "", "the large-R jet container to use" }; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/SumNElNMuPtSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/SumNElNMuPtSelectorAlg.h index 3b302b984d9d88cfc1eec4e0d7e15cddc1a5bd63..2c05003ba857b3554c66a5e8e05d0392bc672ed3 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/SumNElNMuPtSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/SumNElNMuPtSelectorAlg.h @@ -15,8 +15,7 @@ #include <SelectionHelpers/SysWriteSelectionHandle.h> // Framework includes -#include <xAODEgamma/ElectronContainer.h> -#include <xAODMuon/MuonContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODEventInfo/EventInfo.h> #include <EventSelectionAlgorithms/SignEnums.h> @@ -55,7 +54,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the electrons handle - CP::SysReadHandle<xAOD::ElectronContainer> m_electronsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_electronsHandle { this, "electrons", "", "the electron container to use" }; @@ -65,7 +64,7 @@ namespace CP { }; /// \brief the muons handle - CP::SysReadHandle<xAOD::MuonContainer> m_muonsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_muonsHandle { this, "muons", "", "the muon container to use" }; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/TransverseMassSelectorAlg.h b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/TransverseMassSelectorAlg.h index 00a5d726b50bec81e483c3d1ea5168b092b427f4..4f10301bddb3c3ae8464d0f1aacb367e46663a1b 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/TransverseMassSelectorAlg.h +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/EventSelectionAlgorithms/TransverseMassSelectorAlg.h @@ -17,8 +17,7 @@ #include <SystematicsHandles/SysWriteDecorHandle.h> // Framework includes -#include <xAODEgamma/ElectronContainer.h> -#include <xAODMuon/MuonContainer.h> +#include <xAODBase/IParticleContainer.h> #include <xAODMissingET/MissingETContainer.h> #include <xAODEventInfo/EventInfo.h> @@ -52,7 +51,7 @@ namespace CP { CP::SysListHandle m_systematicsList {this}; /// \brief the electron handle - CP::SysReadHandle<xAOD::ElectronContainer> m_electronsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_electronsHandle { this, "electrons", "", "the electron container to use" }; @@ -62,7 +61,7 @@ namespace CP { }; /// \brief the muons handle - CP::SysReadHandle<xAOD::MuonContainer> m_muonsHandle { + CP::SysReadHandle<xAOD::IParticleContainer> m_muonsHandle { this, "muons", "", "the muon container to use" }; @@ -76,6 +75,9 @@ namespace CP { this, "met", "SetMe", "the MET container to use" }; + /// \brief the MET term + Gaudi::Property<std::string> m_metTerm {this, "metTerm", "Final", "the MET term to use"}; + /// \brief the event info handle CP::SysReadHandle<xAOD::EventInfo> m_eventInfoHandle { this, "eventInfo", "EventInfo", "the EventInfo container to read selection decisions from" diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/ChargeSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/ChargeSelectorAlg.cxx index e470c2a2168998d6c35a5d41345ee903cbe83795..e06c61841e5b06662c48398f2453c19cca602903 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/ChargeSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/ChargeSelectorAlg.cxx @@ -17,6 +17,10 @@ namespace CP { ANA_CHECK(m_electronSelection.initialize(m_systematicsList, m_electronsHandle, SG::AllowEmpty)); ANA_CHECK(m_muonsHandle.initialize(m_systematicsList, SG::AllowEmpty)); ANA_CHECK(m_muonSelection.initialize(m_systematicsList, m_muonsHandle, SG::AllowEmpty)); + ANA_CHECK(m_electronsTruthHandle.initialize(m_systematicsList, SG::AllowEmpty)); + ANA_CHECK(m_electronTruthSelection.initialize(m_systematicsList, m_electronsHandle, SG::AllowEmpty)); + ANA_CHECK(m_muonsTruthHandle.initialize(m_systematicsList, SG::AllowEmpty)); + ANA_CHECK(m_muonTruthSelection.initialize(m_systematicsList, m_muonsHandle, SG::AllowEmpty)); ANA_CHECK(m_eventInfoHandle.initialize(m_systematicsList)); ANA_CHECK(m_preselection.initialize(m_systematicsList, m_eventInfoHandle, SG::AllowEmpty)); @@ -47,23 +51,51 @@ namespace CP { const xAOD::MuonContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); + // retrieve the truth electron container + const xAOD::TruthParticleContainer *truthElectrons = nullptr; + if (m_electronsTruthHandle) + ANA_CHECK(m_electronsTruthHandle.retrieve(truthElectrons, sys)); + // retrieve the truth muon container + const xAOD::TruthParticleContainer *truthMuons = nullptr; + if (m_muonsTruthHandle) + ANA_CHECK(m_muonsTruthHandle.retrieve(truthMuons, sys)); // apply the requested selection and compute the local charge int total_charge = 0; int total_leptons = 0; - if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons) { - if (!m_electronSelection || m_electronSelection.getBool(*el, sys)){ - total_charge += el->charge(); - total_leptons++; + if (m_electronsHandle || m_muonsHandle) { + if (m_electronsHandle) { + for (const xAOD::Electron *el : *electrons) { + if (!m_electronSelection || m_electronSelection.getBool(*el, sys)){ + total_charge += el->charge(); + total_leptons++; + } + } + } + if (m_muonsHandle) { + for (const xAOD::Muon *mu : *muons) { + if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)){ + total_charge += mu->charge(); + total_leptons++; + } } } } - if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { - if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)){ - total_charge += mu->charge(); - total_leptons++; + else { + if (m_electronsTruthHandle) { + for (const xAOD::TruthParticle *el : *truthElectrons) { + if (!m_electronTruthSelection || m_electronTruthSelection.getBool(*el, sys)){ + total_charge += el->charge(); + total_leptons++; + } + } + } + if (m_muonsTruthHandle) { + for (const xAOD::TruthParticle *mu : *truthMuons) { + if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*mu, sys)){ + total_charge += mu->charge(); + total_leptons++; + } } } } diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassSelectorAlg.cxx index 3887669a99c46316f826d61f480b3ae6c71abff5..4d9f5cc5b8ee2cf4c94367b7557f6950ecbcd638 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassSelectorAlg.cxx @@ -42,11 +42,11 @@ namespace CP { continue; // retrieve the electron container - const xAOD::ElectronContainer *electrons = nullptr; + const xAOD::IParticleContainer *electrons = nullptr; if (m_electronsHandle) ANA_CHECK(m_electronsHandle.retrieve(electrons, sys)); // retrieve the electron container - const xAOD::MuonContainer *muons = nullptr; + const xAOD::IParticleContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); @@ -55,7 +55,7 @@ namespace CP { int total_leptons = 0; bool isfilled0(false), isfilled1(false); if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons) { + for (const xAOD::IParticle *el : *electrons) { if (!m_electronSelection || m_electronSelection.getBool(*el, sys)) { total_leptons++; if (!isfilled0){ @@ -71,7 +71,7 @@ namespace CP { } } if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { + for (const xAOD::IParticle *mu : *muons) { if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) { total_leptons++; if (!isfilled0){ diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassWindowSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassWindowSelectorAlg.cxx index 7c9b0bec6ccb2c339f1151313e2f52b4f97a1d56..79306c41413e084e46862df769cc78ced3c2cd9c 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassWindowSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonInvariantMassWindowSelectorAlg.cxx @@ -40,11 +40,11 @@ namespace CP { continue; // retrieve the electron container - const xAOD::ElectronContainer *electrons = nullptr; + const xAOD::IParticleContainer *electrons = nullptr; if (m_electronsHandle) ANA_CHECK(m_electronsHandle.retrieve(electrons, sys)); // retrieve the electron container - const xAOD::MuonContainer *muons = nullptr; + const xAOD::IParticleContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); @@ -53,7 +53,7 @@ namespace CP { int total_leptons = 0; bool isfilled0(false), isfilled1(false); if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons) { + for (const xAOD::IParticle *el : *electrons) { if (!m_electronSelection || m_electronSelection.getBool(*el, sys)) { total_leptons++; if (!isfilled0){ @@ -69,7 +69,7 @@ namespace CP { } } if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { + for (const xAOD::IParticle *mu : *muons) { if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) { total_leptons++; if (!isfilled0){ diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonOSSFInvariantMassWindowSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonOSSFInvariantMassWindowSelectorAlg.cxx index d03ab04fb69ea927fa818f7f75d45ba14a372088..326df2c61e008c899d9a58f4f67d1b53579f27fb 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonOSSFInvariantMassWindowSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/DileptonOSSFInvariantMassWindowSelectorAlg.cxx @@ -17,6 +17,10 @@ namespace CP { ANA_CHECK(m_electronSelection.initialize(m_systematicsList, m_electronsHandle, SG::AllowEmpty)); ANA_CHECK(m_muonsHandle.initialize(m_systematicsList, SG::AllowEmpty)); ANA_CHECK(m_muonSelection.initialize(m_systematicsList, m_muonsHandle, SG::AllowEmpty)); + ANA_CHECK(m_electronsTruthHandle.initialize(m_systematicsList, SG::AllowEmpty)); + ANA_CHECK(m_electronTruthSelection.initialize(m_systematicsList, m_electronsHandle, SG::AllowEmpty)); + ANA_CHECK(m_muonsTruthHandle.initialize(m_systematicsList, SG::AllowEmpty)); + ANA_CHECK(m_muonTruthSelection.initialize(m_systematicsList, m_muonsHandle, SG::AllowEmpty)); ANA_CHECK(m_eventInfoHandle.initialize(m_systematicsList)); ANA_CHECK(m_preselection.initialize(m_systematicsList, m_eventInfoHandle, SG::AllowEmpty)); @@ -47,42 +51,88 @@ namespace CP { const xAOD::MuonContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); + // retrieve the truth electron container + const xAOD::TruthParticleContainer *truthElectrons = nullptr; + if (m_electronsTruthHandle) + ANA_CHECK(m_electronsTruthHandle.retrieve(truthElectrons, sys)); + // retrieve the truth muon container + const xAOD::TruthParticleContainer *truthMuons = nullptr; + if (m_muonsTruthHandle) + ANA_CHECK(m_muonsTruthHandle.retrieve(truthMuons, sys)); bool decision = false; - if (electrons->size() >= 2) { - for (size_t i = 0; i < electrons->size() - 1 && !decision; ++i) { - const xAOD::Electron* firstElectron = (*electrons)[i]; - if (!m_electronSelection || m_electronSelection.getBool(*firstElectron, sys)) { - for (size_t j = i + 1; j < electrons->size() && !decision; ++j) { - const xAOD::Electron* secondElectron = (*electrons)[j]; - if (!m_electronSelection || m_electronSelection.getBool(*secondElectron, sys)) { - if (firstElectron->charge() != secondElectron->charge()){ - float mll = (firstElectron->p4() + secondElectron->p4()).M(); - decision |= (mll < m_mll_upper && mll > m_mll_lower); - } - } - } - } - } + if (m_electronsHandle || m_muonsHandle) { + if (electrons->size() >= 2) { + for (size_t i = 0; i < electrons->size() - 1 && !decision; ++i) { + const xAOD::Electron* firstElectron = (*electrons)[i]; + if (!m_electronSelection || m_electronSelection.getBool(*firstElectron, sys)) { + for (size_t j = i + 1; j < electrons->size() && !decision; ++j) { + const xAOD::Electron* secondElectron = (*electrons)[j]; + if (!m_electronSelection || m_electronSelection.getBool(*secondElectron, sys)) { + if (firstElectron->charge() != secondElectron->charge()){ + float mll = (firstElectron->p4() + secondElectron->p4()).M(); + decision |= (mll < m_mll_upper && mll > m_mll_lower); + } + } + } + } + } + } + + // If a pair of electrons satisfies the mass requirements, there is no need to loop over muon pairs. The event is either kept or vetoed hereafter. + if (!decision && muons->size() >= 2) { + for (size_t i = 0; i < muons->size() - 1 && !decision; ++i) { + const xAOD::Muon* firstMuon = (*muons)[i]; + if (!m_muonSelection || m_muonSelection.getBool(*firstMuon, sys)) { + for (size_t j = i + 1; j < muons->size() && !decision; ++j) { + const xAOD::Muon* secondMuon = (*muons)[j]; + if (!m_muonSelection || m_muonSelection.getBool(*secondMuon, sys)) { + if (firstMuon->charge() != secondMuon->charge()){ + float mll = (firstMuon->p4() + secondMuon->p4()).M(); + decision |= (mll < m_mll_upper && mll > m_mll_lower); + } + } + } + } + } + } } + else { + if (truthElectrons->size() >= 2) { + for (size_t i = 0; i < truthElectrons->size() - 1 && !decision; ++i) { + const xAOD::TruthParticle* firstElectron = (*truthElectrons)[i]; + if (!m_electronTruthSelection || m_electronTruthSelection.getBool(*firstElectron, sys)) { + for (size_t j = i + 1; j < truthElectrons->size() && !decision; ++j) { + const xAOD::TruthParticle* secondElectron = (*truthElectrons)[j]; + if (!m_electronTruthSelection || m_electronTruthSelection.getBool(*secondElectron, sys)) { + if (firstElectron->charge() != secondElectron->charge()){ + float mll = (firstElectron->p4() + secondElectron->p4()).M(); + decision |= (mll < m_mll_upper && mll > m_mll_lower); + } + } + } + } + } + } - // If a pair of electrons satisfies the mass requirements, there is no need to loop over muon pairs. The event is either kept or vetoed hereafter. - if (!decision && muons->size() >= 2) { - for (size_t i = 0; i < muons->size() - 1 && !decision; ++i) { - const xAOD::Muon* firstMuon = (*muons)[i]; - if (!m_muonSelection || m_muonSelection.getBool(*firstMuon, sys)) { - for (size_t j = i + 1; j < muons->size() && !decision; ++j) { - const xAOD::Muon* secondMuon = (*muons)[j]; - if (!m_muonSelection || m_muonSelection.getBool(*secondMuon, sys)) { - if (firstMuon->charge() != secondMuon->charge()){ - float mll = (firstMuon->p4() + secondMuon->p4()).M(); - decision |= (mll < m_mll_upper && mll > m_mll_lower); - } - } - } - } - } + // If a pair of electrons satisfies the mass requirements, there is no need to loop over muon pairs. The event is either kept or vetoed hereafter. + if (!decision && truthMuons->size() >= 2) { + for (size_t i = 0; i < truthMuons->size() - 1 && !decision; ++i) { + const xAOD::TruthParticle* firstMuon = (*truthMuons)[i]; + if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*firstMuon, sys)) { + for (size_t j = i + 1; j < truthMuons->size() && !decision; ++j) { + const xAOD::TruthParticle* secondMuon = (*truthMuons)[j]; + if (!m_muonTruthSelection || m_muonTruthSelection.getBool(*secondMuon, sys)) { + if (firstMuon->charge() != secondMuon->charge()){ + float mll = (firstMuon->p4() + secondMuon->p4()).M(); + decision |= (mll < m_mll_upper && mll > m_mll_lower); + } + } + } + } + } + } } if (m_veto) decision = !decision; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETPlusTransverseMassSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETPlusTransverseMassSelectorAlg.cxx index ea7c6f3401dd55d2c3b2034a3a281c595014ba7a..c54ac1f9b0a8e652fe79beb65eb06236ebb671b3 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETPlusTransverseMassSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETPlusTransverseMassSelectorAlg.cxx @@ -46,22 +46,22 @@ namespace CP { const xAOD::MissingETContainer *met = nullptr; ANA_CHECK(m_metHandle.retrieve(met, sys)); // retrieve the electron container - const xAOD::ElectronContainer *electrons = nullptr; + const xAOD::IParticleContainer *electrons = nullptr; if (m_electronsHandle) ANA_CHECK(m_electronsHandle.retrieve(electrons, sys)); // retrieve the electron container - const xAOD::MuonContainer *muons = nullptr; + const xAOD::IParticleContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); // compute the W boson transverse mass - float etmiss_pt = (*met)["Final"]->met(); - float etmiss_phi = (*met)["Final"]->phi(); + float etmiss_pt = (*met)[m_metTerm.value()]->met(); + float etmiss_phi = (*met)[m_metTerm.value()]->phi(); float lep_pt, lep_phi; int lep_count = 0; if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons) { + for (const xAOD::IParticle *el : *electrons) { if (!m_electronSelection || m_electronSelection.getBool(*el, sys)){ lep_pt = el->pt(); lep_phi = el->phi(); @@ -71,7 +71,7 @@ namespace CP { } } if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { + for (const xAOD::IParticle *mu : *muons) { if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) { lep_pt = mu->pt(); lep_phi = mu->phi(); diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETSelectorAlg.cxx index 7039c8107cc04b5fa32fbded03f7b99d5dead22c..40ac8965b5bbda9c364ff2fadd1a8c3048fe6692 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/MissingETSelectorAlg.cxx @@ -43,7 +43,7 @@ namespace CP { ANA_CHECK(m_metHandle.retrieve(met, sys)); // calculate decision - float etmiss = (*met)["Final"]->met(); + float etmiss = (*met)[m_metTerm.value()]->met(); bool decision = SignEnum::checkValue(m_metref.value(), m_signEnum, etmiss); m_decoration.setBool(*evtInfo, decision, sys); } diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/NLargeRJetMassWindowSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/NLargeRJetMassWindowSelectorAlg.cxx index 676063c6a2dc876a293a2c8b40f73bbe7661797f..c91ea04dd0d03c7a6e8c51534b181fc20b26eb6f 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/NLargeRJetMassWindowSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/NLargeRJetMassWindowSelectorAlg.cxx @@ -40,12 +40,12 @@ namespace CP { continue; // retrieve the large-R jet container - const xAOD::JetContainer *ljets = nullptr; + const xAOD::IParticleContainer *ljets = nullptr; ANA_CHECK(m_ljetsHandle.retrieve(ljets, sys)); // apply selection and calculate the jet-wise decision int count = 0; - for (const xAOD::Jet *lj : *ljets) { + for (const xAOD::IParticle *lj : *ljets) { if (!m_ljetSelection || m_ljetSelection.getBool(*lj, sys)) { double mass = lj->m(); bool in_range = ( mass > m_mlower && mass < m_mupper ); diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/SumNElNMuPtSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/SumNElNMuPtSelectorAlg.cxx index e08c6c7a80ded83a356d44dcc9a97e8772884b42..76a2f4a905bc05613f566e414883f8001481c7d2 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/SumNElNMuPtSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/SumNElNMuPtSelectorAlg.cxx @@ -42,18 +42,18 @@ namespace CP { continue; // retrieve the electron container - const xAOD::ElectronContainer *electrons = nullptr; + const xAOD::IParticleContainer *electrons = nullptr; if (m_electronsHandle) ANA_CHECK(m_electronsHandle.retrieve(electrons, sys)); // retrieve the electron container - const xAOD::MuonContainer *muons = nullptr; + const xAOD::IParticleContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); // apply the requested selection int count = 0; if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons){ + for (const xAOD::IParticle *el : *electrons){ if (!m_electronSelection || m_electronSelection.getBool(*el, sys)) { if (el->pt() > m_elptmin){ count++; @@ -62,7 +62,7 @@ namespace CP { } } if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { + for (const xAOD::IParticle *mu : *muons) { if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) { if (mu->pt() > m_muptmin){ count++; diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/TransverseMassSelectorAlg.cxx b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/TransverseMassSelectorAlg.cxx index 18b5666561703f1150dcfcef03c122358ad12c32..0fab6e01751283c415c33828392cd476a7ab7bfe 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/TransverseMassSelectorAlg.cxx +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/Root/TransverseMassSelectorAlg.cxx @@ -46,22 +46,22 @@ namespace CP { const xAOD::MissingETContainer *met = nullptr; ANA_CHECK(m_metHandle.retrieve(met, sys)); // retrieve the electron container - const xAOD::ElectronContainer *electrons = nullptr; + const xAOD::IParticleContainer *electrons = nullptr; if (m_electronsHandle) ANA_CHECK(m_electronsHandle.retrieve(electrons, sys)); // retrieve the electron container - const xAOD::MuonContainer *muons = nullptr; + const xAOD::IParticleContainer *muons = nullptr; if (m_muonsHandle) ANA_CHECK(m_muonsHandle.retrieve(muons, sys)); // apply the requested selection, compute the W boson transverse mass - float etmiss_pt = (*met)["Final"]->met(); - float etmiss_phi = (*met)["Final"]->phi(); + float etmiss_pt = (*met)[m_metTerm.value()]->met(); + float etmiss_phi = (*met)[m_metTerm.value()]->phi(); float lep_pt, lep_phi; int lep_count = 0; if (m_electronsHandle) { - for (const xAOD::Electron *el : *electrons) { + for (const xAOD::IParticle *el : *electrons) { if (!m_electronSelection || m_electronSelection.getBool(*el, sys)){ lep_pt = el->pt(); lep_phi = el->phi(); @@ -71,7 +71,7 @@ namespace CP { } } if (m_muonsHandle) { - for (const xAOD::Muon *mu : *muons) { + for (const xAOD::IParticle *mu : *muons) { if (!m_muonSelection || m_muonSelection.getBool(*mu, sys)) { lep_pt = mu->pt(); lep_phi = mu->phi(); diff --git a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/python/EventSelectionConfig.py b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/python/EventSelectionConfig.py index 06b29e4264e111d066e3056aee22ba3531ae2728..59c962759660b757babf1a5e8028c366282cd1cb 100644 --- a/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/python/EventSelectionConfig.py +++ b/PhysicsAnalysis/Algorithms/EventSelectionAlgorithms/python/EventSelectionConfig.py @@ -32,6 +32,7 @@ class EventSelectionConfig(ConfigBlock): self.addOption('photons', "", type=str) self.addOption('taus', "", type=str) self.addOption('met', "", type=str) + self.addOption('metTerm', "Final", type=str) self.addOption('btagDecoration', "", type=str) self.addOption('preselection', "", type=str) self.addOption('selectionCuts', "", type=str, noneAction='error') @@ -482,6 +483,7 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_MET_{self.step}' alg = config.createAlgorithm('CP::MissingETSelectorAlg', thisalg) alg.met = config.readName(self.met) + alg.metTerm = self.metTerm alg.sign = self.check_sign(items[1]) alg.refMET = self.check_float(items[2]) alg.eventPreselection = f'{self.currentDecoration}' @@ -499,6 +501,7 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_MWT_{self.step}' alg = config.createAlgorithm('CP::TransverseMassSelectorAlg', thisalg) alg.met = config.readName(self.met) + alg.metTerm = self.metTerm alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) alg.sign = self.check_sign(items[1]) @@ -520,6 +523,7 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_METMWT_{self.step}' alg = config.createAlgorithm('CP::MissingETPlusTransverseMassSelectorAlg', thisalg) alg.met = config.readName(self.met) + alg.metTerm = self.metTerm alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) alg.sign = self.check_sign(items[1]) @@ -578,9 +582,15 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_OS_{self.step}' alg = config.createAlgorithm('CP::ChargeSelectorAlg', thisalg) if self.electrons: - alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) + if "Particle" or "Truth" in self.electrons: + alg.truthElectrons, alg.truthElectronSelection = config.readNameAndSelection(self.electrons) + else: + alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) if self.muons: - alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) + if "Particle" or "Truth" in self.electrons: + alg.truthMuons, alg.truthMuonSelection = config.readNameAndSelection(self.muons) + else: + alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) alg.OS = True alg.eventPreselection = f'{self.currentDecoration}' self.setDecorationName(alg, config, f'{thisalg}_%SYS%') @@ -595,9 +605,15 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_SS_{self.step}' alg = config.createAlgorithm('CP::ChargeSelectorAlg', thisalg) if self.electrons: - alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) + if "Particle" or "Truth" in self.electrons: + alg.truthElectrons, alg.truthElectronSelection = config.readNameAndSelection(self.electrons) + else: + alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) if self.muons: - alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) + if "Particle" or "Truth" in self.electrons: + alg.truthMuons, alg.truthMuonSelection = config.readNameAndSelection(self.muons) + else: + alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) alg.OS = False alg.eventPreselection = f'{self.currentDecoration}' self.setDecorationName(alg, config, f'{thisalg}_%SYS%') @@ -614,9 +630,15 @@ class EventSelectionConfig(ConfigBlock): thisalg = f'{self.name}_MLL_OSSF_{self.step}' alg = config.createAlgorithm('CP::DileptonOSSFInvariantMassWindowSelectorAlg', thisalg) if self.electrons: - alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) + if "Particle" or "Truth" in self.electrons: + alg.truthElectrons, alg.truthElectronSelection = config.readNameAndSelection(self.electrons) + else: + alg.electrons, alg.electronSelection = config.readNameAndSelection(self.electrons) if self.muons: - alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) + if "Particle" or "Truth" in self.electrons: + alg.truthMuons, alg.truthMuonSelection = config.readNameAndSelection(self.muons) + else: + alg.muons, alg.muonSelection = config.readNameAndSelection(self.muons) alg.lowMll = self.check_float(items[1]) alg.highMll = self.check_float(items[2]) alg.vetoMode = (len(items) == 4 and self.check_string(items[3]) == "veto") @@ -664,7 +686,7 @@ def makeEventSelectionConfig(seq, name, electrons=None, muons=None, jets=None, largeRjets=None, - photons=None, taus=None, met=None, + photons=None, taus=None, met=None, metTerm=None, btagDecoration=None, preselection=None, selectionCuts=None, noFilter=None, debugMode=None, cutFlowHistograms=None): @@ -679,6 +701,7 @@ def makeEventSelectionConfig(seq, photons -- the photon container and selection taus -- the tau-jet container and selection met -- the MET container + metTerm -- the MET term to use (e.g. 'Final', 'NonInt') btagDecoration -- the b-tagging decoration to use when defining b-jets preselection -- optional event-wise selection flag to start from selectionCuts -- a string listing one selection cut per line @@ -695,6 +718,7 @@ def makeEventSelectionConfig(seq, config.setOptionValue ('photons', photons) config.setOptionValue ('taus', taus) config.setOptionValue ('met', met) + config.setOptionValue ('metTerm', metTerm) config.setOptionValue ('btagDecoration', btagDecoration) config.setOptionValue ('preselection', preselection) config.setOptionValue ('selectionCuts', selectionCuts) @@ -710,7 +734,7 @@ def makeEventSelectionConfig(seq, def makeMultipleEventSelectionConfigs(seq, electrons=None, muons=None, jets=None, largeRjets=None, - photons=None, taus=None, met=None, + photons=None, taus=None, met=None, metTerm=None, btagDecoration=None, preselection=None, selectionCutsDict=None, noFilter=None, debugMode=None, cutFlowHistograms=None): @@ -724,6 +748,7 @@ def makeMultipleEventSelectionConfigs(seq, photons -- the photon container and selection taus -- the tau-jet container and selection met -- the MET container + metTerm -- the MET term to use (e.g. 'Final', 'NonInt') btagDecoration -- the b-tagging decoration to use when defining b-jets preselection -- optional event-wise selection flag to start from selectionCutsDict -- a dictionary with key the name of the selection and value a string listing one selection cut per line @@ -735,13 +760,13 @@ def makeMultipleEventSelectionConfigs(seq, # handle the case where a user is only providing one selection if len(list(selectionCutsDict.keys())) == 1: name, selectionCuts = list(selectionCutsDict.items())[0] - makeEventSelectionConfig(seq, name, electrons, muons, jets, largeRjets, photons, taus, met, btagDecoration, preselection, selectionCuts, noFilter=noFilter, debugMode=debugMode, cutFlowHistograms=cutFlowHistograms) + makeEventSelectionConfig(seq, name, electrons, muons, jets, largeRjets, photons, taus, met, metTerm, btagDecoration, preselection, selectionCuts, noFilter=noFilter, debugMode=debugMode, cutFlowHistograms=cutFlowHistograms) return # first, we generate all the individual event selections # !!! it's important to pass noFilter=True, to avoid applying the individual filters in series for name, selectionCuts in selectionCutsDict.items(): - makeEventSelectionConfig(seq, name, electrons, muons, jets, largeRjets, photons, taus, met, btagDecoration, preselection, selectionCuts, noFilter=True, debugMode=debugMode, cutFlowHistograms=cutFlowHistograms) + makeEventSelectionConfig(seq, name, electrons, muons, jets, largeRjets, photons, taus, met, metTerm, btagDecoration, preselection, selectionCuts, noFilter=True, debugMode=debugMode, cutFlowHistograms=cutFlowHistograms) # now we are ready to collect all the filters and apply their logical OR # !!! subregions (name starts with "SUB") are not used in the final filtering