LDMX Software
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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 & 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, 4)
 

Private Attributes

int runNumber_ {0}
 Run number.
 
std::string detectorName_ {""}
 Detector name.
 
std::string description_ {""}
 Run description.
 
int runStart_ {0}
 Run start in seconds since epoch.
 
int runEnd_ {0}
 Run end in seconds since epoch.
 
int numTries_ {0}
 Total number of events that were begun during the production of this run.
 
std::string softwareTag_ {GIT_SHA1}
 git SHA-1 hash associated with the software tag used to generate this file.
 
std::map< std::string, int > intParameters_
 Map of int parameters.
 
std::map< std::string, float > floatParameters_
 Map of float parameters.
 
std::map< std::string, std::string > stringParameters_
 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.

Definition at line 54 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: runNumber_(runNumber) {}
int runNumber_
Run number.
Definition RunHeader.h:248

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

71{}

Member Function Documentation

◆ getDescription()

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

Definition at line 89 of file RunHeader.h.

89{ return description_; }
std::string description_
Run description.
Definition RunHeader.h:254

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

77{ return detectorName_; }
std::string detectorName_
Detector name.
Definition RunHeader.h:251

References detectorName_.

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

174 {
175 return floatParameters_.at(name);
176 }
std::map< std::string, float > floatParameters_
Map of float parameters.
Definition RunHeader.h:288

References floatParameters_.

◆ getFloatParameters()

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

Get a const reference to all float parameters.

Definition at line 179 of file RunHeader.h.

179 {
180 return floatParameters_;
181 }

References floatParameters_.

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

149 {
150 return intParameters_.at(name);
151 }
std::map< std::string, int > intParameters_
Map of int parameters.
Definition RunHeader.h:285

References intParameters_.

◆ getIntParameters()

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

Get a const reference to all int parameters.

Definition at line 154 of file RunHeader.h.

154 {
155 return intParameters_;
156 }

References intParameters_.

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

129{ return numTries_; }
int numTries_
Total number of events that were begun during the production of this run.
Definition RunHeader.h:276

References numTries_.

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

114{ return runEnd_; }
int runEnd_
Run end in seconds since epoch.
Definition RunHeader.h:260

References runEnd_.

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

100{ return runStart_; }
int runStart_
Run start in seconds since epoch.
Definition RunHeader.h:257

References runStart_.

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

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

References softwareTag_.

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

199 {
200 return stringParameters_.at(name);
201 }
std::map< std::string, std::string > stringParameters_
Map of string parameters.
Definition RunHeader.h:291

References stringParameters_.

◆ getStringParameters()

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

Get a const reference to all string parameters.

Definition at line 204 of file RunHeader.h.

204 {
205 return stringParameters_;
206 }

References stringParameters_.

◆ Print()

void ldmx::RunHeader::Print ( ) const

Print a string desciption of this object.

Definition at line 34 of file RunHeader.cxx.

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

References stream().

◆ setDescription()

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

Set the description of this run.

Definition at line 92 of file RunHeader.h.

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

80{ detectorName_ = det; }

References detectorName_.

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

◆ setFloatParameter()

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

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

141{ numTries_ = numTries; }

References numTries_.

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

121{ runEnd_ = runEnd; }

References runEnd_.

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

107{ runStart_ = runStart; }

References runStart_.

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

◆ setStringParameter()

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

◆ 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: "
20 << "\n";
21 for (const auto &[key, val] : intParameters_)
22 s << " " << key << " = " << val << "\n";
23 s << " floatParameters: "
24 << "\n";
25 for (const auto &[key, val] : floatParameters_)
26 s << " " << key << " = " << val << "\n";
27 s << " stringParameters: "
28 << "\n";
29 for (const auto &[key, val] : stringParameters_)
30 s << " " << key << " = " << val << "\n";
31 s << "}";
32}
int getNumTries() const
Get the total number of tries that were done during the production of this run.
Definition RunHeader.h:129
const std::string & getDescription() const
Definition RunHeader.h:89
const std::string & getDetectorName() const
Definition RunHeader.h:77
int getRunNumber() const
Definition RunHeader.h:74

References floatParameters_, getDescription(), getDetectorName(), getNumTries(), getRunNumber(), intParameters_, and stringParameters_.

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

241 {
242 h.stream(s);
243 return s;
244 }

Member Data Documentation

◆ description_

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

Run description.

Definition at line 254 of file RunHeader.h.

254{""};

Referenced by getDescription(), and setDescription().

◆ detectorName_

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

Detector name.

Definition at line 251 of file RunHeader.h.

251{""};

Referenced by getDetectorName(), and setDetectorName().

◆ floatParameters_

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

Map of float parameters.

Definition at line 288 of file RunHeader.h.

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

◆ intParameters_

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

Map of int parameters.

Definition at line 285 of file RunHeader.h.

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

◆ numTries_

int ldmx::RunHeader::numTries_ {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 276 of file RunHeader.h.

276{0};

Referenced by getNumTries(), and setNumTries().

◆ runEnd_

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

Run end in seconds since epoch.

Definition at line 260 of file RunHeader.h.

260{0};

Referenced by getRunEnd(), and setRunEnd().

◆ runNumber_

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

Run number.

Definition at line 248 of file RunHeader.h.

248{0};

Referenced by getRunNumber().

◆ runStart_

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

Run start in seconds since epoch.

Definition at line 257 of file RunHeader.h.

257{0};

Referenced by getRunStart(), and setRunStart().

◆ softwareTag_

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

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

Definition at line 282 of file RunHeader.h.

282{GIT_SHA1};

Referenced by getSoftwareTag().

◆ stringParameters_

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

Map of string parameters.

Definition at line 291 of file RunHeader.h.

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


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