6 #include "art/Framework/Principal/Event.h" 
    7 #include "art/Framework/Principal/Handle.h" 
    8 #include "art/Framework/Services/Registry/ServiceHandle.h" 
    9 #include "art/Persistency/Common/PtrMaker.h" 
   10 #include "art/Utilities/ToolMacros.h" 
   11 #include "cetlib/cpu_timer.h" 
   12 #include "fhiclcpp/ParameterSet.h" 
   13 #include "messagefacility/MessageLogger/MessageLogger.h" 
   52     void configure(
const fhicl::ParameterSet&) 
override;
 
   92   if (pset.has_key(
"Box")) {
 
   93     std::array<double, 6> box_config = pset.get<std::array<double, 6>>(
"Box");
 
   95     fBox = 
geo::BoxBoundedGeo(box_config[0], box_config[1], box_config[2], box_config[3], box_config[4], box_config[5]);
 
  102   fNThrows = pset.get<
unsigned>(
"NThrows", 10000);
 
  104   std::cout << 
"Detector Box." << std::endl;
 
  121   double secondary_mass = 0.;
 
  145   double kbeta = sqrt(1 - 1. / (kgamma * kgamma));
 
  147   double scale = kgamma * kgamma * (p + kbeta*
E) * (p + kbeta*E) / (p*
p);
 
  159   TLorentzVector mevprtl_mom = flux.
mom;
 
  160   mevprtl_mom.Boost(-flux.
kmom.BoostVector());
 
  162   mevprtl_mom = TLorentzVector(mevprtl_mom.P() * 
dir, mevprtl_mom.E());
 
  165   mevprtl_mom.Boost(flux.
kmom.BoostVector());
 
  173   std::vector<std::vector<TVector3>> allIntersections;
 
  174   std::vector<TLorentzVector> allHMom;
 
  176   for (
unsigned i = 0; i <= 
fNThrows; i++) {
 
  181     if (box_intersections.size() != 2) {
 
  185     TVector3 
A = box_intersections[0];
 
  188     if (mevprtl_mom.Vect().Unit().Dot((A - flux.
pos.Vect()).Unit()) < 0.) {
 
  189       std::cout << 
"RAYTRACE: MeVPrtl points wrong way" << std::endl;
 
  190       std::cout << 
"Pos: " << flux.
pos.X() << 
" " << flux.
pos.Y() << 
" " << flux.
pos.Z() << std::endl;
 
  191       std::cout << 
"A: " << A.X() << 
" " << A.Y() << 
" " << A.Z() << std::endl;
 
  192       std::cout << 
"P: " << mevprtl_mom.Vect().Unit().X() << 
" " << mevprtl_mom.Vect().Unit().Y() << 
" " << mevprtl_mom.Vect().Unit().Z() << std::endl;
 
  197     allIntersections.push_back(box_intersections);
 
  198     allHMom.push_back(mevprtl_mom);
 
  201   std::cout << 
"Prtl intersected (" << allIntersections.size() << 
" / " << 
fNThrows << 
") times.\n";
 
  204   if (allIntersections.size() == 0) {
 
  208   unsigned ind = CLHEP::RandFlat::shootInt(
fEngine, 0, allIntersections.size()-1); 
 
  210   TLorentzVector mevprtl_mom = allHMom[ind];
 
  211   std::vector<TVector3> box_intersections = allIntersections[ind];
 
  213   TVector3 
A = box_intersections[0];
 
  214   TVector3 B = box_intersections[1];
 
  217   if ((flux.
pos.Vect() - 
A).Mag() < (A-B).Mag() && (flux.
pos.Vect() - B).Mag() < (A-B).Mag()) {
 
  218     throw cet::exception(
"ReThrowRayTraceBox Exception", 
"Input mevprtl flux starts inside detector volume: " 
  226   weight = (double)allIntersections.size() / 
fNThrows;
 
  227   flux.
mom = mevprtl_mom;
 
  238   if ((flux.
pos.Vect() - 
A).Mag() < (flux.
pos.Vect() - B).Mag()) {
 
  239     intersection = {
A, B}; 
 
  242     intersection = {B, A}; 
 
  245   std::cout << 
"Kaon 4P: " << flux.
kmom.E() << 
" " << flux.
kmom.Px() << 
" " << flux.
kmom.Py() << 
" " << flux.
kmom.Pz() << std::endl;
 
  246   std::cout << 
"Selected Prtl 4P: " << flux.
mom.E() << 
" " << flux.
mom.Px() << 
" " << flux.
mom.Py() << 
" " << flux.
mom.Pz() << std::endl;
 
  247   std::cout << 
"Selected Scdy 4P: " << flux.
sec.E() << 
" " << flux.
sec.Px() << 
" " << flux.
sec.Py() << 
" " << flux.
sec.Pz() << std::endl;
 
~ReThrowRayTraceBox()
Destructor. 
 
ReThrowRayTraceBox class definiton. 
 
TLorentzVector sec_beamcoord
 
void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool. 
 
Utilities related to art service access. 
 
double fReferenceKaonEnergy
 
double MaxWeight() override
 
const geo::GeometryCore * geometry
 
BEGIN_PROLOG could also be cerr
 
TLorentzVector mom_beamcoord
 
double MinX() const 
Returns the world x coordinate of the start of the box. 
 
geo::BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const 
 
bool IntersectDetector(MeVPrtlFlux &flux, std::array< TVector3, 2 > &intersection, double &weight) override
 
double twobody_momentum(double parent_mass, double childA_mass, double childB_mass)
 
double MaxX() const 
Returns the world x coordinate of the end of the box. 
 
CLHEP::HepRandomEngine * fEngine
 
Access the description of detector geometry. 
 
double MinZ() const 
Returns the world z coordinate of the start of the box. 
 
IMeVPrtlStage interface class definiton. General interface behind each stage. Provides random number ...
 
Description of geometry of one entire detector. 
 
void CalculateMaxWeight()
 
IRayTrace interface class definiton. 
 
Provides a base class aware of world box coordinates. 
 
double MaxY() const 
Returns the world y coordinate of the end of the box. 
 
TLorentzVector ThrowMeVPrtlMomentum(const MeVPrtlFlux &flux)
 
static const Constants & Instance()
 
ReThrowRayTraceBox(fhicl::ParameterSet const &pset)
Constructor. 
 
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
 
std::string to_string(WindowPattern const &pattern)
 
double MaxZ() const 
Returns the world z coordinate of the end of the box. 
 
double fReferencePrtlMass
 
std::vector< TVector3 > GetIntersections(TVector3 const &TrajectoryStart, TVector3 const &TrajectoryDirect) const 
Calculates the entry and exit points of a trajectory on the box surface. 
 
double fReferenceLabSolidAngle
 
TVector3 RandomUnitVector()
 
This provides an interface for an art tool which ray traces "Prtl" (massive) particles from their pro...
 
double MinY() const 
Returns the world y coordinate of the start of the box. 
 
TLorentzVector kmom_beamcoord
 
art framework interface to geometry description 
 
BEGIN_PROLOG could also be cout