#include <iomanip>
int main(
int ,
char ** ) {
std::shared_ptr<HEPRUPAttribute> hepr = std::make_shared<HEPRUPAttribute>();
std::shared_ptr<GenRunInfo> runinfo = std::make_shared<GenRunInfo>();
runinfo->add_attribute("HEPRUP", hepr);
runinfo->add_attribute("NPRUP",
std::make_shared<FloatAttribute>(hepr->heprup.NPRUP));
std::vector<std::string> weightnames;
weightnames.push_back("0");
for ( int i = 0, N = hepr->heprup.weightinfo.size(); i < N; ++i )
weightnames.push_back(hepr->heprup.weightNameHepMC(i));
runinfo->set_weight_names(weightnames);
for ( int i = 0, N = hepr->heprup.generators.size(); i < N; ++i ) {
GenRunInfo::ToolInfo tool;
tool.name = hepr->heprup.generators[i].name;
tool.version = hepr->heprup.generators[i].version;
tool.description = hepr->heprup.generators[i].contents;
runinfo->tools().push_back(tool);
}
WriterAscii output("LHEF_example.hepmc3", runinfo);
int neve = 0;
++neve;
std::shared_ptr<HEPEUPAttribute> hepe = std::make_shared<HEPEUPAttribute>();
GenEvent ev(runinfo, Units::GEV, Units::MM);
ev.set_event_number(neve);
ev.add_attribute("HEPEUP", hepe);
ev.add_attribute("AlphaQCD",
std:: make_shared<DoubleAttribute>(hepe->hepeup.AQCDUP));
ev.add_attribute("AlphaEM",
std::make_shared<DoubleAttribute>(hepe->hepeup.AQEDUP));
ev.add_attribute("NUP",
std::make_shared<IntAttribute>(hepe->hepeup.NUP));
ev.add_attribute("IDPRUP",
std::make_shared<LongAttribute>(hepe->hepeup.IDPRUP));
GenParticlePtr p1 = std::make_shared<GenParticle>(hepe->momentum(0),
hepe->hepeup.IDUP[0],
hepe->hepeup.ISTUP[0]);
GenParticlePtr p2 = std::make_shared<GenParticle>(hepe->momentum(1),
hepe->hepeup.IDUP[1],
hepe->hepeup.ISTUP[1]);
GenVertexPtr vx = std::make_shared<GenVertex>();
vx->add_particle_in(p1);
vx->add_particle_in(p2);
for ( int i = 2; i < hepe->hepeup.NUP; ++i )
vx->add_particle_out(std::make_shared<GenParticle>
(hepe->momentum(i),
hepe->hepeup.IDUP[i],
hepe->hepeup.ISTUP[i]));
ev.add_vertex(vx);
std::vector<double> wts;
for ( int i = 0, N = hepe->hepeup.weights.size(); i < N; ++i )
wts.push_back(hepe->hepeup.weights[i].first);
ev.weights() = wts;
ev.add_attribute("OtherIncoming",
std::make_shared<AssociatedParticle>(p2), p1->id());
output.write_event(ev);
}
output.close();
ReaderAscii input("LHEF_example.hepmc3");
hepr = std::shared_ptr<HEPRUPAttribute>();
while ( true ) {
GenEvent ev(Units::GEV, Units::MM);
if ( !input.read_event(ev) || ev.event_number() == 0 ) break;
std::shared_ptr<AssociatedParticle> assoc =
ev.attribute<AssociatedParticle>("OtherIncoming", 1);
if ( !assoc || !assoc->associated() ||
assoc->associated() != ev.particles()[1] ) return 3;
if ( input.run_info()->weight_names() != weightnames ) return 2;
if ( !hepr ) {
hepr = ev.attribute<HEPRUPAttribute>("HEPRUP");
for ( int i = 0, N = hepr->tags.size(); i < N; ++i )
if ( hepr->tags[i]->name != "init" )
hepr->heprup.NPRUP =
int(input.run_info()->
attribute<FloatAttribute>("NPRUP")->value());
}
}
std::shared_ptr<HEPEUPAttribute> hepe =
ev.attribute<HEPEUPAttribute>("HEPEUP");
for ( int i = 0, N = hepe->tags.size(); i < N; ++i )
if ( hepe->tags[i]->name != "event" &&
hepe->tags[i]->name != "eventgroup" )
hepe->hepeup.AQCDUP =
ev.attribute<DoubleAttribute>("AlphaQCD")->value();
hepe->hepeup.AQEDUP =
ev.attribute<DoubleAttribute>("AlphaEM")->value();
hepe->hepeup.NUP =
ev.attribute<IntAttribute>("NUP")->value();
hepe->hepeup.IDPRUP =
ev.attribute<LongAttribute>("IDPRUP")->value();
}
}
Definition of class AssociatedParticle,.
Definition of class GenEvent.
Definition of class GenParticle.
Definition of class GenVertex.
Definition of class HEPRUPAttribute and class HEPEUAttribute.
Definition of class ReaderAscii.
Definition of class WriterAscii.
std::vector< EventFile > eventfiles
std::ostream & headerBlock()
std::ostream & eventComments()
int main(int argc, char **argv)
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)