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 378 of file MCDumpers.h.

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

212  { DumpGTruth(std::forward<Stream>(out), truth, indent, indent); }
void DumpGTruth(Stream &&out, simb::GTruth const &truth, std::string indent="")
Definition: MCDumpers.h:211
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 309 of file MCDumpers.h.

312  {
313 
314  out << firstIndent
315  << "from " << TruthCCNCname(nu.CCNC())
316  << ", " << TruthInteractionTypeName(nu.InteractionType())
317  << ", mode: " << nu.Mode() << " (" << TruthReactionMode(nu.Mode()) << ")"
318  << '\n' << indent
319  << "target: " << nu.Target() << " (" << ParticleName(nu.Target()) << ")"
320  ;
321  if (nu.HitNuc() != 0) {
322  out << ", hit nucleon: " << nu.HitNuc()
323  << " (" << ParticleName(nu.HitNuc()) << ")";
324  }
325  if (nu.HitQuark() != 0) {
326  out << ", hit quark: " << nu.HitQuark()
327  << " (" << ParticleName(nu.HitQuark()) << ")";
328  }
329  out
330  << '\n' << indent
331  << "x=" << nu.X() << " y=" << nu.Y() << " w=" << nu.W()
332  << " Q^2=" << nu.QSqr() << " GeV^2; theta=" << nu.Theta()
333  << " rad pT=" << nu.Pt() << " GeV/c"
334  ;
335  out << '\n' << indent << "neutrino: ";
336  DumpMCParticle(std::forward<Stream>(out), nu.Nu(), indent + " ", "");
337  out << '\n' << indent << "outgoing lepton: ";
338  DumpMCParticle(std::forward<Stream>(out), nu.Lepton(), indent + " ", "");
339 
340 } // sim::dump::DumpMCNeutrino()
std::string TruthInteractionTypeName(int type)
std::string TruthCCNCname(int ccnc)
std::string TruthReactionMode(int mode)
Returns the "mode" 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.
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent="")
Definition: MCDumpers.h:60
template<typename Stream >
void sim::dump::DumpMCNeutrino ( Stream &&  out,
simb::MCNeutrino const &  neutrino,
std::string  indent = "" 
)

Definition at line 125 of file MCDumpers.h.

126  { DumpMCNeutrino(std::forward<Stream>(out), neutrino, indent, indent); }
void DumpMCNeutrino(Stream &&out, simb::MCNeutrino const &neutrino, std::string indent="")
Definition: MCDumpers.h:125
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 227 of file MCDumpers.h.

230  {
231  out << firstIndent
232  << "ID=" << particle.TrackId() << ": " << ParticleName(particle.PdgCode())
233  << " mass=" << particle.Mass() << " GeV/c2 "
234  << " status=" << particle.StatusCode()
235  << " (" << ParticleStatusName(particle.StatusCode()) << ")"
236  ;
237  if (particle.Weight() != 1.0) out << " weight=" << particle.Weight();
238  if (particle.Rescatter()) {
239  out << " rescattered (" << particle.Rescatter()
240  << ") at vertex " << particle.GetGvtx();
241  }
242  out << "\n" << indent << "created via "
243  << (particle.Process().empty()? "magics": particle.Process());
244  if (particle.Mother() == 0) out << " by the gods";
245  else out << " from ID=" << particle.Mother();
246 
247  const unsigned int nDaughters = particle.NumberDaughters();
248  const unsigned int nPoints = particle.NumberTrajectoryPoints();
249  if (nPoints > 0) {
250  TLorentzVector const& start = particle.Position();
251  TLorentzVector const& start_mom = particle.Momentum();
252  out << " at " << start << " cm with momentum " << start_mom << " GeV/c";
253  }
254  if (particle.Polarization().Mag2() != 0.) {
255  out
256  << " with polarization " << gar::dump::vector3D(particle.Polarization());
257  }
258  // does this particle seem to stop? (by decay, or because of extended traj.)
259  if ((nPoints > 1) || (nDaughters > 0)) {
260  out << "\n" << indent << ((nDaughters > 0)? "ends": "stops") << " by "
261  << (particle.EndProcess().empty()? "magics": particle.EndProcess());
262  if (nPoints > 1) {
263  TLorentzVector const& stop = particle.EndPosition();
264  TLorentzVector const& stop_mom = particle.EndMomentum();
265  out << " at " << stop << " cm with momentum " << stop_mom << " GeV/c";
266  }
267  if (nDaughters > 0) {
268  out << " into ";
269  if (nDaughters == 1)
270  out << "particle ID=" << particle.FirstDaughter();
271  else {
272  out << nDaughters << " particles from ID=" << particle.FirstDaughter()
273  << " to ID=" << particle.LastDaughter();
274  }
275  } // if daughters
276  } // if it stops
277  if (nPoints > 1) {
278  simb::MCTrajectory const& traj = particle.Trajectory();
279  out << "\n" << indent << "comes with a trajectory " << traj.TotalLength()
280  << " cm long in " << nPoints << " points";
281  } // if has points
282 
283 } // 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.
double TotalLength() const
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 60 of file MCDumpers.h.

61  { DumpMCParticle(std::forward<Stream>(out), particle, indent, indent); }
void DumpMCParticle(Stream &&out, simb::MCParticle const &particle, std::string indent="")
Definition: MCDumpers.h:60
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 288 of file MCDumpers.h.

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

Definition at line 93 of file MCDumpers.h.

94  {
95  DumpMCParticleTrajectory(std::forward<Stream>(out), trajectory, 0U, "");
96  }
void DumpMCParticleTrajectory(Stream &&out, simb::MCTrajectory const &trajectory)
Definition: MCDumpers.h:93
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 345 of file MCDumpers.h.

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

Definition at line 162 of file MCDumpers.h.

166  {
168  (std::forward<Stream>(out), truth, pointsPerLine, indent, indent);
169  }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, std::string indent="")
Definition: MCDumpers.h:179
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
std::string  indent,
std::string  firstIndent 
)

Definition at line 172 of file MCDumpers.h.

176  { DumpMCTruth(std::forward<Stream>(out), truth, 0, indent, firstIndent); }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, std::string indent="")
Definition: MCDumpers.h:179
template<typename Stream >
void sim::dump::DumpMCTruth ( Stream &&  out,
simb::MCTruth const &  truth,
std::string  indent = "" 
)

Definition at line 179 of file MCDumpers.h.

182  { DumpMCTruth(std::forward<Stream>(out), truth, indent, indent); }
void DumpMCTruth(Stream &&out, simb::MCTruth const &truth, std::string indent="")
Definition: MCDumpers.h:179