Skip to content
Snippets Groups Projects
Commit 850d1686 authored by Gerhard Raven's avatar Gerhard Raven
Browse files

Make ICloner interface 'const'

- and update implementation
parent 670e8a00
No related branches found
No related tags found
2 merge requests!3788Draft: Update SciFi cluster monitoring,!3619MicroDST: Cleanup remnants of the old cloning code
......@@ -59,10 +59,7 @@ public:
typename Cloner::Type* cloneKeyedContainerItem( const typename Cloner::Type* item ) const;
template <class T>
const T* getStoredClone( const KeyedObject<int>* original ) const;
template <class T>
T* getStoredClone( const KeyedObject<int>* original );
T* getStoredClone( const KeyedObject<int>* original ) const;
/**
* Get the TES container in the TES location to be stored on the
......@@ -271,15 +268,7 @@ MicroDSTCommon<PBASE>::cloneKeyedContainerItem( const typename itemCloner::Type*
template <class PBASE>
template <class T>
const T* MicroDSTCommon<PBASE>::getStoredClone( const KeyedObject<int>* original ) const {
return getStoredClone<T>( original );
}
//=============================================================================
template <class PBASE>
template <class T>
T* MicroDSTCommon<PBASE>::getStoredClone( const KeyedObject<int>* original ) {
T* MicroDSTCommon<PBASE>::getStoredClone( const KeyedObject<int>* original ) const {
if ( !original || !original->parent() ) return nullptr;
const auto cloneLocation = outputTESLocation( MicroDST::objectLocation( original->parent() ) );
......
......@@ -25,14 +25,10 @@ namespace LHCb {
* @author Juan PALACIOS
* @date 2007-11-30
*/
class GAUDI_API ICloneMCParticle : virtual public MicroDST::ICloner<LHCb::MCParticle> {
struct GAUDI_API ICloneMCParticle : virtual MicroDST::ICloner<LHCb::MCParticle> {
public:
/// Interface ID
DeclareInterfaceID( ICloneMCParticle, 2, 0 );
/// Destructor
virtual ~ICloneMCParticle() {}
DeclareInterfaceID( ICloneMCParticle, 3, 0 );
};
#endif // MICRODST_ICLONEMCPARTICLE_H
......@@ -25,14 +25,10 @@ namespace LHCb {
* @author Juan PALACIOS
* @date 2007-11-30
*/
class GAUDI_API ICloneMCVertex : virtual public MicroDST::ICloner<LHCb::MCVertex> {
struct GAUDI_API ICloneMCVertex : virtual MicroDST::ICloner<LHCb::MCVertex> {
public:
/// Interface ID
DeclareInterfaceID( ICloneMCVertex, 2, 0 );
/// Destructor
virtual ~ICloneMCVertex() {}
DeclareInterfaceID( ICloneMCVertex, 3, 0 );
};
#endif // MICRODST_ICLONEMCVERTEX_H
......@@ -8,13 +8,7 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#pragma once
// from STL
#include <string>
// from Gaudi
#include "GaudiKernel/IAlgTool.h"
namespace MicroDST {
......@@ -27,19 +21,12 @@ namespace MicroDST {
*/
template <class T>
class ICloner : virtual public IAlgTool {
struct ICloner : virtual IAlgTool {
public:
/// Type typedef
typedef T Type;
using Type = T;
public:
/// Clone operator
virtual T* operator()( const T* source ) = 0;
public:
/// Destructor
virtual ~ICloner() {}
virtual T* operator()( const T* source ) const = 0;
};
} // namespace MicroDST
......@@ -47,18 +47,18 @@ class MCParticleCloner final : public extends<MicroDSTTool, ICloneMCParticle> {
public:
/// Standard constructor
MCParticleCloner( const std::string& type, const std::string& name, const IInterface* parent );
using extends::extends;
StatusCode initialize() override;
LHCb::MCParticle* operator()( const LHCb::MCParticle* mcp ) override;
LHCb::MCParticle* operator()( const LHCb::MCParticle* mcp ) const override;
private:
LHCb::MCParticle* clone( const LHCb::MCParticle* mcp );
LHCb::MCParticle* clone( const LHCb::MCParticle* mcp ) const;
inline bool cloneOriginVertex( const LHCb::MCVertex* vertex ) { return ( vertex != nullptr ); }
bool cloneOriginVertex( const LHCb::MCVertex* vertex ) const { return ( vertex != nullptr ); }
void cloneDecayVertices( const SmartRefVector<LHCb::MCVertex>& endVertices, LHCb::MCParticle* clonedParticle );
void cloneDecayVertices( const SmartRefVector<LHCb::MCVertex>& endVertices, LHCb::MCParticle* clonedParticle ) const;
private:
typedef MicroDST::BasicItemCloner<LHCb::MCParticle> BasicMCPCloner;
......@@ -67,33 +67,23 @@ private:
private:
ICloneMCVertex* m_vertexCloner = nullptr;
std::string m_vertexClonerName;
Gaudi::Property<std::string> m_vertexClonerName{ this, "ICloneMCVertex", "MCVertexCloner" };
};
//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
MCParticleCloner::MCParticleCloner( const std::string& type, const std::string& name, const IInterface* parent )
: extends( type, name, parent ) {
declareProperty( "ICloneMCVertex", m_vertexClonerName = "MCVertexCloner" );
// setProperty( "OutputLevel", 2 );
}
//=============================================================================
StatusCode MCParticleCloner::initialize() {
const StatusCode sc = extends::initialize();
if ( sc.isFailure() ) return sc;
return extends::initialize().andThen( [&] {
m_vertexCloner =
( m_vertexClonerName == "NONE" ? nullptr : this->tool<ICloneMCVertex>( m_vertexClonerName, this->parent() ) );
( m_vertexClonerName.value() == "NONE" ? nullptr : this->tool<ICloneMCVertex>( m_vertexClonerName, this->parent() ) );
} );
return sc;
}
//=============================================================================
LHCb::MCParticle* MCParticleCloner::clone( const LHCb::MCParticle* mcp ) {
LHCb::MCParticle* MCParticleCloner::clone( const LHCb::MCParticle* mcp ) const {
if ( !mcp ) return nullptr;
if ( msgLevel( MSG::DEBUG ) ) debug() << "clone() called for " << *mcp << endmsg;
......@@ -151,7 +141,7 @@ LHCb::MCParticle* MCParticleCloner::clone( const LHCb::MCParticle* mcp ) {
//=============================================================================
void MCParticleCloner::cloneDecayVertices( const SmartRefVector<LHCb::MCVertex>& endVertices,
LHCb::MCParticle* clonedParticle ) {
LHCb::MCParticle* clonedParticle ) const {
for ( const auto& endVtx : endVertices ) {
if ( endVtx->isDecay() && !( endVtx->products().empty() ) ) {
if ( m_vertexCloner ) {
......@@ -169,10 +159,10 @@ void MCParticleCloner::cloneDecayVertices( const SmartRefVector<LHCb::MCVertex>&
//=============================================================================
LHCb::MCParticle* MCParticleCloner::operator()( const LHCb::MCParticle* mcp ) {
LHCb::MCParticle* MCParticleCloner::operator()( const LHCb::MCParticle* mcp ) const {
if ( !mcp ) return nullptr;
LHCb::MCParticle* clone = getStoredClone<LHCb::MCParticle>( mcp );
return ( clone ? clone : this->clone( mcp ) );
return clone ? clone : this->clone( mcp );
}
//=============================================================================
......
......@@ -34,47 +34,37 @@ class MCVertexCloner final : public extends<MicroDSTTool, ICloneMCVertex> {
public:
/// Standard constructor
MCVertexCloner( const std::string& type, const std::string& name, const IInterface* parent );
using extends::extends;
StatusCode initialize() override;
LHCb::MCVertex* operator()( const LHCb::MCVertex* mcVertex ) override;
LHCb::MCVertex* operator()( const LHCb::MCVertex* mcVertex ) const override;
public:
typedef MicroDST::BasicItemCloner<LHCb::MCVertex> BasicCloner;
private:
LHCb::MCVertex* clone( const LHCb::MCVertex* mcVertex );
LHCb::MCVertex* clone( const LHCb::MCVertex* mcVertex ) const;
void cloneDecayProducts( const SmartRefVector<LHCb::MCParticle>& products, LHCb::MCVertex* clonedVertex );
void cloneDecayProducts( const SmartRefVector<LHCb::MCParticle>& products, LHCb::MCVertex* clonedVertex ) const;
private:
ICloneMCParticle* m_particleCloner = nullptr;
std::string m_particleClonerName;
Gaudi::Property<std::string> m_particleClonerName{ this, "ICloneMCParticle", "MCParticleCloner" };
};
//=============================================================================
// Standard constructor, initializes variables
//=============================================================================
MCVertexCloner::MCVertexCloner( const std::string& type, const std::string& name, const IInterface* parent )
: extends( type, name, parent ) {
declareProperty( "ICloneMCParticle", m_particleClonerName = "MCParticleCloner" );
}
//=============================================================================
StatusCode MCVertexCloner::initialize() {
const StatusCode sc = extends::initialize();
if ( sc.isFailure() ) return sc;
return extends::initialize().andThen( [&]{
m_particleCloner = tool<ICloneMCParticle>( m_particleClonerName, this->parent() );
return sc;
});
}
//=============================================================================
LHCb::MCVertex* MCVertexCloner::operator()( const LHCb::MCVertex* vertex ) {
LHCb::MCVertex* MCVertexCloner::operator()( const LHCb::MCVertex* vertex ) const {
if ( !vertex ) return nullptr;
LHCb::MCVertex* clone = getStoredClone<LHCb::MCVertex>( vertex );
......@@ -87,7 +77,7 @@ LHCb::MCVertex* MCVertexCloner::operator()( const LHCb::MCVertex* vertex ) {
//=============================================================================
LHCb::MCVertex* MCVertexCloner::clone( const LHCb::MCVertex* vertex ) {
LHCb::MCVertex* MCVertexCloner::clone( const LHCb::MCVertex* vertex ) const {
LHCb::MCVertex* clone = nullptr;
if ( vertex ) {
if ( msgLevel( MSG::DEBUG ) )
......@@ -106,7 +96,7 @@ LHCb::MCVertex* MCVertexCloner::clone( const LHCb::MCVertex* vertex ) {
//=============================================================================
void MCVertexCloner::cloneDecayProducts( const SmartRefVector<LHCb::MCParticle>& products,
LHCb::MCVertex* clonedVertex ) {
LHCb::MCVertex* clonedVertex ) const {
// Clear the current products
clonedVertex->clearProducts();
......
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