LDMX Software
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ldmx::EventHeader Class Reference

Provides header information an event such as event number and timestamp. More...

#include <EventHeader.h>

Public Member Functions

 EventHeader ()=default
 Class constructor.
 
virtual ~EventHeader ()=default
 Class destructor.
 
void Clear (Option_t *o="")
 Clear information from this object.
 
void Print (Option_t *o="") const
 Print this object.
 
int getEventNumber () const
 Return the event number.
 
int getRun () const
 Return the run number.
 
const TTimeStamp & getTimestamp () const
 Get the event's timestamp.
 
double getWeight () const
 Get the event weight (default of 1.0).
 
bool isRealData () const
 Is this a real data event?
 
void setRealData (bool yes=true)
 set whether this event is real or MC data
 
void setEventNumber (int eventNumber)
 Set the event number.
 
void setRun (int run)
 Set the run number.
 
void setTimestamp (const TTimeStamp &timestamp)
 Set the timestamp.
 
void setWeight (double weight)
 Set the event weight.
 
int getIntParameter (const std::string &name) const
 Get an int parameter value.
 
void setIntParameter (const std::string &name, int value)
 Set an int parameter value.
 
float getFloatParameter (const std::string &name) const
 Get a float parameter value.
 
void setFloatParameter (const std::string &name, float value)
 Set a float parameter value.
 
std::string getStringParameter (const std::string &name) const
 Get a string parameter value.
 
void setStringParameter (const std::string &name, std::string value)
 Set a string parameter value.
 

Static Public Attributes

static const std::string BRANCH = "EventHeader"
 Name of EventHeader branch.
 

Protected Member Functions

 ClassDef (EventHeader, 2)
 ROOT class definition.
 

Protected Attributes

int eventNumber_ {-1}
 The event number.
 
int run_ {-1}
 The run number.
 
TTimeStamp timestamp_ {0, 0}
 The event timestamp.
 
double weight_ {1.0}
 The event weight.
 
bool isRealData_ {false}
 Is this event real data?
 
std::map< std::string, int > intParameters_
 The int parameters.
 
std::map< std::string, float > floatParameters_
 The float parameters.
 
std::map< std::string, std::string > stringParameters_
 The string parameters.
 

Detailed Description

Provides header information an event such as event number and timestamp.

The evolution of the EventHeader object has been pretty slow since the `*Parameter* members can be used to hold most additional information. ROOT's serialization infrastructure does define a class version and so we document the versions here.

v1

This was the initial version of the EventHeader and should be considered a "beta" version. It is not even internally consistent in that some changes were made to the EventHeader and how it was serialized without modifying this version number. It has largely been lost to the sands of time as Framework has been moved into its own repository out of ldmx-sw.

v2

This is the main version currently and has all of the ldmx-sw necessary information except the number of tries it took to generate any given event. This is what motivated the update to v3.

Definition at line 44 of file EventHeader.h.

Member Function Documentation

◆ Clear()

void ldmx::EventHeader::Clear ( Option_t *  o = "")

Clear information from this object.

Parameters
[in]oROOT-style Option (ignored)

Definition at line 11 of file EventHeader.cxx.

11 {
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}
std::map< std::string, int > intParameters_
The int parameters.
double weight_
The event weight.
TTimeStamp timestamp_
The event timestamp.
int run_
The run number.
bool isRealData_
Is this event real data?
std::map< std::string, float > floatParameters_
The float parameters.
std::map< std::string, std::string > stringParameters_
The string parameters.
int eventNumber_
The event number.

References eventNumber_, floatParameters_, intParameters_, isRealData_, run_, stringParameters_, timestamp_, and weight_.

◆ getEventNumber()

int ldmx::EventHeader::getEventNumber ( ) const
inline

◆ getFloatParameter()

float ldmx::EventHeader::getFloatParameter ( const std::string &  name) const

Get a float parameter value.

Exceptions
Exceptionif parameter does not exist
Parameters
nameThe name of the parameter.
Returns
value The parameter value.

Definition at line 41 of file EventHeader.cxx.

41 {
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}

References floatParameters_.

◆ getIntParameter()

int ldmx::EventHeader::getIntParameter ( const std::string &  name) const

Get an int parameter value.

Exceptions
Exceptionif parameter does not exist
Parameters
nameThe name of the parameter.
Returns
The parameter value.

Definition at line 33 of file EventHeader.cxx.

33 {
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}

References intParameters_.

◆ getRun()

int ldmx::EventHeader::getRun ( ) const
inline

◆ getStringParameter()

std::string ldmx::EventHeader::getStringParameter ( const std::string &  name) const

Get a string parameter value.

Exceptions
Exceptionif parameter does not exist
Parameters
nameThe name of the parameter.
Returns
value The parameter value.

Definition at line 49 of file EventHeader.cxx.

49 {
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}

References stringParameters_.

◆ getTimestamp()

const TTimeStamp & ldmx::EventHeader::getTimestamp ( ) const
inline

Get the event's timestamp.

This currently returns second's since the epoch for simulated events.

Returns
The event's timestamp.
Note
The returned object has a possible resolution of nanoseconds.

Definition at line 92 of file EventHeader.h.

92{ return timestamp_; }

References timestamp_.

◆ getWeight()

double ldmx::EventHeader::getWeight ( ) const
inline

Get the event weight (default of 1.0).

Returns
The event weight.

Definition at line 98 of file EventHeader.h.

98{ return weight_; }

References weight_.

Referenced by framework::Event::getEventWeight(), and dqm::DarkBremInteraction::produce().

◆ isRealData()

bool ldmx::EventHeader::isRealData ( ) const
inline

Is this a real data event?

Returns
True if this is a real data event.

Definition at line 104 of file EventHeader.h.

104{ return isRealData_; }

References isRealData_.

Referenced by framework::Conditions::getConditionPtr(), and framework::ConditionsIOV::validForEvent().

◆ Print()

void ldmx::EventHeader::Print ( Option_t *  o = "") const

Print this object.

Parameters
[in]oROOT-style Option (ignored)

Definition at line 22 of file EventHeader.cxx.

22 {
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}

References eventNumber_, isRealData_, run_, timestamp_, and weight_.

◆ setEventNumber()

void ldmx::EventHeader::setEventNumber ( int  eventNumber)
inline

Set the event number.

Note
This is used within Framework during Production Mode. It is untested but Producers can probably change the event number without issue since the tracking of the number of events processed is done separately within Framework.
Parameters
eventNumberThe event number.

Definition at line 120 of file EventHeader.h.

120{ this->eventNumber_ = eventNumber; }

References eventNumber_.

Referenced by packing::rawdatafile::File::nextEvent(), recon::OverlayProducer::onNewRun(), and framework::Process::run().

◆ setFloatParameter()

void ldmx::EventHeader::setFloatParameter ( const std::string &  name,
float  value 
)
inline

Set a float parameter value.

Parameters
nameThe name of the parameter.
Returns
value The parameter value.

Definition at line 185 of file EventHeader.h.

185 {
186 floatParameters_[name] = value;
187 }

References floatParameters_.

◆ setIntParameter()

void ldmx::EventHeader::setIntParameter ( const std::string &  name,
int  value 
)
inline

Set an int parameter value.

Parameters
nameThe name of the parameter.
valueThe value of the parameter.
Returns
The parameter value.

Definition at line 168 of file EventHeader.h.

168 {
169 intParameters_[name] = value;
170 }

References intParameters_.

◆ setRealData()

void ldmx::EventHeader::setRealData ( bool  yes = true)
inline

set whether this event is real or MC data

Parameters
[in]yesTrue if this event is real data

Definition at line 110 of file EventHeader.h.

110{ isRealData_ = yes; }

References isRealData_.

◆ setRun()

void ldmx::EventHeader::setRun ( int  run)
inline

Set the run number.

Note
This is used within Framework during Production Mode. It is untested but Producers can probably change the run number without issue.
Parameters
runThe run number.

Definition at line 129 of file EventHeader.h.

129{ this->run_ = run; }

References run_.

Referenced by framework::Process::run().

◆ setStringParameter()

void ldmx::EventHeader::setStringParameter ( const std::string &  name,
std::string  value 
)
inline

Set a string parameter value.

Parameters
nameThe name of the parameter.
Returns
value The parameter value.

Definition at line 202 of file EventHeader.h.

202 {
203 stringParameters_[name] = value;
204 }

References stringParameters_.

◆ setTimestamp()

void ldmx::EventHeader::setTimestamp ( const TTimeStamp &  timestamp)
inline

Set the timestamp.

Note
This is used within Framework during Production Mode. It is untested but Producers can probably change the timestamp without issue.
Parameters
timestampThe timestamp.

Definition at line 138 of file EventHeader.h.

138 {
139 this->timestamp_ = timestamp;
140 }

References timestamp_.

Referenced by framework::Process::run().

◆ setWeight()

void ldmx::EventHeader::setWeight ( double  weight)
inline

Set the event weight.

The event weight is by default 1 for all events. It is up to a downstream producer to update the event weight if their procedure demands it (for example, a simulation producer would copy its event weight here).

Parameters
weightThe event weight.

Definition at line 152 of file EventHeader.h.

152{ this->weight_ = weight; }

References weight_.

Member Data Documentation

◆ BRANCH

const std::string ldmx::EventHeader::BRANCH = "EventHeader"
static

◆ eventNumber_

int ldmx::EventHeader::eventNumber_ {-1}
protected

The event number.

Definition at line 210 of file EventHeader.h.

210{-1};

Referenced by Clear(), getEventNumber(), Print(), and setEventNumber().

◆ floatParameters_

std::map<std::string, float> ldmx::EventHeader::floatParameters_
protected

The float parameters.

Definition at line 240 of file EventHeader.h.

Referenced by Clear(), getFloatParameter(), and setFloatParameter().

◆ intParameters_

std::map<std::string, int> ldmx::EventHeader::intParameters_
protected

The int parameters.

Definition at line 235 of file EventHeader.h.

Referenced by Clear(), getIntParameter(), and setIntParameter().

◆ isRealData_

bool ldmx::EventHeader::isRealData_ {false}
protected

Is this event real data?

Definition at line 230 of file EventHeader.h.

230{false};

Referenced by Clear(), isRealData(), Print(), and setRealData().

◆ run_

int ldmx::EventHeader::run_ {-1}
protected

The run number.

Definition at line 215 of file EventHeader.h.

215{-1};

Referenced by Clear(), getRun(), Print(), and setRun().

◆ stringParameters_

std::map<std::string, std::string> ldmx::EventHeader::stringParameters_
protected

The string parameters.

Definition at line 245 of file EventHeader.h.

Referenced by Clear(), getStringParameter(), and setStringParameter().

◆ timestamp_

TTimeStamp ldmx::EventHeader::timestamp_ {0, 0}
protected

The event timestamp.

Definition at line 220 of file EventHeader.h.

220{0, 0};

Referenced by Clear(), getTimestamp(), Print(), and setTimestamp().

◆ weight_

double ldmx::EventHeader::weight_ {1.0}
protected

The event weight.

Definition at line 225 of file EventHeader.h.

225{1.0};

Referenced by Clear(), getWeight(), Print(), and setWeight().


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