Skip to content

Commit

Permalink
avoid infinite loop by specifying the NBevents in the pythiaCMD
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkzerwas committed Oct 3, 2024
1 parent 54eedbf commit 421312e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions k4GeneratorsConfig/src/pythiaLHERunner.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@ int main(int argc, char** argv) {
exit(0);
}

int nEvent = pythia.mode("Main:numberOfEvents");
int nAbort = pythia.mode("Main:timesAllowErrors");

// Begin infinite event loop - to be exited at end of file.
int iAbort = 0;
while (true) {
for (int iEvent = 0; iEvent < nEvent; ++iEvent) {

// Generate event.
if (!pythia.next()) {

// Leave event loop if at end of file.
if (pythia.info.atEndOfFile()) break;
if (pythia.info.atEndOfFile()) {
std::cout << "pythiaLHERunner:: reached EOF at event " << iEvent << " when " << nEvent << " were exopected" << std::endl;
break;
}

if (++iAbort < nAbort) continue;
cout << " Event generation aborted prematurely, owing to error!\n";
Expand Down
2 changes: 2 additions & 0 deletions python/Generators/Madgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ def write_PythiaCMND(self, pythiaFile):
content = "Main:timesAllowErrors = 5\n"
content += "Main:WriteHepMC = on\n"
content += "Beams:frameType = 4\n"
content += "Main:numberOfEvents = {0}\n".format(self.procinfo.get("events"))

# open the file for the evgen generation in EDM4HEP format
with open(self.outdir + "/"+pythiaFile, "w+") as file:
# the generator specific part
Expand Down

0 comments on commit 421312e

Please sign in to comment.