EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenBase
EvtDecayMode.cpp
Go to the documentation of this file.
1
2
/***********************************************************************
3
* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4
* *
5
* This file is part of EvtGen. *
6
* *
7
* EvtGen is free software: you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation, either version 3 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* EvtGen is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19
***********************************************************************/
20
21
#include "
EvtGenBase/EvtDecayMode.hh
"
22
23
#include "
EvtGenBase/EvtReport.hh
"
24
25
#include <assert.h>
26
#include <iostream>
27
using
std::endl;
28
using
std::ostream;
29
30
using
std::string;
31
using
std::vector;
32
33
EvtDecayMode::EvtDecayMode
( std::string mother, vector<string> dau ) :
34
m_mother( mother ), m_dau( dau )
35
{
36
}
37
38
EvtDecayMode::EvtDecayMode
(
const
EvtDecayMode
& other ) :
39
m_mother
( other.
m_mother
),
m_dau
( other.
m_dau
)
40
{
41
}
42
43
EvtDecayMode::EvtDecayMode
(
const
char
* decay )
44
{
45
// Parse the decay string, it should be in a standard
46
// format, e.g. "B+ -> pi+ pi+ pi-" with all spaces
47
48
string
s( decay );
49
50
// mother
51
52
string::size_type i = s.find_first_not_of(
" "
);
53
string::size_type j = s.find_first_of(
" "
, i );
54
55
if
( i == string::npos ) {
56
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
57
<<
"No non-space character found"
<< endl;
58
assert( 0 );
59
}
60
61
if
( j == string::npos ) {
62
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
63
<<
"No space before -> found"
<< endl;
64
assert( 0 );
65
}
66
67
m_mother
= string( s, i, j - i );
68
69
i = s.find_first_not_of(
" "
, j );
70
j = s.find_first_of(
"->"
, j );
71
if
( i != j ) {
72
EvtGenReport
(
EVTGEN_INFO
,
"EvtGen"
)
73
<<
"Multiple mothers?"
<< i <<
","
<< j << endl;
74
assert( 0 );
75
}
76
j += 2;
77
78
while
( 1 ) {
79
i = s.find_first_not_of(
" "
, j );
80
j = s.find_first_of(
" "
, i );
81
82
if
( i == string::npos )
83
break
;
84
if
( j == string::npos ) {
85
m_dau
.push_back(
string
( s, i, s.size() - i + 1 ) );
86
break
;
87
}
else
{
88
m_dau
.push_back(
string
( s, i, j - i ) );
89
}
90
}
91
}
92
93
const
char
*
EvtDecayMode::mother
()
const
94
{
95
return
m_mother
.c_str();
96
}
97
98
int
EvtDecayMode::nD
()
const
99
{
100
return
m_dau
.size();
101
}
102
103
const
char
*
EvtDecayMode::dau
(
int
i )
const
104
{
105
assert( 0 <= i && i < (
int
)
m_dau
.size() );
106
return
m_dau
[i].c_str();
107
}
108
109
std::string
EvtDecayMode::mode
()
const
110
{
111
string
ret =
m_mother
+ string(
" -> "
);
112
113
for
(
size_t
i = 0; i <
m_dau
.size() - 1; i++ ) {
114
ret += string(
m_dau
[i] ) + string(
" "
);
115
}
116
ret +=
m_dau
[
m_dau
.size() - 1];
117
return
ret;
118
}
119
120
ostream&
EvtDecayMode::print
( ostream& os )
const
121
{
122
os <<
m_mother
.c_str() <<
" ->"
;
123
for
(
size_t
i = 0; i <
m_dau
.size(); i++ ) {
124
os <<
" "
<<
m_dau
[i].c_str();
125
}
126
return
os;
127
}
128
129
std::string
EvtDecayMode::m
(
EvtCyclic3::Pair
i )
const
130
{
131
string
s(
"m("
);
132
s.append(
dau
(
EvtCyclic3::first
( i ) ) );
133
s.append(
","
);
134
s.append(
dau
(
EvtCyclic3::second
( i ) ) );
135
s.append(
")"
);
136
return
s;
137
}
138
139
std::string
EvtDecayMode::q
(
EvtCyclic3::Pair
i )
const
140
{
141
string
s(
"q("
);
142
s.append(
dau
(
EvtCyclic3::first
( i ) ) );
143
s.append(
","
);
144
s.append(
dau
(
EvtCyclic3::second
( i ) ) );
145
s.append(
")"
);
146
return
s;
147
}
148
149
std::string
EvtDecayMode::dal
(
EvtCyclic3::Pair
i,
EvtCyclic3::Pair
j )
const
150
{
151
string
s(
q
( i ) );
152
s.append(
":"
);
153
s.append(
q
( j ) );
154
return
s;
155
}
156
157
ostream&
operator<<
( ostream& os,
const
EvtDecayMode
& mode )
158
{
159
mode.
print
( os );
160
return
os;
161
}
operator<<
ostream & operator<<(ostream &os, const EvtDecayMode &mode)
Definition
EvtDecayMode.cpp:157
EvtDecayMode.hh
EvtReport.hh
EvtGenReport
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition
EvtReport.cpp:32
EVTGEN_INFO
@ EVTGEN_INFO
Definition
EvtReport.hh:52
EvtDecayMode
Definition
EvtDecayMode.hh:30
EvtDecayMode::m_dau
std::vector< std::string > m_dau
Definition
EvtDecayMode.hh:51
EvtDecayMode::mother
const char * mother() const
Definition
EvtDecayMode.cpp:93
EvtDecayMode::q
std::string q(EvtCyclic3::Pair i) const
Definition
EvtDecayMode.cpp:139
EvtDecayMode::EvtDecayMode
EvtDecayMode(const char *decay)
Definition
EvtDecayMode.cpp:43
EvtDecayMode::nD
int nD() const
Definition
EvtDecayMode.cpp:98
EvtDecayMode::dau
const char * dau(int i) const
Definition
EvtDecayMode.cpp:103
EvtDecayMode::m_mother
std::string m_mother
Definition
EvtDecayMode.hh:50
EvtDecayMode::mode
std::string mode() const
Definition
EvtDecayMode.cpp:109
EvtDecayMode::print
std::ostream & print(std::ostream &) const
Definition
EvtDecayMode.cpp:120
EvtDecayMode::m
std::string m(EvtCyclic3::Pair i) const
Definition
EvtDecayMode.cpp:129
EvtDecayMode::dal
std::string dal(EvtCyclic3::Pair i, EvtCyclic3::Pair j) const
Definition
EvtDecayMode.cpp:149
EvtCyclic3::Pair
Pair
Definition
EvtCyclic3.hh:37
EvtCyclic3::second
Index second(Pair i)
Definition
EvtCyclic3.cpp:263
EvtCyclic3::first
Index first(Pair i)
Definition
EvtCyclic3.cpp:249
Generated by
1.17.0