TruthText.cxx
Go to the documentation of this file.
2 
3 // This file is adapted from NOvA's EventDisplay/SimulationDrawer.cxx and
4 // Style.cxx
5 
7 
8 namespace evd
9 {
10  // -------------------------------------------------------------------------
11  /// Convert PDG code to a latex string (root-style)
13  {
14  switch(pdgcode){
15  case 22: return "#gamma";
16  case -11: return "e^{+}";
17  case 11: return "e^{-}";
18  case 13: return "#mu";
19  case -15: return "#bar{#tau}";
20  case 15: return "#tau";
21  case -13: return "#bar{#mu}";
22  case 12: return "#nu_{e}";
23  case 14: return "#nu_{#mu}";
24  case 16: return "#nu_{#tau}";
25  case -12: return "#bar{#nu}_{e}";
26  case -14: return "#bar{#nu}_{#mu}";
27  case -16: return "#bar{#nu}_{#tau}";
28  case 111: return "#pi^{0}";
29  case 211: return "#pi^{+}";
30  case -211: return "#pi^{-}";;
31  case 221: return "#eta";
32  case 331: return "#eta'";
33  case 130: return "K^{0}_{L}";
34  case 310: return "K^{0}_{S}";
35  case 311: return "K^{0}";
36  case -311: return "#bar{K}^{0}";
37  case 321: return "K^{+}";
38  case -321: return "K^{-}";
39  case 2112: return "n";
40  case 2212: return "p";
41  case -2112: return "#bar{n}";
42  case -2212: return "#bar{p}";
43  case 2224: return "#Delta^{++}";
44  case 3122: return "#Lambda^{0}";
45  case 3222: return "#Sigma^{+}";
46  case -3222: return "#Sigma^{-}";
47 
48  case 1000010020: return "^{2}H";
49  case 1000010030: return "^{3}H";
50  case 1000020030: return "^{3}He";
51  case 1000020040: return "^{4}He";
52  case 1000040070: return "^{7}Be";
53  case 1000040080: return "^{8}Be";
54  case 1000040100: return "^{10}Be";
55  case 1000050090: return "^{9}B";
56  case 1000050100: return "^{10}B";
57  case 1000050110: return "^{11}B";
58  case 1000060100: return "^{10}C";
59  case 1000060110: return "^{11}C";
60  case 1000060120: return "^{12}C";
61  case 1000060130: return "^{13}C";
62  case 1000060140: return "^{14}C";
63  case 1000070150: return "^{15}N";
64  case 1000100220: return "^{22}Ne";
65  case 1000140300: return "^{30}Si";
66  case 1000150330: return "^{33}P";
67  case 1000160340: return "^{34}S";
68  case 1000160350: return "^{35}S";
69  case 1000160360: return "^{36}S";
70  case 1000170350: return "^{35}Cl";
71  case 1000170360: return "^{36}Cl";
72  case 1000170370: return "^{37}Cl";
73  case 1000180380: return "^{38}Ar";
74  case 1000180400: return "^{40}Ar";
75  case 1000210480: return "^{48}Sc";
76  case 1000260560: return "^{56}Fe";
77  case 1000220480: return "^{48}Ti";
78  case 1000080160: return "^{16}O";
79  case 1000070140: return "^{14}N";
80  case 1000110230: return "^{23}Na";
81  case 1000130270: return "^{27}Al";
82  case 1000140280: return "^{28}Si";
83  case 1000200400: return "^{40}Ca";
84  case 1000561370: return "^{137}Ba";
85  default:
86  static char buf[256];
87  sprintf(buf,"X_{%d}", pdgcode);
88  return buf;
89  }
90  return 0;
91  }
92 
93  // -------------------------------------------------------------------------
95  {
96  return a+"<sup>"+b+"</sup>";
97  }
98 
99  // -------------------------------------------------------------------------
101  {
102  return a+"<sub>"+b+"</sub>";
103  }
104 
105  // -------------------------------------------------------------------------
107  {
108  // NB we escape the quote marks in the CSS because we know this is going to
109  // be served as CSS and we don't sanitize it there.
110  return "<span style=\\\"text-decoration:overline\\\">"+x+"</span>";
111  }
112 
113  // -------------------------------------------------------------------------
114  std::string nucl(const std::string& A, const std::string& elem)
115  {
116  return "<sup>"+A+"</sup>"+elem;
117  }
118 
119  // -------------------------------------------------------------------------
120  /// HTML entities style
122  {
123  // NB we escape the quote marks in the CSS because we know this is going to
124  // be served as CSS and we don't sanitize it there.
125  switch(pdgcode){
126  case 22: return "&gamma;";
127  case -11: return sup("e", "+");
128  case 11: return sup("e", "-");
129  case 13: return "&mu;";
130  case -15: return bar("&tau;");
131  case 15: return "&tau;";
132  case -13: return bar("&mu;");
133  case 12: return sub("&nu;", "e");
134  case 14: return sub("&nu;", "&mu;");
135  case 16: return sub("&nu;", "&tau;");
136  case -12: return sub(bar("&nu;"), "e");
137  case -14: return sub(bar("&nu;"), "&mu;");
138  case -16: return sub(bar("&nu;"), "&tau;");
139  case 111: return sup("&pi;", "0");
140  case 211: return sup("&pi;", "+");
141  case -211: return sup("&pi;", "-");
142  case 221: return "&eta;";
143  case 331: return "&eta;'";
144  case 130: return sub(sup("K", "0"), "L");
145  case 310: return sub(sup("K", "0"), "L");
146  case 311: return sup("K", "0");
147  case -311: return sup(bar("K"), "0");
148  case 321: return sup("K", "+");
149  case -321: return sup("K", "-");
150  case 2112: return "n";
151  case 2212: return "p";
152  case -2112: return bar("n");
153  case -2212: return bar("p");
154  case 2224: return sup("&Delta;", "++");
155  case 3122: return sup("&Lambda;", "0");
156  case 3222: return sup("&Sigma;", "+");
157  case -3222: return sup("&Sigma;", "-");
158 
159  case 1000010020: return nucl("2", "H");
160  case 1000010030: return nucl("3", "H");
161  case 1000020030: return nucl("3", "He");
162  case 1000020040: return nucl("4", "He");
163  case 1000040070: return nucl("7", "Be");
164  case 1000040080: return nucl("8", "Be");
165  case 1000040100: return nucl("10", "Be");
166  case 1000050090: return nucl("9", "B");
167  case 1000050100: return nucl("10", "B");
168  case 1000050110: return nucl("11", "B");
169  case 1000060100: return nucl("10", "C");
170  case 1000060110: return nucl("11", "C");
171  case 1000060120: return nucl("12", "C");
172  case 1000060130: return nucl("13", "C");
173  case 1000060140: return nucl("14", "C");
174  case 1000070150: return nucl("15", "N");
175  case 1000100220: return nucl("22", "Ne");
176  case 1000140300: return nucl("30", "Si");
177  case 1000150330: return nucl("33", "P");
178  case 1000160340: return nucl("34", "S");
179  case 1000160350: return nucl("35", "S");
180  case 1000160360: return nucl("36", "S");
181  case 1000170350: return nucl("35", "Cl");
182  case 1000170360: return nucl("36", "Cl");
183  case 1000170370: return nucl("37", "Cl");
184  case 1000180380: return nucl("38", "Ar");
185  case 1000180400: return nucl("40", "Ar");
186  case 1000210480: return nucl("48", "Sc");
187  case 1000260560: return nucl("56", "Fe");
188  case 1000220480: return nucl("48", "Ti");
189  case 1000080160: return nucl("16", "O");
190  case 1000070140: return nucl("14", "N");
191  case 1000110230: return nucl("23", "Na");
192  case 1000130270: return nucl("27", "Al");
193  case 1000140280: return nucl("28", "Si");
194  case 1000200400: return nucl("40", "Ca");
195  case 1000561370: return nucl("137", "Ba");
196  default: return sub("X", std::to_string(pdgcode));
197  }
198  return 0;
199  }
200 
201  // --------------------------------------------------------------------------
203  {
204  switch(iType){
205  case simb::kQE:
206  case simb::kCCQE:
207  return " (QE)";
208 
209  case simb::kRes:
216  return " (RES)";
217 
218  case simb::kDIS:
219  case simb::kCCDIS:
220  return " (DIS)";
221 
222  case simb::kCoh:
223  case simb::kCCCOH:
224  return " (COH)";
225 
226  case simb::kNCQE:
227  case simb::kNCDIS:
236  return " (NC)";
237 
239  return " (ES)";
240 
242  return " (IBD)";
243 
244  default: // simb::kNuElectronElastic and simb::kInverseMuDecay
245  return "";
246  }
247  }
248 
249  // -------------------------------------------------------------------------
251  {
253  std::string incoming;
254  std::string outgoing;
255  // Label cosmic rays -- others are pretty obvious
256  if(truth.Origin() == simb::kCosmicRay) origin = "c-ray: ";
257 
258  for(int j = 0; j < truth.NParticles(); ++j){
259  const simb::MCParticle& p = truth.GetParticle(j);
260 
261  const unsigned int bufsize = 4096;
262  char buf[bufsize];
263 
264  if(p.P() > 0.05){
265  snprintf(buf, bufsize, "%s&nbsp;[%.1f GeV/c]",
266  HTMLName(p.PdgCode()).c_str(), p.P());
267  }
268  else{
269  snprintf(buf, bufsize, "%s",
270  HTMLName(p.PdgCode()).c_str());
271  }
272  if(p.StatusCode() == 0){
273  if(!incoming.empty()) incoming += " + ";
274  incoming += buf;
275  }
276  if(p.StatusCode() == 1){
277  if(!outgoing.empty()) outgoing += " + ";
278  outgoing += buf;
279  }
280  } // loop on j particles
281 
282  if(origin.empty() && incoming.empty()) return outgoing;
283 
285  return origin+incoming+" &rarr; "+outgoing+suffix;
286  }
287 } // end namespace
std::string bar(const std::string &x)
Definition: TruthText.cxx:106
neutral current quasi-elastic
Definition: MCNeutrino.h:97
resonant charged current, nubar p -> nubar n pi+
Definition: MCNeutrino.h:109
int PdgCode() const
Definition: MCParticle.h:212
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
resonant neutral current, nu p -> nu p pi0
Definition: MCNeutrino.h:101
charged current deep inelastic scatter
Definition: MCNeutrino.h:134
resonant charged current, nubar p -> l+ p pi-
Definition: MCNeutrino.h:107
std::string string
Definition: nybbler.cc:12
resonant charged current, nubar p -> l+ n pi0
Definition: MCNeutrino.h:106
simb::Origin_t Origin() const
Definition: MCTruth.h:74
int StatusCode() const
Definition: MCParticle.h:211
int NParticles() const
Definition: MCTruth.h:75
charged current quasi-elastic
Definition: MCNeutrino.h:96
std::string HTMLName(int pdgcode)
HTML entities style.
Definition: TruthText.cxx:121
resonant charged current, nubar p -> nubar p pi0
Definition: MCNeutrino.h:108
resonant charged current, nu n -> l- p pi0
Definition: MCNeutrino.h:99
int InteractionType() const
Definition: MCNeutrino.h:150
resonant neutral current, nu n -> nu n pi0
Definition: MCNeutrino.h:103
LArSoft includes.
Definition: InfoTransfer.h:33
resonant charged current, nu n -> l- n pi+
Definition: MCNeutrino.h:100
resonant charged current, nubar n -> nubar p pi-
Definition: MCNeutrino.h:111
const double a
double P(const int i=0) const
Definition: MCParticle.h:234
p
Definition: test.py:223
std::string ShortInteractionSuffix(int iType)
Definition: TruthText.cxx:202
charged current deep inelastic scatter
Definition: MCNeutrino.h:133
resonant charged current, nu p -> l- p pi+
Definition: MCNeutrino.h:98
const simb::MCParticle & GetParticle(int i) const
Definition: MCTruth.h:76
charged current coherent pion
Definition: MCNeutrino.h:139
resonant neutral current, nu n -> nu p pi-
Definition: MCNeutrino.h:104
std::string MCTruthShortText(const simb::MCTruth &truth)
Definition: TruthText.cxx:250
resonant charged current, nubar n -> l+ n pi-
Definition: MCNeutrino.h:105
static bool * b
Definition: config.cpp:1043
resonant charged current, nubar n -> nubar n pi0
Definition: MCNeutrino.h:110
std::string nucl(const std::string &A, const std::string &elem)
Definition: TruthText.cxx:114
list x
Definition: train.py:276
Event generator information.
Definition: MCTruth.h:32
std::string sup(const std::string &a, const std::string &b)
Definition: TruthText.cxx:94
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
std::string LatexName(int pdgcode)
Convert PDG code to a latex string (root-style)
Definition: TruthText.cxx:12
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
std::string sub(const std::string &a, const std::string &b)
Definition: TruthText.cxx:100