CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
PathToPlane2Order Class Reference

#include <PathToPlane2Order.h>

Public Types

typedef GloballyPositioned
< Scalar
Frame
 
typedef Plane::Scalar Scalar
 
typedef Basic3DVector< ScalarVector3D
 

Public Member Functions

std::pair< bool, double > operator() (const Plane &plane, const Vector3D &position, const Vector3D &momentum, double charge, const PropagationDirection propDir=alongMomentum)
 
std::pair< bool, double > operator() (const Plane &plane, const GlobalPoint &position, const GlobalVector &momentum, double charge, const PropagationDirection propDir=alongMomentum)
 
 PathToPlane2Order (const RKLocalFieldProvider &fld, const Frame *fieldFrame)
 

Private Attributes

const RKLocalFieldProvidertheField
 
const FrametheFieldFrame
 

Detailed Description

Definition at line 21 of file PathToPlane2Order.h.

Member Typedef Documentation

Definition at line 26 of file PathToPlane2Order.h.

Definition at line 24 of file PathToPlane2Order.h.

Definition at line 25 of file PathToPlane2Order.h.

Constructor & Destructor Documentation

PathToPlane2Order::PathToPlane2Order ( const RKLocalFieldProvider fld,
const Frame fieldFrame 
)
inline

Definition at line 28 of file PathToPlane2Order.h.

28  :
29  theField(fld), theFieldFrame(fieldFrame) {}
const RKLocalFieldProvider & theField
const Frame * theFieldFrame

Member Function Documentation

std::pair< bool, double > PathToPlane2Order::operator() ( const Plane plane,
const Vector3D position,
const Vector3D momentum,
double  charge,
const PropagationDirection  propDir = alongMomentum 
)

the position and momentum are local in the FieldFrame; the plane is in the global frame

Definition at line 9 of file PathToPlane2Order.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), Vector3DBase< T, FrameTag >::cross(), PixelRecoUtilities::curvature(), RKLocalFieldProvider::inTesla(), relval_steps::k, PV3DBase< T, PVType, FrameType >::mag(), Basic3DVector< T >::mag(), HelixArbitraryPlaneCrossing::pathLength(), PV3DBase< T, PVType, FrameType >::perp(), theField, theFieldFrame, GloballyPositioned< T >::toGlobal(), GloballyPositioned< T >::toLocal(), FrameChanger::transformPlane(), Vector3DBase< T, FrameTag >::unit(), Basic3DVector< T >::unit(), Basic3DVector< T >::x(), Basic3DVector< T >::y(), and Basic3DVector< T >::z().

14 {
15  // access to the field in field frame local coordinates
16  RKLocalFieldProvider::Vector B = theField.inTesla( pos.x(), pos.y(), pos.z());
17 
18  // Frame::GlobalVector localZ = Frame::GlobalVector( B.unit()); // local Z along field
19  // transform field axis to global frame
20  Frame::GlobalVector localZ = theFieldFrame->toGlobal( Frame::LocalVector( B.unit())); // local Z along field
21 
22  Frame::GlobalVector localY = localZ.cross( Frame::GlobalVector( 1,0,0));
23  if (localY.mag() < 0.1) {
24  localY = localZ.cross( Frame::GlobalVector(0,1,0)).unit();
25  }
26  else {
27  localY = localY.unit();
28  }
29  Frame::GlobalVector localX = localY.cross(localZ);
30 
31 
33  Frame::RotationType frot( localX, localY, localZ);
34  // frame in which the field is along Z
35  Frame frame( fpos, frot);
36 
37  // cout << "PathToPlane2Order frame " << frame.position() << endl << frame.rotation() << endl;
38 
39  // transform the position and direction to that frame
40  Frame::LocalPoint localPos = frame.toLocal( fpos); // same as LocalPoint(0,0,0)
41 
42  //transform momentum from field frame to new frame via global frame
44  Frame::LocalVector localMom = frame.toLocal( gmom);
45 
46  // transform the plane to the same frame
47  Plane localPlane = FrameChanger::transformPlane( plane, frame);
48 /*
49  cout << "PathToPlane2Order input plane " << plane.position() << endl
50  << plane.rotation() << endl;
51  cout << "PathToPlane2Order transformed plane " << localPlane->position() << endl
52  << localPlane->rotation() << endl;
53 */
54  double k = 2.99792458e-3;
55  double transverseMomentum = localMom.perp(); // transverse to the field
56  if (!(transverseMomentum != 0) ) { // if (!(x!=0)) will trap both 0 and NaN
57  //LogDebug("PathToPlane2Order_ZeroMomentum") << "Momentum transverse to the field is zero or Nan (" << transverseMomentum << ")\n";
58  return std::pair<bool,double>(false,0);
59  }
60  double curvature = -k * charge * B.mag() / transverseMomentum;
61 /*
62  cout << "PathToPlane2Order curvature " << curvature << endl;
63  cout << "transverseMomentum " << transverseMomentum << endl;
64  cout << "B.mag() " << B.mag() << endl;
65  cout << "localZ " << localZ << endl;
66  cout << "pos " << pos << endl;
67  cout << "momentum " << momentum << endl;
68  cout << "localPos " << localPos << endl;
69  cout << "localMom " << localMom << endl;
70 */
71 /*
72  cout << "PathToPlane2Order: local pos " << localPos << " mom " << localMom
73  << " curvature " << curvature << endl;
74  cout << "PathToPlane2Order: local plane pos " << localPlane->position()
75  << " normal " << localPlane->normalVector() << endl;
76 */
77  HelixArbitraryPlaneCrossing crossing( localPos.basicVector(), localMom.basicVector(),
78  curvature, propDir);
79  std::pair<bool,double> res = crossing.pathLength(localPlane);
80 
81  return res;
82 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GloballyPositioned< Scalar > Frame
Basic3DVector unit() const
Vector3DBase< T, GlobalTag > GlobalVector
Definition: Plane.h:17
Vector3DBase< T, LocalTag > LocalVector
T curvature(T InversePt, const edm::EventSetup &iSetup)
virtual std::pair< bool, double > pathLength(const Plane &plane)
GlobalPoint toGlobal(const LocalPoint &lp) const
static Plane transformPlane(const Plane &plane, const GloballyPositioned< T > &frame)
Definition: FrameChanger.h:15
Point3DBase< T, LocalTag > LocalPoint
Point3DBase< T, GlobalTag > PositionType
const RKLocalFieldProvider & theField
TkRotation< T > RotationType
const Frame * theFieldFrame
Vector inTesla(const LocalPoint &lp) const
the argument lp is in the local frame specified in the constructor
std::pair<bool,double> PathToPlane2Order::operator() ( const Plane plane,
const GlobalPoint position,
const GlobalVector momentum,
double  charge,
const PropagationDirection  propDir = alongMomentum 
)
inline

Definition at line 39 of file PathToPlane2Order.h.

References PV3DBase< T, PVType, FrameType >::basicVector(), and GloballyPositioned< T >::toLocal().

43  {
44  return operator()( plane, theFieldFrame->toLocal(position).basicVector(),
45  theFieldFrame->toLocal(momentum).basicVector(), charge, propDir);
46  }
LocalPoint toLocal(const GlobalPoint &gp) const
std::pair< bool, double > operator()(const Plane &plane, const Vector3D &position, const Vector3D &momentum, double charge, const PropagationDirection propDir=alongMomentum)
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56
const Frame * theFieldFrame

Member Data Documentation

const RKLocalFieldProvider& PathToPlane2Order::theField
private

Definition at line 50 of file PathToPlane2Order.h.

Referenced by operator()().

const Frame* PathToPlane2Order::theFieldFrame
private

Definition at line 51 of file PathToPlane2Order.h.

Referenced by operator()().