CMS 3D CMS Logo

ThirdHitPrediction Class Reference

#include <RecoPixelVertexing/PixelLowPtUtilities/interface/ThirdHitPrediction.h>

List of all members.

Public Types

typedef
TkTrackingRegionsMargin< float > 
Margin
typedef PixelRecoRange< float > Range

Public Member Functions

void getRanges (float rORz, float phi[], float rz[])
void getRanges (const DetLayer *layer, float phi[], float rz[])
bool isCompatibleWithMultipleScattering (GlobalPoint g3, std::vector< const TrackingRecHit * > h, std::vector< GlobalVector > &localDirs, const edm::EventSetup &es)
 ThirdHitPrediction (float originRBound, float ptMin, GlobalPoint inner, GlobalPoint outer, const edm::EventSetup &es, double nSigMultipleScattering, double maxAngleRatio)
 ~ThirdHitPrediction ()

Private Member Functions

float angleRatio (const Global2DVector &p3, const Global2DVector &c)
float areaParallelogram (const Global2DVector &a, const Global2DVector &b)
void calculateRanges (float rz3, float phi[2], float rz[2])
void calculateRangesBarrel (float r3, float phi[2], float z[2], bool keep)
void calculateRangesForward (float z3, float phi[2], float r[2], bool keep)
std::pair< float, float > findArcIntersection (std::pair< float, float > a, std::pair< float, float > b, bool &keep)
std::pair< float, float > findMinimalCircles (float r)
void findRectangle (const float x[3], const float y[3], const float par[3], float phi[2], float z[2])
std::pair< float, float > findTouchingCircles (float r)
void fitParabola (const float x[3], const float y[3], float par[3])
void initLayer (const DetLayer *layer)
void invertCircle (Global2DVector &c, float &r)
void invertPoint (Global2DVector &p)
void printOut (char *text)
void spinCloser (float phi[3])

Private Attributes

std::pair< float, float > arc_0m
float Bz
Global2DVector dif
GlobalPoint g1
GlobalPoint g2
bool keep
double maxRatio
double nSigma
Global2DVector p1
Global2DVector p2
float r0
float rm
bool theBarrel
Range theDetRange
bool theForward
const DetLayertheLayer
PixelRecoLineRZ theLine
Margin theTolerance
const
TransientTrackingRecHitBuilder
theTTRecHitBuilder


Detailed Description

Definition at line 32 of file ThirdHitPrediction.h.


Member Typedef Documentation

typedef TkTrackingRegionsMargin<float> ThirdHitPrediction::Margin

Definition at line 35 of file ThirdHitPrediction.h.

typedef PixelRecoRange<float> ThirdHitPrediction::Range

Definition at line 34 of file ThirdHitPrediction.h.


Constructor & Destructor Documentation

ThirdHitPrediction::ThirdHitPrediction ( float  originRBound,
float  ptMin,
GlobalPoint  inner,
GlobalPoint  outer,
const edm::EventSetup es,
double  nSigMultipleScattering,
double  maxAngleRatio 
)

Definition at line 24 of file ThirdHitPrediction.cc.

References g1, g2, edm::EventSetup::get(), keep, volumeBasedMagneticField_1103l_cfi::magfield, HLT_VtxMuL3::nSigma, p1, p2, and edm::ESHandle< T >::product().

00027 {
00028  using namespace edm;
00029  ESHandle<MagneticField> magfield;
00030  es.get<IdealMagneticFieldRecord>().get(magfield);
00031 
00032  edm::ESHandle<TransientTrackingRecHitBuilder> ttrhbESH;
00033 // std::string builderName = ZZ`Z.getParameter<std::string>("TTRHBuilder");
00034 // es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
00035  es.get<TransientRecHitRecord>().get("TTRHBuilderWithoutAngle4PixelTriplets",ttrhbESH);
00036  theTTRecHitBuilder = ttrhbESH.product();
00037 
00038  Bz = fabs(magfield->inInverseGeV(GlobalPoint(0,0,0)).z());
00039 
00040  r0 = originRBound;
00041  rm = ptMin / Bz;
00042 
00043  g1 = inner;
00044  g2 = outer;
00045 
00046  p1 = Global2DVector(g1.x(), g1.y());
00047  p2 = Global2DVector(g2.x(), g2.y());
00048 
00049  dif = p1 - p2;
00050 
00051  // Prepare circles of minimal pt (rm) and cylinder of origin (r0)
00052  keep = true;
00053  arc_0m = findArcIntersection(findMinimalCircles (rm),
00054                               findTouchingCircles(r0), keep);
00055 
00056  nSigma   = nSigMultipleScattering;
00057  maxRatio = maxAngleRatio;
00058 }

ThirdHitPrediction::~ThirdHitPrediction (  ) 

Definition at line 61 of file ThirdHitPrediction.cc.

00062 {
00063 }


Member Function Documentation

float ThirdHitPrediction::angleRatio ( const Global2DVector p3,
const Global2DVector c 
) [private]

Definition at line 190 of file ThirdHitPrediction.cc.

References areaParallelogram(), p1, and p2.

Referenced by calculateRangesBarrel().

00191 {
00192   float rad2 = (p1 - c).mag2();
00193 
00194   float a12 = asin(fabsf(areaParallelogram(p1 - c, p2 - c)) / rad2);
00195   float a23 = asin(fabsf(areaParallelogram(p2 - c, p3 - c)) / rad2);
00196 
00197   return a23/a12;
00198 }

float ThirdHitPrediction::areaParallelogram ( const Global2DVector a,
const Global2DVector b 
) [private]

Definition at line 183 of file ThirdHitPrediction.cc.

References PV2DBase< T, PVType, FrameType >::x(), and PV2DBase< T, PVType, FrameType >::y().

Referenced by angleRatio(), and calculateRangesForward().

00184 {
00185   return a.x() * b.y() - a.y() * b.x();
00186 }

void ThirdHitPrediction::calculateRanges ( float  rz3,
float  phi[2],
float  rz[2] 
) [private]

Definition at line 321 of file ThirdHitPrediction.cc.

References calculateRangesBarrel(), calculateRangesForward(), and theBarrel.

Referenced by getRanges().

00322 {
00323   // Clear
00324   phi[0] = 0.; rz[0] = 0.;
00325   phi[1] = 0.; rz[1] = 0.;
00326 
00327   // Calculate
00328   if(theBarrel) calculateRangesBarrel (rz3, phi,rz, keep);
00329            else calculateRangesForward(rz3, phi,rz, keep);
00330 }

void ThirdHitPrediction::calculateRangesBarrel ( float  r3,
float  phi[2],
float  z[2],
bool  keep 
) [private]

Definition at line 212 of file ThirdHitPrediction.cc.

References angle(), angleRatio(), arc_0m, c3, funct::cos(), findArcIntersection(), findRectangle(), findTouchingCircles(), fitParabola(), g1, g2, i, invertCircle(), invertPoint(), muonGeometry::mag(), p1, p2, PV2DBase< T, PVType, FrameType >::phi(), funct::sin(), spinCloser(), sqr(), funct::sqrt(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by calculateRanges().

00213 {
00214   pair<float,float> arc_all =
00215     findArcIntersection(arc_0m, findTouchingCircles(r3), keep);
00216 
00217   if(arc_all.second != 0.)
00218   {
00219     Global2DVector c3(0.,0.); // barrel at r3
00220     invertCircle(c3,r3);      // inverted
00221 
00222     float angle[3];           // prepare angles
00223     angle[0] = arc_all.first - arc_all.second;
00224     angle[1] = arc_all.first;
00225     angle[2] = arc_all.first + arc_all.second;
00226 
00227     float phi3[3], z3[3];
00228     Global2DVector delta = c3 - p2;
00229 
00230     for(int i=0; i<3; i++)
00231     {
00232       Global2DVector vec(cos(angle[i]), sin(angle[i])); // unit vector
00233       float lambda = delta*vec - sqrt(sqr(delta*vec) - delta*delta + sqr(r3));
00234 
00235       Global2DVector p3 = p2 + lambda * vec;  // inverted third hit 
00236       invertPoint(p3);                        // third hit
00237       phi3[i] = p3.phi();                     // phi of third hit
00238 
00239       float ratio;
00240 
00241       if(keep && i==1)
00242       { // Straight line
00243         ratio = (p2 - p3).mag() / (p1 - p2).mag();
00244       }
00245       else
00246       { // Circle
00247         Global2DVector c = p2 - vec * (vec * (p2 - p1)); // inverted antipodal
00248         invertPoint(c);                                  // antipodal
00249         c = 0.5*(p1 + c);                                // center
00250 
00251         ratio = angleRatio(p3,c);
00252       }
00253 
00254       z3[i] = g2.z() + (g2.z() - g1.z()) * ratio;        // z of third hit
00255     }
00256 
00257     spinCloser(phi3);
00258 
00259     // Parabola on phi - z
00260     float par[3];
00261     fitParabola  (phi3,z3, par);
00262     findRectangle(phi3,z3, par, phi,z);
00263   }
00264 }

void ThirdHitPrediction::calculateRangesForward ( float  z3,
float  phi[2],
float  r[2],
bool  keep 
) [private]

Definition at line 268 of file ThirdHitPrediction.cc.

References angle(), arc_0m, areaParallelogram(), funct::cos(), findRectangle(), fitParabola(), g1, g2, i, invertPoint(), PV2DBase< T, PVType, FrameType >::mag(), maxRatio, p1, p2, PV2DBase< T, PVType, FrameType >::phi(), funct::sin(), spinCloser(), x, y, and PV3DBase< T, PVType, FrameType >::z().

Referenced by calculateRanges().

00269 {
00270   float angle[3];           // prepare angles
00271   angle[0] = arc_0m.first - arc_0m.second;
00272   angle[1] = arc_0m.first;
00273   angle[2] = arc_0m.first + arc_0m.second;
00274 
00275   float ratio = (z3 - g2.z()) / (g2.z() - g1.z());
00276 
00277   if(0 < ratio  && ratio < maxRatio)
00278   {
00279     float phi3[3], r3[3];
00280 
00281     for(int i=0; i<3; i++)
00282     {
00283       Global2DVector p3;
00284 
00285       if(keep && i==1)
00286       { // Straight line
00287         p3 = p2 + ratio * (p2 - p1);
00288       }
00289       else
00290       { // Circle
00291         Global2DVector vec(cos(angle[i]), sin(angle[i])); // unit vector
00292   
00293         Global2DVector c = p2 - vec * (vec * (p2 - p1));  // inverted antipodal
00294         invertPoint(c);                                   // antipodal
00295         c = 0.5*(p1 + c);                                 // center
00296 
00297         float rad2 = (p1 - c).mag2();
00298 
00299         float a12 = asin(areaParallelogram(p1 - c, p2 - c) / rad2);
00300         float a23 = ratio * a12;
00301 
00302         p3 = c + Global2DVector((p2-c).x()*cos(a23) - (p2-c).y()*sin(a23),
00303                                 (p2-c).x()*sin(a23) + (p2-c).y()*cos(a23));
00304       }
00305 
00306       phi3[i] = p3.phi();
00307       r3[i]   = p3.mag();
00308     }
00309 
00310     spinCloser(phi3);
00311 
00312     // Parabola on phi - z
00313     float par[3];
00314     fitParabola  (phi3,r3, par);
00315     findRectangle(phi3,r3, par, phi,r);
00316   }
00317 }

std::pair<float,float> ThirdHitPrediction::findArcIntersection ( std::pair< float, float >  a,
std::pair< float, float >  b,
bool keep 
) [private]

Referenced by calculateRangesBarrel().

pair< float, float > ThirdHitPrediction::findMinimalCircles ( float  r  )  [private]

Definition at line 83 of file ThirdHitPrediction.cc.

References a, dif, PV2DBase< T, PVType, FrameType >::mag2(), PV2DBase< T, PVType, FrameType >::phi(), and sqr().

00084 { 
00085   pair<float,float> a(0.,0.);
00086 
00087   if(dif.mag2() <  2 * sqr(r))
00088     a = pair<float,float>( dif.phi(),
00089                            0.5*acos(1 - 0.5 * dif.mag2()/sqr(r)) );
00090 
00091   return a;
00092 }

void ThirdHitPrediction::findRectangle ( const float  x[3],
const float  y[3],
const float  par[3],
float  phi[2],
float  z[2] 
) [private]

Definition at line 162 of file ThirdHitPrediction.cc.

References sqr().

Referenced by calculateRangesBarrel(), and calculateRangesForward().

00164 { 
00165   // Initial guess
00166   phi[0] = x[0] <? x[2]; z[0] = y[0] <? y[2];
00167   phi[1] = x[0] >? x[2]; z[1] = y[0] >? y[2];
00168 
00169   // Extremum: position and value
00170   float xe = -par[1]/(2*par[2]);
00171   float ye = par[0] - sqr(par[1])/(4*par[2]);
00172 
00173   // Check if extremum is inside the phi range
00174   if(phi[0] < xe  && xe < phi[1])
00175   {
00176     if(ye < z[0]) z[0] = ye;
00177     if(ye > z[1]) z[1] = ye;
00178   }
00179 }

pair< float, float > ThirdHitPrediction::findTouchingCircles ( float  r  )  [private]

Definition at line 95 of file ThirdHitPrediction.cc.

References a, c, invertCircle(), p2, phi, and sqr().

Referenced by calculateRangesBarrel().

00096 {
00097   Global2DVector c(0.,0.);
00098   invertCircle(c,r);
00099 
00100   pair<float,float> a(0.,0.);
00101   a = pair<float,float>( (c - p2).phi(),
00102                           0.5*acos(1 - 2*sqr(r)/(c - p2).mag2()) );
00103 
00104   return a;
00105 }

void ThirdHitPrediction::fitParabola ( const float  x[3],
const float  y[3],
float  par[3] 
) [private]

Definition at line 140 of file ThirdHitPrediction.cc.

References s1, s2, s3, and sqr().

Referenced by calculateRangesBarrel(), and calculateRangesForward().

00141 { 
00142   float s2 = sqr(x[0]) * (y[1] - y[2]) +
00143              sqr(x[1]) * (y[2] - y[0]) +
00144              sqr(x[2]) * (y[0] - y[1]);
00145   
00146   float s1 =     x[0]  * (y[1] - y[2]) +
00147                  x[1]  * (y[2] - y[0]) +
00148                  x[2]  * (y[0] - y[1]);
00149 
00150   float s3 = (x[0] - x[1]) * (x[1] - x[2]) * (x[2] - x[0]);
00151   float s4 = x[0]*x[1]*y[2] * (x[0] - x[1]) +
00152              x[0]*y[1]*x[2] * (x[2] - x[0]) +
00153              y[0]*x[1]*x[2] * (x[1] - x[2]);
00154 
00155   par[2] =  s1 / s3; // a2
00156   par[1] = -s2 / s3; // a1
00157   par[0] = -s4 / s3; // a0
00158 }

void ThirdHitPrediction::getRanges ( float  rORz,
float  phi[],
float  rz[] 
)

Definition at line 373 of file ThirdHitPrediction.cc.

References calculateRanges().

00374 {
00375   calculateRanges(rz3, phi,rz);
00376 }

void ThirdHitPrediction::getRanges ( const DetLayer layer,
float  phi[],
float  rz[] 
)

Definition at line 334 of file ThirdHitPrediction.cc.

References calculateRanges(), initLayer(), max, PixelRecoRange< T >::max(), min, PixelRecoRange< T >::min(), theDetRange, and theLayer.

00335 {
00336   theLayer = layer;
00337   
00338   if (layer) initLayer(layer);
00339 
00340   float phi_inner[2],rz_inner[2];
00341   calculateRanges(theDetRange.min(), phi_inner,rz_inner);
00342 
00343   float phi_outer[2],rz_outer[2];
00344   calculateRanges(theDetRange.max(), phi_outer,rz_outer);
00345 
00346   if( (phi_inner[0] == 0. && phi_inner[1] == 0.) ||
00347       (phi_outer[0] == 0. && phi_outer[1] == 0.) )
00348   {
00349     phi[0] = 0.;
00350     phi[1] = 0.;
00351 
00352      rz[0] = 0.;
00353      rz[1] = 0.;
00354   }
00355   else
00356   {
00357     while(phi_outer[0] > phi_inner[0] + M_PI)
00358     { phi_outer[0] -= 2*M_PI; phi_outer[1] -= 2*M_PI; }
00359 
00360     while(phi_outer[0] < phi_inner[0] - M_PI)
00361     { phi_outer[0] += 2*M_PI; phi_outer[1] += 2*M_PI; }
00362 
00363     phi[0] = min(phi_inner[0],phi_outer[0]);
00364     phi[1] = max(phi_inner[1],phi_outer[1]);
00365   
00366      rz[0] = min( rz_inner[0], rz_outer[0]);
00367      rz[1] = max( rz_inner[1], rz_outer[1]);
00368   }
00369 }

void ThirdHitPrediction::initLayer ( const DetLayer layer  )  [private]

Definition at line 468 of file ThirdHitPrediction.cc.

References GeomDetEnumerators::barrel, BoundSurface::bounds(), GeomDetEnumerators::endcap, DetLayer::location(), GeometricSearchDet::position(), Cylinder::radius(), radius(), BarrelDetLayer::specificSurface(), BarrelDetLayer::surface(), ForwardDetLayer::surface(), theBarrel, theDetRange, theForward, Bounds::thickness(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by getRanges().

00469 {
00470   if ( layer->location() == GeomDetEnumerators::barrel) {
00471     theBarrel = true;
00472     theForward = false;
00473     const BarrelDetLayer& bl = dynamic_cast<const BarrelDetLayer&>(*layer);
00474     float halfThickness  = bl.surface().bounds().thickness()/2;
00475     float radius = bl.specificSurface().radius();
00476     theDetRange = Range(radius-halfThickness, radius+halfThickness);
00477   } else if ( layer->location() == GeomDetEnumerators::endcap) {
00478     theBarrel= false;
00479     theForward = true;
00480     const ForwardDetLayer& fl = dynamic_cast<const ForwardDetLayer&>(*layer);
00481     float halfThickness  = fl.surface().bounds().thickness()/2;
00482     float zLayer = fl.position().z() ;
00483     theDetRange = Range(zLayer-halfThickness, zLayer+halfThickness);
00484   }
00485 }

void ThirdHitPrediction::invertCircle ( Global2DVector c,
float &  r 
) [private]

Definition at line 66 of file ThirdHitPrediction.cc.

References dif, PV2DBase< T, PVType, FrameType >::mag2(), p1, s, and sqr().

Referenced by calculateRangesBarrel(), and findTouchingCircles().

00067 {
00068   float s = dif.mag2() / ((c - p1).mag2() - sqr(r));
00069 
00070   c = p1 + (c - p1)*s;
00071   r *= fabsf(s);
00072 }

void ThirdHitPrediction::invertPoint ( Global2DVector p  )  [private]

Definition at line 75 of file ThirdHitPrediction.cc.

References dif, PV2DBase< T, PVType, FrameType >::mag2(), p1, and s.

Referenced by calculateRangesBarrel(), and calculateRangesForward().

00076 {
00077   float s = dif.mag2() / (p - p1).mag2();
00078 
00079   p = p1 + (p - p1)*s;
00080 }

bool ThirdHitPrediction::isCompatibleWithMultipleScattering ( GlobalPoint  g3,
std::vector< const TrackingRecHit * >  h,
std::vector< GlobalVector > &  localDirs,
const edm::EventSetup es 
)

void ThirdHitPrediction::printOut ( char *  text  )  [private]

void ThirdHitPrediction::spinCloser ( float  phi[3]  )  [private]

Definition at line 201 of file ThirdHitPrediction.cc.

Referenced by calculateRangesBarrel(), and calculateRangesForward().

00202 {
00203   while(phi[1] < phi[0] - M_PI) phi[1] += 2*M_PI;
00204   while(phi[1] > phi[0] + M_PI) phi[1] -= 2*M_PI;
00205 
00206   while(phi[2] < phi[1] - M_PI) phi[2] += 2*M_PI;
00207   while(phi[2] > phi[1] + M_PI) phi[2] -= 2*M_PI;
00208 }


Member Data Documentation

std::pair<float,float> ThirdHitPrediction::arc_0m [private]

Definition at line 90 of file ThirdHitPrediction.h.

Referenced by calculateRangesBarrel(), and calculateRangesForward().

float ThirdHitPrediction::Bz [private]

Definition at line 87 of file ThirdHitPrediction.h.

Global2DVector ThirdHitPrediction::dif [private]

Definition at line 89 of file ThirdHitPrediction.h.

Referenced by findMinimalCircles(), invertCircle(), and invertPoint().

GlobalPoint ThirdHitPrediction::g1 [private]

Definition at line 88 of file ThirdHitPrediction.h.

Referenced by calculateRangesBarrel(), and calculateRangesForward().

GlobalPoint ThirdHitPrediction::g2 [private]

Definition at line 88 of file ThirdHitPrediction.h.

Referenced by calculateRangesBarrel(), and calculateRangesForward().

bool ThirdHitPrediction::keep [private]

Definition at line 92 of file ThirdHitPrediction.h.

double ThirdHitPrediction::maxRatio [private]

Definition at line 95 of file ThirdHitPrediction.h.

Referenced by calculateRangesForward().

double ThirdHitPrediction::nSigma [private]

Definition at line 94 of file ThirdHitPrediction.h.

Global2DVector ThirdHitPrediction::p1 [private]

Definition at line 89 of file ThirdHitPrediction.h.

Referenced by angleRatio(), calculateRangesBarrel(), calculateRangesForward(), invertCircle(), and invertPoint().

Global2DVector ThirdHitPrediction::p2 [private]

Definition at line 89 of file ThirdHitPrediction.h.

Referenced by angleRatio(), calculateRangesBarrel(), calculateRangesForward(), and findTouchingCircles().

float ThirdHitPrediction::r0 [private]

Definition at line 87 of file ThirdHitPrediction.h.

float ThirdHitPrediction::rm [private]

Definition at line 87 of file ThirdHitPrediction.h.

bool ThirdHitPrediction::theBarrel [private]

Definition at line 77 of file ThirdHitPrediction.h.

Referenced by calculateRanges(), and initLayer().

Range ThirdHitPrediction::theDetRange [private]

Definition at line 78 of file ThirdHitPrediction.h.

Referenced by getRanges(), and initLayer().

bool ThirdHitPrediction::theForward [private]

Definition at line 77 of file ThirdHitPrediction.h.

Referenced by initLayer().

const DetLayer* ThirdHitPrediction::theLayer [private]

Definition at line 82 of file ThirdHitPrediction.h.

Referenced by getRanges().

PixelRecoLineRZ ThirdHitPrediction::theLine [private]

Definition at line 80 of file ThirdHitPrediction.h.

Margin ThirdHitPrediction::theTolerance [private]

Definition at line 79 of file ThirdHitPrediction.h.

const TransientTrackingRecHitBuilder* ThirdHitPrediction::theTTRecHitBuilder [private]

Definition at line 84 of file ThirdHitPrediction.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:26 2009 for CMSSW by  doxygen 1.5.4