18 os <<
"--------------------------------" << std::endl;
19 os <<
"--------- EVENT CONTENT --------" << std::endl;
20 os <<
"--------------------------------" << std::endl;
23 os <<
"Weights (" <<
event.weights().size() <<
"): " << std::endl;
24 for (std::vector<double>::const_iterator w = event.
weights().begin(); w != event.
weights().end(); ++w )
28 os <<
"Attributes:" << std::endl;
31 for (
auto vt2: vt1.second) {
32 os << vt2.first <<
": " << vt1.first << std::endl;
36 os <<
"GenParticlePtr (" <<
event.particles().size() <<
")" << std::endl;
38 for (ConstGenParticlePtr p: event.
particles()) {
42 os <<
"GenVertexPtr (" <<
event.vertices().size() <<
")" << std::endl;
43 for ( ConstGenVertexPtr v: event.
vertices() ) {
47 os <<
"-----------------------------" << std::endl;
52 std::ios_base::fmtflags orig = os.flags();
53 std::streamsize prec = os.precision();
56 os.precision(precision);
58 os <<
"________________________________________________________________________" << std::endl;
59 os <<
"GenEvent: #" <<
event.event_number() << std::endl;
62 os <<
" Entries in this event: " <<
event.vertices().size() <<
" vertices, "
63 <<
event.particles().size() <<
" particles, "
64 <<
event.weights().size() <<
" weights." << std::endl;
67 os <<
" Position offset: " << pos.
x() <<
", " << pos.
y() <<
", " << pos.
z() <<
", " << pos.
t() << std::endl;
70 os <<
" GenParticle Legend" << std::endl;
72 <<
"( px, py, pz, E )"
73 <<
" Stat ProdVtx" << std::endl;
74 os <<
"________________________________________________________________________" << std::endl;
77 for (ConstGenVertexPtr v: event.
vertices()) {
84 os <<
"________________________________________________________________________" << std::endl;
89 std::ios_base::fmtflags orig = os.flags();
90 std::streamsize prec = os.precision();
93 os.precision(precision);
95 os <<
"________________________________________________________________________" << std::endl;
96 os <<
"GenRunInfo:" << std::endl;
100 for (
auto n: names) os << n;
101 os <<
" )" << std::endl;
103 os <<
" Tools: " << std::endl;
105 for (
auto t: ri.
tools()) {
108 os <<
"Attributes:" << std::endl;
111 if ( !att.second->to_string(st) ) {
112 HEPMC3_WARNING(
"Print::listing: problem serializing attribute: " << att.first)
114 else { os << att.first <<
" " << att.second->to_string(st);}
121 os <<
"________________________________________________________________________" << std::endl;
125 if (!v) { os <<
"Vtx: Empty vertex" << std::endl;
return;}
128 os << v->id() <<
" stat: ";
134 os <<
" (X,cT): " << pos.
x() <<
" " << pos.
y() <<
" " << pos.
z() <<
" " << pos.
t();
136 else os <<
" (X,cT): 0";
140 bool printed_header =
false;
143 for (ConstGenParticlePtr p: v->particles_in()) {
144 if ( !printed_header ) {
146 printed_header =
true;
153 printed_header =
false;
156 for (ConstGenParticlePtr p: v->particles_out()) {
157 if ( !printed_header ) {
159 printed_header =
true;
168 if (!p) { os <<
" Empty particle" << std::endl;
return;}
173 os << p->pid() <<
" ";
175 os.setf(std::ios::scientific, std::ios::floatfield);
176 os.setf(std::ios_base::showpos);
181 os << momentum.
px() <<
",";
183 os << momentum.
py() <<
",";
185 os << momentum.
pz() <<
",";
187 os << momentum.
e() <<
" ";
188 os.setf(std::ios::fmtflags(0), std::ios::floatfield);
189 os.unsetf(std::ios_base::showpos);
193 ConstGenVertexPtr prod = p->production_vertex();
203 os <<
"GenEvent: #" <<
event.event_number();
205 os <<
" " << s <<
"=" <<
event.attribute_as_string(s);
209 os <<
"GenRunInfo: Number of tools:" << RunInfo.
tools().size();
218void Print::line(std::ostream& os, ConstGenVertexPtr v,
bool attributes) {
219 if (!v) { os <<
"GenVertex: Empty" << std::endl;
return;}
220 os <<
"GenVertex: " << v->id() <<
" stat: ";
223 os <<
" in: " << v->particles_in().size();
225 os <<
" out: " << v->particles_out().size();
228 os <<
" has_set_position: ";
229 if ( v->has_set_position() ) os <<
"true";
232 os <<
" (X,cT): " << pos.
x() <<
", " <<pos.
y() <<
", " << pos.
z() <<
", " << pos.
t();
235 std::vector<std::string> names = v->attribute_names();
237 os <<
" " << ss <<
"=" << (*v).attribute_as_string(ss);
242 os <<
"FourVector: ";
244 std::ios_base::fmtflags orig = os.flags();
245 os.setf(std::ios::scientific, std::ios::floatfield);
246 os.setf(std::ios_base::showpos);
247 std::streamsize prec = os.precision();
250 os <<
" (P,E)=" << p.
x()
260void Print::line(std::ostream& os, ConstGenParticlePtr p,
bool attributes) {
261 if (!p) { os <<
"GenParticle: Empty" << std::endl;
return;}
262 os <<
"GenParticle: ";
264 os << p->id() <<
" PDGID: ";
269 std::ios_base::fmtflags orig = os.flags();
271 os.setf(std::ios::scientific, std::ios::floatfield);
272 os.setf(std::ios_base::showpos);
273 std::streamsize prec = os.precision();
280 os <<
" (P,E)=" << momentum.
px()
281 <<
"," << momentum.
py()
282 <<
"," << momentum.
pz()
283 <<
"," << momentum.
e();
289 ConstGenVertexPtr prod = p->production_vertex();
290 ConstGenVertexPtr end = p->end_vertex();
291 int prod_vtx_id = (prod) ? prod->id() : 0;
292 int end_vtx_id = (end) ? end->id() : 0;
294 os <<
" Stat: " << p->status()
295 <<
" PV: " << prod_vtx_id
296 <<
" EV: " << end_vtx_id
297 <<
" Attr: " << (*p).attribute_names().size();
301 std::vector<std::string> names = p->attribute_names();
303 os <<
" " << ss <<
"=" << (*p).attribute_as_string(ss);
307void Print::line(std::ostream& os, std::shared_ptr<GenCrossSection> &cs) {
308 if (!cs) {os <<
" GenCrossSection: Empty";
return;}
309 os <<
" GenCrossSection: " << cs->xsec(0)
310 <<
" " << cs->xsec_err(0)
311 <<
" " << cs->get_accepted_events()
312 <<
" " << cs->get_attempted_events();
315void Print::line(std::ostream& os, std::shared_ptr<GenHeavyIon> &hi) {
316 if (!hi) {os <<
" GenHeavyIon: Empty";
return;}
317 os <<
" GenHeavyIon: " << hi->Ncoll_hard
318 <<
" " << hi->Npart_proj
319 <<
" " << hi->Npart_targ
321 <<
" " << hi->spectator_neutrons
322 <<
" " << hi->spectator_protons
323 <<
" " << hi->N_Nwounded_collisions
324 <<
" " << hi->Nwounded_N_collisions
325 <<
" " << hi->Nwounded_Nwounded_collisions
326 <<
" " << hi->impact_parameter
327 <<
" " << hi->event_plane_angle
328 <<
" " << hi->eccentricity
329 <<
" " << hi->sigma_inel_NN;
332void Print::line(std::ostream& os, std::shared_ptr<GenPdfInfo> &pi) {
333 if (!pi) {os <<
" GenPdfInfo: Empty";
return;}
334 os <<
" GenPdfInfo: " << pi->parton_id[0]
335 <<
" " << pi->parton_id[1]
341 <<
" " << pi->pdf_id[0]
342 <<
" " << pi->pdf_id[1];
Definition of class Attribute, class IntAttribute and class StringAttribute.
#define HEPMC3_WARNING(MESSAGE)
Macro for printing HEPMC3_HEPMC3_WARNING messages.
Definition of static class Print.
double e() const
Energy component of momentum.
double pz() const
z-component of momentum
double t() const
Time component of position/displacement.
bool is_zero() const
Check if the length of this vertex is zero.
double px() const
x-component of momentum
double py() const
y-component of momentum
double x() const
x-component of position/displacement
double y() const
y-component of position/displacement
double z() const
z-component of position/displacement
Stores event-related information.
std::vector< std::string > attribute_names(const int &id=0) const
Get list of attribute names.
const std::vector< ConstGenVertexPtr > & vertices() const
Get list of vertices (const)
const Units::MomentumUnit & momentum_unit() const
Get momentum unit.
const Units::LengthUnit & length_unit() const
Get length unit.
std::map< std::string, std::map< int, std::shared_ptr< Attribute > > > attributes() const
Get a copy of the list of attributes.
const std::vector< double > & weights() const
Get event weight values as a vector.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
Stores run-related information.
std::map< std::string, std::shared_ptr< Attribute > > attributes() const
Get a copy of the list of attributes.
std::vector< std::string > attribute_names() const
Get list of attribute names.
const std::vector< std::string > & weight_names() const
Get the vector of weight names.
const std::vector< ToolInfo > & tools() const
The vector of tools used to produce this run.
std::string attribute_as_string(const std::string &name) const
Get attribute of any type as string.
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
static void line(std::ostream &os, const GenEvent &event, bool attributes=false)
Print one-line info.
static std::string name(MomentumUnit u)
Get name of momentum unit.