Skip to content
Snippets Groups Projects
Commit 1064c488 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Merge branch 'cleanup-microdst' into 'master'

remove unused code in MicroDst/...

See merge request lhcb/Rec!3280
parents e59811a8 6cf60290
No related branches found
No related tags found
No related merge requests found
Showing
with 2 additions and 933 deletions
......@@ -15,47 +15,18 @@ MicroDST/MicroDSTAlgorithm
gaudi_add_module(MicroDSTAlgorithm
SOURCES
src/CopyCaloClusters.cpp
src/CopyCaloHypos.cpp
src/CopyFlavourTag.cpp
src/CopyGaudiNumbers.cpp
src/CopyHltDecReports.cpp
src/CopyLinePersistenceLocations.cpp
src/CopyMCHeader.cpp
src/CopyMCParticles.cpp
src/CopyODIN.cpp
src/CopyPVWeights.cpp
src/CopyParticle2BackgroundCategory.cpp
src/CopyParticle2LHCbIDs.cpp
src/CopyParticle2MCRelations.cpp
src/CopyParticle2PVMap.cpp
src/CopyParticle2PVRelations.cpp
src/CopyParticle2PVRelationsFromLinePersistenceLocations.cpp
src/CopyParticle2PVWeightedRelations.cpp
src/CopyParticle2RelatedInfo.cpp
src/CopyParticle2RelatedInfoFromLinePersistenceLocations.cpp
src/CopyParticle2TisTosDecisions.cpp
src/CopyParticles.cpp
src/CopyPrimaryVertices.cpp
src/CopyProtoParticle2MCRelations.cpp
src/CopyProtoParticles.cpp
src/CopyRecHeader.cpp
src/CopyRecSummary.cpp
src/CopySignalMCParticles.cpp
src/MoveDataObject.cpp
src/CopyProtoParticle2MCRelations.cpp
LINK
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
LHCb::DAQEventLib
LHCb::HltEvent
LHCb::HltInterfaces
LHCb::LHCbKernel
LHCb::MCAssociators
LHCb::MCEvent
LHCb::MicroDstLib
LHCb::PhysEvent
LHCb::RecEvent
LHCb::RelationsLib
LHCb::MicroDstLib
Rec::DaVinciInterfacesLib
Rec::DaVinciKernelLib
Rec::DaVinciMCKernelLib
......
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#include "CopyCaloClusters.h"
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYCALOCLUSTERS_H
#define COPYCALOCLUSTERS_H 1
// Include files
// from MicroDST
#include "MicroDST/BindType2ClonerDef.h"
#include <MicroDST/ICloneCaloCluster.h>
#include <MicroDST/KeyedContainerClonerAlg.h>
// from LHCb
#include <Event/CaloCluster.h>
/** @class CopyCaloClusters CopyCaloClusters.h
*
* MicroDSTAlgorithm to clone LHCb::CaloCluster and related objects from one TES
* location to a parallel one.
* It inherits the std::string properties InputLocation and OutputPrefix from
* MicroDSTCommon.
* The LHCb::CaloCluster objects are taken from the TES location defined by
* InputLocation, and are cloned and put in TES location "/Event" +
* OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
* The actual cloning of individual LHCb::CaloCluster objects is performed by the
* ICloneCaloCluster tool, the implementation of which is set by the
* ClonerType property (default: CaloClusterCloner).
*
* Usually, one would clone LHCb::CaloCluster objects implicitly by using
* CopyProtoParticles, which copies the associated LHCb::CaloCluster objects.
* The CopyCaloClusters algorithm if useful for when one wants to clone objects
* that one knows may not be associated to LHCb::ProtoParticles objects, but
* which one wants to copy anyway.
*
* @see ICloneCaloCluster
* @see CaloClusterCloner
*
* <b>Example</b>: Clone CaloClusters from "/Event/Hlt/Calo/EcalClusters" to
* "/Event/MyLocation/Hlt/Calo/EcalClusters"
*
* @code
* copyClusters = CopyCaloClusters()
* copyClusters.OutputPrefix = "MyLocation"
* copyClusters.InputLocation = "Hlt/Calo/EcalClusters"
* // Add the CopyCaloClusters instance to a selection sequence
* mySeq = GaudiSequencer("SomeSequence")
* mySeq.Members += [copyClusters]
* @endcode
*/
template <>
struct BindType2Cloner<LHCb::CaloCluster> {
typedef LHCb::CaloCluster Type;
typedef ICloneCaloCluster Cloner;
};
//=============================================================================
template <>
struct Defaults<LHCb::CaloCluster> {
const static std::string clonerType;
};
const std::string Defaults<LHCb::CaloCluster>::clonerType = "CaloClusterCloner";
//=============================================================================
template <>
struct Location<LHCb::CaloCluster> {
const static std::string Default;
};
const std::string Location<LHCb::CaloCluster>::Default = "";
//=============================================================================
typedef MicroDST::KeyedContainerClonerAlg<LHCb::CaloCluster> CopyCaloClusters;
DECLARE_COMPONENT_WITH_ID( CopyCaloClusters, "CopyCaloClusters" )
#endif // COPYCALOCLUSTERS_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#include "CopyCaloHypos.h"
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYCALOHYPOS_H
#define COPYCALOHYPOS_H 1
// Include files
// from MicroDST
#include "MicroDST/BindType2ClonerDef.h"
#include <MicroDST/ICloneCaloHypo.h>
#include <MicroDST/KeyedContainerClonerAlg.h>
// from LHCb
#include <Event/CaloHypo.h>
/** @class CopyCaloHypos CopyCaloHypos.h
*
* MicroDSTAlgorithm to clone LHCb::CaloHypo and related objects from one TES
* location to a parallel one.
* It inherits the std::string properties InputLocation and OutputPrefix from
* MicroDSTCommon.
* The LHCb::CaloHypo objects are taken from the TES location defined by
* InputLocation, and are cloned and put in TES location "/Event" +
* OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
* The actual cloning of individual LHCb::CaloHypo objects is performed by the
* ICloneCaloHypo algorithm, the implementation of which is set by the
* ClonerType property (default: CaloHypoCloner).
*
* Usually, one would clone LHCb::CaloHypo objects implicitly by using
* CopyProtoParticles, which copies the associated LHCb::CaloHypo objects.
* The CopyCaloHypos algorithm if useful for when one wants to clone objects
* that one knows may not be associated to LHCb::ProtoParticles objects, but
* which one wants to copy anyway.
*
* @see ICloneCaloHypo
* @see CaloHypoCloner
*
* <b>Example</b>: Clone CaloHypos from "/Event/MC/Particles" to
* "/Event/MyLocation/MC/Particles"
*
* @code
* copyHypos = CopyCaloHypos()
* copyHypos.OutputPrefix = "MyLocation"
* copyHypos.InputLocation = "MC/Particles"
* // Add the CopyCaloHypos instance to a selection sequence
* mySeq = GaudiSequencer("SomeSequence")
* mySeq.Members += [copyHypos]
* @endcode
*/
template <>
struct BindType2Cloner<LHCb::CaloHypo> {
typedef LHCb::CaloHypo Type;
typedef ICloneCaloHypo Cloner;
};
//=============================================================================
template <>
struct Defaults<LHCb::CaloHypo> {
const static std::string clonerType;
};
const std::string Defaults<LHCb::CaloHypo>::clonerType = "CaloHypoCloner";
//=============================================================================
template <>
struct Location<LHCb::CaloHypo> {
const static std::string Default;
};
const std::string Location<LHCb::CaloHypo>::Default = "";
//=============================================================================
typedef MicroDST::KeyedContainerClonerAlg<LHCb::CaloHypo> CopyCaloHypos;
DECLARE_COMPONENT_WITH_ID( CopyCaloHypos, "CopyCaloHypos" )
#endif // COPYCALOHYPOS_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
// Include files
// local
#include "CopyFlavourTag.h"
//-----------------------------------------------------------------------------
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYFLAVOURTAG_H
#define COPYFLAVOURTAG_H 1
// Include files
// from LHCb
#include <Event/FlavourTag.h>
// from MicroDST
#include "MicroDST/BindType2Cloner.h"
#include "MicroDST/KeyedContainerClonerAlg.h"
#include <MicroDST/ICloneFlavourTag.h>
// local
/** @class CopyFlavourTag CopyFlavourTag.h
*
* MicroDSTAlgorithm to clone an LHCb::FlavourTag container from one TES
* location to another one.
* It inherits the std::string properties InputLocation and
* OutputPrefix from MicroDSTCommon. The LHCb::FlavourTags are taken from the
* TES location defined by InputLocation, and are cloned and put in
* TES location "/Event" + OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
* If no InputLocation is specified the FlavourTags are taken from
* LHCb::FlavourTagLocation::Default
* The cloning action os performed by an implementation of the
* ICloneFlavourTag interface. This is steerable via the ClonerType
* property, with default value FlavourTagCloner.
*
* <b>Example</b>: Clone the LHCb::FlavourTags from default location ("Phys/Tagging")
* to "/Event/MyLocation/Phys/Tagging"
* @code
* # grab a sequencer
* mySeq = GaudiSequencer("SomeSequence")
* copyFT = CopyFlavourTag()
* mySeq.Members += [copyFT]
* copyFT.OutputPrefix = "MyLocation"
* @endcode
*
* @author Juan PALACIOS juan.palacios@nikhef.nl
* @date 2008-04-16
*/
//=============================================================================
template <>
struct BindType2Cloner<LHCb::FlavourTag> {
typedef LHCb::FlavourTag Type;
typedef ICloneFlavourTag Cloner;
};
//=============================================================================
template <>
struct Defaults<LHCb::FlavourTag> {
const static std::string clonerType;
};
const std::string Defaults<LHCb::FlavourTag>::clonerType = "FlavourTagDeepCloner";
//=============================================================================
template <>
struct Location<LHCb::FlavourTag> {
const static std::string Default;
};
const std::string Location<LHCb::FlavourTag>::Default = LHCb::FlavourTagLocation::Default;
//=============================================================================
typedef MicroDST::KeyedContainerClonerAlg<LHCb::FlavourTag> CopyFlavourTag;
DECLARE_COMPONENT_WITH_ID( CopyFlavourTag, "CopyFlavourTag" )
#endif // COPYFLAVOURTAG_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
// Include files
#include "CopyGaudiNumbers.h"
//-----------------------------------------------------------------------------
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYGAUDINUMBERS_H
#define COPYGAUDINUMBERS_H 1
// MicroDST
#include "MicroDST/ObjectClonerAlg.h"
// Include files
// from LHCb
#include "Kernel/Counters.h"
/** @class CopyGaudiNumbers CopyGaudiNumbers.h
*
* MicroDSTAlgorithm to clone a Gaudi::Numbers from one TES location to
* another one. It inherits the std::string properties InputLocation and
* OutputPrefix from MicroDSTCommon. The Gaudi::Numbers is taken from the
* TES location defined by InputLocation, and is cloned and put in
* TES location "/Event" + OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
*
* <b>Example</b>: Clone the Gaudi::Numbers from location ("Counters/CounterAlg")
* to "/Event/MyLocation/Counters/CounterAlg"
* @code
* mySeq = GaudiSequencer("SomeSequence")
* copyRecSummary = CopyGaudiNumbers()
* copyRecSummary.OutputPrefix = "MyLocation"
* mySeq.Members += [copyRecSummary]
* @endcode
*
* @author Juan PALACIOS palacios@physik.uzh.ch
* @date 2011-02-14
*/
//=============================================================================
template <>
struct Location<Gaudi::Numbers> {
const static std::string Default;
};
const std::string Location<Gaudi::Numbers>::Default = "";
//=============================================================================
typedef MicroDST::ObjectClonerAlg<Gaudi::Numbers> CopyGaudiNumbers;
// Declaration of the Algorithm Factory
DECLARE_COMPONENT_WITH_ID( CopyGaudiNumbers, "CopyGaudiNumbers" )
#endif // COPYGAUDINUMBERS_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#include "CopyHltDecReports.h"
//
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYHLTDECREPORTS_H
#define COPYHLTDECREPORTS_H 1
// Include files
// MicroDST
#include "MicroDST/BindType2Cloner.h"
#include "MicroDST/ObjectClonerAlg.h"
// from LHCb
#include "Event/HltDecReports.h"
/** @class CopyHltDecReports CopyHltDecReports.h
*
* MicroDSTAlgorithm to clone an LHCb::HltDecReports from one TES location to
* another one. It inherits the std::string properties InputLocation and
* OutputPrefix from MicroDSTCommon. The LHCb::HltDecReports is taken from the
* TES location defined by InputLocation, and is cloned and put in
* TES location "/Event" + OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
* If no InputLocation is specified the header is taken from LHCb::HltDecReportsLocation::Default
*
* <b>Example</b>: Clone the LHCb::HltDecReports from default location ("DAQ/HltDecReports")
* to "/Event/MyLocation/Hlt/HltDecReports"
* @code
* mySeq = GaudiSequencer("SomeSequence")
* copyHLT = CopyHLTDecReports()
* mySeq.Members += [copyHLT]
* copyHLT.OutputPrefix = "MyLocation"
* @endcode
*
*
* @author Juan PALACIOS
* @date 2009-04-03
*/
//=============================================================================
template <>
struct Location<LHCb::HltDecReports> {
const static std::string Default;
};
const std::string Location<LHCb::HltDecReports>::Default = LHCb::HltDecReportsLocation::Default;
//=============================================================================
typedef MicroDST::ObjectClonerAlg<LHCb::HltDecReports> CopyHltDecReports;
// Declaration of the Algorithm Factory
DECLARE_COMPONENT_WITH_ID( CopyHltDecReports, "CopyHltDecReports" )
#endif // COPYHLTDECREPORTS_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#include <sstream>
#include <GaudiKernel/KeyedContainer.h>
#include <Event/CaloCluster.h>
#include <Event/CaloHypo.h>
#include <Event/FlavourTag.h>
#include <Event/Particle.h>
#include <Event/ProtoParticle.h>
#include <Event/RecSummary.h>
#include <Event/RecVertex.h>
#include <Event/VertexBase.h>
#include "CopyLinePersistenceLocations.h"
DECLARE_COMPONENT( CopyLinePersistenceLocations )
// We clone objects in the order given by this list, from top to bottom.
//
// As motivation for why we do this, imagine that the PersistReco cloner for
// CaloHypo objects is different to that for non-PersistReco, and that it
// clones more information. The Particle cloner will clone CaloHypo objects
// implicitly, through the CaloHypo cloner belonging to the ProtoParticle
// cloner, but that CaloHypo cloner will be different to the PersistReco
// CaloHypo cloner (cloning less information). If the Particle cloner now runs
// before the PersistReco CaloHypo cloner, the CaloHypo objects won't be cloned
// by the PersistReco cloner, as cloners skip objects that have already been
// cloned.
//
// Then, the CaloHypo objects may have less information than they would if the
// PersistReco CaloHypo cloner had cloned them, for example the associated
// CaloDigit objects may not be cloned.
//
// By running the cloners in the order below, going up the dependency tree, we
// ensure that the explicit cloners have priority over implicit cloners, which
// go down the dependency tree.
const std::vector<CLID> CopyLinePersistenceLocations::cloneOrderByClassID = {
KeyedContainer<LHCb::CaloCluster>::classID(),
KeyedContainer<LHCb::CaloHypo>::classID(),
KeyedContainer<LHCb::ProtoParticle>::classID(),
KeyedContainer<LHCb::Particle>::classID(),
KeyedContainer<LHCb::RecVertex>::classID(),
KeyedContainer<LHCb::FlavourTag>::classID(),
LHCb::RecSummary::classID()};
CopyLinePersistenceLocations::CopyLinePersistenceLocations( const std::string& name, ISvcLocator* svcLocator )
: MicroDSTCommon<GaudiAlgorithm>( name, svcLocator ) {
m_linesToCopy.declareUpdateHandler( [this]( auto& ) {
this->m_linesToCopySet = std::set<std::string>( m_linesToCopy.begin(), m_linesToCopy.end() );
} );
m_linesToCopy.useUpdateHandler();
}
template <typename KeyedObjectToClone, typename ClonerSourceObject /* = KeyedObjectToClone */,
typename Cloner /* = ToolHandle<MicroDST::ICloner<ClonerSourceObject>> */>
void CopyLinePersistenceLocations::registerCloner( Cloner cloner,
CopyLinePersistenceLocations::CLIDToCloner& classMap ) {
using KeyedContainerToClone = KeyedContainer<KeyedObjectToClone>;
classMap[KeyedContainerToClone::classID()] = [this, cloner]( const DataObject& container ) {
const auto& castedContainer = dynamic_cast<const KeyedContainerToClone&>( container );
this->cloneKeyedContainer<KeyedObjectToClone, ClonerSourceObject>( castedContainer, cloner );
};
}
template <typename ClonerSourceObject>
void CopyLinePersistenceLocations::registerCopyCloner( CopyLinePersistenceLocations::CLIDToCloner& classMap ) {
classMap[ClonerSourceObject::classID()] = [this]( const DataObject& container ) {
auto inputLocation = MicroDST::objectLocation( &container );
auto outputLocation = this->outputTESLocation( inputLocation );
const auto& castedContainer = dynamic_cast<const ClonerSourceObject&>( container );
ClonerSourceObject* clone = new ClonerSourceObject( castedContainer );
this->put( clone, outputLocation );
};
}
StatusCode CopyLinePersistenceLocations::initialize() {
const StatusCode sc = MicroDSTCommon<GaudiAlgorithm>::initialize();
if ( sc.isFailure() ) { return sc; }
m_linePersistenceSvc = svc<ILinePersistenceSvc>( m_linePersistenceSvcName.value() );
if ( !m_linePersistenceSvc ) {
throw GaudiException( "Could not acquire ILinePersistenceSvc", this->name(), StatusCode::FAILURE );
}
registerCloner<LHCb::CaloCluster>( m_caloClusterCloner, m_cloners );
registerCloner<LHCb::CaloHypo>( m_caloHypoCloner, m_cloners );
registerCloner<LHCb::Particle>( m_particleCloner, m_cloners );
registerCloner<LHCb::ProtoParticle>( m_protoParticleCloner, m_cloners );
registerCloner<LHCb::FlavourTag>( m_flavourtagCloner, m_cloners );
// Vertex cloners are specialised with the VertexBase class, but we
// want to support KeyedContainers of RecVertex, not VertexBase
registerCloner<LHCb::RecVertex, LHCb::VertexBase>( m_vertexCloner, m_cloners );
// Define cloning the RecSummary
registerCopyCloner<LHCb::RecSummary>( m_cloners );
// // Allow for different Calo object cloners for PersistReco lines, with the
// primary use case being so that we can always copy associated CaloDigit
// objects (which depends on having a associated Particle cloning the Calo
// objects by default, which we don't have when cloning whole containers)
registerCloner<LHCb::CaloCluster>( m_turboPPCaloClusterCloner, m_turboPPCloners );
registerCloner<LHCb::CaloHypo>( m_turboPPCaloHypoCloner, m_turboPPCloners );
// Can have a special vertex cloner for locations belonging to full
// PersistReco lines, with the principle use case being that PR lines get
// full PVs, including VELO tracks, rather than the 'light' PVs, without VELO
// tracks, that Turbo lines get
registerCloner<LHCb::RecVertex, LHCb::VertexBase>( m_turboPPVertexCloner, m_turboPPCloners );
// Fall back to non-specific cloners if a Turbo++ cloner wasn't specified
m_turboPPCloners.insert( m_cloners.begin(), m_cloners.end() );
return sc;
}
StatusCode CopyLinePersistenceLocations::execute() {
if ( msgLevel( MSG::DEBUG ) ) { debug() << "==> Execute" << endmsg; }
setFilterPassed( true );
const auto decReports = getIfExists<LHCb::HltDecReports>( m_hltDecReportsLocation.value() );
if ( !decReports ) {
return Warning( "Could not retrieve HltDecReports from " + m_hltDecReportsLocation.value(), StatusCode::SUCCESS );
}
const auto locationsToCopy = m_linePersistenceSvc->locationsToPersist( *decReports, m_linesToCopySet );
const auto turboPPLocationsToCopy = m_linePersistenceSvc->turboPPLocationsToPersist( *decReports, m_linesToCopySet );
ILinePersistenceSvc::Locations nonTurboPPLocationsToCopy;
std::set_difference( locationsToCopy.begin(), locationsToCopy.end(), turboPPLocationsToCopy.begin(),
turboPPLocationsToCopy.end(),
std::inserter( nonTurboPPLocationsToCopy, nonTurboPPLocationsToCopy.begin() ) );
if ( msgLevel( MSG::VERBOSE ) ) {
if ( locationsToCopy.empty() ) {
verbose() << "No locations to copy" << endmsg;
} else {
verbose() << "Will attempt to copy the following locations:" << endmsg;
for ( const auto& loc : locationsToCopy ) { verbose() << " - " << loc << endmsg; }
if ( !turboPPLocationsToCopy.empty() ) {
verbose() << "Out of which these will be cloned with Turbo++ cloners:" << endmsg;
for ( const auto& loc : turboPPLocationsToCopy ) { verbose() << " - " << loc << endmsg; }
}
}
}
// Here we make the implicit assumption that the Turbo++ cloners will
// clone a superset of the data cloned by the standard cloners.
this->cloneLocations( turboPPLocationsToCopy, m_turboPPCloners );
this->cloneLocations( nonTurboPPLocationsToCopy, m_cloners );
return StatusCode::SUCCESS;
}
void CopyLinePersistenceLocations::cloneLocations( const std::set<std::string>& locations,
const CopyLinePersistenceLocations::CLIDToCloner& cloners ) {
// Map each container class ID to a list of containers with that ID
std::map<const CLID, std::vector<const DataObject*>> containerTypeToLocations;
for ( const auto& containerLocation : locations ) {
const auto dataObject = getIfExists<DataObject>( containerLocation );
if ( !dataObject ) {
if ( msgLevel( MSG::VERBOSE ) ) { verbose() << "Found no data at location " << containerLocation << endmsg; }
continue;
} else {
if ( msgLevel( MSG::VERBOSE ) ) {
verbose() << "Found data at location " << containerLocation << " with classID " << dataObject->clID() << endmsg;
}
}
// We have a pointer to a valid container, so add to the list of containers
// for this type
const auto classID = dataObject->clID();
containerTypeToLocations[classID].push_back( dataObject );
}
// Clone each set of containers in order
for ( const auto& classID : cloneOrderByClassID ) {
// Did we find any containers with the current CLID?
auto needle = containerTypeToLocations.find( classID );
if ( needle == containerTypeToLocations.end() ) {
if ( msgLevel( MSG::DEBUG ) ) { debug() << "No containers found with classID " << classID << endmsg; }
continue;
}
auto it = cloners.find( classID );
if ( it == cloners.end() ) {
// We haven't found a cloner for an object type that's in our explicit
// dependency tree; we expect to be able to handle these, so warn
if ( msgLevel( MSG::WARNING ) ) {
warning() << "Cannot clone objects with classID " << classID << ", these containers will be skipped:" << endmsg;
for ( const auto& container : needle->second ) { warning() << " - " << container->name() << endmsg; }
}
continue;
}
// Clone the contents of the container
for ( const auto& container : needle->second ) { it->second( *container ); }
}
}
template <typename KeyedObjectToClone, typename ClonerSourceObject /* = KeyedObjectToClone */,
typename Cloner /* = ToolHandle<MicroDST::ICloner<ClonerSourceObject>> */>
void CopyLinePersistenceLocations::cloneKeyedContainer( const KeyedContainer<KeyedObjectToClone>& container,
Cloner cloner ) const {
auto inputLocation = MicroDST::objectLocation( &container );
if ( m_alwaysCreateOutput.value() && container.empty() ) {
auto outputLocation = this->outputTESLocation( inputLocation );
if ( msgLevel( MSG::VERBOSE ) ) {
verbose() << "Creating empty container at location " << outputLocation << endmsg;
}
auto clone = new KeyedContainer<KeyedObjectToClone>{};
clone->setVersion( container.version() );
put( clone, outputLocation );
} else if ( msgLevel( MSG::VERBOSE ) ) {
verbose() << "Copying " << container.size() << " objects from container at location " << inputLocation << endmsg;
}
for ( const auto& keyedObject : container ) {
if ( msgLevel( MSG::VERBOSE ) ) { verbose() << "Copying " << keyedObject << " with " << cloner->type() << endmsg; }
auto clone = ( *cloner )( keyedObject );
if ( !clone ) {
std::stringstream ss;
ss << "Failed to clone " << keyedObject << " with " << cloner->type() << std::endl;
Warning( ss.str() ).ignore();
}
}
}
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef MICRODST_COPYLINEPERSISTENCELOCATIONS_H
#define MICRODST_COPYLINEPERSISTENCELOCATIONS_H 1
#include <functional>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <GaudiAlg/GaudiAlgorithm.h>
#include <GaudiKernel/DataObject.h>
#include <Event/HltDecReports.h>
#include <Kernel/ILinePersistenceSvc.h>
#include <MicroDST/ICloneCaloCluster.h>
#include <MicroDST/ICloneCaloHypo.h>
#include <MicroDST/ICloneFlavourTag.h>
#include <MicroDST/ICloneParticle.h>
#include <MicroDST/ICloneProtoParticle.h>
#include <MicroDST/ICloneVertexBase.h>
#include <MicroDST/ICloner.h>
#include <MicroDST/MicroDSTCommon.h>
/** @class CopyLinePersistenceLocations CopyLinePersistenceLocations.h
*
* @brief Clone TES locations, of KeyedContainer objects, defined by the
* ILinePersistenceSvc.
*
* For each location returned by the ILinePersistenceSvc, if that location
* contains a KeyedContainer and if the object stored in that KeyedContainer is
* supported by this algorithm, the container is cloned from its original
* location to that with `/Event` replaced by `/Event/<prefix>`, where
* `<prefix>` is the value of the `OutputPrefix` property (inherited from
* MicroDSTCommon).
*
* The objects currently supported for cloning are:
*
* * LHCb::CaloHypo, with the cloner defined by the `ICloneCaloHypo` property
* * LHCb::CaloCluster, with the cloner defined by the `ICloneCaloCluster` property
* * LHCb::Particle, with the cloner defined by the `ICloneParticle` property
* * LHCb::ProtoParticle, with the cloner defined by the `ICloneProtoParticle` property
* * LHCb::VertexBase, with the cloner defined by the `ICloneVertexBase` property
* * LHCb::FlavourTag, with the cloner defined by the `ICloneFlavourTag` property
*
* To accommodate different cloner types for PersistReco (a.k.a.
* Turbo++/TurboPP) lines, the `TurboPPICloneVertexBase` property allows the
* LHCb::VertexBase cloner to be different to that used for 'regular' Turbo
* lines. The primary use-case is allowing the cloning of PV tracks for Turbo++
* lines, in addition to the usual cloning of the PVs themselves. It is an
* assumption of this algorithm that the Turbo++ cloner copies a superset of
* the information copied by the Turbo cloner.
*
* If a TES location defined by the ILinePersistenceSvc contains a
* KeyedContainer of an object not in the above list, or does not contain a
* KeyedContainer, the location is skipped (no warning or error is printed).
*
* *Note*: This algorithm will use the cloner tools as defined by its various
* `IClone*` properties, but the cloner tools may themselves use other cloner
* tools, which need to be overridden explicitly.
* (For example, ParticleCloner uses an ICloneCaloHypo tool to clone associated
* LHCb::CaloHypo objects, and setting the cloning tool on _this_ algorithm but
* not on ParticleCloner may result in different cloning techniques for the
* same object type.)
*
* Example usage:
*
* @code
* from Configurables import CopyLinePersistenceLocations
* container_cloner = CopyLinePersistenceLocations(
* OutputPrefix='/Event/SomeStreamName',
* # Clone the locations requested by one Turbo line
* LinesToCopy=['Hlt2CharmHadD02KmPipTurbo'],
* # Get the list of locations to copy from the TCK
* ILinePersistenceSvc='TCKLinePersistenceSvc',
* # Use a specific cloner for RecVertex containers. Here we choose
* # a cloner that clears the container of tracks on each cloned vertex
* ICloneVertexBase='VertexBaseFromRecVertexClonerNoTracks',
* # Use a specific cloner for RecVertex containers requested by Turbo++ #
* lines. Here we choose a cloner that also copies the container of tracks
* # associated to each cloned vertex
* TurboPPICloneVertexBase='VertexBaseFromRecVertexClonerNoTracks'
* )
* @endcode
*
* @see CopyParticle2PVRelationsFromLinePersistenceLocations for cloning
* relations tables
*/
class CopyLinePersistenceLocations : public MicroDSTCommon<GaudiAlgorithm> {
public:
CopyLinePersistenceLocations( const std::string& name, ISvcLocator* pSvcLocator );
StatusCode initialize() override;
StatusCode execute() override;
using CLIDToCloner = std::map<CLID, std::function<void( const DataObject& )>>;
private:
/// If true, always create output containers, even if the input locations are empty.
/// (Either way, an output container is never made if the input location does not exist.)
Gaudi::Property<bool> m_alwaysCreateOutput{this, "AlwaysCreateOutput", true};
/// Implementation of ILinePersistenceSvc used to get the list of locations to clone.
Gaudi::Property<std::string> m_linePersistenceSvcName{this, "ILinePersistenceSvc", "TCKLinePersistenceSvc"};
/// Implementation of ICloneCaloCluster used to clone LHCb::CaloCluster objects.
ToolHandle<ICloneCaloCluster> m_caloClusterCloner{this, "ICloneCaloCluster", "CaloClusterCloner/CaloClusterCloner"};
/// Implementation of ICloneCaloHypo used to clone LHCb::CaloHypo objects.
ToolHandle<ICloneCaloHypo> m_caloHypoCloner{this, "ICloneCaloHypo", "CaloHypoCloner/CaloHypoCloner"};
/// Implementation of ICloneFlavourTag used to clone LHCb::FlavourTag objects
ToolHandle<ICloneFlavourTag> m_flavourtagCloner{this, "ICloneFlavourTag", "FlavourTagCloner"};
/// Implementation of ICloneParticle used to clone LHCb::Particle objects.
ToolHandle<ICloneParticle> m_particleCloner{this, "ICloneParticle", "ParticleCloner"};
/// Implementation of ICloneProtoParticle used to clone LHCb::ProtoParticle objects.
ToolHandle<ICloneProtoParticle> m_protoParticleCloner{this, "ICloneProtoParticle", "ProtoParticleCloner"};
/// Implementation of ICloneVertexBase used to clone LHCb::VertexBase objects
ToolHandle<ICloneVertexBase> m_vertexCloner{this, "ICloneVertexBase",
"VertexBaseFromRecVertexClonerNoTracks/RecVertexCloner"};
/// Implementation of ICloneCaloClusterCloner used to clone LHCb::CaloCluster objects for Turbo++ lines
ToolHandle<ICloneCaloCluster> m_turboPPCaloClusterCloner{this, "TurboPPICloneCaloCluster",
"CaloClusterCloner/TurboPPCaloClusterCloner"};
/// Implementation of ICloneCaloHypoCloner used to clone LHCb::CaloHypo objects for Turbo++ lines
ToolHandle<ICloneCaloHypo> m_turboPPCaloHypoCloner{this, "TurboPPICloneCaloHypo",
"CaloHypoCloner/TurboPPCaloHypoCloner"};
/// Implementation of ICloneVertexBase used to clone LHCb::VertexBase objects for Turbo++ lines
ToolHandle<ICloneVertexBase> m_turboPPVertexCloner{this, "TurboPPICloneVertexBase",
"VertexBaseFromRecVertexClonerWithTracks/TurboPPRecVertexCloner"};
/// List of HLT2 lines whose outputs are to be copied.
Gaudi::Property<std::vector<std::string>> m_linesToCopy{this, "LinesToCopy", {}};
std::set<std::string> m_linesToCopySet;
/// TES location of the HltDecReports object to give to ILinePersistenceSvc.
Gaudi::Property<std::string> m_hltDecReportsLocation{this, "Hlt2DecReportsLocation",
LHCb::HltDecReportsLocation::Hlt2Default};
SmartIF<ILinePersistenceSvc> m_linePersistenceSvc;
/// Map class IDs to cloner tools.
CLIDToCloner m_cloners;
/// Map class IDs to cloner tools to be used for locations belonging to Turbo++ lines.
CLIDToCloner m_turboPPCloners;
/// List of CLIDs that we support cloning of, in the order in which we clone them.
/// The order matters as cloners can clone object dependencies, but we want to
/// make sure we clone those dependencies *first*, so that the explicit cloner for
/// that dependency overrides the implicit one used by a cloner higher up in the
/// dependency tree.
static const std::vector<CLID> cloneOrderByClassID;
/// Bind the MicroDST::ICloner tool, named cloner_name and that can clone
/// ClonerSourceObject types, to the KeyedObjectToClone template parameter
template <typename KeyedObjectToClone, typename ClonerSourceObject = KeyedObjectToClone,
typename Cloner = ToolHandle<MicroDST::ICloner<ClonerSourceObject>>>
void registerCloner( Cloner cloner, CopyLinePersistenceLocations::CLIDToCloner& classMap );
/// Bind the function to clone an object with a simple copy constructor.
template <typename ClonerSourceObject>
void registerCopyCloner( CopyLinePersistenceLocations::CLIDToCloner& classMap );
/// Loop over the list of locations and invoke the cloner lambda on each, dispatching on the
/// class ID of the KeyedContainer at each location
void cloneLocations( const std::set<std::string>& locations, const CLIDToCloner& cloners );
/// Loop over the container contents and call cloner::operator() on each element.
template <typename KeyedObjectToClone, typename ClonerSourceObject = KeyedObjectToClone,
typename Cloner = ToolHandle<MicroDST::ICloner<ClonerSourceObject>>>
void cloneKeyedContainer( const KeyedContainer<KeyedObjectToClone>& container, Cloner cloner ) const;
void cloneFlavourTags( const KeyedContainer<LHCb::FlavourTag>& container,
std::string originalBCandidateLocation ) const;
};
#endif // MICRODST_COPYLINEPERSISTENCELOCATIONS_H
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#include "CopyODIN.h"
//
/*****************************************************************************\
* (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. *
\*****************************************************************************/
#ifndef COPYODIN_H
#define COPYODIN_H 1
// Include files
// MicroDST
#include "MicroDST/BindType2Cloner.h"
#include "MicroDST/ObjectClonerAlg.h"
// from LHCb
#include "Event/ODIN.h"
/** @class CopyODIN CopyODIN.h
*
* MicroDSTAlgorithm to clone an LHCb::ODIN from one TES location to
* another one. It inherits the std::string properties InputLocation and
* OutputPrefix from MicroDSTCommon. The LHCb::ODIN is taken from the
* TES location defined by InputLocation, and is cloned and put in
* TES location "/Event" + OutputPrefix + InputLocation.
* If InputLocation already contains a leading "/Event" it is removed.
* If no InputLocation is specified the header is taken from LHCb::ODINLocation::Default
*
* <b>Example</b>: Clone the LHCb::ODIN from default location ("DAQ/ODIN")
* to "/Event/MyLocation/DAQ/ODIN"
* @code
* mySeq = GaudiSequencer("SomeSequence")
* copyODIN = CopyODIN()
* copyODIN.OutputPrefix = "MyLocation"
* mySeq.Members += [copyODIN]
* @endcode
*
*
* @author Juan PALACIOS
* @date 2007-10-15
*/
//=============================================================================
template <>
struct Location<LHCb::ODIN> {
const static std::string Default;
};
const std::string Location<LHCb::ODIN>::Default = LHCb::ODINLocation::Default;
//=============================================================================
typedef MicroDST::ObjectClonerAlg<LHCb::ODIN> CopyODIN;
// Declaration of the Algorithm Factory
DECLARE_COMPONENT_WITH_ID( CopyODIN, "CopyODIN" )
#endif // COPYODIN_H
/*****************************************************************************\
* (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. *
\*****************************************************************************/
// Include files
#include "CopyPVWeights.h"
//-----------------------------------------------------------------------------
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