EvtGen 2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
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
22
24
25#include <assert.h>
26#include <iostream>
27using std::endl;
28using std::ostream;
29
30using std::string;
31using std::vector;
32
33EvtDecayMode::EvtDecayMode( std::string mother, vector<string> dau ) :
34 m_mother( mother ), m_dau( dau )
35{
36}
37
39 m_mother( other.m_mother ), m_dau( other.m_dau )
40{
41}
42
43EvtDecayMode::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
93const char* EvtDecayMode::mother() const
94{
95 return m_mother.c_str();
96}
97
99{
100 return m_dau.size();
101}
102
103const 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
109std::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
120ostream& 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
129std::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
139std::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
150{
151 string s( q( i ) );
152 s.append( ":" );
153 s.append( q( j ) );
154 return s;
155}
156
157ostream& operator<<( ostream& os, const EvtDecayMode& mode )
158{
159 mode.print( os );
160 return os;
161}
ostream & operator<<(ostream &os, const EvtDecayMode &mode)
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition EvtReport.cpp:32
@ EVTGEN_INFO
Definition EvtReport.hh:52
std::vector< std::string > m_dau
const char * mother() const
std::string q(EvtCyclic3::Pair i) const
EvtDecayMode(const char *decay)
int nD() const
const char * dau(int i) const
std::string m_mother
std::string mode() const
std::ostream & print(std::ostream &) const
std::string m(EvtCyclic3::Pair i) const
std::string dal(EvtCyclic3::Pair i, EvtCyclic3::Pair j) const
Index second(Pair i)
Index first(Pair i)