11 #include "HepMC/CompareGenEvent.h"
12 #include "HepMC/GenEvent.h"
16 bool compareGenEvent( GenEvent* e1, GenEvent* e2)
20 if( e1->event_number() != e2->event_number() ) {
21 std::cerr <<
"compareGenEvent: event numbers differ " << std::endl;
24 if( e1->signal_process_id() != e2->signal_process_id() ) {
25 std::cerr <<
"compareGenEvent: signal process ids differ " << std::endl;
28 if( e1->event_scale() != e2->event_scale() ) {
29 std::cerr <<
"compareGenEvent: event scales differ " << std::endl;
32 if( e1->alphaQCD() != e2->alphaQCD() ) {
33 std::cerr <<
"compareGenEvent: alphaQCD differs " << std::endl;
36 if( e1->alphaQED() != e2->alphaQED() ) {
37 std::cerr <<
"alphaQED differs " << std::endl;
40 if( e1->mpi() != e2->mpi() ) {
41 std::cerr <<
"compareGenEvent: mpi differs " << std::endl;
44 if ( !compareSignalProcessVertex( e1, e2 ) ) {
return false; }
45 if ( !compareBeamParticles( e1, e2 ) ) {
return false; }
46 if ( !compareWeights( e1, e2 ) ) {
return false; }
47 if( e1->random_states() != e2->random_states() ) {
48 std::cerr <<
"compareGenEvent: random states differ " << std::endl;
51 if( e1->heavy_ion() != e2->heavy_ion() ) {
52 std::cerr <<
"compareGenEvent: heavy ions differ " << std::endl;
55 if( e1->pdf_info() != e2->pdf_info() ) {
56 std::cerr <<
"compareGenEvent: pdf info differs " << std::endl;
59 if ( !compareParticles( e1, e2 ) ) {
return false; }
60 if ( !compareVertices( e1, e2 ) ) {
return false; }
64 bool compareSignalProcessVertex( GenEvent* e1, GenEvent* e2 ) {
66 GenVertex* s1 = e1->signal_process_vertex();
67 GenVertex* s2 = e2->signal_process_vertex();
69 if( (*s1) != (*s2) ) {
70 std::cerr <<
"compareSignalProcessVertex: signal process vertices differ " << std::endl;
77 bool compareBeamParticles( GenEvent* e1, GenEvent* e2 ) {
78 GenParticle* e1b1 = e1->beam_particles().first;
79 GenParticle* e1b2 = e1->beam_particles().second;
80 GenParticle* e2b1 = e2->beam_particles().first;
81 GenParticle* e2b2 = e2->beam_particles().second;
82 if( e1b1 && e1b2 && e2b1 && e2b2 ) {
83 if( (*e1b1) == (*e2b1) && (*e1b2) == (*e2b2) ) {
85 std::cerr <<
"compareBeamParticles: beam particles differ " << std::endl;
92 bool compareWeights( GenEvent* e1, GenEvent* e2 ) {
93 if( e1->weights() == e2->weights() )
return true;
94 std::cerr <<
"compareWeights: weight containers differ " << std::endl;
98 bool compareParticles( GenEvent* e1, GenEvent* e2 ) {
99 if( e1->particles_size() != e2->particles_size() ) {
100 std::cerr <<
"compareParticles: number of particles differs " << std::endl;
103 if( e1->particles_size() == 0 ) {
return true; }
104 for ( GenEvent::particle_const_iterator p1 = e1->particles_begin(),
105 p2 = e2->particles_begin();
106 p1 != e1->particles_end(); ++p1, ++p2 ) {
110 if ( **p1 != **p2 ) {
111 std::cerr <<
"compareParticles: particle "
112 << (*p1)->barcode() <<
" differs from "
113 << (*p2)->barcode() << std::endl;
120 bool compareVertices( GenEvent* e1, GenEvent* e2 ) {
121 if( e1->vertices_size() != e2->vertices_size() ) {
122 std::cerr <<
"compareVertices: number of vertices differs " << std::endl;
125 for ( GenEvent::vertex_const_iterator v = e1->vertices_begin();
126 v != e1->vertices_end(); ++v ) {
129 GenVertex* v1 = (*v);
130 GenVertex* v2 = e2->barcode_to_vertex((*v)->barcode());
131 compareVertex( (*v), e2->barcode_to_vertex((*v)->barcode()));
132 if ( (*v1) != (*v2) ) {
133 std::cerr <<
"compareVertices: vertex "
134 << (*v)->barcode() <<
" differs" << std::endl;
141 bool compareVertex( GenVertex* v1, GenVertex* v2 ) {
142 if ( v1->position() != v2->position() ) {
143 std::cerr <<
"compareVertex: position "
144 << v1->barcode() <<
" differs" << std::endl;
148 if ( v1->particles_in_size() != v2->particles_in_size() ) {
149 std::cerr <<
"compareVertex: particles_in_size "
150 << v1->barcode() <<
" differs" << std::endl;
154 if ( v1->particles_in_const_begin() != v1->particles_in_const_end() ) {
156 ia = v1->particles_in_const_begin(),
157 ib = v2->particles_in_const_begin();
158 ia != v1->particles_in_const_end(); ia++, ib++ ){
159 if ( **ia != **ib ) {
160 std::cerr <<
"compareVertex: incoming particle "
161 << v1->barcode() <<
" differs: "
162 << (*ia)->barcode() <<
" " << (*ib)->barcode()
169 if ( v1->particles_out_size() != v2->particles_out_size() ) {
170 std::cerr <<
"compareVertex: particles_out_size "
171 << v1->barcode() <<
" differs" << std::endl;
175 if ( v1->particles_out_const_begin() != v1->particles_out_const_end() ) {
177 ia = v1->particles_out_const_begin(),
178 ib = v2->particles_out_const_begin();
179 ia != v1->particles_out_const_end(); ia++, ib++ ){
180 if ( **ia != **ib ) {
181 std::cerr <<
"compareVertex: outgoing particle "
182 << v1->barcode() <<
" differs: "
183 << (*ia)->barcode() <<
" " << (*ib)->barcode()
std::vector< HepMC::GenParticle * >::const_iterator particles_in_const_iterator
const iterator for incoming particles
std::vector< HepMC::GenParticle * >::const_iterator particles_out_const_iterator
const iterator for outgoing particles