CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

TrackFitter Class Reference

#include <TrackFitter.h>

Inheritance diagram for TrackFitter:
PixelFitter

List of all members.

Public Member Functions

virtual reco::Trackrun (const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
 TrackFitter (const edm::ParameterSet &cfg)
virtual ~TrackFitter ()

Private Member Functions

int getCharge (const std::vector< GlobalPoint > &points) const
float getCotThetaAndUpdateZip (const GlobalPoint &inner, const GlobalPoint &outer, float radius, float phi, float d0, float &zip) const
void getErrTipAndErrZip (float pt, float eta, float &errZip, float &errTip) const
float getPhi (float xC, float yC, int charge) const
float getZip (float d0, float curv, const GlobalPoint &inner, const GlobalPoint &outer) const

Private Attributes

edm::ParameterSet theConfig
const MagneticFieldtheField
const TrackerGeometrytheTracker
const
TransientTrackingRecHitBuilder
theTTRecHitBuilder

Detailed Description

Definition at line 17 of file TrackFitter.h.


Constructor & Destructor Documentation

TrackFitter::TrackFitter ( const edm::ParameterSet cfg)

Definition at line 39 of file TrackFitter.cc.

virtual TrackFitter::~TrackFitter ( ) [inline, virtual]

Definition at line 21 of file TrackFitter.h.

{ }

Member Function Documentation

int TrackFitter::getCharge ( const std::vector< GlobalPoint > &  points) const [private]
float TrackFitter::getCotThetaAndUpdateZip ( const GlobalPoint inner,
const GlobalPoint outer,
float  radius,
float  phi,
float  d0,
float &  zip 
) const [private]

Definition at line 152 of file TrackFitter.cc.

References funct::cos(), M_PI_2, perp(), funct::sin(), and PV3DBase< T, PVType, FrameType >::z().

{
   float chi = phi - M_PI_2;
   GlobalPoint IP(d0*cos(chi), d0*sin(chi),zip);

   float phi1 = 2*asin(0.5*(inner - IP).perp()/radius);
   float phi2 = 2*asin(0.5*(outer - IP).perp()/radius);

   float dr = radius*(phi2 - phi1);
   float dz = outer.z()-inner.z();

   // Recalculate ZIP
   zip = (inner.z()*phi2 - outer.z()*phi1)/(phi2 - phi1);

   return (fabs(dr) > 1.e-3) ? dz/dr : 0;
}
void TrackFitter::getErrTipAndErrZip ( float  pt,
float  eta,
float &  errZip,
float &  errTip 
) const [private]

Definition at line 204 of file TrackFitter.cc.

References ExpressReco_HICollisions_FallBack::pt, and mathSSE::sqrt().

{
  float coshEta = cosh(eta);

  { // transverse
    float c_ms = 0.0115; //0.0115;
    float s_le = 0.0095; //0.0123;
    float s_ms2 = c_ms*c_ms / (pt*pt) * coshEta;

    errTip = sqrt(s_le*s_le + s_ms2                  );
  }

  { // z
    float c_ms = 0.0070;
    float s_le = 0.0135;

    errZip = sqrt( (s_le*s_le + c_ms*c_ms/(pt*pt)) * coshEta*coshEta*coshEta);
  }
}
float TrackFitter::getPhi ( float  xC,
float  yC,
int  charge 
) const [private]

Definition at line 172 of file TrackFitter.cc.

{
  float phiC;

  if (charge>0) phiC = atan2(xC,-yC);
           else phiC = atan2(-xC,yC);

  return phiC;
}
float TrackFitter::getZip ( float  d0,
float  curv,
const GlobalPoint inner,
const GlobalPoint outer 
) const [private]

Definition at line 184 of file TrackFitter.cc.

References PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::perp2(), and PV3DBase< T, PVType, FrameType >::z().

{
  // phi = asin(r*rho/2) with asin(x) ~= x+x**3/(2*3)
  float rho3 = curv*curv*curv;

  float r1 = inner.perp();
  double phi1 = r1*curv/2 + inner.perp2()*r1*rho3/48.;

  float r2 = outer.perp();
  double phi2 = r2*curv/2 + outer.perp2()*r2*rho3/48.;

  double z1 = inner.z();
  double z2 = outer.z();

  return z1 - phi1/(phi1-phi2)*(z1-z2);
}
reco::Track * TrackFitter::run ( const edm::EventSetup es,
const std::vector< const TrackingRecHit * > &  hits,
const TrackingRegion region 
) const [virtual]

Implements PixelFitter.

Definition at line 46 of file TrackFitter.cc.

References PixelTrackBuilder::build(), CircleFromThreePoints::center(), DeDxDiscriminatorTools::charge(), RZLine::chi2(), ExpressReco_HICollisions_FallBack::chi2, PixelRecoUtilities::curvature(), CircleFromThreePoints::curvature(), ExpressReco_HICollisions_FallBack::errors, RZLine::fit(), edm::EventSetup::get(), PixelRecoUtilities::inversePt(), Basic2DVector< T >::mag(), phi, edm::ESHandle< T >::product(), ExpressReco_HICollisions_FallBack::pt, Basic2DVector< T >::x(), and Basic2DVector< T >::y().

{
  int nhits = hits.size();
  if(nhits <2) return 0;

  vector<GlobalPoint> points;
  vector<GlobalError> errors;
  vector<bool> isBarrel;
  
  if (!theField || !theTracker || !theTTRecHitBuilder)
  {
    edm::ESHandle<TrackerGeometry> trackerESH;
    es.get<TrackerDigiGeometryRecord>().get(trackerESH);
    theTracker = trackerESH.product();

    edm::ESHandle<MagneticField> fieldESH;
    es.get<IdealMagneticFieldRecord>().get(fieldESH);
    theField = fieldESH.product();

    edm::ESHandle<TransientTrackingRecHitBuilder> ttrhbESH;
    std::string builderName = theConfig.getParameter<std::string>("TTRHBuilder");
    es.get<TransientRecHitRecord>().get(builderName,ttrhbESH);
    theTTRecHitBuilder = ttrhbESH.product();
  }

  for (vector<const TrackingRecHit*>::const_iterator ih = hits.begin();
                                                     ih!= hits.end(); ih++)
  {
    TransientTrackingRecHit::RecHitPointer recHit =
      theTTRecHitBuilder->build(*ih);

    points.push_back(recHit->globalPosition());
    errors.push_back(recHit->globalPositionError());
    isBarrel.push_back(recHit->detUnit()->type().isBarrel() );
  }

  CircleFromThreePoints circle = (nhits==2) ?
        CircleFromThreePoints(GlobalPoint(0.,0.,0.), points[0], points[1]) :
        CircleFromThreePoints(points[0],points[1],points[2]); 

  int charge = getCharge(points);
  float curvature = circle.curvature();

  // pt
  float invPt = PixelRecoUtilities::inversePt(curvature, es);
  float valPt = (invPt > 1.e-4) ? 1./invPt : 1.e4;
  float errPt = 0.055*valPt + 0.017*valPt*valPt;

  CircleFromThreePoints::Vector2D center = circle.center();

  // tip
  float valTip = charge * (center.mag()-1/curvature);
  // zip
  float valZip = getZip(valTip, curvature, points[0],points[1]);
  // phi
  float valPhi = getPhi(center.x(), center.y(), charge);
  // cot(theta), update zip
  float valCotTheta =
     getCotThetaAndUpdateZip(points[0],points[1], 1/curvature,
                             valPhi,valTip,valZip);

  // errors
  float errTip, errZip;
  getErrTipAndErrZip(valPt, points.back().eta(), errTip,errZip);
  float errPhi      = 0.002;
  float errCotTheta = 0.002;

  float chi2 = 0;
  if(nhits > 2)
  {
    RZLine rzLine(points,errors,isBarrel);
    float      cotTheta, intercept, covss, covii, covsi; 
    rzLine.fit(cotTheta, intercept, covss, covii, covsi);
    chi2 = rzLine.chi2(cotTheta, intercept);
    //FIXME: check which intercept to use!
  }

  // build pixel track
  PixelTrackBuilder builder;

  Measurement1D pt      (valPt,       errPt);
  Measurement1D phi     (valPhi,      errPhi);
  Measurement1D cotTheta(valCotTheta, errCotTheta);
  Measurement1D tip     (valTip,      errTip);
  Measurement1D zip     (valZip,      errZip);

  return builder.build(pt, phi, cotTheta, tip, zip, chi2,
                       charge, hits, theField);
}

Member Data Documentation

Definition at line 38 of file TrackFitter.h.

const MagneticField* TrackFitter::theField [mutable, private]

Definition at line 41 of file TrackFitter.h.

const TrackerGeometry* TrackFitter::theTracker [mutable, private]

Definition at line 40 of file TrackFitter.h.

Definition at line 42 of file TrackFitter.h.