11 #ifndef LARDATAALG_MCDUMPERS_MCDUMPERS_H
12 #define LARDATAALG_MCDUMPERS_MCDUMPERS_H
20 #include "nusimdata/SimulationBase/MCTrajectory.h"
21 #include "nusimdata/SimulationBase/MCParticle.h"
22 #include "nusimdata/SimulationBase/GTruth.h"
23 #include "nusimdata/SimulationBase/MCTruth.h"
26 #include "TLorentzVector.h"
53 template <
typename Stream>
55 Stream&& out, simb::MCParticle
const& particle,
56 std::string indent, std::string firstIndent
59 template <
typename Stream>
61 (
Stream&& out, simb::MCParticle
const& particle, std::string indent =
"")
62 {
DumpMCParticle(std::forward<Stream>(out), particle, indent, indent); }
86 template <
typename Stream>
88 Stream&& out, simb::MCTrajectory
const& trajectory,
89 unsigned int pointsPerLine, std::string indent
92 template <
typename Stream>
94 (
Stream&& out, simb::MCTrajectory
const& trajectory)
118 template <
typename Stream>
120 Stream&& out, simb::MCNeutrino
const& neutrino,
121 std::string indent, std::string firstIndent
124 template <
typename Stream>
126 (
Stream&& out, simb::MCNeutrino
const& neutrino, std::string indent =
"")
127 {
DumpMCNeutrino(std::forward<Stream>(out), neutrino, indent, indent); }
156 template <
typename Stream>
158 Stream&& out, simb::MCTruth
const& truth,
unsigned int pointsPerLine,
159 std::string indent, std::string firstIndent
162 template <
typename Stream>
164 Stream&& out, simb::MCTruth
const& truth,
unsigned int pointsPerLine,
165 std::string indent =
""
169 (std::forward<Stream>(out), truth, pointsPerLine, indent, indent);
172 template <
typename Stream>
174 Stream&& out, simb::MCTruth
const& truth,
175 std::string indent, std::string firstIndent
177 {
DumpMCTruth(std::forward<Stream>(out), truth, 0, indent, firstIndent); }
179 template <
typename Stream>
181 Stream&& out, simb::MCTruth
const& truth, std::string indent =
""
183 {
DumpMCTruth(std::forward<Stream>(out), truth, indent, indent); }
204 template <
typename Stream>
206 Stream&& out, simb::GTruth
const& truth,
207 std::string indent, std::string firstIndent
210 template <
typename Stream>
212 (
Stream&& out, simb::GTruth
const& truth, std::string indent =
"")
213 {
DumpGTruth(std::forward<Stream>(out), truth, indent, indent); }
227 template <
typename Stream>
229 Stream&& out, simb::MCParticle
const& particle,
230 std::string indent, std::string firstIndent
233 <<
"ID=" << particle.TrackId() <<
": " <<
ParticleName(particle.PdgCode())
234 <<
" mass=" << particle.Mass() <<
" GeV/c2 "
235 <<
" status=" << particle.StatusCode()
238 if (particle.Weight() != 1.0) out <<
" weight=" << particle.Weight();
239 if (particle.Rescatter() != simb::MCParticle::s_uninitialized) {
240 out <<
" rescattered (" << particle.Rescatter() <<
")";
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();
248 const unsigned int nDaughters = particle.NumberDaughters();
249 const unsigned int nPoints = particle.NumberTrajectoryPoints();
251 TLorentzVector
const& start = particle.Position();
252 TLorentzVector
const& start_mom = particle.Momentum();
253 out <<
" at " << start <<
" cm with momentum " << start_mom <<
" GeV/c";
255 if (particle.Polarization().Mag2() != 0.) {
260 if ((nPoints > 1) || (nDaughters > 0)) {
261 out <<
"\n" << indent << ((nDaughters > 0)?
"ends":
"stops") <<
" by "
262 << (particle.EndProcess().empty()?
"magics": particle.EndProcess());
264 TLorentzVector
const& stop = particle.EndPosition();
265 TLorentzVector
const& stop_mom = particle.EndMomentum();
266 out <<
" at " << stop <<
" cm with momentum " << stop_mom <<
" GeV/c";
268 if (nDaughters > 0) {
271 out <<
"particle ID=" << particle.FirstDaughter();
273 out << nDaughters <<
" particles from ID=" << particle.FirstDaughter()
274 <<
" to ID=" << particle.LastDaughter();
279 simb::MCTrajectory
const& traj = particle.Trajectory();
280 out <<
"\n" << indent <<
"comes with a trajectory " << traj.TotalLength()
281 <<
" cm long in " << nPoints <<
" points";
288 template <
typename Stream>
290 Stream&& out, simb::MCTrajectory
const& trajectory,
291 unsigned int pointsPerLine, std::string indent
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;
301 TLorentzVector
const& pos = pair.first;
309 template <
typename Stream>
311 Stream&& out, simb::MCNeutrino
const&
nu,
312 std::string indent, std::string firstIndent
320 <<
"target: " << nu.Target() <<
" (" <<
ParticleName(nu.Target()) <<
")"
322 if (nu.HitNuc() != 0) {
323 out <<
", hit nucleon: " << nu.HitNuc()
326 if (nu.HitQuark() != 0) {
327 out <<
", hit quark: " << nu.HitQuark()
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"
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 +
" ",
"");
345 template <
typename Stream>
347 Stream&& out, simb::MCTruth
const& truth,
unsigned int pointsPerLine,
348 std::string indent, std::string firstIndent
350 unsigned int const nParticles = truth.NParticles();
352 << nParticles <<
" particles from "
354 if (truth.NeutrinoSet()) {
355 out <<
'\n' << indent <<
"neutrino information: ";
357 (std::forward<Stream>(out), truth.GetNeutrino(), indent +
" ",
"");
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 +
" ",
"");
364 const unsigned int nPoints = particle.NumberTrajectoryPoints();
365 if ((nPoints > 0) && (pointsPerLine > 0)) {
368 std::forward<Stream>(out), particle.Trajectory(),
369 pointsPerLine, indent +
" "
378 template <
typename Stream>
380 Stream&& out, simb::GTruth
const& truth,
381 std::string indent, std::string firstIndent
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;
393 <<
"interaction code: " << truth.fGint
394 <<
", neutrino scattering code: " << truth.fGscatter
395 <<
" at " << truth.fVertex
398 <<
" with cp=" << truth.fProbeP4
399 <<
" hit nucleon with cp=" << truth.fHitNucP4 <<
" GeV"
400 <<
" (" << (truth.fIsSeaQuark?
"":
"not a ") <<
"sea quark)"
402 <<
" (Z: " << truth.ftgtZ <<
", A: " << truth.ftgtA <<
")"
404 <<
"event interaction weight (genie internal): " << truth.fweight
405 <<
", interaction probability: " << truth.fprobability
406 <<
", cross section: " << truth.fXsec
407 <<
", differential cross section: " << truth.fDiffXsec
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"
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;
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
432 <<
"FShadSyst: " << truth.fFShadSystP4
441 #endif // LARDATAALG_MCDUMPERS_MCDUMPERS_H
Specializations of geo_vectors_utils.h for ROOT old vector types.
auto vector3D(Vector3D const &v)
Returns a manipulator which will print the specified vector.
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.
std::string TruthInteractionTypeName(int type)
void DumpMCParticleTrajectory(Stream &&out, simb::MCTrajectory const &trajectory, unsigned int pointsPerLine, std::string indent)
Dumps the specified particle trajectory into the output stream.
std::string TruthCCNCname(int ccnc)
std::string TruthReactionMode(int mode)
Returns the "mode" of the reaction (a lesser version of interaction type).
Utilities to dump objects into a stream.
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
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.
std::string TruthOriginName(simb::Origin_t origin)
Returns a string representing the specified process origin.
Utility functions to print MC truth information.
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.
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
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.