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>();
42 std::vector<std::string> weightnames;
43 weightnames.push_back(
"0");
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",
82 ev.add_attribute(
"AlphaEM",
84 ev.add_attribute(
"NUP",
85 make_shared<IntAttribute>(hepe->
hepeup.
NUP));
86 ev.add_attribute(
"IDPRUP",
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>
108 std::vector<double> wts;
109 for (
int i = 0, N = hepe->
hepeup.
weights.size(); i < N; ++i )
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());
183 writer.hepeup = hepe->
hepeup;
184 writer.hepeup.
heprup = &writer.heprup;
std::string weightNameHepMC(int i) const
Attribute that holds a real number as a double.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
Attribute that holds an Integer implemented as an int.
std::vector< WeightInfo > weightinfo
Smart pointer for HepMC objects.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
Stores event-related information.
void add_attribute(const string &name, const shared_ptr< Attribute > &att)
add an attribute This will overwrite existing attribute if an attribute with the same name is present
Class for storing data for LHEF run information.
GenEvent I/O serialization for structured text files.
std::vector< Generator > generators
Class for storing data for LHEF run information.
LHEF::HEPEUP hepeup
The actual HEPEUP object.
std::vector< std::pair< double, const WeightInfo * > > weights
int main(int argc, char **argv)
Definition of template class SmartPointer.
GenEvent I/O parsing for structured text files.
LHEF::HEPRUP heprup
The actual HEPRUP object.
FourVector momentum(int i) const
Get momentum.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
void set_weight_names(const std::vector< std::string > &names)
Set the names of the weights in this run.