2 #include "dk2nu/tree/dk2nu.h"
3 #include "dk2nu/tree/dkmeta.h"
4 #include "dk2nu/tree/NuChoice.h"
5 #include "dk2nu/tree/calcLocationWeights.h"
23 fDk2NuTree=
dynamic_cast<TTree*
>(rootFile->Get(
"dk2nuTree"));
24 fDkMetaTree=
dynamic_cast<TTree*
>(rootFile->Get(
"dkmetaTree"));
43 std::vector<double> rotmat=ps.get<std::vector<double> >(
"rotmatrix");
44 TVector3 newX,newY,newZ;
45 if (rotmat.size()==9) {
46 std::cout<<
"FluxReader: Matrix defined with new axis values"<<std::endl;
47 newX=TVector3(rotmat[0], rotmat[1], rotmat[2]);
48 newY=TVector3(rotmat[3], rotmat[4], rotmat[5]);
49 newZ=TVector3(rotmat[6], rotmat[7], rotmat[8]);
50 }
else if (rotmat.size()==6) {
51 std::cout<<
"FluxReader: Matrix defined with theta phi rotations"<<std::endl;
62 }
catch (std::exception&
e) {
63 std::cout<<
"FluxReader: "<<e.what()<<std::endl;
64 std::cout<<
"FluxReader: These are not numbers"<<std::endl;
69 fhicl::ParameterSet rotps=ps.get<fhicl::ParameterSet >(
"rotmatrix");
70 double xrot=rotps.get<
double>(
"x");
71 double yrot=rotps.get<
double>(
"y");
72 double zrot=rotps.get<
double>(
"z");
77 std::cout<<
"FluxReader: Matrix defined with series of rotations"<<std::endl;
81 }
catch (std::exception& e) {
82 std::cout<<
"FluxReader: "<<e.what()<<std::endl;
83 std::cout<<
"FluxReader: Looks like it was numbers"<<std::endl;
87 std::cout <<
"FluxReader: fBeamRotXML: " << std::setprecision(
p) << std::endl;
99 << std::setw(w) <<
fBeamRotXML.ZZ() <<
" ] " << std::endl;
102 std::vector<double> detxyz=ps.get<std::vector<double> >(
"userbeam");
103 TVector3 userpos,beampos;
104 if (detxyz.size()==3) {
105 userpos=TVector3(0,0,0);
106 beampos=TVector3(detxyz[0], detxyz[1], detxyz[2]);
107 }
else if (detxyz.size()==6) {
108 userpos=TVector3(detxyz[0], detxyz[1], detxyz[2]);
109 beampos=TVector3(detxyz[3], detxyz[4], detxyz[5]);
111 std::cout<<
"FluxReader: userbeam needs 3 or 6 numbers to be properly defined"<<std::endl;
117 std::cout <<
"FluxReader: fBeamPosXML: [ " << std::setprecision(
p)
123 std::vector<double>
windowBase=ps.get<std::vector<double> >(
"windowBase");
124 std::vector<double>
window1 =ps.get<std::vector<double> >(
"window1");
125 std::vector<double>
window2 =ps.get<std::vector<double> >(
"window2");
128 fFluxWindowPtUser[1]=TVector3( window1[0] , window1[1] , window1[2] );
129 fFluxWindowPtUser[2]=TVector3( window2[0] , window2[1] , window2[2] );
133 TLorentzVector ptbm0, ptbm1, ptbm2;
134 User2BeamPos(TLorentzVector(fFluxWindowPtUser[0],0),ptbm0);
135 User2BeamPos(TLorentzVector(fFluxWindowPtUser[1],0),ptbm1);
136 User2BeamPos(TLorentzVector(fFluxWindowPtUser[2],0),ptbm2);
151 if ( TMath::Abs(dot) > 1.0e-8 )
152 std::cout <<
"FluxReader: Dot product between window direction vectors was "
153 << dot <<
"; please check for orthoganality"<<std::endl;
161 TLorentzVector detVec;
163 fDkMeta->location[1].x=detVec.Vect().X();
164 fDkMeta->location[1].y=detVec.Vect().Y();
165 fDkMeta->location[1].z=detVec.Vect().Z();
167 std::cout<<
"FluxReader: Locations "<<std::endl;
168 for (
unsigned int i=0;i<
fDkMeta->location.size();i++) {
171 <<
fDkMeta->location[i].z<<std::endl;
175 TLorentzVector& beamxyz)
const
180 TLorentzVector& usrxyz)
const
185 TLorentzVector& usrp4 )
const
194 xyz[0] = TMath::Cos(phi)*TMath::Sin(theta);
195 xyz[1] = TMath::Sin(phi)*TMath::Sin(theta);
196 xyz[2] = TMath::Cos(theta);
198 for (
int i=0; i<3; ++i) {
199 const double eps = 1.0e-15;
200 if (TMath::Abs(xyz[i]) < eps ) xyz[i] = 0;
201 if (TMath::Abs(xyz[i]-1) < eps ) xyz[i] = 1;
202 if (TMath::Abs(xyz[i]+1) < eps ) xyz[i] = -1;
204 return TVector3(xyz[0],xyz[1],xyz[2]);
215 bsim::calcEnuWgt(
fDk2Nu, x4beam.Vect(),enu,wgt);
217 TLorentzVector x4usr;
220 bsim::NuRay rndnuray=
fDk2Nu->nuray[0];
224 TVector3 p3beam = enu * (x4beam.Vect()-xyzDk).Unit();
232 bsim::NuRay anuray(p3beam.x(), p3beam.y(), p3beam.z(), enu, wgt);
233 fDk2Nu->nuray.push_back(rndnuray);
234 fDk2Nu->nuray.push_back(anuray);
236 TLorentzVector p4beam(p3beam,enu);
237 TLorentzVector p4usr;
240 fNuPos=TLorentzVector(x4usr);
241 fNuMom=TLorentzVector(p4usr);
243 x4usr.SetX(x4usr.X()/100.);
244 x4usr.SetY(x4usr.Y()/100.);
245 x4usr.SetZ(x4usr.Z()/100.);
257 flux.fntype =
fDk2Nu->decay.ntype;
258 flux.fnimpwt =
fDk2Nu->decay.nimpwt;
259 flux.fvx =
fDk2Nu->decay.vx;
260 flux.fvy =
fDk2Nu->decay.vy;
261 flux.fvz =
fDk2Nu->decay.vz;
262 flux.fpdpx =
fDk2Nu->decay.pdpx;
263 flux.fpdpy =
fDk2Nu->decay.pdpy;
264 flux.fpdpz =
fDk2Nu->decay.pdpz;
265 flux.fppdxdz =
fDk2Nu->decay.ppdxdz;
266 flux.fppdydz =
fDk2Nu->decay.ppdydz;
267 flux.fpppz =
fDk2Nu->decay.pppz;
268 flux.fppmedium =
fDk2Nu->decay.ppmedium;
269 flux.fptype =
fDk2Nu->decay.ptype;
270 flux.fndecay =
fDk2Nu->decay.ndecay;
271 flux.fmuparpx =
fDk2Nu->decay.muparpx;
272 flux.fmuparpy =
fDk2Nu->decay.muparpy;
273 flux.fmuparpz =
fDk2Nu->decay.muparpz;
274 flux.fmupare =
fDk2Nu->decay.mupare;
275 flux.fnecm =
fDk2Nu->decay.necm;
277 flux.ftpx =
fDk2Nu->tgtexit.tpx;
278 flux.ftpy =
fDk2Nu->tgtexit.tpy;
279 flux.ftpz =
fDk2Nu->tgtexit.tpz;
280 flux.ftptype =
fDk2Nu->tgtexit.tptype;
281 flux.ftgen =
fDk2Nu->tgtexit.tgen;
284 flux.fevtno =
fDk2Nu->potnum;
285 flux.fnenergyn = flux.fnenergyf = enu;
286 flux.fnwtnear = flux.fnwtfar = wgt;
287 flux.fdk2gen = (x4beam.Vect()-xyzDk).Mag();
288 flux.ftgptype =
fDk2Nu->ancestor[1].pdg;
constexpr auto dot(Vector const &a, Vector const &b)
Return cross product of two vectors.
bool FillMCFlux(Long64_t ientry, simb::MCFlux &mcflux)
TLorentzVector fFluxWindowDir2
bsim::NuChoice * fNuChoice
void User2BeamPos(const TLorentzVector &usrxyz, TLorentzVector &beamxyz) const
TVector3 AnglesToAxis(double theta, double phi)
void Beam2UserPos(const TLorentzVector &beamxyz, TLorentzVector &usrxyz) const
TVector3 fFluxWindowPtUser[3]
TLorentzRotation fBeamRotInv
TLorentzVector fFluxWindowBase
void Init(fhicl::ParameterSet const &ps)
void Beam2UserP4(const TLorentzVector &beamp4, TLorentzVector &usrp4) const
TLorentzVector fFluxWindowDir1
void SetRootFile(TFile *rootFile)
BEGIN_PROLOG could also be cout
TLorentzRotation fBeamRot