5 #include "HepMC/GenEvent.h" 12 unsigned int EPOS_Wrapper::s_sizeof_int = 4;
13 unsigned int EPOS_Wrapper::s_sizeof_real =
sizeof(double);
14 unsigned int EPOS_Wrapper::s_max_number_entries = 99900;
17 : m_trust_mothers_before_daughters(
true),
18 m_trust_both_mothers_and_daughters(
false),
19 m_print_inconsistency_errors(
true),
20 m_trust_beam_particles(
true),
21 m_skip_nucl_frag(
false) {}
26 ostr <<
"IO_EPOS: reads an event from the FORTRAN EPOS g " 37 std::cerr <<
"IO_EPOS::fill_next_event error - passed null event." << std::endl;
47 hepevt_particle[0] =
nullptr;
52 HepMC::GenVertex*
primaryVertex =
new HepMC::GenVertex(HepMC::FourVector(0, 0, 0, 0), 0);
54 if (!evt->signal_process_vertex())
57 std::set<HepMC::GenVertex*> new_vertices;
62 evt->set_beam_particles(hepevt_particle[1], hepevt_particle[2]);
95 if (!hepevt_particle[
i3]->end_vertex() && !hepevt_particle[
i3]->production_vertex()) {
96 HepMC::GenVertex* prod_vtx =
new GenVertex();
97 prod_vtx->add_particle_out(hepevt_particle[
i3]);
98 evt->add_vertex(prod_vtx);
111 index_to_particle[0] =
nullptr;
112 std::map<HepMC::GenParticle*, int> particle_to_index;
113 int particle_counter = 0;
114 for (HepMC::GenEvent::vertex_const_iterator
v = evt->vertices_begin();
v != evt->vertices_end(); ++
v) {
117 for (HepMC::GenVertex::particles_in_const_iterator
p1 = (*v)->particles_in_const_begin();
118 p1 != (*v)->particles_in_const_end();
123 index_to_particle[particle_counter] = *
p1;
124 particle_to_index[*
p1] = particle_counter;
128 for (HepMC::GenVertex::particles_out_const_iterator
p2 = (*v)->particles_out_const_begin();
129 p2 != (*v)->particles_out_const_end();
131 if (!(*p2)->end_vertex()) {
136 index_to_particle[particle_counter] = *
p2;
137 particle_to_index[*
p2] = particle_counter;
148 for (
int i = 1;
i <= particle_counter; ++
i) {
151 FourVector
m = index_to_particle[
i]->momentum();
156 if (index_to_particle[
i]->production_vertex() && index_to_particle[
i]->production_vertex()->particles_in_size()) {
157 FourVector
p = index_to_particle[
i]->production_vertex()->position();
159 int num_mothers = index_to_particle[
i]->production_vertex()->particles_in_size();
161 find_in_map(particle_to_index, *(index_to_particle[
i]->production_vertex()->particles_in_const_begin()));
162 int last_mother = first_mother + num_mothers - 1;
163 if (first_mother == 0)
178 HepMC::GenVertex* prod_vtx =
p->production_vertex();
179 while (!prod_vtx && mother > 0) {
180 prod_vtx = hepevt_particle[mother]->end_vertex();
182 prod_vtx->add_particle_out(
p);
192 prod_vtx =
new HepMC::GenVertex();
193 prod_vtx->add_particle_out(
p);
194 evt->add_vertex(prod_vtx);
197 if (prod_vtx && prod_vtx->position() == FourVector(0, 0, 0, 0)) {
198 prod_vtx->set_position(prod_pos);
203 while (prod_vtx && mother > 0) {
204 if (!hepevt_particle[mother]->end_vertex()) {
206 prod_vtx->add_particle_in(hepevt_particle[mother]);
207 }
else if (hepevt_particle[mother]->end_vertex() != prod_vtx) {
217 std::cerr <<
"HepMC::IO_EPOS: inconsistent mother/daugher " 219 <<
"inspecting the event first with " 220 <<
"\n\tEPOS_Wrapper::check_hepevt_consistency()" 221 <<
"\n This warning can be turned off with the " 222 <<
"IO_EPOS::print_inconsistency_errors switch." << std::endl;
234 HepMC::GenVertex* end_vtx =
p->end_vertex();
235 while (!end_vtx && daughter > 0) {
236 end_vtx = hepevt_particle[daughter]->production_vertex();
238 end_vtx->add_particle_in(
p);
245 end_vtx =
new GenVertex();
246 end_vtx->add_particle_in(
p);
247 evt->add_vertex(end_vtx);
253 while (end_vtx && daughter > 0) {
254 if (!hepevt_particle[daughter]->production_vertex()) {
256 end_vtx->add_particle_out(hepevt_particle[daughter]);
259 if (end_vtx->position() == FourVector(0, 0, 0, 0)) {
265 if (prod_pos != FourVector(0, 0, 0, 0)) {
266 end_vtx->set_position(prod_pos);
269 }
else if (hepevt_particle[daughter]->production_vertex() != end_vtx) {
276 std::cerr <<
"HepMC::IO_EPOS: inconsistent mother/daugher " 278 <<
"inspecting the event first with " 279 <<
"\n\tEPOS_Wrapper::check_hepevt_consistency()" 280 <<
"\n This warning can be turned off with the " 281 <<
"IO_EPOS::print_inconsistency_errors switch." << std::endl;
286 if (!
p->end_vertex() && !
p->production_vertex()) {
299 p->suggest_barcode(
index);
304 std::map<HepMC::GenParticle*, int>::const_iterator iter =
m.find(
p);
bool fill_next_event(HepMC::GenEvent *) override
static void set_children(int index, int firstchild, int lastchild)
define children of a particle
static void set_mass(int index, double mass)
set particle mass
HepMC::GenParticle * build_particle(int index)
static double m(int index)
generated mass
static void set_status(int index, int status)
set particle status
void build_end_vertex(int i, std::vector< HepMC::GenParticle *> &hepevt_particle, HepMC::GenEvent *evt)
static void set_id(int index, int id)
set particle ID
static double e(int index)
Energy.
static double t(int index)
production time
static void set_number_entries(int noentries)
set number of entries in EPOS
static int number_parents(int index)
number of parents
static void set_event_number(int evtno)
set event number
static void set_momentum(int index, double px, double py, double pz, double e)
set particle momentum
static int first_child(int index)
index of 1st daughter
static int first_parent(int index)
index of 1st mother
bool m_print_inconsistency_errors
bool m_trust_mothers_before_daughters
bool m_trust_both_mothers_and_daughters
static double y(int index)
Y Production vertex.
void write_event(const HepMC::GenEvent *) override
static double py(int index)
Y momentum.
Abs< T >::type abs(const T &t)
static int event_number()
event number
bool trust_beam_particles() const
static int status(int index)
status code
static void set_position(int index, double x, double y, double z, double t)
set particle production vertex
static int number_entries()
num entries in current evt
int find_in_map(const std::map< HepMC::GenParticle *, int > &m, HepMC::GenParticle *p) const
static double pz(int index)
Z momentum.
static double z(int index)
Z Production vertex.
static int number_children(int index)
number of children
static int id(int index)
PDG particle id.
static int max_number_entries()
size of common block
void build_production_vertex(int i, std::vector< HepMC::GenParticle *> &hepevt_particle, HepMC::GenEvent *evt)
void print(std::ostream &ostr=std::cout) const override
static int last_child(int index)
index of last daughter
static int last_parent(int index)
index of last mother
static double x(int index)
X Production vertex.
static double px(int index)
X momentum.
primaryVertex
hltOfflineBeamSpot for HLTMON
static void set_parents(int index, int firstparent, int lastparent)
define parents of a particle