79 std::cerr <<
"Pythia8ToHepMCA::fill_next_event error - passed null event."
85 double momFac = HepMC::Units::conversion_factor(HepMC::Units::GEV,
86 evt->momentum_unit());
90 int NewBarcode = evt->particles_size();
91 if (ibarcode > -1) NewBarcode = ibarcode;
93 GenVertex* prod_vtx0 =
new GenVertex();
94 prod_vtx0->add_particle_in( rootpart );
95 evt->add_vertex( prod_vtx0 );
99 std::vector<GenParticle*> hepevt_particles( pyev.size() );
100 for (
int i = 2;
i < pyev.size(); ++
i) {
105 FourVector( momFac * pyev[
i].px(), momFac * pyev[
i].py(),
106 momFac * pyev[
i].pz(), momFac * pyev[
i].
e() ),
107 pyev[
i].
id(), pyev[
i].statusHepMC() );
108 if (ibarcode !=0) NewBarcode++;
109 hepevt_particles[
i]->suggest_barcode(NewBarcode);
110 hepevt_particles[
i]->set_generated_mass( momFac * pyev[
i].
m() );
113 int colType = pyev[
i].colType();
114 if (colType == 1 || colType == 2)
115 hepevt_particles[
i]->set_flow(1, pyev[
i].
col());
116 if (colType == -1 || colType == 2)
117 hepevt_particles[
i]->set_flow(2, pyev[
i].acol());
123 for (
int i = 2;
i < pyev.size(); ++
i) {
127 std::vector<int> mothers = pyev[
i].motherList();
129 unsigned int imother = 0;
131 if ( !mothers.empty() ) mother = mothers[imother];
132 GenVertex* prod_vtx = p->production_vertex();
133 while ( !prod_vtx && mother > 0 ) {
135 prod_vtx = rootpart->end_vertex();
137 prod_vtx = hepevt_particles[mother]->end_vertex();
139 if ( prod_vtx ) prod_vtx->add_particle_out( p );
140 mother = ( ++imother < mothers.size() ) ? mothers[imother] : -1;
145 FourVector prod_pos( lenFac * pyev[
i].xProd(), lenFac * pyev[
i].yProd(),
146 lenFac * pyev[
i].zProd(), lenFac * pyev[
i].tProd() );
147 if ( !prod_vtx && ( mothers.size() > 0 || prod_pos != FourVector() ) ) {
148 prod_vtx =
new GenVertex();
149 prod_vtx->add_particle_out( p );
150 evt->add_vertex( prod_vtx );
154 if ( prod_vtx && prod_vtx->position() == FourVector() )
155 prod_vtx->set_position( prod_pos );
160 if ( !mothers.empty() ) mother = mothers[imother];
161 while ( prod_vtx && mother > 0 ) {
165 if(mother == 1) ppp = rootpart;
166 if(mother > 1) ppp = hepevt_particles[mother];
168 if ( !ppp->end_vertex() ) {
169 prod_vtx->add_particle_in( ppp );
176 }
else if (ppp->end_vertex() != prod_vtx ) {
178 <<
"HepMC::Pythia8ToHepMC: inconsistent mother/daugher "
179 <<
"information in Pythia8 event " << std::endl
180 <<
"i = " <<
i <<
" mother = " << mother
181 <<
"\n This warning can be turned off with the "
182 <<
"Pythia8ToHepMC::print_inconsistency switch." << std::endl;
186 mother = ( ++imother < mothers.size() ) ? mothers[imother] : -1;
192 : pyset->flag(
"HadronLevel:all") && pyset->flag(
"HadronLevel:Hadronize");
197 for (
int i = 2;
i < pyev.size(); ++
i) {
198 if ( !hepevt_particles[
i]->end_vertex() &&
199 !hepevt_particles[
i]->production_vertex() ) {
200 std::cerr <<
"hanging particle " <<
i << std::endl;
201 GenVertex* prod_vtx =
new GenVertex();
202 prod_vtx->add_particle_out( hepevt_particles[
i] );
203 evt->add_vertex( prod_vtx );
208 if ( hepevt_particles[i]->pdg_id() == 21 &&
209 !hepevt_particles[i]->end_vertex() ) {
210 std::cerr <<
"gluon without end vertex " << i << std::endl;
213 if (
abs(hepevt_particles[i]->pdg_id()) <= 6 &&
214 !hepevt_particles[i]->end_vertex() ) {
215 std::cerr <<
"quark without end vertex " << i << std::endl;
bool m_free_parton_warnings
Abs< T >::type abs(const T &t)
bool m_print_inconsistency