31 hbar = 6.582119569e-16;
74 if (parent_mass < childA_mass + childB_mass)
return -1.;
76 return sqrt(parent_mass * parent_mass * parent_mass * parent_mass
77 -2 * parent_mass * parent_mass * childA_mass * childA_mass
78 -2 * parent_mass * parent_mass * childB_mass * childB_mass
79 + childA_mass * childA_mass * childA_mass * childA_mass
80 + childB_mass * childB_mass * childB_mass * childB_mass
81 -2 * childA_mass * childA_mass * childB_mass * childB_mass) / ( 2 * parent_mass );
103 double& lab_frame_p_out,
double& costh_rest_out,
double& wgt)
106 lab_frame_p_out = 0.;
110 double beta = boost.Mag();
111 double gamma = 1. / sqrt(1 - beta*beta);
112 double E_rest = sqrt(rest_frame_p*rest_frame_p + M*M);
115 double costh_lab = boost.Unit().Dot(dir.Unit());
116 double sinth_lab_sq = 1 - costh_lab*costh_lab;
122 auto costh_rest = [costh_lab, sinth_lab_sq, beta, gamma, M, rest_frame_p, E_rest](
int SIGN) {
return -(-SIGN * costh_lab*\
123 sqrt(-M*M + (E_rest*E_rest)/(gamma*gamma) + (M*M)*(beta*beta)*(costh_lab*costh_lab)) \
124 +E_rest*beta*gamma*sinth_lab_sq) / \
125 (rest_frame_p*gamma*(1 - beta*beta*costh_lab*costh_lab)); };
127 double costh_rest_plus = costh_rest(1);
128 double costh_rest_minus = costh_rest(-1);
130 auto lab_frame_p = [costh_lab, beta, gamma, M, E_rest](
int SIGN) {
return (1. / (1 - beta*beta * costh_lab*costh_lab)) *\
131 (E_rest * beta * costh_lab / gamma \
132 + SIGN * sqrt(-M*M + (E_rest*E_rest)/(gamma*gamma) + M*M * beta*beta * costh_lab*costh_lab)); };
134 double lab_frame_p_plus = lab_frame_p(1);
135 double lab_frame_p_minus = lab_frame_p(-1);
137 bool plus_valid = !isnan(lab_frame_p_plus) && lab_frame_p_plus > 0.;
138 bool minus_valid = !isnan(lab_frame_p_minus) && lab_frame_p_minus > 0.;
141 auto wgtf = [costh_lab, rest_frame_p, E_rest, M, beta, gamma](
double p_lab,
int SIGN) {
142 double E_lab = sqrt(p_lab*p_lab + M*M);
144 double dp_labdp_rest = (rest_frame_p / (E_rest * gamma)) * (beta*costh_lab +\
145 SIGN*E_rest / (gamma * sqrt(E_rest*E_rest / (gamma*gamma) - M*M + M*M * beta*beta * costh_lab*costh_lab))) /\
146 (1 - beta*beta * costh_lab*costh_lab);
147 return (E_rest / E_lab) * (p_lab*p_lab / (rest_frame_p*rest_frame_p)) *
abs(dp_labdp_rest);
150 double plus_wgt = plus_valid ? wgtf(lab_frame_p_plus, 1) : 0.;
151 double minus_wgt = minus_valid ? wgtf(lab_frame_p_minus, -1) : 0.;
154 double threshold = 0.5;
157 bool select_plus = plus_valid && (!minus_valid || (rand >= threshold));
158 bool select_minus = minus_valid && (!plus_valid || (rand < threshold));
161 std::cout <<
"COSTH LAB: " << costh_lab << std::endl;
162 std::cout <<
"PREST: " << rest_frame_p << std::endl;
164 std::cout <<
"BETA: " << beta << std::endl;
165 std::cout <<
"GAMMA: " << gamma << std::endl;
167 std::cout <<
"COSTH REST PLUS: " << costh_rest_plus << std::endl;
168 std::cout <<
"COSTH REST MINUS: " << costh_rest_minus << std::endl;
169 std::cout <<
"PLAB PLUS: " << lab_frame_p_plus << std::endl;
170 std::cout <<
"PLAB MINUS: " << lab_frame_p_minus << std::endl;
171 std::cout <<
"WGT PLUS: " << plus_wgt << std::endl;
172 std::cout <<
"WGT MINUS: " << minus_wgt << std::endl;
174 if (select_plus)
std::cout <<
"SELECTED PLUS" << std::endl;
175 else if (select_minus)
std::cout <<
"SELECTED MINUS" << std::endl;
176 else std::cout <<
"SELECTED NONE" << std::endl;
179 costh_rest_out = costh_rest_plus;
180 lab_frame_p_out = lab_frame_p_plus;
181 wgt = plus_wgt * (plus_valid + minus_valid);
183 else if (select_minus) {
184 costh_rest_out = costh_rest_minus;
185 lab_frame_p_out = lab_frame_p_minus;
186 wgt = minus_wgt * (plus_valid + minus_valid);
197 if (parentE - parentM < 1
e-4)
return 0.;
203 double gamma = parentE / parentM;
204 double beta = sqrt(1. - 1. / (gamma*gamma));
206 double rest_prtlE = sqrt(prtlM*prtlM + rest_prtlP*rest_prtlP);
208 return sqrt(prtlM*prtlM - rest_prtlE * rest_prtlE / (gamma*gamma)) / (prtlM*beta);
217 double gamma = parentE / parentM;
218 double beta = sqrt(1. - 1. / (gamma*gamma));
219 TVector3
dir(0., 0., 1.);
220 TVector3 boost(0., 0., beta);
225 double lab_frame_p_out, costh_rest_out, wgt;
227 lab_frame_p_out, costh_rest_out, wgt);
231 double lab_prtlE = sqrt(lab_frame_p_out*lab_frame_p_out + prtlM*prtlM);
251 std::cerr <<
"BAD secondary pdg: " << pdg << std::endl;
252 std::cout <<
"BAD secondary pdg: " << pdg << std::endl;
double abs_VtsVtd_squared
BEGIN_PROLOG could also be cerr
double secPDG2Mass(int pdg)
EResult err(const char *call)
double twobody_momentum(double parent_mass, double childA_mass, double childB_mass)
static void Configure(const fhicl::ParameterSet &p)
double minKinematicCosTheta(double parentM, double secM, double prtlM, double parentE)
static const Constants & Instance()
double rel_VtsVtd_squared
double forwardPrtlEnergy(double parentM, double secM, double prtlM, double parentE)
static Constants & InstanceMut()
BEGIN_PROLOG could also be cout
int calcPrtlRayWgt(double rest_frame_p, double M, TVector3 dir, TVector3 boost, double rand, double &lab_frame_p_out, double &costh_rest_out, double &wgt)