Classes | Typedefs | Enumerations | Functions | Variables
geo Namespace Reference

Helper for AttenCurve. More...

Classes

class  CellGeo
 Encapsulate the cell geometry. More...
 
struct  CellOnLine
 
class  CoordinateTransformation
 
class  CoordinateTransformationTest
 
class  Geometry
 The geometry of one entire detector (near, far, ipnd) More...
 
class  GeometryBase
 The geometry of one entire detector (near, far, ipnd) More...
 
class  GeometryTest
 
class  LiveGeometry
 The instrumented geometry of one entire detector (near, far, ipnd) More...
 
class  OfflineChan
 A (plane, cell) pair. More...
 
class  PlaneGeo
 Geometry information for a single readout plane. More...
 

Typedefs

typedef unsigned long long int CellUniqueId
 
typedef enum geo::_readout Readout_t
 Enumerate the possible locations of the cell readout. More...
 
typedef enum geo::_plane_proj View_t
 Enumerate the possible plane projections. More...
 

Enumerations

enum  BeamType { BEAMTYPE_NUMI = 1, BEAMTYPE_BOONE = 2 }
 Beam type. BOONE or NuMI. More...
 
enum  _return_codes { kPLANE_NOT_FOUND = 999000 }
 Return codes which flag errors and the like. More...
 
enum  _readout { kTop, kWest, kEast, kAnySide }
 Enumerate the possible locations of the cell readout. More...
 
enum  _plane_proj { kX, kY, kXorY }
 Enumerate the possible plane projections. More...
 

Functions

CellUniqueId NodesToUniqueId (const std::vector< const TGeoNode * > &n, unsigned int depth)
 
void ProjectToBoxEdge (const double xyz[], const double dxyz[], double xlo, double xhi, double ylo, double yhi, double zlo, double zhi, double xyzout[])
 Project along a direction from a particular starting point to the edge of a box. More...
 
int WhichWallofBox (const double xyz[], double xlo, double xhi, double ylo, double yhi, double zlo, double zhi)
 
bool IntersectsBox (const double xyz[], const double dxyz[], double xlo, double xhi, double ylo, double yhi, double zlo, double zhi)
 Determine if a particle starting at xyz with direction dxyz will intersect a box defined by xlo, xhi, ylo, yhi, zlo, zhi. More...
 
void ProjectToBoxEdgeFromOutside (const double xyz[], const double dxyz[], int axis, double edge, double xyzout[])
 Project from a position outside of a box to an edge of the box with coordinate value edge for the axis axis. More...
 
bool LineIntersection (double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1, double &x, double &y)
 Find the intersection between two line segments. More...
 
double ClosestApproach (const double point[], const double intercept[], const double slopes[], double closest[])
 Find the distance of closest approach between point and line. More...
 
double ClosestApproach (TVector3 point, TVector3 intercept, TVector3 slopes, TVector3 &closest)
 Find the distance of closest approach between point and line. More...
 
double ClosestApproach (const TVector3 &P0, const TVector3 &P1, const TVector3 &Q0, const TVector3 &Q1, double *sc, double *tc, TVector3 *PC, TVector3 *QC)
 Find the distance of closest approach between two lines which pass through points P0 and P1 and Q0 and Q1. More...
 
double DsqrToLine (double x0, double y0, double x1, double y1, double x2, double y2)
 In two dimensions, return the perpendicular distance from a point (x0,y0) to a line defined by end points (x1,y1) and (x2,y2) More...
 
double LinFit (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
 Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance from the points to the line. More...
 
double LinFitMinDperp (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
 Find the best-fit line to a collection of points in 2-D by minimizing the squared perpendicular distance from the points to the line. More...
 
double DistToEdge (double *point, double detHalfWidth, double detHalfHeight, double detLength)
 Find the distance from the given point to the edge of the detector. More...
 
bool ClampRayToDetectorVolume (TVector3 *p0, TVector3 *p1, const GeometryBase *geom)
 If either endpoint is outside the detector move it to the edge. More...
 
void InitializePathTable ()
 Function to initialize gPathTable for GetAvgPath2D. More...
 
bool ltKey (std::pair< double, double > a, double b)
 
double GetAvgPath2D (double dx)
 Helper for AverageCellPathLength. More...
 
double AverageCellPathLength (geo::View_t view, double dx, double dy, double dz)
 Mean path length of a ray with (unit) direction vector dx, dy, dz through a cell in view, averaged over all transverse positions. More...
 
static bool plane_sort (const PlaneGeo *p1, const PlaneGeo *p2)
 
std::ostream & operator<< (std::ostream &os, const OfflineChan &chan)
 
static bool sort_hori (const CellGeo *c1, const CellGeo *c2)
 
static bool sort_vert (const CellGeo *c1, const CellGeo *c2)
 

Variables

const double pointS_Z = 184.25 * CLHEP::m
 
const double NuMiBeamLineAngle = 0.057715289 * CLHEP::radian
 
const double NOvAneardetNuMiAngle = 0.0145766 * CLHEP::radian
 Angle between NuMi beamline and the NOvA near detectors. More...
 
static std::map< double, double > gPathTable
 

Detailed Description

Helper for AttenCurve.

Detector geometry definition and interface.

Detector geometry information.

Author
bckho.nosp@m.use@.nosp@m.calte.nosp@m.ch.e.nosp@m.du
Date

Typedef Documentation

typedef unsigned long long int geo::CellUniqueId

Definition at line 15 of file CellUniqueId.h.

Enumerate the possible locations of the cell readout.

Enumerate the possible plane projections.

Enumeration Type Documentation

Enumerate the possible plane projections.

Enumerator
kX 

Vertical planes which measure X.

kY 

Horizontal planes which measure Y.

kXorY 

X or Y views.

Definition at line 27 of file PlaneGeo.h.

27  {
28  kX, ///< Vertical planes which measure X
29  kY, ///< Horizontal planes which measure Y
30  kXorY ///< X or Y views
31  } View_t;
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Definition: geo.h:1
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
Definition: geo.h:1

Enumerate the possible locations of the cell readout.

Enumerator
kTop 

Vertical modules readout on the top.

kWest 

Horizontal modules readout on the west.

kEast 

Horizontal modules readout on the east.

kAnySide 

Don't care which side the read out is on.

Definition at line 20 of file PlaneGeo.h.

20  {
21  kTop, ///< Vertical modules readout on the top
22  kWest, ///< Horizontal modules readout on the west
23  kEast, ///< Horizontal modules readout on the east
24  kAnySide ///< Don't care which side the read out is on
25  } Readout_t;
Vertical modules readout on the top.
Definition: PlaneGeo.h:21
Horizontal modules readout on the west.
Definition: PlaneGeo.h:22
enum geo::_readout Readout_t
Enumerate the possible locations of the cell readout.
Don&#39;t care which side the read out is on.
Definition: PlaneGeo.h:24
Horizontal modules readout on the east.
Definition: PlaneGeo.h:23

Return codes which flag errors and the like.

Enumerator
kPLANE_NOT_FOUND 

Definition at line 38 of file GeometryBase.h.

38  {
39  kPLANE_NOT_FOUND = 999000
40  };

Beam type. BOONE or NuMI.

Enumerator
BEAMTYPE_NUMI 
BEAMTYPE_BOONE 

Definition at line 46 of file CoordinateTransformation.h.

Function Documentation

double geo::AverageCellPathLength ( geo::View_t  view,
double  dx,
double  dy,
double  dz 
)

Mean path length of a ray with (unit) direction vector dx, dy, dz through a cell in view, averaged over all transverse positions.

Definition at line 804 of file Geo.cxx.

References std::abs(), e, GetAvgPath2D(), kX, util::pythag(), scale, and std::sqrt().

Referenced by calib::BestPathEstimates().

806  {
807  // Must be a unit vector
808  if(std::abs(util::pythag(dx, dy, dz)-1) > 1e-4)
809  throw cet::exception("Geo") << "provided values are not a unit vector - "
810  << "(dx, dy, dz) = (" << dx << " ," << dy << " ,"
811  << dz << ")";
812 
813  if(view == geo::kX){
814  // Straight down the cell, hardcode NDOS length...
815  if(std::abs(dy) > .99) return 393;
816  // Project down into xz 2D
817  const double scale = sqrt(1-dy*dy);
818  const double dist2D = GetAvgPath2D(dz/scale);
819  // And back up to 3D
820  return dist2D/scale;
821  }
822  else{
823  if(std::abs(dx) > .99) return 262;
824  const double scale = sqrt(1-dx*dx);
825  const double dist2D = GetAvgPath2D(dz/scale);
826  return dist2D/scale;
827  }
828  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
Vertical planes which measure X.
Definition: PlaneGeo.h:28
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
float abs(float number)
Definition: d0nt_math.hpp:39
Double_t scale
Definition: plot.C:25
double dy[NP][NC]
double dx[NP][NC]
double dz[NP][NC]
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
double GetAvgPath2D(double dx)
Helper for AverageCellPathLength.
Definition: Geo.cxx:777
Float_t e
Definition: plot.C:35
bool geo::ClampRayToDetectorVolume ( TVector3 *  p0,
TVector3 *  p1,
const GeometryBase geom 
)

If either endpoint is outside the detector move it to the edge.

If the given ray does not intersect the detector, returns false

Definition at line 640 of file Geo.cxx.

References geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetLength(), dist, stan::math::fabs(), cet::sqlite::max(), getGoodRuns4SAM::n, PandAna.Demos.pi0_spectra::p0, nd_projection_maker::ps, Unit(), X, Y, and Z.

Referenced by geo::GeometryBase::CountCellsOnLineFast(), trk::KalmanGeoHelper::CountMissedCellsOnLine(), trk::WindowTrackingAlg::Make3DTrack(), trk::CosmicTrackAlg::MakeTrack(), crvtx::CosmicRayVertex::produce(), and trk::WindowTrackingAlg::ShortTrack().

642  {
643  const double Lx = geom->DetHalfWidth();
644  const double Ly = geom->DetHalfHeight();
645  const double Lz = geom->DetLength()/2;
646 
647  // Collect points in an array so we can loop
648  TVector3* ps[2] = {p0, p1};
649 
650  for(int n = 0; n < 2; ++n){
651  // Unit vector towards the other point
652  const TVector3 dp = (*ps[1-n]-*ps[n]).Unit();
653 
654  // Distance to detector edge along dp for each view. Zero if inside
655  const double distx = dp.X() ? (fabs(ps[n]->X() )-Lx)/fabs(dp.X()) : 0;
656  const double disty = dp.Y() ? (fabs(ps[n]->Y() )-Ly)/fabs(dp.Y()) : 0;
657  const double distz = dp.Z() ? (fabs(ps[n]->Z()-Lz)-Lz)/fabs(dp.Z()) : 0;
658  // Distance required to be inside the detector. Zero if already contained
659  const double dist = std::max(std::max(distx, disty), distz);
660 
661  if(dist > 0){
662  // Here we're assuming that the reconstructed track already goes
663  // through the detector, so that by moving towards the other point
664  // we'll hit it.
665  *ps[n] += dist*dp;
666  }
667 
668  // If that assumption was false, then we won't have ended up on the edge
669  // of the detector as we intended.
670  if(fabs(ps[n]->X()) > Lx+.1 ||
671  fabs(ps[n]->Y()) > Ly+.1 ||
672  ps[n]->Z() < -.1 ||
673  ps[n]->Z() > 2*Lz+.1){
674  return false;
675  }
676  } // end for n
677  return true;
678  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
Float_t Y
Definition: plot.C:38
double dist
Definition: runWimpSim.h:113
Float_t Z
Definition: plot.C:38
TVector3 Unit() const
void geom(int which=0)
Definition: geom.C:163
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
Float_t X
Definition: plot.C:38
double geo::ClosestApproach ( const double  point[],
const double  intercept[],
const double  slopes[],
double  closest[] 
)

Find the distance of closest approach between point and line.

Parameters
point- xyz coordinates of point
intercept- xyz coordinates of point on line
slopes- direction vector (need not be normalized)
closest- on output, point on line that is closest
Returns
distance from point to line

Definition at line 222 of file Geo.cxx.

References dist.

Referenced by align::Alignment::analyze(), mcchk::CosmicAna::analyze(), align::SplitTracks::analyze(), geo::GeometryBase::ClosestApproach(), dt::Cand::ClosestToEndCell(), dif::DiFShowerFinder::distancefromtrack(), slid::DeconvolveAlg::DistanceToCore(), comi::Leana::FindClosestMuon(), trk::CosmicTrackAlg::FitView(), geo::GeometryBase::isDetectorBigBoxUsed(), cosrej::MakeNueCosRej::MuonParentByDist(), cosrej::MakeNueCosRej::MuonParentByTime(), slid::ParticleIDAlg::PlaneRadius(), slid::ParticleIDAlg::Radius(), and rb::Prong::TotalLength().

226  {
227  TVector3 closest_vec;
228  const double dist = ClosestApproach(TVector3(point),
229  TVector3(intercept), TVector3(slopes),
230  closest_vec);
231  closest_vec.GetXYZ(closest);
232  return dist;
233  }
double dist
Definition: runWimpSim.h:113
double ClosestApproach(const TVector3 &P0, const TVector3 &P1, const TVector3 &Q0, const TVector3 &Q1, double *sc, double *tc, TVector3 *PC, TVector3 *QC)
Find the distance of closest approach between two lines which pass through points P0 and P1 and Q0 an...
Definition: Geo.cxx:284
double geo::ClosestApproach ( TVector3  point,
TVector3  intercept,
TVector3  slopes,
TVector3 &  closest 
)

Find the distance of closest approach between point and line.

Parameters
point- xyz coordinates of point
intercept- xyz coordinates of point on line
slopes- direction vector (need not be normalized)
closest- on output, point on line that is closest
Returns
distance from point to line

Definition at line 246 of file Geo.cxx.

References sd().

248  {
249  const double s = slopes.Dot(point-intercept);
250  const double sd = slopes.Mag2();
251 
252  if(sd > 0){
253  closest = intercept + (s/sd)*slopes;
254  }
255  else {
256  // How to handle this zero gracefully? Assume that the intercept
257  // is a particle vertex and "slopes" are momenta. In that case,
258  // the particle goes nowhere and the closest approach is the
259  // distance from the intercept to point
260  closest = intercept;
261  }
262 
263  return (point-closest).Mag();
264  }
double sd(Eigen::VectorXd x)
const XML_Char * s
Definition: expat.h:262
double geo::ClosestApproach ( const TVector3 &  P0,
const TVector3 &  P1,
const TVector3 &  Q0,
const TVector3 &  Q1,
double *  sc,
double *  tc,
TVector3 *  PC,
TVector3 *  QC 
)

Find the distance of closest approach between two lines which pass through points P0 and P1 and Q0 and Q1.

Parameters
P0- A point on line P
P1- A second point on line P
Q0- A point on line Q
Q1- A second point on line Q
sc- distance from P0 to point on P which is closest
tc- distance from Q0 to point on Q which is closest
PC- point on line P which is closest
QC- point on line Q which is closest
Returns
The distance^2 between the points of closest approach.

If any of the pointers sc, tc, PC, QC are zero, that part of the calculation is skipped.

Definition at line 284 of file Geo.cxx.

References b, d, e, Munits::pC, submit_hadd::u, and registry_explorer::v.

292  {
293  TVector3 w0(P0); w0 -= Q0;
294 
295  TVector3 u(P1); u -= P0; u = u.Unit();
296  TVector3 v(Q1); v -= Q0; v = v.Unit();
297 
298  double b = u.Dot(v);
299  double d = u.Dot(w0);
300  double e = v.Dot(w0);
301 
302  double denom = 1-b*b;
303  double sC, tC;
304  if (denom!=0.0) {
305  sC = (b*e-d)/denom;
306  tC = (e-b*d)/denom;
307  }
308  else {
309  sC = 0.0;
310  tC = d/b;
311  }
312  if (sc!=0) *sc = sC;
313  if (tc!=0) *tc = tC;
314 
315  TVector3 pC(P0+sC*u);
316  TVector3 qC(Q0+tC*v);
317  if (PC!=0) *PC = pC;
318  if (QC!=0) *QC = qC;
319 
320  TVector3 D(pC-qC);
321 
322  return D.Mag2();
323  }
static constexpr Double_t pC
Definition: Munits.h:237
Float_t d
Definition: plot.C:236
#define PC
Definition: eph_manager.h:45
const hit & b
Definition: hits.cxx:21
Float_t e
Definition: plot.C:35
double geo::DistToEdge ( double *  point,
double  detHalfWidth,
double  detHalfHeight,
double  detLength 
)

Find the distance from the given point to the edge of the detector.

Definition at line 626 of file Geo.cxx.

References dx, dy, dz, stan::math::fabs(), and min().

Referenced by air::AirKalmanAna::analyze(), jmshower::NueSel::produce(), and jmshower::JMShower::~JMShower().

630  {
631  // Distance to an edge in each direction
632  const double dx = fabs(detHalfWidth - fabs(point[0]));
633  const double dy = fabs(detHalfHeight - fabs(point[1]));
634  const double dz = std::min(fabs(point[2]), fabs(detLength-point[2]));
635 
636  return std::min(std::min(dx, dy), dz);
637  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double dy[NP][NC]
double dx[NP][NC]
double dz[NP][NC]
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
double geo::DsqrToLine ( double  x0,
double  y0,
double  x1,
double  y1,
double  x2,
double  y2 
)

In two dimensions, return the perpendicular distance from a point (x0,y0) to a line defined by end points (x1,y1) and (x2,y2)

Parameters
x0: x-value of point
y0: y-value of point
x1: x-value of point at one end of line
y1: y-value of point at one end of line
x2: x-value of point at other end of line
y2: y-value of point at other end of line
Returns
Squared distance from the point to the line

Definition at line 338 of file Geo.cxx.

References d, sqr(), and util::sqr().

Referenced by hough::HoughValidate::analyze(), trk::RLFit::Fit(), cosrej::CosRejFxs::fitchisq(), numusand::NumuSandFxs::fitchisq(), trk::CosmicTrackAlg::FitView(), trk::WindowTrackingAlg::FitWindow(), LinFitMinDperp(), vdt::VertexDT::PassPDistReq(), hough::MultiHough2P::ReweightHits(), and zcl::FMMTracker::Tracking2D().

341  {
342  using util::sqr;
343 
344  double d = 0.;
345 
346  // If we've been handed a point instead of a line, return distance
347  // to the point
348  if (x1==x2 && y1==y2) d = sqr(x0-x1)+sqr(y0-y1);
349  else d = sqr((x2-x1)*(y1-y0)-(x1-x0)*(y2-y1)) / (sqr(x2-x1)+sqr(y2-y1));
350 
351  return d;
352 
353  }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
Float_t d
Definition: plot.C:236
T sqr(T x)
Function to perform, and table to cache, timing fits to ADC values.
Definition: ADCShapeFit.cxx:23
double geo::GetAvgPath2D ( double  dx)

Helper for AverageCellPathLength.

Look up average length for a 2D ray in the table. dx is the component in the long direction of the cell (detector dz).

Definition at line 777 of file Geo.cxx.

References std::abs(), dx, InitializePathTable(), ltKey(), x1, and y1.

Referenced by AverageCellPathLength().

778  {
779  if(gPathTable.empty()) InitializePathTable();
780 
781  dx = std::abs(dx);
782 
783  typedef std::map<double, double>::const_iterator it_t;
784 
785  // Find the point after dx
786  it_t itNext = std::lower_bound(gPathTable.begin(), gPathTable.end(), dx,
787  ltKey);
788 
789  if(itNext == gPathTable.end() || itNext == gPathTable.begin())
790  throw cet::exception("Geo") << "cannot find the point after dx: " << dx;
791 
792  // And the point before
793  it_t itPrev = itNext; --itPrev;
794 
795  // Interpolate
796  const double x0 = itPrev->first; const double y0 = itPrev->second;
797  const double x1 = itNext->first; const double y1 = itNext->second;
798  return ((x1-dx)*y0+(dx-x0)*y1)/(x1-x0);
799  }
bool ltKey(std::pair< double, double > a, double b)
Definition: Geo.cxx:770
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
float abs(float number)
Definition: d0nt_math.hpp:39
void InitializePathTable()
Function to initialize gPathTable for GetAvgPath2D.
Definition: Geo.cxx:690
double dx[NP][NC]
static std::map< double, double > gPathTable
Definition: Geo.cxx:683
void geo::InitializePathTable ( )

Function to initialize gPathTable for GetAvgPath2D.

Trace paths through a 2D cell at all angles and all positions. Average over the positions.

Definition at line 690 of file Geo.cxx.

References dx, dy, stan::math::fabs(), cet::sqlite::max(), util::pythag(), std::sqrt(), fillBadChanDBTables::step, confusionMatrixTree::t, submit_hadd::u, submit_syst::x, and submit_syst::y.

Referenced by GetAvgPath2D().

691  {
692  // Don't call me twice
693  if(!gPathTable.empty())
694  throw cet::exception("Geo") << "trying to non-empty initialize path table.";
695 
696  // Numbers off the ends don't mean anything, but they keep the
697  // interpolation happy for borderline cases
698  for(double dx = -.01; dx < 1.02; dx += .02){
699  const double dy = sqrt(std::max(1-dx*dx, 0.));
700 
701  // Dimensions of a cell, in cm. Convention is that x is the long axis
702  // and y the short axis.
703  // TODO: harcoding numbers is bad
704  const double Lx = 5.94;
705  const double Ly = 3.84;
706 
707  // Accumulate into S_tot. Count how many samples we took.
708  double S_tot = 0;
709  int samples = 0;
710 
711  // Step size for the integration, in cm
712  const double step = .005;
713 
714  // This is always a big enough line to integrate over that we'll cover
715  // the whole cell. Starting at zero and only doing half is justified
716  // by the symmetry.
717  const double U = util::pythag(Lx, Ly)/2;
718  for(double u = 0; u < U; u += step){
719  // There really should be exactly zero or two intersection times.
720  // We'll assert that in a minute. But avoid potential memory stomping.
721  double tInts[4];
722  // The place where we'll write the first time
723  double* tInt = tInts;
724 
725  // Integrate over points along a vector perpendicular to the track
726  const double x0 = -dy*u;
727  const double y0 = +dx*u;
728 
729  double x, y, t;
730 
731  // When do we intersect the +x wall? Where are we in y at the time?
732  x = +Lx/2;
733  t = (x-x0)/dx;
734  y = y0+t*dy;
735  // If this is within the cell: record it, and move onto the next slot
736  if(y > -Ly/2 && y < +Ly/2) *tInt++ = t;
737 
738  y = +Ly/2;
739  t = (y-y0)/dy;
740  x = x0+t*dx;
741  if(x > -Lx/2 && x < +Lx/2) *tInt++ = t;
742 
743  x = -Lx/2;
744  t = (x-x0)/dx;
745  y = y0+t*dy;
746  if(y > -Ly/2 && y < +Ly/2) *tInt++ = t;
747 
748  y = -Ly/2;
749  t = (y-y0)/dy;
750  x = x0+t*dx;
751  if(x > -Lx/2 && x < +Lx/2) *tInt++ = t;
752 
753  // Either the ray enters and exits, or it never hits the cell at all
754  if(tInt - tInts != 2 && tInt - tInts != 0)
755  throw cet::exception("Geo") << "ray enters the cell but does not exit, that is a problem";
756 
757  // In this case we missed
758  if(tInt == tInts) continue;
759 
760  // The direction is a unit vector, so the distance is just the times
761  S_tot += fabs(tInts[1]-tInts[0]);
762  ++samples;
763  } // end for u
764 
765  gPathTable[dx] = S_tot/samples;
766  } // end for dx
767  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
T sqrt(T number)
Definition: d0nt_math.hpp:156
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double dy[NP][NC]
double dx[NP][NC]
static std::map< double, double > gPathTable
Definition: Geo.cxx:683
double pythag(double x, double y)
2D Euclidean distance
Definition: MathUtil.h:29
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
bool geo::IntersectsBox ( const double  xyz[],
const double  dxyz[],
double  xlo,
double  xhi,
double  ylo,
double  yhi,
double  zlo,
double  zhi 
)

Determine if a particle starting at xyz with direction dxyz will intersect a box defined by xlo, xhi, ylo, yhi, zlo, zhi.

Definition at line 97 of file Geo.cxx.

References ProjectToBoxEdgeFromOutside().

Referenced by geo::LiveGeometry::DoWeEnterMC(), geo::LiveGeometry::FullNDProjectedCells(), geo::GeometryBase::IntersectsBigBox(), and geo::GeometryBase::IntersectsDetector().

102  {
103  double xyzedge[3] = {0.};
104 
105  // there are 6 edges to a box, check them all. If a particle intersects
106  // any surface, then return true
107 
108  // top surface, y = yhi
109  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 1, yhi, xyzedge);
110  if(xyzedge[0] > xlo && xyzedge[0] < xhi
111  && xyzedge[2] > zlo && xyzedge[2] < zhi) return true;
112 
113  // bottom surface, y = ylo
114  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 1, ylo, xyzedge);
115  if(xyzedge[0] > xlo && xyzedge[0] < xhi
116  && xyzedge[2] > zlo && xyzedge[2] < zhi) return true;
117 
118  // x = xhi
119  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 0, xhi, xyzedge);
120  if(xyzedge[1] > ylo && xyzedge[1] < yhi
121  && xyzedge[2] > zlo && xyzedge[2] < zhi) return true;
122 
123  // x = xlo
124  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 0, xlo, xyzedge);
125  if(xyzedge[1] > ylo && xyzedge[1] < yhi
126  && xyzedge[2] > zlo && xyzedge[2] < zhi) return true;
127 
128  // z = zhi
129  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 2, zhi, xyzedge);
130  if(xyzedge[1] > ylo && xyzedge[1] < yhi
131  && xyzedge[0] > xlo && xyzedge[0] < xhi) return true;
132 
133  // z = zlo
134  geo::ProjectToBoxEdgeFromOutside(xyz, dxyz, 2, zlo, xyzedge);
135  if(xyzedge[1] > ylo && xyzedge[1] < yhi
136  && xyzedge[0] > xlo && xyzedge[0] < xhi) return true;
137 
138  return false;
139 
140  }
void ProjectToBoxEdgeFromOutside(const double xyz[], const double dxyz[], int axis, double edge, double xyzout[])
Project from a position outside of a box to an edge of the box with coordinate value edge for the axi...
Definition: Geo.cxx:148
bool geo::LineIntersection ( double  x0,
double  y0,
double  x1,
double  y1,
double  X0,
double  Y0,
double  X1,
double  Y1,
double &  x,
double &  y 
)

Find the intersection between two line segments.

Given the two line segments (x0,y0)-(x1,y1), and (X0,Y0)-(X1,Y1), fills (x,y) with the point that lies on both of them. The return value indicates if the intersection of the (infinite) lines falls inside the line segments. If it does not, the returned (x,y) is still meaningful, unless the two input lines are parallel.

Definition at line 184 of file Geo.cxx.

References dx, dy, submit_hadd::l, CLHEP::L, x1, and y1.

Referenced by trk::KalmanTrackMerge::CanJoinTracks(), dt::DiscreteTracker::FindVertex(), dt::ViewMerger::FindVertex(), and cosrej::CosRejFxs::getFits().

187  {
188  const double dx = x1-x0;
189  const double dy = y1-y0;
190  const double dX = X1-X0;
191  const double dY = Y1-Y0;
192 
193  const double denom = dX*dy-dY*dx;
194 
195  if(denom == 0){
196  // std::cerr << "Trying to find intercept of parallel lines" << std::endl;
197  x = x1; y = y1;
198  return false;
199  }
200 
201  // Distance of intercept point along each of the two lines
202  const double l = -(X0*dY-Y0*dX+dX*y0-dY*x0)/denom;
203  const double L = +(x0*dy-y0*dx+dx*Y0-dy*X0)/denom;
204 
205  x = X0+L*(X1-X0);
206  y = Y0+L*(Y1-Y0);
207 
208  return l >= 0 && l <= 1 && L >= 0 && L <= 1;
209  }
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
double dy[NP][NC]
double dx[NP][NC]
static constexpr double L
Double_t X1
Definition: plot.C:264
Double_t Y1
Definition: plot.C:264
double geo::LinFit ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  w,
double *  x1,
double *  y1,
double *  x2,
double *  y2 
)

Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance from the points to the line.

To give the most robust fits and avoid cases where the slopes approach infinity, the points are arranged to maximize the horizontal extent. So, the fitter may fit x vs. y or y vs. x.

Parameters
x- input vector of x coordinates
y- input vector of y coordinates
w- input vector of weights for the points
x1- output x coordinate at one end of line
y1- output y coordinate at one end of line
x2- output x coordinate at other end of line
y2- output y coordinate at other end of line
Returns
The chi^2 value defined by chi^2 = sum_i[w_i d^2_i]

Definition at line 373 of file Geo.cxx.

References b, om::cerr, chi2(), allTimeWatchdog::endl, MECModelEnuComparisons::i, util::LinFit(), m, xhi, make_syst_table_plots::xlo, yhi, and ylo.

Referenced by cosrej::CosRejFxs::fitslope(), numusand::NumuSandFxs::fitslope(), LinFitMinDperp(), and jmshower::JMClusterMerge::produce().

378  {
379  unsigned int i;
380 
381  // Before going ahead, make sure we have sensible arrays
382  if( x.size() != y.size() ||
383  x.size() != w.size() ||
384  x.size() < 2)
385  throw cet::exception("Geo") << "Input vectors to LinFit are not the "
386  << "correct length. x size: " << x.size()
387  << " y size: " << y.size()
388  << " w size: " << w.size();
389 
390  // Find the ranges of the input variables
391  double xlo = x[0];
392  double xhi = x[0];
393  double ylo = y[0];
394  double yhi = y[0];
395  for (i=1; i<w.size(); ++i) {
396  if (x[i]<xlo) xlo = x[i];
397  if (x[i]>xhi) xhi = x[i];
398  if (y[i]<ylo) ylo = y[i];
399  if (y[i]>yhi) yhi = y[i];
400  }
401  // Make sure the fit has some span
402  if (yhi-ylo==0.0 && xhi-xlo==0.0) {
403  std::cerr << __FILE__ << ":" << __LINE__
404  << " All points identical in line fit!" << std::endl;
405  *x1 = xlo;
406  *y1 = ylo;
407  *x2 = xhi;
408  *y2 = yhi;
409  return 0.0;
410  }
411 
412  //
413  // If the y extent is larger than the x extent, flip the variables
414  // and fit
415  //
416  if (yhi-ylo > xhi-xlo) {
417  return geo::LinFit(y,x,w,y1,x1,y2,x2);
418  }
419 
420  double m, b;
421  const double chi2 = util::LinFit(x, y, w, m, b);
422 
423  *x1 = xlo;
424  *x2 = xhi;
425  *y1 = m*(*x1)+b;
426  *y2 = m*(*x2)+b;
427 
428  return chi2;
429  }
double LinFit(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance f...
Definition: Geo.cxx:373
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
OStream cerr
Definition: OStream.cxx:7
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double chi2()
const hit & b
Definition: hits.cxx:21
double LinFit(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double &m, double &c)
Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance f...
Definition: MathUtil.cxx:36
Float_t w
Definition: plot.C:20
double geo::LinFitMinDperp ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  w,
double *  x1,
double *  y1,
double *  x2,
double *  y2 
)

Find the best-fit line to a collection of points in 2-D by minimizing the squared perpendicular distance from the points to the line.

This is not the usual "linfit" which minimizes the squared vertical distance

Parameters
x- input vector of x coordinates
y- input vector of y coordinates
w- input vector of weights for the points
x1- output x coordinate at one end of line
y1- output y coordinate at one end of line
x2- output x coordinate at other end of line
y2- output y coordinate at other end of line
Returns
The chi^2 value defined by chi^2 = sum_i[w_i d^2_i]

Definition at line 449 of file Geo.cxx.

References C, chi2(), DsqrToLine(), stan::math::fabs(), MECModelEnuComparisons::i, LinFit(), sqr(), util::sqr(), std::sqrt(), xhi, make_syst_table_plots::xlo, yhi, and ylo.

Referenced by trk::WindowTrackingAlg::DetermineInitialDirection(), trk::RLFit::Fit(), tut::TutProducer::FitPhoton(), cosrej::CosRejFxs::fitslope(), numusand::NumuSandFxs::fitslope(), trk::CosmicTrackAlg::FitView(), trk::WindowTrackingAlg::FitWindow(), trk::CosmicTrackAlg::IsTrackDownstreamFromTiming(), trk::KalmanTrack::SingleSegment(), and zcl::FMMTracker::Tracking2D().

454  {
455  // Before going ahead, make sure we have sensible arrays
456  if( x.size() != y.size() ||
457  x.size() != w.size() ||
458  x.size() < 2)
459  throw cet::exception("Geo") << "Input vectors to LinFit are not the "
460  << "correct length. x size: " << x.size()
461  << " y size: " << y.size()
462  << " w size: " << w.size();
463 
464  //--
465  // The following code implements the output of the following MAPLE
466  // script:
467  //--
468  // assume(x0,real);
469  // assume(y0,real);
470  // assume({M,B},real);
471  // assume({Dsqr},real);
472  // assume(Sw,real);
473  // assume(Swx,real);
474  // assume(Swx2,real);
475  // assume(Swy,real);
476  // assume(Swy2,real);
477  // assume(Swxy,real);
478  // y1 := M*x1 + B;
479  // y2 := M*x2 + B;
480  // Dsqr := (((x2-x1)*(y1-y0)-(x1-x0)*(y2-y1))^2/((x2-x1)^2+(y2-y1)^2));
481  // eqn1 := simplify(expand(diff(Dsqr,M) = 0));
482  // eqn2 := simplify(expand(diff(Dsqr,B) = 0));
483  // Eqn1 := -2*B*Swy*M +B^2*M*Sw +Swy2*M -Swxy*M^2 -B*Swx +Swxy
484  // +B*Swx*M^2 -Swx2*M = 0;
485  // Eqn2 := B*Sw - Swy + M*Swx = 0;
486  // solve({Eqn1,Eqn2},{M,B});
487  // allvalues(%);
488  //--
489 
490  // register is deprecated in c++17 standard
491  //unsigned register int i;
492  unsigned int i;
493 
494  // Find the extremes of the inputs
495  double xlo = DBL_MAX;
496  double xhi = -DBL_MAX;
497  double ylo = DBL_MAX;
498  double yhi = -DBL_MAX;
499  for (i=0; i<w.size(); ++i) {
500  if(w[i] == 0) continue;
501  if (x[i]<xlo) xlo = x[i];
502  if (y[i]<ylo) ylo = y[i];
503  if (x[i]>xhi) xhi = x[i];
504  if (y[i]>yhi) yhi = y[i];
505  }
506 
507  // This algorithm really fails if the y values are identical
508  // return the low and hi values if it's too flat
509  if(fabs(yhi-ylo) < 0.1){
510  *x1 = xlo;
511  *y1 = ylo;
512  *x2 = xhi;
513  *y2 = yhi;
514  return 0.; //its a flat line, chi^2 is 0 by definition
515  }
516 
517  // For stability, fit in a way that avoids infinite slopes,
518  // exchanging the x and y variables as needed.
519  if (fabs(xlo - xhi) < 1.e-3) {
520  double chi2;
521  double xx1, yy1, xx2, yy2;
522  // Notice: (x,y) -> (y,x)
523  chi2 = LinFitMinDperp(y,x,w,&xx1, &yy1,&xx2, &yy2);
524  *x1 = xlo; // Infinite slope means that your initial x positions should be the input
525  *y1 = xx1;
526  *x2 = xhi;
527  *y2 = xx2;
528  return chi2;
529  }
530 
531  // Accumulate the sums needed to compute the fit line
532  double Sw = 0.0;
533  double Swx = 0.0;
534  double Swy = 0.0;
535  double Swxy= 0.0;
536  double Swy2= 0.0;
537  double Swx2= 0.0;
538  for (i=0; i<w.size(); ++i) {
539  Sw += w[i];
540  Swx += w[i]*x[i];
541  Swy += w[i]*y[i];
542  Swxy += w[i]*x[i]*y[i];
543  Swy2 += w[i]*y[i]*y[i];
544  Swx2 += w[i]*x[i]*x[i];
545  }
546 
547  if(Sw == 0.0)
548  throw cet::exception("Geo") << "sum of weights is 0 in LinFitMinDperp";
549 
550  // Precalculate reused squares
551  using util::sqr;
552  const double SwSq = sqr(Sw);
553  const double SwxSq = sqr(Swx);
554  const double SwySq = sqr(Swy);
555 
556  // C and D are two handy temporary variables
557  double C =
558  +sqr(SwxSq) // Swx^4
559  -2.0*SwxSq*Swx2*Sw
560  +2.0*SwxSq*SwySq
561  +2.0*SwxSq*Swy2*Sw
562  +sqr(Swx2)*SwSq
563  +2.0*Swx2*Sw*SwySq
564  -2.0*Swx2*SwSq*Swy2
565  +sqr(sqr(Swy)) // Swy^4
566  -2.0*SwySq*Swy2*Sw
567  +sqr(Swy2)*SwSq
568  -8.0*Swx*Swy*Swxy*Sw
569  +4.0*sqr(Swxy)*SwSq;
570  if (C>0.0) C = sqrt(C);
571  else C = 0.0;
572  double D = -Swx*Swy+Swxy*Sw;
573 
574  // The first of the two solutions. This one is the best fit through
575  // the points
576  double M1;
577  double B1;
578  if (D==0.0) {
579  // D could be zero, this might happen in a segmented detector if
580  // the track fit passed through only a single readout plane and
581  // all hits share the same x coordinates. I've tried to avoid
582  // this by checking if it makes more sense to fit with x and y
583  // exchanged above. This is an extra precaution.
584  D = 1.0E-9;
585  }
586  M1 = -(-SwxSq + Swx2*Sw + SwySq - Swy2*Sw - C)/(2.0*D);
587  B1 = -(-Swy+M1*Swx)/Sw;
588 
589  // This second solution is perpendicular to the first and represents
590  // the worst fit
591  // M2 = -(-SwxSq + Swx2*Sw + SwySq - Swy2*Sw + C)/(2.0*D);
592  // B2 = -(-Swy+M2*Swx)/Sw;
593 
594  *x1 = xlo;
595  *y1 = M1*xlo + B1;
596  *x2 = xhi;
597  *y2 = M1*xhi + B1;
598 
599  // Compute the chi^2 function for return
600  double chi2 = 0.0;
601  for (i=0; i<w.size(); ++i) {
602  chi2 += w[i]*geo::DsqrToLine(x[i],y[i],*x1,*y1,*x2, *y2);
603  }
604 
605  // test if linfit is better
606 
607  double chi2lin, linx1, linx2, liny1, liny2;
608 
609  chi2lin = LinFit(x,y,w,&linx1,&liny1,&linx2,&liny2);
610 
611  if(chi2lin < chi2) { //something is wrong with the perp fit, use the lin fit
612  *x1 = linx1;
613  *y1 = liny1;
614  *x2 = linx2;
615  *y2 = liny2;
616 
617  chi2 = chi2lin;
618  }
619 
620 
621  return chi2;
622  }
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
double LinFit(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
Find the best-fit line to a collection of points in 2-D by minimizing the squared vertical distance f...
Definition: Geo.cxx:373
Float_t y1[n_points_granero]
Definition: compare.C:5
Float_t x1[n_points_granero]
Definition: compare.C:5
T sqrt(T number)
Definition: d0nt_math.hpp:156
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double chi2()
T sqr(T x)
More efficient square function than pow(x,2)
Definition: MathUtil.h:23
const double C
double LinFitMinDperp(const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &w, double *x1, double *y1, double *x2, double *y2)
Find the best-fit line to a collection of points in 2-D by minimizing the squared perpendicular dista...
Definition: Geo.cxx:449
double DsqrToLine(double x0, double y0, double x1, double y1, double x2, double y2)
In two dimensions, return the perpendicular distance from a point (x0,y0) to a line defined by end po...
Definition: Geo.cxx:338
T sqr(T x)
Function to perform, and table to cache, timing fits to ADC values.
Definition: ADCShapeFit.cxx:23
Float_t w
Definition: plot.C:20
bool geo::ltKey ( std::pair< double, double >  a,
double  b 
)

Definition at line 770 of file Geo.cxx.

References b.

Referenced by GetAvgPath2D().

770 {return a.first < b;}
const double a
const hit & b
Definition: hits.cxx:21
CellUniqueId geo::NodesToUniqueId ( const std::vector< const TGeoNode * > &  n,
unsigned int  depth 
)

Definition at line 21 of file CellUniqueId.cxx.

References om::cout, allTimeWatchdog::endl, MECModelEnuComparisons::i, and it.

Referenced by geo::CellGeo::CellGeo(), and geo::GeometryBase::CurrentCellId().

23  {
24  // Only the last seven levels are required for uniqueness. Avoid overflowing
25  // the CellUniqueId.
26  const unsigned int nlvl = 6;
27  if(depth < nlvl) return 0;
28 
29  // There are only a handful of unique node pointers, store them here
30  static std::unordered_map<const TGeoNode*, int> nodemap;
31 
32  CellUniqueId id = 0;
33  for(unsigned int i = depth-nlvl; i <= depth; ++i){
34  auto it = nodemap.find(n[i]);
35  if(it == nodemap.end()){
36  //will be adding new index to the map
37  int mapsize = nodemap.size()+1;
38  nodemap[n[i]] = mapsize;
39  id += mapsize;
40  // In testing (2018/01/26) it was 141.
41  // In testing (2018/01/30) it was 255
42  if(nodemap.size() == 512){
43  std::cout << "NodesToUniqueId: Number of unique TGeoNodes exceeds 511."
44  << " Need to fix the logic here. Abort." << std::endl;
45  abort();
46  }
47  }
48  else{
49  id += it->second;
50  }
51 
52  if(id > ULLONG_MAX/512){
53  std::cout << "NodesToUniqueId: overflow" << std::endl;
54  abort();
55  }
56  id *= 512;
57  } // end for i
58  return id+1; // ensure result is always nonzero
59 
60  // This is the old code, but as of the root6 upgrade, the paths are all
61  // like vPlaneV_0/vModuleV_0/vExtruV_0/vCellV_0 rather than
62  // vPlaneV_3/vModuleV_1/vExtruV_4/vCellV_1, so we use the list of parent
63  // pointers to determine the unique ID instead.
64  /*
65  static std::vector<int> ids;
66  ids.clear();
67  for (unsigned int i=0; i<=depth; ++i) {
68  GetNodeNumbers(n[i]->GetName(), ids);
69  }
70  return IdsToUniqueId(ids);
71  */
72  }
set< int >::iterator it
OStream cout
Definition: OStream.cxx:6
unsigned long long int CellUniqueId
Definition: CellUniqueId.h:15
std::ostream & geo::operator<< ( std::ostream &  os,
const OfflineChan chan 
)

Definition at line 35 of file OfflineChan.cxx.

References geo::OfflineChan::Cell(), and geo::OfflineChan::Plane().

36  {
37  os << "Plane " << chan.Plane() << " Cell " << chan.Cell();
38  return os;
39  }
static bool geo::plane_sort ( const PlaneGeo p1,
const PlaneGeo p2 
)
static

Definition at line 38 of file GeometryBase.cxx.

References geo::PlaneGeo::Cell(), and geo::CellGeo::GetCenter().

Referenced by geo::GeometryBase::LoadGeometryFile().

39  {
40  double xyz1[3], xyz2[3];
41  p1->Cell(0)->GetCenter(xyz1);
42  p2->Cell(0)->GetCenter(xyz2);
43  return xyz1[2]<xyz2[2];
44  }
void geo::ProjectToBoxEdge ( const double  xyz[],
const double  dxyz[],
double  xlo,
double  xhi,
double  ylo,
double  yhi,
double  zlo,
double  zhi,
double  xyzout[] 
)

Project along a direction from a particular starting point to the edge of a box.

Parameters
xyz- The starting x,y,z location. Must be inside box.
dxyz- Direction vector
xlo- Low edge of box in x
xhi- Low edge of box in x
ylo- Low edge of box in y
yhi- Low edge of box in y
zlo- Low edge of box in z
zhi- Low edge of box in z
xyzout- On output, the position at the box edge

Note: It should be safe to use the same array for input and output.

Definition at line 38 of file Geo.cxx.

References d, dx, dy, dz, and MECModelEnuComparisons::i.

Referenced by caf::AddCosmicTruthToVec(), earms::ElasticArmsValidate::analyze(), geo::GeometryBase::DEdge(), remid::RecoMuon::IsTrackContained(), and geo::GeometryTest::testProject().

44  {
45  // Make sure we're inside the box!
46 
47  if(xyz[0] < xlo || xyz[0] > xhi ||
48  xyz[1] < ylo || xyz[1] > yhi ||
49  xyz[2] < zlo || xyz[2] > zhi)
50  throw cet::exception("Geo") << "provided point is outside of the specified box";
51 
52  // Compute the distances to the x/y/z walls
53  double dx = 99.E99;
54  double dy = 99.E99;
55  double dz = 99.E99;
56  if (dxyz[0]>0.0) { dx = (xhi-xyz[0])/dxyz[0]; }
57  else if (dxyz[0]<0.0) { dx = (xlo-xyz[0])/dxyz[0]; }
58  if (dxyz[1]>0.0) { dy = (yhi-xyz[1])/dxyz[1]; }
59  else if (dxyz[1]<0.0) { dy = (ylo-xyz[1])/dxyz[1]; }
60  if (dxyz[2]>0.0) { dz = (zhi-xyz[2])/dxyz[2]; }
61  else if (dxyz[2]<0.0) { dz = (zlo-xyz[2])/dxyz[2]; }
62 
63  // Choose the shortest distance
64  double d = 0.0;
65  if (dx<dy && dx<dz) d = dx;
66  else if (dy<dz && dy<dx) d = dy;
67  else if (dz<dx && dz<dy) d = dz;
68 
69  // Make the step
70  for (int i=0; i<3; ++i) {
71  xyzout[i] = xyz[i] + dxyz[i]*d;
72  }
73  }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double dy[NP][NC]
double dx[NP][NC]
double dz[NP][NC]
Float_t d
Definition: plot.C:236
void geo::ProjectToBoxEdgeFromOutside ( const double  xyz[],
const double  dxyz[],
int  axis,
double  edge,
double  xyzout[] 
)

Project from a position outside of a box to an edge of the box with coordinate value edge for the axis axis.

axis = 0 –> x, axis = 1 –> y, axis = 2 –> z xyzout is the position on the desired edge

Definition at line 148 of file Geo.cxx.

References allInOneTrainingPlots::axis, om::cerr, e, allTimeWatchdog::endl, and std::sqrt().

Referenced by IntersectsBox(), and geo::LiveGeometry::ProjectedDistance().

153  {
154  double momDir = dxyz[axis];
155  double posDir = xyz[axis];
156  double momTot = sqrt(dxyz[0]*dxyz[0] + dxyz[1]*dxyz[1] + dxyz[2]*dxyz[2]);
157 
158  if(momTot < 1.e-9){
159  std::cerr << "no direction information supplied, do nothing" << std::endl;
160  return;
161  }
162 
163  double ddS = momDir/momTot; // direction cosine in the desired direction
164  double length1Dim = (edge - posDir); // length in desired direction to that edge;
165 
166  if(TMath::Abs(ddS) > 0.){
167  length1Dim /= ddS;
168  xyzout[0] = xyz[0] + length1Dim*dxyz[0]/momTot;
169  xyzout[1] = xyz[1] + length1Dim*dxyz[1]/momTot;
170  xyzout[2] = xyz[2] + length1Dim*dxyz[2]/momTot;
171  }
172 
173  return;
174  }
T sqrt(T number)
Definition: d0nt_math.hpp:156
OStream cerr
Definition: OStream.cxx:7
Float_t e
Definition: plot.C:35
static bool geo::sort_hori ( const CellGeo c1,
const CellGeo c2 
)
static

Definition at line 25 of file PlaneGeo.cxx.

References geo::CellGeo::GetCenter().

Referenced by geo::PlaneGeo::PlaneGeo().

26  {
27  double xyz1[3], xyz2[3];
28  c1->GetCenter(xyz1);
29  c2->GetCenter(xyz2);
30  return xyz1[1]<xyz2[1];
31  }
c2
Definition: demo5.py:33
c1
Definition: demo5.py:24
static bool geo::sort_vert ( const CellGeo c1,
const CellGeo c2 
)
static

Definition at line 32 of file PlaneGeo.cxx.

References geo::CellGeo::GetCenter().

Referenced by geo::PlaneGeo::PlaneGeo().

33  {
34  double xyz1[3], xyz2[3];
35  c1->GetCenter(xyz1);
36  c2->GetCenter(xyz2);
37  return xyz1[0]<xyz2[0];
38  }
c2
Definition: demo5.py:33
c1
Definition: demo5.py:24
int geo::WhichWallofBox ( const double  xyz[],
double  xlo,
double  xhi,
double  ylo,
double  yhi,
double  zlo,
double  zhi 
)

Definition at line 75 of file Geo.cxx.

79  {
80  int wall = 0;
81  if(xyz[0] >= xlo-0.01 && xyz[0] <= xlo+0.01) wall = 1;
82  if(xyz[0] >= xhi-0.01 && xyz[0] <= xhi+0.01) wall = 2;
83  if(xyz[1] >= ylo-0.01 && xyz[1] <= ylo+0.01) wall = 3;
84  if(xyz[1] >= yhi-0.01 && xyz[1] <= yhi+0.01) wall = 4;
85  if(xyz[2] >= zlo-0.01 && xyz[2] <= zlo+0.01) wall = 5;
86  if(xyz[2] >= zhi-0.01 && xyz[2] <= zhi+0.01) wall = 6;
87 
88 // if(wall == 0) std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
89 
90  return wall;
91 
92  }

Variable Documentation

std::map<double, double> geo::gPathTable
static

Definition at line 683 of file Geo.cxx.

const double geo::NOvAneardetNuMiAngle = 0.0145766 * CLHEP::radian

Angle between NuMi beamline and the NOvA near detectors.

Definition at line 43 of file CoordinateTransformation.h.

Referenced by geo::CoordinateTransformation::setCoordinateParameters().

const double geo::NuMiBeamLineAngle = 0.057715289 * CLHEP::radian

Angle between NuMI beamline and the earth's surface. Equals to 3.3 degrees

Definition at line 40 of file CoordinateTransformation.h.

Referenced by geo::CoordinateTransformation::setCoordinateParameters().

const double geo::pointS_Z = 184.25 * CLHEP::m

Z position of the point S (mean hadron decay) in beam coordinates. Taken from NOvA-doc-5485.

Definition at line 36 of file CoordinateTransformation.h.

Referenced by geo::CoordinateTransformation::print().