Commit 115629ba authored by Tadej Novak's avatar Tadej Novak
Browse files

Merge branch 'const_copy' into 'master'

change handling of const pointers in SysCopyHandle, const-retrieve in OverlapRemovalAlg

See merge request atlas/athena!59007
parents e823350c 7681d5af
......@@ -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
......
......@@ -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));
......
......@@ -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"};
};
......
......@@ -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
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment