|
||||
File indexing completed on 2025-01-18 09:57:29
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #pragma once 0012 0013 #include <GaudiKernel/Kernel.h> 0014 #include <GaudiKernel/StatusCode.h> 0015 #include <functional> 0016 #include <iosfwd> 0017 #include <memory> 0018 0019 namespace Gaudi { 0020 namespace Interfaces { 0021 class IParticlePropertySvc; 0022 } 0023 class ParticleID; 0024 } // namespace Gaudi 0025 0026 namespace Gaudi::Decays { 0027 /** @class iNode Decays/iNode.h 0028 * The abstract class which represents the single "node" of decay tree 0029 * 0030 * The class is imported from LoKi project 0031 * 0032 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0033 * @date 2008-04-12 0034 */ 0035 class GAUDI_API iNode { 0036 public: 0037 /** the basic operation: comparison of the particle PID with the node 0038 * @param pid the particle to be compared 0039 * @return true if the actual PID matched the node descriptor 0040 */ 0041 virtual bool operator()( const Gaudi::ParticleID& pid ) const = 0; 0042 0043 /// clone method ("virtual constructor") 0044 virtual iNode* clone() const = 0; 0045 0046 /** printout of the stream 0047 * @param s the reference to the output stream 0048 * @return the reference to the output stream 0049 */ 0050 virtual std::ostream& fillStream( std::ostream& s ) const = 0; 0051 /// check the validity of the node 0052 virtual bool valid() const = 0; 0053 /// invalid node? 0054 virtual bool operator!() const; 0055 0056 /** validate the decay node 0057 * @param svc pointer to Particle Property Service 0058 * @return StatusCode 0059 */ 0060 virtual StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const = 0; 0061 0062 /// the string representation of the node 0063 virtual std::string toString() const; 0064 0065 /// virtual destructor 0066 virtual ~iNode() = default; 0067 }; 0068 0069 /** @class Node 0070 * The generic class to hold the pointer to other node 0071 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0072 * @date 2008-04-12 0073 */ 0074 class GAUDI_API Node : public iNode { 0075 public: 0076 /// constructor from the node 0077 Node( const Decays::iNode& node ); 0078 /// copy constructor 0079 Node( const Decays::Node& right ); 0080 /// MANDATORY: clone method ("virtual constructor") 0081 Node* clone() const override; 0082 /// MANDATORY: the only one essential method 0083 bool operator()( const Gaudi::ParticleID& p ) const override; 0084 /// MANDATORY: the specific printout 0085 std::ostream& fillStream( std::ostream& s ) const override; 0086 /// MANDATORY: check the validity of the node 0087 bool valid() const override; 0088 /// MANDATORY: the proper validation of the node 0089 StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const override; 0090 0091 public: 0092 Node& operator&=( const iNode& right ) { return op_and( right ); } 0093 Node& operator|=( const iNode& right ) { return op_or( right ); } 0094 0095 // get the underlying node 0096 inline const iNode& node() const { return *m_node; } 0097 0098 // evaluate the underlying node 0099 inline bool node( const Gaudi::ParticleID& pid ) const { return node()( pid ); } 0100 0101 /// assignment operator: 0102 Node& operator=( const Node& right ); 0103 /// assignment from arbitrary node 0104 Node& operator=( const iNode& right ); 0105 0106 private: 0107 Node& op_and( const iNode& right ); 0108 Node& op_or( const iNode& right ); 0109 0110 /// the node itself: 0111 std::unique_ptr<iNode> m_node; 0112 }; 0113 0114 /** printout to the output stream 0115 * @param s the output stream 0116 * @param n the node 0117 * @return the output stream (Reference) 0118 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0119 * @date 2008-04-21 0120 */ 0121 inline std::ostream& operator<<( std::ostream& s, const iNode& n ) { return n.fillStream( s ); } 0122 0123 /** equality 0124 * The node is "equal" to the PID , if the given pid satisfies the node criteria 0125 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0126 * @date 2008-04-21 0127 */ 0128 inline bool operator==( const Decays::iNode& node, const Gaudi::ParticleID& pid ) { return node( pid ); } 0129 0130 /** "right" equality 0131 * The node is "equal" to the PID , if the given pid satisfies the node criteria 0132 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0133 * @date 2008-04-21 0134 */ 0135 inline bool operator==( const Gaudi::ParticleID& pid, const Decays::iNode& node ) { return node == pid; } 0136 0137 /** non-equality 0138 * The node is "equal" to the PID , if the given PID satisfies the node criteria 0139 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0140 * @date 2008-04-21 0141 */ 0142 inline bool operator!=( const Decays::iNode& node, const Gaudi::ParticleID& pid ) { return !( node == pid ); } 0143 0144 /** non-equality 0145 * The node is "equal" to the PID , if the given PID satisfies the node criteria 0146 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0147 * @date 2008-04-21 0148 */ 0149 inline bool operator!=( const Gaudi::ParticleID& pid, const Decays::iNode& node ) { return node != pid; } 0150 0151 /** "on-flight" validation of the node 0152 * @param n the node 0153 * @param svc particle property service 0154 * @return status code 0155 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0156 * @date 2008-04-21 0157 */ 0158 inline StatusCode operator+( const Decays::iNode& n, const Gaudi::Interfaces::IParticlePropertySvc* svc ) { 0159 return n.validate( svc ); 0160 } 0161 0162 /** "on-flight" validation of the node 0163 * @param n the node 0164 * @param svc particle property service 0165 * @return status code 0166 * @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl 0167 * @date 2008-04-21 0168 */ 0169 inline StatusCode operator*( const Decays::iNode& n, const Gaudi::Interfaces::IParticlePropertySvc* svc ) { 0170 return n.validate( svc ); 0171 } 0172 } // namespace Gaudi::Decays
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |