All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sim::dump Namespace Reference

Functions to dump Monte Carlo object information into a stream. More...

Functions

template<typename Stream >
void DumpMCParticle (Stream &&out, simb::MCParticle const &particle, std::string indent, std::string firstIndent)
 Dumps the content of the specified particle in the output stream. More...
 
template<typename Stream >
void DumpMCParticle (Stream &&out, simb::MCParticle const &particle, std::string indent="")
 
template<typename Stream >
void DumpMCParticleTrajectory (Stream &&out, simb::MCTrajectory const &trajectory, unsigned int pointsPerLine, std::string indent)
 Dumps the specified particle trajectory into the output stream. More...
 
template<typename Stream >
void DumpMCParticleTrajectory (Stream &&out, simb::MCTrajectory const &trajectory)
 
template<typename Stream >
void DumpMCNeutrino (Stream &&out, simb::MCNeutrino const &neutrino, std::string indent, std::string firstIndent)
 Dumps the content of the specified neutrino in the output stream. More...
 
template<typename Stream >
void DumpMCNeutrino (Stream &&out, simb::MCNeutrino const &neutrino, std::string indent="")
 
template<typename Stream >
void DumpMCTruth (Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
 Dumps the content of the specified MC truth in the output stream. More...
 
template<typename Stream >
void DumpMCTruth (Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent="")
 
template<typename Stream >
void DumpMCTruth (Stream &&out, simb::MCTruth const &truth, std::string indent, std::string firstIndent)
 
template<typename Stream >
void DumpMCTruth (Stream &&out, simb::MCTruth const &truth, std::string indent="")
 
template<typename Stream >
void DumpGTruth (Stream &&out, simb::GTruth const &truth, std::string indent, std::string firstIndent)
 Dumps the content of the GENIE truth in the output stream. More...
 
template<typename Stream >
void DumpGTruth (Stream &&out, simb::GTruth const &truth, std::string indent="")
 

Detailed Description

Functions to dump Monte Carlo object information into a stream.

Function Documentation

template<typename Stream >
void sim::dump::DumpGTruth ( Stream &&  out,
simb::GTruth const &  truth,
std::string  indent,
std::string  firstIndent 
)

Dumps the content of the GENIE truth in the output stream.

Template Parameters
Streamthe type of output stream
Parameters
outthe output stream
truththe truth information to be dumped
indentbase indentation string (default: none)
firstIndentstring to be used for indentation of the first line (default: as indent)

The indent string is prepended to every line of output, except for the first one, where firstIndent is used.

The output starts on the current line, and the last line is NOT broken.

Definition at line 379 of file MCDumpers.h.

382  {
383 
384  unsigned int const nCharged
385  = truth.fNumPiPlus + truth.fNumPiMinus + truth.fNumProton;
386  unsigned int const nNeutral = truth.fNumPi0 + truth.fNumNeutron;
387  unsigned int const nPions
388  = truth.fNumPiPlus + truth.fNumPiMinus + truth.fNumPi0;
389  unsigned int const nNucleons = truth.fNumProton + truth.fNumNeutron;
390  unsigned int const nTotalParticles = nCharged + nNeutral;
391 
392  out << firstIndent
393  << "interaction code: " << truth.fGint
394  << ", neutrino scattering code: " << truth.fGscatter
395  << " at " << truth.fVertex
396  << "\n" << indent
397  << "probe: " << ParticleName(truth.fProbePDG)
398  << " with cp=" << truth.fProbeP4
399  << " hit nucleon with cp=" << truth.fHitNucP4 << " GeV"
400  << " (" << (truth.fIsSeaQuark? "": "not a ") << "sea quark)"
401  << " in target: " << ParticleName(truth.ftgtPDG)
402  << " (Z: " << truth.ftgtZ << ", A: " << truth.ftgtA << ")"
403  << "\n" << indent
404  << "event interaction weight (genie internal): " << truth.fweight
405  << ", interaction probability: " << truth.fprobability
406  << ", cross section: " << truth.fXsec
407  << ", differential cross section: " << truth.fDiffXsec
408  << "\n" << indent
409  << "particles after reaction, before FSI: "
410  << truth.fNumPiPlus << " pi+"
411  << ", " << truth.fNumPiMinus << " pi-"
412  << ", " << truth.fNumPi0 << " pi0"
413  << ", " << truth.fNumProton << " p/pbar"
414  << ", " << truth.fNumNeutron << " n/nbar"
415  << "\n" << indent
416  << " total " << nTotalParticles << " particles after reaction before FSI"
417  ": " << nCharged << "/" << nNeutral << " charged/neutral"
418  ", " << nPions << " pions, " << nNucleons << " nucleons"
419  << "\n" << indent << "process "
420  << (truth.fIsCharm? "with": "without") << " charmed hadron";
421  if (truth.fResNum == -1) out << ", no resonance";
422  else out << ", resonance: #" << truth.fResNum;
423  out
424  << "\n" << indent
425  << "internal (on shell) genie kinematics: Q^2: " << truth.fgQ2 << " GeV^2"
426  << " q^2: " << truth.fgq2 << " GeV^2"
427  << ", w: " << truth.fgW << " GeV^2"
428  << ", t: " << truth.fgT << " GeV^2"
429  << ", x: " << truth.fgX
430  << ", y: " << truth.fgY
431  << "\n" << indent
432  << "FShadSyst: " << truth.fFShadSystP4
433  ;
434 
435 } // sim::DumpGTruth::DumpTruth()
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
template<typename Stream >
void sim::dump::DumpGTruth ( Stream &&  out,
simb::GTruth const &  truth,
std::string  indent = "" 
)

Definition at line 212 of file MCDumpers.h.

213  { DumpGTruth(std::forward<Stream>(out), truth, indent, indent); }
void DumpGTruth(Stream &&out, simb::GTruth const &truth, std::string indent, std::string firstIndent)
Dumps the content of the GENIE truth in the output stream.
Definition: MCDumpers.h:379
template<typename Stream >
void sim::dump::DumpMCNeutrino ( Stream &&  out,
simb::MCNeutrino const &  neutrino,
std::string  indent,
std::string  firstIndent 
)

Dumps the content of the specified neutrino in the output stream.

Template Parameters
Streamthe type of output stream
Parameters
outthe output stream
neutrinothe neutrino to be dumped
indentbase indentation string (default: none)
firstIndentstring to be used for indentation of the first line (default: as indent)

The indent string is prepended to every line of output, except for the first one, where firstIndent is used.

The output starts on the current line, and the last line is NOT broken.

Definition at line 310 of file MCDumpers.h.

313  {
314 
315  out << firstIndent
316  << "from " << TruthCCNCname(nu.CCNC())
317  << ", " << TruthInteractionTypeName(nu.InteractionType())
318  << ", mode: " << nu.Mode() << " (" << TruthReactionMode(nu.Mode()) << ")"
319  << '\n' << indent
320  << "target: " << nu.Target() << " (" << ParticleName(nu.Target()) << ")"
321  ;
322  if (nu.HitNuc() != 0) {
323  out << ", hit nucleon: " << nu.HitNuc()
324  << " (" << ParticleName(nu.HitNuc()) << ")";
325  }
326  if (nu.HitQuark() != 0) {
327  out << ", hit quark: " << nu.HitQuark()
328  << " (" << ParticleName(nu.HitQuark()) << ")";
329  }
330  out
331  << '\n' << indent
332  << "x=" << nu.X() << " y=" << nu.Y() << " w=" << nu.W()
333  << " Q^2=" << nu.QSqr() << " GeV^2; theta=" << nu.Theta()
334  << " rad pT=" << nu.Pt() << " GeV/c"
335  ;
336  out << '\n' << indent << "neutrino: ";
337  DumpMCParticle(std::forward<Stream>(out), nu.Nu(), indent + " ", "");
338  out << '\n' << indent << "outgoing lepton: ";
339  DumpMCParticle(std::forward<Stream>(out), nu.Lepton(), indent + " ", "");
340 
341 } // sim::dump::DumpMCNeutrino()
std::string TruthInteractionTypeName(int type)
std::string TruthCCNCname(int ccnc)
std::string TruthReactionMode(int mode)
Returns the &quot;mode&quot; of the reaction (a lesser version of interaction type).
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
BEGIN_PROLOG SN nu
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent, std::string firstIndent)
Dumps the content of the specified particle in the output stream.
Definition: MCDumpers.h:228
template<typename Stream >
void sim::dump::DumpMCNeutrino ( Stream &&  out,
simb::MCNeutrino const &  neutrino,
std::string  indent = "" 
)

Definition at line 126 of file MCDumpers.h.

127  { DumpMCNeutrino(std::forward<Stream>(out), neutrino, indent, indent); }
void DumpMCNeutrino(Stream &&out, simb::MCNeutrino const &neutrino, std::string indent, std::string firstIndent)
Dumps the content of the specified neutrino in the output stream.
Definition: MCDumpers.h:310
template<typename Stream >
void sim::dump::DumpMCParticle ( Stream &&  out,
simb::MCParticle const &  particle,
std::string  indent,
std::string  firstIndent 
)

Dumps the content of the specified particle in the output stream.

Template Parameters
Streamthe type of output stream
Parameters
outthe output stream
particlethe particle to be dumped
indentbase indentation string (default: none)
firstIndentindentation of first line (default: as indent)

The indent string is prepended to every line of output, except for the first one, where firstIndent is used.

The output starts on the current line, and the last line is NOT broken.

Definition at line 228 of file MCDumpers.h.

231  {
232  out << firstIndent
233  << "ID=" << particle.TrackId() << ": " << ParticleName(particle.PdgCode())
234  << " mass=" << particle.Mass() << " GeV/c2 "
235  << " status=" << particle.StatusCode()
236  << " (" << ParticleStatusName(particle.StatusCode()) << ")"
237  ;
238  if (particle.Weight() != 1.0) out << " weight=" << particle.Weight();
239  if (particle.Rescatter() != simb::MCParticle::s_uninitialized) {
240  out << " rescattered (" << particle.Rescatter() << ")";
241  }
242  out << "; generator vertex " << particle.GetGvtx();
243  out << "\n" << indent << "created via "
244  << (particle.Process().empty()? "magics": particle.Process());
245  if (particle.Mother() == 0) out << " by the gods";
246  else out << " from ID=" << particle.Mother();
247 
248  const unsigned int nDaughters = particle.NumberDaughters();
249  const unsigned int nPoints = particle.NumberTrajectoryPoints();
250  if (nPoints > 0) {
251  TLorentzVector const& start = particle.Position();
252  TLorentzVector const& start_mom = particle.Momentum();
253  out << " at " << start << " cm with momentum " << start_mom << " GeV/c";
254  }
255  if (particle.Polarization().Mag2() != 0.) {
256  out
257  << " with polarization " << lar::dump::vector3D(particle.Polarization());
258  }
259  // does this particle seem to stop? (by decay, or because of extended traj.)
260  if ((nPoints > 1) || (nDaughters > 0)) {
261  out << "\n" << indent << ((nDaughters > 0)? "ends": "stops") << " by "
262  << (particle.EndProcess().empty()? "magics": particle.EndProcess());
263  if (nPoints > 1) {
264  TLorentzVector const& stop = particle.EndPosition();
265  TLorentzVector const& stop_mom = particle.EndMomentum();
266  out << " at " << stop << " cm with momentum " << stop_mom << " GeV/c";
267  }
268  if (nDaughters > 0) {
269  out << " into ";
270  if (nDaughters == 1)
271  out << "particle ID=" << particle.FirstDaughter();
272  else {
273  out << nDaughters << " particles from ID=" << particle.FirstDaughter()
274  << " to ID=" << particle.LastDaughter();
275  }
276  } // if daughters
277  } // if it stops
278  if (nPoints > 1) {
279  simb::MCTrajectory const& traj = particle.Trajectory();
280  out << "\n" << indent << "comes with a trajectory " << traj.TotalLength()
281  << " cm long in " << nPoints << " points";
282  } // if has points
283 
284 } // sim::dump::DumpMCParticle()
auto vector3D(Vector3D const &v)
Returns a manipulator which will print the specified vector.
Definition: DumpUtils.h:301
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
template<typename Stream >
void sim::dump::DumpMCParticle ( Stream &&  out,
simb::MCParticle const &  particle,
std::string  indent = "" 
)

Definition at line 61 of file MCDumpers.h.

62  { DumpMCParticle(std::forward<Stream>(out), particle, indent, indent); }
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent, std::string firstIndent)
Dumps the content of the specified particle in the output stream.
Definition: MCDumpers.h:228
template<typename Stream >
void sim::dump::DumpMCParticleTrajectory ( Stream &&  out,
simb::MCTrajectory const &  trajectory,
unsigned int  pointsPerLine,
std::string  indent 
)

Dumps the specified particle trajectory into the output stream.

Template Parameters
Streamthe type of output stream
Parameters
outthe output stream
trajectorythe particle trajectory to be dumped
pointsPerLinenumber of points dumped per line (default: all)
indentbase indentation string (default: none)

All points of the specified Monte Carlo trajectory are printed on screen, pointsPerLine on each line. The points are printed starting on a new line, and each line is applied the same indentation string (indent). As an exception, if pointsPerLine is not specified, all points are printed on the current line and indent is ignored.

The last line of the output is NOT broken.

Definition at line 289 of file MCDumpers.h.

292  {
293  unsigned int page = 0;
294  for (auto const& pair: trajectory) {
295  if ((pointsPerLine > 0) && (page-- == 0)) {
296  out << "\n" << indent << " ";
297  page = pointsPerLine - 1;
298  }
299  else out << " -- ";
300 
301  TLorentzVector const& pos = pair.first;
302  out << pos;
303  } // for trajectory points
304 
305 } // sim::dump::DumpMCParticleTrajectory()
template<typename Stream >
void sim::dump::DumpMCParticleTrajectory ( Stream &&  out,
simb::MCTrajectory const &  trajectory 
)

Definition at line 94 of file MCDumpers.h.

95  {
96  DumpMCParticleTrajectory(std::forward<Stream>(out), trajectory, 0U, "");
97  }
void DumpMCParticleTrajectory(Stream &&out, simb::MCTrajectory const &trajectory, unsigned int pointsPerLine, std::string indent)
Dumps the specified particle trajectory into the output stream.
Definition: MCDumpers.h:289
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
unsigned int  pointsPerLine,
std::string  indent,
std::string  firstIndent 
)

Dumps the content of the specified MC truth in the output stream.

Template Parameters
Streamthe type of output stream
Parameters
outthe output stream
truththe truth information to be dumped
pointsPerLine(optional) number of trajectory points dumped per line (default: 0, no points shown)
indentbase indentation string (default: none)
firstIndentstring to be used for indentation of the first line (default: same as indent)

The indent string is prepended to every line of output, except for the first one, where firstIndent is used.

The argument pointsPerLine regulates the dump of trajectory points from all the particles in the record (except the ones stored in the neutrino object). Setting it to 0, or leaving it out, will suppress the dump of particle trajectories completely. There is no option to reduce the number of printed trajectory points: it's just all or none.

The output starts on the current line, and the last line is NOT broken.

Definition at line 346 of file MCDumpers.h.

349  {
350  unsigned int const nParticles = truth.NParticles();
351  out << firstIndent
352  << nParticles << " particles from "
353  << TruthOriginName(truth.Origin());
354  if (truth.NeutrinoSet()) {
355  out << '\n' << indent << "neutrino information: ";
357  (std::forward<Stream>(out), truth.GetNeutrino(), indent + " ", "");
358  }
359  for (unsigned int i = 0; i < nParticles; ++i) {
360  out << '\n' << indent << "[#" << i << "] ";
361  simb::MCParticle const& particle = truth.GetParticle(i);
362  DumpMCParticle(std::forward<Stream>(out), particle, indent + " ", "");
363 
364  const unsigned int nPoints = particle.NumberTrajectoryPoints();
365  if ((nPoints > 0) && (pointsPerLine > 0)) {
366  out << ":";
368  std::forward<Stream>(out), particle.Trajectory(),
369  pointsPerLine, indent + " "
370  );
371  } // if has points
372  } // for all particles
373 
374 } // sim::dump::DumpMCTruth()
void DumpMCParticleTrajectory(Stream &&out, simb::MCTrajectory const &trajectory, unsigned int pointsPerLine, std::string indent)
Dumps the specified particle trajectory into the output stream.
Definition: MCDumpers.h:289
std::string TruthOriginName(simb::Origin_t origin)
Returns a string representing the specified process origin.
void DumpMCNeutrino(Stream &&out, simb::MCNeutrino const &neutrino, std::string indent, std::string firstIndent)
Dumps the content of the specified neutrino in the output stream.
Definition: MCDumpers.h:310
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent, std::string firstIndent)
Dumps the content of the specified particle in the output stream.
Definition: MCDumpers.h:228
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
unsigned int  pointsPerLine,
std::string  indent = "" 
)

Definition at line 163 of file MCDumpers.h.

167  {
169  (std::forward<Stream>(out), truth, pointsPerLine, indent, indent);
170  }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
Definition: MCDumpers.h:346
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
std::string  indent,
std::string  firstIndent 
)

Definition at line 173 of file MCDumpers.h.

177  { DumpMCTruth(std::forward<Stream>(out), truth, 0, indent, firstIndent); }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
Definition: MCDumpers.h:346
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
std::string  indent = "" 
)

Definition at line 180 of file MCDumpers.h.

183  { DumpMCTruth(std::forward<Stream>(out), truth, indent, indent); }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, unsigned int pointsPerLine, std::string indent, std::string firstIndent)
Dumps the content of the specified MC truth in the output stream.
Definition: MCDumpers.h:346