14 #include "HepMC/GenVertex.h"
15 #include "HepMC/GenParticle.h"
16 #include "HepMC/StreamHelpers.h"
17 #include "HepMC/IO_Exception.h"
23 std::istream & read_vertex( std::istream & is,
24 TempParticleMap & particle_to_end_vertex,
30 std::cerr <<
"StreamHelpers::detail::read_vertex setting badbit." << std::endl;
31 is.clear(std::ios::badbit);
37 std::getline(is,line);
38 std::istringstream iline(line);
43 if ( firstc !=
"V" ) {
44 std::cerr <<
"StreamHelpers::detail::read_vertex invalid line type: "
45 << firstc << std::endl;
46 std::cerr <<
"StreamHelpers::detail::read_vertex setting badbit." << std::endl;
47 is.clear(std::ios::badbit);
51 int identifier =0,
id =0, num_orphans_in =0,
52 num_particles_out = 0, weights_size = 0;
53 double x = 0., y = 0., z = 0., t = 0.;
55 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
57 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
59 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
61 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
63 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
65 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
66 iline >> num_orphans_in ;
67 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
68 iline >> num_particles_out ;
69 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
70 iline >> weights_size;
71 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
72 WeightContainer weights(weights_size);
73 for (
int i1 = 0; i1 < weights_size; ++i1 ) {
75 if(!iline) {
throw IO_Exception(
"read_vertex input stream encounterd invalid data"); }
77 v->set_position( FourVector(x,y,z,t) );
79 v->weights() = weights;
80 v->suggest_barcode( identifier );
85 for (
int i2 = 1; i2 <= num_orphans_in; ++i2 ) {
86 GenParticle* p1 =
new GenParticle( );
87 detail::read_particle(is,particle_to_end_vertex,p1);
89 for (
int i3 = 1; i3 <= num_particles_out; ++i3 ) {
90 GenParticle* p2 =
new GenParticle( );
91 detail::read_particle(is,particle_to_end_vertex,p2);
92 v->add_particle_out( p2 );
98 std::istream & find_event_end( std::istream & is ) {
103 std::string line, firstc;
108 throw IO_Exception(
"input stream encountered invalid data");
110 }
else if( firstc.size() > 1 ) {
111 throw IO_Exception(
"input stream encountered invalid data, now at end of event block");
114 std::getline(is,line);
117 throw IO_Exception(
"input stream encountered invalid data, stream is now corrupt");