BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtDecayMode.cc
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// File and Version Information:
3// $Id: EvtDecayMode.cc,v 1.1.1.2 2007/10/26 05:03:14 pingrg Exp $
4//
5// Environment:
6// This software is part of the EvtGen package developed jointly
7// for the BaBar and CLEO collaborations. If you use all or part
8// of it, please give an appropriate acknowledgement.
9//
10// Copyright Information:
11// Copyright (C) 1998 Caltech, UCSB
12//
13// Module creator:
14// Alexei Dvoretskii, Caltech, 2001-2002.
15//-----------------------------------------------------------------------
16#include "EvtPatches.hh"
17
18// Parses a decay string to identify the name
19// of the mother and of the daughters. The string should
20// be in standard format e.g. "B+ -> pi+ pi+ pi-"
21
22#include "EvtDecayMode.hh"
23#include "EvtPatches.hh"
24#include "EvtReport.hh"
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 ) : _mother( mother ) {
34 unsigned i;
35 for ( i = 0; i < dau.size(); i++ )
36 {
37
38 string s;
39 s.append( dau[i] );
40 _dau.push_back( s );
41 }
42}
43
44EvtDecayMode::EvtDecayMode( const EvtDecayMode& other ) : _mother( other._mother ) {
45 unsigned i;
46 for ( i = 0; i < other._dau.size(); i++ )
47 {
48
49 string s;
50 s.append( other._dau[i] );
51 _dau.push_back( s );
52 }
53}
54
55EvtDecayMode::EvtDecayMode( const char* decay ) {
56 // Parse the decay string, it should be in a standard
57 // format, e.g. "B+ -> pi+ pi+ pi-" with all spaces
58
59 string s( decay );
60 size_t i, j;
61
62 // mother
63
64 i = s.find_first_not_of( " " );
65 j = s.find_first_of( " ", i );
66
67 if ( i == string::npos )
68 {
69
70 report( INFO, "EvtGen" ) << "No non-space character found" << endl;
71 assert( 0 );
72 }
73
74 if ( j == string::npos )
75 {
76
77 report( INFO, "EvtGen" ) << "No space before -> found" << endl;
78 assert( 0 );
79 }
80
81 _mother = string( s, i, j - i );
82
83 i = s.find_first_not_of( " ", j );
84 j = s.find_first_of( "->", j );
85 if ( i != j )
86 {
87
88 report( INFO, "EvtGen" ) << "Multiple mothers?" << i << "," << j << endl;
89 assert( 0 );
90 }
91 j += 2;
92
93 while ( 1 )
94 {
95
96 i = s.find_first_not_of( " ", j );
97 j = s.find_first_of( " ", i );
98
99 if ( i == string::npos ) break;
100 if ( j == string::npos )
101 {
102 _dau.push_back( string( s, i, s.size() - i + 1 ) );
103 break;
104 }
105 else { _dau.push_back( string( s, i, j - i ) ); }
106 }
107}
108
110
111const char* EvtDecayMode::mother() const { return _mother.c_str(); }
112
113int EvtDecayMode::nD() const { return _dau.size(); }
114
115const char* EvtDecayMode::dau( int i ) const {
116 assert( 0 <= i && i < (int)_dau.size() );
117 return _dau[i].c_str();
118}
119
120const char* EvtDecayMode::mode() const {
121 string ret = _mother + string( " -> " );
122 int i;
123 for ( i = 0; i < _dau.size() - 1; i++ ) ret += string( _dau[i] ) + string( " " );
124 ret += _dau[_dau.size() - 1];
125 return ret.c_str();
126}
127
128ostream& EvtDecayMode::print( ostream& os ) const {
129 os << _mother.c_str() << " ->";
130 unsigned i;
131 for ( i = 0; i < _dau.size(); i++ ) os << " " << _dau[i].c_str();
132 return os;
133}
134
135const char* EvtDecayMode::m( EvtCyclic3::Pair i ) const {
136 string s( "m(" );
137 s.append( dau( first( i ) ) );
138 s.append( "," );
139 s.append( dau( second( i ) ) );
140 s.append( ")" );
141 return s.c_str();
142}
143
144const char* EvtDecayMode::q( EvtCyclic3::Pair i ) const {
145 string s( "q(" );
146 s.append( dau( first( i ) ) );
147 s.append( "," );
148 s.append( dau( second( i ) ) );
149 s.append( ")" );
150 return s.c_str();
151}
152
154 string s( q( i ) );
155 s.append( ":" );
156 s.append( q( j ) );
157 return s.c_str();
158}
159
160ostream& operator<<( ostream& os, const EvtDecayMode& mode ) {
161 mode.print( os );
162 return os;
163}
ostream & operator<<(ostream &os, const EvtDecayMode &mode)
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ INFO
Definition EvtReport.hh:52
XmlRpcServer s
****INTEGER imax DOUBLE PRECISION m_pi *DOUBLE PRECISION m_amfin DOUBLE PRECISION m_Chfin DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_sinw2 DOUBLE PRECISION m_GFermi DOUBLE PRECISION m_MfinMin DOUBLE PRECISION m_ta2 INTEGER m_out INTEGER m_KeyFSR INTEGER m_KeyQCD *COMMON c_Semalib $ !copy of input $ !CMS energy $ !beam mass $ !final mass $ !beam charge $ !final charge $ !smallest final mass $ !Z mass $ !Z width $ !EW mixing angle $ !Gmu Fermi $ alphaQED at q
Definition KKsem.h:33
const char * dal(EvtCyclic3::Pair i, EvtCyclic3::Pair j) const
const char * mother() const
const char * mode() const
EvtDecayMode(const char *decay)
int nD() const
const char * dau(int i) const
const char * q(EvtCyclic3::Pair i) const
std::ostream & print(std::ostream &) const
const char * m(EvtCyclic3::Pair i) const