EvtMTree Class Reference

#include <EvtMTree.hh>

List of all members.

Public Member Functions

 EvtMTree (const EvtId *idtbl, int ndaug)
 ~EvtMTree ()
EvtSpinAmp amplitude (const vector< EvtVector4R > &product) const
void addtree (const string &args)

Private Member Functions

bool parsecheck (char arg, const string &chars)
void parseerror (bool, ptype &, ptype &, ptype &)
string parseId (ptype &, ptype &, ptype &)
string parseKey (ptype &, ptype &, ptype &)
vector< stringparseArg (ptype &, ptype &, ptype &)
vector< EvtComplexparseAmps (ptype &, ptype &, ptype &)
vector< EvtMNode * > duplicate (const vector< EvtMNode * > &) const
vector< vector< EvtMNode * > > unionChildren (const string &, vector< vector< EvtMNode * > > &)
vector< vector< EvtMNode * > > parseChildren (ptype &, ptype &, ptype &)
vector< EvtMNode * > parsenode (const string &, bool)
bool validTree (const EvtMNode *) const
vector< EvtMNode * > makeparticles (const string &)
EvtMResmakeresonance (const EvtId &, const string &, const vector< string > &, const string &, const vector< EvtComplex > &, const vector< EvtMNode * > &)

Private Attributes

vector< EvtMNode * > _root
vector< string_lbltbl
double _norm


Detailed Description

Definition at line 21 of file EvtMTree.hh.


Constructor & Destructor Documentation

EvtMTree::EvtMTree ( const EvtId idtbl,
int  ndaug 
)

Definition at line 20 of file EvtMTree.cc.

References _lbltbl, genRecEmupikp::i, and EvtPDL::name().

00021 {
00022     for( int i=0; i<ndaug; ++i ) {
00023         _lbltbl.push_back( EvtPDL::name( idtbl[i] ) );
00024     }
00025 }

EvtMTree::~EvtMTree (  ) 

Definition at line 27 of file EvtMTree.cc.

References _root, and genRecEmupikp::i.

00028 {
00029     for(int i=0; i<_root.size(); ++i) delete _root[i];
00030 }


Member Function Documentation

void EvtMTree::addtree ( const string args  ) 

Definition at line 379 of file EvtMTree.cc.

References _norm, _root, genRecEmupikp::i, parsenode(), and validTree().

Referenced by EvtMultibody::init().

00380 {
00381     vector<EvtMNode *> roots = parsenode( str, true );
00382     _norm = 0;
00383 
00384     for( int i=0; i<roots.size(); ++i ) {
00385         if( validTree( roots[i] ) ) {
00386             _root.push_back( roots[i] );
00387             _norm = _norm + 1;
00388         } else
00389             delete roots[i];
00390     }
00391     
00392     _norm = 1.0/sqrt(_norm);
00393 }

EvtSpinAmp EvtMTree::amplitude ( const vector< EvtVector4R > &  product  )  const

Definition at line 395 of file EvtMTree.cc.

References _norm, _root, calibUtil::ERROR, genRecEmupikp::i, and report().

Referenced by EvtMultibody::decay().

00397 {
00398     if( _root.size() == 0 ) {
00399         report(ERROR, "EvtGen")<<"No decay tree present."<<endl;
00400         ::abort();
00401     }
00402     
00403     EvtSpinAmp amp = _root[0]->amplitude( product );
00404     for( int i=1; i<_root.size(); ++i ) {
00405         // Assume that helicity amplitude is returned and rotate to standard
00406         // amplitude here, do this before adding the amplitudes (different
00407         // frames?)
00408         amp += _root[i]->amplitude( product );
00409     }
00410 
00411     return _norm*amp;
00412 }

vector< EvtMNode * > EvtMTree::duplicate ( const vector< EvtMNode * > &   )  const [private]

Definition at line 219 of file EvtMTree.cc.

References genRecEmupikp::i.

Referenced by unionChildren().

00220 {
00221     vector<EvtMNode *> newlist;
00222 
00223     for(int i=0; i<list.size(); ++i)
00224         newlist.push_back( list[i]->duplicate() );
00225 
00226     return newlist;
00227 }

vector< EvtMNode * > EvtMTree::makeparticles ( const string  )  [private]

Definition at line 43 of file EvtMTree.cc.

References _lbltbl, calibUtil::ERROR, EvtPDL::getId(), genRecEmupikp::i, and report().

Referenced by parsenode().

00044 {
00045     vector<EvtMNode *> particles;
00046     vector<int> labels;
00047    
00048     for( int i = 0; i<_lbltbl.size(); ++i ) {
00049         if( _lbltbl[i] == strid ) labels.push_back( i );
00050     }
00051     
00052     if( labels.size() == 0 ) {
00053         report(ERROR,"EvtGen")<<"Error unknown particle label "<<strid<<endl;
00054         ::abort();
00055     }
00056 
00057     for( int i = 0; i<labels.size(); ++i )
00058         particles.push_back( new EvtMParticle( labels[i], EvtPDL::getId( strid ) ) );
00059 
00060     return particles;
00061 }

EvtMRes * EvtMTree::makeresonance ( const EvtId ,
const string ,
const vector< string > &  ,
const string ,
const vector< EvtComplex > &  ,
const vector< EvtMNode * > &   
) [private]

Definition at line 63 of file EvtMTree.cc.

References calibUtil::ERROR, report(), and EvtMLineShape::setres().

Referenced by parsenode().

00066 {
00067     EvtMRes * resonance = NULL;
00068     EvtMLineShape * lineshape = NULL;
00069 
00070     if( ls=="BREITWIGNER" ) {
00071         lineshape = new EvtMBreitWigner( id, lsarg );
00072     } else if( ls=="TRIVIAL" ) {
00073         lineshape = new EvtMTrivialLS( id, lsarg );
00074     } else {
00075         report(ERROR,"EvtGen")<<"Lineshape "<<lineshape
00076                               <<" not recognized."<<endl;
00077         ::abort();
00078     }
00079 
00080     if( type=="HELAMP" ) {
00081         resonance = new EvtMHelAmp( id, lineshape, children, amps );
00082     } else {
00083         report(ERROR,"EvtGen")<<"Model "<<type<<" not recognized."<<endl;
00084         ::abort();
00085     }
00086 
00087     lineshape->setres( resonance );
00088 
00089     return resonance;
00090 }

vector< EvtComplex > EvtMTree::parseAmps ( ptype ,
ptype ,
ptype  
) [private]

Definition at line 184 of file EvtMTree.cc.

References amps, exp(), parseArg(), and parseerror().

Referenced by parsenode().

00186 {
00187     vector<string> parg = parseArg( c_iter, c_begin, c_end );
00188     parseerror( parg.size() == 0, c_iter, c_begin, c_end );
00189 
00190     // Get parametrization amplitudes
00191     vector<string>::iterator amp_iter = parg.begin();
00192     vector<string>::iterator amp_end = parg.end();
00193     vector<EvtComplex> amps;
00194 
00195     while( amp_iter != amp_end ) {
00196         const char * nptr;
00197         char * endptr = NULL;
00198         double amp=0.0, phase=0.0;
00199 
00200         nptr = (*amp_iter).c_str();
00201         amp = strtod(nptr, &endptr);
00202         parseerror( nptr==endptr, c_iter, c_begin, c_end );
00203 
00204         ++amp_iter;
00205         parseerror( amp_iter == amp_end, c_iter, c_begin, c_end );
00206 
00207         nptr = (*amp_iter).c_str();
00208         phase = strtod(nptr, &endptr);
00209         parseerror( nptr==endptr, c_iter, c_begin, c_end );
00210 
00211         amps.push_back( amp*exp(EvtComplex(0.0, phase)) );
00212 
00213         ++amp_iter;
00214     }
00215 
00216     return amps;
00217 }

vector< string > EvtMTree::parseArg ( ptype ,
ptype ,
ptype  
) [private]

Definition at line 150 of file EvtMTree.cc.

References arg(), parsecheck(), parseerror(), deljobs::string, and subSeperate::temp.

Referenced by parseAmps(), and parsenode().

00151 {
00152     vector<string> arg;
00153 
00154     if( *c_iter != '[' ) return arg;
00155     ++c_iter;
00156 
00157     string temp;
00158     while(true) {
00159         parseerror( c_iter == c_end || parsecheck(*c_iter, "[()"),
00160                 c_iter, c_begin, c_end );
00161 
00162         if( *c_iter == ']' ) {
00163             ++c_iter;
00164             if(temp.size() > 0) arg.push_back( temp );
00165             break;
00166         }
00167 
00168         if( *c_iter == ',') {
00169             arg.push_back( temp );
00170             temp.erase();
00171             ++c_iter;
00172             continue;
00173         }
00174 
00175         temp += *c_iter;
00176         ++c_iter;
00177     }
00178     parseerror(c_iter == c_end || *c_iter != ',', c_iter, c_begin, c_end);
00179     ++c_iter;
00180 
00181     return arg;
00182 }

bool EvtMTree::parsecheck ( char  arg,
const string chars 
) [private]

Definition at line 32 of file EvtMTree.cc.

References genRecEmupikp::i.

Referenced by parseArg(), parseId(), and parseKey().

00033 {
00034     bool ret = false;
00035 
00036     for(int i=0; i<chars.size(); ++i) {
00037         ret = ret || (chars[i]==arg);
00038     }
00039 
00040     return ret;
00041 }

vector< vector< EvtMNode * > > EvtMTree::parseChildren ( ptype ,
ptype ,
ptype  
) [private]

Definition at line 265 of file EvtMTree.cc.

References parseerror(), deljobs::string, test, and unionChildren().

Referenced by parsenode().

00267 {
00268     bool test = true;
00269     int pcount=0;
00270     string nodestr;
00271     vector< vector<EvtMNode * > > children;
00272 
00273     parseerror(c_iter == c_end || *c_iter != '[', c_iter, c_begin, c_end );
00274     ++c_iter;
00275 
00276     while( test ) {
00277         parseerror( c_iter==c_end || pcount < 0, c_iter, c_begin, c_end );
00278 
00279         switch( *c_iter ) {
00280             case ')':
00281                 --pcount;
00282                 nodestr += *c_iter;
00283                 break;
00284             case '(':
00285                 ++pcount;
00286                 nodestr += *c_iter;
00287                 break;
00288             case ']':
00289                 if( pcount==0 ) {
00290                     children = unionChildren( nodestr, children );
00291                     test=false;
00292                 } else {
00293                     nodestr += *c_iter;
00294                 }
00295                 break;
00296             case ',':
00297                 if( pcount==0 ) {
00298                     children = unionChildren( nodestr, children );
00299                     nodestr.erase();
00300                 } else {
00301                     nodestr += *c_iter;
00302                 }
00303                 break;
00304             default:
00305                 nodestr += *c_iter;
00306                 break;
00307         }
00308 
00309         ++c_iter;
00310     }
00311 
00312     return children;
00313 }

void EvtMTree::parseerror ( bool  ,
ptype ,
ptype ,
ptype  
) [private]

Definition at line 92 of file EvtMTree.cc.

References calibUtil::ERROR, ers::error, report(), and deljobs::string.

Referenced by parseAmps(), parseArg(), parseChildren(), parseId(), parseKey(), and parsenode().

00094 { 
00095     if(!flag) return;
00096 
00097     string error;
00098     
00099     while( c_begin != c_end ) {
00100         if(c_begin == c_iter) {
00101             error+='_';
00102             error+=*c_begin;
00103             error+='_';
00104         } else 
00105             error+=*c_begin;
00106 
00107         ++c_begin;
00108     }
00109 
00110     report(ERROR,"EvtGen")<<"Parse error at: "<<error<<endl;
00111     ::abort();
00112 }

string EvtMTree::parseId ( ptype ,
ptype ,
ptype  
) [private]

Definition at line 114 of file EvtMTree.cc.

References parsecheck(), parseerror(), and deljobs::string.

Referenced by parsenode().

00115 {
00116     string strid;
00117 
00118     while(c_iter != c_end) {
00119         parseerror(parsecheck(*c_iter, ")[],"), c_iter, c_begin, c_end);
00120         if( *c_iter == '(' ) {
00121             ++c_iter;
00122             return strid;
00123         }
00124 
00125         strid += *c_iter;
00126         ++c_iter;
00127     }
00128 
00129     return strid;
00130 }

string EvtMTree::parseKey ( ptype ,
ptype ,
ptype  
) [private]

Definition at line 132 of file EvtMTree.cc.

References key, parsecheck(), parseerror(), and deljobs::string.

Referenced by parsenode().

00133 {
00134     string key;
00135 
00136     while( *c_iter != ',' ) {
00137         parseerror(c_iter==c_end || parsecheck(*c_iter, "()[]"),
00138             c_iter, c_begin, c_end);
00139         key += *c_iter;
00140         ++c_iter;
00141     }
00142 
00143     ++c_iter;
00144 
00145     parseerror(c_iter == c_end, c_iter, c_begin, c_end);
00146     
00147     return key;
00148 }

vector< EvtMNode * > EvtMTree::parsenode ( const string ,
bool   
) [private]

Definition at line 315 of file EvtMTree.cc.

References amps, calibUtil::ERROR, EvtPDL::getId(), genRecEmupikp::i, makeparticles(), makeresonance(), parseAmps(), parseArg(), parseChildren(), parseerror(), parseId(), parseKey(), report(), deljobs::string, and type.

Referenced by addtree(), and unionChildren().

00316 {
00317     ptype c_iter, c_begin, c_end;
00318 
00319     c_iter=c_begin=args.begin();
00320     c_end = args.end();
00321 
00322     string strid = parseId( c_iter, c_begin, c_end );
00323 
00324     // Case 1: Particle
00325     if( c_iter == c_end ) return makeparticles( strid );
00326 
00327     // Case 2: Resonance - parse further
00328     EvtId id = EvtPDL::getId(strid);
00329     parseerror(EvtId( -1, -1 )==id, c_iter, c_begin, c_end);
00330     
00331     string ls;
00332     vector<string> lsarg;
00333 
00334     if( rootnode ) {
00335         ls = "TRIVIAL";
00336     } else {
00337         // Get lineshape (e.g. BREITWIGNER)
00338         ls = parseKey( c_iter, c_begin, c_end );
00339         lsarg = parseArg( c_iter, c_begin, c_end );
00340     }
00341 
00342     // Get resonance parametrization type (e.g. HELAMP)
00343     string type = parseKey( c_iter, c_begin, c_end );
00344     vector<EvtComplex> amps = parseAmps( c_iter, c_begin, c_end );
00345 
00346     // Children
00347     vector<vector<EvtMNode * > > children = parseChildren( c_iter, c_begin,
00348             c_end );
00349     
00350     report(ERROR,"EvtGen")<<children.size()<<endl;
00351     vector<EvtMNode *> resonances;
00352     for(int i=0; i<children.size(); ++i ) {
00353         resonances.push_back(makeresonance(id,ls,lsarg,type,amps,children[i]));
00354     }
00355 
00356     parseerror(c_iter == c_end || *c_iter!=')', c_iter, c_begin, c_end);
00357 
00358     return resonances;
00359 }

vector< vector< EvtMNode * > > EvtMTree::unionChildren ( const string ,
vector< vector< EvtMNode * > > &   
) [private]

Definition at line 231 of file EvtMTree.cc.

References duplicate(), genRecEmupikp::i, ganga-rec::j, parsenode(), and subSeperate::temp.

Referenced by parseChildren().

00233 {
00234     vector<EvtMNode *> cl2 = parsenode( nodestr, false );
00235     vector< vector<EvtMNode * > > cl;
00236     
00237     if( cl1.size() == 0 ) {
00238         for( int i=0; i<cl2.size(); ++i ) {
00239             vector<EvtMNode *> temp(1, cl2[i]);
00240             cl.push_back( temp );
00241         }
00242 
00243         return cl;
00244     }
00245 
00246     for( int i=0; i<cl1.size(); ++i ) {
00247         for( int j=0; j<cl2.size(); ++j ) {
00248             vector<EvtMNode *> temp;
00249             temp = duplicate( cl1[i] );
00250             temp.push_back( cl2[j]->duplicate() );
00251 
00252             cl.push_back( temp );
00253         }
00254     }
00255  
00256     for(int i=0; i<cl1.size(); ++i)
00257         for(int j=0; j<cl1[i].size(); ++j)
00258             delete cl1[i][j];
00259     for(int i=0; i<cl2.size(); ++i)
00260         delete (cl2[i]);
00261 
00262     return cl;
00263 }

bool EvtMTree::validTree ( const EvtMNode  )  const [private]

Definition at line 361 of file EvtMTree.cc.

References genRecEmupikp::i, and root.

Referenced by addtree().

00362 {
00363     vector<int> res = root->getresonance();
00364     vector<bool> check(res.size(), false);
00365 
00366     for( int i=0; i<res.size(); ++i) {
00367         check[res[i]] = true;
00368     }
00369 
00370     bool ret = true;
00371 
00372     for( int i=0; i<check.size(); ++i ) {
00373         ret = ret&&check[i];
00374     }
00375 
00376     return ret;
00377 }


Member Data Documentation

vector<string> EvtMTree::_lbltbl [private]

Definition at line 38 of file EvtMTree.hh.

Referenced by EvtMTree(), and makeparticles().

double EvtMTree::_norm [private]

Definition at line 39 of file EvtMTree.hh.

Referenced by addtree(), and amplitude().

vector< EvtMNode * > EvtMTree::_root [private]

Definition at line 37 of file EvtMTree.hh.

Referenced by addtree(), amplitude(), and ~EvtMTree().


Generated on Tue Nov 29 23:19:07 2016 for BOSS_7.0.2 by  doxygen 1.4.7