The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
24namespace Gaudi {
25 namespace Interfaces {
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 }
101
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:
147 std::string m_name;
151 double m_charge;
153 double m_mass;
155 double m_tlife;
159 std::string m_evtgen;
164 };
165} // namespace Gaudi
166
174std::ostream& operator<<( std::ostream& stream, const Gaudi::ParticleProperty& pp );
175
176class MsgStream;
177namespace Gaudi {
178 namespace ParticleProperties {
230 std::ostream& printAsTable_( const std::vector<const Gaudi::ParticleProperty*>& particles, std::ostream& stream,
231 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
232
286 std::string printAsTable( const std::vector<const Gaudi::ParticleProperty*>& particles,
287 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
288
343 MsgStream& printAsTable( const std::vector<const Gaudi::ParticleProperty*>& particles, MsgStream& stream,
344 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
345
355 std::ostream& printAsTable_( const std::vector<Gaudi::ParticleID>& particles, std::ostream& stream,
356 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
357
358 template <class C_, class A_>
359 inline std::ostream& printAsTable_( const std::set<Gaudi::ParticleID, C_, A_>& particles, std::ostream& stream,
360 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) {
361 return printAsTable_( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), stream, service );
362 }
363
372 std::string printAsTable( const std::vector<Gaudi::ParticleID>& particles,
373 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
374
375 template <class C_, class A_>
376 inline std::string printAsTable( const std::set<Gaudi::ParticleID, C_, A_>& particles,
377 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 ) {
378 return printAsTable( std::vector<Gaudi::ParticleID>( particles.begin(), particles.end() ), service );
379 }
380
390 MsgStream& printAsTable( const std::vector<Gaudi::ParticleID>& particles, MsgStream& stream,
391 const Gaudi::Interfaces::IParticlePropertySvc* service = 0 );
392
393 template <class C_, class A_>
394 inline MsgStream& printAsTable( const std::set<Gaudi::ParticleID, C_, A_>& particles, MsgStream& stream,
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
400namespace Gaudi {
401 namespace Utils {
410 std::ostream& toStream( const std::vector<const Gaudi::ParticleProperty*>& particles, std::ostream& stream );
411 } // namespace Utils
412} // namespace Gaudi
413namespace std {
415 const Gaudi::ParticleProperty* abs( const Gaudi::ParticleProperty* p );
416} // namespace std
std::ostream & operator<<(std::ostream &stream, const Gaudi::ParticleProperty &pp)
standard output operator to the stream
#define GAUDI_API
Definition Kernel.h:49
The abstract interface to Particle Property Service.
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
Definition ParticleID.h:43
A trivial class to hold information about a single particle properties.
const Gaudi::ParticleID & pdgID() const
get the particle ID
bool selfcc() const
self-charge conjugated?
double charge() const
Get the particle charge.
std::string m_name
the name for the particle
double lifetime() const
Get the particle lifetime.
const std::string & evtGen() const
Get the EvtGen name.
const Gaudi::ParticleProperty * anti() const
get the pointer to the anti-particle
const Gaudi::ParticleID & particleID() const
get the particle ID
double width() const
Get the particle natural width.
double m_charge
the charge for the particle
const std::string & particle() const
Get the particle name.
const std::string & evtGenName() const
Get the EvtGen name.
friend bool operator<(const ParticleProperty &lhs, const ParticleProperty &rhs)
comparison/ordering operator ( "strict-less-by-PID&Name" )
double maxWidth() const
Get the max width deviation.
double mass() const
Get the particle mass.
Gaudi::ParticleID m_pid
the PID for the particle
const Gaudi::ParticleID & pid() const
get the particle ID
const std::string & name() const
Get the particle name.
int threeCharge() const
Three times the charge (in positron charge units)
int pythia() const
Get the Pythia ID.
int pythiaID() const
Get the Pythia ID.
double m_tlife
the nominal proper lifetime for the particle
double m_mass
the nominal mass for the particle
double ctau() const
Get the particle proper lifetime in c*tau units.
int m_pythia
the ID for the particle used in Pythia generator
const Gaudi::ParticleProperty * antiParticle() const
get the pointer to the anti-particle
const Gaudi::ParticleProperty * m_anti
the pointer to the anti-particle
double m_maxWidth
The maximum width deviation.
std::string m_evtgen
the name of the particle for EvtGen program
double lifeTime() const
Get the particle lifetime.
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29
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
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
constexpr double hbarc
constexpr double c_light
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:304
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
STL namespace.
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition ParticleID.h:191
The comparison criteria for particle properties.
bool operator()(const ParticleProperty *p1, const ParticleProperty *p2) const