100 std::string colon(
":" ), equals(
"=" );
105 <<
"In readDecayFile, reading:" << dec_name.c_str() << endl;
109 fin.open( dec_name.c_str() );
112 <<
"Could not open " << dec_name.c_str() << endl;
117 parser.
read( dec_name );
125 for ( itok = 0; itok < parser.
getNToken(); itok++ ) {
128 if ( token ==
"End" )
134 <<
"Could not find an 'End' in " << dec_name.c_str() << endl;
136 <<
"Will terminate execution." << endl;
140 std::string model, parent, sdaug;
150 std::vector<EvtModelAlias> modelAliasList;
153 token = parser.
getToken( itoken++ );
156 if ( token ==
"noFSR" ) {
161 <<
"As requested, final-state radiation will be turned off."
164 }
else if ( token ==
"yesFSR" ) {
169 <<
"As requested, final-state radiation will be turned on for all decays."
172 }
else if ( token ==
"normalFSR" ) {
177 <<
"As requested, final-state radiation will be turned on only when requested."
180 }
else if ( token ==
"noPhotos" ) {
182 <<
"'noPhotos' is deprecated. Use 'noFSR' instead. " << endl;
187 <<
"As requested, final-state radiation will be turned off."
190 }
else if ( token ==
"yesPhotos" ) {
192 <<
"'yesPhotos' is deprecated. Use 'yesFSR' instead." << endl;
197 <<
" As requested, final-state radiation will be turned on for all decays."
200 }
else if ( token ==
"normalPhotos" ) {
202 <<
"'normalPhotos' is deprecated. Use 'normalFSR' instead. "
208 <<
"As requested, final-state radiation will be turned on only when requested."
211 }
else if ( token ==
"Alias" ) {
215 newname = parser.
getToken( itoken++ );
216 oldname = parser.
getToken( itoken++ );
220 if (
id ==
EvtId( -1, -1 ) ) {
222 <<
"Unknown particle name:" << oldname.c_str()
225 <<
"Will terminate execution!" << endl;
233 }
else if ( token ==
"ModelAlias" ) {
234 std::vector<std::string> modelArgList;
236 std::string aliasName = parser.
getToken( itoken++ );
237 std::string modelName = parser.
getToken( itoken++ );
239 std::string nameTemp;
241 nameTemp = parser.
getToken( itoken++ );
242 if ( nameTemp !=
";" ) {
243 modelArgList.push_back( nameTemp );
245 }
while ( nameTemp !=
";" );
246 EvtModelAlias newAlias( aliasName, modelName, modelArgList );
247 modelAliasList.push_back( newAlias );
248 }
else if ( token ==
"ChargeConj" ) {
250 std::string abarname;
252 aname = parser.
getToken( itoken++ );
253 abarname = parser.
getToken( itoken++ );
258 if ( a ==
EvtId( -1, -1 ) ) {
260 <<
"Unknown particle name:" << aname.c_str() <<
" on line "
263 <<
"Will terminate execution!" << endl;
267 if ( abar ==
EvtId( -1, -1 ) ) {
269 <<
"Unknown particle name:" << abarname.c_str()
272 <<
"Will terminate execution!" << endl;
278 }
else if ( token ==
"JetSetPar" ) {
280 std::string pythiaCommand = parser.
getToken( itoken++ );
285 int i1 = pythiaCommand.find_first_of(
"(" );
286 int i2 = pythiaCommand.find_first_of(
")" );
287 int i3 = pythiaCommand.find_first_of(
"=" );
289 std::string pythiaModule = pythiaCommand.substr( 0, i1 );
290 std::string pythiaParam = pythiaCommand.substr( i1 + 1, i2 - i1 - 1 );
291 std::string pythiaValue = pythiaCommand.substr( i3 + 1 );
293 command[
"MODULE"] = pythiaModule;
294 command[
"PARAM"] = pythiaParam;
295 command[
"VALUE"] = pythiaValue;
297 command[
"GENERATOR"] =
"Both";
298 command[
"VERSION"] =
"PYTHIA6";
300 extGenCommands->
addCommand(
"PYTHIA", command );
302 }
else if ( modelist.
isCommand( token ) ) {
305 cnfgstr = parser.
getToken( itoken++ );
309 }
else if ( token ==
"PythiaGenericParam" ||
310 token ==
"PythiaAliasParam" || token ==
"PythiaBothParam" ) {
319 std::string pythiaCommand = parser.
getToken( itoken++ );
320 std::string pythiaModule(
"" ), pythiaParam(
"" ), pythiaValue(
"" );
325 std::vector<std::string> pComVect1 =
328 if ( pComVect1.size() == 2 ) {
329 pythiaModule = pComVect1[0];
331 std::string pCom2 = pComVect1[1];
333 std::vector<std::string> pComVect2 = this->
splitString( pCom2,
336 if ( pComVect2.size() == 2 ) {
337 pythiaParam = pComVect2[0];
338 pythiaValue = pComVect2[1];
345 if ( token ==
"PythiaGenericParam" ) {
346 command[
"GENERATOR"] =
"Generic";
347 }
else if ( token ==
"PythiaAliasParam" ) {
348 command[
"GENERATOR"] =
"Alias";
350 command[
"GENERATOR"] =
"Both";
353 command[
"MODULE"] = pythiaModule;
354 command[
"PARAM"] = pythiaParam;
355 command[
"VALUE"] = pythiaValue;
357 command[
"VERSION"] =
"PYTHIA8";
358 extGenCommands->
addCommand(
"PYTHIA", command );
360 }
else if ( token ==
"CDecay" ) {
366 if ( ipar ==
EvtId( -1, -1 ) ) {
368 <<
"Unknown particle name:" << name.c_str() <<
" on line "
371 <<
"Will terminate execution!" << endl;
380 <<
"Redefined decay of " << name.c_str() <<
" in CDecay"
390 }
else if ( token ==
"Define" ) {
401 }
else if ( token ==
"Particle" ) {
403 pname = parser.
getToken( itoken++ );
407 double newMass = atof( parser.
getToken( itoken++ ).c_str() );
411 newWidth = atof( parser.
getToken( itoken++ ).c_str() );
419 <<
"Changing particle properties of " << pname.c_str()
420 <<
" Mass=" << newMass <<
" Width=" << newWidth << endl;
422 }
else if ( token ==
"ChangeMassMin" ) {
424 pname = parser.
getToken( itoken++ );
425 double tmass = atof( parser.
getToken( itoken++ ).c_str() );
431 <<
"Refined minimum mass for "
432 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tmass
435 }
else if ( token ==
"ChangeMassMax" ) {
437 pname = parser.
getToken( itoken++ );
438 double tmass = atof( parser.
getToken( itoken++ ).c_str() );
443 <<
"Refined maximum mass for "
444 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tmass
447 }
else if ( token ==
"IncludeBirthFactor" ) {
449 pname = parser.
getToken( itoken++ );
451 if ( parser.
getToken( itoken++ ) ==
"yes" )
458 <<
"Include birth factor for "
462 <<
"No longer include birth factor for "
466 }
else if ( token ==
"IncludeDecayFactor" ) {
468 pname = parser.
getToken( itoken++ );
470 if ( parser.
getToken( itoken++ ) ==
"yes" )
477 <<
"Include decay factor for "
481 <<
"No longer include decay factor for "
484 }
else if ( token ==
"LSNONRELBW" ) {
486 pname = parser.
getToken( itoken++ );
488 std::string tstr =
"NONRELBW";
492 <<
"Change lineshape to non-rel BW for "
494 }
else if ( token ==
"LSFLAT" ) {
496 pname = parser.
getToken( itoken++ );
498 std::string tstr =
"FLAT";
502 <<
"Change lineshape to flat for "
504 }
else if ( token ==
"LSMANYDELTAFUNC" ) {
506 pname = parser.
getToken( itoken++ );
508 std::string tstr =
"MANYDELTAFUNC";
512 <<
"Change lineshape to spikes for "
515 }
else if ( token ==
"BlattWeisskopf" ) {
517 pname = parser.
getToken( itoken++ );
518 double tnum = atof( parser.
getToken( itoken++ ).c_str() );
523 <<
"Redefined Blatt-Weisskopf factor "
524 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tnum
526 }
else if ( token ==
"BlattWeisskopfBirth" ) {
528 pname = parser.
getToken( itoken++ );
529 double tnum = atof( parser.
getToken( itoken++ ).c_str() );
534 <<
"Redefined Blatt-Weisskopf birth factor "
535 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << tnum
537 }
else if ( token ==
"SetLineshapePW" ) {
539 pname = parser.
getToken( itoken++ );
541 std::string pnameD1 = parser.
getToken( itoken++ );
543 std::string pnameD2 = parser.
getToken( itoken++ );
545 int pw = atoi( parser.
getToken( itoken++ ).c_str() );
548 <<
"Redefined Partial wave for " << pname.c_str() <<
" to "
549 << pnameD1.c_str() <<
" " << pnameD2.c_str() <<
" (" << pw
555 }
else if ( token ==
"Decay" ) {
556 std::string temp_fcn_new_model;
560 double brfrsum = 0.0;
562 parent = parser.
getToken( itoken++ );
565 if ( ipar ==
EvtId( -1, -1 ) ) {
567 <<
"Unknown particle name:" << parent.c_str() <<
" on line "
570 <<
"Will terminate execution!" << endl;
576 <<
"Redefined decay of " << parent.c_str() << endl;
581 token = parser.
getToken( itoken++ );
583 if ( token !=
"Enddecay" ) {
585 while ( token.c_str()[i++] != 0 ) {
586 if ( isalpha( token.c_str()[i] ) ) {
588 <<
"Expected to find a branching fraction or Enddecay "
589 <<
"but found:" << token.c_str() <<
" on line "
592 <<
"Possibly to few arguments to model "
593 <<
"on previous line!" << endl;
595 <<
"Will terminate execution!" << endl;
600 brfr = atof( token.c_str() );
606 if ( !( isname || ismodel ) ) {
608 for (
size_t iAlias = 0; iAlias < modelAliasList.size();
610 if ( modelAliasList[iAlias].matchAlias(
618 if ( !( isname || ismodel ) ) {
620 << parser.
getToken( itoken ).c_str()
621 <<
" is neither a particle name nor "
622 <<
"the name of a model. " << endl;
624 <<
"It was encountered on line "
626 <<
" of the decay file." << endl;
628 <<
"Please fix it. Thank you." << endl;
630 <<
"Be sure to check that the "
631 <<
"correct case has been used. \n";
633 <<
"Terminating execution. \n";
643 sdaug = parser.
getToken( itoken++ );
645 if ( daught[n_daugh - 1] ==
EvtId( -1, -1 ) ) {
647 <<
"Unknown particle name:" << sdaug.c_str()
651 <<
"Will terminate execution!" << endl;
656 model = parser.
getToken( itoken++ );
659 bool verboseModel =
false;
660 bool summary =
false;
663 if ( model ==
"PHOTOS" || model ==
"FSR" ) {
665 if ( model ==
"PHOTOS" ) {
667 <<
"'PHOTOS' is deprecated. Use 'FSR' instead. "
670 model = parser.
getToken( itoken++ );
672 if ( model ==
"VERBOSE" ) {
674 model = parser.
getToken( itoken++ );
676 if ( model ==
"SUMMARY" ) {
678 model = parser.
getToken( itoken++ );
680 }
while ( model ==
"PHOTOS" || model ==
"FSR" ||
681 model ==
"VERBOSE" || model ==
"SUMMARY" );
684 int foundAnAlias = -1;
685 for (
size_t iAlias = 0; iAlias < modelAliasList.size();
687 if ( modelAliasList[iAlias].matchAlias( model ) ) {
688 foundAnAlias = iAlias;
693 if ( foundAnAlias == -1 ) {
694 if ( !modelist.
isModel( model ) ) {
696 <<
"Expected to find a model name,"
697 <<
"found:" << model.c_str() <<
" on line "
700 <<
"Will terminate execution!" << endl;
704 model = modelAliasList[foundAnAlias].getName();
707 temp_fcn_new_model = model;
708 temp_fcn_new = modelist.
getFcn( model );
713 if ( verboseModel ) {
720 std::vector<std::string> temp_fcn_new_args;
725 if ( foundAnAlias == -1 ) {
729 temp_fcn_new_args.push_back(
733 <<
"Reading arguments and found:"
734 << name.c_str() <<
" on line:"
738 <<
"Will terminate execution!" << endl;
743 ismodel = modelist.
isModel( name );
746 <<
"Expected ';' but found:" << name.c_str()
751 <<
"Most probable error is omitted ';'."
754 <<
"Will terminate execution!" << endl;
757 }
while ( name !=
";" );
759 std::vector<std::string> copyMe =
760 modelAliasList[foundAnAlias].getArgList();
761 temp_fcn_new_args = copyMe;
769 temp_fcn_new_args.size(),
771 temp_fcn_new_model, brfr );
773 double massmin = 0.0;
787 }
while ( token !=
"Enddecay" );
794 else if ( token ==
"CopyDecay" ) {
798 newname = parser.
getToken( itoken++ );
799 oldname = parser.
getToken( itoken++ );
804 if ( oldipar ==
EvtId( -1, -1 ) ) {
806 <<
"Unknown particle name:" << oldname.c_str()
809 <<
"Will terminate execution!" << endl;
812 if ( newipar ==
EvtId( -1, -1 ) ) {
814 <<
"Unknown particle name:" << newname.c_str()
817 <<
"Will terminate execution!" << endl;
822 <<
"Redefining decay of " << newname << endl;
829 else if ( token ==
"RemoveDecay" ) {
830 parent = parser.
getToken( itoken++ );
833 if ( ipar ==
EvtId( -1, -1 ) ) {
835 <<
"Unknown particle name:" << parent.c_str() <<
" on line "
838 <<
"Will terminate execution!" << endl;
844 <<
"No decays to delete for " << parent.c_str() << endl;
847 <<
"Deleting selected decays of " << parent.c_str() << endl;
853 if ( token !=
"Enddecay" ) {
857 sdaug = parser.
getToken( itoken++ );
859 if ( daught[n_daugh - 1] ==
EvtId( -1, -1 ) ) {
861 <<
"Unknown particle name:" << sdaug.c_str()
865 <<
"Will terminate execution!" << endl;
870 if ( token !=
";" ) {
872 <<
"Expected ';' but found:" << token <<
" on line:"
875 <<
"Most probable error is omitted ';'." << endl;
877 <<
"Will terminate execution!" << endl;
880 token = parser.
getToken( itoken++ );
882 std::vector<std::string> temp_fcn_new_args;
883 std::string temp_fcn_new_model(
"PHSP" );
886 temp_fcn_new_model, 0. );
889 }
while ( token !=
"Enddecay" );
891 }
else if ( token !=
"End" ) {
893 <<
"Found unknown command:'" << token.c_str() <<
"' on line "
896 <<
"Will terminate execution!" << endl;
900 }
while ( ( token !=
"End" ) && itoken != parser.
getNToken() );
905 EvtId temp( ii, ii );
915 for ( jj = 0; jj < nModTot; jj++ ) {
916 double tmass =
m_decaytable[ii].getDecay( jj ).getMassMin();
917 if ( tmass < minMass )
923 <<
"Given allowed decays, resetting minMass "
940 parser.
open( dec_name );
943 std::string decayParent =
"";
945 std::vector<EvtModelAlias> modelAliasList;
946 bool endReached =
false;
955 <<
"'photos' is deprecated. Use 'fsr' instead. " << endl;
960 if ( usage ==
"always" ) {
964 <<
"As requested, final-state radiation will be turned on for all decays."
966 }
else if ( usage ==
"never" ) {
970 <<
"As requested, final-state radiation will be turned off."
976 <<
"As requested, final-state radiation will be turned on only when requested."
990 }
else if ( parser.
getTagTitle() ==
"modelAlias" ) {
991 std::vector<std::string> modelArgList;
996 std::istringstream paramStream( paramStr );
1000 if ( paramStr ==
"" ) {
1004 while ( paramName !=
"" ) {
1009 modelArgList.push_back( param );
1014 while ( std::getline( paramStream, param,
' ' ) ) {
1015 modelArgList.push_back( param );
1019 modelAliasList.push_back( newAlias );
1021 }
else if ( parser.
getTagTitle() ==
"chargeConj" ) {
1023 std::string conjugate = parser.
readAttribute(
"conjugate" );
1033 }
else if ( parser.
getTagTitle() ==
"conjDecay" ) {
1045 <<
"Redefined decay of " << particle.c_str()
1046 <<
" in ConjDecay" << endl;
1060 }
else if ( parser.
getTagTitle() ==
"particle" ) {
1067 "includeBirthFactor" );
1069 "includeDecayFactor" );
1070 std::string lineShape = parser.
readAttribute(
"lineShape" );
1072 "blattWeisskopfFactor" );
1074 "blattWeisskopfBirth" );
1082 <<
"Refined mass for "
1083 <<
EvtPDL::name( thisPart ).c_str() <<
" to be " << mass
1086 if ( width != -1 ) {
1089 <<
"Refined width for "
1093 if ( minMass != -1 ) {
1096 <<
"Refined minimum mass for "
1100 if ( maxMass != -1 ) {
1103 <<
"Refined maximum mass for "
1107 if ( !birthFactor.empty() ) {
1113 <<
"Include birth factor for "
1117 <<
"No longer include birth factor for "
1122 if ( !decayFactor.empty() ) {
1128 <<
"Include decay factor for "
1132 <<
"No longer include decay factor for "
1137 if ( !lineShape.empty() ) {
1141 <<
"Change lineshape to " << lineShape <<
" for "
1144 if ( blattWeisskopfD != -1 ) {
1148 <<
"Redefined Blatt-Weisskopf factor "
1150 << blattWeisskopfD << endl;
1152 if ( blattWeisskopfB != -1 ) {
1156 <<
"Redefined Blatt-Weisskopf birth factor "
1158 << blattWeisskopfB << endl;
1160 }
else if ( parser.
getTagTitle() ==
"lineShapePW" ) {
1179 <<
"Redefined Partial wave for " << parent.c_str()
1180 <<
" to " << daug1.c_str() <<
" " << daug2.c_str()
1181 <<
" (" << pw <<
")" << endl;
1191 <<
"Redefined decay of " << decayParent.c_str() << endl;
1195 }
else if ( parser.
getTagTitle() ==
"copyDecay" ) {
1207 <<
"Redefining decay of " << particle << endl;
1213 }
else if ( parser.
getTagTitle() ==
"removeDecay" ) {
1220 <<
"No decays to delete for " << decayParent.c_str()
1224 <<
"Deleting selected decays of " << decayParent.c_str()
1228 }
else if ( parser.
getTagTitle() ==
"pythiaParam" ) {
1234 command[
"VERSION"] =
"PYTHIA8";
1235 extGenCommands->
addCommand(
"PYTHIA", command );
1237 }
else if ( parser.
getTagTitle() ==
"pythia6Param" ) {
1243 command[
"VERSION"] =
"PYTHIA6";
1244 extGenCommands->
addCommand(
"PYTHIA", command );
1261 <<
" found in XML decay file near line "
1272 std::string temp_fcn_new_model;
1273 std::vector<std::string> temp_fcn_new_args;
1277 std::istringstream daugStream( daugStr );
1280 std::istringstream paramStream( paramStr );
1287 <<
"'photos' is deprecated. Use 'fsr' instead. " << endl;
1295 while ( std::getline( daugStream, daugh,
' ' ) ) {
1300 int modelAlias = -1;
1301 for (
size_t iAlias = 0; iAlias < modelAliasList.size();
1303 if ( modelAliasList[iAlias].matchAlias( model ) ) {
1304 modelAlias = iAlias;
1309 if ( modelAlias == -1 ) {
1310 if ( !modelist.
isModel( model ) ) {
1312 <<
"Expected to find a model name near line "
1314 <<
"found:" << model.c_str() << endl;
1316 <<
"Will terminate execution!" << endl;
1320 model = modelAliasList[modelAlias].getName();
1323 temp_fcn_new_model = model;
1324 temp_fcn_new = modelist.
getFcn( model );
1334 if ( modelAlias == -1 ) {
1336 if ( paramStr ==
"" ) {
1338 std::string paramName = temp_fcn_new->
getParamName( 0 );
1339 while ( paramName !=
"" ) {
1344 temp_fcn_new_args.push_back(
1348 <<
"Reading arguments near line "
1350 <<
" and found:" << param.c_str() << endl;
1352 <<
"Will terminate execution!" << endl;
1360 while ( std::getline( paramStream, param,
' ' ) ) {
1361 temp_fcn_new_args.push_back(
1365 <<
"Reading arguments near line "
1367 <<
" and found:" << param.c_str() << endl;
1369 <<
"Will terminate execution!" << endl;
1375 std::vector<std::string> copyMe =
1376 modelAliasList[modelAlias].getArgList();
1377 temp_fcn_new_args = copyMe;
1383 temp_fcn_new_args.size(),
1385 temp_fcn_new_model, brfr );
1387 double massMin = 0.0;
1405 <<
" found in XML decay file near line "
1415 std::istringstream daugStream( daugStr );
1418 while ( std::getline( daugStream, daugh,
' ' ) ) {
1424 std::vector<std::string> temp_fcn_new_args;
1425 std::string temp_fcn_new_model(
"PHSP" );
1428 temp_fcn_new_model, 0. );
1430 }
else if ( parser.
getTagTitle() !=
"/removeDecay" ) {
1433 <<
" found in XML decay file near line "
1440 if ( !endReached ) {
1442 <<
"Either the decay file ended prematurely or the file is badly formed.\n"
1443 <<
"Error occured near line" << parser.
getLineNumber() << endl;
1449 EvtId temp( ii, ii );
1459 for ( jj = 0; jj < nModTot; jj++ ) {
1460 double tmass =
m_decaytable[ii].getDecay( jj ).getMassMin();
1461 if ( tmass < minMass )
1467 <<
"Given allowed decays, resetting minMass "
1662 std::string& splitter )
const
1665 std::vector<std::string> result;
1667 if ( !theString.empty() && !splitter.empty() ) {
1668 for ( std::string::size_type offset = 0;; ) {
1669 std::string::size_type found = theString.find( splitter, offset );
1671 if ( found != std::string::npos ) {
1672 std::string tmpString = theString.substr( offset, found - offset );
1673 if ( tmpString.size() > 0 ) {
1674 result.push_back( tmpString );
1676 offset = found + splitter.size();
1678 std::string tmpString =
1679 theString.substr( offset, theString.size() - offset );
1680 if ( tmpString.size() > 0 ) {
1681 result.push_back( tmpString );