CMS 3D CMS Logo

PathToPlane2Order.cc
Go to the documentation of this file.
1 #include "PathToPlane2Order.h"
2 #include "RKLocalFieldProvider.h"
3 #include "FrameChanger.h"
5 
6 #include <iostream>
7 
8 std::pair<bool, double> PathToPlane2Order::operator()(const Plane& plane,
9  const Vector3D& pos,
10  const Vector3D& momentum,
11  double charge,
12  const PropagationDirection propDir) {
13  // access to the field in field frame local coordinates
15 
16  // Frame::GlobalVector localZ = Frame::GlobalVector( B.unit()); // local Z along field
17  // transform field axis to global frame
18  Frame::GlobalVector localZ = theFieldFrame->toGlobal(Frame::LocalVector(B.unit())); // local Z along field
19 
21  if (localY.mag() < 0.1) {
22  localY = localZ.cross(Frame::GlobalVector(0, 1, 0)).unit();
23  } else {
24  localY = localY.unit();
25  }
26  Frame::GlobalVector localX = localY.cross(localZ);
27 
29  Frame::RotationType frot(localX, localY, localZ);
30  // frame in which the field is along Z
31  Frame frame(fpos, frot);
32 
33  // cout << "PathToPlane2Order frame " << frame.position() << endl << frame.rotation() << endl;
34 
35  // transform the position and direction to that frame
36  Frame::LocalPoint localPos = frame.toLocal(fpos); // same as LocalPoint(0,0,0)
37 
38  //transform momentum from field frame to new frame via global frame
40  Frame::LocalVector localMom = frame.toLocal(gmom);
41 
42  // transform the plane to the same frame
43  Plane localPlane = FrameChanger::transformPlane(plane, frame);
44  /*
45  cout << "PathToPlane2Order input plane " << plane.position() << endl
46  << plane.rotation() << endl;
47  cout << "PathToPlane2Order transformed plane " << localPlane->position() << endl
48  << localPlane->rotation() << endl;
49 */
50  double k = 2.99792458e-3;
51  double transverseMomentum = localMom.perp(); // transverse to the field
52  if (!(transverseMomentum != 0)) { // if (!(x!=0)) will trap both 0 and NaN
53  //LogDebug("PathToPlane2Order_ZeroMomentum") << "Momentum transverse to the field is zero or Nan (" << transverseMomentum << ")\n";
54  return std::pair<bool, double>(false, 0);
55  }
56  double curvature = -k * charge * B.mag() / transverseMomentum;
57  /*
58  cout << "PathToPlane2Order curvature " << curvature << endl;
59  cout << "transverseMomentum " << transverseMomentum << endl;
60  cout << "B.mag() " << B.mag() << endl;
61  cout << "localZ " << localZ << endl;
62  cout << "pos " << pos << endl;
63  cout << "momentum " << momentum << endl;
64  cout << "localPos " << localPos << endl;
65  cout << "localMom " << localMom << endl;
66 */
67  /*
68  cout << "PathToPlane2Order: local pos " << localPos << " mom " << localMom
69  << " curvature " << curvature << endl;
70  cout << "PathToPlane2Order: local plane pos " << localPlane->position()
71  << " normal " << localPlane->normalVector() << endl;
72 */
73  HelixArbitraryPlaneCrossing crossing(localPos.basicVector(), localMom.basicVector(), curvature, propDir);
74  std::pair<bool, double> res = crossing.pathLength(localPlane);
75 
76  return res;
77 }
Vector3DBase
Definition: Vector3DBase.h:8
GloballyPositioned
Definition: GloballyPositioned.h:18
TkRotation
Definition: extTkRotation.h:13
phase1PixelTopology::localY
constexpr uint16_t localY(uint16_t py)
Definition: phase1PixelTopology.h:58
pos
Definition: PixelAliasList.h:18
RKLocalFieldProvider::inTesla
Vector inTesla(const LocalPoint &lp) const
the argument lp is in the local frame specified in the constructor
Definition: RKLocalFieldProvider.cc:11
PixelRecoUtilities::curvature
T curvature(T InversePt, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:42
PathToPlane2Order::operator()
std::pair< bool, double > operator()(const Plane &plane, const Vector3D &position, const Vector3D &momentum, double charge, const PropagationDirection propDir=alongMomentum)
Definition: PathToPlane2Order.cc:8
RKLocalFieldProvider.h
FrameChanger.h
PathToPlane2Order.h
HelixArbitraryPlaneCrossing
Definition: HelixArbitraryPlaneCrossing.h:10
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Point3DBase< T, GlobalTag >
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
phase1PixelTopology::localX
constexpr uint16_t localX(uint16_t px)
Definition: phase1PixelTopology.h:49
FrameChanger::transformPlane
static Plane transformPlane(const Plane &plane, const GloballyPositioned< T > &frame)
Definition: FrameChanger.h:14
HelixArbitraryPlaneCrossing.h
Vector3DBase::cross
Vector3DBase< typename PreciseFloatType< T, U >::Type, FrameTag > cross(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:110
res
Definition: Electron.h:6
PV3DBase::basicVector
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
PropagationDirection
PropagationDirection
Definition: PropagationDirection.h:4
PathToPlane2Order::theField
const RKLocalFieldProvider & theField
Definition: PathToPlane2Order.h:51
Plane
Definition: Plane.h:16
PathToPlane2Order::theFieldFrame
const Frame * theFieldFrame
Definition: PathToPlane2Order.h:52
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
Basic3DVector< Scalar >
GloballyPositioned::toGlobal
GlobalPoint toGlobal(const LocalPoint &lp) const
Definition: GloballyPositioned.h:66