MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
HepMC3::Print Class Reference

Provides different printing formats. More...

#include <Print.h>

Public Member Functions

Printoperator= (const Print &)=delete
 deleted copy assignment operator
 

Static Public Member Functions

static void content (const GenEvent &event)
 Print content of all GenEvent containers to std::cout.
 
static void content (std::ostream &os, const GenEvent &event)
 Print content of all GenEvent containers.
 
static void line (const FourVector &p)
 Print one-line info to std::cout.
 
static void line (const GenEvent &event, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (const GenRunInfo &RunInfo, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (const GenRunInfo::ToolInfo &t)
 Print one-line info to std::cout.
 
static void line (ConstGenParticlePtr p, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (ConstGenVertexPtr v, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (GenParticlePtr p, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (GenVertexPtr v, bool attributes=false)
 Print one-line info to std::cout.
 
static void line (std::ostream &os, const FourVector &p)
 Print one-line info.
 
static void line (std::ostream &os, const GenEvent &event, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, const GenRunInfo &RunInfo, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, const GenRunInfo::ToolInfo &t)
 Print one-line info.
 
static void line (std::ostream &os, ConstGenParticlePtr p, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, ConstGenVertexPtr v, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, GenParticlePtr p, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, GenVertexPtr v, bool attributes=false)
 Print one-line info.
 
static void line (std::ostream &os, std::shared_ptr< GenCrossSection > &cs)
 Print one-line info.
 
static void line (std::ostream &os, std::shared_ptr< GenHeavyIon > &hi)
 Print one-line info.
 
static void line (std::ostream &os, std::shared_ptr< GenPdfInfo > &pi)
 Print one-line info.
 
static void line (std::shared_ptr< GenCrossSection > &cs)
 Print one-line info to std::cout.
 
static void line (std::shared_ptr< GenHeavyIon > &hi)
 Print one-line info to std::cout.
 
static void line (std::shared_ptr< GenPdfInfo > &pi)
 Print one-line info to std::cout.
 
static void listing (const GenEvent &event, unsigned short precision=2)
 Print event in listing (HepMC2) format to std::cout.
 
static void listing (const GenRunInfo &ri, unsigned short precision=2)
 Print runinfo in listing to std::cout.
 
static void listing (std::ostream &os, const GenEvent &event, unsigned short precision=2)
 Print event in listing (HepMC2) format.
 
static void listing (std::ostream &os, const GenRunInfo &ri, unsigned short precision=2)
 Print runinfo in listing.
 

Detailed Description

Provides different printing formats.

Definition at line 27 of file Print.h.

Member Function Documentation

◆ content() [1/2]

static void HepMC3::Print::content ( const GenEvent & event)
inlinestatic

Print content of all GenEvent containers to std::cout.

Definition at line 32 of file Print.h.

32{ content(std::cout, event); }
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.

References content().

Referenced by content().

◆ content() [2/2]

void HepMC3::Print::content ( std::ostream & os,
const GenEvent & event )
static

Print content of all GenEvent containers.

Definition at line 1384 of file marley_hepmc3.cc.

1384 {
1385 os << "--------------------------------" << std::endl;
1386 os << "--------- EVENT CONTENT --------" << std::endl;
1387 os << "--------------------------------" << std::endl;
1388 os << std::endl;
1389
1390 os << "Weights (" << event.weights().size() << "): " << std::endl;
1391 for (const auto& w: event.weights()) {
1392 os << " " << w;
1393 }
1394
1395 os << "Attributes:" << std::endl;
1396
1397 for (const auto& vt1: event.attributes()) {
1398 for (const auto& vt2: vt1.second) {
1399 os << vt2.first << ": " << vt1.first << std::endl;
1400 }
1401 }
1402
1403 os << "GenParticlePtr (" << event.particles().size() << ")" << std::endl;
1404
1405 for (const ConstGenParticlePtr& p: event.particles()) {
1406 Print::line(os, p, true);
1407 os << std::endl;
1408 }
1409
1410 os << "GenVertexPtr (" << event.vertices().size() << ")" << std::endl;
1411 for ( const ConstGenVertexPtr& v: event.vertices() ) {
1412 Print::line(os, v, true);
1413 os << std::endl;
1414 }
1415
1416 os << "-----------------------------" << std::endl;
1417}
static void line(std::ostream &os, const GenEvent &event, bool attributes=false)
Print one-line info.

References HepMC3::GenEvent::attributes(), line(), HepMC3::GenEvent::particles(), HepMC3::GenEvent::vertices(), and HepMC3::GenEvent::weights().

◆ line() [1/22]

static void HepMC3::Print::line ( const FourVector & p)
inlinestatic

Print one-line info to std::cout.

Definition at line 93 of file Print.h.

93 {
94 line(std::cout, p);
95 std::cout << std::endl;
96 }

References line().

◆ line() [2/22]

static void HepMC3::Print::line ( const GenEvent & event,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 51 of file Print.h.

51 {
52 line(std::cout, event, attributes);
53 std::cout<<std::endl;
54 }

References line().

◆ line() [3/22]

static void HepMC3::Print::line ( const GenRunInfo & RunInfo,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 59 of file Print.h.

59 {
60 line(std::cout, RunInfo, attributes);
61 std::cout<<std::endl;
62 }

References line().

◆ line() [4/22]

static void HepMC3::Print::line ( const GenRunInfo::ToolInfo & t)
inlinestatic

Print one-line info to std::cout.

Definition at line 67 of file Print.h.

67 {
68 line(std::cout, t);
69 std::cout << std::endl;
70 }

References line().

◆ line() [5/22]

static void HepMC3::Print::line ( ConstGenParticlePtr p,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 101 of file Print.h.

101 {
102 line(std::cout, p, attributes);
103 std::cout << std::endl;
104 }

References line().

◆ line() [6/22]

static void HepMC3::Print::line ( ConstGenVertexPtr v,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 77 of file Print.h.

77 {
78 line(std::cout, v, attributes);
79 std::cout << std::endl;
80 }

References line().

◆ line() [7/22]

static void HepMC3::Print::line ( GenParticlePtr p,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 109 of file Print.h.

109 {
110 line(std::cout, p, attributes);
111 std::cout << std::endl;
112 }

References line().

◆ line() [8/22]

static void HepMC3::Print::line ( GenVertexPtr v,
bool attributes = false )
inlinestatic

Print one-line info to std::cout.

Definition at line 85 of file Print.h.

85 {
86 line(std::cout, v, attributes);
87 std::cout << std::endl;
88 }

References line().

◆ line() [9/22]

void HepMC3::Print::line ( std::ostream & os,
const FourVector & p )
static

Print one-line info.

Definition at line 1623 of file marley_hepmc3.cc.

1623 {
1624 os << "FourVector: ";
1625 // Find the current stream state
1626 std::ios_base::fmtflags orig = os.flags();
1627 os.setf(std::ios::scientific, std::ios::floatfield);
1628 os.setf(std::ios_base::showpos);
1629 std::streamsize prec = os.precision();
1630 // Set precision
1631 os.precision(2);
1632 os << " (P,E)=" << p.x()
1633 << "," << p.y()
1634 << "," << p.z()
1635 << "," << p.e();
1636
1637 // Restore the stream state
1638 os.flags(orig);
1639 os.precision(prec);
1640}

References HepMC3::FourVector::e(), HepMC3::FourVector::x(), HepMC3::FourVector::y(), and HepMC3::FourVector::z().

◆ line() [10/22]

void HepMC3::Print::line ( std::ostream & os,
const GenEvent & event,
bool attributes = false )
static

Print one-line info.

Definition at line 1571 of file marley_hepmc3.cc.

1571 {
1572 os << "GenEvent: #" << event.event_number();
1573 if (attributes) {
1574 for (const std::string& s: event.attribute_names()) {
1575 os << " " << s << "=" <<event.attribute_as_string(s);
1576 }
1577 }
1578}

References HepMC3::GenEvent::attribute_names().

Referenced by content(), line(), line(), line(), line(), line(), line(), line(), line(), line(), line(), line(), and listing().

◆ line() [11/22]

void HepMC3::Print::line ( std::ostream & os,
const GenRunInfo & RunInfo,
bool attributes = false )
static

Print one-line info.

Definition at line 1580 of file marley_hepmc3.cc.

1580 {
1581 os <<"GenRunInfo: Number of tools:" << RunInfo.tools().size();
1582
1583 if (attributes) {
1584 for (const std::string& s: RunInfo.attribute_names()) {
1585 os << " " << s << "=" << RunInfo.attribute_as_string(s);
1586 }
1587 }
1588}

References HepMC3::GenRunInfo::attribute_as_string(), HepMC3::GenRunInfo::attribute_names(), and HepMC3::GenRunInfo::tools().

◆ line() [12/22]

void HepMC3::Print::line ( std::ostream & os,
const GenRunInfo::ToolInfo & t )
static

Print one-line info.

Definition at line 1590 of file marley_hepmc3.cc.

1590 {
1591 os << "GenRunInfo::ToolInfo " << t.name<< " " << t.version << " " << t.description;
1592}

References HepMC3::GenRunInfo::ToolInfo::description, HepMC3::GenRunInfo::ToolInfo::name, and HepMC3::GenRunInfo::ToolInfo::version.

◆ line() [13/22]

void HepMC3::Print::line ( std::ostream & os,
ConstGenParticlePtr p,
bool attributes = false )
static

Print one-line info.

Definition at line 1691 of file marley_hepmc3.cc.

1691{ line_p(os,p,attributes); }

◆ line() [14/22]

void HepMC3::Print::line ( std::ostream & os,
ConstGenVertexPtr v,
bool attributes = false )
static

Print one-line info.

Definition at line 1618 of file marley_hepmc3.cc.

1618{ line_v(os,v,attributes); }

◆ line() [15/22]

void HepMC3::Print::line ( std::ostream & os,
GenParticlePtr p,
bool attributes = false )
static

Print one-line info.

Definition at line 1692 of file marley_hepmc3.cc.

1692{ line_p(os,p,attributes); }

◆ line() [16/22]

void HepMC3::Print::line ( std::ostream & os,
GenVertexPtr v,
bool attributes = false )
static

Print one-line info.

Definition at line 1619 of file marley_hepmc3.cc.

1619{ line_v(os,v,attributes); }

◆ line() [17/22]

void HepMC3::Print::line ( std::ostream & os,
std::shared_ptr< GenCrossSection > & cs )
static

Print one-line info.

Definition at line 1694 of file marley_hepmc3.cc.

1694 {
1695 if (!cs) {os << " GenCrossSection: Empty"; return;}
1696 os << " GenCrossSection: " << cs->xsec(0)
1697 << " " << cs->xsec_err(0)
1698 << " " << cs->get_accepted_events()
1699 << " " << cs->get_attempted_events();
1700}

◆ line() [18/22]

void HepMC3::Print::line ( std::ostream & os,
std::shared_ptr< GenHeavyIon > & hi )
static

Print one-line info.

Definition at line 1702 of file marley_hepmc3.cc.

1702 {
1703 if (!hi) {os << " GenHeavyIon: Empty"; return;}
1704 os << " GenHeavyIon: " << hi->Ncoll_hard
1705 << " " << hi->Npart_proj
1706 << " " << hi->Npart_targ
1707 << " " << hi->Ncoll
1708 << " " << hi->spectator_neutrons
1709 << " " << hi->spectator_protons
1710 << " " << hi->N_Nwounded_collisions
1711 << " " << hi->Nwounded_N_collisions
1712 << " " << hi->Nwounded_Nwounded_collisions
1713 << " " << hi->impact_parameter
1714 << " " << hi->event_plane_angle
1715 << " " << hi->eccentricity
1716 << " " << hi->sigma_inel_NN;
1717}

◆ line() [19/22]

void HepMC3::Print::line ( std::ostream & os,
std::shared_ptr< GenPdfInfo > & pi )
static

Print one-line info.

Definition at line 1719 of file marley_hepmc3.cc.

1719 {
1720 if (!pi) {os << " GenPdfInfo: Empty"; return;}
1721 os << " GenPdfInfo: " << pi->parton_id[0]
1722 << " " << pi->parton_id[1]
1723 << " " << pi->x[0]
1724 << " " << pi->x[1]
1725 << " " << pi->scale
1726 << " " << pi->xf[0]
1727 << " " << pi->xf[1]
1728 << " " << pi->pdf_id[0]
1729 << " " << pi->pdf_id[1];
1730}

◆ line() [20/22]

static void HepMC3::Print::line ( std::shared_ptr< GenCrossSection > & cs)
inlinestatic

Print one-line info to std::cout.

Definition at line 118 of file Print.h.

118 {
119 line(std::cout, cs);
120 std::cout<<std::endl;
121 }

References line().

◆ line() [21/22]

static void HepMC3::Print::line ( std::shared_ptr< GenHeavyIon > & hi)
inlinestatic

Print one-line info to std::cout.

Definition at line 126 of file Print.h.

126 {
127 line(std::cout, hi);
128 std::cout<<std::endl;
129 }

References line().

◆ line() [22/22]

static void HepMC3::Print::line ( std::shared_ptr< GenPdfInfo > & pi)
inlinestatic

Print one-line info to std::cout.

Definition at line 134 of file Print.h.

134 {
135 line(std::cout, pi);
136 std::cout<<std::endl;
137 }

References line().

◆ listing() [1/4]

static void HepMC3::Print::listing ( const GenEvent & event,
unsigned short precision = 2 )
inlinestatic

Print event in listing (HepMC2) format to std::cout.

Definition at line 37 of file Print.h.

37 {
38 listing(std::cout, event, precision);
39 }
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.

References listing().

◆ listing() [2/4]

static void HepMC3::Print::listing ( const GenRunInfo & ri,
unsigned short precision = 2 )
inlinestatic

Print runinfo in listing to std::cout.

Definition at line 44 of file Print.h.

44 {
45 listing(std::cout, ri, precision);
46 }

References listing().

◆ listing() [3/4]

void HepMC3::Print::listing ( std::ostream & os,
const GenEvent & event,
unsigned short precision = 2 )
static

Print event in listing (HepMC2) format.

Definition at line 1419 of file marley_hepmc3.cc.

1419 {
1420 // Find the current stream state
1421 std::ios_base::fmtflags orig = os.flags();
1422 std::streamsize prec = os.precision();
1423
1424 // Set precision
1425 os.precision(precision);
1426
1427 os << "________________________________________________________________________" << std::endl;
1428 os << "GenEvent: #" << event.event_number() << std::endl;
1429 os << " Momentum units: " << Units::name(event.momentum_unit())
1430 << " Position units: " << Units::name(event.length_unit()) << std::endl;
1431 os << " Entries in this event: " << event.vertices().size() << " vertices, "
1432 << event.particles().size() << " particles, "
1433 << event.weights().size() << " weights." << std::endl;
1434
1435 const FourVector &pos = event.event_pos();
1436 os << " Position offset: " << pos.x() << ", " << pos.y() << ", " << pos.z() << ", " << pos.t() << std::endl;
1437
1438 // Print a legend to describe the particle info
1439 os << " GenParticle Legend" << std::endl;
1440 os << " ID PDG ID "
1441 << "( px, py, pz, E )"
1442 << " Stat ProdVtx" << std::endl;
1443 os << "________________________________________________________________________" << std::endl;
1444
1445 // Print all vertices
1446 for (const ConstGenVertexPtr& v: event.vertices()) {
1447 Print::listing(os, v);
1448 }
1449
1450 // Restore the stream state
1451 os.flags(orig);
1452 os.precision(prec);
1453 os << "________________________________________________________________________" << std::endl;
1454}
static std::string name(MomentumUnit u)
Get name of momentum unit.
Definition Units.h:56

References HepMC3::GenEvent::length_unit(), listing(), HepMC3::GenEvent::momentum_unit(), HepMC3::Units::name(), HepMC3::FourVector::t(), HepMC3::GenEvent::vertices(), HepMC3::FourVector::x(), HepMC3::FourVector::y(), and HepMC3::FourVector::z().

Referenced by listing(), listing(), and listing().

◆ listing() [4/4]

void HepMC3::Print::listing ( std::ostream & os,
const GenRunInfo & ri,
unsigned short precision = 2 )
static

Print runinfo in listing.

Definition at line 1456 of file marley_hepmc3.cc.

1456 {
1457 // Find the current stream state
1458 std::ios_base::fmtflags orig = os.flags();
1459 std::streamsize prec = os.precision();
1460
1461 // Set precision
1462 os.precision(precision);
1463
1464 os << "________________________________________________________________________" << std::endl;
1465 os << "GenRunInfo:" << std::endl;
1466
1467 std::vector<std::string> names = ri.weight_names();
1468 os << " Names: ( ";
1469 for (const auto& n: names) os << n;
1470 os << " )" << std::endl;
1471
1472 os << " Tools: " << std::endl;
1473
1474 for (const auto& t: ri.tools()) {
1475 Print::line(os, t);
1476 }
1477 os << "Attributes:" << std::endl;
1478 for (const auto& att: ri.attributes()) {
1479 std::string st;
1480 if ( !att.second->to_string(st) ) {
1481 HEPMC3_WARNING_LEVEL(300,"Print::listing: problem serializing attribute: " << att.first)
1482 }
1483 else { os << att.first << " " << st;}
1484 os << std::endl;
1485 }
1486
1487 // Restore the stream state
1488 os.flags(orig);
1489 os.precision(prec);
1490 os << "________________________________________________________________________" << std::endl;
1491}

References HepMC3::GenRunInfo::attributes(), line(), HepMC3::GenRunInfo::tools(), and HepMC3::GenRunInfo::weight_names().


The documentation for this class was generated from the following files: