22 for(
int i=0; i<ndaug; ++i ) {
29 for(
int i=0; i<_root.size(); ++i)
delete _root[i];
32bool EvtMTree::parsecheck(
char arg,
const string& chars )
36 for(
int i=0; i<chars.size(); ++i) {
37 ret = ret || (chars[i]==
arg);
43vector<EvtMNode *> EvtMTree::makeparticles(
const string& strid )
45 vector<EvtMNode *> particles;
48 for(
int i = 0; i<_lbltbl.size(); ++i ) {
49 if( _lbltbl[i] == strid ) labels.push_back( i );
52 if( labels.size() == 0 ) {
53 report(
ERROR,
"EvtGen")<<
"Error unknown particle label "<<strid<<endl;
57 for(
int i = 0; i<labels.size(); ++i )
63EvtMRes * EvtMTree::makeresonance(
const EvtId&
id,
const string& ls,
64 const vector<string>& lsarg,
const string& type,
65 const vector<EvtComplex>& amps,
const vector<EvtMNode *>& children )
70 if( ls==
"BREITWIGNER" ) {
72 }
else if( ls==
"TRIVIAL" ) {
76 <<
" not recognized."<<endl;
80 if( type==
"HELAMP" ) {
81 resonance =
new EvtMHelAmp(
id, lineshape, children, amps );
83 report(
ERROR,
"EvtGen")<<
"Model "<<type<<
" not recognized."<<endl;
87 lineshape->
setres( resonance );
92void EvtMTree::parseerror(
bool flag,
ptype& c_iter,
ptype& c_begin,
99 while( c_begin != c_end ) {
100 if(c_begin == c_iter) {
118 while(c_iter != c_end) {
119 parseerror(parsecheck(*c_iter,
")[],"), c_iter, c_begin, c_end);
120 if( *c_iter ==
'(' ) {
132string EvtMTree::parseKey(
ptype& c_iter,
ptype& c_begin,
ptype& c_end )
136 while( *c_iter !=
',' ) {
137 parseerror(c_iter==c_end || parsecheck(*c_iter,
"()[]"),
138 c_iter, c_begin, c_end);
145 parseerror(c_iter == c_end, c_iter, c_begin, c_end);
150vector<string> EvtMTree::parseArg(
ptype &c_iter,
ptype &c_begin,
ptype &c_end )
154 if( *c_iter !=
'[' )
return arg;
159 parseerror( c_iter == c_end || parsecheck(*c_iter,
"[()"),
160 c_iter, c_begin, c_end );
162 if( *c_iter ==
']' ) {
164 if(temp.size() > 0)
arg.push_back( temp );
168 if( *c_iter ==
',') {
169 arg.push_back( temp );
178 parseerror(c_iter == c_end || *c_iter !=
',', c_iter, c_begin, c_end);
184vector<EvtComplex> EvtMTree::parseAmps(
ptype &c_iter,
187 vector<string> parg = parseArg( c_iter, c_begin, c_end );
188 parseerror( parg.size() == 0, c_iter, c_begin, c_end );
191 vector<string>::iterator amp_iter = parg.begin();
192 vector<string>::iterator amp_end = parg.end();
193 vector<EvtComplex> amps;
195 while( amp_iter != amp_end ) {
197 char * endptr =
NULL;
198 double amp=0.0, phase=0.0;
200 nptr = (*amp_iter).c_str();
201 amp = strtod(nptr, &endptr);
202 parseerror( nptr==endptr, c_iter, c_begin, c_end );
205 parseerror( amp_iter == amp_end, c_iter, c_begin, c_end );
207 nptr = (*amp_iter).c_str();
208 phase = strtod(nptr, &endptr);
209 parseerror( nptr==endptr, c_iter, c_begin, c_end );
219vector<EvtMNode *> EvtMTree::duplicate(
const vector<EvtMNode *>& list )
const
221 vector<EvtMNode *> newlist;
223 for(
int i=0; i<list.size(); ++i)
224 newlist.push_back( list[i]->duplicate() );
231vector< vector<EvtMNode * > > EvtMTree::unionChildren(
const string& nodestr,
232 vector< vector<EvtMNode * > >& cl1 )
234 vector<EvtMNode *> cl2 = parsenode( nodestr,
false );
235 vector< vector<EvtMNode * > > cl;
237 if( cl1.size() == 0 ) {
238 for(
int i=0; i<cl2.size(); ++i ) {
239 vector<EvtMNode *> temp(1, cl2[i]);
240 cl.push_back( temp );
246 for(
int i=0; i<cl1.size(); ++i ) {
247 for(
int j=0; j<cl2.size(); ++j ) {
248 vector<EvtMNode *> temp;
249 temp = duplicate( cl1[i] );
250 temp.push_back( cl2[j]->duplicate() );
252 cl.push_back( temp );
256 for(
int i=0; i<cl1.size(); ++i)
257 for(
int j=0; j<cl1[i].size(); ++j)
259 for(
int i=0; i<cl2.size(); ++i)
265vector< vector<EvtMNode * > > EvtMTree::parseChildren(
ptype &c_iter,
271 vector< vector<EvtMNode * > > children;
273 parseerror(c_iter == c_end || *c_iter !=
'[', c_iter, c_begin, c_end );
277 parseerror( c_iter==c_end || pcount < 0, c_iter, c_begin, c_end );
290 children = unionChildren( nodestr, children );
298 children = unionChildren( nodestr, children );
315vector<EvtMNode *> EvtMTree::parsenode(
const string& args,
bool rootnode )
317 ptype c_iter, c_begin, c_end;
319 c_iter=c_begin=args.begin();
322 string strid = parseId( c_iter, c_begin, c_end );
325 if( c_iter == c_end )
return makeparticles( strid );
329 parseerror(
EvtId( -1, -1 )==
id, c_iter, c_begin, c_end);
332 vector<string> lsarg;
338 ls = parseKey( c_iter, c_begin, c_end );
339 lsarg = parseArg( c_iter, c_begin, c_end );
343 string type = parseKey( c_iter, c_begin, c_end );
344 vector<EvtComplex> amps = parseAmps( c_iter, c_begin, c_end );
347 vector<vector<EvtMNode * > > children = parseChildren( c_iter, c_begin,
351 vector<EvtMNode *> resonances;
352 for(
int i=0; i<children.size(); ++i ) {
353 resonances.push_back(makeresonance(
id,ls,lsarg,type,amps,children[i]));
356 parseerror(c_iter == c_end || *c_iter!=
')', c_iter, c_begin, c_end);
363 vector<int> res =
root->getresonance();
364 vector<bool> check(res.size(),
false);
366 for(
int i=0; i<res.size(); ++i) {
367 check[res[i]] =
true;
372 for(
int i=0; i<check.size(); ++i ) {
381 vector<EvtMNode *> roots = parsenode( str,
true );
384 for(
int i=0; i<roots.size(); ++i ) {
385 if( validTree( roots[i] ) ) {
386 _root.push_back( roots[i] );
392 _norm = 1.0/sqrt(_norm);
398 if( _root.size() == 0 ) {
399 report(
ERROR,
"EvtGen")<<
"No decay tree present."<<endl;
403 EvtSpinAmp amp = _root[0]->amplitude( product );
404 for(
int i=1; i<_root.size(); ++i ) {
408 amp += _root[i]->amplitude( product );
EvtComplex exp(const EvtComplex &c)
double arg(const EvtComplex &c)
string::const_iterator ptype
ostream & report(Severity severity, const char *facility)
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
EvtMTree(const EvtId *idtbl, int ndaug)
void addtree(const string &args)
EvtSpinAmp amplitude(const vector< EvtVector4R > &product) const
static std::string name(EvtId i)
static EvtId getId(const std::string &name)