#include <TangentCircle.h>
Public Member Functions | |
int | charge (float magz) |
double | curvatureError () |
GlobalVector | directionAtVertex () |
Return the direction at the vertex. | |
GlobalPoint | innerPoint () const |
bool | isValid () const |
GlobalPoint | outerPoint () const |
double | rho () const |
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. | |
TangentCircle () | |
TangentCircle (const GlobalVector &direction, const GlobalPoint &innerPoint, const GlobalPoint &outerPoint) | |
TangentCircle (const GlobalPoint &outerPoint, const GlobalPoint &innerPoint, const GlobalPoint &vertexPoint) | |
Copy of FastCircle. | |
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 |
Definition at line 7 of file TangentCircle.h.
TangentCircle::TangentCircle | ( | ) | [inline] |
Definition at line 14 of file TangentCircle.h.
: theInnerPoint(), theOuterPoint(), theVertexPoint(), theDirectionAtVertex(), theX0(0), theY0(0), theRho(0), theVertexError(0), valid(false), theCharge(0) {}
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(), ExpressReco_HICollisions_FallBack::denominator, direction(), PV3DBase< T, PVType, FrameType >::mag(), mag(), PV3DBase< T, PVType, FrameType >::perp2(), PI, funct::sin(), theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theVertexError, theX0, theY0, valid, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
: theInnerPoint(inner), theOuterPoint(outer), theVertexPoint(inner) { if(theInnerPoint.perp2() > theOuterPoint.perp2()) { valid = false; } else valid=true; double x1 = inner.x(); double y1 = inner.y(); double x2 = outer.x(); double y2 = outer.y(); double alpha1 = (direction.y() != 0) ? atan(-direction.x()/direction.y()) : PI/2 ; double denominator = 2*((x1-x2)*cos(alpha1)+(y1-y2)*sin(alpha1)); theRho = (denominator != 0) ? ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))/denominator : 1E12; // TODO : variable not yet calculated look in nucl.C theX0 = 1E10; theY0 = 1E10; theDirectionAtVertex = direction; theDirectionAtVertex/=theDirectionAtVertex.mag(); //theCharge = (theRho>0) ? -1 : 1; theCharge = 0; theRho = fabs(theRho); theVertexError = (theInnerPoint-theOuterPoint).mag(); }
TangentCircle::TangentCircle | ( | const GlobalPoint & | outerPoint, |
const GlobalPoint & | innerPoint, | ||
const GlobalPoint & | vertexPoint | ||
) |
Copy of FastCircle.
Definition at line 36 of file TangentCircle.cc.
References FastCircle::isValid(), PV3DBase< T, PVType, FrameType >::perp2(), FastCircle::rho(), theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theVertexError, theX0, theY0, valid, FastCircle::x0(), and FastCircle::y0().
: theInnerPoint(innerPoint), theOuterPoint(outerPoint), theVertexPoint(vertexPoint) { FastCircle circle(outerPoint, innerPoint, vertexPoint); theX0 = circle.x0(); theY0 = circle.y0(); theRho = circle.rho(); theVertexError = 0; theCharge = 0; theDirectionAtVertex = GlobalVector(1000, 1000, 1000); if(theInnerPoint.perp2() > theOuterPoint.perp2() || !circle.isValid()) { valid = false; } else valid=true; }
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 49 of file TangentCircle.cc.
References dir, getPosition(), i, innerPoint(), isTangent(), LogDebug, mag(), outerPoint(), PV3DBase< T, PVType, FrameType >::perp2(), rho(), asciidump::s, theCharge, theDirectionAtVertex, theInnerPoint, theOuterPoint, theRho, theta(), theVertexError, theVertexPoint, theX0, theY0, valid, vertexPoint(), PV3DBase< T, PVType, FrameType >::x(), x0(), PV3DBase< T, PVType, FrameType >::y(), and y0().
{ if(theInnerPoint.perp2() > theOuterPoint.perp2()) { valid = false; } else valid = true; int NITER = 10; // Initial vertex used = outerPoint of the primary circle (should be the first estimation of the nuclear interaction position) GlobalPoint InitialVertex( primCircle.outerPoint().x() , primCircle.outerPoint().y(), 0); GlobalPoint SecInnerPoint( innerPoint.x(), innerPoint.y(), 0); GlobalPoint SecOuterPoint( outerPoint.x(), outerPoint.y(), 0); // distance between the initial vertex and the inner point of the secondary circle double s = (SecInnerPoint - InitialVertex).mag(); double deltaTheta = s/primCircle.rho(); double minTangentCondition = 1E12; TangentCircle theCorrectSecCircle; GlobalPoint vertex = InitialVertex; int dir = 1; double theta = deltaTheta/(NITER-1); for(int i=0; i<NITER; i++) { // get the circle which pass through outerPoint, innerPoint and the vertex TangentCircle secCircle( SecOuterPoint, SecInnerPoint, vertex ); // get a value relative to the tangentness of the 2 circles double minCond = isTangent(primCircle, secCircle); // double dirDiff = (primCircle.direction(vertex) - secCircle.direction(vertex)).mag(); // if( dirDiff > 1) dirDiff = 2-dirDiff; if(minCond < minTangentCondition) { minTangentCondition = minCond; theCorrectSecCircle = secCircle; vertex = getPosition( primCircle, secCircle.vertexPoint(), theta, dir ); if( i==0 && ((vertex-SecInnerPoint).mag() > (InitialVertex-SecInnerPoint).mag()) ) { dir=-1; vertex = getPosition( primCircle, InitialVertex, theta, dir ); LogDebug("NuclearSeedGenerator") << "Change direction to look for vertex" << "\n"; } } else break; } theInnerPoint = theCorrectSecCircle.innerPoint(); theOuterPoint = theCorrectSecCircle.outerPoint(); theVertexPoint = theCorrectSecCircle.vertexPoint(); theX0 = theCorrectSecCircle.x0(); theY0 = theCorrectSecCircle.y0(); theRho = theCorrectSecCircle.rho(); theCharge = 0; theDirectionAtVertex = GlobalVector(1000, 1000, 1000); theVertexError = s/NITER; }
int TangentCircle::charge | ( | float | magz | ) |
Definition at line 180 of file TangentCircle.cc.
References chargeLocally(), directionAtVertex(), LogDebug, theCharge, theVertexPoint, theX0, theY0, v, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
Referenced by TangentHelix::charge().
{ if(theCharge != 0) return theCharge; if(theX0 > 1E9 || theY0 > 1E9) theCharge = chargeLocally(magz, directionAtVertex()); else { GlobalPoint center(theX0, theY0, 0); GlobalVector u = center - theVertexPoint; GlobalVector v = directionAtVertex(); // F = force vector GlobalVector F( v.y() * magz, -v.x() * magz, 0); if( u.x() * F.x() + u.y() * F.y() > 0) theCharge=-1; else theCharge=1; if(theCharge != chargeLocally(magz, v)) { LogDebug("NuclearSeedGenerator") << "Inconsistency in calculation of the charge" << "\n"; } } return theCharge; }
int TangentCircle::chargeLocally | ( | float | magz, |
GlobalVector | v | ||
) | const [private] |
Definition at line 203 of file TangentCircle.cc.
References theOuterPoint, theVertexPoint, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
Referenced by charge().
{ GlobalVector u = theOuterPoint - theVertexPoint; double tz = v.x() * u.y() - v.y() * u.x() ; if(tz * magz > 0) return 1; else return -1; }
double TangentCircle::curvatureError | ( | ) |
Definition at line 167 of file TangentCircle.cc.
References directionAtVertex(), mag(), rho(), theInnerPoint, theOuterPoint, theVertexError, and theVertexPoint.
Referenced by TangentHelix::curvatureError().
{ if( (theInnerPoint - theVertexPoint).mag() < theVertexError ) { TangentCircle circle1( directionAtVertex() , theVertexPoint - theVertexError*directionAtVertex(), theOuterPoint); TangentCircle circle2( directionAtVertex() , theVertexPoint + theVertexError*directionAtVertex(), theOuterPoint); return fabs(1/circle1.rho() - 1/circle2.rho()); } else { TangentCircle circle1( theOuterPoint, theInnerPoint, theVertexPoint - theVertexError*directionAtVertex()); TangentCircle circle2( theOuterPoint, theInnerPoint, theVertexPoint + theVertexError*directionAtVertex()); return fabs(1/circle1.rho() - 1/circle2.rho()); } }
GlobalVector TangentCircle::direction | ( | const GlobalPoint & | point | ) | const [private] |
Definition at line 118 of file TangentCircle.cc.
References diffTreeTool::diff, dir, LogDebug, mag(), theInnerPoint, theOuterPoint, theX0, theY0, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().
Referenced by directionAtVertex(), and TangentCircle().
{ if(theY0 > 1E9 || theX0 > 1E9) { LogDebug("NuclearSeedGenerator") << "Center of TangentCircle not calculated but used !!!" << "\n"; } // calculate the direction perpendicular to the vector v = point - center_of_circle GlobalVector dir(point.y() - theY0, theX0 - point.x(), 0); dir/=dir.mag(); // Check the sign : GlobalVector fastDir = theOuterPoint - theInnerPoint; double diff = (dir - fastDir).mag(); double sum = (dir + fastDir).mag(); if( sum < diff ) dir = (-1)*dir; return dir; }
GlobalVector TangentCircle::directionAtVertex | ( | ) |
Return the direction at the vertex.
Definition at line 139 of file TangentCircle.cc.
References direction(), theDirectionAtVertex, theVertexPoint, and PV3DBase< T, PVType, FrameType >::x().
Referenced by charge(), curvatureError(), and TangentHelix::directionAtVertex().
{ if(theDirectionAtVertex.x() > 999) theDirectionAtVertex = direction(theVertexPoint); return theDirectionAtVertex; }
GlobalPoint TangentCircle::getPosition | ( | const TangentCircle & | circle, |
const GlobalPoint & | initalPosition, | ||
double | theta, | ||
int | direction | ||
) | const [private] |
Definition at line 145 of file TangentCircle.cc.
References alpha, beta, funct::cos(), prof2calltree::l, PI, rho(), funct::sin(), PV3DBase< T, PVType, FrameType >::x(), x0(), PV3DBase< T, PVType, FrameType >::y(), and y0().
Referenced by TangentCircle().
{ int sign[3]; double x2 = initalPosition.x(); double y2 = initalPosition.y(); if( (x2>circle.x0()) && dir >0) { sign[0] = 1; sign[1] = -1; sign[2] = -1; } if( (x2>circle.x0()) && dir <0) { sign[0] = 1; sign[1] = 1; sign[2] = 1; } if( (x2<circle.x0()) && dir >0) { sign[0] = -1; sign[1] = 1; sign[2] = -1; } if( (x2<circle.x0()) && dir <0) { sign[0] = -1; sign[1] = -1; sign[2] = 1; } double l = 2*circle.rho()*sin(theta/2); double alpha = atan((y2-circle.y0())/(x2-circle.x0())); double beta = PI/2-theta/2; double gamma = PI + sign[2]* alpha - beta; double xnew = x2 + sign[0]*l*cos(gamma); double ynew = y2 + sign[1]*l*sin(gamma); return GlobalPoint( xnew, ynew, 0 ); }
GlobalPoint TangentCircle::innerPoint | ( | ) | const [inline] |
Definition at line 40 of file TangentCircle.h.
References theInnerPoint.
Referenced by TangentCircle().
{ return theInnerPoint; }
double TangentCircle::isTangent | ( | const TangentCircle & | primCircle, |
const TangentCircle & | secCircle | ||
) | const [private] |
Definition at line 107 of file TangentCircle.cc.
References min, rho(), x0(), and y0().
Referenced by TangentCircle().
{ // return a value that should be equal to 0 if primCircle and secCircle are tangent double distanceBetweenCircle = (primCircle.x0() - secCircle.x0())*(primCircle.x0() - secCircle.x0()) + (primCircle.y0() - secCircle.y0())*(primCircle.y0() - secCircle.y0()); double RadiusSum = (primCircle.rho() + secCircle.rho())*(primCircle.rho() + secCircle.rho()); double RadiusDifference = (primCircle.rho() - secCircle.rho())*(primCircle.rho() - secCircle.rho()); return std::min( fabs(RadiusSum-distanceBetweenCircle), fabs(RadiusDifference-distanceBetweenCircle) ); }
bool TangentCircle::isValid | ( | void | ) | const [inline] |
Definition at line 50 of file TangentCircle.h.
References isValid().
Referenced by isValid().
{ return isValid(); }
GlobalPoint TangentCircle::outerPoint | ( | ) | const [inline] |
Definition at line 38 of file TangentCircle.h.
References theOuterPoint.
Referenced by TangentCircle().
{ return theOuterPoint; }
double TangentCircle::rho | ( | ) | const [inline] |
Definition at line 36 of file TangentCircle.h.
References theRho.
Referenced by curvatureError(), getPosition(), isTangent(), TangentHelix::rho(), and TangentCircle().
{return theRho;}
double TangentCircle::vertexError | ( | ) | const [inline] |
Definition at line 44 of file TangentCircle.h.
References theVertexError.
Referenced by TangentHelix::vertexError().
{ return theVertexError; }
GlobalPoint TangentCircle::vertexPoint | ( | ) | const [inline] |
Definition at line 42 of file TangentCircle.h.
References theVertexPoint.
Referenced by TangentCircle(), and TangentHelix::TangentHelix().
{ return theVertexPoint; }
double TangentCircle::x0 | ( | ) | const [inline] |
Definition at line 32 of file TangentCircle.h.
References theX0.
Referenced by getPosition(), isTangent(), and TangentCircle().
{return theX0;}
double TangentCircle::y0 | ( | ) | const [inline] |
Definition at line 34 of file TangentCircle.h.
References theY0.
Referenced by getPosition(), isTangent(), and TangentCircle().
{return theY0;}
int TangentCircle::theCharge [private] |
Definition at line 66 of file TangentCircle.h.
Referenced by charge(), and TangentCircle().
Definition at line 57 of file TangentCircle.h.
Referenced by directionAtVertex(), and TangentCircle().
GlobalPoint TangentCircle::theInnerPoint [private] |
Definition at line 53 of file TangentCircle.h.
Referenced by curvatureError(), direction(), innerPoint(), and TangentCircle().
GlobalPoint TangentCircle::theOuterPoint [private] |
Definition at line 54 of file TangentCircle.h.
Referenced by chargeLocally(), curvatureError(), direction(), outerPoint(), and TangentCircle().
double TangentCircle::theRho [private] |
Signed radius of the circle (=q*R)
Definition at line 61 of file TangentCircle.h.
Referenced by rho(), and TangentCircle().
double TangentCircle::theVertexError [private] |
the error on the vertex position along the direction of the circle at this point
Definition at line 63 of file TangentCircle.h.
Referenced by curvatureError(), TangentCircle(), and vertexError().
GlobalPoint TangentCircle::theVertexPoint [private] |
Definition at line 55 of file TangentCircle.h.
Referenced by charge(), chargeLocally(), curvatureError(), directionAtVertex(), TangentCircle(), and vertexPoint().
double TangentCircle::theX0 [private] |
x center of the circle
Definition at line 59 of file TangentCircle.h.
Referenced by charge(), direction(), TangentCircle(), and x0().
double TangentCircle::theY0 [private] |
y center of the circle
Definition at line 60 of file TangentCircle.h.
Referenced by charge(), direction(), TangentCircle(), and y0().
bool TangentCircle::valid [private] |
Definition at line 65 of file TangentCircle.h.
Referenced by TangentCircle().