LBNENuWeight.cc
Go to the documentation of this file.
1 // $Id: LBNENuWeight.cc,v 1.1 2011/07/13 16:20:52 loiacono Exp $
2 
3 #include <iostream>
4 #include <cmath>
5 #include "Rtypes.h"
6 
7 #include "G4ParticleTable.hh"
8 
9 
10 #include "LBNENuWeight.hh"
11 #include "LBNEParticleCode.hh"
12 
13 const double rdet = 100.; //in cm
14 
15 using namespace std;
16 
18 {
19 }
20 
22 {
23 }
24 
26  const vector<double> xdet,
27  double& nu_wght,
28  double& nu_energy)
29 {
30  //assumes units are GeV and cm
31 
32  double parent_mass=0.;
33  G4ParticleTable* pTable=G4ParticleTable::GetParticleTable();
34  string parent_name =
36  parent_mass=pTable->FindParticle(parent_name)->GetPDGMass()/CLHEP::GeV;
37 
38  double parent_energy = sqrt(nudata->pdPx*nudata->pdPx +
39  nudata->pdPy*nudata->pdPy +
40  nudata->pdPz*nudata->pdPz +
41  parent_mass*parent_mass);
42  double gamma = parent_energy / parent_mass;
43  double gamma_sqr = gamma*gamma;
44  double beta_mag = sqrt((gamma_sqr-1.)/gamma_sqr);
45 
46  double enuzr = nudata->Necm;
47 
48  double rad = sqrt((xdet[0]-nudata->Vx)*(xdet[0]-nudata->Vx) +
49  (xdet[1]-nudata->Vy)*(xdet[1]-nudata->Vy) +
50  (xdet[2]-nudata->Vz)*(xdet[2]-nudata->Vz));
51 
52  double parentp = sqrt((nudata->pdPx*nudata->pdPx)+
53  (nudata->pdPy*nudata->pdPy)+
54  (nudata->pdPz*nudata->pdPz));
55  double costh_pardet = (nudata->pdPx*(xdet[0]-nudata->Vx) +
56  nudata->pdPy*(xdet[1]-nudata->Vy) +
57  nudata->pdPz*(xdet[2]-nudata->Vz))/(parentp*rad);
58 
59  if (costh_pardet>1.) costh_pardet = 1.;
60  else if (costh_pardet<-1.) costh_pardet = -1.;
61  double theta_pardet = acos(costh_pardet);
62 
63  double emrat = 1./(gamma*(1. - beta_mag * cos(theta_pardet)));
64 
65  nu_energy = emrat*enuzr;
66 
67  double sangdet = (rdet*rdet /(rad*rad)/ 4.);
68 
69  nu_wght = sangdet * emrat * emrat;
70 
71  //done for all except polarized muon
72  // in which case need to modify weight
73  if (nudata->ptype == LBNEParticleCode::kMuonPlus ||
75  {
76  //boost new neutrino to mu decay cm
77  double beta[3];
78  double p_nu[3]; //nu momentum
79  beta[0]=nudata->pdPx / parent_energy;
80  beta[1]=nudata->pdPy / parent_energy;
81  beta[2]=nudata->pdPz / parent_energy;
82 
83  p_nu[0] = (xdet[0]- nudata->Vx) * nu_energy / rad;
84  p_nu[1] = (xdet[1]- nudata->Vy) * nu_energy / rad;
85  p_nu[2] = (xdet[2]- nudata->Vz) * nu_energy / rad;
86 
87  double partial = gamma*(beta[0]*p_nu[0]+
88  beta[1]*p_nu[1]+
89  beta[2]*p_nu[2]);
90  partial = nu_energy-partial / (gamma+1.);
91  double p_dcm_nu[4];
92  for (int i=0;i<3;i++) p_dcm_nu[i]=p_nu[i]-beta[i]*gamma*partial;
93  p_dcm_nu[3]=0.;
94  for (int i=0;i<3;i++) p_dcm_nu[3]+=p_dcm_nu[i]*p_dcm_nu[i];
95  p_dcm_nu[3]=sqrt(p_dcm_nu[3]);
96 
97  //boost parent of mu to mu production cm
98  gamma=nudata->ppenergy / parent_mass;
99  beta[0] = nudata->ppdxdz * nudata->pppz / nudata->ppenergy;
100  beta[1] = nudata->ppdydz * nudata->pppz / nudata->ppenergy;
101  beta[2] = nudata->pppz / nudata->ppenergy;
102  partial = gamma*(beta[0]*nudata->muparpx+
103  beta[1]*nudata->muparpy+
104  beta[2]*nudata->muparpz);
105  partial = nudata->mupare - partial / (gamma+1.);
106  double p_pcm_mp[4];
107  p_pcm_mp[0]=nudata->muparpx-beta[0]*gamma*partial;
108  p_pcm_mp[1]=nudata->muparpy-beta[1]*gamma*partial;
109  p_pcm_mp[2]=nudata->muparpz-beta[2]*gamma*partial;
110  p_pcm_mp[3]=0.;
111  for (int i=0;i<3;i++) p_pcm_mp[3]+=p_pcm_mp[i]*p_pcm_mp[i];
112  p_pcm_mp[3]=sqrt(p_pcm_mp[3]);
113 
114  double wt_ratio = 1.;
115  //have to check p_pcm_mp
116  //it can be 0 if mupar..=0. (I guess muons created in target??)
117  if (p_pcm_mp[3] != 0. ) {
118  //calc new decay angle w.r.t. (anti)spin direction
119  double costh = (p_dcm_nu[0]*p_pcm_mp[0]+
120  p_dcm_nu[1]*p_pcm_mp[1]+
121  p_dcm_nu[2]*p_pcm_mp[2])/(p_dcm_nu[3]*p_pcm_mp[3]);
122 
123  if (costh>1.) costh = 1.;
124  else if (costh<-1.) costh = -1.;
125 
126  //calc relative weight due to angle difference
127  if (nudata->Ntype == LBNEParticleCode::kElectronNeutrino ||
129  wt_ratio = 1.-costh;
130  else if (nudata->Ntype == LBNEParticleCode::kMuonNeutrino ||
132  double mumass = pTable->FindParticle("mu+")->GetPDGMass()/CLHEP::GeV;
133  double xnu = 2.* enuzr / mumass;
134  wt_ratio = ( (3.-2.*xnu) - (1.-2.*xnu)*costh ) / (3.-2.*xnu);
135  } else {
136  cout << "NuWeight:: Bad neutrino type"<<endl;
137  }
138  }
139  nu_wght *= wt_ratio;
140  }
141 
142  return nu_wght;
143 }
double GetWeight(const LBNEDataNtp_t *nudata, const std::vector< double > xdet, double &nu_wght, double &nu_energy)
Definition: LBNENuWeight.cc:25
STL namespace.
const double rdet
Definition: LBNENuWeight.cc:13
Definition: nudata.h:21
LBNEParticleCode_t IntToEnum(G4int particleInt)
G4String AsString(LBNEParticleCode_t pCode)
QTextStream & endl(QTextStream &s)