diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/OverlapRemovalAlg.h b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/OverlapRemovalAlg.h index 25674fc10ea42059e8bc1f61267ccf455ebf53c3..6daaec880a58b67c90509a71e16043ba2c14c2d1 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/OverlapRemovalAlg.h +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/AsgAnalysisAlgorithms/OverlapRemovalAlg.h @@ -45,17 +45,17 @@ namespace CP SysListHandle m_systematicsList {this}; private: - SysCopyHandle<xAOD::ElectronContainer> m_electronsHandle { + SysCopyHandle<const xAOD::ElectronContainer> m_electronsHandle { this, "electrons", "", "the electrons container to use"}; - SysCopyHandle<xAOD::MuonContainer> m_muonsHandle { + SysCopyHandle<const xAOD::MuonContainer> m_muonsHandle { this, "muons", "", "the muons container to use"}; - SysCopyHandle<xAOD::JetContainer> m_jetsHandle { + SysCopyHandle<const xAOD::JetContainer> m_jetsHandle { this, "jets", "", "the jets container to use"}; - SysCopyHandle<xAOD::TauJetContainer> m_tausHandle { + SysCopyHandle<const xAOD::TauJetContainer> m_tausHandle { this, "taus", "", "the taus container to use"}; - SysCopyHandle<xAOD::PhotonContainer> m_photonsHandle { + SysCopyHandle<const xAOD::PhotonContainer> m_photonsHandle { this, "photons", "", "the photons container to use"}; - SysCopyHandle<xAOD::JetContainer> m_fatJetsHandle { + SysCopyHandle<const xAOD::JetContainer> m_fatJetsHandle { this, "fatJets", "", "the fat jets container to use"}; /// \brief the decoration for the overlap removal status diff --git a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/OverlapRemovalAlg.cxx b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/OverlapRemovalAlg.cxx index 8c19d32ea05becfa8a6f7cf8943c67267ebebf16..966170ed16e23bd2364c5d68f379e0dde2fcee46 100644 --- a/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/OverlapRemovalAlg.cxx +++ b/PhysicsAnalysis/Algorithms/AsgAnalysisAlgorithms/Root/OverlapRemovalAlg.cxx @@ -65,42 +65,42 @@ namespace CP { std::unordered_map<const xAOD::IParticleContainer *, const SysWriteSelectionHandle *> decorationsMap; - xAOD::ElectronContainer *electrons {nullptr}; + const xAOD::ElectronContainer *electrons {nullptr}; if (m_electronsHandle) { ANA_CHECK (m_electronsHandle.getCopy (electrons, sys)); if (m_electronsSelectionHandle) decorationsMap.emplace(electrons, &m_electronsSelectionHandle); } - xAOD::MuonContainer *muons {nullptr}; + const xAOD::MuonContainer *muons {nullptr}; if (m_muonsHandle) { ANA_CHECK (m_muonsHandle.getCopy (muons, sys)); if (m_muonsSelectionHandle) decorationsMap.emplace(muons, &m_muonsSelectionHandle); } - xAOD::JetContainer *jets {nullptr}; + const xAOD::JetContainer *jets {nullptr}; if (m_jetsHandle) { ANA_CHECK (m_jetsHandle.getCopy (jets, sys)); if (m_jetsSelectionHandle) decorationsMap.emplace(jets, &m_jetsSelectionHandle); } - xAOD::TauJetContainer *taus {nullptr}; + const xAOD::TauJetContainer *taus {nullptr}; if (m_tausHandle) { ANA_CHECK (m_tausHandle.getCopy (taus, sys)); if (m_tausSelectionHandle) decorationsMap.emplace(taus, &m_tausSelectionHandle); } - xAOD::PhotonContainer *photons {nullptr}; + const xAOD::PhotonContainer *photons {nullptr}; if (m_photonsHandle) { ANA_CHECK (m_photonsHandle.getCopy (photons, sys)); if (m_photonsSelectionHandle) decorationsMap.emplace(photons, &m_photonsSelectionHandle); } - xAOD::JetContainer *fatJets {nullptr}; + const xAOD::JetContainer *fatJets {nullptr}; if (m_fatJetsHandle) { ANA_CHECK (m_fatJetsHandle.getCopy (fatJets, sys)); diff --git a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetDecoratorAlg.h b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetDecoratorAlg.h index d5f0cd1a11b02f8a137abc36ac0432a8d67bc9ed..1803b0042614259eb8fc194f688512b5643e777d 100644 --- a/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetDecoratorAlg.h +++ b/PhysicsAnalysis/Algorithms/JetAnalysisAlgorithms/JetAnalysisAlgorithms/JetDecoratorAlg.h @@ -42,7 +42,7 @@ namespace CP /// \brief the jet collection we run on private: - SysCopyHandle<xAOD::JetContainer> m_jetHandle { + SysCopyHandle<const xAOD::JetContainer> m_jetHandle { this, "jets", "", "the jet collection to run on"}; }; diff --git a/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.h b/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.h index f480fcfed01a718bedfa735285dabbdfe39025a9..6d04d24bcbca6dc088456ce166e3d92071b9f000 100644 --- a/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.h +++ b/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.h @@ -91,12 +91,6 @@ namespace CP const CP::SystematicSet& sys) const; - /// \brief const retrieve the object for the given name - public: - ::StatusCode getCopy (const T*& object, - const CP::SystematicSet& sys) const; - - // // inherited interface diff --git a/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.icc b/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.icc index ea133f4ac314b6d787dde31bf20f4f930572ee39..088fa80f85a17f0262c802bd645c4607304eb0bf 100644 --- a/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.icc +++ b/PhysicsAnalysis/Algorithms/SystematicsHandles/SystematicsHandles/SysCopyHandle.icc @@ -100,6 +100,7 @@ namespace CP if (std::get<1>(cache->second).empty()) { // if no output name is configured, act like an update handle + // (or read handle if const qualified) return m_evtStore->retrieve (object, std::get<0>(cache->second)); } else { @@ -111,43 +112,12 @@ namespace CP if (m_evtStore->retrieve (inputObject, std::get<0>(cache->second)).isFailure()) return StatusCode::FAILURE; - return detail::ShallowCopy<T>::getCopy - (msg(), *m_evtStore, object, inputObject, - std::get<1>(cache->second), std::get<2>(cache->second)); - } - } - - template<typename T> ::StatusCode SysCopyHandle<T> :: - getCopy (const T*& object, const CP::SystematicSet& sys) const - { - auto cache = m_nameCache.find (sys); - if (cache == m_nameCache.end()) - { - if (m_nameCache.empty()) - throw std::logic_error ("uninitialized SysCopyHandle (" + m_inputName + ")"); - else - throw std::logic_error ("unsupported systematic in SysCopyHandle (" + m_inputName + "): (" + sys.name() + ")"); - } - assert (m_evtStore); - if (std::get<1>(cache->second).empty()) - { - // if no output name is configured, act like an update handle - return m_evtStore->retrieve (object, std::get<0>(cache->second)); - } else - { - // if an output name is configured, retrieve the input object as - // a const object, (shallow) copy it, record the copy and return - // it. - - const T *inputObject = nullptr; - if (m_evtStore->retrieve (inputObject, std::get<0>(cache->second)).isFailure()) - return StatusCode::FAILURE; - - T *tmpObject = nullptr; - - if (detail::ShallowCopy<T>::getCopy - (msg(), *m_evtStore, tmpObject, inputObject, - std::get<1>(cache->second), std::get<2>(cache->second)).isFailure()) + // using an intermediate, since in the const version we can't + // pass in our argument pointer + std::remove_const_t<T> *tmpObject = nullptr; + if (detail::ShallowCopy<std::remove_const_t<T>>::getCopy + (msg(), *m_evtStore, tmpObject, inputObject, + std::get<1>(cache->second), std::get<2>(cache->second)).isFailure()) return StatusCode::FAILURE; object = tmpObject; return StatusCode::SUCCESS;