Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remollGenExternal should not wrap around when /run/beamOn request too many events #484

Open
wdconinc opened this issue Apr 29, 2021 · 3 comments

Comments

@wdconinc
Copy link
Member

Environment: (where does this bug occur, have you tried other environments)

  • branch (master for latest released): develop
  • revision (HEAD for most recent): HEAD
  • OS or system: linux
  • Special ROOT or Geant4 versions? nope

Steps to reproduce: (give a step by step account of how to trigger the bug)

  1. Change macros/tests/unit/test_gen_external.mac to run twice with 100 events: /run/beamOn 100
  2. build/remoll macros/tests/unit/test_gen_external.mac

Expected Result: (what do you expect when you execute the steps above)

The second run should only pick up about 50 events, and it should end then.

Actual Result: (what do you get when you execute the steps above)

It keeps repeating events, e.g. root -l remollout.root -e 'T->Draw("part.vx:Entry$")'
image

@wdconinc
Copy link
Member Author

I'm thinking something like this, but the checks in remollVEvent don't agree.

diff --git a/src/remollGenExternal.cc b/src/remollGenExternal.cc
index 206215f5..b34a6469 100644
--- a/src/remollGenExternal.cc
+++ b/src/remollGenExternal.cc
@@ -9,6 +9,7 @@
 // Geant4 headers
 #include "G4ParticleTable.hh"
 #include "G4GenericMessenger.hh"
+#include "G4RunManager.hh"
 
 // ROOT headers
 #include "TFile.h"
@@ -108,9 +109,10 @@ void remollGenExternal::SamplePhysics(remollVertex* /* vert */, remollEvent* evt
   do {
 
     // Read next event from tree and increment
-    //fTree->GetEntry(fEntry++);
-    if (fEntry >= fEntries)
-        fEntry = 0;
+    if (fEntry >= fEntries) {
+      G4RunManager::GetRunManager()->AbortRun();
+      return;
+    }
     fTree->GetEntry(fEntry++);
 
     // Weighting completely handled by event file

@rahmans1
Copy link
Contributor

I'm thinking something like this, but the checks in remollVEvent don't agree.

diff --git a/src/remollGenExternal.cc b/src/remollGenExternal.cc
index 206215f5..b34a6469 100644
--- a/src/remollGenExternal.cc
+++ b/src/remollGenExternal.cc
@@ -9,6 +9,7 @@
 // Geant4 headers
 #include "G4ParticleTable.hh"
 #include "G4GenericMessenger.hh"
+#include "G4RunManager.hh"
 
 // ROOT headers
 #include "TFile.h"
@@ -108,9 +109,10 @@ void remollGenExternal::SamplePhysics(remollVertex* /* vert */, remollEvent* evt
   do {
 
     // Read next event from tree and increment
-    //fTree->GetEntry(fEntry++);
-    if (fEntry >= fEntries)
-        fEntry = 0;
+    if (fEntry >= fEntries) {
+      G4RunManager::GetRunManager()->AbortRun();
+      return;
+    }
     fTree->GetEntry(fEntry++);
 
     // Weighting completely handled by event file

What checks are there in remollEventVGen? This seems like it should be sufficient.......

@wdconinc
Copy link
Member Author

remollVEventGen checks that the asymmetry etc is set properly. If it isn't, it exits right away. That prevents the run manager from cleanly ending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants