fire v0.19.0
Framework for sImulation and Reconstruction of Events
fire::StorageControl Class Reference

Isolation of voting system deciding if events should be kept. 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

 StorageControl (const config::Parameters &ps)
 Configure the various options for how the storage contol behaves. More...
 
void resetEventState ()
 Reset the event-by-event state by removing any hints provided by processors during the previous event.
 
void addHint (Hint hint, const std::string &purpose, const std::string &processor_name)
 Add a storage hint for a given processor. More...
 
bool keepEvent () const
 Determine if the current event should be kept, based on the defined rules. More...
 

Private Attributes

bool default_keep_ {true}
 Default state for storage control.
 
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. More...
 
std::vector< Hinthints_
 Collection of hints from the event processors.
 

Detailed Description

Isolation of voting system deciding if events should be kept.

Any Processor 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.

Member Enumeration Documentation

◆ Hint

enum class fire::StorageControl::Hint
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.

Constructor & Destructor Documentation

◆ StorageControl()

fire::StorageControl::StorageControl ( const config::Parameters ps)

Configure the various options for how the storage contol behaves.

Exceptions
Exceptionif required parameters are not found
Exceptionif one of the listening rule regex's is malformed
Parameters
[in]psParameters used to configure storage controller

Member Function Documentation

◆ addHint()

void fire::StorageControl::addHint ( Hint  hint,
const std::string purpose,
const std::string processor_name 
)

Add a storage hint for a given processor.

The hint needs to match at least one of the listening rules in order to be considered.

Note
This means if no listing rules are provided then no storage hints are considered!
Parameters
[in]hintThe storage control hint to apply for the given event
[in]purposeA purpose string which can be used in the skim control configuration
[in]processor_nameName of the event processor

◆ keepEvent()

bool fire::StorageControl::keepEvent ( ) const

Determine if the current event should be kept, based on the defined rules.

Note
Currently, no weighting system is implemented.

Both "should" and "must" type of hints are given equal weighting. The "keep" and "drop" votes are counted and then the following logic is applied.

  1. If there are no votes either way, we return the default decision.
  2. If there are strictly more keep votes, we decide to keep.
  3. If there are strictly more drop votes, we decide to drop.
  4. If there are an equal number of votes, we return the default decision.
Returns
true if we should store the current event into the output file

Member Data Documentation

◆ rules_

std::vector<std::pair<std::regex, std::regex> > fire::StorageControl::rules_
private

Collection of rules allowing certain processors or purposes to be considered ("listened to") during the storage decision.

Each rule has two entries:

  1. a processor regex to match hints coming from processors named a certain way
  2. a purpose regex to match hints from all processors with a specific purpose

The documentation for this class was generated from the following files: