6 #include "HepMC/IO_HERWIG.h"
7 #include "HepMC/GenEvent.h"
12 IO_HERWIG::IO_HERWIG() : m_trust_mothers_before_daughters(false),
13 m_trust_both_mothers_and_daughters(true),
14 m_print_inconsistency_errors(true),
15 m_no_gaps_in_barcodes(true),
16 m_herwig_to_pdg_id(100,0)
21 m_herwig_to_pdg_id[1] =1;
22 m_herwig_to_pdg_id[2] =2;
23 m_herwig_to_pdg_id[3] =3;
24 m_herwig_to_pdg_id[4] =4;
25 m_herwig_to_pdg_id[5] =5;
26 m_herwig_to_pdg_id[6] =6;
27 m_herwig_to_pdg_id[7] =7;
28 m_herwig_to_pdg_id[8] =8;
30 m_herwig_to_pdg_id[11] =11;
31 m_herwig_to_pdg_id[12] =12;
32 m_herwig_to_pdg_id[13] =13;
33 m_herwig_to_pdg_id[14] =14;
34 m_herwig_to_pdg_id[15] =15;
35 m_herwig_to_pdg_id[16] =16;
37 m_herwig_to_pdg_id[21] =21;
38 m_herwig_to_pdg_id[22] =22;
39 m_herwig_to_pdg_id[23] =23;
40 m_herwig_to_pdg_id[24] =24;
41 m_herwig_to_pdg_id[25] =25;
42 m_herwig_to_pdg_id[26] =51;
44 m_herwig_to_pdg_id[32] =32;
45 m_herwig_to_pdg_id[35] =35;
46 m_herwig_to_pdg_id[36] =36;
47 m_herwig_to_pdg_id[37] =37;
48 m_herwig_to_pdg_id[39] =39;
50 m_herwig_to_pdg_id[40] =40;
52 m_herwig_to_pdg_id[81] =81;
53 m_herwig_to_pdg_id[82] =82;
54 m_herwig_to_pdg_id[83] =83;
55 m_herwig_to_pdg_id[84] =84;
56 m_herwig_to_pdg_id[85] =85;
57 m_herwig_to_pdg_id[86] =86;
58 m_herwig_to_pdg_id[87] =87;
59 m_herwig_to_pdg_id[88] =88;
60 m_herwig_to_pdg_id[89] =89;
61 m_herwig_to_pdg_id[90] =90;
63 m_herwig_to_pdg_id[91] =91;
64 m_herwig_to_pdg_id[92] =92;
65 m_herwig_to_pdg_id[93] =93;
66 m_herwig_to_pdg_id[94] =94;
67 m_herwig_to_pdg_id[95] =95;
68 m_herwig_to_pdg_id[96] =96;
69 m_herwig_to_pdg_id[97] =97;
70 m_herwig_to_pdg_id[98] =9920022;
71 m_herwig_to_pdg_id[99] =9922212;
74 m_no_antiparticles.insert(-21);
75 m_no_antiparticles.insert(-22);
76 m_no_antiparticles.insert(-23);
77 m_no_antiparticles.insert(-25);
78 m_no_antiparticles.insert(-51);
79 m_no_antiparticles.insert(-35);
80 m_no_antiparticles.insert(-36);
83 IO_HERWIG::~IO_HERWIG(){}
86 ostr <<
"IO_HERWIG: reads an event from the FORTRAN Herwig HEPEVT "
88 <<
" trust_mothers_before_daughters = "
89 << m_trust_mothers_before_daughters
90 <<
" trust_both_mothers_and_daughters = "
91 << m_trust_both_mothers_and_daughters
92 <<
" print_inconsistency_errors = "
93 << m_print_inconsistency_errors << std::endl;
103 <<
"IO_HERWIG::fill_next_event error - passed null event."
123 std::vector<GenParticle*> hepevt_particle(
125 hepevt_particle[0] = 0;
129 std::set<GenVertex*> new_vertices;
149 if ( index_121!=0 && index_122!=0 )
break;
151 if ( index_121 && index_122 ) {
161 if ( index_hard!=0 )
break;
164 if ( index_hard!=0) {
191 if ( m_trust_mothers_before_daughters ||
192 m_trust_both_mothers_and_daughters ) {
198 if ( !m_trust_mothers_before_daughters ||
199 m_trust_both_mothers_and_daughters ) {
213 if ( hepevt_particle[i3] && !hepevt_particle[i3]->parent_event()
214 && !hepevt_particle[i3]->pdg_id()
215 && !hepevt_particle[i3]->status() ) {
219 delete hepevt_particle[i3];
220 }
else if ( hepevt_particle[i3] &&
221 !hepevt_particle[i3]->end_vertex() &&
222 !hepevt_particle[i3]->production_vertex() ) {
232 std::vector<GenParticle*>&
242 while ( !prod_vtx && mother > 0 ) {
243 prod_vtx = hepevt_particle[mother]->end_vertex();
268 while ( prod_vtx && mother > 0 ) {
269 if ( !hepevt_particle[mother]->end_vertex() ) {
272 }
else if (hepevt_particle[mother]->end_vertex() != prod_vtx ) {
281 if ( m_print_inconsistency_errors ) {
283 <<
"HepMC::IO_HERWIG: inconsistent mother/daugher "
284 <<
"information in HEPEVT event "
286 <<
". \n I recommend you try "
287 <<
"inspecting the event first with "
288 <<
"\n\tHEPEVT_Wrapper::check_hepevt_consistency()"
289 <<
"\n This warning can be turned off with the "
290 <<
"IO_HERWIG::print_inconsistency_errors switch."
292 hepevt_particle[mother]->print(std::cerr);
294 <<
"problem vertices are: (prod_vtx, mother)" << std::endl;
295 if ( prod_vtx ) prod_vtx->
print(std::cerr);
296 hepevt_particle[mother]->end_vertex()->print(std::cerr);
304 (
int i, std::vector<GenParticle*>& hepevt_particle,
GenEvent* evt )
314 while ( !end_vtx && daughter > 0 ) {
315 end_vtx = hepevt_particle[daughter]->production_vertex();
330 while ( end_vtx && daughter > 0 ) {
331 if ( !hepevt_particle[daughter]->production_vertex() ) {
346 }
else if (hepevt_particle[daughter]->production_vertex()
353 if ( m_print_inconsistency_errors ) std::cerr
354 <<
"HepMC::IO_HERWIG: inconsistent mother/daugher "
355 <<
"information in HEPEVT event "
357 <<
". \n I recommend you try "
358 <<
"inspecting the event first with "
359 <<
"\n\tHEPEVT_Wrapper::check_hepevt_consistency()"
360 <<
"\n This warning can be turned off with the "
361 <<
"IO_HERWIG::print_inconsistency_errors switch."
368 build_production_vertex( i, hepevt_particle, evt );
389 std::map<GenParticle*,int>::const_iterator iter = m.find(p);
390 if ( iter == m.end() )
return 0;
427 int index_collision = 0;
441 if ( index_collision!=0 && index_hard!=0 && index_101!=0 &&
442 index_102!=0 && index_121!=0 && index_122!=0 )
break;
603 bool first_is_acceptable =
true;
604 bool last_is_acceptable =
true;
606 if ( ifirst>=i || ifirst<0 ) first_is_acceptable =
false;
607 if ( ilast>=i || ilast<ifirst || ilast<0 )last_is_acceptable=
false;
608 if ( first_is_acceptable ) {
609 for (
int j = ifirst; j<=ilast; j++ ) {
622 else if (j==ifirst) { first_is_acceptable =
false;
break; }
623 else { last_is_acceptable =
false;
break; }
630 { first_is_acceptable =
true; }
632 if ( !first_is_acceptable ) {
634 }
else if ( !last_is_acceptable ) {
652 bool is_acceptable =
true;
654 if ( ifirst<=i || ifirst<0 ) is_acceptable =
false;
655 if ( ilast<=i || ilast<ifirst || ilast<0 ) is_acceptable =
false;
656 if ( is_acceptable ) {
657 for (
int j = ifirst; j<=ilast; j++ ) {
664 else { is_acceptable =
false; }
726 for (
int i=1; i <=ilast; i++ ) {
761 int i1 = (ida/10)%10;
762 int i2 = (ida/100)%10;
763 int i3 = (ida/1000)%10;
767 int ksusy = (ida/1000000)%10;
769 int kqn = (ida/1000000000)%10;
774 if ( m_print_inconsistency_errors ) {
775 std::cerr <<
"IO_HERWIG::translate_herwig_to_pdg_id " <<
id
776 <<
"nonallowed ion" << std::endl;
779 else if (ida < 100) {
781 hwtran = m_herwig_to_pdg_id[ida];
782 if (
id < 0 ) hwtran *= -1;
785 if ( hwtran>=-99 && hwtran<=-81) hwtran=0;
786 if ( m_no_antiparticles.count(hwtran) ) hwtran=0;
789 else if ( ksusy==1 || ksusy==2 ) { ; }
791 else if ( i1!=0 && i3!=0 && j1==2 ) {;}
793 else if ( i1!=0 && i3!=0 && j1==4 ) {;}
795 else if ( i1!=0 && i2!=0 && i3==0 ) {
798 if ( i1==i2 &&
id<0) hwtran=0;
800 else if ( i2!=0 && i3!=0 && i1==0 ) {;}
808 if (
id==-130 ||
id==-310 ) hwtran=0;
810 if ( hwtran==0 && ida!=0 && m_print_inconsistency_errors ) {
812 <<
"IO_HERWIG::translate_herwig_to_pdg_id HERWIG particle "
813 <<
id <<
" translates to zero." << std::endl;
static void set_children(int index, int firstchild, int lastchild)
define children of a particle
static double y(int index)
Y Production vertex.
static void set_mass(int index, double mass)
set particle mass
static double z(int index)
Z Production vertex.
int translate_herwig_to_pdg_id(int i) const
translate particle ID
int find_in_map(const std::map< GenParticle *, int > &m, GenParticle *p) const
find this particle in the map
static int id(int index)
PDG particle id.
bool fill_next_event(GenEvent *)
get the next event
static int status(int index)
status code
static void set_number_entries(int noentries)
set number of entries in HEPEVT
static int first_parent(int index)
index of 1st mother
void repair_hepevt() const
make the HERWIG HEPEVT common block look like the standard
void print(std::ostream &ostr=std::cout) const
write to ostr
void set_signal_process_vertex(GenVertex *)
set pointer to the vertex containing the signal process
void print(std::ostream &ostr=std::cout) const
print vertex information
static int number_parents(int index)
number of parents
void add_particle_in(GenParticle *inparticle)
add incoming particle
static double x(int index)
X Production vertex.
static int event_number()
event number
static void set_momentum(int index, double px, double py, double pz, double e)
set particle momentum
void set_position(const FourVector &position=FourVector(0, 0, 0, 0))
set vertex position and time
void set_event_number(int eventno)
set event number
GenVertex * production_vertex() const
pointer to the production vertex
static double e(int index)
Energy.
GenVertex contains information about decay vertices.
static int last_parent(int index)
index of last mother
bool suggest_barcode(int the_bar_code)
In general there is no reason to "suggest_barcode".
GenParticle * build_particle(int index)
make a particle
The GenEvent class is the core of HepMC.
void remove_gaps_in_hepevt() const
deal with artifacts of repairing HEPEVT
static double px(int index)
X momentum.
void add_particle_out(GenParticle *outparticle)
add outgoing particle
bool add_vertex(GenVertex *vtx)
adds to evt and adopts
void build_end_vertex(int i, std::vector< GenParticle * > &hepevt_particle, GenEvent *evt)
make a decay vertex
static double t(int index)
production time
static int last_child(int index)
index of last daughter
bool set_beam_particles(GenParticle *, GenParticle *)
set incoming beam particles
static void set_parents(int index, int firstparent, int lastparent)
define parents of a particle
static void set_status(int index, int status)
set particle status
static int number_entries()
num entries in current evt
const FourVector & position() const
vertex position and time
static int first_child(int index)
index of 1st daughter
FourVector is a simple representation of a physics 4 vector.
static double py(int index)
Y momentum.
GenVertex * end_vertex() const
pointer to the decay vertex
static double pz(int index)
Z momentum.
void setGeneratedMass(const double &m)
setGeneratedMass() is included for backwards compatibility with CLHEP HepMC
void build_production_vertex(int i, std::vector< GenParticle * > &hepevt_particle, GenEvent *evt)
make a production vertex
void zero_hepevt_entry(int i) const
zero out a HEPEVT pseudo particle
static int max_number_entries()
size of common block
static int number_children(int index)
number of children
static void set_id(int index, int id)
set particle ID
The GenParticle class contains information about generated particles.
static double m(int index)
generated mass
static void set_position(int index, double x, double y, double z, double t)
set particle production vertex