CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
estimate_field.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Tracks
4 // Class : estimate_field
5 // $Id: estimate_field.cc,v 1.4 2009/12/11 21:18:45 dmytro Exp $
6 //
7 
8 #include "Math/Vector3D.h"
11 
12 double
13 fw::estimate_field( const reco::Track& track, bool highQuality )
14 {
15  if ( !track.extra().isAvailable() ) return -1;
16  // We have 3 states so we can form 3 pairs to check for curvature
17  // In practice we want to avoid estimates over lost of material and
18  // in regions with small field. Therefore we should look at the pair
19  // based on POCA and closest state to it. Than we will estimate the
20  // filed inside the solenoid.
21  double estimate = -1;
22  if ( pow(track.outerPosition().x()-track.vx(),2)+pow(track.outerPosition().y()-track.vy(),2) <
23  pow(track.innerPosition().x()-track.vx(),2)+pow(track.innerPosition().y()-track.vy(),2) )
24  {
25  estimate = estimate_field( track.outerPosition().x(),
26  track.outerPosition().y(),
27  track.vx(),
28  track.vy(),
29  track.px(),
30  track.py() );
31  }
32  else
33  {
34  estimate = estimate_field( track.innerPosition().x(),
35  track.innerPosition().y(),
36  track.vx(),
37  track.vy(),
38  track.px(),
39  track.py() );
40  }
41 
42  if ( highQuality ){
43  if ( fabs( track.outerMomentum().rho()/track.pt()-1 )<0.1 &&
44  track.innerPosition().rho()<129 &&
45  track.outerPosition().rho()<129 ){
46  /*printf("outer-poca: \tPOCA Pt: %0.2f, \tinner Rho: %0.1f, \touter Rho: %0.1f, \tchange in pt: %0.1f%%, \testimate: %0.2f\n",
47  track.pt(), track.innerPosition().rho(), track.outerPosition().rho(),
48  fabs( track.outerMomentum().rho()/track.pt()-1 )*100, estimate);*/
49  return estimate;
50  } else {
51  return -1;
52  }
53  } else
54  return estimate;
55 }
56 
57 double
58 fw::estimate_field( double vx1, double vy1, double vx2, double vy2, double px, double py )
59 {
60  math::XYZVector displacement(vx2-vx1, vy2-vy1, 0);
61  math::XYZVector transverseMomentum(px, py, 0);
62  double cosAlpha = transverseMomentum.Dot(displacement)/transverseMomentum.r()/displacement.r();
63  return 200*sqrt(1-cosAlpha*cosAlpha)/0.2998*transverseMomentum.r()/displacement.r();
64 }
const TrackExtraRef & extra() const
reference to &quot;extra&quot; object
Definition: Track.h:97
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:133
bool isAvailable() const
Definition: Ref.h:276
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:47
double estimate_field(const reco::Track &track, bool highQuality=false)
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:42
T sqrt(T t)
Definition: SSEVec.h:46
double pt() const
track transverse momentum
Definition: TrackBase.h:131
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:49
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:145
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:135
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:143