LDMX Software
|
Class which encapsulates storage control functionality, used by the Process class. More...
#include <StorageControl.h>
Public Types | |
enum class | Hint { NoOpinion = 0 , Undefined = -1 , ShouldKeep = 1 , MustKeep = 10 , ShouldDrop = 2 , MustDrop = 20 } |
Hints that can be provided by processors to the storage controller. More... | |
Public Member Functions | |
void | setDefaultKeep (bool keep) |
Set the default state. | |
void | resetEventState () |
Reset the event-by-event state. | |
void | addHint (const std::string &processor_name, Hint hint, const std::string &purposeString) |
Add a storage hint for a given processor. | |
void | addRule (const std::string &processor_pat, const std::string &purpose_pat) |
Add a listening rule. | |
bool | keepEvent (bool event_completed) const |
Determine if the current event should be kept, based on the defined rules. | |
Private Attributes | |
bool | defaultIsKeep_ {true} |
Default state for storage control. | |
std::vector< Hint > | hints_ |
Collection of hints from the event processors. | |
std::vector< std::pair< std::regex, std::regex > > | rules_ |
Collection of rules allowing certain processors or purposes to be considered ("listened to") during the storage decision. | |
Class which encapsulates storage control functionality, used by the Process class.
Any EventProcessor can provide a hint as to whether a given event should be kept or dropped. The hint is cached in the StorageControl object until the end of the event. At that point, the process queries the StorageControl to determine if the event should be stored in the output file.
Definition at line 27 of file StorageControl.h.
|
strong |
Hints that can be provided by processors to the storage controller.
Integer values of the hints are currently not used for anything, although one could imagine a "weighting" system being implemented where different Hints are weighted based on how "strong" the hint is.
Definition at line 36 of file StorageControl.h.
void framework::StorageControl::addHint | ( | const std::string & | processor_name, |
Hint | hint, | ||
const std::string & | purposeString | ||
) |
Add a storage hint for a given processor.
This is the function eventually called when a processor uses EventProcessor::setStorageHint during processing. When a hint is added, we check it against our configured listening rules. If the hint does not match any of our listening rules, then we simply ignore it by not adding it to our internal cache that will be used later when deciding to keep the event.
processor_name | Name of the event processor |
controlhint | The storage control hint to apply for the given event |
purposeString | A purpose string which can be used in the skim control configuration |
Definition at line 9 of file StorageControl.cxx.
References hints_, and rules_.
Referenced by framework::EventProcessor::setStorageHint().
void framework::StorageControl::addRule | ( | const std::string & | processor_pat, |
const std::string & | purpose_pat | ||
) |
Add a listening rule.
These listening rules are regex patterns to decide if a specific hint should be counted when deciding if an event should be kept.
processor_pattern | Regex pattern to compare with event processor |
purpose_pattern | Regex pattern to compare with the purpose string |
Definition at line 22 of file StorageControl.cxx.
References rules_.
Referenced by framework::Process::Process().
bool framework::StorageControl::keepEvent | ( | bool | event_completed | ) | const |
Determine if the current event should be kept, based on the defined rules.
Separating the 'must' keywords into their own tier helps give them greater importance that reflects their name. In order, the decision follows the criteria below only using hints that match one of the listening rules configured for the process.
[in] | event_completed | did we complete processing of the current event? |
loop over the hints provided by processors we are listening to.
mustDrop is highest priority, if it exists the event is dropped
mustKeep is second highest, if it exists when mustDrop does not, the event is kept
If we don't have any 'must' hints, we tally votes and follow the choice made by a simple majority.
If there is a tie in the vote (including the case where there were no votes), then we use the default decision.
Definition at line 45 of file StorageControl.cxx.
References defaultIsKeep_, and hints_.
Referenced by framework::Process::run().
void framework::StorageControl::resetEventState | ( | ) |
Reset the event-by-event state.
Definition at line 7 of file StorageControl.cxx.
References hints_.
Referenced by framework::Process::run().
|
inline |
Set the default state.
Definition at line 47 of file StorageControl.h.
References defaultIsKeep_.
Referenced by framework::Process::Process().
|
private |
Default state for storage control.
Definition at line 106 of file StorageControl.h.
Referenced by keepEvent(), and setDefaultKeep().
|
private |
Collection of hints from the event processors.
These are only the hints that are from processors matching one of the listening rules.
Definition at line 114 of file StorageControl.h.
Referenced by addHint(), keepEvent(), and resetEventState().
|
private |
Collection of rules allowing certain processors or purposes to be considered ("listened to") during the storage decision.
Each rule has two entries:
Definition at line 127 of file StorageControl.h.