All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KaonParent.cxx
Go to the documentation of this file.
1 #include "KaonParent.h"
2 #include <cassert>
3 
4 evgen::ldm::KaonParent::KaonParent(const simb::MCFlux &flux) {
5  // set the particle codes
6  switch (flux.fndecay) {
7  case 1 /*K0L -> nue pi- e+ */:
8  case 2 /*K0L -> nuebar pi+ e-*/:
9  case 3 /* K0L -> numu pi- mu+*/:
10  case 4 /*K0L -> numubar pi+ mu-*/:
11  kaon_pdg = 130;
12  break;
13  case 5 /*K+ -> numu mu+*/:
14  case 6 /*K+ -> nue pi0 e+*/:
15  case 7 /*K+ -> numu pi0 mu+*/:
16  kaon_pdg = 321;
17  break;
18  case 8 /*K- -> numubar mu-*/:
19  case 9 /*K- -> nuebar pi0 e-*/:
20  case 10 /*K- -> numubar pi0 mu-*/:
21  kaon_pdg = -321;
22  break;
23  default:
24  kaon_pdg = 0;
25  return; // not a kaon decay
26  }
27  mode = flux.fndecay;
28 
29  TVector3 pos3 = TVector3(flux.fvx, flux.fvy, flux.fvz);
30  double time = flux.fxpoint; /* README: the MCFlux for some reason does not have any time variable, so I have chosen to canibalize this one,
31  which according to documentation is just for debugging. (I am very sorry). */
32 
33  pos.SetVect(pos3);
34  pos.SetT(time);
35 
36 
37  // Get the mass from the available kinematics in the MCFlux
38 
39  // Get the magnitue of the beam slope drdz^2
40  double drdz2 = flux.fppdxdz*flux.fppdxdz + flux.fppdydz*flux.fppdydz;
41 
42  // the total momentum is p/cos(theta) = p * sqrt(1 + drdz2)
43  double production_momentum = flux.fpppz * sqrt(1 + drdz2);
44 
45  // And then we can use the total energy/momentum to get the mass
46  //
47  // This operation is dangerous numerically because for large energy we are relying
48  // on the cancellation of two large numbers to get a small number. I have tested that
49  // this gives precise results to 6 digits up to the energies relevant for numi (50GeV),
50  // provided one uses doubles.
51  double mass = sqrt(flux.fppenergy*flux.fppenergy - production_momentum*production_momentum);
52 
53  mom.SetVectM(TVector3(flux.fpdpx, flux.fpdpy, flux.fpdpz), mass);
54 
55  weight = flux.fnimpwt;
56 }
57 
TLorentzVector pos
Definition: KaonParent.h:12
TLorentzVector mom
Definition: KaonParent.h:13
float mass
Definition: dedx.py:47