LDMX Software
EventProcessor.cxx
2
3// LDMX
5#include "Framework/Process.h"
6#include "Framework/RunHeader.h"
7#include "TDirectory.h"
8
9namespace framework {
10
11EventProcessor::EventProcessor(const std::string &name, Process &process)
12 : histograms_{name},
13 theLog_{logging::makeLogger(name)},
14 process_{process},
15 name_{name} {}
16
20
24
26 if (!histoDir_) {
28 }
29 histoDir_->cd(); // make this the current directory
30 return histoDir_;
31}
32
34 const std::string &purposeString) {
35 process_.getStorageController().addHint(name_, hint, purposeString);
36}
37
41
43
44void EventProcessor::declare(const std::string &classname, int classtype,
45 EventProcessorMaker *maker) {
47 maker);
48}
49
51 const std::vector<framework::config::Parameters> &histos) {
52 for (auto const &h : histos) {
53 auto name{h.getParameter<std::string>("name")};
54 auto xLabel{h.getParameter<std::string>("xlabel")};
55 auto xbins{h.getParameter<std::vector<double>>("xbins")};
56 auto yLabel{h.getParameter<std::string>("ylabel")};
57 auto ybins{h.getParameter<std::vector<double>>("ybins", {})};
58 if (ybins.empty()) {
59 // assume 1D histogram
60 histograms_.create(name, xLabel, xbins);
61 } else {
62 // assume 2D histogram
63 histograms_.create(name, xLabel, xbins, yLabel, ybins);
64 }
65 }
66}
67
68Producer::Producer(const std::string &name, Process &process)
69 : EventProcessor(name, process) {}
70
71Analyzer::Analyzer(const std::string &name, Process &process)
72 : EventProcessor(name, process) {}
73} // namespace framework
Base classes for all user event processing components to extend.
Class which provides a singleton module factory that creates EventProcessor objects.
Class which represents the process under execution.
Analyzer(const std::string &name, Process &process)
Class constructor.
Container and cache for conditions and conditions providers.
Definition Conditions.h:43
Base class for all event processing components.
static void declare(const std::string &classname, int classtype, EventProcessorMaker *)
Internal function which is part of the PluginFactory machinery.
Process & process_
Handle to the Process.
std::string name_
The name of the EventProcessor.
void createHistograms(const std::vector< framework::config::Parameters > &histos)
Internal function which is used to create histograms passed from the python configuration @parma hist...
TDirectory * histoDir_
Histogram directory.
EventProcessor(const std::string &name, Process &process)
Class constructor.
Conditions & getConditions() const
Internal getter for conditions without exposing all of Process.
const ldmx::EventHeader & getEventHeader() const
Internal getter for EventHeader without exposing all of Process.
int getRunNumber() const
Get the run number from the process.
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...
HistogramHelper histograms_
Interface class for making and filling histograms.
int getLogFrequency() const
Get the current logging frequency from the process.
void setStorageHint(framework::StorageControl::Hint hint)
Mark the current event as having the given storage control hint from this module.
void create(const std::string &name, const std::string &xLabel, const double &bins, const double &xmin, const double &xmax)
Create a ROOT 1D histogram of type TH1F and pool it for later use.
void registerEventProcessor(const std::string &classname, int classtype, EventProcessorMaker *maker)
Register the event processor.
static PluginFactory & getInstance()
Get the factory instance.
Class which represents the process under execution.
Definition Process.h:36
int getLogFrequency() const
Get the frequency with which the event information is printed.
Definition Process.h:84
Conditions & getConditions()
Get a reference to the conditions system.
Definition Process.h:78
TDirectory * makeHistoDirectory(const std::string &dirName)
Construct a TDirectory* for the given module.
Definition Process.cxx:424
const ldmx::EventHeader * getEventHeader() const
Get the pointer to the current event header, if defined.
Definition Process.h:68
StorageControl & getStorageController()
Access the storage control unit for this process.
Definition Process.h:109
int getRunNumber() const
Get the current run number or the run number to be used when initiating new events from the job.
Definition Process.cxx:420
Producer(const std::string &name, Process &process)
Class constructor.
void addHint(const std::string &processor_name, Hint hint, const std::string &purposeString)
Add a storage hint for a given processor.
Hint
Hints that can be provided by processors to the storage controller.
Provides header information an event such as event number and timestamp.
Definition EventHeader.h:44
All classes in the ldmx-sw project use this namespace.
Definition PerfDict.cxx:45
EventProcessor * EventProcessorMaker(const std::string &name, Process &process)
Typedef for EventProcessorFactory use.