16 m_reader = std::make_shared<LHEF::Reader>(filename);
21 m_reader = std::make_shared<LHEF::Reader>(stream);
26 : m_shared_stream(s_stream)
35 for (
int nn = n; nn > 0; --nn)
49 m_hepr = std::make_shared<HEPRUPAttribute>();
56 for (
auto t1:
m_hepr->tags) {
57 if (t1->name !=
"header")
continue;
58 for (
auto t2: t1->tags) {
59 if (t2->name !=
"initrwgt")
continue;
60 for (
auto t3: t2->tags) {
61 if (t3->name !=
"weightgroup")
continue;
62 for (
auto t4: t3->tags)
if (t4->name ==
"weight") nweights++;
78 std::make_shared<FloatAttribute>(
m_hepr->heprup.NPRUP));
84 std::vector<std::string> weightnames;
85 for (
int i = 0, N =
m_hepr->heprup.weightinfo.size(); i < N; ++i ) weightnames.push_back(
m_hepr->heprup.weightNameHepMC(i));
86 if (nweights == 0) nweights=1;
87 for (
size_t i = weightnames.size(); i < nweights; ++i ) weightnames.push_back(std::to_string(i));
88 run_info()->set_weight_names(weightnames);
92 for (
int i = 0, N =
m_hepr->heprup.generators.size(); i < N; ++i )
118 std::shared_ptr<HEPEUPAttribute> hepe = std::make_shared<HEPEUPAttribute>();
119 if (
m_reader->outsideBlock.length() )
123 std::vector<LHEF::HEPEUP*> input;
124 if (
m_reader->hepeup.subevents.size() > 0) input.insert(input.end(), hepe->hepeup.subevents.begin(), hepe->hepeup.subevents.end());
125 else { input.push_back(&
m_reader->hepeup);}
126 int first_group_event =
m_neve;
128 for (
auto ahepeup: input)
132 evt.
add_attribute(
"AlphaQCD", std::make_shared<DoubleAttribute>(ahepeup->AQCDUP));
133 evt.
add_attribute(
"AlphaEM", std::make_shared<DoubleAttribute>(ahepeup->AQEDUP));
134 evt.
add_attribute(
"NUP", std::make_shared<IntAttribute>(ahepeup->NUP));
135 evt.
add_attribute(
"IDPRUP", std::make_shared<LongAttribute>(ahepeup->IDPRUP));
137 std::vector<GenParticlePtr> particles;
138 std::map< std::pair<int, int>, GenVertexPtr> vertices;
139 for (
int i = 0; i < ahepeup->NUP; ++i )
141 FourVector mom((ahepeup->PUP)[i][0], (ahepeup->PUP)[i][1], (ahepeup->PUP)[i][2], (ahepeup->PUP)[i][3]);
142 particles.push_back(std::make_shared<GenParticle>(mom, ahepeup->IDUP[i], ahepeup->ISTUP[i]));
143 if ( i < 2 )
continue;
144 std::pair<int, int> vertex_index(ahepeup->MOTHUP[i].first, ahepeup->MOTHUP[i].second);
145 if (vertices.find(vertex_index) == vertices.end()) vertices[vertex_index] = std::make_shared<GenVertex>();
146 vertices[vertex_index]->add_particle_out(particles.back());
148 for (
auto v: vertices )
150 std::pair<int, int> vertex_index = v.first;
151 GenVertexPtr vertex = v.second;
152 for (
int i = vertex_index.first-1; i < vertex_index.second; ++i)
153 if ( i >= 0 && i < (
int)particles.size())
154 vertex->add_particle_in(particles[i]);
156 std::pair<int, int> vertex_index(0, 0);
157 if (vertices.find(vertex_index) == vertices.end()) vertices[vertex_index] = std::make_shared<GenVertex>();
158 for (
size_t i = 0; i < particles.size(); ++i)
159 if (!particles[i]->end_vertex() && !particles[i]->production_vertex())
161 if ( i < 2 ) vertices[vertex_index]->add_particle_in(particles[i]);
162 else vertices[vertex_index]->add_particle_out(particles[i]);
164 for (
auto v: vertices ) evt.
add_vertex(v.second);
165 if (particles.size() > 1)
167 particles[0]->set_status(4);
168 particles[1]->set_status(4);
174 std::vector<double> wts;
175 for (
int i = 0, N = ahepeup->weights.size(); i < N; ++i )
177 wts.push_back(ahepeup->weights[i].first);
Definition of class ReaderLHEF.
Stores event-related information.
void add_vertex(GenVertexPtr v)
Add vertex.
void set_event_number(const int &num)
Set event number.
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0)
const std::vector< double > & weights() const
Get event weight values as a vector.
void clear()
Remove contents of this event.
void set_beam_particles(GenParticlePtr p1, GenParticlePtr p2)
Set incoming beam particles.
bool failed() override
State.
bool read_event(GenEvent &ev) override
Reading event.
bool skip(const int) override
skip events
std::shared_ptr< HEPRUPAttribute > m_hepr
Holder of attributes.
void close() override
Close.
bool m_failed
State of reader.
std::deque< GenEvent > m_storage
storage used for subevents.
ReaderLHEF(std::istream &)
The ctor to read from stream.
std::shared_ptr< std::istream > m_shared_stream
Holds temporary stream.
std::shared_ptr< LHEF::Reader > m_reader
The actual reader.
std::shared_ptr< GenRunInfo > run_info() const
Get the global GenRunInfo object.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the global GenRunInfo object.
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)