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"
62 void configure(
const fhicl::ParameterSet&)
override;
96 double QEstimator(
unsigned nsuccess,
unsigned nfail,
unsigned r) {
97 if (nsuccess < r)
return 0.;
99 return ((
double)(r - 1) / (r+nfail-1));
117 if (pset.has_key(
"Box")) {
118 std::array<double, 6> box_config = pset.get<std::array<double, 6>>(
"Box");
120 fBox =
geo::BoxBoundedGeo(box_config[0], box_config[1], box_config[2], box_config[3], box_config[4], box_config[5]);
127 std::cout <<
"Detector Box." << std::endl;
141 fNThrow = pset.get<
unsigned>(
"NThrow");
143 fNSuccess = pset.get<
unsigned>(
"NSuccess", 2);
157 TVector3
dir(1, 0, 0);
158 TVector3 boost(beta, 0., 0.);
160 double lab_frame_p, costh_rest, weight;
164 throw cet::exception(
"Weighted Ray Trace: Bad max weight calculation.");
176 double sinth = sqrt(1 - costh*costh);
178 TVector3
dir(cos(phi)*sinth, sin(phi)*sinth, costh);
184 TLorentzVector mevprtl_mom = flux.
mom;
185 mevprtl_mom.Boost(-flux.
kmom.BoostVector());
187 mevprtl_mom = TLorentzVector(mevprtl_mom.P() *
dir, mevprtl_mom.E());
190 mevprtl_mom.Boost(flux.
kmom.BoostVector());
196 TVector3 pdir = R.Inverse()*TVector3(0, 0, 1);
198 std::cout <<
"Parent Direction: " << pdir.X() <<
" " << pdir.Y() <<
" " << pdir.Z() <<
" at location: " << origin.X() <<
" " << origin.Y() <<
" " << origin.Z() <<
" hits detector!\n";
199 return {-M_PI, M_PI};
203 double phihi = -M_PI;
206 for (
unsigned i = 0; i < 8; i++) {
211 TVector3 corner(X, Y, Z);
213 double phi = (R * (corner -
origin)).Phi();
214 if (phi > phihi) phihi = phi;
215 if (phi < philo) philo = phi;
221 bool order_is_up = (phihi - philo) < (M_PI - phihi) + (philo + M_PI);
225 std::cout <<
"FLIP PHILIM! " << philo <<
" " << phihi << std::endl;
227 phihi = philo + 2*M_PI;
231 return {philo, phihi};
238 unsigned nsuccess = 0;
247 if (box_intersections.size() != 2) {
253 TVector3
A = box_intersections[0];
254 if (mevprtl_mom.Vect().Unit().Dot((A - flux.
pos.Vect()).Unit()) < 0.) {
266 std::cout <<
"NSUCCESS: " << nsuccess << std::endl;
270 ret.
pass = nsuccess > 0;
280 unsigned nsuccess = 0;
288 if (box_intersections.size() != 2) {
294 TVector3
A = box_intersections[0];
295 if (mevprtl_mom.Vect().Unit().Dot((A - flux.
pos.Vect()).Unit()) < 0.) {
306 std::cout <<
"NFAIL: " << nfail << std::endl;
307 std::cout <<
"NSUCCESS: " << nsuccess << std::endl;
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;
377 TLorentzVector mevprtl_mom = info.
allPrtlMom[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;
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;
TLorentzVector sec_beamcoord
~MixedWeightRayTraceBox()
Destructor.
std::vector< TLorentzVector > allPrtlMom
Utilities related to art service access.
double QEstimator(unsigned nsuccess, unsigned nfail, unsigned r)
RayWeightInfo ThrowFixedSuccess(const MeVPrtlFlux &flux, TRotation &RInv, double phi)
const geo::GeometryCore * geometry
double secPDG2Mass(int pdg)
TLorentzVector mom_beamcoord
EResult err(const char *call)
double MinX() const
Returns the world x coordinate of the start of the box.
geo::BoxBoundedGeo DetectorEnclosureBox(std::string const &name="volDetEnclosure") const
void CalculateMaxWeight()
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.
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
double MaxWeight() override
double fReferenceKaonEnergy
CLHEP::HepRandomEngine * fEngine
Access the description of detector geometry.
double fReferenceLabSolidAngle
RayWeightInfo ThrowFixedThrows(const MeVPrtlFlux &flux, TRotation &RInv, double phi)
TLorentzVector ThrowMeVPrtlMomentum(const MeVPrtlFlux &flux, TRotation &RInv, double phi)
double MinZ() const
Returns the world z coordinate of the start of the box.
MixedWeightRayTraceBox(fhicl::ParameterSet const &pset)
Constructor.
IMeVPrtlStage interface class definiton. General interface behind each stage. Provides random number ...
Description of geometry of one entire detector.
IRayTrace interface class definiton.
void configure(const fhicl::ParameterSet &) override
Interface for configuring the particular algorithm tool.
Provides a base class aware of world box coordinates.
double MaxY() const
Returns the world y coordinate of the end of the box.
static const Constants & Instance()
double fReferencePrtlMass
std::vector< std::vector< TVector3 > > allIntersections
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.
std::vector< TVector3 > GetIntersections(TVector3 const &TrajectoryStart, TVector3 const &TrajectoryDirect) const
Calculates the entry and exit points of a trajectory on the box surface.
bool IntersectDetector(MeVPrtlFlux &flux, std::array< TVector3, 2 > &intersection, double &weight) override
MixedWeightRayTraceBox class definiton.
finds tracks best matching by angle
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
constexpr Point origin()
Returns a origin position with a point of the specified type.
std::pair< double, double > DeltaPhi(TVector3 origin, TRotation &R)
int calcPrtlRayWgt(double rest_frame_p, double M, TVector3 dir, TVector3 boost, double rand, double &lab_frame_p_out, double &costh_rest_out, double &wgt)