LDMX Software
ldmx::RunHeader Class Reference

Run-specific configuration and data stored in its own output TTree alongside the event TTree in the output file. More...

#include <RunHeader.h>

Public Member Functions

 RunHeader (int runNumber)
 Constructor.
 
 RunHeader ()=default
 Default constructor.
 
virtual ~RunHeader ()
 Destructor.
 
int getRunNumber () const
 
const std::string & getDetectorName () const
 
void setDetectorName (const std::string &det)
 Set the name of the detector that was used in this run.
 
const std::string & getSoftwareTag () const
 
const std::string & getLdmxswVersion () const
 
const std::string & getDescription () const
 
void setDescription (const std::string &des)
 Set the description of this run.
 
int getRunStart () const
 Get the start time of the run in seconds since epoch.
 
void setRunStart (const int runStart)
 Set the run start time in seconds since epoch.
 
int getRunEnd () const
 Get the end time of the run in seconds since epoch.
 
void setRunEnd (const int runEnd)
 Set the end time of the run in seconds since epoch.
 
int getNumTries () const
 Get the total number of tries that were done during the production of this run.
 
void setNumTries (const int numTries)
 Set the total number of tries that were done during the production of this run.
 
int getIntParameter (const std::string &name) const
 Get an int parameter value.
 
const std::map< std::string, int > & getIntParameters () const
 Get a const reference to all int parameters.
 
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.
 
const std::map< std::string, float > & getFloatParameters () const
 Get a const reference to all float parameters.
 
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.
 
const std::map< std::string, std::string > & getStringParameters () const
 Get a const reference to all string parameters.
 
void setStringParameter (const std::string &name, std::string value)
 Set a string parameter value.
 
void stream (std::ostream &s) const
 Stream this object into the input ostream.
 
void print () const
 Print a string desciption of this object.
 

Private Member Functions

 ClassDef (RunHeader, 6)
 

Private Attributes

int run_number_ {0}
 Run number.
 
std::string detector_name_ {""}
 Detector name.
 
std::string description_ {""}
 Run description.
 
int run_start_ {0}
 Run start in seconds since epoch.
 
int run_end_ {0}
 Run end in seconds since epoch.
 
int num_tries_ {0}
 Total number of events that were begun during the production of this run.
 
std::string software_tag_ {GIT_SHA1}
 git SHA-1 hash associated with the software tag used to generate this file.
 
std::string ldmxsw_version_ {LDMXSW_VERSION}
 ldmx-sw software version
 
std::map< std::string, int > int_parameters_
 Map of int parameters.
 
std::map< std::string, float > float_parameters_
 Map of float parameters.
 
std::map< std::string, std::string > string_parameters_
 Map of string parameters.
 

Friends

std::ostream & operator<< (std::ostream &s, const ldmx::RunHeader &h)
 Stream this object to an output stream.
 

Detailed Description

Run-specific configuration and data stored in its own output TTree alongside the event TTree in the output file.

Similar to the EventHeader, the evolution of this object has been pretty slow since the *Parameter* members have been used to hold most of the additional information (for example, a lot of the simulation configuration information). The versions of the RunHeader as defined by ROOT's serialization infrastructure are documented here.

v1

An initial beta version now lost to the sands of time.

v2 and v3

There are no material (serialized data) changes that are different between v2 and v3, but this version was increased because we moved the Framework repo (and thus the RunHeader source) from being within ldmx-sw to its own stand-alone repo. With an abundance of caution (and lack of understanding of what ROOT's dictionary cares about), we increased the version number.

v4

Add the numTries_ member variable in order to store exactly how many events were started during the production of the run.

Interop with v3

When reading a file written with v3 RunHeader using software with v4 RunHeader, the numTries_ member will keep its default value of 0. This is a nice signal value since it conveys to the user the lack of information. If the user somehow gets into the situation of reading a v4 RunHeader with v3 software, the numTries_ member is quietly ignored, maintaining the format of the v3 RunHeader in the resulting output file.

v5

Include a member to track the ldmx-sw version

Definition at line 57 of file RunHeader.h.

Constructor & Destructor Documentation

◆ RunHeader() [1/2]

ldmx::RunHeader::RunHeader ( int runNumber)

Constructor.

Parameters
runNumberThe run number uniquely identifying this run

Definition at line 13 of file RunHeader.cxx.

13: run_number_(run_number) {}
int run_number_
Run number.
Definition RunHeader.h:256

◆ RunHeader() [2/2]

ldmx::RunHeader::RunHeader ( )
default

Default constructor.

Note
This exists for filling the object from a ROOT branch.

◆ ~RunHeader()

virtual ldmx::RunHeader::~RunHeader ( )
inlinevirtual

Destructor.

Definition at line 74 of file RunHeader.h.

74{}

Member Function Documentation

◆ getDescription()

const std::string & ldmx::RunHeader::getDescription ( ) const
inline
Returns
A short description of the run.

Definition at line 97 of file RunHeader.h.

97{ return description_; }
std::string description_
Run description.
Definition RunHeader.h:262

References description_.

Referenced by stream().

◆ getDetectorName()

const std::string & ldmx::RunHeader::getDetectorName ( ) const
inline
Returns
The name of the detector used to create the events.

Definition at line 80 of file RunHeader.h.

80{ return detector_name_; }
std::string detector_name_
Detector name.
Definition RunHeader.h:259

References detector_name_.

Referenced by ecal::EcalGeometryProvider::onNewRun(), hcal::HcalGeometryProvider::onNewRun(), and stream().

◆ getFloatParameter()

float ldmx::RunHeader::getFloatParameter ( const std::string & name) const
inline

Get a float parameter value.

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

Definition at line 182 of file RunHeader.h.

182 {
183 return float_parameters_.at(name);
184 }
std::map< std::string, float > float_parameters_
Map of float parameters.
Definition RunHeader.h:301

References float_parameters_.

◆ getFloatParameters()

const std::map< std::string, float > & ldmx::RunHeader::getFloatParameters ( ) const
inline

Get a const reference to all float parameters.

Definition at line 187 of file RunHeader.h.

187 {
188 return float_parameters_;
189 }

References float_parameters_.

◆ getIntParameter()

int ldmx::RunHeader::getIntParameter ( const std::string & name) const
inline

Get an int parameter value.

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

Definition at line 157 of file RunHeader.h.

157 {
158 return int_parameters_.at(name);
159 }
std::map< std::string, int > int_parameters_
Map of int parameters.
Definition RunHeader.h:298

References int_parameters_.

◆ getIntParameters()

const std::map< std::string, int > & ldmx::RunHeader::getIntParameters ( ) const
inline

Get a const reference to all int parameters.

Definition at line 162 of file RunHeader.h.

162 {
163 return int_parameters_;
164 }

References int_parameters_.

◆ getLdmxswVersion()

const std::string & ldmx::RunHeader::getLdmxswVersion ( ) const
inline
Returns
The ldmx-sw version used to generate this file

Definition at line 94 of file RunHeader.h.

94{ return ldmxsw_version_; }
std::string ldmxsw_version_
ldmx-sw software version
Definition RunHeader.h:295

References ldmxsw_version_.

◆ getNumTries()

int ldmx::RunHeader::getNumTries ( ) const
inline

Get the total number of tries that were done during the production of this run.

Returns
the number of tries

Definition at line 137 of file RunHeader.h.

137{ return num_tries_; }
int num_tries_
Total number of events that were begun during the production of this run.
Definition RunHeader.h:284

References num_tries_.

Referenced by stream().

◆ getRunEnd()

int ldmx::RunHeader::getRunEnd ( ) const
inline

Get the end time of the run in seconds since epoch.

Returns
The end time of the run.

Definition at line 122 of file RunHeader.h.

122{ return run_end_; }
int run_end_
Run end in seconds since epoch.
Definition RunHeader.h:268

References run_end_.

◆ getRunNumber()

int ldmx::RunHeader::getRunNumber ( ) const
inline

◆ getRunStart()

int ldmx::RunHeader::getRunStart ( ) const
inline

Get the start time of the run in seconds since epoch.

Returns
The start time of the run.

Definition at line 108 of file RunHeader.h.

108{ return run_start_; }
int run_start_
Run start in seconds since epoch.
Definition RunHeader.h:265

References run_start_.

◆ getSoftwareTag()

const std::string & ldmx::RunHeader::getSoftwareTag ( ) const
inline
Returns
The git SHA-1 associated with the software tag used to generate this file.

Definition at line 89 of file RunHeader.h.

89{ return software_tag_; }
std::string software_tag_
git SHA-1 hash associated with the software tag used to generate this file.
Definition RunHeader.h:290

References software_tag_.

◆ getStringParameter()

std::string ldmx::RunHeader::getStringParameter ( const std::string & name) const
inline

Get a string parameter value.

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

Definition at line 207 of file RunHeader.h.

207 {
208 return string_parameters_.at(name);
209 }
std::map< std::string, std::string > string_parameters_
Map of string parameters.
Definition RunHeader.h:304

References string_parameters_.

◆ getStringParameters()

const std::map< std::string, std::string > & ldmx::RunHeader::getStringParameters ( ) const
inline

Get a const reference to all string parameters.

Definition at line 212 of file RunHeader.h.

212 {
213 return string_parameters_;
214 }

References string_parameters_.

Referenced by simcore::GenieReweightProducer::onNewRun().

◆ print()

void ldmx::RunHeader::print ( ) const

Print a string desciption of this object.

Definition at line 31 of file RunHeader.cxx.

31{ stream(std::cout); }
void stream(std::ostream &s) const
Stream this object into the input ostream.
Definition RunHeader.cxx:15

References stream().

Referenced by framework::RunHeaderAnalyzer::onNewRun().

◆ setDescription()

void ldmx::RunHeader::setDescription ( const std::string & des)
inline

Set the description of this run.

Definition at line 100 of file RunHeader.h.

100{ description_ = des; }

References description_.

Referenced by simcore::Simulator::beforeNewRun().

◆ setDetectorName()

void ldmx::RunHeader::setDetectorName ( const std::string & det)
inline

Set the name of the detector that was used in this run.

Definition at line 83 of file RunHeader.h.

83{ detector_name_ = det; }

References detector_name_.

Referenced by hcal::HcalRawDecoder::beforeNewRun(), packing::SingleSubsystemUnpacker::beforeNewRun(), and simcore::Simulator::beforeNewRun().

◆ setFloatParameter()

◆ setIntParameter()

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

◆ setNumTries()

void ldmx::RunHeader::setNumTries ( const int numTries)
inline

Set the total number of tries that were done during the production of this run.

Note
This function is called within framework::Process::run and so it should not be used elsewhere. Changing the number of tries during processing is undefined behavior.
Parameters
[in]numTriesthe number of tries in this run

Definition at line 149 of file RunHeader.h.

149{ num_tries_ = numTries; }

References num_tries_.

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

◆ setRunEnd()

void ldmx::RunHeader::setRunEnd ( const int runEnd)
inline

Set the end time of the run in seconds since epoch.

Parameters
[in]runEndthe end time of the run.

Definition at line 129 of file RunHeader.h.

129{ run_end_ = runEnd; }

References run_end_.

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

◆ setRunStart()

void ldmx::RunHeader::setRunStart ( const int runStart)
inline

Set the run start time in seconds since epoch.

Parameters
[in]runStartthe start time of the run.

Definition at line 115 of file RunHeader.h.

115{ run_start_ = runStart; }

References run_start_.

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

◆ setStringParameter()

◆ stream()

void ldmx::RunHeader::stream ( std::ostream & s) const

Stream this object into the input ostream.

Includes new-line characters to separate out the different parameter maps

Parameters
[in]sostream to write to

Definition at line 15 of file RunHeader.cxx.

15 {
16 s << "RunHeader { run: " << getRunNumber() << ", numTries: " << getNumTries()
17 << ", detectorName: " << getDetectorName()
18 << ", description: " << getDescription() << "\n";
19 s << " intParameters: " << "\n";
20 for (const auto &[key, val] : int_parameters_)
21 s << " " << key << " = " << val << "\n";
22 s << " floatParameters: " << "\n";
23 for (const auto &[key, val] : float_parameters_)
24 s << " " << key << " = " << val << "\n";
25 s << " stringParameters: " << "\n";
26 for (const auto &[key, val] : string_parameters_)
27 s << " " << key << " = " << val << "\n";
28 s << "}";
29}
int getNumTries() const
Get the total number of tries that were done during the production of this run.
Definition RunHeader.h:137
const std::string & getDescription() const
Definition RunHeader.h:97
const std::string & getDetectorName() const
Definition RunHeader.h:80
int getRunNumber() const
Definition RunHeader.h:77

References float_parameters_, getDescription(), getDetectorName(), getNumTries(), getRunNumber(), int_parameters_, and string_parameters_.

Referenced by print().

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const ldmx::RunHeader & h )
friend

Stream this object to an output stream.

Needs to be here and labeled as friend for it to be compatible with Boost logging.

See also
ldmx::RunHeader::stream
Parameters
[in]sostream to write to
[in]hRunHeader to write out
Returns
modified ostream

Definition at line 249 of file RunHeader.h.

249 {
250 h.stream(s);
251 return s;
252 }

Member Data Documentation

◆ description_

std::string ldmx::RunHeader::description_ {""}
private

Run description.

Definition at line 262 of file RunHeader.h.

262{""};

Referenced by getDescription(), and setDescription().

◆ detector_name_

std::string ldmx::RunHeader::detector_name_ {""}
private

Detector name.

Definition at line 259 of file RunHeader.h.

259{""};

Referenced by getDetectorName(), and setDetectorName().

◆ float_parameters_

std::map<std::string, float> ldmx::RunHeader::float_parameters_
private

Map of float parameters.

Definition at line 301 of file RunHeader.h.

Referenced by getFloatParameter(), getFloatParameters(), setFloatParameter(), and stream().

◆ int_parameters_

std::map<std::string, int> ldmx::RunHeader::int_parameters_
private

Map of int parameters.

Definition at line 298 of file RunHeader.h.

Referenced by getIntParameter(), getIntParameters(), setIntParameter(), and stream().

◆ ldmxsw_version_

std::string ldmx::RunHeader::ldmxsw_version_ {LDMXSW_VERSION}
private

ldmx-sw software version

Definition at line 295 of file RunHeader.h.

295{LDMXSW_VERSION};

Referenced by getLdmxswVersion().

◆ num_tries_

int ldmx::RunHeader::num_tries_ {0}
private

Total number of events that were begun during the production of this run.

This value is only set at the end of processing so we can faithfully store the total number of events that were started. In the case where maxTriesPerEvent is set to 1, this will be the same as the configured maxEvents during Production Mode. If more than one try per event is allowed, this will not necessarily be maxEvents since processors could abort an event causing more than maxEvents to be started. This can be summarized by the following inequality

maxEvents <= numTries <= maxEvents*maxTriesPerEvent

Definition at line 284 of file RunHeader.h.

284{0};

Referenced by getNumTries(), and setNumTries().

◆ run_end_

int ldmx::RunHeader::run_end_ {0}
private

Run end in seconds since epoch.

Definition at line 268 of file RunHeader.h.

268{0};

Referenced by getRunEnd(), and setRunEnd().

◆ run_number_

int ldmx::RunHeader::run_number_ {0}
private

Run number.

Definition at line 256 of file RunHeader.h.

256{0};

Referenced by getRunNumber().

◆ run_start_

int ldmx::RunHeader::run_start_ {0}
private

Run start in seconds since epoch.

Definition at line 265 of file RunHeader.h.

265{0};

Referenced by getRunStart(), and setRunStart().

◆ software_tag_

std::string ldmx::RunHeader::software_tag_ {GIT_SHA1}
private

git SHA-1 hash associated with the software tag used to generate this file.

Definition at line 290 of file RunHeader.h.

290{GIT_SHA1};

Referenced by getSoftwareTag().

◆ string_parameters_

std::map<std::string, std::string> ldmx::RunHeader::string_parameters_
private

Map of string parameters.

Definition at line 304 of file RunHeader.h.

Referenced by getStringParameter(), getStringParameters(), setStringParameter(), and stream().


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