16 int main(
int ,
char ** ) {
22 std::shared_ptr<HEPRUPAttribute> hepr = std::make_shared<HEPRUPAttribute>();
23 hepr->
heprup = reader.heprup;
31 std::shared_ptr<GenRunInfo> runinfo = std::make_shared<GenRunInfo>();
37 std::make_shared<FloatAttribute>(hepr->
heprup.
NPRUP));
42 std::vector<std::string> weightnames;
43 weightnames.push_back(
"0");
56 runinfo->
tools().push_back(tool);
63 while ( reader.readEvent() ) {
70 std::shared_ptr<HEPEUPAttribute> hepe = std::make_shared<HEPEUPAttribute>();
71 if ( reader.outsideBlock.length() )
73 hepe->
hepeup = reader.hepeup;
74 GenEvent ev(runinfo, Units::GEV, Units::MM);
75 ev.set_event_number(neve);
79 ev.add_attribute(
"HEPEUP", hepe);
80 ev.add_attribute(
"AlphaQCD",
81 std:: make_shared<DoubleAttribute>(hepe->
hepeup.
AQCDUP));
82 ev.add_attribute(
"AlphaEM",
84 ev.add_attribute(
"NUP",
85 std::make_shared<IntAttribute>(hepe->
hepeup.
NUP));
86 ev.add_attribute(
"IDPRUP",
90 GenParticlePtr p1 = std::make_shared<GenParticle>(hepe->
momentum(0),
93 GenParticlePtr p2 = std::make_shared<GenParticle>(hepe->
momentum(1),
96 GenVertexPtr vx = std::make_shared<GenVertex>();
97 vx->add_particle_in(p1);
98 vx->add_particle_in(p2);
100 for (
int i = 2; i < hepe->
hepeup.
NUP; ++i )
101 vx->add_particle_out(std::make_shared<GenParticle>
108 std::vector<double> wts;
109 for (
int i = 0, N = hepe->
hepeup.
weights.size(); i < N; ++i )
114 ev.add_attribute(
"OtherIncoming",
115 std::make_shared<AssociatedParticle>(p2), p1->id());
119 output.write_event(ev);
130 hepr = std::shared_ptr<HEPRUPAttribute>();
137 if ( !input.read_event(ev) || ev.event_number() == 0 )
break;
140 std::shared_ptr<AssociatedParticle> assoc =
143 assoc->
associated() != ev.particles()[1] )
return 3;
146 if ( input.run_info()->weight_names() != weightnames )
return 2;
155 for (
int i = 0, N = hepr->
tags.size(); i < N; ++i )
156 if ( hepr->
tags[i]->name !=
"init" )
157 hepr->
tags[i]->print(writer.headerBlock());
162 int(input.run_info()->
163 attribute<FloatAttribute>(
"NPRUP")->value());
166 writer.heprup = hepr->
heprup;
167 if ( writer.heprup.eventfiles.size() >= 2 ) {
168 writer.heprup.
eventfiles[0].filename =
"LHEF_example_1_out.plhe";
169 writer.heprup.eventfiles[1].filename =
"LHEF_example_2_out.plhe";
176 std::shared_ptr<HEPEUPAttribute> hepe =
181 for (
int i = 0, N = hepe->
tags.size(); i < N; ++i )
182 if ( hepe->
tags[i]->name !=
"event" &&
183 hepe->
tags[i]->name !=
"eventgroup" )
184 hepe->
tags[i]->print(writer.eventComments());
198 writer.hepeup = hepe->
hepeup;
199 writer.hepeup.
heprup = &writer.heprup;
Definition of class HEPRUPAttribute and class HEPEUAttribute.
std::string weightNameHepMC(int i) const
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)
void set_weight_names(const std::vector< std::string > &names)
Set the names of the weights in this run.
GenEvent I/O parsing for structured text files.
Definition of class GenParticle.
std::vector< EventFile > eventfiles
Class for storing data for LHEF run information.
Definition of class GenVertex.
Definition of class WriterAscii.
Class for storing data for LHEF run information.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
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
LHEF::HEPRUP heprup
The actual HEPRUP object.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
Stores event-related information.
Attribute that holds a real number as a double.
FourVector momentum(int i) const
Get momentum.
Definition of class ReaderAscii.
std::vector< std::pair< double, const WeightInfo * > > weights
LHEF::HEPEUP hepeup
The actual HEPEUP object.
std::vector< Generator > generators
ConstGenParticlePtr associated() const
get a pointer to the associated particle.
int main(int argc, char **argv)
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
Attribute that holds an Integer implemented as an int.
Definition of class GenEvent.
Definition of class AssociatedParticle,.
Attribute class allowing eg. a GenParticle to refer to another GenParticle.
std::vector< WeightInfo > weightinfo
Attribute that holds an Integer implemented as an int.
GenEvent I/O serialization for structured text files.