1 //-----------------------------------------------------------------------
2 // File and Version Information:
3 // $Id: EvtDecayMode.cc,v 1.17 2009/02/18 03:31:38 ryd Exp $
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.
10 // Copyright Information:
11 // Copyright (C) 1998 Caltech, UCSB
14 // Alexei Dvoretskii, Caltech, 2001-2002.
15 //-----------------------------------------------------------------------
16 #include "EvtGenBase/EvtPatches.hh"
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-"
22 #include "EvtGenBase/EvtPatches.hh"
25 #include "EvtGenBase/EvtDecayMode.hh"
26 #include "EvtGenBase/EvtReport.hh"
34 EvtDecayMode::EvtDecayMode(std::string mother,vector<string> dau)
41 EvtDecayMode::EvtDecayMode(const EvtDecayMode& other)
42 : _mother(other._mother),
48 EvtDecayMode::EvtDecayMode(const char* decay)
50 // Parse the decay string, it should be in a standard
51 // format, e.g. "B+ -> pi+ pi+ pi-" with all spaces
57 string::size_type i = s.find_first_not_of(" ");
58 string::size_type j = s.find_first_of(" ",i);
60 if(i == string::npos) {
62 report(INFO,"EvtGen") << "No non-space character found" << endl;
66 if(j == string::npos) {
68 report(INFO,"EvtGen") << "No space before -> found" << endl;
72 _mother = string(s,i,j-i);
74 i = s.find_first_not_of(" ",j);
75 j = s.find_first_of("->",j);
78 report(INFO,"EvtGen") << "Multiple mothers?" << i << "," << j << endl;
85 i = s.find_first_not_of(" ",j);
86 j = s.find_first_of(" ",i);
88 if(i == string::npos) break;
89 if(j == string::npos) {
90 _dau.push_back(string(s,i,s.size()-i+1));
93 _dau.push_back(string(s,i,j-i));
100 EvtDecayMode::~EvtDecayMode()
104 const char* EvtDecayMode::mother() const
106 return _mother.c_str();
110 int EvtDecayMode::nD() const
116 const char* EvtDecayMode::dau(int i) const
118 assert(0<=i && i< (int) _dau.size());
119 return _dau[i].c_str();
122 std::string EvtDecayMode::mode() const
124 string ret = _mother + string(" -> ");
126 for(size_t i=0;i<_dau.size()-1;i++) {
127 ret += string(_dau[i]) + string(" ");
129 ret += _dau[_dau.size()-1];
134 ostream& EvtDecayMode::print(ostream& os) const
136 os << _mother.c_str() << " ->";
137 for(size_t i=0;i<_dau.size();i++) {
138 os << " " << _dau[i].c_str();
144 std::string EvtDecayMode::m(EvtCyclic3::Pair i) const
147 s.append(dau(EvtCyclic3::first(i)));
149 s.append(dau(EvtCyclic3::second(i)));
155 std::string EvtDecayMode::q(EvtCyclic3::Pair i) const
158 s.append(dau(EvtCyclic3::first(i)));
160 s.append(dau(EvtCyclic3::second(i)));
166 std::string EvtDecayMode::dal(EvtCyclic3::Pair i, EvtCyclic3::Pair j) const
175 ostream& operator<<(ostream& os, const EvtDecayMode& mode)