Changeset View
Changeset View
Standalone View
Standalone View
src/EvtGenBase/EvtDecayMode.cpp
Show All 26 Lines | |||||
#include <iostream> | #include <iostream> | ||||
using std::endl; | using std::endl; | ||||
using std::ostream; | using std::ostream; | ||||
using std::string; | using std::string; | ||||
using std::vector; | using std::vector; | ||||
EvtDecayMode::EvtDecayMode( std::string mother, vector<string> dau ) : | EvtDecayMode::EvtDecayMode( std::string mother, vector<string> dau ) : | ||||
_mother( mother ), _dau( dau ) | m_mother( mother ), m_dau( dau ) | ||||
{ | { | ||||
} | } | ||||
EvtDecayMode::EvtDecayMode( const EvtDecayMode& other ) : | EvtDecayMode::EvtDecayMode( const EvtDecayMode& other ) : | ||||
_mother( other._mother ), _dau( other._dau ) | m_mother( other.m_mother ), m_dau( other.m_dau ) | ||||
{ | { | ||||
} | } | ||||
EvtDecayMode::EvtDecayMode( const char* decay ) | EvtDecayMode::EvtDecayMode( const char* decay ) | ||||
{ | { | ||||
// Parse the decay string, it should be in a standard | // Parse the decay string, it should be in a standard | ||||
// format, e.g. "B+ -> pi+ pi+ pi-" with all spaces | // format, e.g. "B+ -> pi+ pi+ pi-" with all spaces | ||||
Show All 11 Lines | EvtDecayMode::EvtDecayMode( const char* decay ) | ||||
} | } | ||||
if ( j == string::npos ) { | if ( j == string::npos ) { | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "No space before -> found" << endl; | << "No space before -> found" << endl; | ||||
assert( 0 ); | assert( 0 ); | ||||
} | } | ||||
_mother = string( s, i, j - i ); | m_mother = string( s, i, j - i ); | ||||
i = s.find_first_not_of( " ", j ); | i = s.find_first_not_of( " ", j ); | ||||
j = s.find_first_of( "->", j ); | j = s.find_first_of( "->", j ); | ||||
if ( i != j ) { | if ( i != j ) { | ||||
EvtGenReport( EVTGEN_INFO, "EvtGen" ) | EvtGenReport( EVTGEN_INFO, "EvtGen" ) | ||||
<< "Multiple mothers?" << i << "," << j << endl; | << "Multiple mothers?" << i << "," << j << endl; | ||||
assert( 0 ); | assert( 0 ); | ||||
} | } | ||||
j += 2; | j += 2; | ||||
while ( 1 ) { | while ( 1 ) { | ||||
i = s.find_first_not_of( " ", j ); | i = s.find_first_not_of( " ", j ); | ||||
j = s.find_first_of( " ", i ); | j = s.find_first_of( " ", i ); | ||||
if ( i == string::npos ) | if ( i == string::npos ) | ||||
break; | break; | ||||
if ( j == string::npos ) { | if ( j == string::npos ) { | ||||
_dau.push_back( string( s, i, s.size() - i + 1 ) ); | m_dau.push_back( string( s, i, s.size() - i + 1 ) ); | ||||
break; | break; | ||||
} else { | } else { | ||||
_dau.push_back( string( s, i, j - i ) ); | m_dau.push_back( string( s, i, j - i ) ); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
const char* EvtDecayMode::mother() const | const char* EvtDecayMode::mother() const | ||||
{ | { | ||||
return _mother.c_str(); | return m_mother.c_str(); | ||||
} | } | ||||
int EvtDecayMode::nD() const | int EvtDecayMode::nD() const | ||||
{ | { | ||||
return _dau.size(); | return m_dau.size(); | ||||
} | } | ||||
const char* EvtDecayMode::dau( int i ) const | const char* EvtDecayMode::dau( int i ) const | ||||
{ | { | ||||
assert( 0 <= i && i < (int)_dau.size() ); | assert( 0 <= i && i < (int)m_dau.size() ); | ||||
return _dau[i].c_str(); | return m_dau[i].c_str(); | ||||
} | } | ||||
std::string EvtDecayMode::mode() const | std::string EvtDecayMode::mode() const | ||||
{ | { | ||||
string ret = _mother + string( " -> " ); | string ret = m_mother + string( " -> " ); | ||||
for ( size_t i = 0; i < _dau.size() - 1; i++ ) { | for ( size_t i = 0; i < m_dau.size() - 1; i++ ) { | ||||
ret += string( _dau[i] ) + string( " " ); | ret += string( m_dau[i] ) + string( " " ); | ||||
} | } | ||||
ret += _dau[_dau.size() - 1]; | ret += m_dau[m_dau.size() - 1]; | ||||
return ret; | return ret; | ||||
} | } | ||||
ostream& EvtDecayMode::print( ostream& os ) const | ostream& EvtDecayMode::print( ostream& os ) const | ||||
{ | { | ||||
os << _mother.c_str() << " ->"; | os << m_mother.c_str() << " ->"; | ||||
for ( size_t i = 0; i < _dau.size(); i++ ) { | for ( size_t i = 0; i < m_dau.size(); i++ ) { | ||||
os << " " << _dau[i].c_str(); | os << " " << m_dau[i].c_str(); | ||||
} | } | ||||
return os; | return os; | ||||
} | } | ||||
std::string EvtDecayMode::m( EvtCyclic3::Pair i ) const | std::string EvtDecayMode::m( EvtCyclic3::Pair i ) const | ||||
{ | { | ||||
string s( "m(" ); | string s( "m(" ); | ||||
s.append( dau( EvtCyclic3::first( i ) ) ); | s.append( dau( EvtCyclic3::first( i ) ) ); | ||||
Show All 29 Lines |