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;
16 IO_EPOS::IO_EPOS() : m_trust_mothers_before_daughters(1),
17 m_trust_both_mothers_and_daughters(0),
18 m_print_inconsistency_errors(1),
19 m_trust_beam_particles(
true),
20 m_skip_nucl_frag(
false)
26 ostr <<
"IO_EPOS: reads an event from the FORTRAN EPOS g "
28 <<
" trust_mothers_before_daughters = "
30 <<
" trust_both_mothers_and_daughters = "
32 <<
", print_inconsistency_errors = "
41 <<
"IO_EPOS::fill_next_event error - passed null event."
51 std::vector<HepMC::GenParticle*> hepevt_particle(
53 hepevt_particle[0] = 0;
58 HepMC::GenVertex*
primaryVertex =
new HepMC::GenVertex(HepMC::FourVector(0,0,0,0),0);
59 evt->add_vertex(primaryVertex);
60 if(!evt->signal_process_vertex()) evt->set_signal_process_vertex(primaryVertex);
62 std::set<HepMC::GenVertex*> new_vertices;
67 evt->set_beam_particles( hepevt_particle[1], hepevt_particle[2] );
102 if ( !hepevt_particle[i3]->end_vertex() &&
103 !hepevt_particle[i3]->production_vertex() ) {
104 HepMC::GenVertex* prod_vtx =
new GenVertex();
105 prod_vtx->add_particle_out( hepevt_particle[i3] );
106 evt->add_vertex( prod_vtx );
117 std::vector<HepMC::GenParticle*> index_to_particle(
119 index_to_particle[0]=0;
120 std::map<HepMC::GenParticle*,int> particle_to_index;
121 int particle_counter=0;
122 for ( HepMC::GenEvent::vertex_const_iterator
v = evt->vertices_begin();
123 v != evt->vertices_end(); ++
v ) {
126 for ( HepMC::GenVertex::particles_in_const_iterator
p1
127 = (*v)->particles_in_const_begin();
128 p1 != (*v)->particles_in_const_end(); ++
p1 ) {
130 if ( particle_counter >
132 index_to_particle[particle_counter] = *
p1;
133 particle_to_index[*
p1] = particle_counter;
137 for ( HepMC::GenVertex::particles_out_const_iterator
p2
138 = (*v)->particles_out_const_begin();
139 p2 != (*v)->particles_out_const_end(); ++
p2 ) {
140 if ( !(*p2)->end_vertex() ) {
142 if ( particle_counter >
146 index_to_particle[particle_counter] = *
p2;
147 particle_to_index[*
p2] = particle_counter;
158 for (
int i = 1;
i <= particle_counter; ++
i ) {
161 FourVector
m = index_to_particle[
i]->momentum();
166 if ( index_to_particle[
i]->production_vertex() &&
167 index_to_particle[
i]->production_vertex()->particles_in_size()) {
168 FourVector
p = index_to_particle[
i]->
169 production_vertex()->position();
171 int num_mothers = index_to_particle[
i]->production_vertex()->
174 *(index_to_particle[
i]->
175 production_vertex()->
176 particles_in_const_begin()));
177 int last_mother = first_mother + num_mothers - 1;
178 if ( first_mother == 0 ) last_mother = 0;
189 std::vector<HepMC::GenParticle*>&
195 HepMC::GenVertex* prod_vtx = p->production_vertex();
196 while ( !prod_vtx && mother > 0 ) {
197 prod_vtx = hepevt_particle[mother]->end_vertex();
198 if ( prod_vtx ) prod_vtx->add_particle_out( p );
209 || prod_pos!=FourVector(0,0,0,0)) )
211 prod_vtx =
new HepMC::GenVertex();
212 prod_vtx->add_particle_out( p );
213 evt->add_vertex( prod_vtx );
216 if ( prod_vtx && prod_vtx->position()==FourVector(0,0,0,0) ) {
217 prod_vtx->set_position( prod_pos );
222 while ( prod_vtx && mother > 0 ) {
223 if ( !hepevt_particle[mother]->end_vertex() ) {
225 prod_vtx->add_particle_in( hepevt_particle[mother] );
226 }
else if (hepevt_particle[mother]->end_vertex() != prod_vtx ) {
236 <<
"HepMC::IO_EPOS: inconsistent mother/daugher "
237 <<
"information in EPOS event "
239 <<
". \n I recommend you try "
240 <<
"inspecting the event first with "
241 <<
"\n\tEPOS_Wrapper::check_hepevt_consistency()"
242 <<
"\n This warning can be turned off with the "
243 <<
"IO_EPOS::print_inconsistency_errors switch."
251 (
int i, std::vector<HepMC::GenParticle*>& hepevt_particle, GenEvent* evt )
257 HepMC::GenVertex* end_vtx = p->end_vertex();
258 while ( !end_vtx && daughter > 0 ) {
259 end_vtx = hepevt_particle[daughter]->production_vertex();
260 if ( end_vtx ) end_vtx->add_particle_in( p );
266 end_vtx =
new GenVertex();
267 end_vtx->add_particle_in( p );
268 evt->add_vertex( end_vtx );
274 while ( end_vtx && daughter > 0 ) {
275 if ( !hepevt_particle[daughter]->production_vertex() ) {
277 end_vtx->add_particle_out( hepevt_particle[daughter] );
280 if ( end_vtx->position()==FourVector(0,0,0,0) ) {
287 if ( prod_pos != FourVector(0,0,0,0) ) {
288 end_vtx->set_position( prod_pos );
291 }
else if (hepevt_particle[daughter]->production_vertex()
298 if ( m_print_inconsistency_errors )
std::cerr
299 <<
"HepMC::IO_EPOS: inconsistent mother/daugher "
300 <<
"information in EPOS event "
302 <<
". \n I recommend you try "
303 <<
"inspecting the event first with "
304 <<
"\n\tEPOS_Wrapper::check_hepevt_consistency()"
305 <<
"\n This warning can be turned off with the "
306 <<
"IO_EPOS::print_inconsistency_errors switch."
311 if ( !p->end_vertex() && !p->production_vertex() ) {
313 build_production_vertex( i, hepevt_particle, evt );
327 p->suggest_barcode( index );
333 std::map<HepMC::GenParticle*,int>::const_iterator
iter = m.find(p);
334 if ( iter == m.end() )
return 0;
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
void print(std::ostream &ostr=std::cout) const
static void set_status(int index, int status)
set particle status
bool fill_next_event(HepMC::GenEvent *)
static void set_id(int index, int id)
set particle ID
static double e(int index)
Energy.
void build_end_vertex(int i, std::vector< HepMC::GenParticle * > &hepevt_particle, HepMC::GenEvent *evt)
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
void build_production_vertex(int i, std::vector< HepMC::GenParticle * > &hepevt_particle, HepMC::GenEvent *evt)
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.
static double py(int index)
Y momentum.
bool trust_beam_particles() const
void write_event(const HepMC::GenEvent *)
Abs< T >::type abs(const T &t)
static int event_number()
event number
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
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
static int last_child(int index)
index of last daughter
static int last_parent(int index)
index of last mother
int find_in_map(const std::map< HepMC::GenParticle *, int > &m, HepMC::GenParticle *p) const
static double x(int index)
X Production vertex.
volatile std::atomic< bool > shutdown_flag false
static double px(int index)
X momentum.
static void set_parents(int index, int firstparent, int lastparent)
define parents of a particle