HepMC3 event record library
|
Basic example of use of LHEF for reading and writing LHE files
#include <iomanip>
int main(
int ,
char ** ) {
std::shared_ptr<HEPRUPAttribute> hepr = std::make_shared<HEPRUPAttribute>();
std::shared_ptr<GenRunInfo> runinfo = std::make_shared<GenRunInfo>();
std::vector<std::string> weightnames;
weightnames.push_back("0");
runinfo->
tools().push_back(tool);
}
int neve = 0;
++neve;
std::shared_ptr<HEPEUPAttribute> hepe = std::make_shared<HEPEUPAttribute>();
GenEvent ev(runinfo, Units::GEV, Units::MM);
std::make_shared<IntAttribute>(hepe->
hepeup.
NUP));
GenParticlePtr p1 = std::make_shared<GenParticle>(hepe->
momentum(0),
GenParticlePtr p2 = std::make_shared<GenParticle>(hepe->
momentum(1),
GenVertexPtr vx = std::make_shared<GenVertex>();
vx->add_particle_in(p1);
vx->add_particle_in(p2);
vx->add_particle_out(std::make_shared<GenParticle>
std::vector<double> wts;
std::make_shared<AssociatedParticle>(p2), p1->id());
}
hepr = std::shared_ptr<HEPRUPAttribute>();
while ( true ) {
std::shared_ptr<AssociatedParticle> assoc =
if ( input.
run_info()->weight_names() != weightnames )
return 2;
if ( !hepr ) {
for (
int i = 0, N = hepr->
tags.size(); i < N; ++i )
if ( hepr->
tags[i]->name !=
"init" )
attribute<FloatAttribute>("NPRUP")->value());
}
}
std::shared_ptr<HEPEUPAttribute> hepe =
for (
int i = 0, N = hepe->
tags.size(); i < N; ++i )
if ( hepe->
tags[i]->name !=
"event" &&
hepe->
tags[i]->name !=
"eventgroup" )
}
}
std::ostream & eventComments()
Definition of class GenEvent.
Class for storing data for LHEF run information.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
int event_number() const
Get event number.
GenEvent I/O serialization for structured text files.
Stores event-related information.
void add_vertex(GenVertexPtr v)
Add vertex.
Definition of class GenVertex.
std::vector< Generator > generators
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0)
Add event attribute to event.
LHEF::HEPRUP heprup
The actual HEPRUP object.
Definition of class HEPRUPAttribute and class HEPEUAttribute.
Attribute that holds an Integer implemented as an int.
Definition of class GenParticle.
Attribute that holds an Integer implemented as an int.
GenEvent I/O parsing for structured text files.
void set_event_number(const int &num)
Set event number.
const std::vector< double > & weights() const
Get event weight values as a vector.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
ConstGenParticlePtr associated() const
get a pointer to the associated particle.
Definition of class WriterAscii.
Attribute class allowing eg. a GenParticle to refer to another GenParticle.
std::vector< EventFile > eventfiles
Attribute that holds a real number as a double.
Class for storing data for LHEF run information.
void set_weight_names(const std::vector< std::string > &names)
Set the names of the weights in this run.
std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
std::vector< WeightInfo > weightinfo
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)
Definition of class AssociatedParticle,.
LHEF::HEPEUP hepeup
The actual HEPEUP object.
Definition of class ReaderAscii.
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att)
add an attribute This will overwrite existing attribute if an attribute with the same name is present
std::string weightNameHepMC(int i) const
bool read_event(GenEvent &evt) override
Load event from file.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
int main(int argc, char **argv)
std::vector< std::pair< double, const WeightInfo * > > weights
FourVector momentum(int i) const
Get momentum.
void write_event(const GenEvent &evt) override
Write event to file.
std::shared_ptr< T > attribute(const std::string &name, const int &id=0) const
Get attribute of type T.
std::ostream & headerBlock()
void close() override
Close file stream.