Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:07:01

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 <Gaudi/ParticleID.h>
0014 #include <GaudiKernel/StatusCode.h>
0015 #include <string>
0016 #include <vector>
0017 
0018 namespace Gaudi {
0019   namespace Interfaces {
0020     class IParticlePropertySvc;
0021   }
0022   class ParticleProperty;
0023 } // namespace Gaudi
0024 
0025 namespace Gaudi::Decays {
0026   /** @class Decay Kernel/Decay.h
0027    *  The simple representation of "simple 1-step" decay (there are no trees!
0028    *
0029    *  @author  Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0030    *  @date   2008-03-31
0031    */
0032   class GAUDI_API Decay final {
0033   public:
0034     /** @class Item
0035      *  the helper representation of the item in the decay chain
0036      *  @author  Vanya BELYAEV Ivan.Belyaev@nikhef.nl
0037      *  @date   2008-03-31
0038      */
0039     class Item final {
0040     public:
0041       /// the constructor from the particle property
0042       Item( const Gaudi::ParticleProperty* pp = 0 );
0043       /// the constructor from the particle name
0044       Item( const std::string& name );
0045       /// the constructor from the particle PID
0046       Item( const Gaudi::ParticleID& pid );
0047 
0048       /// get the particle name
0049       const std::string& name() const { return m_name; }
0050       /// get the particle PID
0051       const Gaudi::ParticleID& pid() const { return m_pid; }
0052       /// get the particle property
0053       const Gaudi::ParticleProperty* pp() const { return m_pp; }
0054 
0055       /// the default printout
0056       std::ostream& fillStream( std::ostream& s ) const;
0057 
0058       /// validate the item using the service
0059       StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const;
0060       /// validate the item using the particle property object
0061       StatusCode validate( const Gaudi::ParticleProperty* prop ) const;
0062 
0063     private:
0064       /// the particle name
0065       mutable std::string m_name;
0066       /// the particle PID
0067       mutable Gaudi::ParticleID m_pid;
0068       /// the source of properties
0069       mutable const Gaudi::ParticleProperty* m_pp = nullptr;
0070     };
0071 
0072     /// the vector of items (the obvious representation of daughter particles)
0073     typedef std::vector<Item> Items;
0074 
0075   public:
0076     Decay() = default;
0077 
0078     /** the constructor from mother and daughters
0079      *  @param mother the mother
0080      *  @param daughters the daughters
0081      */
0082     Decay( const Gaudi::ParticleProperty* mother, const std::vector<const Gaudi::ParticleProperty*>& daughters );
0083 
0084     /** the constructor from mother and daughters
0085      *  @param mother the mother
0086      *  @param daughters the daughters
0087      */
0088 
0089     Decay( const std::string& mother, const std::vector<std::string>& daughters );
0090     /** the constructor from mother and daughters
0091      *  @param mother the mother
0092      *  @param daughters the daughters
0093      */
0094 
0095     Decay( const Gaudi::ParticleID& mother, const std::vector<Gaudi::ParticleID>& daughters );
0096 
0097     /** the constructor from mother and daughters
0098      *  @param mother the mother
0099      *  @param daughters the daughters
0100      */
0101     Decay( const Item& mother, const std::vector<Item>& daughters );
0102 
0103     /// get the mother(head) of the decay
0104     const Item& mother() const { return m_mother; }
0105     /// get all daughters
0106     const Items& daughters() const { return m_daughters; }
0107     /// get all daughters
0108     const Items& children() const { return daughters(); }
0109     /// get the number of daughters
0110     size_t nDaughters() const { return m_daughters.size(); }
0111     /// get the number of daughters
0112     size_t nChildren() const { return m_daughters.size(); }
0113     /** get the component by the number
0114      *  @attention index 0 corresponds to the mother particle
0115      *  @param index the index (0 corresponds to the mother particle)
0116      *  @return the component
0117      */
0118     const Item& operator()( const unsigned int index ) const;
0119     /** get the component by the number
0120      *  @attention index 0 corresponds to th emother particle
0121      *  @param index the index (0 corresponds to the mother particle)
0122      *  @return the component
0123      */
0124     const Item& operator[]( const unsigned int index ) const { return ( *this )( index ); }
0125 
0126     /// set the mother
0127     void setMother( const Item& mom );
0128     /// set the mother
0129     void setMother( const Gaudi::ParticleProperty* mom );
0130     /// set the mother
0131     void setMother( const std::string& mom );
0132     /// set the mother
0133     void setMother( const Gaudi::ParticleID& mom );
0134     /// set the daughters
0135     void setDaughters( const Items& daugs );
0136     /// set the daughters
0137     void setDaughters( const std::vector<const Gaudi::ParticleProperty*>& daugs );
0138     /// set the daughters
0139     void setDaughters( const std::vector<std::string>& daugs );
0140     /// set the daughters
0141     void setDaughters( const std::vector<Gaudi::ParticleID>& daugs );
0142     /// set the daughters
0143     void setChildren( const Items& daugs ) { setDaughters( daugs ); }
0144     /// set the daughters
0145     void setChildren( const std::vector<const Gaudi::ParticleProperty*>& daugs ) { setDaughters( daugs ); }
0146     /// set the daughters
0147     void setChildren( const std::vector<std::string>& daugs ) { setDaughters( daugs ); }
0148     /// set the daughters
0149     void setChidlren( const std::vector<Gaudi::ParticleID>& daugs ) { setDaughters( daugs ); }
0150 
0151     /// add the child
0152     Decay& operator+=( const std::string& child );
0153     /// add the child
0154     Decay& operator+=( const Gaudi::ParticleID& child );
0155     /// add the child
0156     Decay& operator+=( const Gaudi::ParticleProperty* child );
0157     /// add the child
0158     Decay& operator+=( const Item& child );
0159 
0160     /// validate the decay using the service
0161     StatusCode validate( const Gaudi::Interfaces::IParticlePropertySvc* svc ) const;
0162 
0163     /// the default printout
0164     std::ostream& fillStream( std::ostream& s ) const;
0165     /// the conversion to the string
0166     std::string toString() const;
0167 
0168     /// the head of the decay
0169     mutable Item m_mother; // the head of the decay
0170     /// the daughter particles
0171     mutable Items m_daughters; // the daughter particles
0172   };
0173 } // namespace Gaudi::Decays
0174 
0175 /// the printout operator to the stream
0176 inline std::ostream& operator<<( std::ostream& s, const Gaudi::Decays::Decay& decay ) { return decay.fillStream( s ); }
0177 
0178 /// the printout operator to the stream
0179 inline std::ostream& operator<<( std::ostream& s, const Gaudi::Decays::Decay::Item& item ) {
0180   return item.fillStream( s );
0181 }