CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HelixBarrelCylinderCrossing Class Reference

#include <HelixBarrelCylinderCrossing.h>

Public Types

typedef GlobalVector DirectionType
 
typedef Basic2DVector< TmpTypePoint
 
typedef GlobalPoint PositionType
 
enum  Solution { bothSol, bestSol, onlyPos }
 
typedef double TmpType
 
typedef Basic2DVector< TmpTypeVector
 

Public Member Functions

DirectionType direction () const
 
bool hasSolution () const
 
 HelixBarrelCylinderCrossing (const GlobalPoint &startingPos, const GlobalVector &startingDir, double rho, PropagationDirection propDir, const Cylinder &cyl, Solution sol=bothSol)
 
double pathLength () const
 
PositionType position () const
 
PositionType position1 () const
 Method to access separately each solution of the helix-cylinder crossing equations. More...
 
PositionType position2 () const
 Method to access separately each solution of the helix-cylinder crossing equations. More...
 

Private Member Functions

std::pair< Vector, int > chooseSolution (const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir)
 

Private Attributes

DirectionType theDir
 
PositionType thePos
 
PositionType thePos1
 
PositionType thePos2
 
double theS
 
bool theSolExists
 

Detailed Description

Calculates the crossing of a helix with a barrel cylinder.

Definition at line 16 of file HelixBarrelCylinderCrossing.h.

Member Typedef Documentation

◆ DirectionType

Definition at line 25 of file HelixBarrelCylinderCrossing.h.

◆ Point

Definition at line 21 of file HelixBarrelCylinderCrossing.h.

◆ PositionType

Definition at line 24 of file HelixBarrelCylinderCrossing.h.

◆ TmpType

Definition at line 20 of file HelixBarrelCylinderCrossing.h.

◆ Vector

Definition at line 22 of file HelixBarrelCylinderCrossing.h.

Member Enumeration Documentation

◆ Solution

Enumerator
bothSol 
bestSol 
onlyPos 

Definition at line 18 of file HelixBarrelCylinderCrossing.h.

18 { bothSol, bestSol, onlyPos };

Constructor & Destructor Documentation

◆ HelixBarrelCylinderCrossing()

HelixBarrelCylinderCrossing::HelixBarrelCylinderCrossing ( const GlobalPoint startingPos,
const GlobalVector startingDir,
double  rho,
PropagationDirection  propDir,
const Cylinder cyl,
Solution  sol = bothSol 
)

Definition at line 17 of file HelixBarrelCylinderCrossing.cc.

22  {
23  // assumes the cylinder is centered at 0,0
24  double R = cyl.radius();
25 
26  // protect for zero curvature case
27  const double sraightLineCutoff = 1.e-7;
28  if (fabs(rho) * R < sraightLineCutoff && fabs(rho) * startingPos.perp() < sraightLineCutoff) {
29  // switch to straight line case
30  StraightLineCylinderCrossing slc(cyl.toLocal(startingPos), cyl.toLocal(startingDir), propDir);
31  std::pair<bool, double> pl = slc.pathLength(cyl);
32  if (pl.first) {
33  theSolExists = true;
34  theS = pl.second;
35  thePos = cyl.toGlobal(slc.position(theS));
36  theDir = startingDir;
37  } else
38  theSolExists = false;
39  return; // all needed data members have been set
40  }
41 
42  double R2cyl = R * R;
43  double pt = startingDir.perp();
44  Point center(startingPos.x() - startingDir.y() / (pt * rho), startingPos.y() + startingDir.x() / (pt * rho));
45  double p2 = startingPos.perp2();
46  bool solveForX;
47  double B, C, E, F;
48  if (fabs(center.x()) > fabs(center.y())) {
49  solveForX = false;
50  E = (R2cyl - p2) / (2. * center.x());
51  F = center.y() / center.x();
52  B = 2. * (startingPos.y() - F * startingPos.x() - E * F);
53  C = 2. * E * startingPos.x() + E * E + p2 - R2cyl;
54  } else {
55  solveForX = true;
56  E = (R2cyl - p2) / (2. * center.y());
57  F = center.x() / center.y();
58  B = 2. * (startingPos.x() - F * startingPos.y() - E * F);
59  C = 2. * E * startingPos.y() + E * E + p2 - R2cyl;
60  }
61 
62  RealQuadEquation eq(1 + F * F, B, C);
63  if (!eq.hasSolution) {
64  theSolExists = false;
65  return;
66  }
67 
68  Vector d1, d2;
69  ;
70  if (solveForX) {
71  d1 = Point(eq.first, E - F * eq.first);
72  d2 = Point(eq.second, E - F * eq.second);
73  } else {
74  d1 = Point(E - F * eq.first, eq.first);
75  d2 = Point(E - F * eq.second, eq.second);
76  }
77 
78  Vector theD;
79  int theActualDir;
80 
81  std::tie(theD, theActualDir) = chooseSolution(d1, d2, startingPos, startingDir, propDir);
82  if (!theSolExists)
83  return;
84 
85  float ipabs = 1.f / startingDir.mag();
86  float sinTheta = float(pt) * ipabs;
87  float cosTheta = startingDir.z() * ipabs;
88 
89  // -------
90 
91  auto dMag = theD.mag();
92  float tmp = 0.5f * float(dMag * rho);
93  if (std::abs(tmp) > 1.f)
94  tmp = std::copysign(1.f, tmp);
95  theS = theActualDir * 2.f * std::asin(tmp) / (float(rho) * sinTheta);
96  thePos = GlobalPoint(startingPos.x() + theD.x(), startingPos.y() + theD.y(), startingPos.z() + theS * cosTheta);
97 
98  if (sol == onlyPos)
99  return;
100 
101  if (theS < 0)
102  tmp = -tmp;
103  auto sinPhi = 2.f * tmp * sqrt(1.f - tmp * tmp);
104  auto cosPhi = 1.f - 2.f * tmp * tmp;
105  theDir = DirectionType(startingDir.x() * cosPhi - startingDir.y() * sinPhi,
106  startingDir.x() * sinPhi + startingDir.y() * cosPhi,
107  startingDir.z());
108 
109  if (sol != bothSol)
110  return;
111 
112  //----- BM
113  //double momProj1 = startingDir.x()*d1.x() + startingDir.y()*d1.y();
114  //double momProj2 = startingDir.x()*d2.x() + startingDir.y()*d2.y();
115 
116  int theActualDir1 = propDir == alongMomentum ? 1 : -1;
117  int theActualDir2 = propDir == alongMomentum ? 1 : -1;
118 
119  auto dMag1 = d1.mag();
120  auto tmp1 = 0.5f * dMag1 * float(rho);
121  if (std::abs(tmp1) > 1.f)
122  tmp1 = std::copysign(1.f, tmp1);
123  auto theS1 = theActualDir1 * 2.f * std::asin(tmp1) / (rho * sinTheta);
124  thePos1 = GlobalPoint(startingPos.x() + d1.x(), startingPos.y() + d1.y(), startingPos.z() + theS1 * cosTheta);
125 
126  auto dMag2 = d2.mag();
127  auto tmp2 = 0.5f * dMag2 * float(rho);
128  if (std::abs(tmp2) > 1.f)
129  tmp2 = std::copysign(1.f, tmp2);
130  auto theS2 = theActualDir2 * 2.f * std::asin(tmp2) / (float(rho) * sinTheta);
131  thePos2 = GlobalPoint(startingPos.x() + d2.x(), startingPos.y() + d2.y(), startingPos.z() + theS2 * cosTheta);
132 }

References funct::abs(), alongMomentum, TtFullHadDaughter::B, bothSol, gen::C, chooseSolution(), d1, edm::eq(), f, F(), dqmMemoryStats::float, PV3DBase< T, PVType, FrameType >::mag(), Basic2DVector< T >::mag(), onlyPos, p2, StraightLineCylinderCrossing::pathLength(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), DiDispStaMuonMonitor_cfi::pt, dttmaxenums::R, Cylinder::radius(), rho, mathSSE::sqrt(), theDir, thePos, thePos1, thePos2, theS, theSolExists, createJobs::tmp, Surface::toGlobal(), GloballyPositioned< T >::toLocal(), PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), Basic2DVector< T >::y(), and PV3DBase< T, PVType, FrameType >::z().

Member Function Documentation

◆ chooseSolution()

std::pair< HelixBarrelCylinderCrossing::Vector, int > HelixBarrelCylinderCrossing::chooseSolution ( const Point p1,
const Point p2,
const PositionType startingPos,
const DirectionType startingDir,
PropagationDirection  propDir 
)
private

Definition at line 134 of file HelixBarrelCylinderCrossing.cc.

139  {
140  Vector theD;
141  int theActualDir;
142 
143  auto momProj1 = startingDir.x() * d1.x() + startingDir.y() * d1.y();
144  auto momProj2 = startingDir.x() * d2.x() + startingDir.y() * d2.y();
145 
146  if (propDir == anyDirection) {
147  theSolExists = true;
148  if (d1.mag2() < d2.mag2()) {
149  theD = d1;
150  theActualDir = (momProj1 > 0) ? 1 : -1;
151  } else {
152  theD = d2;
153  theActualDir = (momProj2 > 0) ? 1 : -1;
154  }
155  } else {
156  int propSign = propDir == alongMomentum ? 1 : -1;
157  if (momProj1 * momProj2 < 0) {
158  // if different signs return the positive one
159  theSolExists = true;
160  theD = (momProj1 * propSign > 0) ? d1 : d2;
161  theActualDir = propSign;
162  } else if (momProj1 * propSign > 0) {
163  // if both positive, return the shortest
164  theSolExists = true;
165  theD = (d1.mag2() < d2.mag2()) ? d1 : d2;
166  theActualDir = propSign;
167  } else
168  theSolExists = false;
169  }
170 
171  return std::pair<Vector, int>(theD, theActualDir);
172 }

References alongMomentum, anyDirection, d1, Basic2DVector< T >::mag2(), theSolExists, PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic2DVector< T >::y().

Referenced by HelixBarrelCylinderCrossing().

◆ direction()

DirectionType HelixBarrelCylinderCrossing::direction ( ) const
inline

Returns the direction along the helix that corresponds to path length "s" from the starting point. As for position, the direction of the crossing with a cylinder (if it exists!) is given by direction( pathLength( cylinder)).

Definition at line 61 of file HelixBarrelCylinderCrossing.h.

61 { return theDir; }

References theDir.

Referenced by TIBRing::computeCrossings().

◆ hasSolution()

bool HelixBarrelCylinderCrossing::hasSolution ( ) const
inline

Definition at line 34 of file HelixBarrelCylinderCrossing.h.

34 { return theSolExists; }

References theSolExists.

Referenced by TBLayer::computeCrossings(), and TIBRing::computeCrossings().

◆ pathLength()

double HelixBarrelCylinderCrossing::pathLength ( ) const
inline

Propagation status (true if valid) and (signed) path length along the helix from the starting point to the cylinder. The starting point and the cylinder are given in the constructor.

Definition at line 40 of file HelixBarrelCylinderCrossing.h.

40 { return theS; }

References theS.

◆ position()

PositionType HelixBarrelCylinderCrossing::position ( ) const
inline

Returns the position along the helix that corresponds to path length "s" from the starting point. If s is obtained from the pathLength method the position is the destination point, i.e. the position of the crossing with a cylinder (if it exists!) is given by position( pathLength( cylinder)).

Definition at line 48 of file HelixBarrelCylinderCrossing.h.

48 { return thePos; }

References thePos.

Referenced by TBLayer::computeCrossings(), and TIBRing::computeCrossings().

◆ position1()

PositionType HelixBarrelCylinderCrossing::position1 ( ) const
inline

Method to access separately each solution of the helix-cylinder crossing equations.

Definition at line 51 of file HelixBarrelCylinderCrossing.h.

51 { return thePos1; }

References thePos1.

◆ position2()

PositionType HelixBarrelCylinderCrossing::position2 ( ) const
inline

Method to access separately each solution of the helix-cylinder crossing equations.

Definition at line 54 of file HelixBarrelCylinderCrossing.h.

54 { return thePos2; }

References thePos2.

Member Data Documentation

◆ theDir

DirectionType HelixBarrelCylinderCrossing::theDir
private

Definition at line 65 of file HelixBarrelCylinderCrossing.h.

Referenced by direction(), and HelixBarrelCylinderCrossing().

◆ thePos

PositionType HelixBarrelCylinderCrossing::thePos
private

Definition at line 64 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position().

◆ thePos1

PositionType HelixBarrelCylinderCrossing::thePos1
private

Definition at line 69 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position1().

◆ thePos2

PositionType HelixBarrelCylinderCrossing::thePos2
private

Definition at line 70 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and position2().

◆ theS

double HelixBarrelCylinderCrossing::theS
private

Definition at line 66 of file HelixBarrelCylinderCrossing.h.

Referenced by HelixBarrelCylinderCrossing(), and pathLength().

◆ theSolExists

bool HelixBarrelCylinderCrossing::theSolExists
private
anyDirection
Definition: PropagationDirection.h:4
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
Cylinder::radius
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
HelixBarrelCylinderCrossing::onlyPos
Definition: HelixBarrelCylinderCrossing.h:18
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HelixBarrelCylinderCrossing::Point
Basic2DVector< TmpType > Point
Definition: HelixBarrelCylinderCrossing.h:21
HelixBarrelCylinderCrossing::theSolExists
bool theSolExists
Definition: HelixBarrelCylinderCrossing.h:67
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
Vector
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HelixBarrelCylinderCrossing::bestSol
Definition: HelixBarrelCylinderCrossing.h:18
StraightLineCylinderCrossing::pathLength
std::pair< bool, double > pathLength(const Cylinder &cyl) const
Definition: StraightLineCylinderCrossing.cc:16
HelixBarrelCylinderCrossing::thePos1
PositionType thePos1
Definition: HelixBarrelCylinderCrossing.h:69
RealQuadEquation
Definition: RealQuadEquation.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
p2
double p2[4]
Definition: TauolaWrapper.h:90
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
DDAxes::rho
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
StraightLineCylinderCrossing
Definition: StraightLineCylinderCrossing.h:17
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
HelixBarrelCylinderCrossing::bothSol
Definition: HelixBarrelCylinderCrossing.h:18
edm::eq
bool eq(const ELstring &s1, const ELstring s2)
Definition: ELstring.cc:39
HelixBarrelCylinderCrossing::chooseSolution
std::pair< Vector, int > chooseSolution(const Point &p1, const Point &p2, const PositionType &startingPos, const DirectionType &startingDir, PropagationDirection propDir)
Definition: HelixBarrelCylinderCrossing.cc:134
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
HelixBarrelCylinderCrossing::DirectionType
GlobalVector DirectionType
Definition: HelixBarrelCylinderCrossing.h:25
HelixBarrelCylinderCrossing::thePos
PositionType thePos
Definition: HelixBarrelCylinderCrossing.h:64
gen::C
C
Definition: PomwigHadronizer.cc:76
HelixBarrelCylinderCrossing::thePos2
PositionType thePos2
Definition: HelixBarrelCylinderCrossing.h:70
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dttmaxenums::R
Definition: DTTMax.h:29
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
HelixBarrelCylinderCrossing::theDir
DirectionType theDir
Definition: HelixBarrelCylinderCrossing.h:65
alongMomentum
Definition: PropagationDirection.h:4
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:85
PV3DBase::perp2
T perp2() const
Definition: PV3DBase.h:68
HelixBarrelCylinderCrossing::theS
double theS
Definition: HelixBarrelCylinderCrossing.h:66