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.
 
bool isCompleted () const
 Check whether the file holding this run was closed cleanly.
 
void setCompleted (const bool completed)
 Mark whether this run was completed.
 
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.
 

Static Public Attributes

static constexpr int VERSION_WITH_COMPLETED {7}
 The first class version that writes completed_.
 

Private Member Functions

 ClassDef (RunHeader, 7)
 

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.
 
bool completed_ {false}
 True only once the run finished and the file was closed cleanly.
 
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

v7

Add the completed_ member so a consumer can tell a complete file from one whose writer died partway through.

Interop with v6 and earlier

Those versions have no completed_ on disk, so reading one leaves the member at its default of false. A reader cannot tell such a run apart from one that was cut short, so it has to look at the class version of the run tree (VERSION_WITH_COMPLETED) before trusting the flag.

Definition at line 67 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:294

◆ 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 92 of file RunHeader.h.

92{}

Member Function Documentation

◆ getDescription()

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

Definition at line 115 of file RunHeader.h.

115{ return description_; }
std::string description_
Run description.
Definition RunHeader.h:300

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 98 of file RunHeader.h.

98{ return detector_name_; }
std::string detector_name_
Detector name.
Definition RunHeader.h:297

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 220 of file RunHeader.h.

220 {
221 return float_parameters_.at(name);
222 }
std::map< std::string, float > float_parameters_
Map of float parameters.
Definition RunHeader.h:342

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 225 of file RunHeader.h.

225 {
226 return float_parameters_;
227 }

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 195 of file RunHeader.h.

195 {
196 return int_parameters_.at(name);
197 }
std::map< std::string, int > int_parameters_
Map of int parameters.
Definition RunHeader.h:339

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 200 of file RunHeader.h.

200 {
201 return int_parameters_;
202 }

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 112 of file RunHeader.h.

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

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 155 of file RunHeader.h.

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

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 140 of file RunHeader.h.

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

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 126 of file RunHeader.h.

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

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 107 of file RunHeader.h.

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

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 245 of file RunHeader.h.

245 {
246 return string_parameters_.at(name);
247 }
std::map< std::string, std::string > string_parameters_
Map of string parameters.
Definition RunHeader.h:345

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 250 of file RunHeader.h.

250 {
251 return string_parameters_;
252 }

References string_parameters_.

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

◆ isCompleted()

bool ldmx::RunHeader::isCompleted ( ) const
inline

Check whether the file holding this run was closed cleanly.

False means the file is missing events, either because the job was killed or because it stopped early on a preemption signal.

Returns
true if the run finished and the file closed cleanly

Definition at line 177 of file RunHeader.h.

177{ return completed_; }
bool completed_
True only once the run finished and the file was closed cleanly.
Definition RunHeader.h:325

References completed_.

Referenced by stream().

◆ print()

void ldmx::RunHeader::print ( ) const

Print a string desciption of this object.

Definition at line 32 of file RunHeader.cxx.

32{ 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().

◆ setCompleted()

void ldmx::RunHeader::setCompleted ( const bool completed)
inline

Mark whether this run was completed.

Note
Called within framework::EventFile::writeRunTree and so it should not be used elsewhere.
Parameters
[in]completedwhether the run finished cleanly

Definition at line 187 of file RunHeader.h.

187{ completed_ = completed; }

References completed_.

◆ setDescription()

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

Set the description of this run.

Definition at line 118 of file RunHeader.h.

118{ 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 101 of file RunHeader.h.

101{ detector_name_ = det; }

References detector_name_.

Referenced by hcal::HcalRawDecoder::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 167 of file RunHeader.h.

167{ num_tries_ = numTries; }

References num_tries_.

◆ 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 147 of file RunHeader.h.

147{ run_end_ = runEnd; }

References run_end_.

◆ 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 133 of file RunHeader.h.

133{ run_start_ = runStart; }

References run_start_.

◆ 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 << ", completed: " << (isCompleted() ? "true" : "false")
18 << ", detectorName: " << getDetectorName()
19 << ", description: " << getDescription() << "\n";
20 s << " intParameters: " << "\n";
21 for (const auto& [key, val] : int_parameters_)
22 s << " " << key << " = " << val << "\n";
23 s << " floatParameters: " << "\n";
24 for (const auto& [key, val] : float_parameters_)
25 s << " " << key << " = " << val << "\n";
26 s << " stringParameters: " << "\n";
27 for (const auto& [key, val] : string_parameters_)
28 s << " " << key << " = " << val << "\n";
29 s << "}";
30}
int getNumTries() const
Get the total number of tries that were done during the production of this run.
Definition RunHeader.h:155
const std::string & getDescription() const
Definition RunHeader.h:115
const std::string & getDetectorName() const
Definition RunHeader.h:98
bool isCompleted() const
Check whether the file holding this run was closed cleanly.
Definition RunHeader.h:177
int getRunNumber() const
Definition RunHeader.h:95

References float_parameters_, getDescription(), getDetectorName(), getNumTries(), getRunNumber(), int_parameters_, isCompleted(), 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 287 of file RunHeader.h.

287 {
288 h.stream(s);
289 return s;
290 }

Member Data Documentation

◆ completed_

bool ldmx::RunHeader::completed_ {false}
private

True only once the run finished and the file was closed cleanly.

Definition at line 325 of file RunHeader.h.

325{false};

Referenced by isCompleted(), and setCompleted().

◆ description_

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

Run description.

Definition at line 300 of file RunHeader.h.

300{""};

Referenced by getDescription(), and setDescription().

◆ detector_name_

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

Detector name.

Definition at line 297 of file RunHeader.h.

297{""};

Referenced by getDetectorName(), and setDetectorName().

◆ float_parameters_

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

Map of float parameters.

Definition at line 342 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 339 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 336 of file RunHeader.h.

336{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 322 of file RunHeader.h.

322{0};

Referenced by getNumTries(), and setNumTries().

◆ run_end_

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

Run end in seconds since epoch.

Definition at line 306 of file RunHeader.h.

306{0};

Referenced by getRunEnd(), and setRunEnd().

◆ run_number_

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

Run number.

Definition at line 294 of file RunHeader.h.

294{0};

Referenced by getRunNumber().

◆ run_start_

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

Run start in seconds since epoch.

Definition at line 303 of file RunHeader.h.

303{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 331 of file RunHeader.h.

331{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 345 of file RunHeader.h.

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

◆ VERSION_WITH_COMPLETED

int ldmx::RunHeader::VERSION_WITH_COMPLETED {7}
staticconstexpr

The first class version that writes completed_.

Run headers read out of a file written with an earlier version say nothing about whether their run finished.

Definition at line 75 of file RunHeader.h.

75{7};

Referenced by framework::EventFile::importRunHeaders().


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