The Gaudi Framework
master (6507eef1)
Toggle main menu visibility
Loading...
Searching...
No Matches
Decay.cpp
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
#include <
Gaudi/Decays/Decay.h
>
12
#include <
Gaudi/Interfaces/IParticlePropertySvc.h
>
13
#include <
Gaudi/ParticleID.h
>
14
#include <
Gaudi/ParticleProperty.h
>
15
#include <sstream>
16
17
namespace
Decays
=
Gaudi::Decays
;
18
24
Decays::Decay::Item::Item
(
const
Gaudi::ParticleProperty
*
pp
) :
m_pp
(
pp
) {
25
if
(
m_pp
) {
26
m_name
=
m_pp
->particle();
27
m_pid
=
m_pp
->particleID();
28
}
29
}
30
31
Decays::Decay::Item::Item
(
const
std::string&
name
) :
m_name
(
name
) {}
32
33
Decays::Decay::Item::Item
(
const
Gaudi::ParticleID
&
pid
) :
m_pid
(
pid
) {}
34
35
StatusCode
Decays::Decay::Item::validate
(
const
Gaudi::Interfaces::IParticlePropertySvc
* svc )
const
{
36
if
(
m_pp
) {
37
m_name
=
m_pp
->particle();
38
m_pid
=
m_pp
->particleID();
39
return
StatusCode::SUCCESS
;
40
}
41
// it not possible to validate it!
42
if
( 0 == svc ) {
return
StatusCode::FAILURE
; }
43
// check by name
44
if
( !
m_name
.empty() ) {
45
m_pp
= svc->
find
(
m_name
);
46
if
( !
m_pp
) {
return
StatusCode::FAILURE
; }
47
m_pid
=
m_pp
->particleID();
48
return
StatusCode::SUCCESS
;
49
}
50
// check by PID
51
if
(
Gaudi::ParticleID
() !=
m_pid
) {
52
m_pp
= svc->
find
(
m_pid
);
53
if
( !
m_pp
) {
return
StatusCode::FAILURE
; }
54
m_name
=
m_pp
->particle();
55
return
StatusCode::SUCCESS
;
56
}
57
return
StatusCode::FAILURE
;
58
}
59
60
StatusCode
Decays::Decay::Item::validate
(
const
Gaudi::ParticleProperty
*
pp
)
const
{
61
if
(
m_pp
&& !
pp
) {
62
m_name
=
m_pp
->particle();
63
m_pid
=
m_pp
->particleID();
64
return
StatusCode::SUCCESS
;
65
}
else
if
(
pp
) {
66
m_pp
=
pp
;
67
m_name
=
m_pp
->particle();
68
m_pid
=
m_pp
->particleID();
69
return
StatusCode::SUCCESS
;
70
}
71
return
StatusCode::FAILURE
;
72
}
73
74
Decays::Decay::Decay
(
const
Gaudi::ParticleProperty
*
mother
,
75
const
std::vector<const Gaudi::ParticleProperty*>&
daughters
)
76
:
m_mother
(
mother
) {
77
setDaughters
(
daughters
);
78
}
79
80
Decays::Decay::Decay
(
const
std::string&
mother
,
const
std::vector<std::string>&
daughters
) :
m_mother
(
mother
) {
81
setDaughters
(
daughters
);
82
}
83
84
Decays::Decay::Decay
(
const
Gaudi::ParticleID
&
mother
,
const
std::vector<Gaudi::ParticleID>&
daughters
)
85
:
m_mother
(
mother
) {
86
setDaughters
(
daughters
);
87
}
88
89
Decays::Decay::Decay
(
const
Decays::Decay::Item
&
mother
,
const
std::vector<Decays::Decay::Item>&
daughters
)
90
:
m_mother
(
mother
),
m_daughters
(
daughters
) {}
91
92
StatusCode
Decays::Decay::validate
(
const
Gaudi::Interfaces::IParticlePropertySvc
* svc )
const
{
93
// validate the mother
94
StatusCode
sc =
m_mother
.validate( svc );
95
if
( sc.
isFailure
() ) {
return
sc; }
96
if
(
m_daughters
.empty() ) {
return
StatusCode::FAILURE
; }
97
// loop over daughters
98
for
(
auto
idau =
m_daughters
.begin();
m_daughters
.end() != idau; ++idau ) {
99
sc = idau->validate( svc );
100
if
( sc.
isFailure
() ) {
return
sc; }
101
}
102
return
sc;
103
}
104
105
std::ostream&
Decays::Decay::fillStream
( std::ostream& s )
const
{
106
m_mother
.fillStream( s );
107
if
(
m_daughters
.empty() ) {
return
s; }
108
s <<
"->"
;
109
// loop over daughters
110
for
(
const
auto
& dau :
m_daughters
) { dau.fillStream( s ); }
111
return
s;
112
}
113
114
std::ostream&
Decays::Decay::Item::fillStream
( std::ostream& s )
const
{
115
if
(
m_name
.empty() ) {
116
if
(
m_pp
) {
117
m_name
=
m_pp
->particle();
118
}
else
if
(
Gaudi::ParticleID
() !=
m_pid
) {
119
return
s <<
' '
<<
m_pid
.pid() <<
' '
;
120
}
else
{
121
return
s <<
" ? "
;
122
}
123
}
124
return
s <<
' '
<<
m_name
<<
' '
;
125
}
126
127
std::string
Decays::Decay::toString
()
const
{
128
std::ostringstream s;
129
fillStream
( s );
130
return
s.str();
131
}
132
133
void
Decays::Decay::setDaughters
(
const
std::vector<const Gaudi::ParticleProperty*>& daugs ) {
134
m_daughters
.clear();
135
for
(
const
auto
& pp : daugs ) *
this
+= pp;
136
}
137
138
void
Decays::Decay::setDaughters
(
const
std::vector<std::string>& daugs ) {
139
m_daughters
.clear();
140
for
(
const
auto
& pp : daugs ) *
this
+= pp;
141
}
142
143
void
Decays::Decay::setDaughters
(
const
std::vector<Gaudi::ParticleID>& daugs ) {
144
m_daughters
.clear();
145
for
(
const
auto
& pp : daugs ) *
this
+= pp;
146
}
147
148
void
Decays::Decay::setDaughters
(
const
Decays::Decay::Items
& daugs ) {
m_daughters
= daugs; }
149
150
Decays::Decay
&
Decays::Decay::operator+=
(
const
std::string& child ) {
return
( *
this
) +=
Item
( child ); }
151
152
Decays::Decay
&
Decays::Decay::operator+=
(
const
Gaudi::ParticleID
& child ) {
return
( *
this
) +=
Item
( child ); }
153
154
Decays::Decay
&
Decays::Decay::operator+=
(
const
Gaudi::ParticleProperty
* child ) {
return
( *
this
) +=
Item
( child ); }
155
156
Decays::Decay
&
Decays::Decay::operator+=
(
const
Decays::Decay::Item
& child ) {
157
m_daughters
.push_back( child );
158
return
*
this
;
159
}
160
161
/* get the component by the number
162
* @attention index 0 corresponds to the mother particle
163
* @param index the index (0 corresponds to the mother particle)
164
* @return the component
165
*/
166
const
Decays::Decay::Item
&
Decays::Decay::operator()
(
const
unsigned
int
index )
const
{
167
if
( 0 == index ) {
return
m_mother
; }
168
return
m_daughters
[index - 1];
169
}
170
171
void
Decays::Decay::setMother
(
const
Decays::Decay::Item
& mom ) {
m_mother
= mom; }
172
173
void
Decays::Decay::setMother
(
const
Gaudi::ParticleProperty
* mom ) {
setMother
(
Item
( mom ) ); }
174
175
void
Decays::Decay::setMother
(
const
Gaudi::ParticleID
& mom ) {
setMother
(
Item
( mom ) ); }
176
177
void
Decays::Decay::setMother
(
const
std::string& mom ) {
setMother
(
Item
( mom ) ); }
Decay.h
ParticleProperty.h
IParticlePropertySvc.h
ParticleID.h
Gaudi::Decays::Decay::Item
the helper representation of the item in the decay chain
Definition
Decay.h:39
Gaudi::Decays::Decay::Item::m_name
std::string m_name
the particle name
Definition
Decay.h:65
Gaudi::Decays::Decay::Item::pp
const Gaudi::ParticleProperty * pp() const
get the particle property
Definition
Decay.h:53
Gaudi::Decays::Decay::Item::pid
const Gaudi::ParticleID & pid() const
get the particle PID
Definition
Decay.h:51
Gaudi::Decays::Decay::Item::validate
StatusCode validate(const Gaudi::Interfaces::IParticlePropertySvc *svc) const
validate the item using the service
Definition
Decay.cpp:35
Gaudi::Decays::Decay::Item::m_pid
Gaudi::ParticleID m_pid
the particle PID
Definition
Decay.h:67
Gaudi::Decays::Decay::Item::Item
Item(const Gaudi::ParticleProperty *pp=0)
the constructor from the particle property
Definition
Decay.cpp:24
Gaudi::Decays::Decay::Item::m_pp
const Gaudi::ParticleProperty * m_pp
the source of properties
Definition
Decay.h:69
Gaudi::Decays::Decay::Item::fillStream
std::ostream & fillStream(std::ostream &s) const
the default printout
Definition
Decay.cpp:114
Gaudi::Decays::Decay::Item::name
const std::string & name() const
get the particle name
Definition
Decay.h:49
Gaudi::Decays::Decay
The simple representation of "simple 1-step" decay (there are no trees!
Definition
Decay.h:32
Gaudi::Decays::Decay::validate
StatusCode validate(const Gaudi::Interfaces::IParticlePropertySvc *svc) const
validate the decay using the service
Definition
Decay.cpp:92
Gaudi::Decays::Decay::operator+=
Decay & operator+=(const std::string &child)
add the child
Definition
Decay.cpp:150
Gaudi::Decays::Decay::toString
std::string toString() const
the conversion to the string
Definition
Decay.cpp:127
Gaudi::Decays::Decay::fillStream
std::ostream & fillStream(std::ostream &s) const
the default printout
Definition
Decay.cpp:105
Gaudi::Decays::Decay::m_daughters
Items m_daughters
the daughter particles
Definition
Decay.h:171
Gaudi::Decays::Decay::operator()
const Item & operator()(const unsigned int index) const
get the component by the number
Definition
Decay.cpp:166
Gaudi::Decays::Decay::setDaughters
void setDaughters(const Items &daugs)
set the daughters
Definition
Decay.cpp:148
Gaudi::Decays::Decay::mother
const Item & mother() const
get the mother(head) of the decay
Definition
Decay.h:104
Gaudi::Decays::Decay::Items
std::vector< Item > Items
the vector of items (the obvious representation of daughter particles)
Definition
Decay.h:73
Gaudi::Decays::Decay::Decay
Decay()=default
Gaudi::Decays::Decay::daughters
const Items & daughters() const
get all daughters
Definition
Decay.h:106
Gaudi::Decays::Decay::m_mother
Item m_mother
the head of the decay
Definition
Decay.h:169
Gaudi::Decays::Decay::setMother
void setMother(const Item &mom)
set the mother
Definition
Decay.cpp:171
Gaudi::Interfaces::IParticlePropertySvc
The abstract interface to Particle Property Service.
Definition
IParticlePropertySvc.h:29
Gaudi::Interfaces::IParticlePropertySvc::find
virtual const ParticleProperty * find(const std::string &name) const =0
Retrieve an object by name:
Gaudi::ParticleID
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
Definition
ParticleID.h:43
Gaudi::ParticleProperty
A trivial class to hold information about a single particle properties.
Definition
ParticleProperty.h:37
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isFailure
bool isFailure() const
Definition
StatusCode.h:118
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
Gaudi::Decays
Definition
CC.h:17
GaudiPartProp
src
Decay.cpp
Generated on
for The Gaudi Framework by
1.17.0