LDMX Software
EventHeader.cxx
1
3
4#include "Framework/Exception/Exception.h"
5
6ClassImp(ldmx::EventHeader);
7
8namespace ldmx {
9const std::string EventHeader::BRANCH = "EventHeader";
10
11void EventHeader::Clear(Option_t*) {
12 eventNumber_ = -1;
13 run_ = -1;
14 timestamp_ = TTimeStamp(0, 0);
15 weight_ = 1.0;
16 isRealData_ = false;
17 intParameters_.clear();
18 floatParameters_.clear();
19 stringParameters_.clear();
20}
21
22void EventHeader::Print(Option_t*) const {
23 std::cout << "EventHeader {"
24 << " eventNumber: " << eventNumber_ << ", run: " << run_
25 << ", timestamp: " << timestamp_ << ", weight: " << weight_;
26 if (isRealData_)
27 std::cout << ", DATA";
28 else
29 std::cout << ", MC";
30 std::cout << " }" << std::endl;
31}
32
33int EventHeader::getIntParameter(const std::string& name) const {
34 if (intParameters_.find(name) == intParameters_.end()) {
35 EXCEPTION_RAISE("NoParam", "Parameter '" + name +
36 "' does not exist in the int parameters.");
37 }
38 return intParameters_.at(name);
39}
40
41float EventHeader::getFloatParameter(const std::string& name) const {
42 if (floatParameters_.find(name) == floatParameters_.end()) {
43 EXCEPTION_RAISE("NoParam", "Parameter '" + name +
44 "' does not exist in the float parameters.");
45 }
46 return floatParameters_.at(name);
47}
48
49std::string EventHeader::getStringParameter(const std::string& name) const {
50 if (stringParameters_.find(name) == stringParameters_.end()) {
51 EXCEPTION_RAISE(
52 "NoParam",
53 "Parameter '" + name + "' does not exist in the string parameters.");
54 }
55 return stringParameters_.at(name);
56}
57
58} // namespace ldmx
Class that provides header information about an event such as event number and timestamp.
Provides header information an event such as event number and timestamp.
Definition EventHeader.h:44
std::map< std::string, int > intParameters_
The int parameters.
double weight_
The event weight.
TTimeStamp timestamp_
The event timestamp.
int getIntParameter(const std::string &name) const
Get an int parameter value.
int run_
The run number.
bool isRealData_
Is this event real data?
std::map< std::string, float > floatParameters_
The float parameters.
float getFloatParameter(const std::string &name) const
Get a float parameter value.
std::map< std::string, std::string > stringParameters_
The string parameters.
void Print(Option_t *o="") const
Print this object.
static const std::string BRANCH
Name of EventHeader branch.
Definition EventHeader.h:49
std::string getStringParameter(const std::string &name) const
Get a string parameter value.
int eventNumber_
The event number.
void Clear(Option_t *o="")
Clear information from this object.