LDMX Software
Public Member Functions | List of all members
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 beforeNewRun (ldmx::RunHeader &header)
 Handle allowing producers to modify run headers before the run begins.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 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

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Producer
static const int CLASSTYPE {1}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 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.

34 : framework::Producer(name, process) {
35 CHECK(name == "test_instance");
36 }
Base class for a module which produces a data product.

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

◆ 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 101 of file ConfigurePythonTest.cxx.

101{}

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