MCDumperUtils.cxx
Go to the documentation of this file.
1 /**
2  * @file lardataalg/MCDumpers/MCDumperUtils.cxx
3  * @brief Utility functions to print MC truth information (implementation).
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date November 2, 2017
6  * @see lardataalg/MCDumpers/MCDumpersUtils.h
7  *
8  */
9 
10 // library header
12 
13 // nusimdata
15 
16 // GENIE headers
17 #ifdef HAS_GENIE // does not happen in LArSoft
18 # include "GENIE/HadronTransport/INukeHadroFates.h"
19 #endif // HAS_GENIE
20 
21 // ROOT
22 #include "TDatabasePDG.h"
23 #include "TParticlePDG.h"
24 
25 
26 //------------------------------------------------------------------------------
28  switch (origin) {
29  case simb::kUnknown : return "unknown origin";
30  case simb::kBeamNeutrino : return "neutrinos from beam";
31  case simb::kCosmicRay : return "cosmic rays";
32  case simb::kSuperNovaNeutrino: return "supernova neutrinos";
33  case simb::kSingleParticle : return "single particle";
34  default: return "unsupported (" + std::to_string((int)origin) + ")";
35  } // switch
36 } // sim::TruthOriginName()
37 
38 
39 //------------------------------------------------------------------------------
41  switch (ccnc) {
42  case simb::kCC: return "charged weak current";
43  case simb::kNC: return "neutral weak current";
44  default: return "unsupported (" + std::to_string(ccnc) + ")";
45  } // switch
46 } // sim::TruthCCNCname()
47 
48 
49 //------------------------------------------------------------------------------
51 
52  switch (mode) {
53  case 0: return "quasi-elastic";
54  case 1: return "resonant";
55  case 2: return "deep inelastic";
56  case 3: return "coherent";
57  default: return "unknown mode";
58  } // switch
59 
60 } // sim::TruthReactionMode()
61 
62 
63 //------------------------------------------------------------------------------
65  switch (type) {
66  case simb::kUnknownInteraction : return "unknown interaction";
67  case simb::kQE : return "quasi-elastic scattering";
68  case simb::kRes : return "resonant scattering";
69  case simb::kDIS : return "deep inelastic scattering";
70  case simb::kCoh : return "coherent scattering";
71  case simb::kCohElastic : return "coherent elastic scattering";
72  case simb::kElectronScattering : return "electron scattering";
73  case simb::kIMDAnnihilation : return "inverse muon decay annihilation";
74  case simb::kInverseBetaDecay : return "inverse beta decay";
75  case simb::kGlashowResonance : return "Glashow resonance";
76  case simb::kAMNuGamma : return "anomalous neutrino-photon interaction";
77  case simb::kMEC : return "meson exchange current";
78  case simb::kDiffractive : return "diffractive";
79  case simb::kEM : return "electromagnetic";
80  case simb::kWeakMix : return "weak mixing";
81  case simb::kNuanceOffset : return "<nuance offset>";
82  case simb::kCCQE : return "charged current quasi-elastic scattering";
83  case simb::kNCQE : return "neutral current quasi-elastic scattering";
84  case simb::kResCCNuProtonPiPlus : return "resonant charged current neutrino proton pi+";
85  case simb::kResCCNuNeutronPi0 : return "resonant charged current neutrino neutron pi0";
86  case simb::kResCCNuNeutronPiPlus : return "resonant charged current neutrino neutron pi+";
87  case simb::kResNCNuProtonPi0 : return "resonant neutral current neutrino proton pi0";
88  case simb::kResNCNuProtonPiPlus : return "resonant neutral current neutrino proton pi+";
89  case simb::kResNCNuNeutronPi0 : return "resonant neutral current neutrino neutron pi0";
90  case simb::kResNCNuNeutronPiMinus : return "resonant neutral current neutrino neutron pi-";
91  case simb::kResCCNuBarNeutronPiMinus : return "resonant charged current antineutrino neutron pi-";
92  case simb::kResCCNuBarProtonPi0 : return "resonant charged current antineutrino proton pi0";
93  case simb::kResCCNuBarProtonPiMinus : return "resonant charged current antineutrino proton pi-";
94  case simb::kResNCNuBarProtonPi0 : return "resonant neutral current antineutrino proton pi0";
95  case simb::kResNCNuBarProtonPiPlus : return "resonant neutral current antineutrino proton pi+";
96  case simb::kResNCNuBarNeutronPi0 : return "resonant neutral current antineutrino neutron pi0";
97  case simb::kResNCNuBarNeutronPiMinus : return "resonant neutral current antineutrino neutron pi-";
98  case simb::kResCCNuDeltaPlusPiPlus : return "resonant charged current neutrino Delta+ pi+";
99  case simb::kResCCNuDelta2PlusPiMinus : return "resonant charged current neutrino Delta++ pi-";
100  case simb::kResCCNuBarDelta0PiMinus : return "resonant charged current antineutrino Delta0 pi-";
101  case simb::kResCCNuBarDeltaMinusPiPlus : return "resonant charged current antineutrino Delta- pi+";
102  case simb::kResCCNuProtonRhoPlus : return "resonant charged current neutrino proton rho+";
103  case simb::kResCCNuNeutronRhoPlus : return "resonant charged current neutrino neutron rho+";
104  case simb::kResCCNuBarNeutronRhoMinus : return "resonant charged current antineutrino neutron rho-";
105  case simb::kResCCNuBarNeutronRho0 : return "resonant charged current antineutrino neutron rho0";
106  case simb::kResCCNuSigmaPlusKaonPlus : return "resonant charged current neutrino Sigma+ kaon+";
107  case simb::kResCCNuSigmaPlusKaon0 : return "resonant charged current neutrino Sigma+ kaon0";
108  case simb::kResCCNuBarSigmaMinusKaon0 : return "resonant charged current antineutrino Sigma- kaon0";
109  case simb::kResCCNuBarSigma0Kaon0 : return "resonant charged current antineutrino Sigma0 kaon0";
110  case simb::kResCCNuProtonEta : return "resonant charged current neutrino proton eta";
111  case simb::kResCCNuBarNeutronEta : return "resonant charged current antineutrino neutron eta";
112  case simb::kResCCNuKaonPlusLambda0 : return "resonant charged current neutrino Kaon+ Lambda0";
113  case simb::kResCCNuBarKaon0Lambda0 : return "resonant charged current antineutrino kaon0 Lambda0";
114  case simb::kResCCNuProtonPiPlusPiMinus : return "resonant charged current neutrino proton pi+ pi-";
115  case simb::kResCCNuProtonPi0Pi0 : return "resonant charged current neutrino proton pi0 pi0";
116  case simb::kResCCNuBarNeutronPiPlusPiMinus: return "resonant charged current antineutrino neutron pi+ pi-";
117  case simb::kResCCNuBarNeutronPi0Pi0 : return "resonant charged current antineutrino neutron pi0 pi0";
118  case simb::kResCCNuBarProtonPi0Pi0 : return "resonant charged current antineutrino proton pi0 pi0";
119  case simb::kCCDIS : return "charged current deep inelastic scattering";
120  case simb::kNCDIS : return "neutral current deep inelastic scattering";
121  case simb::kUnUsed1 : return "unused (1)";
122  case simb::kUnUsed2 : return "unused (2)";
123  case simb::kCCQEHyperon : return "charged current quasi-elastic scattering with hyperon";
124  case simb::kNCCOH : return "neutral current coherent scattering";
125  case simb::kCCCOH : return "charged current coherent scattering";
126  case simb::kNuElectronElastic : return "electron neutrino elastic";
127  case simb::kInverseMuDecay : return "inverse muon decay";
128  default : return "unsupported (" + std::to_string(type) + ")";
129  } // switch
130 } // sim::TruthInteractionTypeName()
131 
132 
133 //------------------------------------------------------------------------------
135 
136  switch(code) {
137  case -1: return "undefined";
138  case 0: return "initial state";
139  case 1: return "stable final state";
140  case 2: return "intermediate";
141  case 3: return "decayed";
142  case 11: return "nucleon target";
143  case 12: return "pre-fragmentation hadronic state";
144  case 13: return "pre-decay resonant state";
145  case 14: return "hadron in nucleus";
146  case 15: return "final state nuclear remnant";
147  case 16: return "nucleon cluster target";
148  default: return "unknown";
149  } // switch
150 
151 } // sim::ParticleStatusName
152 
153 
154 //------------------------------------------------------------------------------
155 std::string sim::ParticleName(int pigid) {
156  TParticlePDG const* PDGinfo = TDatabasePDG::Instance()->GetParticle(pigid);
157  return PDGinfo? PDGinfo->GetTitle(): ("PDG ID " + std::to_string(pigid));
158 } // sim::ParticleName()
159 
160 
161 //------------------------------------------------------------------------------
163  (int code, RescatterCategory cat /* = RescatterCategory::LArSoftDefault */)
164 {
165  using namespace std::string_literals;
166 
167  if (code == simb::MCParticle::s_uninitialized) return "(unset)"s;
168 
169  switch (cat) {
170  case RescatterCategory::GENIE_INukeFateHA:
172  default:
173  return "unknown category "s + std::to_string(static_cast<int>(cat))
174  + " (code: "s + std::to_string(code) + ")"s;
175  } // switch(code)
176 
177 } // sim::RescatteringName()
178 
179 
180 //------------------------------------------------------------------------------
182 
183 #ifdef _INTRANUKE_FATES_H_ // from GENIE
184 
185  return
186  genie::INukeHadroFates::AsString(static_cast<genie::INukeFateHA_t>(code));
187 
188 #else // !_INTRANUKE_FATES_H_:
189 
190  using namespace std::string_literals;
191 
192  /*
193  * Here we do an horrible thing, that is to copy GENIE code into LArSoft.
194  * By defining `HAS_GENIE`, the proper code branch would be taken instead,
195  * which directly refers to GENIE.
196  * But LArSoft does not do that, because we don't want to be forced to have
197  * GENIE around all the time we use `simb::MCParticle`.
198  *
199  */
200  switch (code) {
201  // from Fermilab UPS GENIE v3_0_0_b4a, `Physics/HadronTransport/INukeHadroFates.h`:
202  case 0 /* kIHAFtUndefined */ : return "** Undefined HA-mode fate **"s; break;
203  case 1 /* kIHAFtNoInteraction */ : return "HA-mode / no interaction"s; break;
204  case 2 /* kIHAFtCEx */ : return "HA-mode / cex"s; break;
205  case 3 /* kIHAFtElas */ : return "HA-mode / elas"s; break;
206  case 4 /* kIHAFtInelas */ : return "HA-mode / inelas"s; break;
207  case 5 /* kIHAFtAbs */ : return "HA-mode / abs"s; break;
208  case 6 /* kIHAFtKo */ : return "HA-mode / knock-out"s; break;
209  case 7 /* kIHAFtCmp */ : return "HA-mode / compound"s; break;
210  case 8 /* kIHAFtPiProd */ : return "HA-mode / pi-production"s ; break;
211  case 9 /* kIHAFtInclPip */ : return "HA-mode / pi-prod incl pi+"s; break;
212  case 10 /* kIHAFtInclPim */ : return "HA-mode / pi-prod incl pi-"s; break;
213  case 11 /* kIHAFtInclPi0 */ : return "HA-mode / pi-prod incl pi0"s; break;
214  case 12 /* kIHAFtDCEx */ : return "HA-mode / dcex"s; break;
215  default:
216  return "unknown ("s + std::to_string(code) + ")"s;
217  } // switch(code)
218 
219 #endif // ?_INTRANUKE_FATES_H_
220 
221 } // sim::GENIE_INukeFateHA_RescatteringName()
222 
223 //------------------------------------------------------------------------------
neutral current quasi-elastic
Definition: MCNeutrino.h:97
RescatterCategory
Possible sources of rescattering code (which is generator-dependent).
Definition: MCDumperUtils.h:39
resonant charged current, nubar p -> nubar n pi+
Definition: MCNeutrino.h:109
resonant neutral current, nu p -> nu p pi0
Definition: MCNeutrino.h:101
charged current deep inelastic scatter
Definition: MCNeutrino.h:134
std::string TruthInteractionTypeName(int type)
resonant charged current, nubar p -> l+ p pi-
Definition: MCNeutrino.h:107
static const int s_uninitialized
Definition: MCParticle.h:28
neutrino electron elastic scatter
Definition: MCNeutrino.h:140
std::string string
Definition: nybbler.cc:12
resonant charged current, nubar p -> l+ n pi0
Definition: MCNeutrino.h:106
enum simb::_ev_origin Origin_t
event origin types
offset to account for adding in Nuance codes to this enum
Definition: MCNeutrino.h:95
std::string TruthCCNCname(int ccnc)
std::string RescatteringName(int code, RescatterCategory cat=RescatterCategory::LArSoftDefault)
The name of the specified rescattering code.
charged current quasi-elastic
Definition: MCNeutrino.h:96
Particle class.
resonant charged current, nubar p -> nubar p pi0
Definition: MCNeutrino.h:108
resonant charged current, nu n -> l- p pi0
Definition: MCNeutrino.h:99
std::string TruthReactionMode(int mode)
Returns the "mode" of the reaction (a lesser version of interaction type).
resonant neutral current, nu n -> nu n pi0
Definition: MCNeutrino.h:103
resonant charged current, nu n -> l- n pi+
Definition: MCNeutrino.h:100
single particles thrown at the detector
Definition: MCTruth.h:26
resonant charged current, nubar n -> nubar p pi-
Definition: MCNeutrino.h:111
std::string ParticleName(int pigid)
Returns a string with the name of particle the specified with PDG ID.
CodeOutputInterface * code
charged current deep inelastic scatter
Definition: MCNeutrino.h:133
resonant charged current, nu p -> l- p pi+
Definition: MCNeutrino.h:98
n.b.: this group is similar but not quite, entirely unlike GENIE ScatteringType convention ...
Definition: MCNeutrino.h:80
std::string TruthOriginName(simb::Origin_t origin)
Returns a string representing the specified process origin.
charged current coherent pion
Definition: MCNeutrino.h:139
resonant neutral current, nu n -> nu p pi-
Definition: MCNeutrino.h:104
std::string GENIE_INukeFateHA_RescatteringName(int code)
Description of a rescattering code from GENIE INukeFateHA_t.
static string AsString(INukeFateHN_t fate)
inverse muon decay
Definition: MCNeutrino.h:141
resonant charged current, nubar n -> l+ n pi-
Definition: MCNeutrino.h:105
Supernova neutrinos.
Definition: MCTruth.h:25
Utility functions to print MC truth information.
resonant charged current, nubar n -> nubar n pi0
Definition: MCNeutrino.h:110
std::string ParticleStatusName(int code)
Describes the status of a particle (simb::MCParticle::StatusCode()).
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString * s
Definition: config.cpp:1042
resonant neutral current, nu p -> nu p pi+
Definition: MCNeutrino.h:102
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
Cosmic rays.
Definition: MCTruth.h:24
Beam neutrinos.
Definition: MCTruth.h:23