CMS 3D CMS Logo

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

#include <TangentCircle.h>

Public Member Functions

int charge (float magz)
 
double curvatureError ()
 
GlobalVector directionAtVertex ()
 Return the direction at the vertex. More...
 
GlobalPoint innerPoint () const
 
GlobalPoint outerPoint () const
 
double rho () const
 
 TangentCircle ()
 
 TangentCircle (const GlobalVector &direction, const GlobalPoint &innerPoint, const GlobalPoint &outerPoint)
 
 TangentCircle (const GlobalPoint &outerPoint, const GlobalPoint &innerPoint, const GlobalPoint &vertexPoint)
 Copy of FastCircle. More...
 
 TangentCircle (const TangentCircle &primCircle, const GlobalPoint &outerPoint, const GlobalPoint &innerPoint)
 Calculate the parameters of a circle which pass by 2 points (innerPoint and outerPoint) and which is tangent to primCircle. More...
 
double vertexError () const
 
GlobalPoint vertexPoint () const
 
double x0 () const
 
double y0 () const
 

Private Member Functions

int chargeLocally (float magz, GlobalVector v) const
 
GlobalVector direction (const GlobalPoint &point) const
 
GlobalPoint getPosition (const TangentCircle &circle, const GlobalPoint &initalPosition, double theta, int direction) const
 
double isTangent (const TangentCircle &primCircle, const TangentCircle &secCircle) const
 

Private Attributes

int theCharge
 
GlobalVector theDirectionAtVertex
 
GlobalPoint theInnerPoint
 
GlobalPoint theOuterPoint
 
double theRho
 
double theVertexError
 
GlobalPoint theVertexPoint
 
double theX0
 
double theY0
 
bool valid
 

Detailed Description

Definition at line 7 of file TangentCircle.h.

Constructor & Destructor Documentation

◆ TangentCircle() [1/4]

TangentCircle::TangentCircle ( )
inline

Definition at line 13 of file TangentCircle.h.

14  : theInnerPoint(),
15  theOuterPoint(),
18  theX0(0),
19  theY0(0),
20  theRho(0),
21  theVertexError(0),
22  valid(false),
23  theCharge(0) {}
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
double theVertexError
Definition: TangentCircle.h:67

◆ TangentCircle() [2/4]

TangentCircle::TangentCircle ( const GlobalVector direction,
const GlobalPoint innerPoint,
const GlobalPoint outerPoint 
)

Calculate the circle from 2 points on the circle (the vertex=innerPoint and the outerPoint) and the tangent direction at the inner point

Definition at line 7 of file TangentCircle.cc.

References funct::cos(), bTagMiniDQMDeepCSV::denominator, direction(), SurfaceOrientation::inner, PV3DBase< T, PVType, FrameType >::mag(), mag(), SurfaceOrientation::outer, PV3DBase< T, PVType, FrameType >::perp2(), funct::sin(), theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theVertexError, theX0, theY0, valid, PV3DBase< T, PVType, FrameType >::x(), testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, PV3DBase< T, PVType, FrameType >::y(), testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

10  valid = false;
11  } else
12  valid = true;
13 
14  double x1 = inner.x();
15  double y1 = inner.y();
16  double x2 = outer.x();
17  double y2 = outer.y();
18  double alpha1 = (direction.y() != 0) ? atan(-direction.x() / direction.y()) : PI / 2;
19  double denominator = 2 * ((x1 - x2) * cos(alpha1) + (y1 - y2) * sin(alpha1));
20  theRho = (denominator != 0) ? ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / denominator : 1E12;
21 
22  // TODO : variable not yet calculated look in nucl.C
23  theX0 = 1E10;
24  theY0 = 1E10;
25 
28 
29  //theCharge = (theRho>0) ? -1 : 1;
30 
31  theCharge = 0;
32  theRho = fabs(theRho);
33 
35 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T mag() const
Definition: PV3DBase.h:64
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
T perp2() const
Definition: PV3DBase.h:68
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
double theVertexError
Definition: TangentCircle.h:67
GlobalVector direction(const GlobalPoint &point) const

◆ TangentCircle() [3/4]

TangentCircle::TangentCircle ( const GlobalPoint outerPoint,
const GlobalPoint innerPoint,
const GlobalPoint vertexPoint 
)

Copy of FastCircle.

Definition at line 37 of file TangentCircle.cc.

References innerPoint(), FastCircle::isValid(), outerPoint(), PV3DBase< T, PVType, FrameType >::perp2(), FastCircle::rho(), theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theVertexError, theX0, theY0, valid, vertexPoint(), FastCircle::x0(), and FastCircle::y0().

42  theX0 = circle.x0();
43  theY0 = circle.y0();
44  theRho = circle.rho();
45  theVertexError = 0;
46  theCharge = 0;
47  theDirectionAtVertex = GlobalVector(1000, 1000, 1000);
48  if (theInnerPoint.perp2() > theOuterPoint.perp2() || !circle.isValid()) {
49  valid = false;
50  } else
51  valid = true;
52 }
GlobalPoint vertexPoint() const
Definition: TangentCircle.h:48
GlobalPoint outerPoint() const
Definition: TangentCircle.h:44
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
GlobalPoint innerPoint() const
Definition: TangentCircle.h:46
T perp2() const
Definition: PV3DBase.h:68
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
double theVertexError
Definition: TangentCircle.h:67
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ TangentCircle() [4/4]

TangentCircle::TangentCircle ( const TangentCircle primCircle,
const GlobalPoint outerPoint,
const GlobalPoint innerPoint 
)

Calculate the parameters of a circle which pass by 2 points (innerPoint and outerPoint) and which is tangent to primCircle.

Definition at line 54 of file TangentCircle.cc.

References DeadROC_duringRun::dir, getPosition(), mps_fire::i, innerPoint(), isTangent(), LogDebug, mag(), outerPoint(), PV3DBase< T, PVType, FrameType >::perp2(), rho(), alignCSCRings::s, theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theta(), theVertexError, theVertexPoint, theX0, theY0, valid, bphysicsOniaDQM_cfi::vertex, vertexPoint(), PV3DBase< T, PVType, FrameType >::x(), x0(), PV3DBase< T, PVType, FrameType >::y(), and y0().

56  {
58  valid = false;
59  } else
60  valid = true;
61 
62  int NITER = 10;
63 
64  // Initial vertex used = outerPoint of the primary circle (should be the first estimation of the nuclear interaction position)
65  GlobalPoint InitialVertex(primCircle.outerPoint().x(), primCircle.outerPoint().y(), 0);
66  GlobalPoint SecInnerPoint(innerPoint.x(), innerPoint.y(), 0);
67  GlobalPoint SecOuterPoint(outerPoint.x(), outerPoint.y(), 0);
68 
69  // distance between the initial vertex and the inner point of the secondary circle
70  double s = (SecInnerPoint - InitialVertex).mag();
71  double deltaTheta = s / primCircle.rho();
72 
73  double minTangentCondition = 1E12;
74  TangentCircle theCorrectSecCircle;
75  GlobalPoint vertex = InitialVertex;
76  int dir = 1;
77  double theta = deltaTheta / (NITER - 1);
78 
79  for (int i = 0; i < NITER; i++) {
80  // get the circle which pass through outerPoint, innerPoint and the vertex
81  TangentCircle secCircle(SecOuterPoint, SecInnerPoint, vertex);
82 
83  // get a value relative to the tangentness of the 2 circles
84  double minCond = isTangent(primCircle, secCircle);
85 
86  // double dirDiff = (primCircle.direction(vertex) - secCircle.direction(vertex)).mag();
87  // if( dirDiff > 1) dirDiff = 2-dirDiff;
88 
89  if (minCond < minTangentCondition) {
90  minTangentCondition = minCond;
91  theCorrectSecCircle = secCircle;
92  vertex = getPosition(primCircle, secCircle.vertexPoint(), theta, dir);
93  if (i == 0 && ((vertex - SecInnerPoint).mag() > (InitialVertex - SecInnerPoint).mag())) {
94  dir = -1;
95  vertex = getPosition(primCircle, InitialVertex, theta, dir);
96  LogDebug("NuclearSeedGenerator") << "Change direction to look for vertex"
97  << "\n";
98  }
99  } else
100  break;
101  }
102  theInnerPoint = theCorrectSecCircle.innerPoint();
103  theOuterPoint = theCorrectSecCircle.outerPoint();
104  theVertexPoint = theCorrectSecCircle.vertexPoint();
105  theX0 = theCorrectSecCircle.x0();
106  theY0 = theCorrectSecCircle.y0();
107  theRho = theCorrectSecCircle.rho();
108  theCharge = 0;
109  theDirectionAtVertex = GlobalVector(1000, 1000, 1000);
110 
111  theVertexError = s / NITER;
112 }
GlobalPoint getPosition(const TangentCircle &circle, const GlobalPoint &initalPosition, double theta, int direction) const
GlobalPoint vertexPoint() const
Definition: TangentCircle.h:48
GlobalPoint outerPoint() const
Definition: TangentCircle.h:44
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
double isTangent(const TangentCircle &primCircle, const TangentCircle &secCircle) const
double rho() const
Definition: TangentCircle.h:42
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint innerPoint() const
Definition: TangentCircle.h:46
T perp2() const
Definition: PV3DBase.h:68
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
double x0() const
Definition: TangentCircle.h:38
double y0() const
Definition: TangentCircle.h:40
double theVertexError
Definition: TangentCircle.h:67
Geom::Theta< T > theta() const
Global3DVector GlobalVector
Definition: GlobalVector.h:10
#define LogDebug(id)

Member Function Documentation

◆ charge()

int TangentCircle::charge ( float  magz)

Definition at line 205 of file TangentCircle.cc.

References chargeLocally(), directionAtVertex(), F(), LogDebug, theCharge, theVertexPoint, theX0, theY0, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by TangentHelix::charge().

205  {
206  if (theCharge != 0)
207  return theCharge;
208 
209  if (theX0 > 1E9 || theY0 > 1E9)
211  else {
212  GlobalPoint center(theX0, theY0, 0);
213  GlobalVector u = center - theVertexPoint;
215 
216  // F = force vector
217  GlobalVector F(v.y() * magz, -v.x() * magz, 0);
218  if (u.x() * F.x() + u.y() * F.y() > 0)
219  theCharge = -1;
220  else
221  theCharge = 1;
222 
223  if (theCharge != chargeLocally(magz, v)) {
224  LogDebug("NuclearSeedGenerator") << "Inconsistency in calculation of the charge"
225  << "\n";
226  }
227  }
228  return theCharge;
229 }
int chargeLocally(float magz, GlobalVector v) const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalVector directionAtVertex()
Return the direction at the vertex.
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
#define LogDebug(id)

◆ chargeLocally()

int TangentCircle::chargeLocally ( float  magz,
GlobalVector  v 
) const
private

Definition at line 231 of file TangentCircle.cc.

References theOuterPoint, theVertexPoint, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by charge().

231  {
233  double tz = v.x() * u.y() - v.y() * u.x();
234 
235  if (tz * magz > 0)
236  return 1;
237  else
238  return -1;
239 }
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58

◆ curvatureError()

double TangentCircle::curvatureError ( )

Definition at line 193 of file TangentCircle.cc.

References directionAtVertex(), mag(), rho(), theInnerPoint, theOuterPoint, theVertexError, and theVertexPoint.

Referenced by TangentHelix::curvatureError().

193  {
197  return fabs(1 / circle1.rho() - 1 / circle2.rho());
198  } else {
201  return fabs(1 / circle1.rho() - 1 / circle2.rho());
202  }
203 }
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalVector directionAtVertex()
Return the direction at the vertex.
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
double theVertexError
Definition: TangentCircle.h:67

◆ direction()

GlobalVector TangentCircle::direction ( const GlobalPoint point) const
private

Definition at line 125 of file TangentCircle.cc.

References change_name::diff, DeadROC_duringRun::dir, LogDebug, mag(), point, theInnerPoint, theOuterPoint, theX0, and theY0.

Referenced by directionAtVertex(), and TangentCircle().

125  {
126  if (theY0 > 1E9 || theX0 > 1E9) {
127  LogDebug("NuclearSeedGenerator") << "Center of TangentCircle not calculated but used !!!"
128  << "\n";
129  }
130 
131  // calculate the direction perpendicular to the vector v = point - center_of_circle
132  GlobalVector dir(point.y() - theY0, theX0 - point.x(), 0);
133 
134  dir /= dir.mag();
135 
136  // Check the sign :
138  double diff = (dir - fastDir).mag();
139  double sum = (dir + fastDir).mag();
140 
141  if (sum < diff)
142  dir = (-1) * dir;
143 
144  return dir;
145 }
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
*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
#define LogDebug(id)

◆ directionAtVertex()

GlobalVector TangentCircle::directionAtVertex ( )

Return the direction at the vertex.

Definition at line 147 of file TangentCircle.cc.

References direction(), theDirectionAtVertex, theVertexPoint, and PV3DBase< T, PVType, FrameType >::x().

Referenced by charge(), curvatureError(), and TangentHelix::directionAtVertex().

147  {
148  if (theDirectionAtVertex.x() > 999)
150  return theDirectionAtVertex;
151 }
T x() const
Definition: PV3DBase.h:59
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
GlobalVector direction(const GlobalPoint &point) const

◆ getPosition()

GlobalPoint TangentCircle::getPosition ( const TangentCircle circle,
const GlobalPoint initalPosition,
double  theta,
int  direction 
) const
private

Definition at line 153 of file TangentCircle.cc.

References simBeamSpotPI::alpha, HLT_2024v11_cff::beta, funct::cos(), DeadROC_duringRun::dir, CustomPhysics_cfi::gamma, MainPageGenerator::l, rho(), Validation_hcalonly_cfi::sign, funct::sin(), theta(), PV3DBase< T, PVType, FrameType >::x(), x0(), testProducerWithPsetDescEmpty_cfi::x2, PV3DBase< T, PVType, FrameType >::y(), y0(), and testProducerWithPsetDescEmpty_cfi::y2.

Referenced by TangentCircle().

156  {
157  int sign[3];
158  double x2 = initalPosition.x();
159  double y2 = initalPosition.y();
160 
161  if ((x2 > circle.x0()) && dir > 0) {
162  sign[0] = 1;
163  sign[1] = -1;
164  sign[2] = -1;
165  }
166  if ((x2 > circle.x0()) && dir < 0) {
167  sign[0] = 1;
168  sign[1] = 1;
169  sign[2] = 1;
170  }
171  if ((x2 < circle.x0()) && dir > 0) {
172  sign[0] = -1;
173  sign[1] = 1;
174  sign[2] = -1;
175  }
176  if ((x2 < circle.x0()) && dir < 0) {
177  sign[0] = -1;
178  sign[1] = -1;
179  sign[2] = 1;
180  }
181 
182  double l = 2 * circle.rho() * sin(theta / 2);
183  double alpha = atan((y2 - circle.y0()) / (x2 - circle.x0()));
184  double beta = PI / 2 - theta / 2;
185  double gamma = PI + sign[2] * alpha - beta;
186 
187  double xnew = x2 + sign[0] * l * cos(gamma);
188  double ynew = y2 + sign[1] * l * sin(gamma);
189 
190  return GlobalPoint(xnew, ynew, 0);
191 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double rho() const
Definition: TangentCircle.h:42
double x0() const
Definition: TangentCircle.h:38
double y0() const
Definition: TangentCircle.h:40
Geom::Theta< T > theta() const

◆ innerPoint()

GlobalPoint TangentCircle::innerPoint ( ) const
inline

Definition at line 46 of file TangentCircle.h.

References theInnerPoint.

Referenced by TangentCircle().

46 { return theInnerPoint; }
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57

◆ isTangent()

double TangentCircle::isTangent ( const TangentCircle primCircle,
const TangentCircle secCircle 
) const
private

Definition at line 114 of file TangentCircle.cc.

References SiStripPI::min, rho(), x0(), and y0().

Referenced by TangentCircle().

114  {
115  // return a value that should be equal to 0 if primCircle and secCircle are tangent
116 
117  double distanceBetweenCircle = (primCircle.x0() - secCircle.x0()) * (primCircle.x0() - secCircle.x0()) +
118  (primCircle.y0() - secCircle.y0()) * (primCircle.y0() - secCircle.y0());
119  double RadiusSum = (primCircle.rho() + secCircle.rho()) * (primCircle.rho() + secCircle.rho());
120  double RadiusDifference = (primCircle.rho() - secCircle.rho()) * (primCircle.rho() - secCircle.rho());
121 
122  return std::min(fabs(RadiusSum - distanceBetweenCircle), fabs(RadiusDifference - distanceBetweenCircle));
123 }
double rho() const
Definition: TangentCircle.h:42
double x0() const
Definition: TangentCircle.h:38
double y0() const
Definition: TangentCircle.h:40

◆ outerPoint()

GlobalPoint TangentCircle::outerPoint ( ) const
inline

Definition at line 44 of file TangentCircle.h.

References theOuterPoint.

Referenced by TangentCircle().

44 { return theOuterPoint; }
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58

◆ rho()

double TangentCircle::rho ( ) const
inline

◆ vertexError()

double TangentCircle::vertexError ( ) const
inline

Definition at line 50 of file TangentCircle.h.

References theVertexError.

Referenced by TangentHelix::vertexError().

50 { return theVertexError; }
double theVertexError
Definition: TangentCircle.h:67

◆ vertexPoint()

GlobalPoint TangentCircle::vertexPoint ( ) const
inline

Definition at line 48 of file TangentCircle.h.

References theVertexPoint.

Referenced by TangentCircle(), and TangentHelix::TangentHelix().

48 { return theVertexPoint; }
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59

◆ x0()

double TangentCircle::x0 ( ) const
inline

Definition at line 38 of file TangentCircle.h.

References theX0.

Referenced by getPosition(), isTangent(), and TangentCircle().

38 { return theX0; }

◆ y0()

double TangentCircle::y0 ( ) const
inline

Definition at line 40 of file TangentCircle.h.

References theY0.

Referenced by getPosition(), isTangent(), and TangentCircle().

40 { return theY0; }

Member Data Documentation

◆ theCharge

int TangentCircle::theCharge
private

Definition at line 70 of file TangentCircle.h.

Referenced by charge(), and TangentCircle().

◆ theDirectionAtVertex

GlobalVector TangentCircle::theDirectionAtVertex
private

Definition at line 61 of file TangentCircle.h.

Referenced by directionAtVertex(), and TangentCircle().

◆ theInnerPoint

GlobalPoint TangentCircle::theInnerPoint
private

Definition at line 57 of file TangentCircle.h.

Referenced by curvatureError(), direction(), innerPoint(), and TangentCircle().

◆ theOuterPoint

GlobalPoint TangentCircle::theOuterPoint
private

Definition at line 58 of file TangentCircle.h.

Referenced by chargeLocally(), curvatureError(), direction(), outerPoint(), and TangentCircle().

◆ theRho

double TangentCircle::theRho
private

Signed radius of the circle (=q*R)

Definition at line 65 of file TangentCircle.h.

Referenced by rho(), and TangentCircle().

◆ theVertexError

double TangentCircle::theVertexError
private

the error on the vertex position along the direction of the circle at this point

Definition at line 67 of file TangentCircle.h.

Referenced by curvatureError(), TangentCircle(), and vertexError().

◆ theVertexPoint

GlobalPoint TangentCircle::theVertexPoint
private

◆ theX0

double TangentCircle::theX0
private

x center of the circle

Definition at line 63 of file TangentCircle.h.

Referenced by charge(), direction(), TangentCircle(), and x0().

◆ theY0

double TangentCircle::theY0
private

y center of the circle

Definition at line 64 of file TangentCircle.h.

Referenced by charge(), direction(), TangentCircle(), and y0().

◆ valid

bool TangentCircle::valid
private

Definition at line 69 of file TangentCircle.h.

Referenced by TangentCircle().