15 ReaderLHEF::ReaderLHEF(
const std::string& filename)
20 ReaderLHEF::ReaderLHEF(std::istream & stream)
26 bool ReaderLHEF::skip(
const int n)
29 for (
int nn=n; nn>0; --nn)
31 if (!read_event(evt))
return false;
38 void ReaderLHEF::init()
43 m_hepr = make_shared<HEPRUPAttribute>();
44 m_hepr->heprup = m_reader->heprup;
52 set_run_info(make_shared<GenRunInfo>());
53 run_info()->add_attribute(
"HEPRUP", m_hepr);
57 run_info()->add_attribute(
"NPRUP",
58 make_shared<FloatAttribute>(m_hepr->heprup.NPRUP));
63 std::vector<std::string> weightnames;
64 weightnames.push_back(
"0");
66 for (
int i = 0, N = m_hepr->heprup.weightinfo.size(); i < N; ++i )
67 weightnames.push_back(m_hepr->heprup.weightNameHepMC(i));
68 run_info()->set_weight_names(weightnames);
72 for (
int i = 0, N = m_hepr->heprup.generators.size(); i < N; ++i )
75 tool.
name = m_hepr->heprup.generators[i].name;
76 tool.
version = m_hepr->heprup.generators[i].version;
77 tool.
description = m_hepr->heprup.generators[i].contents;
78 run_info()->tools().push_back(tool);
82 ReaderLHEF::~ReaderLHEF() {close();};
86 m_failed=!(m_reader->readEvent());
87 if (m_failed)
return m_failed;
92 shared_ptr<HEPEUPAttribute> hepe = make_shared<HEPEUPAttribute>();
93 if ( m_reader->outsideBlock.length() )
95 hepe->hepeup = m_reader->hepeup;
102 make_shared<DoubleAttribute>(hepe->hepeup.AQCDUP));
104 make_shared<DoubleAttribute>(hepe->hepeup.AQEDUP));
106 make_shared<IntAttribute>(hepe->hepeup.NUP));
108 make_shared<LongAttribute>(hepe->hepeup.IDPRUP));
111 GenParticlePtr p1 = make_shared<GenParticle>(hepe->momentum(0),
112 hepe->hepeup.IDUP[0],
113 hepe->hepeup.ISTUP[0]);
114 GenParticlePtr p2 = make_shared<GenParticle>(hepe->momentum(1),
115 hepe->hepeup.IDUP[1],
116 hepe->hepeup.ISTUP[1]);
117 GenVertexPtr vx = make_shared<GenVertex>();
118 vx->add_particle_in(p1);
119 vx->add_particle_in(p2);
121 for (
int i = 2; i < hepe->hepeup.NUP; ++i )
122 vx->add_particle_out(make_shared<GenParticle>
124 hepe->hepeup.IDUP[i],
125 hepe->hepeup.ISTUP[i]));
128 std::vector<double> wts;
129 for (
int i = 0, N = hepe->hepeup.weights.size(); i < N; ++i )
130 wts.push_back(hepe->hepeup.weights[i].first);
135 bool ReaderLHEF::failed() {
return m_failed;}
138 void ReaderLHEF::close() {
delete m_reader; };
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)
void add_vertex(GenVertexPtr v)
Add vertex.
Stores event-related information.
void add_attribute(const string &name, const shared_ptr< Attribute > &att, const int &id=0)
Add event attribute to event.
const std::vector< double > & weights() const
Get event weight values as a vector.
void clear()
Remove contents of this event.
Definition of class ReaderLHEF.
void set_event_number(const int &num)
Set event number.