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 GlobalPoint &outerPoint, const GlobalPoint &innerPoint, const GlobalPoint &vertexPoint)
 Copy of FastCircle. More...
 
 TangentCircle (const GlobalVector &direction, const GlobalPoint &innerPoint, const GlobalPoint &outerPoint)
 
 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) {}

◆ 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.

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 }

References funct::cos(), HLTTauDQMOffline_cfi::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.

◆ 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.

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 }

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().

◆ 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.

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 }

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().

Member Function Documentation

◆ charge()

int TangentCircle::charge ( float  magz)

Definition at line 205 of file TangentCircle.cc.

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 }

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().

◆ chargeLocally()

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

Definition at line 231 of file TangentCircle.cc.

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 }

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

Referenced by charge().

◆ curvatureError()

double TangentCircle::curvatureError ( )

Definition at line 193 of file TangentCircle.cc.

193  {
197  return fabs(1 / circle1.rho() - 1 / circle2.rho());
198  } else {
201  return fabs(1 / circle1.rho() - 1 / circle2.rho());
202  }
203 }

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

Referenced by TangentHelix::curvatureError().

◆ direction()

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

Definition at line 125 of file TangentCircle.cc.

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 }

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

Referenced by directionAtVertex(), and TangentCircle().

◆ directionAtVertex()

GlobalVector TangentCircle::directionAtVertex ( )

Return the direction at the vertex.

Definition at line 147 of file TangentCircle.cc.

147  {
148  if (theDirectionAtVertex.x() > 999)
150  return theDirectionAtVertex;
151 }

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

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

◆ getPosition()

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

Definition at line 153 of file TangentCircle.cc.

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 }

References zMuMuMuonUserData::alpha, zMuMuMuonUserData::beta, funct::cos(), DeadROC_duringRun::dir, CustomPhysics_cfi::gamma, cmsLHEtoEOSManager::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().

◆ innerPoint()

GlobalPoint TangentCircle::innerPoint ( ) const
inline

Definition at line 46 of file TangentCircle.h.

46 { return theInnerPoint; }

References theInnerPoint.

Referenced by TangentCircle().

◆ isTangent()

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

Definition at line 114 of file TangentCircle.cc.

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 }

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

Referenced by TangentCircle().

◆ outerPoint()

GlobalPoint TangentCircle::outerPoint ( ) const
inline

Definition at line 44 of file TangentCircle.h.

44 { return theOuterPoint; }

References theOuterPoint.

Referenced by TangentCircle().

◆ rho()

double TangentCircle::rho ( ) const
inline

◆ vertexError()

double TangentCircle::vertexError ( ) const
inline

Definition at line 50 of file TangentCircle.h.

50 { return theVertexError; }

References theVertexError.

Referenced by TangentHelix::vertexError().

◆ vertexPoint()

GlobalPoint TangentCircle::vertexPoint ( ) const
inline

Definition at line 48 of file TangentCircle.h.

48 { return theVertexPoint; }

References theVertexPoint.

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

◆ x0()

double TangentCircle::x0 ( ) const
inline

Definition at line 38 of file TangentCircle.h.

38 { return theX0; }

References theX0.

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

◆ y0()

double TangentCircle::y0 ( ) const
inline

Definition at line 40 of file TangentCircle.h.

40 { return theY0; }

References theY0.

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

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().

Vector3DBase
Definition: Vector3DBase.h:8
PI
Definition: PayloadInspector.h:19
change_name.diff
diff
Definition: change_name.py:13
mps_fire.i
i
Definition: mps_fire.py:355
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
min
T min(T a, T b)
Definition: MathUtil.h:58
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
TangentCircle::theOuterPoint
GlobalPoint theOuterPoint
Definition: TangentCircle.h:58
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
findQualityFiles.v
v
Definition: findQualityFiles.py:179
F
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
Definition: blowfish.cc:163
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TangentCircle::isTangent
double isTangent(const TangentCircle &primCircle, const TangentCircle &secCircle) const
Definition: TangentCircle.cc:114
TangentCircle::getPosition
GlobalPoint getPosition(const TangentCircle &circle, const GlobalPoint &initalPosition, double theta, int direction) const
Definition: TangentCircle.cc:153
TangentCircle::theCharge
int theCharge
Definition: TangentCircle.h:70
SurfaceOrientation::inner
Definition: Surface.h:19
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
TangentCircle::valid
bool valid
Definition: TangentCircle.h:69
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
TangentCircle::x0
double x0() const
Definition: TangentCircle.h:38
TangentCircle
Definition: TangentCircle.h:7
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
TangentCircle::theX0
double theX0
Definition: TangentCircle.h:63
TangentCircle::y0
double y0() const
Definition: TangentCircle.h:40
TangentCircle::direction
GlobalVector direction(const GlobalPoint &point) const
Definition: TangentCircle.cc:125
TangentCircle::theRho
double theRho
Definition: TangentCircle.h:65
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
TangentCircle::vertexPoint
GlobalPoint vertexPoint() const
Definition: TangentCircle.h:48
FastCircle
Definition: FastCircle.h:33
TangentCircle::theDirectionAtVertex
GlobalVector theDirectionAtVertex
Definition: TangentCircle.h:61
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
TangentCircle::innerPoint
GlobalPoint innerPoint() const
Definition: TangentCircle.h:46
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
HLTTauDQMOffline_cfi.denominator
denominator
Definition: HLTTauDQMOffline_cfi.py:195
TangentCircle::rho
double rho() const
Definition: TangentCircle.h:42
TangentCircle::outerPoint
GlobalPoint outerPoint() const
Definition: TangentCircle.h:44
TangentCircle::directionAtVertex
GlobalVector directionAtVertex()
Return the direction at the vertex.
Definition: TangentCircle.cc:147
TangentCircle::theY0
double theY0
Definition: TangentCircle.h:64
TangentCircle::theInnerPoint
GlobalPoint theInnerPoint
Definition: TangentCircle.h:57
SurfaceOrientation::outer
Definition: Surface.h:19
point
*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
TangentCircle::theVertexPoint
GlobalPoint theVertexPoint
Definition: TangentCircle.h:59
TangentCircle::theVertexError
double theVertexError
Definition: TangentCircle.h:67
TangentCircle::chargeLocally
int chargeLocally(float magz, GlobalVector v) const
Definition: TangentCircle.cc:231
PV3DBase::perp2
T perp2() const
Definition: PV3DBase.h:68
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23