HepMC3 event record library
Files | Data Structures
Attributes

Files

file  LHEFAttributes.h
 Definition of class HEPRUPAttribute and class HEPEUAttribute.
 

Data Structures

class  AssociatedParticle
 Attribute class allowing eg. a GenParticle to refer to another GenParticle. More...
 
class  IntAttribute
 Attribute that holds an Integer implemented as an int. More...
 
class  Attribute
 Base attribute class. More...
 
class  LongAttribute
 Attribute that holds an Integer implemented as an int. More...
 
class  DoubleAttribute
 Attribute that holds a real number as a double. More...
 
class  FloatAttribute
 Attribute that holds a real number as a float. More...
 
class  StringAttribute
 Attribute that holds a string. More...
 
class  CharAttribute
 Attribute that holds an Chareger implemented as an int. More...
 
class  LongLongAttribute
 Attribute that holds an Integer implemented as an int. More...
 
class  LongDoubleAttribute
 Attribute that holds a real number as a double. More...
 
class  UIntAttribute
 Attribute that holds an unsigned int. More...
 
class  ULongAttribute
 Attribute that holds an unsigned long. More...
 
class  ULongLongAttribute
 Attribute that holds an unsigned long long. More...
 
class  BoolAttribute
 Attribute that holds an Booleger implemented as an int. More...
 
class  VectorCharAttribute
 Attribute that holds a vector of charegers of type char. More...
 
class  VectorFloatAttribute
 Attribute that holds a vector of floategers of type float. More...
 
class  VectorLongDoubleAttribute
 Attribute that holds a vector of long doubleegers of type long double. More...
 
class  VectorLongLongAttribute
 Attribute that holds a vector of long longegers of type long long. More...
 
class  VectorUIntAttribute
 Attribute that holds a vector of unsigned integers of type unsigned int. More...
 
class  VectorULongAttribute
 Attribute that holds a vector of unsigned longegers of type unsigned long. More...
 
class  VectorULongLongAttribute
 Attribute that holds a vector of unsigned long longegers of type unsigned long long. More...
 
class  VectorIntAttribute
 Attribute that holds a vector of integers of type int. More...
 
class  VectorLongIntAttribute
 Attribute that holds a vector of integers of type int. More...
 
class  VectorDoubleAttribute
 Attribute that holds a vector of FPs of type double. More...
 
class  VectorStringAttribute
 Attribute that holds a vector of FPs of type string. More...
 
class  GenCrossSection
 Stores additional information about cross-section. More...
 
class  GenHeavyIon
 Stores additional information about Heavy Ion generator. More...
 
class  GenPdfInfo
 Stores additional information about PDFs. More...
 

Detailed Description

Using Attributes

Attributes can be attached to GenEvent, GenParticle or GenVertex and they can have any format defined by the user (see Writing custom attributes). An attribute is accessed through a shared pointer and identified by its name.

Example of reading an attribute from the event:

shared_ptr<GenPdfInfo> pdf_info = event.attribute<GenPdfInfo>("GenPdfInfo");
if( pdf_info ) pdf_info->print();

Example of adding an attribute to the event:

shared_ptr<GenPdfInfo> pdf_info = make_shared<GenPdfInfo>();
evt.add_attribute("GenPdfInfo",pdf_info);
// Setting values can be done before or after adding it to the event
pdf_info->set(1,2,3.4,5.6,7.8,9.0,1.2,3,4);

Adding and getting attributes of a vertex or particle uses the same principles.

Note
An event (or particle or vertex) can have more than one attribute of the same type distinguished by different names. This might be useful in some applications, however, we strongly encourage to use just one instance named by its class name, as in these examples.

Writing custom attributes

Any class that derives from HepMC::Attribute class can be used as an attribute that can be attached to the event, vertex or particle.

User has to provide two abstract methods from HepMC::Attribute used to parse the class content from/to string.

Example:

struct MyAttribute : public HepMC::Attribute {
double val1; /// First value
int val2; /// Second value
public:
/// Implementation of Attribute::from_string
bool from_string(const string &att) {
val1 = stof( att );
val2 = stol( att.substr( att.find(' ')+1 ) );
return true;
}
/// Implementation of Attribute::to_string
bool to_string(string &att) const {
char buf[64];
sprintf(buf,"%.8e %i",val1,val2);
att = buf;
return true;
}
};
Definition of class Attribute, class IntAttribute and class StringAttribute.

For other examples see attributes provided in the HepMC3 package.


Last update 27 Oct 2020