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

more cleanup

parent 0e2f0e31
No related branches found
No related tags found
2 merge requests!3788Draft: Update SciFi cluster monitoring,!3619MicroDST: Cleanup remnants of the old cloning code
Pipeline #6327874 passed
Showing with 95 additions and 121 deletions
......@@ -8,17 +8,16 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/Particle.h"
#include "ICloneMCParticle.h"
#include "Kernel/Particle2MCParticle.h"
#include "MicroDST/Defaults.h"
#include "MicroDST/Functions.h"
#include "MicroDST/MicroDSTAlgorithm.h"
#include "boost/algorithm/string.hpp"
#include <boost/bind/bind.hpp>
#include <boost/function.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <MicroDST/Functors.h>
#include "Event/Particle.h"
#include "Kernel/Particle2MCParticle.h"
#include "boost/algorithm/string.hpp"
#include "ICloneMCParticle.h"
/** @class BindType2Cloner BindType2ClonerDef.h MicroDST/BindType2ClonerDef.h
*
......@@ -178,15 +177,13 @@ namespace MicroDST {
void copyTableFromLocation( const std::string& inputLocation ) {
class DataObjectGuard {
const DataObject* m_ptr;
public:
explicit DataObjectGuard( const DataObject* ptr ) : m_ptr( ptr ) {}
~DataObjectGuard() {
if ( !m_ptr->registry() ) delete m_ptr;
}
private:
const DataObject* m_ptr;
};
const std::string outputLocation = this->outputTESLocation( inputLocation );
......@@ -235,9 +232,9 @@ namespace MicroDST {
typedef typename boost::remove_pointer<typename TABLE::From>::type _From;
private:
inline const CLONER* cloner() { return m_cloner; }
const CLONER* cloner() { return m_cloner; }
inline typename TABLE::From cloneFrom( const typename TABLE::From from ) {
typename TABLE::From cloneFrom( const typename TABLE::From from ) {
if ( m_useOriginalFrom ) { return from; }
if ( !from ) {
error() << "From is nullptr. Cannot clone!" << endmsg;
......@@ -250,7 +247,7 @@ namespace MicroDST {
return getStoredClone<_From>( from );
}
inline typename TABLE::To cloneTo( const typename TABLE::To to ) {
typename TABLE::To cloneTo( const typename TABLE::To to ) {
if ( !m_cloner ) { return to; }
if ( !to ) {
error() << "To is nullptr. Cannot clone!" << endmsg;
......@@ -275,23 +272,21 @@ namespace MicroDST {
TableCloner m_tableCloner;
};
/** @class CopyProtoParticle2MCRelations CopyProtoParticle2MCRelations.h
*
* Near-duplicate of the CopyParticle2MCRelations microDST algorithm that
* copies weighted LHCb::ProtoParticle to LHCb:MCParticle relations, rather
* than weighted LHCb::Particle to LHCb:MCParticle relations.
*
* Another difference is that this algorithm is a specialisation of the
* MicroDST::RelationsClonerAlg template class, rather than the
* MicroDST::RelationsFromParticleLocationsClonerAlg class that
* CopyParticle2MCRelations specialises. With this difference, this class
* takes TES locations of relations tables as input, rather than taking
* particle locations and trying to deduce the relations table location from
* that. It will then take the locations of the associated LHCb::Particle
* objects by interrogating the relations table itself.
*/
/** @class CopyProtoParticle2MCRelations CopyProtoParticle2MCRelations.h
*
* Near-duplicate of the CopyParticle2MCRelations microDST algorithm that
* copies weighted LHCb::ProtoParticle to LHCb:MCParticle relations, rather
* than weighted LHCb::Particle to LHCb:MCParticle relations.
*
* Another difference is that this algorithm is a specialisation of the
* MicroDST::RelationsClonerAlg template class, rather than the
* MicroDST::RelationsFromParticleLocationsClonerAlg class that
* CopyParticle2MCRelations specialises. With this difference, this class
* takes TES locations of relations tables as input, rather than taking
* particle locations and trying to deduce the relations table location from
* that. It will then take the locations of the associated LHCb::Particle
* objects by interrogating the relations table itself.
*/
/** @class RelationsFromParticleLocationsClonerAlg MicroDST/RelationsFromParticleLocationsClonerAlg.h
*
......
......@@ -9,8 +9,8 @@
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/MCParticle.h"
#include "Kernel/Particle2MCLinker.h"
#include "ICloneMCParticle.h"
#include "Kernel/Particle2MCLinker.h"
#include "MicroDST/MicroDSTAlgorithm.h"
#include <memory>
#include <string>
......
......@@ -29,4 +29,3 @@ struct GAUDI_API ICloneMCVertex : virtual MicroDST::ICloner<LHCb::MCVertex> {
/// Interface ID
DeclareInterfaceID( ICloneMCVertex, 3, 0 );
};
......@@ -8,10 +8,9 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include <Event/MCParticle.h>
#include <MicroDST/Functors.h>
#include "ICloneMCParticle.h"
#include "ICloneMCVertex.h"
#include <Event/MCParticle.h>
#include <MicroDST/MicroDSTTool.h>
#include <algorithm>
//-----------------------------------------------------------------------------
......@@ -67,18 +66,17 @@ private:
private:
ICloneMCVertex* m_vertexCloner = nullptr;
Gaudi::Property<std::string> m_vertexClonerName{ this, "ICloneMCVertex", "MCVertexCloner" };
Gaudi::Property<std::string> m_vertexClonerName{this, "ICloneMCVertex", "MCVertexCloner"};
};
//=============================================================================
StatusCode MCParticleCloner::initialize() {
return extends::initialize().andThen( [&] {
m_vertexCloner =
( m_vertexClonerName.value() == "NONE" ? nullptr : this->tool<ICloneMCVertex>( m_vertexClonerName, this->parent() ) );
m_vertexCloner =
( m_vertexClonerName.value() == "NONE" ? nullptr
: this->tool<ICloneMCVertex>( m_vertexClonerName, this->parent() ) );
} );
}
//=============================================================================
......
......@@ -8,9 +8,9 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include <Event/MCVertex.h>
#include "ICloneMCParticle.h"
#include "ICloneMCVertex.h"
#include <Event/MCVertex.h>
#include <MicroDST/MicroDSTTool.h>
//-----------------------------------------------------------------------------
......@@ -49,17 +49,15 @@ private:
void cloneDecayProducts( const SmartRefVector<LHCb::MCParticle>& products, LHCb::MCVertex* clonedVertex ) const;
private:
ICloneMCParticle* m_particleCloner = nullptr;
Gaudi::Property<std::string> m_particleClonerName{ this, "ICloneMCParticle", "MCParticleCloner" };
ICloneMCParticle* m_particleCloner = nullptr;
Gaudi::Property<std::string> m_particleClonerName{this, "ICloneMCParticle", "MCParticleCloner"};
};
//=============================================================================
StatusCode MCVertexCloner::initialize() {
return extends::initialize().andThen( [&]{
m_particleCloner = tool<ICloneMCParticle>( m_particleClonerName, this->parent() );
});
return extends::initialize().andThen(
[&] { m_particleCloner = tool<ICloneMCParticle>( m_particleClonerName, this->parent() ); } );
}
//=============================================================================
......
/*****************************************************************************\
* (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#pragma once
#include "MicroDST/Functions.h"
/** @namespace MicroDST Functors.hpp MicroDST/Functors.hpp
*
*
* Collection of useful functors satisfying the Cloner policy and
* dealing with the cloning and storing clones into TES locations.
*
* Policy: Cloner must export a clone(const T*) method that returns
* a T*. If the input T* is null, Cloner must return a null
* pointer.
* A cloner must export member type T as ::Type.
*
* @author Juan PALACIOS
* @date 2007-10-24
*/
namespace MicroDST {
/**
*
* BasicItemCloner satisfying the Cloner policy.
* Requirements on template parameter T:
* T must export a method T* T::clone().
*
* @author Juan Palacios juancho@nikhef.nl
* @date 16-10-2007
*/
template <class T>
struct BasicItemCloner {
typedef T Type;
Type* operator()( const Type* item ) { return clone( item ); }
static Type* copy( const Type* item ) { return clone( item ); }
static Type* clone( const Type* item ) { return item ? item->clone() : NULL; }
};
/**
*
* BasicCopy satisfying the Cloner policy.
* Requirements on template parameter T:
* T must have a copy constructor.
*
* @author Juan Palacios juancho@nikhef.nl
* @date 16-10-2007
*/
template <class T>
struct BasicCopy {
typedef T Type;
Type* operator()( const Type* item ) { return copy( item ); }
static Type* copy( const Type* item ) { return item ? new Type( *item ) : NULL; }
static Type* clone( const Type* item ) { return copy( item ); }
};
//===========================================================================
} // namespace MicroDST
......@@ -45,8 +45,8 @@ protected:
}
private:
Gaudi::Property<std::string> m_inputTESLocation{ this, "InputLocation", "" };
Gaudi::Property<std::vector<std::string>> m_inputTESLocations{this, "InputLocations", {} };
Gaudi::Property<std::string> m_inputTESLocation{this, "InputLocation", ""};
Gaudi::Property<std::vector<std::string>> m_inputTESLocations{this, "InputLocations", {}};
};
#endif // COPYANDSTOREDATA_H
......@@ -8,15 +8,65 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#pragma once
#include "GaudiKernel/IDataManagerSvc.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/SmartIF.h"
#include "GaudiKernel/StatusCode.h"
#include <GaudiAlg/GaudiAlgorithm.h>
#include <GaudiKernel/KeyedObject.h>
#include <MicroDST/Functors.h>
/** @namespace MicroDST Functors.hpp MicroDST/Functors.hpp
*
*
* Collection of useful functors satisfying the Cloner policy and
* dealing with the cloning and storing clones into TES locations.
*
* Policy: Cloner must export a clone(const T*) method that returns
* a T*. If the input T* is null, Cloner must return a null
* pointer.
* A cloner must export member type T as ::Type.
*
* @author Juan PALACIOS
* @date 2007-10-24
*/
namespace MicroDST {
/**
*
* BasicItemCloner satisfying the Cloner policy.
* Requirements on template parameter T:
* T must export a method T* T::clone().
*
* @author Juan Palacios juancho@nikhef.nl
* @date 16-10-2007
*/
template <class T>
struct BasicItemCloner {
typedef T Type;
Type* operator()( const Type* item ) { return clone( item ); }
static Type* copy( const Type* item ) { return clone( item ); }
static Type* clone( const Type* item ) { return item ? item->clone() : NULL; }
};
/**
*
* BasicCopy satisfying the Cloner policy.
* Requirements on template parameter T:
* T must have a copy constructor.
*
* @author Juan Palacios juancho@nikhef.nl
* @date 16-10-2007
*/
template <class T>
struct BasicCopy {
typedef T Type;
Type* operator()( const Type* item ) { return copy( item ); }
static Type* copy( const Type* item ) { return item ? new Type( *item ) : NULL; }
static Type* clone( const Type* item ) { return copy( item ); }
};
//===========================================================================
} // namespace MicroDST
/** @class MicroDSTCommon MicroDSTCommon.h MicroDST/MicroDSTCommon.h
*
......@@ -134,7 +184,7 @@ MicroDSTCommon<PBASE>::cloneKeyedContainerItem( const typename itemCloner::Type*
return nullptr;
}
const auto cloneLocation = outputTESLocation( MicroDST::objectLocation( item->parent() ) );
const auto cloneLocation = outputTESLocation( objectLocation( item->parent() ) );
auto clones = getOutputContainer<typename itemCloner::Type::Container>( cloneLocation );
if ( !clones ) return nullptr;
......@@ -172,7 +222,7 @@ template <class T>
T* MicroDSTCommon<PBASE>::getStoredClone( const KeyedObject<int>* original ) const {
if ( !original || !original->parent() ) return nullptr;
const auto cloneLocation = outputTESLocation( MicroDST::objectLocation( original->parent() ) );
const auto cloneLocation = outputTESLocation( objectLocation( original->parent() ) );
auto clones = this->template getIfExists<typename T::Container>( cloneLocation );
......
......@@ -12,6 +12,7 @@
// Include files
// from Gaudi
#include "Functions.h"
#include <GaudiAlg/GaudiTool.h>
#include <MicroDST/MicroDSTCommon.h>
......@@ -28,8 +29,7 @@ public:
using MicroDSTCommon::MicroDSTCommon;
StatusCode initialize() override {
return MicroDSTCommon::initialize().andThen( [&]{
return MicroDST::synchroniseProperty( this->parent(), this, "OutputPrefix" );
} );
return MicroDSTCommon::initialize().andThen(
[&] { return MicroDST::synchroniseProperty( this->parent(), this, "OutputPrefix" ); } );
}
};
......@@ -16,7 +16,6 @@
// 2007-10-11 : Juan PALACIOS
//-----------------------------------------------------------------------------
//=============================================================================
// Initialization
//=============================================================================
......
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