342 TVector3 parent_dir = flux.kmom.Vect().Unit();
343 TVector3 zdir(0, 0, 1);
344 TVector3 perp_parent_dir = zdir.Cross(parent_dir);
345 double angle = acos(parent_dir.Z());
350 if (perp_parent_dir.Mag() > 1
e-4) {
351 R.Rotate(-angle, perp_parent_dir);
353 TRotation RInv = R.Inverse();
355 std::cout <<
"PARENT DIR: " << parent_dir.X() <<
" " << parent_dir.Y() <<
" " << parent_dir.Z() << std::endl;
356 TVector3 parent_dir_rotated = R * parent_dir;
357 std::cout <<
"PARENT DIR ROTATED: " << parent_dir_rotated.X() <<
" " << parent_dir_rotated.Y() <<
" " << parent_dir_rotated.Z() << std::endl;
360 std::pair<double, double> philim =
DeltaPhi(flux.pos.Vect(), R);
361 double philo = philim.first;
362 double phihi = philim.second;
364 std::cout <<
"PHILIM: " << philo <<
" " << phihi << std::endl;
365 std::cout <<
"DELTAPHI: " << (phihi - philo) << std::endl;
368 double phi =
GetRandom() * (phihi - philo) + philo;
370 std::cout <<
"THISPHI: " << phi << std::endl;
374 if (!info.pass)
return false;
376 unsigned ind = CLHEP::RandFlat::shootInt(
fEngine, 0, info.allIntersections.size()-1);
377 TLorentzVector mevprtl_mom = info.allPrtlMom[ind];
378 std::vector<TVector3> box_intersections = info.allIntersections[ind];
380 TVector3
A = box_intersections[0];
381 TVector3 B = box_intersections[1];
384 if ((flux.pos.Vect() -
A).Mag() < (A-B).Mag() && (flux.pos.Vect() - B).Mag() < (A-B).Mag()) {
385 throw cet::exception(
"ReThrowRayTraceBox Exception",
"Input mevprtl flux starts inside detector volume: "
393 double phiweight = (phihi - philo) / (2*M_PI);
395 weight = phiweight * info.weight;
397 std::cout <<
"Final WEIGHT: " << weight << std::endl;
399 flux.mom = mevprtl_mom;
401 flux.mom_beamcoord = mevprtl_mom;
402 flux.mom_beamcoord.Boost(-flux.kmom.BoostVector());
403 flux.mom_beamcoord.Boost(flux.kmom_beamcoord.BoostVector());
407 flux.sec = flux.kmom - flux.mom;
408 flux.sec_beamcoord = flux.kmom_beamcoord - flux.mom_beamcoord;
410 if ((flux.pos.Vect() -
A).Mag() < (flux.pos.Vect() - B).Mag()) {
411 intersection = {
A, B};
414 intersection = {B, A};
417 std::cout <<
"Kaon 4P: " << flux.kmom.E() <<
" " << flux.kmom.Px() <<
" " << flux.kmom.Py() <<
" " << flux.kmom.Pz() << std::endl;
418 std::cout <<
"Selected Prtl 4P: " << flux.mom.E() <<
" " << flux.mom.Px() <<
" " << flux.mom.Py() <<
" " << flux.mom.Pz() << std::endl;
419 std::cout <<
"Selected Scdy 4P: " << flux.sec.E() <<
" " << flux.sec.Px() <<
" " << flux.sec.Py() <<
" " << flux.sec.Pz() << std::endl;
RayWeightInfo ThrowFixedSuccess(const MeVPrtlFlux &flux, TRotation &RInv, double phi)
CLHEP::HepRandomEngine * fEngine
RayWeightInfo ThrowFixedThrows(const MeVPrtlFlux &flux, TRotation &RInv, double phi)
std::string to_string(WindowPattern const &pattern)
finds tracks best matching by angle
BEGIN_PROLOG could also be cout
std::pair< double, double > DeltaPhi(TVector3 origin, TRotation &R)