5 #include "HepMC/LHEFAttributes.h" 6 #include "HepMC/ReaderAscii.h" 7 #include "HepMC/WriterAscii.h" 8 #include "HepMC/GenEvent.h" 9 #include "HepMC/GenParticle.h" 10 #include "HepMC/GenVertex.h" 13 using namespace HepMC;
16 int main(
int ,
char ** ) {
22 shared_ptr<HEPRUPAttribute> hepr = make_shared<HEPRUPAttribute>();
23 hepr->heprup = reader.heprup;
27 hepr->tags = XMLTag::findXMLTags(reader.headerBlock + reader.initComments);
31 shared_ptr<GenRunInfo> runinfo = make_shared<GenRunInfo>();
32 runinfo->add_attribute(
"HEPRUP", hepr);
36 runinfo->add_attribute(
"NPRUP",
37 make_shared<FloatAttribute>(hepr->heprup.NPRUP));
42 std::vector<std::string> weightnames;
43 weightnames.push_back(
"0");
45 for (
int i = 0, N = hepr->heprup.weightinfo.size(); i < N; ++i )
46 weightnames.push_back(hepr->heprup.weightNameHepMC(i));
47 runinfo->set_weight_names(weightnames);
51 for (
int i = 0, N = hepr->heprup.generators.size(); i < N; ++i ) {
53 tool.
name = hepr->heprup.generators[i].name;
54 tool.
version = hepr->heprup.generators[i].version;
55 tool.
description = hepr->heprup.generators[i].contents;
56 runinfo->tools().push_back(tool);
63 while ( reader.readEvent() ) {
70 shared_ptr<HEPEUPAttribute> hepe = make_shared<HEPEUPAttribute>();
71 if ( reader.outsideBlock.length() )
72 hepe->tags = XMLTag::findXMLTags(reader.outsideBlock);
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 make_shared<DoubleAttribute>(hepe->hepeup.AQCDUP));
82 ev.add_attribute(
"AlphaEM",
83 make_shared<DoubleAttribute>(hepe->hepeup.AQEDUP));
84 ev.add_attribute(
"NUP",
85 make_shared<IntAttribute>(hepe->hepeup.NUP));
86 ev.add_attribute(
"IDPRUP",
87 make_shared<LongAttribute>(hepe->hepeup.IDPRUP));
92 hepe->hepeup.ISTUP[0]);
95 hepe->hepeup.ISTUP[1]);
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(make_shared<GenParticle>
103 hepe->hepeup.IDUP[i],
104 hepe->hepeup.ISTUP[i]));
108 std::vector<double> wts;
109 for (
int i = 0, N = hepe->hepeup.weights.size(); i < N; ++i )
110 wts.push_back(hepe->hepeup.weights[i].first);
114 output.write_event(ev);
125 hepr = shared_ptr<HEPRUPAttribute>();
132 if ( !input.read_event(ev) || ev.event_number() == 0 )
break;
135 if ( input.run_info()->weight_names() != weightnames )
return 2;
144 for (
int i = 0, N = hepr->tags.size(); i < N; ++i )
145 if ( hepr->tags[i]->name !=
"init" )
146 hepr->
tags[i]->print(writer.headerBlock());
151 int(input.run_info()->
152 attribute<FloatAttribute>(
"NPRUP")->value());
155 writer.heprup = hepr->heprup;
161 shared_ptr<HEPEUPAttribute> hepe =
166 for (
int i = 0, N = hepe->tags.size(); i < N; ++i )
167 if ( hepe->tags[i]->name !=
"event" &&
168 hepe->tags[i]->name !=
"eventgroup" )
169 hepe->
tags[i]->print(writer.eventComments());
173 hepe->hepeup.AQCDUP =
175 hepe->hepeup.AQEDUP =
179 hepe->hepeup.IDPRUP =
183 writer.hepeup = hepe->hepeup;
184 writer.hepeup.heprup = &writer.heprup;
Attribute that holds a real number as a double.
Attribute that holds an Integer implemented as an int.
Smart pointer for HepMC objects.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
Stores event-related information.
Class for storing data for LHEF run information.
GenEvent I/O serialization for structured text files.
Class for storing data for LHEF run information.
int main(int argc, char **argv)
Definition of template class SmartPointer.
GenEvent I/O parsing for structured text files.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.