19 #include "HepMC3/Version.h"
26 #include "IsGoodEvent.h"
27 using namespace HepMC3;
28 bool massInfo(
const GenEvent&, std::ostream& );
34 if (ascii_in.failed())
return 1;
43 int num_good_events=0;
44 double x1=0., x2=0., q=0., xf1=0., xf2=0.;
46 while ( !ascii_in.failed() )
48 bool readOK=ascii_in.read_event(evt);
49 if (!readOK)
return 1;
51 if ( icount%50==1 ) std::cout <<
"Processing Event Number " << icount<<
" its # " << evt.
event_number() << std::endl;
52 if ( is_good_event(evt) )
54 if (num_good_events == 0 )
57 x1 = std::min(0.8, 0.07 * icount);
61 if( evt.
beams().size()==2 )
63 GenParticlePtr bp1 = evt.
beams().at(0);
64 GenParticlePtr bp2 = evt.
beams().at(1);
65 xf1 = x1*bp1->momentum().p3mod();
66 xf2 = x2*bp1->momentum().p3mod();
74 std::shared_ptr< GenPdfInfo> pdf = std::make_shared< GenPdfInfo>();
76 pdf->set( 2, 3, x1, x2, q, xf1, xf2, 230, 230);
78 std::shared_ptr< GenHeavyIon> ion = std::make_shared< GenHeavyIon>();
80 ion->set(23,11,12,15,3,5,0,0,0,0.0145,0.0,0.0,0.0,0.23);
82 std::cout <<
"saving Event " << evt.
event_number() << std::endl;
85 std::cout <<
"Weights: ";
86 for ( std::vector<double>::const_iterator w=evt.
weights().begin(); w!=evt.
weights().end(); ++w )
88 std::cout << std::endl;
90 ascii_out.write_event(evt);
97 std::cout << num_good_events <<
" out of " << icount
98 <<
" processed events passed the cuts. Finished." << std::endl;
103 std::ifstream istr(
"testMass1.out" );
106 std::cerr <<
"testMass: cannot open " << std::endl;
110 if (xin.failed())
return 1;
113 if (xout.failed())
return 1;
116 while ( !xin.failed() )
118 bool readOK=xin.read_event(evt);
119 if (!readOK)
return 1;
121 std::cout <<
"reading Event " << evt.
event_number() << std::endl;
124 std::cout <<
"Weights: ";
125 for ( std::vector<double>::const_iterator w=evt.
weights().begin(); w!=evt.
weights().end(); ++w )
127 std::cout << std::endl;
129 xout.write_event(evt);
131 if (! massInfo(evt,std::cout))
return 1;
136 std::cout << ixin <<
" events in the second pass. Finished." << std::endl;
142 bool massInfo(
const GenEvent& e, std::ostream& os )
144 for (ConstGenParticlePtr p: e.
particles()) {
145 double gm = p->generated_mass();
146 double m = p->momentum().m();
148 if( d > 1.0e-4 && gm>1.0e-4)
151 <<
" Particle " << (p)->pdg_id()
152 <<
" generated mass " << gm
153 <<
" mass from momentum " << m
154 <<
" difference " << d << std::endl;
GenEvent I/O serialization for structured text files.
Definition of class GenParticle.
Definition of attribute class GenHeavyIon.
Definition of class WriterAscii.
std::string version()
Get the HepMC library version string.
int event_number() const
Get event number.
Parser for HepMC2 I/O files.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition of class ReaderAscii.
std::vector< ConstGenParticlePtr > beams() const
Vector of beam particles.
Definition of class WriterAsciiHepMC2.
void add_attribute(const string &name, const shared_ptr< Attribute > &att, const int &id=0)
Add event attribute to event.
Definition of event attribute class GenPdfInfo.
int main(int argc, char **argv)
const std::vector< double > & weights() const
Get event weight values as a vector.
Definition of class GenEvent.
void clear()
Remove contents of this event.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you'd expect. If foo is a valid Feature...