diff --git a/CMakeLists.txt b/CMakeLists.txt index 8176c83afd331cb3c71e928a43fe2f4ce4f3b491..c0a1318040df51b2ce68a33565fcb7bb70eb18d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ lhcb_add_subdirectories( Phys/JetAccessoriesMC Phys/LoKiAlgoMC Phys/LoKiPhysMC - Phys/Particle2MCTruth ) lhcb_finalize_configuration() diff --git a/Phys/Particle2MCTruth/CMakeLists.txt b/Phys/Particle2MCTruth/CMakeLists.txt deleted file mode 100644 index 4a7463fa2734ed81ef88a4d86d13204859fae747..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# (c) Copyright 2000-2021 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. # -############################################################################### -#[=======================================================================[.rst: -Phys/Particle2MCTruth ---------------------- -#]=======================================================================] - -gaudi_add_library(Particle2MCTruthLib - SOURCES - src/Lib/P2MCPBase.cpp - LINK - PUBLIC - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - LHCb::LoKiMCLib - LHCb::MCAssociators - LHCb::MCEvent - LHCb::PhysEvent - LHCb::RelationsLib - Rec::DaVinciMCKernelLib -) - -gaudi_add_module(Particle2MCTruth - SOURCES - src/MCMatchObjP2MCRelator.cpp - src/P2MCRelatorAlg.cpp - LINK - Analysis::LoKiPhysMCLib - Boost::headers - Gaudi::GaudiAlgLib - Gaudi::GaudiKernel - LHCb::LoKiCoreLib - LHCb::LoKiMCLib - Particle2MCTruthLib - Rec::DaVinciMCKernelLib -) - -gaudi_add_dictionary(P2MCPDict - HEADERFILES dict/Particle2MCTruthDict.h - SELECTION dict/Particle2MCTruthDict.xml - LINK Particle2MCTruthLib -) diff --git a/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.h b/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.h deleted file mode 100644 index a829fe0c2011ebeec7ce8b8dbbdc06156dd7904b..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.h +++ /dev/null @@ -1,28 +0,0 @@ -/*****************************************************************************\ -* (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 DICT_PARTICLE2MCTRUTHDICT_H -# define DICT_PARTICLE2MCTRUTHDICT_H 1 - -// Include files - -/** @file dict/Particle2MCTruthDict.h - * - * - * @author Juan PALACIOS - * @date 2009-03-10 - */ -# include "P2MCP/IP2MCP.h" -# include "P2MCP/P2MCPTypes.h" -#endif // DICT_PARTICLE2MCTRUTHDICT_H - -namespace { - std::vector<LHCb::MCParticle::ConstVector> __stdvector_mcpVC; -} diff --git a/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.xml b/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.xml deleted file mode 100644 index 6465e094e64d71da06b07a729057509701dbb3f1..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/dict/Particle2MCTruthDict.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - (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. ---> -<!--- Author : Juan PALACIOS --> -<!--- Created : 2009-03-10 --> - -<lcgdict> -<!-- P2MCP --> - <class name = "IP2MCP"/> - <class name = "P2MCP::DecayLines"/> -</lcgdict> diff --git a/Phys/Particle2MCTruth/doc/release.notes b/Phys/Particle2MCTruth/doc/release.notes deleted file mode 100644 index ad716b067f1b4db45c091bfcd806439b405d5eb5..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/doc/release.notes +++ /dev/null @@ -1,228 +0,0 @@ -!----------------------------------------------------------------------------- -! Package : Phys/Particle2MCTruth -! Responsible : DaVinci coordinator -! Purpose : Collection of implementations of IP2MCP and -! P2MCPBase for Particle -> MCTruth matching -!----------------------------------------------------------------------------- - -!===================== Particle2MCTruth v2r7 2015-06-13 ====================== - -! 2016-06-03 - Stefano Perazzini - - Added location to match MC particles for Turbo - -!===================== Particle2MCTruth v2r6 2015-12-03 ====================== - -! 2015-11-09 - Gerhard Raven - - replace LoKi::Select with std::copy_if - -!========================= Particle2MCTruth v2r5p1 2013-12-18 ========================= - -! 2013-11-15 - Marco Clemencic - - Fixed genreflex XML selection file. - -!========================= Particle2MCTruth v2r5 2012-11-30 ========================= - -! 2012-11-29 - Marco Clemencic - - Added CMake configuration file. - -! 2012-11-08 - Chris Jones - - Improvements to the MC association tools to better support uDSTs - -!========================= Particle2MCTruth v2r4p1 2012-02-09 ========================= - -! 2012-02-09 - Chris Jones - - Remove obsolete dll.cpp file - -!========================= Particle2MCTruth v2r4 2011-12-15 ========================= - -! 2011-12-12 - Chris Jones - - Tidy up - -! 2011-11-11 - Chris Jones - - Update MCMatchObjP2MCRelator to make it more inteligent in where it - looks for the relations tables. Will now try to look in the same place in - the TES location as the input Particle container, which helps when running - on uDSTs. - -! ======================== Particle2MCTruth v2r3p6 2010-04-29 =============== -! 2011-04-08 - Juan Palacios - - src/MCMatchObjP2MCRelator.cpp - . Check matcher poitner before dereferencing. - - cmt/requirements - . Increase to v2r3p6 - -! ======================== Particle2MCTruth v2r3p5 2010-05-28 =============== - -! 2010-05-28 - Juan Palacios - - src/P2MCRelatorAlg.cpp - . Protect against Particle::Range not being found. - - cmt/requirements - . Increase to v2r3p5 - -! ======================== Particle2MCTruth v2r3p4 2010-05-18 =============== - -! 2010-05-18 - Juan Palacios - - src/P2MCRelatorAlg.cpp - . Suppress warnings until end of job. - . Fix trivial but crucial bug. - - cmt/requirements - . Increase to v2r3p4 - -! ======================== Particle2MCTruth v2r3p3 2010-04-30 =============== - -! 2010-04-15 - Juan Palacios - - src/P2MCRelatorAlg.cpp - . Use Particle::Range for input particles. - - cmt/requirements - . Increase version to v2r3p3 - -! ======================== Particle2MCTruth v2r3p2 2009-10-28 =============== - -! 2009-10-27 - Vanya Belyaev - - - MCMatchObjP2MCRelator - - change a bit the initialization logic: - postpone the loading of the relation tables - to the first actual usage of them.. - - -! 2009-10-22 - Chris Jones - - Add private usage of CLHEP (needed for linking on OSX) - -! 2009-10-15 - Juan PALACIOS - - P2MCP/IP2MCP.h - . Add missing GAUDI_API - - - cmt/requirements - . Increase version to v2r3p2 - -! ======================== Particle2MCTruth v2r3 2009-08-27 ================= - -! 2009-08-25 - Juan PALACIOS - - src/P2MCRelatorAlg{.h, .cpp} - . Allow for list of input locations - - cmt/requirements - . Increase version vo v2r3 - -! ======================== Particle2MCTruth v2r2 2009-08-11 ================= - -! 2009-07-30 - Juan PALACIOS - - Use new Gaudi v21 interface mechanism. - - Remove src/Lib/Particle2MCTruthInterfaces.cpp - - cmt/requirements - . Increase version to v2r2 - -! ======================== Particle2MCTruth v2r1 2009-07-15 ================= - -! 2009-07-13 - Juan PALACIOS - - src/MCMatchObjP2MCRelator.h - . Make an IIncidentListener - - src/MCMatchObjP2MCRelator.cpp - . IncidentListener now uses to trigger loading of input relations tables and - clearing of LoKi::MCMatchObj data member. Considerably speeds up - associations. Move initialization of MCMatchObj to initialize method. - - cmt/requirements - . Increase version to v2r1 - -! ======================== Particle2MCTruth v2r0 2009-07-02 ================= - -! 2009-06-30 - Juan PALACIOS - - - Add new class DecayLines (P2MCP/DecayLines.h) - . Wrapper around vector of vectors of const LHCb::MCParticle*. It splits and - sorts an input single vector on construction. The sorting and splitting is - according to position in decay tree. There is no write access to the - internal data structure, so the particles are guaranteed to be sorted and - split on construction of an instance of P2MCP::DecayLines. - - - P2MCP/IP2MCP.h - . Return P2MCP::DecayLines instead of P2MCP::Types::FlatTrees. - - - P2MCP/P2MCPBase,h, src/Lib/P2MCPBase.cpp - . Adapt to interface changes. - . No sort methods needed any more since DecayLines is self-sorted. Derived - classes only have to implement the isMatched method. - - - src/MCMatchObjP2MCRelator{.cpp, .h} - . Remove sort methods. Class now only needs to take care od deciding if an - MCParticle is matched to a Particle. - - - dict/Particle2MCTruthDict.xml - . Add dict for P2MCP::DecayLines and remove FlatTrees dicts. - - - cmt/requirements - . Increase version to v2r0 - -! 2009-06-25 - Juan PALACIOS - - P2MCP/P2MCPBase.h, P2MCP/IP2MCP.h - . Fix header location in doxygen - - cmt/requirements - . Increase version to v1r0p1 - -! ======================== Particle2MCTruth v1r0 2009-05-11 ================= - -! 2009-05-07 - Juan PALACIOS - - P2MCP/P2MCPBase.h, src/Lib/P2MCPBase.cpp - . Add implementation for IParticle2MCAssociator::operator()(const LHCb::Particle*) - -! 2009-04-28 - Juan PALACIOS - - MCMatchObjP2MCRelator - . Input relations tables are now a property, "RelTableLocations". The - tool accepts ProtoParticle->MCP and Particle->MCP (LoKi::Types::TablePP2MC - and LoKi::Types::TableP2MC respectively). By default, tool loads - "Relations/" + LHCb::ProtoParticleLocation::Charged, - "Relations/" + LHCb::ProtoParticleLocation::Upstream and - "Relations/" + LHCb::ProtoParticleLocation::Neutrals using the DataOnDemand - service, as before. - -! 2009-04-16 - Juan PALACIOS - - src/P2MCRelatorAlg.cpp - - src/P2MCRelatorAlg.h - . New GaudiAlgorithm that takes an MCParticle and Particle location, and uses - an IP2MCP to create a Particle2MCParticle::Table of associations between - Particles and MCParticles that pass IP2MCP::isMatched. - -! 2009-03-31 - Juan PALACIOS - - P2MCP/IP2MCP.h - . Now inherits from IParticle2MCAssociator (DaVinciMCKernel) - - P2MCP/P2MCPBase.h - . restRelatedMCP -> relatedMCP to conform to Particle2MCAssociator interface. - - src/Lib/P2MCPBase.cpp - . Add method relatedMCP(const LHCb::Particle* particle, - const std::string& mcParticleLocation) - -! 2009-03-13 - Juan PALACIOS - - P2MCP/IP2MCP.h - . Clean up. Return P2MCPTypes::FlatTrees - - P2MCP/P2MCPBase.h, src/Lib/P2MCP/P2MCPBase.cpp - . Big changes adapt to IP2MCP. - - P2MCP/P2MCPTypes.h - . Nested P2MCP::Types namespace. - . Clean up. - - Add P2MCP/P2MCPFunctors.h - . Useful sorting and other functors in P2MCP::Functors namespace. - - src/MCMatchObjP2MCRelator.h src/MCMatchObjP2MCRelator.cpp - . Use new functors - - dict/Particle2MCTruthDict{.h, .xml} - . Add dicts and instantiations for P2MCP::Types::FlatTree and P2MCP::Types::FlatTree -! 2009-03-10 - Juan PALACIOS - - cmt/requirements - . Add linker library and export include P2MCP - - Add: - . P2MCP/IP2MCP.h : IParticle2MCAssociator.h clone - . P2MCP/P2MCPBase.h : Base implementation of IP2MCP - . src/Lib/P2MCPBase.cpp : " " " " - . dict/Particle2MCTruthDict{.h, .xml} : dictionaries for IP2MCP - . P2MCP/P2MCPTypes.h : typedefs for IP2MCP - - src/MCMatchObjP2MCRelator{.cpp, .h} - . Inherit from IP2MCP and P2MCPBase - -! 2009-03-06 - Juan PALACIOS - - src/MCMatchObjP2MCRelator.h - . Add virtual private sort methods to over-ride those defined in Particle2MCAssociatorBase - - src/MCMatchObjP2MCRelator.cpp - . Implement sort methods and add relations tables for PP->MCP - -! 2009-03-04 - Juan PALACIOS - - First import. Add MCMatchObjP2MCRelator, uses LoKi stuff. diff --git a/Phys/Particle2MCTruth/include/P2MCP/DecayLines.h b/Phys/Particle2MCTruth/include/P2MCP/DecayLines.h deleted file mode 100644 index 27e0e7c04c303cb9c4d152cf796d2d3aca04397a..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/include/P2MCP/DecayLines.h +++ /dev/null @@ -1,61 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCP_DECAYLINES_H -#define P2MCP_DECAYLINES_H 1 - -// Include files -#include "P2MCP/P2MCPFunctors.h" -#include "P2MCP/P2MCPTypes.h" -/** @class DecayLines DecayLines.h P2MCP/DecayLines.h - * - * Class containing sorted, segmented sequences of LHCb::MCParticles. - * Underying data structure is a container of LHCb::MCParticle::ConstVectors. - * Each entry contains MCParticles that come from one line in a decay tree. - * They are sorted according to position in that line, with the parent in - * first position and each generation following. - * - * @author Juan PALACIOS - * @date 2009-06-30 - */ - -namespace P2MCP { - - class DecayLines { - public: - inline explicit DecayLines( const LHCb::MCParticle::ConstVector& mcParticles ) - : m_treeSorter(), m_lines( m_treeSorter( mcParticles ) ) {} - - inline explicit DecayLines( const LHCb::MCParticle::Container& mcParticles ) - : m_treeSorter(), m_lines( m_treeSorter( mcParticles ) ) {} - - inline DecayLines() : m_lines( 0 ) {} - - virtual ~DecayLines() {} ///< Destructor - - inline size_t size() { return m_lines.size(); } - - inline bool empty() { return m_lines.empty(); } - - inline LHCb::MCParticle::ConstVector& operator[]( size_t index ) { return m_lines[index]; } - - inline P2MCP::Types::FlatTrees::const_iterator begin() { return m_lines.begin(); } - - inline P2MCP::Types::FlatTrees::const_iterator end() { return m_lines.begin(); } - - private: - P2MCP::Functors::SortIntoTrees<P2MCP::Functors::InTree, P2MCP::Functors::SortInTrees> m_treeSorter; - - P2MCP::Types::FlatTrees m_lines; - }; - -} // namespace P2MCP - -#endif // P2MCP_DECAYLINES_H diff --git a/Phys/Particle2MCTruth/include/P2MCP/IP2MCP.h b/Phys/Particle2MCTruth/include/P2MCP/IP2MCP.h deleted file mode 100644 index 9bbf97f145b6b2261bea9ac8d3bfa0350daaa0ac..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/include/P2MCP/IP2MCP.h +++ /dev/null @@ -1,123 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCP_IP2MCP_H -#define P2MCP_IP2MCP_H 1 - -// Include files -// from STL -#include <string> - -// from Gaudi -#include "GaudiKernel/IAlgTool.h" -// from LHCb -#include "Event/MCParticle.h" -// from DaVinciMCKernel -#include "Kernel/IParticle2MCAssociator.h" -// from Particle2MCTruth -#include "P2MCP/DecayLines.h" - -namespace LHCb { - class Particle; -} - -/** @class IP2MCP IP2MCP.h P2MCP/IP2MCP.h - * - * Tool interface to generate weighted associations between one or many - * LHCb::Particles and return them to the user in different formats. The - * user is in control of the resulting associations and the invoking interface - * methods should have no side-effects. TES access should be read-only. - * Interface implementations should not populate the TES with their results - * directly or indirectly, and should not have any runtime configuration - * that alters the result, except for the assumed TES location of the - * LHCb::MCParticles for the relevant methods. - * - * @author Juan PALACIOS - * @date 2009-01-19 - */ -class GAUDI_API IP2MCP : virtual public IParticle2MCAssociator { -public: - DeclareInterfaceID( IP2MCP, 2, 0 ); - - /** - * Calculate and return the weighted associations between an - * LHCb::Particle and some LHCb::MCParticles from a TES locaiton. - * @param particle LHCb::Particle* to be associated - * @return P2MCP::Types::FlatTrees containing - * tree-sorted weighted relations between the - * LHCb::Particle and the LCHb::MCParticles - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 2009-02-02 - * - **/ - virtual P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle ) const = 0; - - /** - * - * Calculate and return the weighted associations between an - * LHCb::Particle and some LHCb::MCParticles from a TES locaiton. - * @param particle LHCb::Particle* to be associated - * @param mcParticleLocation TES location of LHCb::MCParticles to base the - * association on. - * @return P2MCP::Types::FlatTrees containing tree-sorted - * weighted relations between the LHCb::Particle and the LCHb::MCParticles - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 2009-02-02 - * - **/ - virtual P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, - const std::string& mcParticleLocation ) const = 0; - - /** - * - * Calculate and return the weighted associations between a container of - * LHCb::Particles and a container of LHCb::MCParticles. - * @param particles Container of LHCb::Particles to be associated - * @param mcParticles Container of LHCb::MCParticles to base the - * association on. - * @return P2MCP::Types::FlatTrees containing tree-sorted - * relations between the LHCb::Particles and the LCHb::MCParticles - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 2009-02-02 - * - **/ - virtual P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::ConstVector& mcParticles ) const = 0; - - /** - * - * Calculate and return the weighted associations between a container of - * LHCb::Particles and a container of LHCb::MCParticles. - * @param particles Container of LHCb::Particles to be associated - * @param mcParticles Container of LHCb::MCParticles to base the - * association on. - * @return P2MCP::Types::FlatTrees Relations table containing tree-sorted - * relations between the LHCb::Particles and the LCHb::MCParticles - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 2009-02-02 - * - **/ - virtual P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::Container& mcParticles ) const = 0; - - /** - * Calculate the association between an LHCb::Particle and an - * LHCb::MCParticle. - * - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 2009-02-02 - * - **/ - virtual bool isMatched( const LHCb::Particle* particle, const LHCb::MCParticle* mcParticle ) const = 0; - -protected: - virtual ~IP2MCP() {} ///< virtual and protected destructor -}; -#endif // P2MCP_IP2MCP_H diff --git a/Phys/Particle2MCTruth/include/P2MCP/P2MCPBase.h b/Phys/Particle2MCTruth/include/P2MCP/P2MCPBase.h deleted file mode 100644 index 99e78380bdaf6691a4d0f7b056e707cf98b632b2..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/include/P2MCP/P2MCPBase.h +++ /dev/null @@ -1,99 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCP_P2MCPBASE_H -#define P2MCP_P2MCPBASE_H 1 - -// Include files -// from Gaudi -#include "GaudiAlg/GaudiTool.h" -// local -#include "P2MCP/IP2MCP.h" // Interface - -/** @class P2MCPBase P2MCPBase.h P2MCP/P2MCPBase.h - * - * Common implementation for descendants of IParticle2MCAssociator. - * Mainly inline helper methods for common implementation of host of - * similar methods in the interface. - * Set of methods is self-consistent. Derived classes only need to implement - * method - * @code - * bool isMatched(const LHCb::Particle*, const LHCb::MCParticle) - * @endcode - * and - * - * @author Juan PALACIOS - * @date 2009-01-30 - */ -class GAUDI_API P2MCPBase : public extends1<GaudiTool, IP2MCP> { -public: - /// Standard constructor - P2MCPBase( const std::string& type, const std::string& name, const IInterface* parent ); - - StatusCode initialize() override; - - StatusCode finalize() override; - - virtual ~P2MCPBase(); - - const LHCb::MCParticle* relatedMCP( const LHCb::Particle* particle ) const override; - - const LHCb::MCParticle* operator()( const LHCb::Particle* particle ) const override; - - const LHCb::MCParticle* relatedMCP( const LHCb::Particle*, const std::string& mcParticleLocation ) const override; - - const LHCb::MCParticle* relatedMCP( const LHCb::Particle* particle, - const LHCb::MCParticle::ConstVector& mcParticles ) const override; - - const LHCb::MCParticle* relatedMCP( const LHCb::Particle* particle, - const LHCb::MCParticle::Container& mcParticles ) const override; - - P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle ) const override; - - P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, const std::string& mcParticleLocation ) const override; - - P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::ConstVector& mcParticles ) const override; - - P2MCP::DecayLines relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::Container& mcParticles ) const override; - - bool isMatched( const LHCb::Particle* particle, const LHCb::MCParticle* mcParticle ) const override; - -private: - inline LHCb::MCParticle::Container* i_MCParticles( const std::string& location ) const { - return ( exist<LHCb::MCParticle::Container>( location ) ) ? get<LHCb::MCParticle::Container>( location ) : 0; - } - - template <typename Iter> - const LHCb::MCParticle* i_bestMCP( const LHCb::Particle* particle, Iter begin, Iter end ) const { - P2MCP::DecayLines trees = i_relatedMCPs( particle, begin, end ); - return ( trees.empty() ) ? 0 : trees[0].back(); - } - - template <typename Iter> - P2MCP::DecayLines i_relatedMCPs( const LHCb::Particle* particle, Iter begin, Iter end ) const { - if ( 0 != particle ) { - LHCb::MCParticle::ConstVector mcps; - for ( Iter iMCP = begin; iMCP != end; ++iMCP ) { - const bool match = isMatched( particle, *iMCP ); - if ( match ) mcps.push_back( *iMCP ); - } - return P2MCP::DecayLines( mcps ); - } else { - Warning( "No particle!" ).ignore(); - return P2MCP::DecayLines(); - } - } - -private: - std::string m_defMCLoc; -}; -#endif // P2MCP_P2MCPBASE_H diff --git a/Phys/Particle2MCTruth/include/P2MCP/P2MCPFunctors.h b/Phys/Particle2MCTruth/include/P2MCP/P2MCPFunctors.h deleted file mode 100644 index 92bb655fc6ecfd4bf94e895a3f5ba312ab0f7670..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/include/P2MCP/P2MCPFunctors.h +++ /dev/null @@ -1,77 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCP_P2MCPFUNCTORS_H -#define P2MCP_P2MCPFUNCTORS_H 1 - -// Include files -#include "LoKi/BuildMCTrees.h" -#include "P2MCP/P2MCPTypes.h" -#include <algorithm> -#include <functional> -/** @namespace P2MCP::Functors P2MCP/P2MCPFunctors.h - * - * - * @author Juan Palacios - * @date 2009-03-13 - */ -namespace P2MCP { - namespace Functors { - - struct SortInTrees : public std::binary_function<const LHCb::MCParticle*, const LHCb::MCParticle*, bool> { - - bool operator()( const LHCb::MCParticle* p1, const LHCb::MCParticle* p2 ) const { - LoKi::MCParticles::FromMCDecayTree fromDecay( p1 ); - return fromDecay( p2 ); - } - }; - - struct InTree : public std::unary_function<const LHCb::MCParticle*, bool> { - - InTree( const LHCb::MCParticle* head ) : m_head( head ) {} - - bool operator()( const LHCb::MCParticle* mc ) const { - P2MCP::Functors::SortInTrees sorter; - return sorter( m_head, mc ); - } - - private: - InTree() {} - - private: - const LHCb::MCParticle* m_head; - }; - - template <class Selector, class Sorter> - struct SortIntoTrees { - - template <class InputContainer> - P2MCP::Types::FlatTrees operator()( const InputContainer& mcps ) const { - LHCb::MCParticle::ConstVector heads = LoKi::MCTrees::buildTrees( mcps ); - - P2MCP::Types::FlatTrees output; - - LHCb::MCParticle::ConstVector::iterator itHead = heads.begin(); - - for ( ; itHead != heads.end(); ++itHead ) { - Selector selector( *itHead ); - P2MCP::Types::FlatTree tree; - std::copy_if( mcps.begin(), mcps.end(), std::back_inserter( tree ), std::cref( selector ) ); - std::stable_sort( tree.begin(), tree.end(), Sorter() ); - output.push_back( tree ); - } - return output; - } - }; - - } // namespace Functors - -} // namespace P2MCP -#endif // P2MCP_P2MCPFUNCTORS_H diff --git a/Phys/Particle2MCTruth/include/P2MCP/P2MCPTypes.h b/Phys/Particle2MCTruth/include/P2MCP/P2MCPTypes.h deleted file mode 100644 index 42d5ae99d1b377b4819c0ce8ed2a0683b7e4db7f..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/include/P2MCP/P2MCPTypes.h +++ /dev/null @@ -1,50 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCP_P2MCPTYPES_H -#define P2MCP_P2MCPTYPES_H 1 - -// Include files -#include "Event/MCParticle.h" -#include "Event/Particle.h" -#include "Kernel/MCAssociation.h" -#include "Relations/Relation.h" -#include "Relations/Relation1D.h" -#include <vector> -/** @namespace P2MCPTypes P2MCP/P2MCPTypes.h - * - * - * Namespace containing types corresponding to the Particle -> MCParticle - * uni-directional weighted relationship. - * - * @author Juan PALACIOS - * @date 2009-03-10 - */ -namespace P2MCP { - - namespace Types { - - typedef LHCb::MCParticle::ConstVector FlatTree; - typedef std::vector<FlatTree> FlatTrees; - - typedef LHCb::Relation1D<LHCb::Particle, LHCb::MCParticle> Table; - - typedef Relations::Relation<LHCb::Particle, LHCb::MCParticle> LightTable; - typedef Table::Range Range; - typedef Table::IBase::Entry Relation; - typedef Table::IBase::Entries Relations; - typedef Table::To To; - typedef Table::From From; - - typedef std::vector<MCAssociation> ToVector; - } // namespace Types - -} // namespace P2MCP -#endif // P2MCP_P2MCPTYPES_H diff --git a/Phys/Particle2MCTruth/src/Lib/P2MCPBase.cpp b/Phys/Particle2MCTruth/src/Lib/P2MCPBase.cpp deleted file mode 100644 index 70862104a6da6e4c08d67a434b75f90bc8b2ab66..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/src/Lib/P2MCPBase.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*****************************************************************************\ -* (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 "P2MCP/P2MCPBase.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : P2MCPBase -// -// 2009-01-30 : Juan PALACIOS -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -P2MCPBase::P2MCPBase( const std::string& type, const std::string& name, const IInterface* parent ) - : base_class( type, name, parent ), m_defMCLoc( LHCb::MCParticleLocation::Default ) { - declareProperty( "MCParticleDefaultLocation", m_defMCLoc ); -} -//============================================================================= -const LHCb::MCParticle* P2MCPBase::relatedMCP( const LHCb::Particle* particle ) const { - const LHCb::MCParticle::Container* mcParticles = i_MCParticles( m_defMCLoc ); - return ( 0 == mcParticles ) ? 0 : i_bestMCP( particle, mcParticles->begin(), mcParticles->end() ); -} -//============================================================================= -const LHCb::MCParticle* P2MCPBase::operator()( const LHCb::Particle* particle ) const { - const LHCb::MCParticle::Container* mcParticles = i_MCParticles( m_defMCLoc ); - return ( 0 == mcParticles ) ? 0 : i_bestMCP( particle, mcParticles->begin(), mcParticles->end() ); -} -//============================================================================= -const LHCb::MCParticle* P2MCPBase::relatedMCP( const LHCb::Particle* particle, - const std::string& mcParticleLocation ) const { - LHCb::MCParticle::Container* mcps = i_MCParticles( mcParticleLocation ); - return ( 0 != mcps ) ? i_bestMCP( particle, mcps->begin(), mcps->end() ) : 0; -} -//============================================================================= -const LHCb::MCParticle* P2MCPBase::relatedMCP( const LHCb::Particle* particle, - const LHCb::MCParticle::ConstVector& mcParticles ) const { - return i_bestMCP( particle, mcParticles.begin(), mcParticles.end() ); -} -//============================================================================= -const LHCb::MCParticle* P2MCPBase::relatedMCP( const LHCb::Particle* particle, - const LHCb::MCParticle::Container& mcParticles ) const { - return i_bestMCP( particle, mcParticles.begin(), mcParticles.end() ); -} -//============================================================================= -P2MCP::DecayLines P2MCPBase::relatedMCPs( const LHCb::Particle* particle ) const { - return relatedMCPs( particle, m_defMCLoc ); -} -//============================================================================= -P2MCP::DecayLines P2MCPBase::relatedMCPs( const LHCb::Particle* particle, - const std::string& mcParticleLocation ) const { - LHCb::MCParticle::Container* mcps = i_MCParticles( mcParticleLocation ); - if ( 0 != mcps ) { - return i_relatedMCPs( particle, mcps->begin(), mcps->end() ); - } else { - return P2MCP::DecayLines(); - } -} -//============================================================================= -P2MCP::DecayLines P2MCPBase::relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::ConstVector& mcParticles ) const { - return i_relatedMCPs( particle, mcParticles.begin(), mcParticles.end() ); -} -//============================================================================= -P2MCP::DecayLines P2MCPBase::relatedMCPs( const LHCb::Particle* particle, - const LHCb::MCParticle::Container& mcParticles ) const { - return i_relatedMCPs( particle, mcParticles.begin(), mcParticles.end() ); -} -//============================================================================= -bool P2MCPBase::isMatched( const LHCb::Particle* /*particle */, const LHCb::MCParticle* /* mcParticle */ ) const { - return false; -} -//============================================================================= -// initialize -//============================================================================= -StatusCode P2MCPBase::initialize() { return base_class::initialize(); } -//============================================================================= -// finalize -//============================================================================= -StatusCode P2MCPBase::finalize() { return base_class::finalize(); } -//============================================================================= -// Destructor -//============================================================================= -P2MCPBase::~P2MCPBase() {} -//============================================================================= diff --git a/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.cpp b/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.cpp deleted file mode 100644 index ae946c758c7e2cd898ccdefc2013ba46fe68b1c7..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/*****************************************************************************\ -* (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 - -// LoKi -#include "LoKi/IReporter.h" -// P2MCP -#include "P2MCP/P2MCPFunctors.h" -// local -#include "MCMatchObjP2MCRelator.h" -// boost -#include "boost/algorithm/string.hpp" - -//----------------------------------------------------------------------------- -// Implementation file for class : MCMatchObjP2MCRelator -// -// 2009-03-04 : Juan PALACIOS -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -MCMatchObjP2MCRelator::MCMatchObjP2MCRelator( const std::string& type, const std::string& name, - const IInterface* parent ) - : base_class( type, name, parent ), m_reporter( NULL ), m_matcher( NULL ), m_loaded( false ) { - m_tables.clear(); - m_tables.push_back( "Relations/" + LHCb::ProtoParticleLocation::Charged ); - m_tables.push_back( "Relations/" + LHCb::ProtoParticleLocation::Upstream ); - m_tables.push_back( "Relations/" + LHCb::ProtoParticleLocation::Neutrals ); - m_tables.push_back( "Turbo/Relations/Turbo/Protos" ); - m_tables.push_back( "Turbo/Relations/Rec/ProtoP/Charged" ); - declareProperty( "RelTableLocations", m_tables ); - // setProperty( "OutputLevel", 2 ); -} - -//============================================================================= - -StatusCode MCMatchObjP2MCRelator::initialize() { - StatusCode sc = base_class::initialize(); - if ( sc.isFailure() ) return sc; - - m_reporter = tool<LoKi::IReporter>( "LoKi::Reporter", this ); - - if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << "RelTableLocations: " << endmsg; - for ( Addresses::const_iterator iAddr = m_tables.begin(); iAddr != m_tables.end(); ++iAddr ) { - verbose() << "\t" << *iAddr << endmsg; - } - } - - // Incident service call back - incSvc()->addListener( this, IncidentType::EndEvent ); - - // create the new matcher - m_matcher = new LoKi::MCMatchObj( "P2MCRelator", m_reporter ); - - // increment the reference counter - m_matcher->addRef(); - - m_loaded = false; - m_pLocDoneMap.clear(); - - // return - return sc; -} - -//============================================================================= - -StatusCode MCMatchObjP2MCRelator::finalize() { - m_matcher->clear(); - long count = m_matcher->refCount(); - while ( 0 < count ) { count = m_matcher->release(); } - m_matcher = NULL; - m_loaded = false; - m_pLocDoneMap.clear(); - return base_class::finalize(); -} - -//============================================================================= - -bool MCMatchObjP2MCRelator::isMatched( const LHCb::Particle* particle, const LHCb::MCParticle* mcParticle ) const { - if ( !particle ) { - mcParticle = NULL; - return false; - } - - if ( !m_loaded ) { - addTables(); - m_loaded = true; - } - - // First try the DST way, with the default tables - bool match = matcher()->match( particle, mcParticle ); - if ( !match ) { - // No match found the 'normal' way. Try the Particle location dependent (uDST) way. - addTable( particle ); - match = matcher()->match( particle, mcParticle ); - } - - if ( msgLevel( MSG::DEBUG ) ) { - if ( match ) { - debug() << " -> Matched Particle PID " << particle->particleID().pid() << " to MCParticle PID " - << mcParticle->particleID().pid() << endmsg; - } else if ( msgLevel( MSG::VERBOSE ) ) { - verbose() << " -> No match for Particle PID " << particle->particleID().pid() << endmsg; - } - } - - return match; -} - -//============================================================================= - -void MCMatchObjP2MCRelator::addTable( const LHCb::Particle* particle ) const { - // Try Particle specific locations for relations tables - std::string pLoc = objectLocation( particle->parent() ); - if ( !m_pLocDoneMap[pLoc] ) { - m_pLocDoneMap[pLoc] = true; - - // Form the relations TES location for this Particles location - boost::replace_all( pLoc, "/Particles", "/P2MCPRelations" ); - - // load the table - loadTable( pLoc ); - } -} - -//============================================================================= - -void MCMatchObjP2MCRelator::addTables() const { - for ( Addresses::const_iterator item = m_tables.begin(); item != m_tables.end(); ++item ) { loadTable( *item ); } - m_loaded = true; -} - -//============================================================================= - -void MCMatchObjP2MCRelator::loadTable( const std::string& address ) const { - // First try respecting the RootInTES settings. - if ( exist<LoKi::Types::TablePP2MC>( address ) ) { - LoKi::Types::TablePP2MC* table = get<LoKi::Types::TablePP2MC>( address ); - m_matcher->addMatchInfo( table ); - } else if ( exist<LoKi::Types::TableP2MC>( address ) ) { - LoKi::Types::TableP2MC* table = get<LoKi::Types::TableP2MC>( address ); - m_matcher->addMatchInfo( table ); - } - // If that fails, try without RootInTES - else if ( exist<LoKi::Types::TablePP2MC>( address, false ) ) { - LoKi::Types::TablePP2MC* table = get<LoKi::Types::TablePP2MC>( address, false ); - m_matcher->addMatchInfo( table ); - } else if ( exist<LoKi::Types::TableP2MC>( address, false ) ) { - LoKi::Types::TableP2MC* table = get<LoKi::Types::TableP2MC>( address, false ); - m_matcher->addMatchInfo( table ); - } -} - -//============================================================================= - -void MCMatchObjP2MCRelator::handle( const Incident& ) { - m_matcher->clear(); - m_loaded = false; - m_pLocDoneMap.clear(); -} - -//============================================================================= -// Destructor -//============================================================================= -MCMatchObjP2MCRelator::~MCMatchObjP2MCRelator() {} -//============================================================================= - -// Declaration of the Tool Factory -DECLARE_COMPONENT( MCMatchObjP2MCRelator ) - -//============================================================================= diff --git a/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.h b/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.h deleted file mode 100644 index 43538398683ebdbd490b0ae4e14f160c8d12a767..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/src/MCMatchObjP2MCRelator.h +++ /dev/null @@ -1,92 +0,0 @@ -/*****************************************************************************\ -* (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 MCMATCHOBJP2MCRELATOR_H -#define MCMATCHOBJP2MCRELATOR_H 1 - -// Include files -#include <functional> -#include <map> -#include <string> - -// from Gaudi -#include "LoKi/MCMatch.h" -#include "LoKi/MCMatchObj.h" -#include "LoKi/MCParticles.h" -#include "P2MCP/P2MCPBase.h" -#include <GaudiKernel/IIncidentListener.h> -#include <GaudiKernel/IIncidentSvc.h> -// forward declarations -namespace LoKi { - class IReporter; -} - -/** @class MCMatchObjP2MCRelator MCMatchObjP2MCRelator.h - * - * - * @author Juan PALACIOS - * @date 2009-03-04 - */ -class MCMatchObjP2MCRelator : public extends1<P2MCPBase, IIncidentListener> { - -public: - /// Standard constructor - MCMatchObjP2MCRelator( const std::string& type, const std::string& name, const IInterface* parent ); - - virtual ~MCMatchObjP2MCRelator(); ///< Destructor - - StatusCode initialize() override; - - StatusCode finalize() override; - -public: - bool isMatched( const LHCb::Particle* particle, const LHCb::MCParticle* mcParticle ) const override; - -public: - void handle( const Incident& ) override; - -private: - inline LoKi::MCMatch matcher() const { return LoKi::MCMatch( m_matcher ); } - - void addTables() const; - - void addTable( const LHCb::Particle* particle ) const; - - void loadTable( const std::string& address ) const; - - void printMCPIDs( const LHCb::MCParticle::ConstVector& mcps ) const { - always() << "==================================" << endmsg; - for ( LHCb::MCParticle::ConstVector::const_iterator mcp = mcps.begin(); mcp != mcps.end(); ++mcp ) { - always() << "\tMCP PID " << ( *mcp )->particleID().pid() << endmsg; - } - } - - /** Returns the full location of the given object in the Data Store - * - * @param pObj Data object - * - * @return Location of given data object - */ - inline std::string objectLocation( const DataObject* pObj ) const { - return ( !pObj ? "Null DataObject !" : ( pObj->registry() ? pObj->registry()->identifier() : "UnRegistered" ) ); - } - -private: - LoKi::IReporter* m_reporter; - LoKi::MCMatchObj* m_matcher; - - typedef std::vector<std::string> Addresses; - Addresses m_tables; - - mutable bool m_loaded; - mutable std::map<std::string, bool> m_pLocDoneMap; -}; - -#endif // MCMATCHOBJP2MCPRELATOR_H diff --git a/Phys/Particle2MCTruth/src/P2MCRelatorAlg.cpp b/Phys/Particle2MCTruth/src/P2MCRelatorAlg.cpp deleted file mode 100644 index e02bab8ddeca298fb36288282e5c62cb8b370246..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/src/P2MCRelatorAlg.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/*****************************************************************************\ -* (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 "P2MCRelatorAlg.h" - -//----------------------------------------------------------------------------- -// Implementation file for class : P2MCRelatorAlg -// -// 2009-04-16 : Juan PALACIOS -//----------------------------------------------------------------------------- - -//============================================================================= -// Standard constructor, initializes variables -//============================================================================= -P2MCRelatorAlg::P2MCRelatorAlg( const std::string& name, ISvcLocator* pSvcLocator ) - : GaudiAlgorithm( name, pSvcLocator ) - , m_mcpLocation( LHCb::MCParticleLocation::Default ) - , m_p2mcp( NULL ) - , m_p2mcpType( "MCMatchObjP2MCRelator" ) { - declareProperty( "ParticleLocations", m_particleLocations ); - declareProperty( "MCParticleLocation", m_mcpLocation ); - declareProperty( "IP2MCP", m_p2mcpType ); - // setProperty( "OutputLevel", 2 ); -} - -//============================================================================= -// Destructor -//============================================================================= -P2MCRelatorAlg::~P2MCRelatorAlg() {} - -//============================================================================= -// Initialization -//============================================================================= -StatusCode P2MCRelatorAlg::initialize() { - const StatusCode sc = GaudiAlgorithm::initialize(); - if ( sc.isFailure() ) return sc; - - m_p2mcp = tool<IP2MCP>( m_p2mcpType, "MCMatcherForP2MCRelatorAlg" ); - - return sc; -} - -//============================================================================= -// Main execution -//============================================================================= -StatusCode P2MCRelatorAlg::execute() { - if ( msgLevel( MSG::DEBUG ) ) debug() << "==> Execute" << endmsg; - - m_mcParticles = getIfExists<LHCb::MCParticle::Container>( m_mcpLocation, false ); - if ( !m_mcParticles ) { return Warning( "Found no MCParticles in " + m_mcpLocation, StatusCode::SUCCESS, 0 ); } - - // Clear the tables - m_tables.clear(); - - // Create and fill the tables - typedef std::vector<std::string> StringVector; - for ( StringVector::const_iterator iLoc = m_particleLocations.begin(); iLoc != m_particleLocations.end(); ++iLoc ) { - const LHCb::Particle::Range particles = getIfExists<LHCb::Particle::Range>( *iLoc ); - if ( !particles.empty() ) { i_particleLoop( particles.begin(), particles.end() ); } - } - - // Loop over the final saved tables and save them - for ( Tables::iterator iT = m_tables.begin(); iT != m_tables.end(); ++iT ) { - ( *iT ).second.i_sort(); - Particle2MCParticle::Table* table = new Particle2MCParticle::Table( ( *iT ).second ); - put( table, ( *iT ).first ); - } - - return StatusCode::SUCCESS; -} - -//============================================================================= - -std::string P2MCRelatorAlg::relationsLocation( const DataObject* pObj ) const { - // Get the parent container TES location - std::string pLoc = objectLocation( pObj ); - if ( pLoc.empty() ) { return pLoc; } - - // Form the relations TES location for this location - boost::replace_all( pLoc, "/Particles", "/P2MCPRelations" ); - - // return the new location - return pLoc; -} - -//============================================================================= - -// Declaration of the Algorithm Factory -DECLARE_COMPONENT( P2MCRelatorAlg ) - -//============================================================================= diff --git a/Phys/Particle2MCTruth/src/P2MCRelatorAlg.h b/Phys/Particle2MCTruth/src/P2MCRelatorAlg.h deleted file mode 100644 index e61fabf7494febb66b8440b73aa4cbd609ed9948..0000000000000000000000000000000000000000 --- a/Phys/Particle2MCTruth/src/P2MCRelatorAlg.h +++ /dev/null @@ -1,117 +0,0 @@ -/*****************************************************************************\ -* (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 P2MCRELATORALG_H -#define P2MCRELATORALG_H 1 - -// from Gaudi -#include "GaudiAlg/GaudiAlgorithm.h" -// from LHCb -#include "Kernel/Particle2MCParticle.h" -// from P2MCP -#include "P2MCP/IP2MCP.h" -// boost -#include "boost/algorithm/string.hpp" - -/** @class P2MCRelatorAlg P2MCRelatorAlg.h - * - * GaudiAlgorithm that takes an MCParticle and Particle location, and uses - * an IP2MCP to create a Particle2MCParticle::Table of associations between - * Particles and MCParticles that pass IP2MCP::isMatched. - * The relations table is written to the parent of ParticleLocation + "P2MCPRelations". - * - * <b> Properties</b> - * - * ParticleLocations: TES location of input LHCb::Particles - * - * MCParticleLocation: TES location of input LHCb::Particles. Default: LHCb::MCParticleLocation::Default - * - * IP2MCP: Implementation name of IP2MCP interface. Default: MCMatchObjP2MCRelator - * - * <b>Example</b>: Create relations table for LHCb::MCParticles associated to - * LHCb::Particles in "Phys/DC06selBd2Jpsi2MuMu_Kst2KPi/Particles". Table is - * written to "Phys/DC06selBd2Jpsi2MuMu_Kst2KPi/P2MCPRelations" - * - * @code - * from Configurables import P2MCRelatorAlg - * p2mc = P2MCRelatorAlg() - * p2mc.ParticleLocations = ["Phys/DC06selBd2Jpsi2MuMu_Kst2KPi/Particles"] - * # Add it to a selection sequence - * seq = GaudiSequencer('SeqDC06selBd2Jpsi2MuMu_Kst2KPi') - * seq.Members += [p2mc] - * @endcode - * - * - * @author Juan PALACIOS - * @date 2009-04-16 - */ -class P2MCRelatorAlg : public GaudiAlgorithm { - -public: - /// Standard constructor - P2MCRelatorAlg( const std::string& name, ISvcLocator* pSvcLocator ); - - virtual ~P2MCRelatorAlg(); ///< Destructor - - StatusCode initialize() override; ///< Algorithm initialization - StatusCode execute() override; ///< Algorithm execution - -private: - /** Returns the full location of the given object in the Data Store - * - * @param pObj Data object - * - * @return Location of given data object - */ - inline std::string objectLocation( const DataObject* pObj ) const { - return ( !pObj ? "" : ( pObj->registry() ? pObj->registry()->identifier() : "" ) ); - } - - template <class Iter> - void i_particleLoop( const Iter begin, const Iter end, const std::string level = "" ) { - for ( Iter it = begin; it != end; ++it ) { - if ( msgLevel( MSG::DEBUG ) ) - debug() << level << "-> " << objectLocation( ( *it )->parent() ) << " : key=" << ( *it )->key() - << " PID=" << ( *it )->particleID().pid() << endmsg; - for ( LHCb::MCParticle::Container::const_iterator iMCP = m_mcParticles->begin(); iMCP != m_mcParticles->end(); - ++iMCP ) { - if ( m_p2mcp->isMatched( *it, *iMCP ) ) { - // Get the TES location for the relations for this Particle - const std::string pLoc = relationsLocation( ( *it )->parent() ); - if ( msgLevel( MSG::DEBUG ) ) - debug() << level << " -> Found MCMatch : key=" << ( *iMCP )->key() - << " MCPID=" << ( *iMCP )->particleID().pid() << " : Filling " << pLoc << endmsg; - if ( !pLoc.empty() ) { - // Fill table for this location - m_tables[pLoc].i_push( *it, *iMCP ); - } else { - Warning( "Particle parent not in the TES" ).ignore(); - } - } - } - // Recursively save the relations for the daughters - const SmartRefVector<LHCb::Particle>& daughters = ( *it )->daughters(); - if ( !daughters.empty() ) { i_particleLoop( daughters.begin(), daughters.end(), level + " " ); } - } - } - - std::string relationsLocation( const DataObject* pObj ) const; - -private: - std::vector<std::string> m_particleLocations; - std::string m_mcpLocation; - IP2MCP* m_p2mcp; - std::string m_p2mcpType; - typedef std::map<std::string, Particle2MCParticle::LightTable> Tables; - Tables m_tables; - LHCb::MCParticle::Container* m_mcParticles; -}; - -#endif // P2MCRELATORALG_H