77 {
78
81 int i;
82
83 report(
INFO,
"EvtGen" ) <<
"In readDecayFile, reading:" << dec_name.c_str() << endl;
84
86
87 fin.open( dec_name.c_str() );
88 if ( !fin ) {
report(
ERROR,
"EvtGen" ) <<
"Could not open " << dec_name.c_str() << endl; }
89 fin.close();
90
91 EvtParser parser;
92 parser.
Read( dec_name );
93
94 int itok;
95
96 int hasend = 0;
97
98 std::string token;
99
100 for ( itok = 0; itok < parser.
getNToken(); itok++ )
101 {
102
104
105 if ( token == "End" ) hasend = 1;
106 }
107
108 if ( !hasend )
109 {
110 report(
ERROR,
"EvtGen" ) <<
"Could not find an 'End' in " << dec_name.c_str() << endl;
111 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution." << endl;
112 ::abort();
113 }
114
115 std::string model, parent, sdaug;
116
117 EvtId ipar;
118
119 int n_daugh;
121 double brfr;
122
123 int itoken = 0;
124
125 std::vector<EvtModelAlias> modelAliasList;
126
127 do {
128
129 token = parser.
getToken( itoken++ );
130
131
132 if ( token == "noPhotos" )
133 {
135 report(
INFO,
"EvtGen" ) <<
"As requested, PHOTOS will be turned off." << endl;
136 }
137 else if ( token == "yesPhotos" )
138 {
140 report(
INFO,
"EvtGen" ) <<
"As requested, PHOTOS will be turned on." << endl;
141 }
142 else if ( token == "normalPhotos" )
143 {
145 report(
INFO,
"EvtGen" ) <<
"As requested, PHOTOS will be turned on only when requested."
146 << endl;
147 }
148 else if ( token == "Alias" )
149 {
150
151 std::string newname;
152 std::string oldname;
153
154 newname = parser.
getToken( itoken++ );
155 oldname = parser.
getToken( itoken++ );
156
158
159 if ( id == EvtId( -1, -1 ) )
160 {
161 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << oldname.c_str() <<
" on line "
163 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
164 ::abort();
165 }
166
169 }
170 else if ( token == "ModelAlias" )
171 {
172 std::vector<std::string> modelArgList;
173
174 std::string aliasName = parser.
getToken( itoken++ );
175 std::string modelName = parser.
getToken( itoken++ );
176
177 std::string nameTemp;
178 do {
179 nameTemp = parser.
getToken( itoken++ );
180 if ( nameTemp != ";" ) { modelArgList.push_back( nameTemp ); }
181 } while ( nameTemp != ";" );
182 EvtModelAlias newAlias( aliasName, modelName, modelArgList );
183 modelAliasList.push_back( newAlias );
184 }
185 else if ( token == "ChargeConj" )
186 {
187
188 std::string aname;
189 std::string abarname;
190
191 aname = parser.
getToken( itoken++ );
192 abarname = parser.
getToken( itoken++ );
193
196
197 if ( a == EvtId( -1, -1 ) )
198 {
199 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << aname.c_str() <<
" on line "
201 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
202 ::abort();
203 }
204
205 if ( abar == EvtId( -1, -1 ) )
206 {
207 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << abarname.c_str()
209 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
210 ::abort();
211 }
212
214 }
216 {
217
218 std::string cnfgstr;
219
220 cnfgstr = parser.
getToken( itoken++ );
221
223 }
224 else if ( token == "CDecay" )
225 {
226
227 std::string name;
228
231
232 if ( ipar == EvtId( -1, -1 ) )
233 {
234 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << name.c_str() <<
" on line "
236 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
237 ::abort();
238 }
239
241
242 if ( decaytable[ipar.
getAlias()].getNMode() != 0 )
243 {
244
246 << "Redefined decay of " << name.c_str() << " in CDecay" << endl;
247
248 decaytable[ipar.
getAlias()].removeDecay();
249 }
250
251
252 decaytable[ipar.
getAlias()].makeChargeConj( &decaytable[cipar.
getAlias()] );
253 }
254 else if ( token == "Define" )
255 {
256
257 std::string name;
258
260
261
263
264
265
266
267 }
268 else if ( token == "Particle" )
269 {
270
271 std::string pname;
272 pname = parser.
getToken( itoken++ );
273 report(
INFO,
"EvtGen" ) << pname.c_str() << endl;
274
275 double newMass = atof( parser.
getToken( itoken++ ).c_str() );
278 if ( parser.
getNToken() > 3 ) newWidth = atof( parser.
getToken( itoken++ ).c_str() );
279
280
283
284 report(
INFO,
"EvtGen" ) <<
"Changing particle properties of " << pname.c_str()
285 << " Mass=" << newMass << " Width=" << newWidth << endl;
286 }
287 else if ( token == "ChangeMassMin" )
288 {
289 std::string pname;
290 pname = parser.
getToken( itoken++ );
291 double tmass = atof( parser.
getToken( itoken++ ).c_str() );
292
295 report(
DEBUG,
"EvtGen" ) <<
"Refined minimum mass for "
296 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tmass
297 << endl;
298 }
299 else if ( token == "ChangeMassMax" )
300 {
301 std::string pname;
302 pname = parser.
getToken( itoken++ );
303 double tmass = atof( parser.
getToken( itoken++ ).c_str() );
306 report(
DEBUG,
"EvtGen" ) <<
"Refined maximum mass for "
307 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tmass
308 << endl;
309 }
310 else if ( token == "IncludeBirthFactor" )
311 {
312 std::string pname;
313 pname = parser.
getToken( itoken++ );
314 bool yesno = false;
315 if ( parser.
getToken( itoken++ ).c_str() ==
"yes" ) yesno =
true;
318 if ( yesno )
320 <<
"Include birth factor for " <<
EvtPDL::name( thisPart ).c_str() << endl;
321 if ( !yesno )
322 report(
DEBUG,
"EvtGen" ) <<
"No longer include birth factor for "
324 }
325 else if ( token == "IncludeDecayFactor" )
326 {
327 std::string pname;
328 pname = parser.
getToken( itoken++ );
329 bool yesno = false;
330 if ( parser.
getToken( itoken++ ).c_str() ==
"yes" ) yesno =
true;
333 if ( yesno )
335 <<
"Include decay factor for " <<
EvtPDL::name( thisPart ).c_str() << endl;
336 if ( !yesno )
337 report(
DEBUG,
"EvtGen" ) <<
"No longer include decay factor for "
339 }
340 else if ( token == "AddFactorPn" )
341 {
342 std::string pname;
343 pname = parser.
getToken( itoken++ );
344 double factor = atof( parser.
getToken( itoken++ ).c_str() );
347 report(
DEBUG,
"EvtGen" ) <<
"Include momentum factor Pn= " << factor <<
" for "
349 }
350 else if ( token == "LSNONRELBW" )
351 {
352 std::string pname;
353 pname = parser.
getToken( itoken++ );
355 std::string tstr = "NONRELBW";
357 report(
DEBUG,
"EvtGen" ) <<
"Change lineshape to non-rel BW for "
359 }
360 else if ( token == "SP6LSFIX" )
361 {
362 std::string pname;
363 pname = parser.
getToken( itoken++ );
366 report(
DEBUG,
"EvtGen" ) <<
"Fixed lineshape for SP6 --from M.Baak "
368 }
369 else if ( token == "LSFLAT" )
370 {
371 std::string pname;
372 pname = parser.
getToken( itoken++ );
374 std::string tstr = "FLAT";
376 report(
DEBUG,
"EvtGen" ) <<
"Change lineshape to flat for "
378 }
379 else if ( token == "LSMANYDELTAFUNC" )
380 {
381 std::string pname;
382 pname = parser.
getToken( itoken++ );
384 std::string tstr = "MANYDELTAFUNC";
386 report(
DEBUG,
"EvtGen" ) <<
"Change lineshape to spikes for "
388 }
389 else if ( token == "BlattWeisskopf" )
390 {
391 std::string pname;
392 pname = parser.
getToken( itoken++ );
393 double tnum = atof( parser.
getToken( itoken++ ).c_str() );
396 report(
DEBUG,
"EvtGen" ) <<
"Redefined Blatt-Weisskopf factor "
397 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tnum
398 << endl;
399 }
400 else if ( token == "SetLineshapePW" )
401 {
402 std::string pname;
403 pname = parser.
getToken( itoken++ );
405 std::string pnameD1 = parser.
getToken( itoken++ );
407 std::string pnameD2 = parser.
getToken( itoken++ );
409 int pw = atoi( parser.
getToken( itoken++ ).c_str() );
410 report(
DEBUG,
"EvtGen" ) <<
"Redefined Partial wave for " << pname.c_str() <<
" to "
411 << pnameD1.c_str() << " " << pnameD2.c_str() << " (" << pw
412 << ")" << endl;
414 }
415 else if ( token == "Decay" )
416 {
417
418 std::string temp_fcn_new_model;
419
420 EvtDecayBase* temp_fcn_new;
421
422 double brfrsum = 0.0;
423
424 parent = parser.
getToken( itoken++ );
426
427 if ( ipar == EvtId( -1, -1 ) )
428 {
429 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << parent.c_str() <<
" on line "
431 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
432 ::abort();
433 }
434
435 if ( decaytable[ipar.
getAlias()].getNMode() != 0 )
436 {
437 report(
DEBUG,
"EvtGen" ) <<
"Redefined decay of " << parent.c_str() << endl;
438 decaytable[ipar.
getAlias()].removeDecay();
439 }
440
441 do {
442
443 token = parser.
getToken( itoken++ );
444
445 if ( token != "Enddecay" )
446 {
447
448 i = 0;
449 while ( token.c_str()[i++] != 0 )
450 {
451 if ( isalpha( token.c_str()[i] ) )
452 {
453 report(
ERROR,
"EvtGen" ) <<
"Expected to find a branching fraction or Enddecay "
454 << "but found:" << token.c_str() << " on line "
456 report(
ERROR,
"EvtGen" ) <<
"Possibly to few arguments to model "
457 << "on previous line!" << endl;
458 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
459 ::abort();
460 }
461 }
462
463 brfr = atof( token.c_str() );
464
467
468 if ( !( isname || ismodel ) )
469 {
470
471 int iAlias;
472 for ( iAlias = 0; iAlias < modelAliasList.size(); iAlias++ )
473 {
474 if ( modelAliasList[iAlias].matchAlias( parser.
getToken( itoken ) ) )
475 {
476 ismodel = 2;
477 break;
478 }
479 }
480 }
481
482 if ( !( isname || ismodel ) )
483 {
484
486 << parser.
getToken( itoken ).c_str() <<
" is neither a particle name nor "
487 << "the name of a model. " << endl;
489 <<
"It was encountered on line " << parser.
getLineofToken( itoken )
490 << " of the decay file." << endl;
491 report(
INFO,
"EvtGen" ) <<
"Please fix it. Thank you." << endl;
492 report(
INFO,
"EvtGen" ) <<
"Be sure to check that the "
493 << "correct case has been used. \n";
494 report(
INFO,
"EvtGen" ) <<
"Terminating execution. \n";
495 ::abort();
496
497 itoken++;
498 }
499
500 n_daugh = 0;
501
503 {
504 sdaug = parser.
getToken( itoken++ );
506 if ( daught[n_daugh - 1] == EvtId( -1, -1 ) )
507 {
509 << "Unknown particle name:" << sdaug.c_str() << " on line "
511 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
512 ::abort();
513 }
514 }
515
516 model = parser.
getToken( itoken++ );
517
518 int photos = 0;
519 int verbose = 0;
520 int summary = 0;
521
522 do {
523 if ( model == "PHOTOS" )
524 {
525 photos = 1;
526 model = parser.
getToken( itoken++ );
527 }
528 if ( model == "VERBOSE" )
529 {
530 verbose = 1;
531 model = parser.
getToken( itoken++ );
532 }
533 if ( model == "SUMMARY" )
534 {
535 summary = 1;
536 model = parser.
getToken( itoken++ );
537 }
538 } while ( model == "PHOTOS" || model == "VERBOSE" || model == "SUMMARY" );
539
540
541 int iAlias;
542 int foundAnAlias = -1;
543 for ( iAlias = 0; iAlias < modelAliasList.size(); iAlias++ )
544 {
545 if ( modelAliasList[iAlias].matchAlias( model ) )
546 {
547 foundAnAlias = iAlias;
548 break;
549 }
550 }
551
552 if ( foundAnAlias == -1 )
553 {
554 if ( !modelist.
isModel( model ) )
555 {
556 report(
ERROR,
"EvtGen" ) <<
"Expected to find a model name,"
557 << "found:" << model.c_str() << " on line "
559 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
560 ::abort();
561 }
562 }
563 else { model = modelAliasList[foundAnAlias].getName(); }
564
565 temp_fcn_new_model = model;
566 temp_fcn_new = modelist.
getFcn( model );
567
568 if ( photos ) { temp_fcn_new->
setPHOTOS(); }
569 if ( verbose ) { temp_fcn_new->
setVerbose(); }
570 if ( summary ) { temp_fcn_new->
setSummary(); }
571
572 std::vector<std::string> temp_fcn_new_args;
573
574 std::string name;
575 int ierr;
576
577 if ( foundAnAlias == -1 )
578 {
579 do {
581 if ( name != ";" )
582 {
584 if ( ierr )
585 {
587 << "Reading arguments and found:" << name.c_str()
589 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
590 ::abort();
591 }
592 }
593
594 int ismodel = modelist.
isModel( name );
595 if ( ismodel )
596 {
598 << "Expected ';' but found:" << name.c_str()
600 report(
ERROR,
"EvtGen" ) <<
"Most probable error is omitted ';'." << endl;
601 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
602 ::abort();
603 }
604 } while ( name != ";" );
605 }
606 else
607 {
608 std::vector<std::string> copyMe = modelAliasList[foundAnAlias].getArgList();
609 temp_fcn_new_args = copyMe;
610 itoken++;
611 }
612
613
614 brfrsum += brfr;
615
616 temp_fcn_new->
saveDecayInfo( ipar, n_daugh, daught, temp_fcn_new_args.size(),
617 temp_fcn_new_args, temp_fcn_new_model, brfr );
618
619 double massmin = 0.0;
620
621
623 {
627 }
628
629 decaytable[ipar.
getAlias()].addMode( temp_fcn_new, brfrsum, massmin );
630 }
631 } while ( token != "Enddecay" );
632
633 decaytable[ipar.
getAlias()].finalize();
634 }
635
636
637 else if ( token == "CopyDecay" )
638 {
639 std::string newname;
640 std::string oldname;
641
642 newname = parser.
getToken( itoken++ );
643 oldname = parser.
getToken( itoken++ );
644
647
648 if ( oldipar == EvtId( -1, -1 ) )
649 {
650 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << oldname.c_str() <<
" on line "
652 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
653 ::abort();
654 }
655 if ( newipar == EvtId( -1, -1 ) )
656 {
657 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << newname.c_str() <<
" on line "
659 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
660 ::abort();
661 }
662 if ( decaytable[newipar.
getAlias()].getNMode() != 0 )
663 {
664 report(
DEBUG,
"EvtGen" ) <<
"Redefining decay of " << newname << endl;
665 decaytable[newipar.
getAlias()].removeDecay();
666 }
668 }
669
670
671 else if ( token == "RemoveDecay" )
672 {
673 parent = parser.
getToken( itoken++ );
675
676 if ( ipar == EvtId( -1, -1 ) )
677 {
678 report(
ERROR,
"EvtGen" ) <<
"Unknown particle name:" << parent.c_str() <<
" on line "
680 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
681 ::abort();
682 }
683
684 if ( decaytable[ipar.
getAlias()].getNMode() == 0 )
685 {
report(
DEBUG,
"EvtGen" ) <<
"No decays to delete for " << parent.c_str() << endl; }
686 else
687 {
688 report(
DEBUG,
"EvtGen" ) <<
"Deleting selected decays of " << parent.c_str() << endl;
689 }
690
691 do {
693
694 if ( token != "Enddecay" )
695 {
696 n_daugh = 0;
698 {
699 sdaug = parser.
getToken( itoken++ );
701 if ( daught[n_daugh - 1] == EvtId( -1, -1 ) )
702 {
704 << "Unknown particle name:" << sdaug.c_str() << " on line "
706 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
707 ::abort();
708 }
709 }
711 if ( token != ";" )
712 {
714 << "Expected ';' but found:" << token
716 report(
ERROR,
"EvtGen" ) <<
"Most probable error is omitted ';'." << endl;
717 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
718 ::abort();
719 }
720 token = parser.
getToken( itoken++ );
721 EvtDecayBase* temp_fcn_new = modelist.
getFcn(
"PHSP" );
722 std::vector<std::string> temp_fcn_new_args;
723 std::string temp_fcn_new_model( "PHSP" );
724 temp_fcn_new->
saveDecayInfo( ipar, n_daugh, daught, 0, temp_fcn_new_args,
725 temp_fcn_new_model, 0. );
726 decaytable[ipar.
getAlias()].removeMode( temp_fcn_new );
727 }
728 } while ( token != "Enddecay" );
729 itoken++;
730 }
731 else if ( token != "End" )
732 {
733
734 report(
ERROR,
"EvtGen" ) <<
"Found unknown command:'" << token.c_str() <<
"' on line "
736 report(
ERROR,
"EvtGen" ) <<
"Will terminate execution!" << endl;
737 ::abort();
738 }
739
740 }
while ( ( token !=
"End" ) && itoken != parser.
getNToken() );
741
742
743
744 int ii;
746 {
747 EvtId temp( ii, ii );
749
750 if ( nModTot == 0 ) continue;
751
753 int jj;
755 for ( jj = 0; jj < nModTot; jj++ )
756 {
757 double tmass = decaytable[ii].getDecay( jj ).getMassMin();
758 if ( tmass < minMass ) minMass = tmass;
759 }
761 {
762
763 report(
INFO,
"EvtGen" ) <<
"Given allowed decays, resetting minMass "
767 }
768 }
769}
ostream & report(Severity severity, const char *facility)
void saveDecayInfo(EvtId ipar, int ndaug, EvtId *daug, int narg, std::vector< std::string > &args, std::string name, double brfr)
virtual int nRealDaughters()
EvtDecayBase * getFcn(std::string model_name)
void storeCommand(std::string cmd, std::string cnfgstr)
int isModel(std::string name)
static EvtModel & instance()
int isCommand(std::string cmd)
static double getWidth(EvtId i)
static void reSetBlatt(EvtId i, double blatt)
static void addFactorPn(EvtId i, double factor)
static void fixLSForSP8(EvtId i)
static void changeLS(EvtId i, std::string &newLS)
static double getMeanMass(EvtId i)
static void reSetWidth(EvtId i, double width)
static void reSetMass(EvtId i, double mass)
static void alias(EvtId num, const std::string &newname)
static void includeDecayFactor(EvtId i, bool yesno)
static void reSetMassMax(EvtId i, double mass)
static std::string name(EvtId i)
static EvtId chargeConj(EvtId id)
static double getMinMass(EvtId i)
static void setPWForDecay(EvtId i, int spin, EvtId d1, EvtId d2)
static void aliasChgConj(EvtId a, EvtId abar)
static void includeBirthFactor(EvtId i, bool yesno)
static double getMaxMass(EvtId i)
static EvtId getId(const std::string &name)
static void reSetMassMin(EvtId i, double mass)
int getLineofToken(int i)
const std::string & getToken(int i)
int Read(const std::string filename)
static void setAlwaysRadCorr()
static void setNormalRadCorr()
static void setNeverRadCorr()
static void Define(const std::string &name, std::string d)
static std::string Get(const std::string &name, int &ierr)