1#include "SimCore/ReSimulator.h"
11 auto configured_events{
12 parameters.
getParameter<std::vector<framework::config::Parameters>>(
13 "events_to_resimulate", {})};
14 if (configured_events.size() == 0) {
17 "ReSim was configured with resimulate_all_events marked false but "
18 "no event numbers were requested.\n\nDid you forget to configure "
19 "the events_to_resimulate parameter?\n");
21 for (
const auto& run_event : configured_events) {
23 run_event.getParameter<
int>(
"event"));
30 auto& eventHeader{
event.getEventHeader()};
31 const auto eventNumber{eventHeader.getEventNumber()};
34 std::cout <<
"Skipping event: " << eventNumber
35 <<
" since it wasn't part of the requested events..."
42 std::cout <<
"Resimulating " << eventNumber << std::endl;
45 std::istringstream iss(eventHeader.getStringParameter(
"eventSeed"));
46 G4Random::restoreFullState(iss);
49 std::cout <<
"Finished with event number " << eventNumber << std::endl;
54 [](
auto sd) { sd->OnFinishedEvent(); });
57 "Resimulation resulted in an aborted event, something is wrong with "
58 "the seed from event " +
59 std::to_string(eventNumber));
62 eventHeader.setEventNumber(++events_resimulated_);
63 updateEventHeader(eventHeader);
83 auto found_event_to_resim = std::find_if(
85 [&](
const std::pair<int, int>& run_event) ->
bool {
86 bool runs_match =
true;
89 return event.getEventNumber() == run_event.second and runs_match;
#define DECLARE_PRODUCER_NS(NS, CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
void abortEvent()
Abort the event immediately.
Implements an event buffer system for storing event data.
ldmx::EventHeader & getEventHeader()
Get the event header.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
void apply(UnaryFunction f) const
Apply the input UnaryFunction to each entry in the inventory.
static Factory & get()
get the factory instance
void produce(framework::Event &event) override
Run resimulation if the event is part of the requested sets of events to resimulate.
std::vector< std::pair< int, int > > events_to_resimulate_
List of events in the input files that should be resimulated if resimulate_all_events is false.
void configure(framework::config::Parameters ¶meters) override
Callback for the processor to configure itself from the given set of parameters.
bool care_about_run_
Whether or not we should check the run number when seeing if a specific event should be resimulated.
bool skip(framework::Event &event) const
Check if an event should be skipped during resimulation.
bool resimulate_all_events_
Whether to resimulate all events in the input files.
std::unique_ptr< RunManager > runManager_
Manager controlling G4 simulation run.
void configure(framework::config::Parameters ¶meters) override
Callback for the EventProcessor to configure itself from the given set of parameters.
int verbosity_
Vebosity for the simulation.