fire v0.19.0
Framework for sImulation and Reconstruction of Events
EventProcessor.h
Go to the documentation of this file.
1
6#ifndef FIRE_FRAMEWORK_EVENTPROCESSOR_H
7#define FIRE_FRAMEWORK_EVENTPROCESSOR_H
8
9#include "fire/Processor.h"
10#include "Framework/Configure/Parameters.h"
11#include "Framework/Logger.h"
12
22namespace framework {
23
34class Event {
37 public:
42
48 return event_.header();
49 }
50
55 int getEventNumber() const {
56 return event_.header().number();
57 }
58
63 double getEventWeight() const {
64 return event_.header().weight();
65 }
66
71 template<typename T>
72 void add(const std::string& n, const T& o) {
73 event_.add(n,o);
74 }
75
80 template<typename T>
81 const T& getObject(const std::string& n, const std::string& p = "") const {
82 return event_.get<T>(n,p);
83 }
84
89 template<typename T>
90 const std::vector<T>& getCollection(const std::string& n, const std::string& p = "") const {
91 return getObject<std::vector<T>>(n,p);
92 }
93
98 template<typename K, typename V>
99 const std::map<K,V>& getCollection(const std::string& n, const std::string& p = "") const {
100 return getObject<std::map<K,V>>(n,p);
101 }
102};
103
106
128 ps.add("name",name);
129 return ps;
130 }
131 public:
143 : fire::Processor(minimal_parameter_set(name)) {
144 this->attach(&p);
145 }
146
148 virtual void process(fire::Event &event) = 0;
149
157 virtual void configure(config::Parameters& ps) {}
158};
159
167class Producer : public EventProcessor {
168 public:
175 : EventProcessor(name,p) {}
176
181 virtual void produce(framework::Event &event) = 0;
182
189 virtual void process(fire::Event &event) final override {
190 framework::Event e(event);
191 this->produce(e);
192 }
193};
194
209class Analyzer : public EventProcessor {
210 public:
217 : EventProcessor(name,p) {}
222 virtual void beforeNewRun(fire::RunHeader&) final override {}
223
228 virtual void analyze(const framework::Event &event) = 0;
229
236 virtual void process(fire::Event &event) final override {
237 framework::Event e(event);
238 this->analyze(e);
239 }
240};
241
242}
243
252#define DECLARE_PRODUCER_NS(NS,CLASS) DECLARE_PROCESSOR(NS::CLASS)
253
259#define DECLARE_PRODUCER(CLASS) DECLARE_PROCESSOR(CLASS)
260
269#define DECLARE_ANALYZER_NS(NS,CLASS) DECLARE_PROCESSOR(NS::CLASS)
270
276#define DECLARE_ANALYZER(CLASS) DECLARE_PROCESSOR(CLASS)
277
278#endif // FIRE_FRAMEWORK_EVENTPROCESSOR_H
Header information of an event such as event number and timestamp.
Definition: EventHeader.h:27
int number() const
Return the event number.
Definition: EventHeader.h:70
double weight() const
Get the event weight (default of 1.0).
Definition: EventHeader.h:94
Event class for interfacing with processors.
Definition: Event.h:28
const EventHeader & header() const
Get the event header.
Definition: Event.h:156
const DataType & get(const std::string &name, const std::string &pass="") const
get a piece of data from the event
Definition: Event.h:349
void add(const std::string &name, const DataType &data)
add a piece of data to the event
Definition: Event.h:242
The central object managing the data processing.
Definition: Process.h:16
Base class for all event processing components.
Definition: Processor.h:57
virtual void attach(Process *p) final
Attach the current process to this processor.
Definition: Processor.h:172
Processor(const config::Parameters &ps)
Configure the processor upon construction.
Definition: Processor.cxx:7
Container for run parameters.
Definition: RunHeader.h:27
Class encapsulating parameters for configuring a processor.
Definition: Parameters.h:28
void add(const std::string &name, const T &value)
Add a parameter to the parameter list.
Definition: Parameters.h:41
Legacy analyzer class.
Definition: EventProcessor.h:209
virtual void analyze(const framework::Event &event)=0
Pure virtual analyze function to align with legacy implementation.
virtual void beforeNewRun(fire::RunHeader &) final override
Don't allow legacy analyzers to use this method by defining the final version to be empty.
Definition: EventProcessor.h:222
virtual void process(fire::Event &event) final override
Final implementation of pure virtual process method, wrapping event in framework::Event and giving it...
Definition: EventProcessor.h:236
Analyzer(const std::string &name, framework::Process &p)
Pass construction to base legacy processor.
Definition: EventProcessor.h:216
Wrapper class for fire::Processor which does the necessary modifications on the constructors and adds...
Definition: EventProcessor.h:116
virtual void process(fire::Event &event)=0
pass on pure virtual process function
static fire::config::Parameters minimal_parameter_set(const std::string &name)
Construct the minimal parameter set for a fire::Processor.
Definition: EventProcessor.h:126
virtual void configure(config::Parameters &ps)
Legacy configure method.
Definition: EventProcessor.h:157
EventProcessor(const std::string &name, framework::Process &p)
Construct a legacy event processor.
Definition: EventProcessor.h:142
Wrapper Event in this namespace reintroducing legacy functionality.
Definition: EventProcessor.h:34
int getEventNumber() const
Get the event number.
Definition: EventProcessor.h:55
fire::EventHeader & getEventHeader()
Get the event header.
Definition: EventProcessor.h:47
fire::Event & event_
reference to current event bus
Definition: EventProcessor.h:36
const T & getObject(const std::string &n, const std::string &p="") const
Retrieve an object from the event bus.
Definition: EventProcessor.h:81
double getEventWeight() const
Get the event weight.
Definition: EventProcessor.h:63
void add(const std::string &n, const T &o)
Add an object to the event bus.
Definition: EventProcessor.h:72
Event(fire::Event &e)
wrap the current event with a legacy interface
Definition: EventProcessor.h:41
const std::map< K, V > & getCollection(const std::string &n, const std::string &p="") const
Retrieve an object from the event bus.
Definition: EventProcessor.h:99
const std::vector< T > & getCollection(const std::string &n, const std::string &p="") const
Retrieve an object from the event bus.
Definition: EventProcessor.h:90
Legacy producer class.
Definition: EventProcessor.h:167
virtual void produce(framework::Event &event)=0
Pure virtual produce function to align with legacy implementation.
Producer(const std::string &name, framework::Process &p)
Pass construction to base legacy processor.
Definition: EventProcessor.h:174
virtual void process(fire::Event &event) final override
Final implementation of pure virtual process method, wrapping event in framework::Event and giving it...
Definition: EventProcessor.h:189
Namespace for interop with ROOT-based framework styled processors.
Definition: ConditionsObject.h:6
fire::Process Process
alias Process into this namespace
Definition: EventProcessor.h:105