The Gaudi Framework  master (37c0b60a)
ParticleProperty.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 #include <Gaudi/ParticleID.h>
14 #include <GaudiKernel/Kernel.h>
16 #include <cmath>
17 #include <functional>
18 #include <iosfwd>
19 #include <limits>
20 #include <set>
21 #include <string>
22 #include <vector>
23 
24 namespace Gaudi {
25  namespace Interfaces {
26  class IParticlePropertySvc;
27  }
28 
38  public:
44  struct Compare {
45  inline bool operator()( const ParticleProperty* p1, const ParticleProperty* p2 ) const {
46  return p1 == p2 ? false : 0 == p1 ? true : 0 == p2 ? false : ( *p1 < *p2 );
47  }
48  };
49 
60  ParticleProperty( const std::string& name, const Gaudi::ParticleID& pid, const double charge, const double mass,
61  const double tlife, const double maxWidth, const std::string& evtgen, const int pythia );
74  ParticleProperty( const std::string& name, const Gaudi::ParticleID& pid, const double charge, const double mass,
75  const double tlife, const double maxWidth );
76 
78  const std::string& particle() const { return m_name; }
80  const std::string& name() const { return m_name; }
82  const Gaudi::ParticleID& particleID() const { return m_pid; }
84  const Gaudi::ParticleID& pdgID() const { return m_pid; }
86  const Gaudi::ParticleID& pid() const { return m_pid; }
88  double charge() const { return m_charge; }
90  double mass() const { return m_mass; }
92  double lifetime() const { return m_tlife; }
94  double lifeTime() const { return m_tlife; }
96  double ctau() const { return Gaudi::Units::c_light * lifeTime(); }
98  double width() const {
99  return std::abs( ctau() ) < std::numeric_limits<double>::epsilon() ? 0.0 : Gaudi::Units::hbarc / ctau();
100  }
102  double maxWidth() const { return m_maxWidth; } // max-width
104  const Gaudi::ParticleProperty* antiParticle() const { return anti(); }
106  const Gaudi::ParticleProperty* anti() const { return m_anti; }
107 
109  bool selfcc() const { return m_anti == this; }
110 
112  int threeCharge() const { return m_pid.threeCharge(); }
113 
118  void setAntiParticle( const ParticleProperty* p );
119 
121  const std::string& evtGenName() const { return m_evtgen; }
123  const std::string& evtGen() const { return m_evtgen; }
125  int pythiaID() const { return m_pythia; }
127  int pythia() const { return m_pythia; }
128 
130  friend bool operator<( const ParticleProperty& lhs, const ParticleProperty& rhs ) {
131  return std::tie( lhs.m_pid, lhs.m_name ) < std::tie( rhs.m_pid, rhs.m_name );
132  }
133 
135  operator const Gaudi::ParticleID&() const { return m_pid; }
136 
141  std::ostream& fillStream( std::ostream& s ) const;
143  std::string toString() const;
144 
145  private:
151  double m_charge;
153  double m_mass;
155  double m_tlife;
157  double m_maxWidth;
161  int m_pythia;
164  };
165 } // namespace Gaudi
166 
175 
176 class MsgStream;
177 namespace Gaudi {
178  namespace ParticleProperties {
229  GAUDI_API
231  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
232 
285  GAUDI_API
287  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
288 
342  GAUDI_API
344  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
345 
354  GAUDI_API
356  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
357 
358  template <class C_, class A_>
360  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) {
361  return printAsTable_( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service );
362  }
363 
371  GAUDI_API
373  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
374 
375  template <class C_, class A_>
377  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) {
378  return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), service );
379  }
380 
389  GAUDI_API
391  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
392 
393  template <class C_, class A_>
395  const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) {
396  return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service );
397  }
398  } // namespace ParticleProperties
399 } // namespace Gaudi
400 namespace Gaudi {
401  namespace Utils {
409  GAUDI_API
411  } // namespace Utils
412 } // namespace Gaudi
413 namespace std {
414  GAUDI_API
416 } // namespace std
Gaudi::Units::hbarc
constexpr double hbarc
Definition: PhysicalConstants.h:76
operator<<
std::ostream & operator<<(std::ostream &stream, const Gaudi::ParticleProperty &pp)
standard output operator to the stream
Definition: ParticleProperty.cpp:30
Gaudi::ParticleProperty::m_pythia
int m_pythia
the ID for the particle used in Pythia generator
Definition: ParticleProperty.h:161
Gaudi::ParticleProperty::pythia
int pythia() const
Get the Pythia ID.
Definition: ParticleProperty.h:127
Gaudi::ParticleProperty::pdgID
const Gaudi::ParticleID & pdgID() const
get the particle ID
Definition: ParticleProperty.h:84
Write.stream
stream
Definition: Write.py:32
Gaudi::ParticleProperty::threeCharge
int threeCharge() const
Three times the charge (in positron charge units)
Definition: ParticleProperty.h:112
std::string
STL class.
AlgSequencer.p2
p2
Definition: AlgSequencer.py:30
Gaudi::ParticleProperty::pid
const Gaudi::ParticleID & pid() const
get the particle ID
Definition: ParticleProperty.h:86
gaudirun.s
string s
Definition: gaudirun.py:346
Gaudi::ParticleProperty::m_name
std::string m_name
the name for the particle
Definition: ParticleProperty.h:147
std::vector
STL class.
Gaudi::ParticleProperty::particle
const std::string & particle() const
Get the particle name.
Definition: ParticleProperty.h:78
Gaudi::ParticleProperty::width
double width() const
Get the particle natural width.
Definition: ParticleProperty.h:98
ParticleProperty
Definition: ParticleProperty.py:1
Gaudi::ParticleProperty::lifeTime
double lifeTime() const
Get the particle lifetime.
Definition: ParticleProperty.h:94
Gaudi::Interfaces::IParticlePropertySvc
Definition: IParticlePropertySvc.h:29
Gaudi::ParticleProperty::name
const std::string & name() const
Get the particle name.
Definition: ParticleProperty.h:80
Gaudi::ParticleProperty::m_maxWidth
double m_maxWidth
The maximum width deviation.
Definition: ParticleProperty.h:157
Gaudi::ParticleProperty::m_anti
const Gaudi::ParticleProperty * m_anti
the pointer to the anti-particle
Definition: ParticleProperty.h:163
ParticleID.h
Gaudi::ParticleProperty::anti
const Gaudi::ParticleProperty * anti() const
get the pointer to the anti-particle
Definition: ParticleProperty.h:106
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition: ParticleID.h:191
PhysicalConstants.h
Gaudi::ParticleProperty::antiParticle
const Gaudi::ParticleProperty * antiParticle() const
get the pointer to the anti-particle
Definition: ParticleProperty.h:104
Gaudi::ParticleProperty::evtGenName
const std::string & evtGenName() const
Get the EvtGen name.
Definition: ParticleProperty.h:121
Gaudi::ParticleProperty::maxWidth
double maxWidth() const
Get the max width deviation.
Definition: ParticleProperty.h:102
Gaudi::ParticleProperty::operator<
friend bool operator<(const ParticleProperty &lhs, const ParticleProperty &rhs)
comparison/ordering operator ( "strict-less-by-PID&Name" )
Definition: ParticleProperty.h:130
std::tie
T tie(T... args)
Gaudi::ParticleProperties::printAsTable
GAUDI_API std::string printAsTable(const std::vector< const Gaudi::ParticleProperty * > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
print a list of properties in a form of the table
Definition: ParticleProperty.cpp:319
Gaudi::ParticleProperty::Compare::operator()
bool operator()(const ParticleProperty *p1, const ParticleProperty *p2) const
Definition: ParticleProperty.h:45
Gaudi::ParticleProperty::ctau
double ctau() const
Get the particle proper lifetime in c*tau units.
Definition: ParticleProperty.h:96
std::ostream
STL class.
Gaudi::ParticleProperty::mass
double mass() const
Get the particle mass.
Definition: ParticleProperty.h:90
Gaudi::ParticleProperties::printAsTable_
GAUDI_API std::ostream & printAsTable_(const std::vector< const Gaudi::ParticleProperty * > &particles, std::ostream &stream, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
print a list of properties in a form of the table
Definition: ParticleProperty.cpp:173
Gaudi::ParticleProperty::m_charge
double m_charge
the charge for the particle
Definition: ParticleProperty.h:151
AlgSequencer.p1
p1
Definition: AlgSequencer.py:29
Gaudi::ParticleProperty::m_pid
Gaudi::ParticleID m_pid
the PID for the particle
Definition: ParticleProperty.h:149
Gaudi::ParticleProperty::pythiaID
int pythiaID() const
Get the Pythia ID.
Definition: ParticleProperty.h:125
Gaudi::Units::c_light
constexpr double c_light
Definition: PhysicalConstants.h:66
Gaudi::ParticleProperty::m_mass
double m_mass
the nominal mass for the particle
Definition: ParticleProperty.h:153
Gaudi::ParticleProperty
Definition: ParticleProperty.h:37
MsgStream
Definition: MsgStream.h:33
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
std::numeric_limits::epsilon
T epsilon(T... args)
Gaudi::ParticleProperty::m_tlife
double m_tlife
the nominal proper lifetime for the particle
Definition: ParticleProperty.h:155
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:353
Gaudi::ParticleProperty::m_evtgen
std::string m_evtgen
the name of the particle for EvtGen program
Definition: ParticleProperty.h:159
Gaudi::ParticleProperty::particleID
const Gaudi::ParticleID & particleID() const
get the particle ID
Definition: ParticleProperty.h:82
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
std::set::begin
T begin(T... args)
std
STL namespace.
Kernel.h
Gaudi::Utils::toStream
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
Definition: ToStream.h:299
Gaudi::ParticleProperty::charge
double charge() const
Get the particle charge.
Definition: ParticleProperty.h:88
Gaudi::ParticleID
Definition: ParticleID.h:43
Gaudi::ParticleProperty::selfcc
bool selfcc() const
self-charge conjugated?
Definition: ParticleProperty.h:109
Gaudi::ParticleProperty::lifetime
double lifetime() const
Get the particle lifetime.
Definition: ParticleProperty.h:92
Gaudi::ParticleProperty::evtGen
const std::string & evtGen() const
Get the EvtGen name.
Definition: ParticleProperty.h:123
Gaudi::ParticleProperty::Compare
Definition: ParticleProperty.h:44
std::set::end
T end(T... args)
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:507
std::set
STL class.
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81