21 #include "HepMC3/Version.h"
28 #include "IsGoodEvent.h"
29 using namespace HepMC3;
30 bool massInfo(
const GenEvent&, std::ostream& );
36 if (ascii_in.failed())
return 1;
45 int num_good_events=0;
46 double x1=0., x2=0., q=0., xf1=0., xf2=0.;
48 while ( !ascii_in.failed() )
50 bool readOK=ascii_in.read_event(evt);
51 if (!readOK)
return 1;
53 if ( icount%50==1 ) std::cout <<
"Processing Event Number " << icount<<
" its # " << evt.
event_number() << std::endl;
54 if ( is_good_event(evt) )
56 if (num_good_events == 0 )
59 x1 = std::min(0.8, 0.07 * icount);
63 if( evt.
beams().size()==2 )
65 GenParticlePtr bp1 = evt.
beams().at(0);
66 GenParticlePtr bp2 = evt.
beams().at(1);
67 xf1 = x1*bp1->momentum().p3mod();
68 xf2 = x2*bp1->momentum().p3mod();
76 std::shared_ptr< GenPdfInfo> pdf = std::make_shared< GenPdfInfo>();
78 pdf->set( 2, 3, x1, x2, q, xf1, xf2, 230, 230);
80 std::shared_ptr< GenHeavyIon> ion = std::make_shared< GenHeavyIon>();
82 ion->set(23,11,12,15,3,5,0,0,0,0.0145,0.0,0.0,0.0,0.23);
84 std::cout <<
"saving Event " << evt.
event_number() << std::endl;
87 std::cout <<
"Weights: ";
88 for ( std::vector<double>::const_iterator w=evt.
weights().begin(); w!=evt.
weights().end(); ++w )
90 std::cout << std::endl;
92 ascii_out.write_event(evt);
99 std::cout << num_good_events <<
" out of " << icount
100 <<
" processed events passed the cuts. Finished." << std::endl;
105 std::ifstream istr(
"testMass1.out" );
108 std::cerr <<
"testMass: cannot open " << std::endl;
112 if (xin.failed())
return 1;
115 if (xout.failed())
return 1;
118 while ( !xin.failed() )
120 bool readOK=xin.read_event(evt);
121 if (!readOK)
return 1;
123 std::cout <<
"reading Event " << evt.
event_number() << std::endl;
126 std::cout <<
"Weights: ";
127 for ( std::vector<double>::const_iterator w=evt.
weights().begin(); w!=evt.
weights().end(); ++w )
129 std::cout << std::endl;
131 xout.write_event(evt);
133 if (! massInfo(evt,std::cout))
return 1;
138 std::cout << ixin <<
" events in the second pass. Finished." << std::endl;
144 bool massInfo(
const GenEvent& e, std::ostream& os )
146 for (ConstGenParticlePtr p: e.
particles()) {
147 double gm = p->generated_mass();
148 double m = p->momentum().m();
150 if( d > 1.0e-4 && gm>1.0e-4)
153 <<
" Particle " << (p)->pdg_id()
154 <<
" generated mass " << gm
155 <<
" mass from momentum " << m
156 <<
" 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.
void add_attribute(const std::string &name, const std::shared_ptr< Attribute > &att, const int &id=0)
Add event attribute to event.
Parser for HepMC2 I/O files.
std::vector< ConstGenParticlePtr > beams() const
Vector of beam particles.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition of class ReaderAscii.
Definition of class WriterAsciiHepMC2.
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...