LDMX Software
framework::test::TestConfig Class Reference

Defines a test Producer to test the passing of configuration variables. More...

Public Member Functions

 TestConfig (const std::string &name, framework::Process &process)
 Constructor.
 
void configure (framework::config::Parameters &parameters) final override
 Configure function.
 
virtual void produce (framework::Event &) override
 Process the event and put new data products into it.
 
- Public Member Functions inherited from framework::Producer
 Producer (const std::string &name, Process &process)
 Class constructor.
 
virtual void process (Event &event) final
 Processing an event for a Producer is calling produce.
 
- Public Member Functions inherited from framework::EventProcessor
 DECLARE_FACTORY (EventProcessor, EventProcessor *, const std::string &, Process &)
 declare that we have a factory for this class
 
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()=default
 Class destructor.
 
virtual void beforeNewRun (ldmx::RunHeader &run_header)
 Callback for Producers to add parameters to the run header before conditions are initialized.
 
virtual void onNewRun (const ldmx::RunHeader &run_header)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &event_file)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
virtual void onProcessStart ()
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
virtual void onProcessEnd ()
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module_.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Additional Inherited Members

- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramPool histograms_
 helper object for making and filling histograms
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger the_log_
 The logger for this EventProcessor.
 

Detailed Description

Defines a test Producer to test the passing of configuration variables.

Definition at line 23 of file ConfigurePythonTest.cxx.

Constructor & Destructor Documentation

◆ TestConfig()

framework::test::TestConfig::TestConfig ( const std::string & name,
framework::Process & process )
inline

Constructor.

Follows the standard form for a framework::Producer.

Checks that the passed name is the same as what is written to the python config script.

Definition at line 33 of file ConfigurePythonTest.cxx.

35 CHECK(name == "test_instance");
36 }
Base class for a module which produces a data product.
virtual void process(Event &event) final
Processing an event for a Producer is calling produce.

Member Function Documentation

◆ configure()

void framework::test::TestConfig::configure ( framework::config::Parameters & parameters)
inlinefinaloverridevirtual

Configure function.

Checks:

  • int parameter
  • double parameter
  • string parameter
  • dictionary parameter
  • vector of ints parameter
  • vector of doubles parameter
  • vector of strings parameter

Reimplemented from framework::EventProcessor.

Definition at line 50 of file ConfigurePythonTest.cxx.

50 {
51 // Check parameters
52 CHECK(parameters.get<int>("test_int") == 9);
53 CHECK(parameters.get<double>("test_double") == Approx(7.7));
54 CHECK(parameters.get<std::string>("test_string") == "Yay!");
55
56 // Check dictionary
57 auto test_dict{parameters.get<framework::config::Parameters>("test_dict")};
58 CHECK(test_dict.get<int>("one") == 1);
59 CHECK(test_dict.get<double>("two") == 2.0);
60
61 // Check int vector
62 std::vector<int> int_vect{1, 2, 3};
63 auto test_int_vec{parameters.get<std::vector<int>>("test_int_vec")};
64 REQUIRE(test_int_vec.size() == int_vect.size());
65 for (std::size_t i{0}; i < test_int_vec.size(); i++)
66 CHECK(test_int_vec.at(i) == int_vect.at(i));
67
68 // Check double vec
69 std::vector<double> double_vec{0.1, 0.2, 0.3};
70 auto test_double_vec{
71 parameters.get<std::vector<double>>("test_double_vec")};
72 REQUIRE(test_double_vec.size() == double_vec.size());
73 for (std::size_t i{0}; i < test_double_vec.size(); i++)
74 CHECK(test_double_vec.at(i) == double_vec.at(i));
75
76 // Check string vector
77 std::vector<std::string> string_vec{"first", "second", "third"};
78 auto test_string_vec{
79 parameters.get<std::vector<std::string>>("test_string_vec")};
80 REQUIRE(test_string_vec.size() == string_vec.size());
81 for (std::size_t i{0}; i < test_string_vec.size(); i++)
82 CHECK(test_string_vec.at(i) == string_vec.at(i));
83
84 // check 2d vector
85 std::vector<std::vector<int>> twod_vec{
86 {11, 12, 13}, {21, 22}, {31, 32, 33, 34}};
87 auto test_2d_vec{
88 parameters.get<std::vector<std::vector<int>>>("test_2dlist")};
89 REQUIRE(test_2d_vec.size() == twod_vec.size());
90 for (std::size_t i{0}; i < twod_vec.size(); i++) {
91 REQUIRE(test_2d_vec.at(i).size() == twod_vec.at(i).size());
92 for (std::size_t j{0}; j < twod_vec.at(i).size(); j++) {
93 CHECK(test_2d_vec.at(i).at(j) == twod_vec.at(i).at(j));
94 }
95 }
96 }
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78

◆ produce()

virtual void framework::test::TestConfig::produce ( framework::Event & event)
inlineoverridevirtual

Process the event and put new data products into it.

Parameters
eventThe Event to process.

Implements framework::Producer.

Definition at line 99 of file ConfigurePythonTest.cxx.

99{}

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