Belle II Software light-2406-ragdoll
EventExtraInfo Class Reference

Class to stores ExtraInfo of the whole event. More...

#include <EventExtraInfo.h>

Inheritance diagram for EventExtraInfo:
Collaboration diagram for EventExtraInfo:

Public Member Functions

float getExtraInfo (const std::string &name) const
 Return given value if set.
 
bool hasExtraInfo (const std::string &name) const
 Return whether the extra info with the given name is set.
 
void removeExtraInfo ()
 Removes extra info from event.
 
void addExtraInfo (const std::string &name, float value)
 Sets the user-defined data of given name to the given value.
 
void setExtraInfo (const std::string &name, float value)
 Sets the user-defined data of given name to the given value.
 
std::string getInfoHTML () const
 Return a short summary of this object's contents in HTML format.
 
std::vector< std::string > getNames () const
 Grab the names in this event extra info (for printing etc)
 
std::string getExtraStringInfo (const std::string &name) const
 Return given value if set.
 
bool hasExtraStringInfo (const std::string &name) const
 Return whether the extra string info with the given name is set.
 
void removeExtraStringInfo ()
 Removes extra string info from event.
 
void addExtraStringInfo (const std::string &name, const std::string &value)
 Sets the user-defined data of given name to the given value.
 
void setExtraStringInfo (const std::string &name, const std::string &value)
 Sets the user-defined data of given name to the given value.
 
std::vector< std::string > getStringInfoNames () const
 Grab the names in this event extra string info (for printing etc)
 
void addEventType (const std::string &eventType)
 Add the event type information.
 
std::string getEventType () const
 Get the event type information.
 

Private Member Functions

 ClassDef (EventExtraInfo, 3)
 Class to store event extra info.
 

Private Attributes

std::map< std::string, float > eventExtraInfo
 map variable names to values.
 
std::map< std::string, std::string > eventExtraStringInfo
 map variable names to values for string data type.
 

Detailed Description

Class to stores ExtraInfo of the whole event.

Used by TMVAExpert to save expert output for a event-level training

Definition at line 25 of file EventExtraInfo.h.

Member Function Documentation

◆ addEventType()

void addEventType ( const std::string &  eventType)
inline

Add the event type information.

Helper function for the GeneratorBaseModule.

Definition at line 90 of file EventExtraInfo.h.

91 {
92 addExtraStringInfo(std::string("eventType"), eventType);
93 };
void addExtraStringInfo(const std::string &name, const std::string &value)
Sets the user-defined data of given name to the given value.

◆ addExtraInfo()

void addExtraInfo ( const std::string &  name,
float  value 
)

Sets the user-defined data of given name to the given value.

throws std::out_of_range if variable is already set.

Definition at line 34 of file EventExtraInfo.cc.

35{
36 if (hasExtraInfo(name)) {
37 throw std::out_of_range(std::string("Key with name ") + name + " already exists in EventExtraInfo.");
38 }
39 eventExtraInfo[name] = value;
40}
std::map< std::string, float > eventExtraInfo
map variable names to values.
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.

◆ addExtraStringInfo()

void addExtraStringInfo ( const std::string &  name,
const std::string &  value 
)

Sets the user-defined data of given name to the given value.

throws std::out_of_range if variable is already set.

Definition at line 84 of file EventExtraInfo.cc.

85{
86 if (hasExtraStringInfo(name)) {
87 throw std::out_of_range(std::string("Key with name ") + name + " already exists in EventExtraInfo.");
88 }
89 eventExtraStringInfo[name] = value;
90}
std::map< std::string, std::string > eventExtraStringInfo
map variable names to values for string data type.
bool hasExtraStringInfo(const std::string &name) const
Return whether the extra string info with the given name is set.

◆ getEventType()

std::string getEventType ( ) const

Get the event type information.

Helper function for the VariablesToNtupleModule

Definition at line 105 of file EventExtraInfo.cc.

106{
107 if (hasExtraStringInfo(std::string("eventType")))
108 return getExtraStringInfo(std::string("eventType"));
109 else
110 return std::string("");
111}
std::string getExtraStringInfo(const std::string &name) const
Return given value if set.

◆ getExtraInfo()

float getExtraInfo ( const std::string &  name) const

Return given value if set.

throws std::out_of_range if variable is not set.

Definition at line 16 of file EventExtraInfo.cc.

17{
18 if (hasExtraInfo(name)) return eventExtraInfo.at(name);
19 else throw std::runtime_error("EventExtraInfo::getExtraInfo: You try to access the EventExtraInfo '" + name +
20 "', but it doesn't exist.");
21}

◆ getExtraStringInfo()

std::string getExtraStringInfo ( const std::string &  name) const

Return given value if set.

throws std::out_of_range if variable is not set.

Definition at line 66 of file EventExtraInfo.cc.

67{
68 if (hasExtraStringInfo(name)) return eventExtraStringInfo.at(name);
69 else throw std::runtime_error("EventExtraInfo::getExtraStringInfo: You try to access the EventExtraInfo '" + name +
70 "', but it doesn't exist.");
71}

◆ getInfoHTML()

std::string getInfoHTML ( ) const

Return a short summary of this object's contents in HTML format.

Definition at line 47 of file EventExtraInfo.cc.

48{
49 std::string s;
50 for (const auto& pair : eventExtraInfo) {
51 s += HTML::escape(pair.first) + " = " + std::to_string(pair.second) + "<br />";
52 }
53 return s;
54}
std::string escape(const std::string &str)
Convert &, <, > etc.
Definition: HTML.cc:159

◆ getNames()

std::vector< std::string > getNames ( ) const

Grab the names in this event extra info (for printing etc)

Definition at line 56 of file EventExtraInfo.cc.

57{
58 std::vector<std::string> out;
59 for (const auto& pair : eventExtraInfo)
60 out.push_back(pair.first);
61 return out;
62}

◆ getStringInfoNames()

std::vector< std::string > getStringInfoNames ( ) const

Grab the names in this event extra string info (for printing etc)

Definition at line 97 of file EventExtraInfo.cc.

98{
99 std::vector<std::string> out;
100 for (const auto& pair : eventExtraStringInfo)
101 out.push_back(pair.first);
102 return out;
103}

◆ hasExtraInfo()

bool hasExtraInfo ( const std::string &  name) const

Return whether the extra info with the given name is set.

Definition at line 23 of file EventExtraInfo.cc.

24{
25 return not(eventExtraInfo.find(name) == eventExtraInfo.end());
26}

◆ hasExtraStringInfo()

bool hasExtraStringInfo ( const std::string &  name) const

Return whether the extra string info with the given name is set.

Definition at line 73 of file EventExtraInfo.cc.

74{
75 return not(eventExtraStringInfo.find(name) == eventExtraStringInfo.end());
76}

◆ removeExtraInfo()

void removeExtraInfo ( )

Removes extra info from event.

Definition at line 29 of file EventExtraInfo.cc.

30{
31 eventExtraInfo.clear();
32}

◆ removeExtraStringInfo()

void removeExtraStringInfo ( )

Removes extra string info from event.

Definition at line 79 of file EventExtraInfo.cc.

80{
82}

◆ setExtraInfo()

void setExtraInfo ( const std::string &  name,
float  value 
)

Sets the user-defined data of given name to the given value.

Does not throw anything if the value is already set. Overrides existing values

Definition at line 42 of file EventExtraInfo.cc.

43{
44 eventExtraInfo[name] = value;
45}

◆ setExtraStringInfo()

void setExtraStringInfo ( const std::string &  name,
const std::string &  value 
)

Sets the user-defined data of given name to the given value.

Does not throw anything if the value is already set. Overrides existing values

Definition at line 92 of file EventExtraInfo.cc.

93{
94 eventExtraStringInfo[name] = value;
95}

Member Data Documentation

◆ eventExtraInfo

std::map<std::string, float> eventExtraInfo
private

map variable names to values.

Definition at line 100 of file EventExtraInfo.h.

◆ eventExtraStringInfo

std::map<std::string, std::string> eventExtraStringInfo
private

map variable names to values for string data type.

Definition at line 102 of file EventExtraInfo.h.


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