3 const double rdet = 100.;
19 int likely_ion = 100000000;
22 int pdg = nu->ancestor[size-2].pdg;
24 if(pdg>likely_ion || pdg<-1*likely_ion){
25 std::cout<<
"Not handling ions yet, pdg: "<<pdg<<
std::endl;
29 mpar =
particle->GetParticle(pdg)->Mass();
32 double ppar = sqrt(
pow(nu->decay.pdpx,2) +
pow(nu->decay.pdpy,2) +
pow(nu->decay.pdpz,2) );
33 double epar = sqrt(
pow(ppar,2)+
pow(mpar,2));
34 double gamma = epar / mpar;
38 double cos_theta = ( (nu->decay.pdpx)*(
xdet-nu->decay.vx) + (nu->decay.pdpy)*(
ydet-nu->decay.vy) + (nu->decay.pdpz)*(
zdet-nu->decay.vz) )/ (ppar*rr);
40 if(cos_theta > 1 || cos_theta < -1){
41 std::cout<<
"Cosine of neutrino not allowed: "<<cos_theta<<
std::endl;
44 double MM = 1.0/(gamma*(1.0-beta*cos_theta));
51 if (pdg == 13 || pdg == -13){
55 vbeta[0] = nu->decay.pdpx / epar;
56 vbeta[1] = nu->decay.pdpy / epar;
57 vbeta[2] = nu->decay.pdpz / epar;
64 double partial = gamma*(vbeta[0]*p_nu[0]+vbeta[1]*p_nu[1]+vbeta[2]*p_nu[2]);
68 for (
int i=0;i<3;i++) p_dcm_nu[i]=p_nu[i]-vbeta[i]*gamma*partial;
70 for (
int i=0;i<3;i++) p_dcm_nu[3]+=p_dcm_nu[i]*p_dcm_nu[i];
71 p_dcm_nu[3]=sqrt(p_dcm_nu[3]);
74 gamma = nu->decay.ppenergy / mpar;
75 vbeta[0] = nu->decay.ppdxdz * nu->decay.pppz / nu->decay.ppenergy;
76 vbeta[1] = nu->decay.ppdydz * nu->decay.pppz / nu->decay.ppenergy;
77 vbeta[2] = nu->decay.pppz / nu->decay.ppenergy;
78 partial = gamma*(vbeta[0]*nu->decay.muparpx+vbeta[1]*nu->decay.muparpy+vbeta[2]*nu->decay.muparpz);
79 partial = nu->decay.mupare - partial / (gamma+1.);
82 p_pcm_mp[0]=nu->decay.muparpx-vbeta[0]*gamma*partial;
83 p_pcm_mp[1]=nu->decay.muparpy-vbeta[1]*gamma*partial;
84 p_pcm_mp[2]=nu->decay.muparpz-vbeta[2]*gamma*partial;
86 for (
int i=0;i<3;i++) p_pcm_mp[3]+=p_pcm_mp[i]*p_pcm_mp[i];
87 p_pcm_mp[3]=sqrt(p_pcm_mp[3]);
92 if (p_pcm_mp[3] != 0. ) {
94 double costh = (p_dcm_nu[0]*p_pcm_mp[0]+
95 p_dcm_nu[1]*p_pcm_mp[1]+
96 p_dcm_nu[2]*p_pcm_mp[2])/(p_dcm_nu[3]*p_pcm_mp[3]);
98 if (costh>1.) costh = 1.;
99 else if (costh<-1.) costh = -1.;
102 if(nu->decay.ntype == 12 || nu->decay.ntype == -12){
105 else if(nu->decay.ntype == 14 || nu->decay.ntype == -14){
106 double mumass =
particle->GetParticle(13)->Mass();
107 double xnu = 2.* nu->decay.necm / mumass;
108 wt_ratio = ( (3.-2.*xnu) - (1.-2.*xnu)*costh ) / (3.-2.*xnu);
110 std::cout <<
"NuWeight:: Bad neutrino type"<<
std::endl;
113 NuWeight::wgt *= wt_ratio;
double beta(double KE, const simb::MCParticle *part)
void calculate_weight(bsim::Dk2Nu *nu)
Calculate weight based on dk2nu entry. After this, enu and wgt have meaningful values.
NuWeight(std::vector< double > &posdet)
The constructor has to have the position of the detector.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
double gamma(double KE, const simb::MCParticle *part)
QTextStream & endl(QTextStream &s)