From eb7f30c302f28e63c1e24a74bbe2b3a0ddcfcb7d Mon Sep 17 00:00:00 2001 From: cprouve <cprouve@cern.ch> Date: Wed, 13 Dec 2023 12:37:15 +0100 Subject: [PATCH 1/4] delete IBTaggingTool.h and all the places where it is called --- .../dict/DaVinciInterfacesDict.h | 1 - .../dict/DaVinciInterfacesDict.xml | 1 - .../include/Kernel/IBTaggingTool.h | 104 ------------------ .../include/Kernel/DVCommonBase.h | 10 -- 4 files changed, 116 deletions(-) delete mode 100644 Phys/DaVinciInterfaces/include/Kernel/IBTaggingTool.h diff --git a/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.h b/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.h index e4120fba188..c4c60c7c469 100644 --- a/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.h +++ b/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.h @@ -22,7 +22,6 @@ // ============================================================================ // DaVinciKernel // ============================================================================ -#include "Kernel/IBTaggingTool.h" #include "Kernel/ICaloParticleMaker.h" #include "Kernel/IChangePIDTool.h" #include "Kernel/ICheckOverlap.h" diff --git a/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.xml b/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.xml index ad0b8f44007..b8b67f8ac41 100644 --- a/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.xml +++ b/Phys/DaVinciInterfaces/dict/DaVinciInterfacesDict.xml @@ -12,7 +12,6 @@ <!-- DaVinciInterfaces --> - <class name = "IBTaggingTool"/> <class name = "ICaloParticleMaker"/> <class name = "IChangePIDTool"/> <class name = "ICheckOverlap"/> diff --git a/Phys/DaVinciInterfaces/include/Kernel/IBTaggingTool.h b/Phys/DaVinciInterfaces/include/Kernel/IBTaggingTool.h deleted file mode 100644 index 7af0fe05cdd..00000000000 --- a/Phys/DaVinciInterfaces/include/Kernel/IBTaggingTool.h +++ /dev/null @@ -1,104 +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 BTAGGINGTOOL_IBTAGGINGTOOL_H -#define BTAGGINGTOOL_IBTAGGINGTOOL_H 1 - -// Include files -// from STL -#include <string> - -// from Gaudi -#include "Event/FlavourTag.h" -#include "Event/RecVertex.h" -#include "GaudiKernel/IAlgTool.h" - -/** @class IBTaggingTool IBTaggingTool.h - * - * v2.0 - * @author Marco Musy, Julian Wishahi - * @date 2004-2017 - */ - -struct GAUDI_API IBTaggingTool : extend_interfaces<IAlgTool> { - - DeclareInterfaceID( IBTaggingTool, 3, 0 ); - - /** - * @brief Tag a signal candidates - * - * @param flavTag The flavour tag - * @param[in] sigPart The signal particle - * - * @return StatusCode - */ - virtual StatusCode tag( LHCb::FlavourTag& flavTag, const LHCb::Particle* sigPart ) = 0; - - virtual StatusCode tag( LHCb::FlavourTag& flavTag, const LHCb::Particle* sigPart, - const LHCb::RecVertex* assocVtx ) = 0; - - virtual StatusCode tag( LHCb::FlavourTag& flavTag, const LHCb::Particle* sigPart, const LHCb::RecVertex* assocVtx, - LHCb::Particle::ConstVector& tagParts ) = 0; - - /** - * @brief List of active Taggers - * - * @return Vector of names of active taggers. - */ - virtual std::vector<std::string> activeTaggerTypeNames() const = 0; - - /** - * @brief List of active Taggers - * - * @return Vector of enum values of active taggers. - */ - virtual std::vector<LHCb::Tagger::TaggerType> activeTaggerTypes() const = 0; - - /** - * @brief Names of the features used by the tagger for the tag decision - * - * @return Vector of strings that represent the names of the features used - * by the tagger for the previous tag decision. - * - * @todo Make fully virtual - */ - virtual std::vector<std::string> featureNames( LHCb::Tagger::TaggerType taggerType ) const = 0; - - /** - * @brief Values of the features used by the tagger for the tag decision - * - * @return Vector of values of all features used for the previous tagging - * decision. Follows the ordering as given by featureNames(). - */ - virtual std::vector<double> featureValues( LHCb::Tagger::TaggerType taggerType ) const = 0; - - /** - * @brief Feature names evaluated by the tagger for each tagging particle - * - * @return Vector of strings that represent the names of the features used - * by the tagger in the process of determining the previous tag - * decision. In contrast to featureNames() this holds information - * evaluated for each tagging particle. - */ - virtual std::vector<std::string> featureNamesTagParts( LHCb::Tagger::TaggerType taggerType ) const = 0; - - /** - * @brief Feature values evaluated by the tagger for each tagging particle - * - * @return A vector of vector of values of all features used for the - * previous tagging decision. Each vector<double> represents one - * 'column' (associated to the featureName), each 'row' represents - * the features of one tagging particle. The column ordering - * follows the ones given by featureNamesTagParts(). - */ - virtual std::vector<std::vector<double>> featureValuesTagParts( LHCb::Tagger::TaggerType taggerType ) const = 0; -}; - -#endif // BTAGGINGTOOL_IBTAGGINGTOOL_H diff --git a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h index c398ba0ab0d..aa88d71f7d4 100644 --- a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h +++ b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h @@ -24,7 +24,6 @@ #include "Event/Particle.h" #include "Event/Vertex.h" -#include "Kernel/IBTaggingTool.h" #include "Kernel/ICheckOverlap.h" #include "Kernel/IDVAlgorithm.h" #include "Kernel/IDecayTreeFit.h" @@ -249,10 +248,6 @@ public: return this->getTool<IParticleFilter>( name, m_filterNames, this->defaultParticleFiltersNames(), m_filters, this ); } - /// Tagging Tool - IBTaggingTool* flavourTagging() const override { - return this->getTool<IBTaggingTool>( m_taggingToolName, m_taggingTool, this ); - } public: /// Overridden from Gaudi Algo to produce a warning if not called by user @@ -796,11 +791,6 @@ protected: /// Reference to CheckOverlap mutable ICheckOverlap* m_checkOverlap{nullptr}; - /// Concrete Type of FlavourTagging tool - std::string m_taggingToolName{"BTaggingTool"}; - /// Reference to FlavourTagging - mutable IBTaggingTool* m_taggingTool{nullptr}; - /// Reference to ParticleDescendants mutable IParticleDescendants* m_descendants{nullptr}; /// Concrete Type of ParticleDescendants tool -- GitLab From dd90c1ee17ffae1515ef101ca262b89033074290 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Wed, 13 Dec 2023 11:44:37 +0000 Subject: [PATCH 2/4] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/34695375 --- Phys/DaVinciKernel/include/Kernel/DVCommonBase.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h index aa88d71f7d4..982b0196e10 100644 --- a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h +++ b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h @@ -248,7 +248,6 @@ public: return this->getTool<IParticleFilter>( name, m_filterNames, this->defaultParticleFiltersNames(), m_filters, this ); } - public: /// Overridden from Gaudi Algo to produce a warning if not called by user void setFilterPassed( bool state ) const; -- GitLab From 33e4347cb8338d02ba0988bcbafd9db93acabb90 Mon Sep 17 00:00:00 2001 From: Gitlab CI <noreply@cern.ch> Date: Fri, 15 Dec 2023 09:46:36 +0000 Subject: [PATCH 3/4] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Rec/-/jobs/34753804 --- Phys/DaVinciKernel/include/Kernel/DVCommonBase.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h index d811f0f9d89..982b0196e10 100644 --- a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h +++ b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h @@ -961,4 +961,3 @@ private: /// Default nickname mapping for DistanceCalculators const ToolMap& defaultDistanceCalculatorsNames() const; }; - -- GitLab From bb2c2516115c6c37a07cfe26b63b0c94f25a4e0f Mon Sep 17 00:00:00 2001 From: cprouve <cprouve@cern.ch> Date: Fri, 15 Dec 2023 10:50:50 +0100 Subject: [PATCH 4/4] fix failure in rebase --- .../include/Kernel/DVCommonBase.h | 963 ------------------ 1 file changed, 963 deletions(-) delete mode 100644 Phys/DaVinciKernel/include/Kernel/DVCommonBase.h diff --git a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h b/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h deleted file mode 100644 index 982b0196e10..00000000000 --- a/Phys/DaVinciKernel/include/Kernel/DVCommonBase.h +++ /dev/null @@ -1,963 +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. * -\*****************************************************************************/ -#pragma once - -#include <map> - -#include "GAUDI_VERSION.h" -#include "GaudiAlg/GaudiTupleAlg.h" -#include "GaudiKernel/DataObjectHandle.h" -#include "GaudiKernel/HashMap.h" -#include "GaudiKernel/VectorMap.h" - -#include "Kernel/IParticlePropertySvc.h" -#include "Kernel/ParticleProperty.h" - -#include "Event/Particle.h" -#include "Event/Vertex.h" - -#include "Kernel/ICheckOverlap.h" -#include "Kernel/IDVAlgorithm.h" -#include "Kernel/IDecayTreeFit.h" -#include "Kernel/IDirectionFit.h" -#include "Kernel/IDistanceCalculator.h" -#include "Kernel/ILifetimeFitter.h" -#include "Kernel/IMassFit.h" -#include "Kernel/IPVReFitter.h" -#include "Kernel/IParticleDescendants.h" -#include "Kernel/IParticleFilter.h" -#include "Kernel/IRelatedPVFinder.h" -#include "Kernel/IVertexFit.h" - -#include "Kernel/Particle2Vertex.h" - -#include "Kernel/DaVinciFun.h" -#include "Kernel/DefaultDVToolTypes.h" - -#include "Kernel/Guards.h" - -#include "DetDesc/DetectorElement.h" -#include "DetDesc/GenericConditionAccessorHolder.h" - -/** @class DVCommonBase DVCommonBase.h Kernel/DVCommonBase.h - * - * Base Class for DaVinci Selection Algorithms: - * Does the retrieval of all necessary DaVinci Tools - * - * The specific configuration properties of the base class: - * - * - <b>Inputs</b> : TES location of input data container. - * - * - <b>Output</b> : TES location of output data container. - * - * - <b>VertexFitters</b> : the map for possible vertex fitters. - * @see IVertexFit - * The semantic is - * @code - * MyAgl.VertexFitters = { "" : "OfflineVertexFitter" , - * "special" : "MySpecialVertexFitter" } ; - * @endcode - * - * - <b>Distance Tools</b> : the map of possible geometry tools - * @see IDistanceCalculator - * - * - <b>ParticleFilters</b> : the map for possible particle filters - * @see IParticleFilter - * - * - <b>ParticleCombiners</b> : the map for possible particle combiners - * @see IParticleCombiner - * - * - <b>ParticleReFitters</b> : the map for possible particle re-fitters - * @see IParticleReFit - * - * - <b>PVReFitters</b> : the map for possible primary vertex re-fitters - * @see IPVReFitter - * - * - <b>ReFitPVs</b> : bool. Perform automatic PV re-fitting when asking for - * best PV. Default: false. - * - * - <b>UseP2PVRelations</b> : bool. Use P2PV relations internally - * or calculate best PV on the fly. Forced to true if <b>ReFitPVs</b> is true. - * Default: true. - * - * - <b>WriteP2PVRelations</b> : bool. Write P2PV relations to - * output TES location "<algorithm output location>/Particle2VertexRelations". - * Writes the relations for all particles in the TES after saving local - * particles, including relations for input particles. Does not write anything - * Default: true. - * - * - <b>IgnoreP2PVFromInputLocations</b> : Do not pick up <Inpus>"/Particle2VertexRelations". - * Forces to calculate best PV on the fly. To be used specially if you want - * to use ReFitPVs when the input algorithms didn't or vice versa. - * Or to be sure that you are re-calculating the best PV in your own algorithm. - * Bear in mind this involves potentially CPU expensive calculations. - * Default: false. - * - * - <b>DecayDescriptor</b> : the decay descriptor ofthe algorithm - * in the spirit of (MC)DecayFinder tool by Olivier Dormond. - * - * - * - <b>ForceOutput</b> : boolean flag (default value is <c>true</c>) - * forcing the wrinting of empty containers if no output data are required. - * - * - <b>PreloadTools</b> : the boolean flag (default value is <c>true</c>) - * to force the preloading of all nesessary tools at the initialization time - * - * @author Chris Jones - * @date 2012-06-22 - */ - -template <class PBASE> -class DVCommonBase : public extends1<LHCb::DetDesc::ConditionAccessorHolder<PBASE>, IDVAlgorithm> { - -public: - DVCommonBase( const std::string& name, ISvcLocator* pSvcLocator ); - -public: - LHCb::DetDesc::ConditionAccessor<DetectorElement> m_lhcb{this, "StandardGeometryTop", LHCb::standard_geometry_top}; - - Gaudi::Property<bool> m_fiddledLocs{this, "ModifyLocations", true, - "if set to false, does not append /Particles to outputParticles location"}; - - /** Handle to the concrete implementation, or to the parent if - * implementation does not derive from GaudiAlgorithm - */ - const GaudiAlgorithm* gaudiAlg() const override { return this; } - - // get IGeometryInfo - IGeometryInfo const& geometry() override { return *m_lhcb.get().geometry(); }; - - /// get the best related primary vertex - const LHCb::VertexBase* bestVertex( LHCb::Particle const* particle, IGeometryInfo const& geometry ) const override { - return bestPV( particle, geometry ); - } - - /// get all loaded input particles - const LHCb::Particle::Range particles() const override { - return LHCb::Particle::Range( m_inputParts.begin(), m_inputParts.end() ); - } - - /** direct const access to container of input primary vertices. - * @author Juan Palacios juan.palacios@nikhef.nl - */ - inline const LHCb::RecVertex::Range primaryVertices() const override { - return this->template getIfExists<LHCb::RecVertex::Range>( m_PVLocation.value() ); - } - - /** Accessor for IDistanceCalculator tools by name/typename/nickname - * @see IDistanceCalculator - * @param name the tool name/typename/nickname - * @return pointer to acquired tool - */ - const IDistanceCalculator* distanceCalculator( const std::string& name = "" ) const override { - return this->getTool<IDistanceCalculator>( name, m_distanceCalculatorNames, this->defaultDistanceCalculatorsNames(), - m_distanceCalculators, this ); - } - - /** Accessor for ILifetimeFitter tools by name/typename/nickname - * @see ILifetimeFitter - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const ILifetimeFitter* lifetimeFitter( const std::string& name = "" ) const override { - return this->getTool<ILifetimeFitter>( name, m_lifetimeFitterNames, this->defaultLifetimeFittersNames(), - m_lifetimeFitters, this ); - } - - /** Accessor for IVertexFit tools by name/typename/nickname - * @see IVertexFit - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IVertexFit* vertexFitter( const std::string& name = "" ) const override { - return this->getTool<IVertexFit>( name, m_vertexFitNames, this->defaultVertexFittersNames(), m_vertexFits, this ); - } - - /** Accessor for IParticleReFitter tools by name/typename/nickname - * @see IParticleReFitter - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IParticleReFitter* particleReFitter( const std::string& name = "" ) const override { - return this->getTool<IParticleReFitter>( name, m_particleReFitterNames, this->defaultParticleReFittersNames(), - m_particleReFitters, this ); - } - - /** Accessor for IDecayTreeFit tools by name/typename/nickname - * @see IDecayTreeFit - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - IDecayTreeFit* decayTreeFitter( const std::string& name = "" ) const override { - return this->getTool<IDecayTreeFit>( name, m_decayTreeFitterNames, this->defaultDecayTreeFittersNames(), - m_decayTreeFitters, this ); - } - - /** Accessor for IParticleCombiner tools by name/typename/nickname - * @see IParticleCombiner - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IParticleCombiner* particleCombiner( const std::string& name = "" ) const override { - return this->getTool<IParticleCombiner>( name, m_particleCombinerNames, this->defaultParticleCombinersNames(), - m_particleCombiners, this ); - } - - /** Accessor for IMassFit tools by name/typename/nickname - * @see IMassFit - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IMassFit* massFitter( const std::string& name = "" ) const override { - return this->getTool<IMassFit>( name, m_massFitterNames, this->defaultMassFittersNames(), m_massFitters, this ); - } - - /** Accessor for IDirectionFit tools by name/typename/nickname - * @see IDirectionFit - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IDirectionFit* directionFitter( const std::string& name = "" ) const override { - return this->getTool<IDirectionFit>( name, m_directionFitterNames, this->defaultDirectionFittersNames(), - m_directionFitters, this ); - } - - /** Accessor for IPVReFitter tools by name/typename/nickname - * @see IPVReFitter - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IPVReFitter* primaryVertexReFitter( const std::string& name = "" ) const override { - return this->getTool<IPVReFitter>( name, m_pvReFitterNames, this->defaultPVReFittersNames(), m_pvReFitters, this ); - } - - /** Accessor for Particle Filter Tool - * @see IPArticleFilter - * @param name the tool name/typename/nickname - * @return pointer to aquired tool - */ - const IParticleFilter* particleFilter( const std::string& name = "" ) const override { - return this->getTool<IParticleFilter>( name, m_filterNames, this->defaultParticleFiltersNames(), m_filters, this ); - } - -public: - /// Overridden from Gaudi Algo to produce a warning if not called by user - void setFilterPassed( bool state ) const; - - /// Overridden from Gaudi Algorithm - StatusCode sysExecute( const EventContext& ) override; - - // Overridden from Gaudi Algorithm - StatusCode initialize() override; - - // Overridden from Gaudi Algorithm - StatusCode finalize() override; - -public: - // Get decay descriptor - const std::string& getDecayDescriptor() const { return m_decayDescriptor; } - - // Set decay descriptor - void setDecayDescriptor( const std::string& dd ) { m_decayDescriptor = dd; } - - /** - * Direct const access to the tool that calculates the Particle->PV - * weighted relations - * - * @author Juan Palacios juan.palacios@nikhef.nl - **/ - inline const IRelatedPVFinder* relatedPVFinder() const { - return this->getTool<IRelatedPVFinder>( m_pvRelatorName, m_pvRelator, this ); - } - - /** - * Cached access to default IPVReFitter tool. - * - * @author Juan Palacios palacios@physik.uzh.ch - * - * @attention TO be removed. Use primaryVertexReFitter() instead. - **/ - inline const IPVReFitter* defaultPVReFitter() const { return this->primaryVertexReFitter(); } - - /** - * Inline access to best PV for a given particle. - * - **/ - inline const LHCb::VertexBase* bestPV( LHCb::Particle const* particle, IGeometryInfo const& geometry ) const { - return i_bestVertex( particle, geometry ); - } - - /** - * Calculate the best related PV for a particle and return it to the user - * If property "ReFitPVs" is set to true, this triggers a re-fit of the PVs - * after removing tracks coming from the particle in question. If not, then - * it uses the container of PVs obtained from method primaryVertices(). - * Returns a newed pointer to a vertex either from the TES or stored in the - * local storage. - * - * @author Juan Palacios juan.palacios@nikhef.nl - * @param p LHCb::Particle to be related - * @return newed pointer to related vertex. TES or DV Algorithm in charge of - * memory management. - **/ - const LHCb::VertexBase* calculateRelatedPV( LHCb::Particle const* p, IGeometryInfo const& geometry ) const; - - /** - * Get the related PV from the relations table, or call calculateRelatedPV - * if it isn't already there. - * - * @author Juan Palacios juan.palacios@nikhef.nl - * @date 10/02/2009 - **/ - const LHCb::VertexBase* getRelatedPV( LHCb::Particle const* p, IGeometryInfo const& geometry ) const; - - /** - * Relate a VertexBase to a Particle. - * Overwrites existing relation to that particle. - * - * @param part (INPUT) LHCb::Particle to which an LHCb::VertexBase - * will be related - * @param vert (INPUT) LHCb::VertexBase that will be related to part. - * - * @author Juan Palacios palacios@physik.uzh.ch - **/ - inline void relate( const LHCb::Particle* particle, const LHCb::VertexBase* vertex ) const { - if ( particle && vertex ) { m_p2PVMap[particle] = vertex; } - } - - /** - * - * Remove the PV relation of a particle if there is one. - * - * @param particle - * @author Juan Palacios palacios@physik.uzh.ch - **/ - inline void unRelatePV( const LHCb::Particle* particle ) const override { m_p2PVMap.erase( particle ); } - -public: - /// Accessor for CheckOverlap Tool - inline ICheckOverlap* checkOverlap() const { - return this->getTool<ICheckOverlap>( m_checkOverlapName, m_checkOverlap ); - } - - /// Descendants - inline IParticleDescendants* descendants() const { - return this->getTool<IParticleDescendants>( m_descendantsName, m_descendants ); - } - - /** Accessor for ParticlePropertySvc - * @see LHCb::ParticlePropertySvc - * @return pointer to Particle Property Service - */ - inline const LHCb::IParticlePropertySvc* ppSvc() const { - if ( !m_ppSvc ) { m_ppSvc = this->template svc<LHCb::IParticlePropertySvc>( "LHCb::ParticlePropertySvc", true ); } - return m_ppSvc; - } - - /** helper method to get a proper ParticleProperty for the given name - * - * @code - * - * const LHCb::ParticleProperty* pion = pid ( "pi+" ) ; - * - * @endcode - * - * @see LHCb::ParticleProperty - * @see LHCb::IParticlePropertySvc - * @param name the particle name - * @return pointer to particle property - */ - inline const LHCb::ParticleProperty* pid( const std::string& name ) const { - const LHCb::ParticleProperty* pp = ppSvc()->find( name ); - if ( !pp ) { this->Error( "pid('" + name + "') : invalid LHCb::ParticleProperty!" ).ignore(); } - return pp; - } - - /** helper method to get a proper ParticleProperty for the given pid - * - * @code - * - * const LHCb::Particle* p = ... ; - * - * const LHCb::ParticleProperty* pp = pid ( p->particleID() ) ; - * - * @endcode - * - * @see LHCb::ParticleProperty - * @see LHCb::IParticlePropertySvc - * @see LHCb::ParticleID - * @param id the particle pid - * @return pointer to particle property - */ - inline const LHCb::ParticleProperty* pid( const LHCb::ParticleID& id ) const { - const LHCb::ParticleProperty* pp = ppSvc()->find( id ); - if ( !pp ) { this->Error( "pid() : invalid LHCb::ParticleProperty!" ).ignore(); } - return pp; - } - -protected: - /// the actual type for mapping "tool nickname -> the actual type/name" - using ToolMap = std::map<std::string, std::string>; - -private: - /** helper protected function to load the tool on-demand - * @param name name of tool - * @param t tool - * @param ptr the pointer to this or NULL for private or common tools - * @return tool - */ - template <class TYPE> - TYPE* getTool( const std::string& name, TYPE*& t, const IInterface* ptr = NULL ) const { - if ( !t ) { t = this->template tool<TYPE>( name, ptr ); } - return t; - } - - /** helper method to locate the tool by nickname - * - * @attention it is for internal usage ONLY, - * used for implementation of - * concrete accessor functions - * - * It is assumed that the map "nickname -> type/name" is performed - * through the algorithm properties - * - * @param nickName the nickname for the tool - * @param nameMap the actual mapping "nickname -> type/name" - * (to be specified through the properties) - * @param toolMap the actual storage of located tool, e.g. - * std::map<std::string,TYPE*> or - * Gaudi::Utils::VectorMap<std::string,TYPE*> - * @param parent the parent of the tools - * @return the located tool - */ - template <class TYPE, class STORAGE> - TYPE* getTool( const std::string& nickName, const ToolMap& customMap, const ToolMap& defaultMap, STORAGE& toolMap, - const IInterface* parent = NULL ) const { - TYPE* t = NULL; - // look within the local list of already located tools of given type - typename STORAGE::const_iterator ifind = toolMap.find( nickName ); - // tool is in the list? - if ( toolMap.end() != ifind ) { - t = ifind->second; - if ( !t ) { - this->Exception( "getTool<" + System::typeinfoName( typeid( TYPE ) ) + ">('" + nickName + - "'): tool points to NULL" ); - } - } else { - // get the actual tool type - std::string toolType = nickName; - ToolMap::const_iterator iname = customMap.find( nickName ); - if ( iname != customMap.end() ) { - toolType = iname->second; - } else { - iname = defaultMap.find( nickName ); - if ( iname != defaultMap.end() ) { toolType = iname->second; } - } - // locate the tool - t = this->template tool<TYPE>( toolType, parent ); - // add the located tool into the container - typename STORAGE::value_type value( nickName, t ); - toolMap.insert( value ); - } - return t; // RETURN - } - -protected: - /** - * Access to the list of TES input locations given by the Inputs - * property - * - * @return vector or strings with TES input locations - */ - inline const std::vector<std::string>& inputLocations() const { return m_inputLocations.value(); } - - /** - * Access to the list of TES input locations given by the Inputs - * property - * - * @return vector or strings with TES input locations - */ - inline std::vector<std::string>& inputLocations() { return m_inputLocations.value(); } - - /// Marks a single particle for saving, ignoring it's decay tree. - /// Particle must be on the heap, either already in the TES or - /// newed by the client. Particle's decay products must be in the TES. - /// If these conditions are not met, saving to the TES via saveInTES will - /// fail. - /// - /// @attention use markTree, markNewTree methods - /// unless you are really sure all the decay products are in the TES. - /// - /// @attention if <b>particle</b> is on the TES they will not be saved - /// by default, special action is required via over-writing of _saveInTES. - /// - inline void markParticle( const LHCb::Particle* particle ) { - if ( m_parts.end() == std::find( m_parts.begin(), m_parts.end(), particle ) ) { m_parts.push_back( particle ); } - } - - /// Mark particles for saving, ignoring it's decay tree. - /// Particles must be on the heap, either already in the TES or - /// newed by the client. Particle's decay products must be in the TES. - /// If these conditions are not met, savinf to the TES via saveInTES will - /// fail. - /// - /// @attention use markTrees, markNewTrees methods - /// unless you are really sure all the decay products are in the TES. - /// - /// @attention if <b>particles</b> are on the TES they will not be saved - /// by default, special action is required via over-writing of _saveInTES. - /// - template <class PARTICLES> - inline void markParticles( const PARTICLES& particles ) { - for ( typename PARTICLES::const_iterator iPart = particles.begin(); iPart != particles.end(); ++iPart ) { - markParticle( *iPart ); - } - } - - /// Mark a decay tree for saving. Scans decay tree marking - /// elements for saving. Each branch is followed and each vertex - /// is cloned until a vertex is found which is in the TES. - /// - /// @attention Cloning stops at vertices that are in the TES. - /// @param particle (INPUT) The head of the decay to be cloned and marked. - /// Ownership remains unchanged (either client's or TES). - /// @return the cloned head of the decay or the input if in TES. - /// - const LHCb::Particle* markTree( const LHCb::Particle* particle ); - - /// Mark particles for saving. Scans decay trees marking - /// elements for saving. Each branch is followed and each vertex - /// is cloned until a vertex is found which is in the TES. - /// - /// @attention Cloning stops at vertices that are in the TES. - /// @param heads (INPUT) The heads of the decays to be cloned and marked. - /// Ownership remains unchanged (either client's or TES). - /// - template <class PARTICLES> - inline void markTrees( const PARTICLES heads ) { - for ( typename PARTICLES::const_iterator iHead = heads.begin(); iHead != heads.end(); ++iHead ) { - markTree( *iHead ); - } - } - - /* Method removed since causing a memory leak, see JIRA task LHCBPS-1650 - - /// Clone a particle and mark for saving. Scans descendants cloning - /// and marking elements for saving. Each branch is followed until - /// a vertex is found which is in the TES. - /// - /// @attention particle is always cloned, but cloning of decays - /// stops at vertices that are in the TES. - /// @param particle (INPUT) The head of the decay to be cloned and marked. - /// Ownership remains unchanged (either client's or TES). - /// @return the cloned head of the decay or the input if in TES. - /// - const LHCb::Particle* cloneAndMarkTree(const LHCb::Particle* particle); - - /// Clone particles and mark for saving. Scans descendants cloning - /// and marking elements for saving. Each branch is followed until - /// a vertex is found which is in the TES. - /// - /// @attention head is always cloned, but cloning of decays - /// stops at vertices that are in the TES. - /// @param heads (INPUT) The heads of the decays to be cloned and marked. - /// Ownership remains unchanged (either client's or TES). - /// @return the cloned head of the decay or the input if in TES. - /// - template <class PARTICLES> - void cloneAndMarkTrees(const PARTICLES& heads) - { - for ( typename PARTICLES::const_iterator iHead = heads.begin(); - iHead != heads.end(); ++iHead ) { cloneAndMarkTree(*iHead); } - } - */ - - /// - /// Mark Particles head and its decay products for saving. - /// Elements already on the TES or their descendants will not be marked. - /// @param head (INPUT) Particle, head of decays to be stored. - /// Algorithm takes over ownership. Element <b>must be on the heap</b>. - /// - inline void markNewTree( const LHCb::Particle* head ) { - DaVinci::Utils::findDecayTree( head, m_parts, m_secVerts, &m_inTES ); - } - - /// - /// Mark the particles in heads and their decay products for saving. - /// Elements already on the TES or their descendants will not be marked. - /// @param heads (INPUT) vector of heads of decays to be stored. - /// Algorithm takes over ownership. Elements <b>must be on the heap</b>. - /// - template <class PARTICLES> - inline void markNewTrees( const PARTICLES& heads ) { - for ( typename PARTICLES::const_iterator iHead = heads.begin(); iHead != heads.end(); ++iHead ) { - markNewTree( *iHead ); - } - } - - /// Return the output location where data will be written to the TES - inline const std::string& outputLocation() const { return m_outputLocation; } - /// Return the output location where Particles will be written to the TES - inline const std::string& particleOutputLocation() const { return m_particleOutputLocation; } - /// Return the output location where decay vertices will be written - /// to the TES - inline const std::string& decayVertexOutputLocation() const { return m_decayVertexOutputLocation; } - - /// Return the output location where data will be written to the TES - inline const std::string& tableOutputLocation() const { return m_tableOutputLocation; } - - /// Get the best related PV from the local relations table. Return 0 if - /// nothing is there. Does not invoke any calculations. - inline const LHCb::VertexBase* getStoredBestPV( const LHCb::Particle* particle ) const { - P2PVMap::const_iterator iPV = m_p2PVMap.find( particle ); - return ( iPV != m_p2PVMap.end() ? iPV->second : NULL ); - } - - /// Inline access to local input Particle storage. - inline const LHCb::Particle::ConstVector& i_particles() const { return m_inputParts; } - - /// Inline access to local marked Particle storage. - inline const LHCb::Particle::ConstVector& i_markedParticles() const { return m_parts; } - -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() : "" ) ); - } - - /** Try and find the related PV by predicting the relations table - * location from the Particle TES container location - */ - const LHCb::VertexBase* relatePVViaParticleTESLoc( const LHCb::Particle* p ) const; - - /** - * Inline access to best PV for a given particle. - * - **/ - inline const LHCb::VertexBase* i_bestVertex( LHCb::Particle const* p, IGeometryInfo const& geometry ) const { - return ( useP2PV() ? getRelatedPV( p, geometry ) : calculateRelatedPV( p, geometry ) ); - } - - /// Initialise relative Inputs - void initializeInputLocations(); - - /// Initialise Particle->PV relations input locations. - void initializeOutputLocations(); - - /// Load all tools. - /// The base class provides an instance of all type of tools - StatusCode loadTools(); - - /// Load particles, primary vertices, relations tables. - virtual StatusCode loadEventInput(); - - /// Load particles from Inputs - StatusCode loadParticles(); - - /// Load Particle->PV relations for loaded particles. - StatusCode loadParticle2PVRelations(); - - /// Take a range of Particle -> PV relations and store them locally, - /// overwriting existing relations with the same From. - void loadRelations( const Particle2Vertex::Table::Range& relations ) const; - - /// Does the particle have a relation to a PV stored in the local - /// relations table? - inline bool hasStoredRelatedPV( const LHCb::Particle* particle ) const { - return ( m_p2PVMap.find( particle ) != m_p2PVMap.end() ); - } - - /// Does the event have more than 1 primary vertex? - inline bool multiPV() const { return ( this->primaryVertices().size() > 1 ); } - - /// Should PVs be re-fitted when bestVertex is asked for? - inline bool refitPVs() const { return m_refitPVs.value(); } - - /// Should Particle->PV relations table be used? - inline bool useP2PV() const { return ( refitPVs() ? true : m_useP2PV.value() ); } - - /// Should Particle->PV relations be stored in the TES? - inline bool saveP2PV() const { return ( m_writeP2PV && !m_noPVs ); } - - /// Save the local Particle->Vertex relations table to the TES - StatusCode saveP2PVRelations( IGeometryInfo const& geometry ) const; - - /// Scan the marked particles' decay trees and get or calculate - /// best PV relations and store them on the local map. - void buildP2PVMap( IGeometryInfo const& geometry ) const; - - /// Mark a local PV for saving. - const LHCb::RecVertex* mark( const LHCb::RecVertex* PV ) const; - - template <class PARTICLES> - void i_markTrees( const PARTICLES& heads ) { - for ( typename PARTICLES::const_iterator iHead = heads.begin(); iHead != heads.end(); ++iHead ) { - DaVinci::Utils::findDecayTree( *iHead, m_parts, m_secVerts, &m_inTES ); - } - } - - /// Save local re-fitted PVs related to saved particles. - /// Only saves PVs that are not already in the TES. - void saveRefittedPVs( const LHCb::RecVertex::ConstVector& vToSave ) const; - - /// Save all marked local particles not already in the TES. - /// Saves decay tree elements not already in TES, plus related - /// PV and relation table entry when applicable. - StatusCode saveInTES( IGeometryInfo const& geometry ); - -protected: - /// Save all marked local particles not already in the TES. - /// Saves decay tree elements not already in TES - /// This method can be overwritten if special TES saving actions are - /// required. Avoid if possible! - virtual StatusCode _saveInTES(); - - /// Write an empty Particles container of the same type as that in - /// saveInTES(). Can be overwritten for specialist actions. - virtual void writeEmptyTESContainers(); - - /// handle the update of "Inputs" property" - void handleInputsUpdate( Gaudi::Details::PropertyBase& /* p */ ); // update the factory - -private: - std::string m_outputLocation; ///< Output location TES folder. - - std::string m_decayVertexOutputLocation; ///< Output location TES folder. - - std::string m_tableOutputLocation; ///< Output location TES folder. - - LHCb::Particle::ConstVector m_parts; ///< Local Container of local particles - - LHCb::Particle::ConstVector m_inputParts; ///< Local container of input particles. - - LHCb::Vertex::ConstVector m_secVerts; ///< Local Container of secondary vertices - - mutable LHCb::RecVertex::ConstVector m_refittedPVs; ///< Local Container of re-fitted primary vertices - - /// Type for mapping between Particles and PVs - using P2PVMap = GaudiUtils::HashMap<const LHCb::Particle*, const LHCb::VertexBase*>; - - mutable P2PVMap m_p2PVMap; ///< Local store of Particle->PV relations. - -protected: - /// The actual map of "nickname -> tool" for Vertex Fitters - mutable GaudiUtils::VectorMap<std::string, IVertexFit*> m_vertexFits; - - /// Mapping of "nickname ->type/name" for Geometry Tools - ToolMap m_geomToolNames; - - /// Mapping of "nickname ->type/name" for Particle Filters - /// The actual map of "nickname -> tool" for Particle Filters - mutable GaudiUtils::VectorMap<std::string, IParticleFilter*> m_filters; - - /// The actual map of "nickname -> tool" for Particle Combiners - mutable GaudiUtils::VectorMap<std::string, IParticleCombiner*> m_particleCombiners; - - /// The actual map of "nickname -> tool" for Particle Refitters - mutable GaudiUtils::VectorMap<std::string, IParticleReFitter*> m_particleReFitters; - - /// The actual map of "nickname -> tool" for Particle Refitters - mutable GaudiUtils::VectorMap<std::string, IPVReFitter*> m_pvReFitters; - - /// The actual map of "nickname -> tool" for Decay Tree fitters - mutable GaudiUtils::VectorMap<std::string, IDecayTreeFit*> m_decayTreeFitters; - /// The actual map of "nickname -> tool" for mass-constrained fitters - mutable GaudiUtils::VectorMap<std::string, IMassFit*> m_massFitters; - - /// The actual map of "nickname -> tool" for lifetime fitters - mutable GaudiUtils::VectorMap<std::string, ILifetimeFitter*> m_lifetimeFitters; - - /// The actual map of "nickname -> tool" for direction fitters - mutable GaudiUtils::VectorMap<std::string, IDirectionFit*> m_directionFitters; - - /// the actual map of "nickname -> distance calculator" - mutable GaudiUtils::VectorMap<std::string, IDistanceCalculator*> m_distanceCalculators; - -protected: - /// Reference to CheckOverlap - mutable ICheckOverlap* m_checkOverlap{nullptr}; - - /// Reference to ParticleDescendants - mutable IParticleDescendants* m_descendants{nullptr}; - /// Concrete Type of ParticleDescendants tool - std::string m_descendantsName{"ParticleDescendants"}; - - /// Find the related PV - mutable IRelatedPVFinder* m_pvRelator{nullptr}; - - /// Reference to ParticlePropertySvc - mutable const LHCb::IParticlePropertySvc* m_ppSvc{nullptr}; - -private: - /// Has setFilterPassed() already been called in current event? - mutable bool m_setFilterCalled{false}; - - /// Do we have more than one PV in the event? - bool m_multiPV{false}; - -public: - Gaudi::Property<std::string> m_pvRelatorName{this, "PrimaryVertexRelator", DaVinci::DefaultTools::PVRelator}; - - Gaudi::Property<std::string> m_decayDescriptor{this, "DecayDescriptor", "", "Describes the decay"}; - - /// avoid the writeup of empty containers - Gaudi::Property<bool> m_forceOutput{this, "ForceOutput", true, "If true TES location is written"}; - - Gaudi::Property<bool> m_refitPVs{this, "ReFitPVs", false, "Refit PV"}; - /// Do we want to use the Particle -> PV relations? Default: true. - - Gaudi::Property<bool> m_useP2PV{this, "UseP2PVRelations", true, "Use P->PV relations internally. \ - Forced to true if re-fitting PVs. Otherwise disabled for single PV events. Default: true."}; - /** Ignore Particle->PV relations from Inputs? - * User-defined ones are kept. */ - - Gaudi::Property<bool> m_ignoreP2PVFromInputLocations{this, "IgnoreP2PVFromInputLocations", false}; - /** Force building of Particle-> best PV relations for selected - * particles and their decay products where applicable. Only has effect - * if <b>WriteP2PVRelations</b> is true. This is a post-execute action - * and has no effect over the user's execute actions. <b>Default</b> false. - * Takes existing relations and adds missing ones. */ - - Gaudi::Property<bool> m_forceP2PVBuild{this, "ForceP2PVBuild", false, - "Force construction of P->PV relations table. Default: false"}; - - /// Do we want to write the Particle -> PV relations table to the TES? - Gaudi::Property<bool> m_writeP2PV{this, "WriteP2PVRelations", true, - "Write out P->PV relations table to TES. Default: true"}; - - /** Switch PreloadTools to false to not preload any tools. - * This will have the effect that they will be loaded on demand, when needed, - * at any event. This option is thus only recommended for use of DV Algorithm - * to do something unrelated to physics analysis. - */ - Gaudi::Property<bool> m_preloadTools{this, "PreloadTools", false, "If true all tools are pre-loaded in initialize"}; - - Gaudi::Property<std::string> m_checkOverlapName{this, "CheckOverlapTool", "CheckOverlap:PUBLIC", - "Name of Overlap Tool"}; - Gaudi::Property<ToolMap> m_vertexFitNames{this, "VertexFitters", {}, "Names of vertex fitters"}; - - Gaudi::Property<ToolMap> m_filterNames{this, "ParticleFilters", {}, "Names of ParticleFilters"}; - - Gaudi::Property<ToolMap> m_particleCombinerNames{ - this, "ParticleCombiners", {}, "Names of particle combiners, the basic tools for creation of composed particles"}; - - Gaudi::Property<ToolMap> m_particleReFitterNames{this, "ParticleReFitters", {}, "Names of particle refitters"}; - - Gaudi::Property<ToolMap> m_pvReFitterNames{this, "PVReFitters", {}, "Names of Primary Vertex refitters"}; - - Gaudi::Property<ToolMap> m_decayTreeFitterNames{ - this, "DecayTreeFitters", {}, "The mapping of nick/name/type for IDecaytreeFitFit tools"}; - - Gaudi::Property<ToolMap> m_massFitterNames{ - this, "MassFitters", {}, "The mapping of nick/name/type for IMassFit tools"}; - - Gaudi::Property<ToolMap> m_lifetimeFitterNames{ - this, "LifetimeFitters", {}, "The mapping of nick/name/type for ILifetimeFitter tools"}; - - Gaudi::Property<ToolMap> m_directionFitterNames{ - this, "DirectionFitters", {}, "The mapping of nick/name/type for IDirectionFit tools"}; - - Gaudi::Property<ToolMap> m_distanceCalculatorNames{ - this, "DistanceCalculators", {}, "The mapping of nick/name/type for IDistanceCalculator tools"}; - - /// InputLocations - Gaudi::Property<std::vector<std::string>> m_inputLocations{ - this, "Inputs", {}, &DVCommonBase<PBASE>::handleInputsUpdate, "Input Locations forwarded of Particles"}; - - /// User-defined Particle->PV relations locations - Gaudi::Property<std::vector<std::string>> m_p2PVInputLocations{ - this, "P2PVInputLocations", {}, "Particle -> PV Relations Input Locations"}; - - /// TES location of input PVs. - Gaudi::Property<std::string> m_PVLocation{this, "InputPrimaryVertices", LHCb::RecVertexLocation::Primary}; - /// TES location of output particles - Gaudi::Property<std::string> m_particleOutputLocation{this, "Output", "", "output location of a particle"}; - -private: - /// Don't use PVs - bool m_noPVs{false}; - - /// Functor determining if LHCb::Particle is in TES. - DaVinci::Utils::ParticleInTES m_inTES; - - /// Counter for "effective filters" - mutable Gaudi::Accumulators::BinomialCounter<> m_acceptCounter{this, "#accept"}; - mutable Gaudi::Accumulators::StatCounter<> m_nInputParticles{this, "# input particles"}; - -private: // classes - /** @class DVAlgGuard - * - * Guard class to clear containers and Particle->PV relations table. - */ - class DVAlgGuard { - - public: - /// Constructor with data values - DVAlgGuard( LHCb::Particle::ConstVector& inputParticles, LHCb::Particle::ConstVector& localParticles, - LHCb::Vertex::ConstVector& localSecondaryVertices, LHCb::RecVertex::ConstVector& primaryVertices, - P2PVMap& tableP2PV ) - : m_guardInputP( inputParticles ) - , m_guardLocalP( localParticles ) - , m_guardLocalSV( localSecondaryVertices ) - , m_guardPV( primaryVertices ) - , m_table( tableP2PV ) {} - - /// Destructor - ~DVAlgGuard() { m_table.clear(); } - - private: - /// Disallow default constructor - DVAlgGuard(); - - private: - DaVinci::Utils::OrphanPointerContainerGuard<LHCb::Particle::ConstVector> m_guardInputP; - DaVinci::Utils::OrphanPointerContainerGuard<LHCb::Particle::ConstVector> m_guardLocalP; - DaVinci::Utils::OrphanPointerContainerGuard<LHCb::Vertex::ConstVector> m_guardLocalSV; - DaVinci::Utils::OrphanPointerContainerGuard<LHCb::RecVertex::ConstVector> m_guardPV; - P2PVMap& m_table; - }; - -private: - /// Default nickname mapping for VertexFitters - const ToolMap& defaultVertexFittersNames() const; - - /// Default nickname mapping for ParticleFilters - const ToolMap& defaultParticleFiltersNames() const; - - /// Default nickname mapping for ParticleCombiners - const ToolMap& defaultParticleCombinersNames() const; - - /// Default nickname mapping for ParticleReFitters - const ToolMap& defaultParticleReFittersNames() const; - - /// Default nickname mapping for PVReFitters - const ToolMap& defaultPVReFittersNames() const; - - /// Default nickname mapping for DecayTreeFitters - const ToolMap& defaultDecayTreeFittersNames() const; - - /// Default nickname mapping for MassFitters - const ToolMap& defaultMassFittersNames() const; - - /// Default nickname mapping for LifetimeFitters - const ToolMap& defaultLifetimeFittersNames() const; - - /// Default nickname mapping for DirectionFitters - const ToolMap& defaultDirectionFittersNames() const; - - /// Default nickname mapping for DistanceCalculators - const ToolMap& defaultDistanceCalculatorsNames() const; -}; -- GitLab