HepMC3 event record library
|
Go to the documentation of this file.
6 #ifndef HEPMC3_ATTRIBUTE_H
7 #define HEPMC3_ATTRIBUTE_H
29 #include "HepMC3/GenParticle_fwd.h"
30 #include "HepMC3/GenVertex_fwd.h"
96 virtual bool to_string(
string &att)
const = 0;
120 return std::const_pointer_cast<GenParticle>(
m_particle);
130 return std::const_pointer_cast<GenVertex>(
m_vertex);
169 m_val = atoi( att.c_str() );
175 att = std::to_string(
m_val);
210 m_val = atol( att.c_str() );
216 att = std::to_string(
m_val);
253 m_val = atof( att.c_str() );
259 std::ostringstream oss;
260 oss << std::setprecision(std::numeric_limits<double>::digits10)
298 m_val = float(atof( att.c_str() ));
304 std::ostringstream oss;
305 oss << std::setprecision(std::numeric_limits<float>::digits10)
401 att = std::to_string(
m_val);
436 m_val = atoll( att.c_str() );
442 att = std::to_string(
m_val);
479 m_val = strtold( att.c_str(),NULL);
485 std::ostringstream oss;
486 oss << std::setprecision(std::numeric_limits<long double>::digits10)
526 m_val = strtoul(att.c_str(), NULL, 0);
532 att = std::to_string(
m_val);
569 m_val = strtoul(att.c_str(), NULL, 0);
575 att = std::to_string(
m_val);
611 m_val = strtoull(att.c_str(), NULL, 0);
617 att = std::to_string(
m_val);
651 if (att.size()!=1)
return false;
652 if(att==std::string(
"1")) {
m_val =
true;
return true;}
653 if(att==std::string(
"0")) {
m_val =
false;
return true;}
659 att = std::to_string(
m_val);
696 std::stringstream datastream(att);
697 while (datastream >> datafoo)
m_val.push_back(datafoo);
704 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
741 std::stringstream datastream(att);
742 while (datastream >> datafoo)
m_val.push_back(datafoo);
749 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
787 std::stringstream datastream(att);
788 while (datastream >> datafoo)
m_val.push_back(datafoo);
795 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
800 std::vector<long double>
value()
const {
834 std::stringstream datastream(att);
835 while (datastream >> datafoo)
m_val.push_back(datafoo);
842 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
847 std::vector<long long>
value()
const {
877 unsigned int datafoo;
879 std::stringstream datastream(att);
880 while (datastream >> datafoo)
m_val.push_back(datafoo);
887 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
892 std::vector<unsigned int>
value()
const {
922 unsigned long datafoo;
924 std::stringstream datastream(att);
925 while (datastream >> datafoo)
m_val.push_back(datafoo);
932 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
937 std::vector<unsigned long>
value()
const {
968 unsigned long long datafoo;
970 std::stringstream datastream(att);
971 while (datastream >> datafoo)
m_val.push_back(datafoo);
978 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
983 std::vector<unsigned long long>
value()
const {
988 void set_value(
const std::vector<unsigned long long>& i) {
993 std::vector<unsigned long long>
m_val;
1015 std::stringstream datastream(att);
1016 while (datastream >> datafoo)
m_val.push_back(datafoo);
1023 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1060 std::stringstream datastream(att);
1061 while (datastream >> datafoo)
m_val.push_back(datafoo);
1068 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1105 std::stringstream datastream(att);
1106 while (datastream >> datafoo)
m_val.push_back(datafoo);
1113 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=std::to_string(a);}
1149 std::string datafoo;
1151 size_t posb=att.find_first_not_of(
' ');
1153 while (posb!=std::string::npos) { pose=att.find_first_not_of(
' ',posb+1);
m_val.push_back(att.substr(posb,pose)); posb=att.find_first_not_of(
' ',pose+1);}
1160 for (
auto a:
m_val) {
if (att.length()) att+=
" "; att+=a;}
bool to_string(string &att) const override
Implementation of Attribute::to_string.
std::vector< float > m_val
Attribute value.
DoubleAttribute()
Default constructor.
std::vector< unsigned long long > value() const
get the value associated to this Attribute.
LongLongAttribute()
Default constructor.
virtual bool init()
Optionally initialize the attribute after from_string.
void set_value(const std::vector< char > &i)
set the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
VectorDoubleAttribute()
Default constructor.
Attribute that holds a string.
LongAttribute(long val)
Constructor initializing attribute value.
unsigned long long value() const
get the value associated to this Attribute.
ULongLongAttribute()
Default constructor.
std::vector< long double > m_val
Attribute value.
BoolAttribute()
Default constructor.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_value(const std::vector< string > &i)
set the value associated to this Attribute.
char m_val
Attribute value.
Attribute that holds a vector of floategers of type float.
FloatAttribute(float val)
Constructor initializing attribute value.
std::vector< char > m_val
Attribute value.
Stores event-related information.
VectorFloatAttribute()
Default constructor.
Attribute that holds a real number as a double.
float value() const
get the value associated to this Attribute.
void set_value(const string &s)
set the value associated to this Attribute.
IntAttribute(int val)
Constructor initializing attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
void set_value(const double &d)
set the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
char value() const
get the value associated to this Attribute.
long long m_val
Attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
double value() const
get the value associated to this Attribute.
IntAttribute()
Default constructor.
bool m_val
Attribute value.
unsigned long m_val
Attribute value.
long m_val
Attribute value.
std::vector< char > value() const
get the value associated to this Attribute.
void set_value(const char &i)
set the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
double m_val
Attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
long long value() const
get the value associated to this Attribute.
std::vector< string > m_val
Attribute value.
unsigned long value() const
get the value associated to this Attribute.
std::vector< long int > m_val
Attribute value.
std::vector< double > value() const
get the value associated to this Attribute.
LongDoubleAttribute(long double val)
Constructor initializing attribute value.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_value(const unsigned long long &i)
set the value associated to this Attribute.
Attribute that holds an Integer implemented as an int.
std::vector< int > m_val
Attribute value.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
std::vector< float > value() const
get the value associated to this Attribute.
VectorLongIntAttribute()
Default constructor.
unsigned int m_val
Attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
CharAttribute()
Default constructor.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
bool is_parsed() const
Check if this attribute is parsed.
VectorUIntAttribute()
Default constructor.
long value() const
get the value associated to this Attribute.
Attribute that holds an Integer implemented as an int.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
VectorFloatAttribute(std::vector< float > val)
Constructor initializing attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
Attribute that holds an Chareger implemented as an int.
void set_value(const std::vector< unsigned long > &i)
set the value associated to this Attribute.
void set_value(const std::vector< long long > &i)
set the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
std::vector< int > value() const
get the value associated to this Attribute.
VectorLongDoubleAttribute()
Default constructor.
GenParticlePtr m_particle
controlling GenEvent object.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
GenParticlePtr particle()
VectorIntAttribute(std::vector< int > val)
Constructor initializing attribute value.
ULongAttribute()
Default constructor.
long double value() const
get the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
Attribute that holds an unsigned long.
VectorULongLongAttribute()
Default constructor.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
virtual bool init(const GenRunInfo &)
Optionally initialize the attribute after from_string.
UIntAttribute(unsigned int val)
Constructor initializing attribute value.
VectorULongLongAttribute(std::vector< unsigned long long > val)
Constructor initializing attribute value.
VectorULongAttribute()
Default constructor.
void set_value(const std::vector< long double > &i)
set the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
std::vector< unsigned int > m_val
Attribute value.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
const GenEvent * event() const
virtual bool to_string(string &att) const =0
Fill string from class content.
void set_value(const unsigned int &i)
set the value associated to this Attribute.
Attribute that holds a vector of charegers of type char.
StringAttribute()
Default constructor - empty string.
std::vector< string > value() const
get the value associated to this Attribute.
Attribute(const string &st)
Protected constructor that allows to set string.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
std::vector< unsigned long long > m_val
Attribute value.
VectorUIntAttribute(std::vector< unsigned int > val)
Constructor initializing attribute value.
std::vector< long double > value() const
get the value associated to this Attribute.
std::vector< long long > m_val
Attribute value.
std::vector< long long > value() const
get the value associated to this Attribute.
void set_value(const long &l)
set the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
ConstGenVertexPtr vertex() const
void set_value(const int &i)
set the value associated to this Attribute.
std::vector< unsigned long > m_val
Attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
VectorCharAttribute()
Default constructor.
LongLongAttribute(long long val)
Constructor initializing attribute value.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
std::vector< long int > value() const
get the value associated to this Attribute.
VectorLongLongAttribute()
Default constructor.
Attribute that holds a real number as a double.
Attribute that holds a vector of integers of type int.
std::vector< double > m_val
Attribute value.
void set_value(const long long &l)
set the value associated to this Attribute.
std::vector< unsigned long > value() const
get the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
VectorULongAttribute(std::vector< unsigned long > val)
Constructor initializing attribute value.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
VectorStringAttribute()
Default constructor.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
bool value() const
get the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
string value() const
get the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_value(const std::vector< unsigned long long > &i)
set the value associated to this Attribute.
Attribute that holds an unsigned int.
Attribute that holds a vector of long longegers of type long long.
BoolAttribute(bool val)
Constructor initializing attribute value.
std::vector< unsigned int > value() const
get the value associated to this Attribute.
GenVertexPtr m_vertex
Vertex to which assigned.
VectorDoubleAttribute(std::vector< double > val)
Constructor initializing attribute value.
Attribute that holds an unsigned long long.
void set_value(const std::vector< long int > &i)
set the value associated to this Attribute.
VectorStringAttribute(std::vector< string > val)
Constructor initializing attribute value.
ULongLongAttribute(unsigned long long val)
Constructor initializing attribute value.
void set_is_parsed(bool flag)
Set is_parsed flag.
Forward declaration of GenParticle.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
VectorCharAttribute(std::vector< char > val)
Constructor initializing attribute value.
float m_val
Attribute value.
Attribute that holds a vector of unsigned longegers of type unsigned long.
DoubleAttribute(double val)
Constructor initializing attribute value.
VectorIntAttribute()
Default constructor.
Attribute that holds an Integer implemented as an int.
Attribute that holds an Booleger implemented as an int.
ULongAttribute(unsigned long val)
Constructor initializing attribute value.
void set_value(const std::vector< float > &i)
set the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_value(const long double &d)
set the value associated to this Attribute.
long double m_val
Attribute value.
void set_value(const std::vector< unsigned int > &i)
set the value associated to this Attribute.
FloatAttribute()
Default constructor.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
VectorLongLongAttribute(std::vector< long long > val)
Constructor initializing attribute value.
Attribute that holds a real number as a float.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_value(const std::vector< int > &i)
set the value associated to this Attribute.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
void set_unparsed_string(const string &st)
Set unparsed string.
VectorLongIntAttribute(std::vector< long int > val)
Constructor initializing attribute value.
void set_value(const unsigned long &i)
set the value associated to this Attribute.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
ConstGenParticlePtr particle() const
StringAttribute(const string &st)
String-based constructor.
Attribute that holds a vector of long doubleegers of type long double.
string m_string
Raw (unparsed) string.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
unsigned long long m_val
Attribute value.
int m_val
Attribute value.
Attribute that holds a vector of unsigned long longegers of type unsigned long long.
void set_value(const std::vector< double > &i)
set the value associated to this Attribute.
VectorLongDoubleAttribute(std::vector< long double > val)
Constructor initializing attribute value.
const string & unparsed_string() const
Get unparsed string.
bool from_string(const string &att) override
Implementation of Attribute::from_string.
virtual bool from_string(const string &att)=0
Fill class content from string.
int value() const
get the value associated to this Attribute.
LongAttribute()
Default constructor.
UIntAttribute()
Default constructor.
Attribute()
Default constructor.
void set_value(const bool &i)
set the value associated to this Attribute.
LongDoubleAttribute()
Default constructor.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
bool to_string(string &att) const override
Implementation of Attribute::to_string.
Attribute that holds a vector of unsigned integers of type unsigned int.
void set_value(const float &f)
set the value associated to this Attribute.
bool m_is_parsed
Is this attribute parsed?
bool from_string(const string &att) override
Implementation of Attribute::from_string.
CharAttribute(char val)
Constructor initializing attribute value.
virtual ~Attribute()
Virtual destructor.
unsigned int value() const
get the value associated to this Attribute.
Stores run-related information.