diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.cxx index 30f356c303090da549202565c457f3f534fa1e12..f0393252ceb18c146740d14ee782a9ab4c721e45 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.cxx +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingAuxContainerCnv.cxx 566967 2013-10-24 13:24:31Z krasznaa $ @@ -15,48 +15,25 @@ #include "xAODTracking/TrackParticleContainer.h" #include "AthContainers/tools/copyThinned.h" -#include "AthenaKernel/IThinningSvc.h" -xAODBTagVertexAuxContainerCnv::xAODBTagVertexAuxContainerCnv( ISvcLocator* svcLoc ) - : xAODBTagVertexAuxContainerCnvBase( svcLoc ) { +#define LOAD_DICTIONARY( name ) do { TClass* cl = TClass::GetClass( name ); \ + if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { ATH_MSG_ERROR( "Couldn't load dictionary for type: " << name ); } } while(0) -} xAOD::BTagVertexAuxContainer* xAODBTagVertexAuxContainerCnv:: -createPersistent( xAOD::BTagVertexAuxContainer* trans ) { - - static const char* trackParticleType = - "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >"; - static bool dictLoaded = false; - if( ! dictLoaded ) { - TClass* cl = TClass::GetClass( trackParticleType ); - if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { - ATH_MSG_ERROR( "Couldn't load the dictionary for \"" - << trackParticleType << "\"" ); - } else { - dictLoaded = true; - } - } +createPersistentWithKey( xAOD::BTagVertexAuxContainer* trans, + const std::string& key) +{ + // ??? Still needed? + std::once_flag flag; + std::call_once (flag, + [this] { + LOAD_DICTIONARY( "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >" ); + }); // Create a copy of the container: - return SG::copyThinned (*trans, IThinningSvc::instance()); + return xAODBTagVertexAuxContainerCnvBase::createPersistentWithKey (trans, key); } -xAOD::BTagVertexAuxContainer* xAODBTagVertexAuxContainerCnv::createTransient() { - - // The known ID(s) for this container: - const pool::Guid v1_guid( "09CD44BA-0F40-4FDB-BB30-2F4226FF3E18" ); - - // Check which version of the container we're reading: - if( compareClassGuid( v1_guid ) ) { - // It's the latest version, read it directly: - return poolReadObject< xAOD::BTagVertexAuxContainer >(); - } - - // If we didn't recognise the ID: - throw std::runtime_error( "Unsupported version of " - "xAOD::BTagVertexAuxContainer found" ); - return 0; -} diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.h index 454f3f9657780f54387eade463a5d11d39be9083..a978f4f1b1f389150864e8b06916567f72850a9e 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.h +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexAuxContainerCnv.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingAuxContainerCnv.h 566967 2013-10-24 13:24:31Z krasznaa $ @@ -9,14 +9,13 @@ #define XAODBTAGGINGATHENAPOOL_XAODBTAGVERTEXAUXCONTAINERCNV_H // Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" // EDM include(s): #include "xAODBTagging/BTagVertexAuxContainer.h" /// Base class for the converter -typedef T_AthenaPoolCustomCnv< xAOD::BTagVertexAuxContainer, - xAOD::BTagVertexAuxContainer > +typedef T_AthenaPoolAuxContainerCnv< xAOD::BTagVertexAuxContainer > xAODBTagVertexAuxContainerCnvBase; /** @@ -34,19 +33,17 @@ typedef T_AthenaPoolCustomCnv< xAOD::BTagVertexAuxContainer, * $Date: 2013-10-24 15:24:31 +0200 (Thu, 24 Oct 2013) $ */ class xAODBTagVertexAuxContainerCnv : - public xAODBTagVertexAuxContainerCnvBase { - + public xAODBTagVertexAuxContainerCnvBase +{ public: - /// Converter constructor - xAODBTagVertexAuxContainerCnv( ISvcLocator* svcLoc ); + using xAODBTagVertexAuxContainerCnvBase::xAODBTagVertexAuxContainerCnvBase; + -protected: /// Function preparing the container to be written out virtual xAOD::BTagVertexAuxContainer* - createPersistent( xAOD::BTagVertexAuxContainer* trans ); - /// Function reading in the object from the input file - virtual xAOD::BTagVertexAuxContainer* createTransient(); - + createPersistentWithKey( xAOD::BTagVertexAuxContainer* trans, + const std::string& key ) override; }; // class xAODBTaggingAuxContainerCnv + #endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGAUXCONTAINERCNV_H diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.cxx deleted file mode 100644 index d1c799150eec8dbbdf2610d759a55dd5e3fe4fd9..0000000000000000000000000000000000000000 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: xAODBTagVertexContainerCnv.cxx 581167 2014-02-03 10:45:56Z $ - -// System include(s): -#include <exception> - -// Local include(s): -#include "xAODBTagVertexContainerCnv.h" - -namespace { - - /// Helper function setting up the container's link to its auxiliary store - void setStoreLink( SG::AuxVectorBase* cont, const std::string& key ) { - - // The link to set up: - DataLink< SG::IConstAuxStore > link( key + "Aux." ); - - // Give it to the container: - cont->setStore( link ); - - return; - } - -} // private namespace - -xAODBTagVertexContainerCnv::xAODBTagVertexContainerCnv( ISvcLocator* svcLoc ) - : xAODBTagVertexContainerCnvBase( svcLoc ) { - -} - -/** - * This function needs to be re-implemented in order to figure out the StoreGate - * key of the container that's being created. After that's done, it lets the - * base class do its normal task. - */ -StatusCode xAODBTagVertexContainerCnv::createObj( IOpaqueAddress* pAddr, - DataObject*& pObj ) { - - // Get the key of the container that we'll be creating: - m_key = *( pAddr->par() + 1 ); - ATH_MSG_VERBOSE( "Key of xAOD::BTagVertexContainer: " << m_key ); - - // Let the base class do its thing now: - return AthenaPoolConverter::createObj( pAddr, pObj ); -} - -xAOD::BTagVertexContainer* -xAODBTagVertexContainerCnv::createPersistent( xAOD::BTagVertexContainer* trans ) { - - // Create a view copy of the container: - xAOD::BTagVertexContainer* result = - new xAOD::BTagVertexContainer( trans->begin(), trans->end(), - SG::VIEW_ELEMENTS ); - - // Prepare the objects to be written out: - xAOD::BTagVertexContainer::iterator itr = result->begin(); - xAOD::BTagVertexContainer::iterator end = result->end(); - for( ; itr != end; ++itr ) { - toPersistent( *itr ); - } - - // Return the new container: - return result; -} - -xAOD::BTagVertexContainer* xAODBTagVertexContainerCnv::createTransient() { - - // The known ID(s) for this container: - const pool::Guid v1_guid( "E225A9EC-9782-43F7-B7BF-1B215187C11C" ); - - // Check if we're reading the most up to date type: - if( compareClassGuid( v1_guid ) ) { - xAOD::BTagVertexContainer* c = poolReadObject< xAOD::BTagVertexContainer >(); - setStoreLink( c, m_key ); - return c; - } - - // If we didn't recognise the ID, let's complain: - throw std::runtime_error( "Unsupported version of " - "xAOD::BTagVertexContainer found" ); - return 0; -} - -void xAODBTagVertexContainerCnv::toPersistent( xAOD::BTagVertex* BTagVertex ) const { - - // Tell the object to prepare all its smart pointers for persistification: - BTagVertex->toPersistent(); - - return; -} diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.h deleted file mode 100644 index 4675136e8e6c0727bd021132aa10e7487dde7e1c..0000000000000000000000000000000000000000 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTagVertexContainerCnv.h +++ /dev/null @@ -1,62 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: xAODJetContainerCnv.h 581167 2014-02-03 10:45:56Z krasznaa $ -#ifndef XAODBTAGGINGATHENAPOOL_XAODBTAGVERTEXCONTAINERCNV_H -#define XAODBTAGGINGATHENAPOOL_XAODBTAGVERTEXCONTAINERCNV_H - -// System include(s): -#include <string> - -// Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" - -// EDM include(s): -#include "xAODBTagging/BTagVertexContainer.h" - -/// Type definition for the converter's base -typedef T_AthenaPoolCustomCnv< xAOD::BTagVertexContainer, - xAOD::BTagVertexContainer > - xAODBTagVertexContainerCnvBase; - -/** - * @short POOL converter for the xAOD::BTaggingContainer class - * - * Simple converter class making the xAOD::BTaggingContainer - * class known to POOL. - * - * @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - * - * $Revision: 581167 $ - * $Date: 2014-02-03 11:45:56 +0100 (Mon, 03 Feb 2014) $ - */ -class xAODBTagVertexContainerCnv : public xAODBTagVertexContainerCnvBase { - - // Declare the factory as our friend: - friend class CnvFactory< xAODBTagVertexContainerCnv >; - -public: - /// Converter constructor - xAODBTagVertexContainerCnv( ISvcLocator* svcLoc ); - - /// Re-implemented function in order to get access to the SG key - virtual StatusCode createObj( IOpaqueAddress* pAddr, DataObject*& pObj ); - - /// Function preparing the container to be written out - virtual xAOD::BTagVertexContainer* createPersistent( xAOD::BTagVertexContainer* trans ); - /// Function reading in the persistent object - virtual xAOD::BTagVertexContainer* createTransient(); - -private: - /// Function preparing a vertex object for persistence - void toPersistent( xAOD::BTagVertex* BTagVertex ) const; - - /// StoreGate key of the container just being created - std::string m_key; - -}; // class xAODBTaggingContainerCnv - -#endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGCONTAINERCNV_H diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.cxx index 4df00d2e21aa7beffb5e387b2bbc8541df7bbea3..adbe6c1a28125a5c7e4363fb4f54b7a9749b25d9 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.cxx +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingAuxContainerCnv.cxx 566967 2013-10-24 13:24:31Z krasznaa $ @@ -15,49 +15,24 @@ #include "xAODTracking/TrackParticleContainer.h" #include "AthContainers/tools/copyThinned.h" -#include "AthenaKernel/IThinningSvc.h" -xAODBTaggingAuxContainerCnv::xAODBTaggingAuxContainerCnv( ISvcLocator* svcLoc ) - : xAODBTaggingAuxContainerCnvBase( svcLoc ) { -} +#define LOAD_DICTIONARY( name ) do { TClass* cl = TClass::GetClass( name ); \ + if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { ATH_MSG_ERROR( "Couldn't load dictionary for type: " << name ); } } while(0) + xAOD::BTaggingAuxContainer* xAODBTaggingAuxContainerCnv:: -createPersistent( xAOD::BTaggingAuxContainer* trans ) { - - // Make sure that the dictionary for the Athena-only dynamic variable - // is loaded: - static const char* trackParticleType = - "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >"; - static bool dictLoaded = false; - if( ! dictLoaded ) { - TClass* cl = TClass::GetClass( trackParticleType ); - if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { - ATH_MSG_ERROR( "Couldn't load the dictionary for \"" - << trackParticleType << "\"" ); - } else { - dictLoaded = true; - } - } - +createPersistentWithKey( xAOD::BTaggingAuxContainer* trans, + const std::string& key) +{ + // ??? Still needed? + std::once_flag flag; + std::call_once (flag, + [this] { + LOAD_DICTIONARY( "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >" ); + }); + // Create a copy of the container: - return SG::copyThinned (*trans, IThinningSvc::instance()); -} - -xAOD::BTaggingAuxContainer* xAODBTaggingAuxContainerCnv::createTransient() { - - // The known ID(s) for this container: - const pool::Guid v1_guid( "5E1973D2-D860-4BB1-B8EF-C9AD8E6C66A2" ); - - // Check which version of the container we're reading: - if( compareClassGuid( v1_guid ) ) { - // It's the latest version, read it directly: - return poolReadObject< xAOD::BTaggingAuxContainer >(); - } - - // If we didn't recognise the ID: - throw std::runtime_error( "Unsupported version of " - "xAOD::BTaggingAuxContainer found" ); - return 0; + return xAODBTaggingAuxContainerCnvBase::createPersistentWithKey (trans, key); } diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.h index 8caf3be74e31f3044356fe80846669c6fb4fec9c..71c0ad8c47f5a4493e9500e5bc18ae95dab5941f 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.h +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingAuxContainerCnv.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingAuxContainerCnv.h 566967 2013-10-24 13:24:31Z krasznaa $ @@ -9,14 +9,13 @@ #define XAODBTAGGINGATHENAPOOL_XAODBTAGGINGAUXCONTAINERCNV_H // Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" // EDM include(s): #include "xAODBTagging/BTaggingAuxContainer.h" /// Base class for the converter -typedef T_AthenaPoolCustomCnv< xAOD::BTaggingAuxContainer, - xAOD::BTaggingAuxContainer > +typedef T_AthenaPoolAuxContainerCnv< xAOD::BTaggingAuxContainer > xAODBTaggingAuxContainerCnvBase; /** @@ -34,19 +33,17 @@ typedef T_AthenaPoolCustomCnv< xAOD::BTaggingAuxContainer, * $Date: 2013-10-24 15:24:31 +0200 (Thu, 24 Oct 2013) $ */ class xAODBTaggingAuxContainerCnv : - public xAODBTaggingAuxContainerCnvBase { - + public xAODBTaggingAuxContainerCnvBase +{ public: - /// Converter constructor - xAODBTaggingAuxContainerCnv( ISvcLocator* svcLoc ); + using xAODBTaggingAuxContainerCnvBase::xAODBTaggingAuxContainerCnvBase; -protected: + /// Function preparing the container to be written out virtual xAOD::BTaggingAuxContainer* - createPersistent( xAOD::BTaggingAuxContainer* trans ); - /// Function reading in the object from the input file - virtual xAOD::BTaggingAuxContainer* createTransient(); - + createPersistentWithKey( xAOD::BTaggingAuxContainer* trans, + const std::string& key ) override; }; // class xAODBTaggingAuxContainerCnv + #endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGAUXCONTAINERCNV_H diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.cxx deleted file mode 100644 index e59036151dd8ba21a1ca6f7a3c67ab84662d7b0b..0000000000000000000000000000000000000000 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: xAODBTaggingContainerCnv.cxx 581167 2014-02-03 10:45:56Z krasznaa $ - -// System include(s): -#include <exception> - -// Local include(s): -#include "xAODBTaggingContainerCnv.h" - -namespace { - - /// Helper function setting up the container's link to its auxiliary store - void setStoreLink( SG::AuxVectorBase* cont, const std::string& key ) { - - // The link to set up: - DataLink< SG::IConstAuxStore > link( key + "Aux." ); - - // Give it to the container: - cont->setStore( link ); - - return; - } - -} // private namespace - -xAODBTaggingContainerCnv::xAODBTaggingContainerCnv( ISvcLocator* svcLoc ) - : xAODBTaggingContainerCnvBase( svcLoc ) { - -} - -/** - * This function needs to be re-implemented in order to figure out the StoreGate - * key of the container that's being created. After that's done, it lets the - * base class do its normal task. - */ -StatusCode xAODBTaggingContainerCnv::createObj( IOpaqueAddress* pAddr, - DataObject*& pObj ) { - - // Get the key of the container that we'll be creating: - m_key = *( pAddr->par() + 1 ); - ATH_MSG_VERBOSE( "Key of xAOD::BTaggingContainer: " << m_key ); - - // Let the base class do its thing now: - return AthenaPoolConverter::createObj( pAddr, pObj ); -} - -xAOD::BTaggingContainer* -xAODBTaggingContainerCnv::createPersistent( xAOD::BTaggingContainer* trans ) { - - // Create a view copy of the container: - xAOD::BTaggingContainer* result = - new xAOD::BTaggingContainer( trans->begin(), trans->end(), - SG::VIEW_ELEMENTS ); - - // Prepare the objects to be written out: - xAOD::BTaggingContainer::iterator itr = result->begin(); - xAOD::BTaggingContainer::iterator end = result->end(); - for( ; itr != end; ++itr ) { - toPersistent( *itr ); - } - - // Return the new container: - return result; -} - -xAOD::BTaggingContainer* xAODBTaggingContainerCnv::createTransient() { - - // The known ID(s) for this container: - const pool::Guid v1_guid( "5D19F171-E07E-4F65-BC1F-FC4F4099E9F1" ); - - // Check if we're reading the most up to date type: - if( compareClassGuid( v1_guid ) ) { - xAOD::BTaggingContainer* c = poolReadObject< xAOD::BTaggingContainer >(); - setStoreLink( c, m_key ); - return c; - } - - // If we didn't recognise the ID, let's complain: - throw std::runtime_error( "Unsupported version of " - "xAOD::BTaggingContainer found" ); - return 0; -} - -void xAODBTaggingContainerCnv::toPersistent( xAOD::BTagging* BTagging ) const { - - // Tell the object to prepare all its smart pointers for persistification: - BTagging->toPersistent(); - - return; -} diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.h deleted file mode 100644 index 263e7fe6b924d153bb4a107b382c14c84b26d861..0000000000000000000000000000000000000000 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingContainerCnv.h +++ /dev/null @@ -1,62 +0,0 @@ -// Dear emacs, this is -*- c++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: xAODJetContainerCnv.h 581167 2014-02-03 10:45:56Z krasznaa $ -#ifndef XAODBTAGGINGATHENAPOOL_XAODBTAGGINGCONTAINERCNV_H -#define XAODBTAGGINGATHENAPOOL_XAODBTAGGINGCONTAINERCNV_H - -// System include(s): -#include <string> - -// Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" - -// EDM include(s): -#include "xAODBTagging/BTaggingContainer.h" - -/// Type definition for the converter's base -typedef T_AthenaPoolCustomCnv< xAOD::BTaggingContainer, - xAOD::BTaggingContainer > - xAODBTaggingContainerCnvBase; - -/** - * @short POOL converter for the xAOD::BTaggingContainer class - * - * Simple converter class making the xAOD::BTaggingContainer - * class known to POOL. - * - * @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> - * - * $Revision: 581167 $ - * $Date: 2014-02-03 11:45:56 +0100 (Mon, 03 Feb 2014) $ - */ -class xAODBTaggingContainerCnv : public xAODBTaggingContainerCnvBase { - - // Declare the factory as our friend: - friend class CnvFactory< xAODBTaggingContainerCnv >; - -public: - /// Converter constructor - xAODBTaggingContainerCnv( ISvcLocator* svcLoc ); - - /// Re-implemented function in order to get access to the SG key - virtual StatusCode createObj( IOpaqueAddress* pAddr, DataObject*& pObj ); - - /// Function preparing the container to be written out - virtual xAOD::BTaggingContainer* createPersistent( xAOD::BTaggingContainer* trans ); - /// Function reading in the persistent object - virtual xAOD::BTaggingContainer* createTransient(); - -private: - /// Function preparing a vertex object for persistence - void toPersistent( xAOD::BTagging* BTagging ) const; - - /// StoreGate key of the container just being created - std::string m_key; - -}; // class xAODBTaggingContainerCnv - -#endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGCONTAINERCNV_H diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.cxx index cbba92dc57bf99a17fa3b890ec149f53cd43dec6..298fe3f0b6f1d1c58a9e0d80096f153eb97be6a2 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.cxx +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingTrigAuxContainerCnv.cxx 705820 2015-11-04 14:54:05Z krasznaa $ @@ -11,7 +11,6 @@ #include <TClass.h> // Gaudi/Athena include(s): -#include "AthenaKernel/IThinningSvc.h" #include "AthContainers/tools/copyThinned.h" // EDM include(s): @@ -21,64 +20,23 @@ #include "xAODBTaggingTrigAuxContainerCnv.h" #include "xAODBTaggingTrigAuxContainerOfflineCnv_v1.h" -xAODBTaggingTrigAuxContainerCnv:: -xAODBTaggingTrigAuxContainerCnv( ISvcLocator* svcLoc ) - : xAODBTaggingTrigAuxContainerCnvBase( svcLoc ) { -} +#define LOAD_DICTIONARY( name ) do { TClass* cl = TClass::GetClass( name ); \ + if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { ATH_MSG_ERROR( "Couldn't load dictionary for type: " << name ); } } while(0) + xAOD::BTaggingTrigAuxContainer* xAODBTaggingTrigAuxContainerCnv:: -createPersistent( xAOD::BTaggingTrigAuxContainer* trans ) { - - // Make sure that the dictionary for the Athena-only dynamic variable - // is loaded: - static const char* trackParticleType = - "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >"; - static bool dictLoaded = false; - if( ! dictLoaded ) { - TClass* cl = TClass::GetClass( trackParticleType ); - if( ( ! cl ) || ( ! cl->IsLoaded() ) ) { - ATH_MSG_ERROR( "Couldn't load the dictionary for \"" - << trackParticleType << "\"" ); - } else { - dictLoaded = true; - } - } - +createPersistentWithKey( xAOD::BTaggingTrigAuxContainer* trans, + const std::string& key ) +{ + // ??? Still needed? + std::once_flag flag; + std::call_once (flag, + [this] { + LOAD_DICTIONARY( "std::vector<std::vector<ElementLink<DataVector<xAOD::TrackParticle_v1> > > >" ); + }); + // Create a copy of the container: - return SG::copyThinned (*trans, IThinningSvc::instance()); -} - -xAOD::BTaggingTrigAuxContainer* -xAODBTaggingTrigAuxContainerCnv::createTransient() { - - // The known ID(s) for this container: - const pool::Guid v1_guid( "1B738105-2F3E-4DCB-9DAE-DA3A4964486E" ); - const pool::Guid - v1_offline_guid( "5E1973D2-D860-4BB1-B8EF-C9AD8E6C66A2" ); - - // Check which version of the container we're reading: - if( compareClassGuid( v1_guid ) ) { - - // It's the latest version, read it directly: - return poolReadObject< xAOD::BTaggingTrigAuxContainer >(); - - } else if( compareClassGuid( v1_offline_guid ) ) { - - // The converter: - static xAODBTaggingTrigAuxContainerOfflineCnv_v1 converter; - - // Read in the offline v1 version: - std::unique_ptr< xAOD::BTaggingAuxContainer_v1 > - old( poolReadObject< xAOD::BTaggingAuxContainer_v1 >() ); - - // Return the converter object: - return converter.createTransient( old.get(), msg() ); - } - - // If we didn't recognise the ID: - throw std::runtime_error( "Unsupported version of " - "xAOD::BTaggingTrigAuxContainer found" ); - return 0; + return xAODBTaggingTrigAuxContainerCnvBase::createPersistentWithKey (trans, key); } diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.h index bfbc1e2ab0da51d033ffe20eaf7ceb29861d4b39..ded8e6db0c08ac576dd49c8cda2b9417cfc7cc70 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.h +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerCnv.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingTrigAuxContainerCnv.h 705820 2015-11-04 14:54:05Z krasznaa $ @@ -9,14 +9,15 @@ #define XAODBTAGGINGATHENAPOOL_XAODBTAGGINGTRIGAUXCONTAINERCNV_H // Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolCustomCnv.h" +#include "AthenaPoolCnvSvc/T_AthenaPoolAuxContainerCnv.h" // EDM include(s): #include "xAODBTagging/BTaggingTrigAuxContainer.h" +#include "xAODBTaggingTrigAuxContainerOfflineCnv_v1.h" /// Base class for the converter -typedef T_AthenaPoolCustomCnv< xAOD::BTaggingTrigAuxContainer, - xAOD::BTaggingTrigAuxContainer > +typedef T_AthenaPoolAuxContainerCnv< xAOD::BTaggingTrigAuxContainer, + xAODBTaggingTrigAuxContainerOfflineCnv_v1 > xAODBTaggingTrigAuxContainerCnvBase; /** @@ -34,23 +35,17 @@ typedef T_AthenaPoolCustomCnv< xAOD::BTaggingTrigAuxContainer, * $Date: 2015-11-04 15:54:05 +0100 (Wed, 04 Nov 2015) $ */ class xAODBTaggingTrigAuxContainerCnv : - public xAODBTaggingTrigAuxContainerCnvBase { - - // Declare the factory as our friend: - friend class CnvFactory< xAODBTaggingTrigAuxContainerCnv >; - -protected: - /// Converter constructor + public xAODBTaggingTrigAuxContainerCnvBase +{ public: - xAODBTaggingTrigAuxContainerCnv( ISvcLocator* svcLoc ); -protected: + using xAODBTaggingTrigAuxContainerCnvBase::xAODBTaggingTrigAuxContainerCnvBase; + /// Function preparing the container to be written out virtual xAOD::BTaggingTrigAuxContainer* - createPersistent( xAOD::BTaggingTrigAuxContainer* trans ); - /// Function reading in the object from the input file - virtual xAOD::BTaggingTrigAuxContainer* createTransient(); - + createPersistentWithKey( xAOD::BTaggingTrigAuxContainer* trans, + const std::string& key) override; }; // class xAODBTaggingTrigAuxContainerCnv + #endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGTRIGAUXCONTAINERCNV_H diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.cxx b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.cxx deleted file mode 100644 index fd009ff4eb13b9e8337243312d60454c639dff7f..0000000000000000000000000000000000000000 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// $Id: xAODBTaggingTrigAuxContainerOfflineCnv_v1.cxx 705820 2015-11-04 14:54:05Z krasznaa $ - -// System include(s): -#include <stdexcept> - -// Gaudi/Athena include(s): -#include "GaudiKernel/MsgStream.h" - -// Core EDM include(s): -#include "AthContainers/tools/copyAuxStoreThinned.h" - -// Local include(s): -#include "xAODBTaggingTrigAuxContainerOfflineCnv_v1.h" - -/// Convenience macro for setting the level of output messages -#define MSGLVL MSG::DEBUG - -/// Another convenience macro for printing messages in the converter -#define ATH_MSG( MSG ) \ - do { \ - if( log.level() <= MSGLVL ) { \ - log << MSGLVL << MSG << endmsg; \ - } \ - } while( 0 ) - -xAODBTaggingTrigAuxContainerOfflineCnv_v1:: -xAODBTaggingTrigAuxContainerOfflineCnv_v1() - : T_AthenaPoolTPCnvBase< xAOD::BTaggingTrigAuxContainer, - xAOD::BTaggingAuxContainer_v1 >() { - -} - -void xAODBTaggingTrigAuxContainerOfflineCnv_v1:: -persToTrans( const xAOD::BTaggingAuxContainer_v1* oldObj, - xAOD::BTaggingTrigAuxContainer* newObj, - MsgStream& log ) { - - // Greet the user: - ATH_MSG( "Converting xAOD::BTaggingAuxContainer_v1 to " - "xAOD::BTaggingTrigAuxContainer..." ); - - // Clear the transient object: - newObj->resize( 0 ); - - // Copy the payload of the v1 object into the latest one by misusing - // the thinning code a bit... - SG::copyAuxStoreThinned( *oldObj, *newObj, 0 ); - - // Print what happened: - ATH_MSG( "Converting xAOD::BTaggingAuxContainer_v1 to " - "xAOD::BTaggingTrigAuxContainer [OK]" ); - - return; -} - -/// This function should never be called, as we are not supposed to convert -/// object before writing. -/// -void xAODBTaggingTrigAuxContainerOfflineCnv_v1:: -transToPers( const xAOD::BTaggingTrigAuxContainer*, - xAOD::BTaggingAuxContainer_v1*, - MsgStream& log ) { - - log << MSG::ERROR - << "Somebody called xAODBTaggingTrigAuxContainerOfflineCnv_v1::" - << "transToPers" << endmsg; - throw std::runtime_error( "Somebody called " - "xAODBTaggingTrigAuxContainerOfflineCnv_v1::" - "transToPers" ); - - return; -} diff --git a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.h b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.h index 13b30bd8e9841fc39febbc0792f2cae3233dd24b..2235e8f5900bc27e8e174a2dbbf64c075ed8f963 100644 --- a/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.h +++ b/Event/xAOD/xAODBTaggingAthenaPool/src/xAODBTaggingTrigAuxContainerOfflineCnv_v1.h @@ -1,7 +1,7 @@ // Dear emacs, this is -*- c++ -*- /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration */ // $Id: xAODBTaggingTrigAuxContainerOfflineCnv_v1.h 705820 2015-11-04 14:54:05Z krasznaa $ @@ -9,7 +9,7 @@ #define XAODBTAGGINGATHENAPOOL_XAODBTAGGINGTRIGAUXCONTAINEROFFLINECNV_V1_H // Gaudi/Athena include(s): -#include "AthenaPoolCnvSvc/T_AthenaPoolTPConverter.h" +#include "AthenaPoolCnvSvc/T_AuxContainerCopyTPCnv.h" // EDM include(s): #include "xAODBTagging/versions/BTaggingAuxContainer_v1.h" @@ -23,28 +23,9 @@ /// objects into the trigger ones automatically, to be able to read old /// RAW files correctly. /// -/// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch> -/// -/// $Revision: 705820 $ -/// $Date: 2015-11-04 15:54:05 +0100 (Wed, 04 Nov 2015) $ -/// -class xAODBTaggingTrigAuxContainerOfflineCnv_v1 : - public T_AthenaPoolTPCnvBase< xAOD::BTaggingTrigAuxContainer, - xAOD::BTaggingAuxContainer_v1 > { - -public: - /// Default constructor - xAODBTaggingTrigAuxContainerOfflineCnv_v1(); - - /// Function converting from the old type to the current one - virtual void persToTrans( const xAOD::BTaggingAuxContainer_v1* oldObj, - xAOD::BTaggingTrigAuxContainer* newObj, - MsgStream& log ); - /// Dummy function inherited from the base class - virtual void transToPers( const xAOD::BTaggingTrigAuxContainer*, - xAOD::BTaggingAuxContainer_v1*, - MsgStream& log ); +typedef T_AuxContainerCopyTPCnv< xAOD::BTaggingTrigAuxContainer, + xAOD::BTaggingAuxContainer_v1 > + xAODBTaggingTrigAuxContainerOfflineCnv_v1; -}; // class xAODBTaggingTrigAuxContainerOfflineCnv_v1 #endif // XAODBTAGGINGATHENAPOOL_XAODBTAGGINGTRIGAUXCONTAINEROFFLINECNV_V1_H