2 #include "dk2nu/tree/NuChoice.h" 3 #include "dk2nu/tree/calcLocationWeights.h" 4 #include "dk2nu/tree/dk2nu.h" 5 #include "dk2nu/tree/dkmeta.h" 18 fDk2NuTree =
dynamic_cast<TTree*
>(rootFile->Get(
"dk2nuTree"));
19 fDkMetaTree =
dynamic_cast<TTree*
>(rootFile->Get(
"dkmetaTree"));
45 std::vector<double> rotmat = ps.
get<std::vector<double>>(
"rotmatrix");
46 TVector3 newX, newY, newZ;
48 if (rotmat.size() == 9) {
50 newX = TVector3(rotmat[0], rotmat[1], rotmat[2]);
51 newY = TVector3(rotmat[3], rotmat[4], rotmat[5]);
52 newZ = TVector3(rotmat[6], rotmat[7], rotmat[8]);
54 else if (rotmat.size() == 6) {
59 fTempRot.RotateAxes(newX, newY, newZ);
63 fTempRot.RotateAxes(newX, newY, newZ);
71 std::cout <<
" fBeamRotXML: " << std::setprecision(p) << std::endl;
72 std::cout <<
" [ " << std::setw(w) <<
fBeamRotXML.XX() <<
" " << std::setw(w)
74 <<
" " << std::setw(w) <<
fBeamRotXML.YX() <<
" " << std::setw(w)
76 <<
" " << std::setw(w) <<
fBeamRotXML.ZX() <<
" " << std::setw(w)
78 std::cout << std::endl;
80 std::vector<double> detxyz = ps.
get<std::vector<double>>(
"userbeam");
81 if (detxyz.size() == 3) {
fBeamPosXML = TVector3(detxyz[0], detxyz[1], detxyz[2]); }
82 else if (detxyz.size() == 6) {
83 TVector3 userpos = TVector3(detxyz[0], detxyz[1], detxyz[2]);
84 TVector3 beampos = TVector3(detxyz[3], detxyz[4], detxyz[5]);
88 std::cout <<
"userbeam needs 3 or 6 numbers to be properly defined" << std::endl;
95 std::cout <<
" fBeamPosXML: [ " << std::setprecision(p) << std::setw(w) <<
fBeamPosXML.X()
96 <<
" , " << std::setw(w) <<
fBeamPosXML.Y() <<
" , " << std::setw(w)
111 std::vector<double> x_detAV = ps.
get<std::vector<double>>(
"x_detAV");
112 std::vector<double> y_detAV = ps.
get<std::vector<double>>(
"y_detAV");
113 std::vector<double> z_detAV = ps.
get<std::vector<double>>(
"z_detAV");
118 detAV_rand_user[1] = gRandom->Uniform(y_detAV[0], y_detAV[1]);
119 detAV_rand_user[2] = gRandom->Uniform(z_detAV[0], z_detAV[1]);
122 fRandUser = TLorentzVector(detAV_rand_user, 0);
136 TLorentzVector detVec;
138 fDkMeta->location[1].x = detVec.Vect().X();
139 fDkMeta->location[1].y = detVec.Vect().Y();
140 fDkMeta->location[1].z = detVec.Vect().Z();
142 std::cout <<
"Locations " << std::endl;
143 for (
unsigned int i = 0; i <
fDkMeta->location.size(); i++) {
144 std::cout << i <<
"\t" <<
fDkMeta->location[i].x <<
"\t" <<
fDkMeta->location[i].y <<
"\t" 145 <<
fDkMeta->location[i].z << std::endl;
165 xyz[0] = TMath::Cos(phi) * TMath::Sin(theta);
166 xyz[1] = TMath::Sin(phi) * TMath::Sin(theta);
167 xyz[2] = TMath::Cos(theta);
169 for (
int i = 0; i < 3; ++i) {
170 const double eps = 1.0e-15;
171 if (TMath::Abs(xyz[i]) < eps) xyz[i] = 0;
172 if (TMath::Abs(xyz[i] - 1) < eps) xyz[i] = 1;
173 if (TMath::Abs(xyz[i] + 1) < eps) xyz[i] = -1;
175 return TVector3(xyz[0], xyz[1], xyz[2]);
181 if (!
fDk2NuTree->GetEntry(ientry))
return false;
186 if (
fDk2Nu->decay.ptype == 2112)
return true;
187 if ((
fDk2Nu->decay.ptype == 13 ||
fDk2Nu->decay.ptype == -13) &&
188 (
fDk2Nu->decay.ntype == 14 ||
fDk2Nu->decay.ntype == -14)) {
190 double xnu = (2 *
fDk2Nu->decay.necm) / 0.105658389;
191 if (xnu > 1)
return true;
200 bsim::calcEnuWgt(
fDk2Nu, x4beam.Vect(), enu, wgt);
202 TLorentzVector x4usr;
205 bsim::NuRay rndnuray =
fDk2Nu->nuray[0];
209 TVector3 p3beam = enu * (x4beam.Vect() - xyzDk).Unit();
212 wgt *= 1 / TMath::Pi();
215 bsim::NuRay anuray(p3beam.x(), p3beam.y(), p3beam.z(), enu, wgt);
216 fDk2Nu->nuray.push_back(rndnuray);
217 fDk2Nu->nuray.push_back(anuray);
219 TLorentzVector p4beam(p3beam, enu);
220 TLorentzVector p4usr;
223 fNuPos = TLorentzVector(x4usr);
224 fNuMom = TLorentzVector(p4usr);
226 x4usr.SetX(x4usr.X() / 100.);
227 x4usr.SetY(x4usr.Y() / 100.);
228 x4usr.SetZ(x4usr.Z() / 100.);
272 flux.
fdk2gen = (x4beam.Vect() - xyzDk).Mag();
bool FillMCFlux(Long64_t ientry, simb::MCFlux &mcflux)
double fdk2gen
distance from decay to ray origin
bsim::NuChoice * fNuChoice
bool is_key_to_table(std::string const &key) const
T get(std::string const &key) const
void User2BeamPos(const TLorentzVector &usrxyz, TLorentzVector &beamxyz) const
TVector3 AnglesToAxis(double theta, double phi)
void Beam2UserPos(const TLorentzVector &beamxyz, TLorentzVector &usrxyz) const
TLorentzRotation fBeamRotInv
void Init(fhicl::ParameterSet const &ps)
void Beam2UserP4(const TLorentzVector &beamp4, TLorentzVector &usrp4) const
void SetRootFile(TFile *rootFile)
TLorentzRotation fBeamRot