Commit 135b60d8 authored by Simone Pagan Griso's avatar Simone Pagan Griso
Browse files

add additional early protection against failure to balance energy

parent c58585eb
......@@ -133,15 +133,22 @@ namespace Pythia8{
try {
nShowerAttempts++;
suep_shower4momenta=suep_shower.generate_shower();
nShowerAttempts = -1; //exit condition
if( suep_shower4momenta.size()<3){
//Failed to balance energy or less than 3 particles in the shower
//Try again until nShowerAttempts >= 3
} else {
//All ok!
nShowerAttempts = -1; //exit condition
}
} catch (std::exception &e) {
//Failed to generate the shower!
//Can happen in some rare circumstances, try again
//Can happen in some rare circumstances,
//Try again until nShowerAttempts >= 3
}
} while ((nShowerAttempts > 0) && (nShowerAttempts < 3));
if (nShowerAttempts >= 3) {
//Something is seriously wrong then, print warning and skip to next event
std::cout << "[SUEP] ERROR: Something went terribly wrong in generating the shower. Skipping the event." << std::endl;
std::cout << "[SUEP] WARNING: Something went wrong in generating the shower. Skipping the event." << std::endl;
return true; //veto the event!
}
......
......@@ -146,6 +146,13 @@ vector< Vec4 > Suep_shower::generate_shower(){
event[n][i] += correction;
}
}
//Shield against an exception in the calculation of "p_scale" further down. If it fails, abort the event.
if(Suep_shower::reballance_func(2.0,event)<0.0){
// failed to balance energy.
event.clear();
return event;
}
// finally, ballance the total energy, without destroying momentum conservation
tolerance tol = 0.00001;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment