Skip to content
Snippets Groups Projects
Commit c81fd031 authored by Attila Krasznahorkay's avatar Attila Krasznahorkay
Browse files

Made some e/gamma dynamic variable types be declared on library load.

This was necessary to work around some issues with ROOT's dictionary
handling. See merge request !33096 for more details.
parent afe62efb
No related branches found
No related tags found
No related merge requests found
...@@ -15,12 +15,50 @@ ...@@ -15,12 +15,50 @@
// ================================================================== // ==================================================================
const xAOD::Electron* xAOD::EgammaHelpers::getRecoElectron(const xAOD::TruthParticle* particle){ /// Accessor for the "recoElectronLink" dynamic variable
return getLink<xAOD::Electron>(particle, "recoElectronLink"); ///
/// It is declared outside of the @c xAOD::EgammaHelpers::getRecoElectron(...)
/// call to make sure that the auxiliary ID registry would know about this type
/// as soon as the library holding this code is loaded.
///
static const SG::AuxElement::Accessor< ElementLink< xAOD::ElectronContainer > >
recoElectronLinkAcc( "recoElectronLink" );
const xAOD::Electron*
xAOD::EgammaHelpers::getRecoElectron( const xAOD::TruthParticle* particle ) {
if( ! recoElectronLinkAcc.isAvailable( *particle ) ) {
return nullptr;
}
const ElementLink< xAOD::ElectronContainer >& link =
recoElectronLinkAcc( *particle );
if( ! link.isValid() ) {
return nullptr;
}
return *link;
} }
const xAOD::Photon* xAOD::EgammaHelpers::getRecoPhoton(const xAOD::TruthParticle* particle){ /// Accessor for the "recoPhotonLink" dynamic variable
return getLink<xAOD::Photon>(particle, "recoPhotonLink"); ///
/// It is declared outside of the @c xAOD::EgammaHelpers::getRecoPhoton(...)
/// call to make sure that the auxiliary ID registry would know about this type
/// as soon as the library holding this code is loaded.
///
static const SG::AuxElement::Accessor< ElementLink< xAOD::PhotonContainer > >
recoPhotonLinkAcc( "recoPhotonLink" );
const xAOD::Photon*
xAOD::EgammaHelpers::getRecoPhoton( const xAOD::TruthParticle* particle ) {
if( ! recoPhotonLinkAcc.isAvailable( *particle ) ) {
return nullptr;
}
const ElementLink< xAOD::PhotonContainer >& link =
recoPhotonLinkAcc( *particle );
if( ! link.isValid() ) {
return nullptr;
}
return *link;
} }
// ================================================================== // ==================================================================
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/ */
// $Id: Egamma_v1$
// EDM include(s): // EDM include(s):
#include "xAODCore/AuxStoreAccessorMacros.h" #include "xAODCore/AuxStoreAccessorMacros.h"
// Local include(s): // Local include(s):
...@@ -183,13 +181,26 @@ void Egamma_v1::setAuthor(uint16_t newAuthor) { ...@@ -183,13 +181,26 @@ void Egamma_v1::setAuthor(uint16_t newAuthor) {
acc(*this) = newAuthor; acc(*this) = newAuthor;
} }
/// Accessor for the "ambiguityLink" dynamic variable
///
/// It is declared outside of the @c xAOD::Egamma_v1::ambiguousObject() call to
/// make sure that the auxiliary ID registry would know about this type as soon
/// as the library holding this code is loaded.
///
static const SG::AuxElement::Accessor< ElementLink< xAOD::EgammaContainer > >
ambiguityLinkAcc( "ambiguityLink" );
/// ambiguous /// ambiguous
const Egamma_v1* Egamma_v1::ambiguousObject() const{ const Egamma_v1* Egamma_v1::ambiguousObject() const {
static const SG::AuxElement::Accessor<ElementLink<xAOD::EgammaContainer> > acc("ambiguityLink");
if(acc.isAvailable(*this) && acc(*this).isValid()){ if( ! ambiguityLinkAcc.isAvailable( *this ) ) {
return (*acc(*this)); return nullptr;
} }
return nullptr; const ElementLink< xAOD::EgammaContainer >& link = ambiguityLinkAcc( *this );
if( ! link.isValid() ) {
return nullptr;
}
return *link;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment