14 using namespace HepMC3;
17 int main(
int ,
char ** ) {
23 shared_ptr<HEPRUPAttribute> hepr = make_shared<HEPRUPAttribute>();
24 hepr->heprup = reader.heprup;
28 hepr->tags = XMLTag::findXMLTags(reader.headerBlock + reader.initComments);
32 shared_ptr<GenRunInfo> runinfo = make_shared<GenRunInfo>();
33 runinfo->add_attribute(
"HEPRUP", hepr);
37 runinfo->add_attribute(
"NPRUP",
38 make_shared<FloatAttribute>(hepr->heprup.NPRUP));
43 std::vector<std::string> weightnames;
44 weightnames.push_back(
"0");
46 for (
int i = 0, N = hepr->heprup.weightinfo.size(); i < N; ++i )
47 weightnames.push_back(hepr->heprup.weightNameHepMC(i));
48 runinfo->set_weight_names(weightnames);
52 for (
int i = 0, N = hepr->heprup.generators.size(); i < N; ++i ) {
54 tool.
name = hepr->heprup.generators[i].name;
55 tool.
version = hepr->heprup.generators[i].version;
56 tool.
description = hepr->heprup.generators[i].contents;
57 runinfo->tools().push_back(tool);
64 while ( reader.readEvent() ) {
71 shared_ptr<HEPEUPAttribute> hepe = make_shared<HEPEUPAttribute>();
72 if ( reader.outsideBlock.length() )
73 hepe->tags = XMLTag::findXMLTags(reader.outsideBlock);
74 hepe->hepeup = reader.hepeup;
75 GenEvent ev(runinfo, Units::GEV, Units::MM);
76 ev.set_event_number(neve);
80 ev.add_attribute(
"HEPEUP", hepe);
81 ev.add_attribute(
"AlphaQCD",
82 make_shared<DoubleAttribute>(hepe->hepeup.AQCDUP));
83 ev.add_attribute(
"AlphaEM",
84 make_shared<DoubleAttribute>(hepe->hepeup.AQEDUP));
85 ev.add_attribute(
"NUP",
86 make_shared<IntAttribute>(hepe->hepeup.NUP));
87 ev.add_attribute(
"IDPRUP",
88 make_shared<LongAttribute>(hepe->hepeup.IDPRUP));
91 GenParticlePtr p1 = make_shared<GenParticle>(hepe->momentum(0),
93 hepe->hepeup.ISTUP[0]);
94 GenParticlePtr p2 = make_shared<GenParticle>(hepe->momentum(1),
96 hepe->hepeup.ISTUP[1]);
97 GenVertexPtr vx = make_shared<GenVertex>();
98 vx->add_particle_in(p1);
99 vx->add_particle_in(p2);
101 for (
int i = 2; i < hepe->hepeup.NUP; ++i )
102 vx->add_particle_out(make_shared<GenParticle>
104 hepe->hepeup.IDUP[i],
105 hepe->hepeup.ISTUP[i]));
109 std::vector<double> wts;
110 for (
int i = 0, N = hepe->hepeup.weights.size(); i < N; ++i )
111 wts.push_back(hepe->hepeup.weights[i].first);
115 ev.add_attribute(
"OtherIncoming",
116 make_shared<AssociatedParticle>(p2), p1->id());
120 output.write_event(ev);
131 hepr = shared_ptr<HEPRUPAttribute>();
138 if ( !input.read_event(ev) || ev.event_number() == 0 )
break;
141 shared_ptr<AssociatedParticle> assoc =
143 if ( !assoc || !assoc->associated() ||
144 assoc->associated() != ev.particles()[1] )
return 3;
147 if ( input.run_info()->weight_names() != weightnames )
return 2;
156 for (
int i = 0, N = hepr->tags.size(); i < N; ++i )
157 if ( hepr->tags[i]->name !=
"init" )
158 hepr->
tags[i]->print(writer.headerBlock());
163 int(input.run_info()->
164 attribute<FloatAttribute>(
"NPRUP")->value());
167 writer.heprup = hepr->heprup;
168 if ( writer.heprup.eventfiles.size() >= 2 ) {
169 writer.heprup.eventfiles[0].filename =
"LHEF_example_1_out.plhe";
170 writer.heprup.eventfiles[1].filename =
"LHEF_example_2_out.plhe";
177 shared_ptr<HEPEUPAttribute> hepe =
182 for (
int i = 0, N = hepe->tags.size(); i < N; ++i )
183 if ( hepe->tags[i]->name !=
"event" &&
184 hepe->tags[i]->name !=
"eventgroup" )
185 hepe->
tags[i]->print(writer.eventComments());
189 hepe->hepeup.AQCDUP =
191 hepe->hepeup.AQEDUP =
195 hepe->hepeup.IDPRUP =
199 writer.hepeup = hepe->hepeup;
200 writer.hepeup.heprup = &writer.heprup;
Definition of class HEPRUPAttribute and class HEPEUAttribute.
GenEvent I/O parsing for structured text files.
Definition of class GenParticle.
Class for storing data for LHEF run information.
Definition of class GenVertex.
Definition of class WriterAscii.
Class for storing data for LHEF run information.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
Stores event-related information.
Attribute that holds a real number as a double.
Definition of class ReaderAscii.
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.
Attribute that holds an Integer implemented as an int.
GenEvent I/O serialization for structured text files.