00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "EvtGenBase/EvtPatches.hh"
00017
00018
00019
00020
00021
00022 #include "EvtGenBase/EvtPatches.hh"
00023 #include <assert.h>
00024 #include <iostream>
00025 #include "EvtGenBase/EvtDecayMode.hh"
00026 #include "EvtGenBase/EvtReport.hh"
00027 using std::endl;
00028 using std::ostream;
00029
00030 using std::string;
00031 using std::vector;
00032
00033
00034 EvtDecayMode::EvtDecayMode(std::string mother,vector<string> dau)
00035 : _mother(mother)
00036 {
00037 unsigned i;
00038 for(i=0;i<dau.size();i++) {
00039
00040 string s;
00041 s.append(dau[i]);
00042 _dau.push_back(s);
00043 }
00044 }
00045
00046
00047 EvtDecayMode::EvtDecayMode(const EvtDecayMode& other)
00048 : _mother(other._mother)
00049 {
00050 unsigned i;
00051 for(i=0;i<other._dau.size();i++) {
00052
00053 string s;
00054 s.append(other._dau[i]);
00055 _dau.push_back(s);
00056 }
00057 }
00058
00059
00060 EvtDecayMode::EvtDecayMode(const char* decay)
00061 {
00062
00063
00064
00065 string s(decay);
00066 size_t i,j;
00067
00068
00069
00070 i = s.find_first_not_of(" ");
00071 j = s.find_first_of(" ",i);
00072
00073 if(i == string::npos) {
00074
00075 report(INFO,"EvtGen") << "No non-space character found" << endl;
00076 assert(0);
00077 }
00078
00079 if(j == string::npos) {
00080
00081 report(INFO,"EvtGen") << "No space before -> found" << endl;
00082 assert(0);
00083 }
00084
00085 _mother = string(s,i,j-i);
00086
00087 i = s.find_first_not_of(" ",j);
00088 j = s.find_first_of("->",j);
00089 if(i != j) {
00090
00091 report(INFO,"EvtGen") << "Multiple mothers?" << i << "," << j << endl;
00092 assert(0);
00093 }
00094 j += 2;
00095
00096 while(1) {
00097
00098 i = s.find_first_not_of(" ",j);
00099 j = s.find_first_of(" ",i);
00100
00101 if(i == string::npos) break;
00102 if(j == string::npos) {
00103 _dau.push_back(string(s,i,s.size()-i+1));
00104 break;
00105 } else {
00106 _dau.push_back(string(s,i,j-i));
00107 }
00108 }
00109 }
00110
00111
00112
00113 EvtDecayMode::~EvtDecayMode()
00114 {}
00115
00116
00117 const char* EvtDecayMode::mother() const
00118 {
00119 return _mother.c_str();
00120 }
00121
00122
00123 int EvtDecayMode::nD() const
00124 {
00125 return _dau.size();
00126 }
00127
00128
00129 const char* EvtDecayMode::dau(int i) const
00130 {
00131 assert(0<=i && i< (int) _dau.size());
00132 return _dau[i].c_str();
00133 }
00134
00135 const char* EvtDecayMode::mode() const
00136 {
00137 string ret = _mother + string(" -> ");
00138 int i;
00139 for(i=0;i<_dau.size()-1;i++) ret += string(_dau[i]) + string(" ");
00140 ret += _dau[_dau.size()-1];
00141 return ret.c_str();
00142 }
00143
00144
00145 ostream& EvtDecayMode::print(ostream& os) const
00146 {
00147 os << _mother.c_str() << " ->";
00148 unsigned i;
00149 for(i=0;i<_dau.size();i++) os << " " << _dau[i].c_str();
00150 return os;
00151 }
00152
00153
00154 const char* EvtDecayMode::m(EvtCyclic3::Pair i) const
00155 {
00156 string s("m(");
00157 s.append(dau(first(i)));
00158 s.append(",");
00159 s.append(dau(second(i)));
00160 s.append(")");
00161 return s.c_str();
00162 }
00163
00164
00165 const char* EvtDecayMode::q(EvtCyclic3::Pair i) const
00166 {
00167 string s("q(");
00168 s.append(dau(first(i)));
00169 s.append(",");
00170 s.append(dau(second(i)));
00171 s.append(")");
00172 return s.c_str();
00173 }
00174
00175
00176 const char* EvtDecayMode::dal(EvtCyclic3::Pair i, EvtCyclic3::Pair j) const
00177 {
00178 string s(q(i));
00179 s.append(":");
00180 s.append(q(j));
00181 return s.c_str();
00182 }
00183
00184
00185 ostream& operator<<(ostream& os, const EvtDecayMode& mode)
00186 {
00187 mode.print(os);
00188 return os;
00189 }