CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StraightLinePlaneCrossing.cc
Go to the documentation of this file.
2 
4 
5 #include <cmath>
6 #include <cfloat>
7 
9  const DirectionType& momentum,
10  const PropagationDirection propDir) :
11  theX0(point),
12  theP0(momentum.unit()),
13  thePropDir(propDir) {
14 // cout << "StraightLinePlaneCrossing: x0 = " << point
15 // << ", p0 = " << momentum << endl;
16 }
17 //
18 // Propagation status and path length to intersection
19 //
20 std::pair<bool,double>
22  //
23  // Protect against p_normal=0 and calculate path length
24  //
25  PositionTypeDouble planePosition(plane.position());
26  DirectionTypeDouble planeNormal(plane.normalVector());
27 // double pz = plane.localZ(GlobalVector(theP0));
28  double pz = planeNormal.dot(theP0);
29 // cout << "pz = " << pz << endl;
30  if ( fabs(pz)<FLT_MIN ) return std::pair<bool,double>(false,0);
31 // double dS = -plane.localZ(GlobalPoint(theX0))/pz;
32  double dS = -planeNormal.dot(theX0-planePosition)/pz;
33 // if ( thePropDir==alongMomentum ) cout << "alongMomentum ";
34 // else if ( thePropDir==oppositeToMomentum ) cout << "oppositeToMomentum ";
35 // else cout << "anyDirection ";
36 // cout << dS << endl;
37  if ( (thePropDir==alongMomentum && dS<0.) ||
38  (thePropDir==oppositeToMomentum && dS>0.) ) return std::pair<bool,double>(false,0);
39  //
40  // Return result
41  //
42  return std::pair<bool,double>(true,dS);
43 }
44 
45 std::pair<bool,StraightLinePlaneCrossing::PositionType>
47 {
48  std::pair<bool,double> crossed = pathLength(plane);
49  if (crossed.first) return std::pair<bool,PositionType>(true, position(crossed.second));
50  else return std::pair<bool,PositionType>(false, PositionType());
51 }
52 
Basic3DVector< float > PositionType
const PositionTypeDouble theX0
const PropagationDirection thePropDir
GlobalVector normalVector() const
Definition: Plane.h:47
StraightLinePlaneCrossing(const PositionType &point, const DirectionType &momentum, const PropagationDirection propDir=alongMomentum)
PropagationDirection
Definition: Plane.h:17
string unit
Definition: csvLumiCalc.py:46
std::pair< bool, double > pathLength(const Plane &plane) const
PositionType position(double s) const
const PositionTypeDouble theP0
const PositionType & position() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
T dot(const Basic3DVector &rh) const
Scalar product, or &quot;dot&quot; product, with a vector of same type.