diff --git a/Framework/include/Framework/Process.h b/Framework/include/Framework/Process.h index c76d3896f..cce917e11 100644 --- a/Framework/include/Framework/Process.h +++ b/Framework/include/Framework/Process.h @@ -172,6 +172,11 @@ class Process { /** Limit on events to process. */ int eventLimit_; + + /** Number of events we'd like to produce + independetly of the number of tries it would take. + Be warned about infinite loops!*/ + int totalEvents_; /** The frequency with which event info is printed. */ int logFrequency_; diff --git a/Framework/python/ldmxcfg.py.in b/Framework/python/ldmxcfg.py.in index da526daba..c1d0f5d04 100644 --- a/Framework/python/ldmxcfg.py.in +++ b/Framework/python/ldmxcfg.py.in @@ -328,10 +328,15 @@ class Process: lastProcess : Process Class-wide reference to the last Process object to be constructed maxEvents : int - Maximum number events to process + Maximum number events to process. + If totalEvents is set, this will be ignored. maxTriesPerEvent : int Maximum number of attempts to make in a row before giving up on an event Only used in Production Mode (no input files) + If totalEvents is set, this will be ignored. + totalEvents : int + Number of events we'd like to produce independetly of the number of tries it would take. + Both maxEvents and maxTriesPerEvent will be ignored. Be warned about infinite loops! run : int Run number for this process inputFiles : list of strings diff --git a/Framework/src/Framework/Process.cxx b/Framework/src/Framework/Process.cxx index 3118b4f89..5dd4322b1 100644 --- a/Framework/src/Framework/Process.cxx +++ b/Framework/src/Framework/Process.cxx @@ -30,6 +30,7 @@ Process::Process(const framework::config::Parameters &configuration) maxTries_ = configuration.getParameter("maxTriesPerEvent", 1); eventLimit_ = configuration.getParameter("maxEvents", -1); + totalEvents_ = configuration.getParameter("totalEvents", -1); logFrequency_ = configuration.getParameter("logFrequency", -1); compressionSetting_ = configuration.getParameter("compressionSetting", 9); @@ -202,7 +203,13 @@ void Process::run() { int totalTries = 0; // total number of tries for entire run int numTries = 0; // number of tries for the current event number - while (n_events_processed < eventLimit_) { + int event_limit = eventLimit_; + if (totalEvents_ > 0) { + // Have a warning at the first event + if (numTries == 0) ldmx_log(warn) << "The totalEvents was set, so maxEvents and maxTriesPerEvent will be ignored!"; + event_limit = totalEvents_; + } + while (n_events_processed < event_limit) { totalTries++; numTries++; @@ -223,7 +230,8 @@ void Process::run() { // we use modulo here insetad of >= because we want to carry // the number of tries across the number of events processed boundary - if (completed or numTries % maxTries_ == 0) { + // totalEvents_ is set let's not exit until that's reached + if (completed or (totalEvents_ < 0 and numTries % maxTries_ == 0)) { n_events_processed++; // increment events made NtupleManager::getInstance().fill(); // fill ntuples } @@ -237,6 +245,12 @@ void Process::run() { runHeader.setNumTries(totalTries); ldmx_log(info) << runHeader; outFile.writeRunTree(); + + // Give a warning that this filter has very low efficiency + if (n_events_processed < totalTries / 10000) { // integer division is okay + ldmx_log(warn) << "Less than 1 event out of every 10k events tried was accepted!"; + ldmx_log(warn) << "This could be an issue with your filtering and biasing procedure since this is incredibly inefficient."; + } } else { // there are input files