CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/Fireworks/Tracks/src/estimate_field.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Tracks
00004 // Class  :     estimate_field
00005 // $Id: estimate_field.cc,v 1.4 2009/12/11 21:18:45 dmytro Exp $
00006 //
00007 
00008 #include "Math/Vector3D.h"
00009 #include "DataFormats/TrackReco/interface/Track.h"
00010 #include "Fireworks/Tracks/interface/estimate_field.h"
00011 
00012 double
00013 fw::estimate_field( const reco::Track& track, bool highQuality )
00014 {
00015    if ( !track.extra().isAvailable() ) return -1;
00016    // We have 3 states so we can form 3 pairs to check for curvature
00017    // In practice we want to avoid estimates over lost of material and
00018    // in regions with small field. Therefore we should look at the pair
00019    // based on POCA and closest state to it. Than we will estimate the
00020    // filed inside the solenoid. 
00021    double estimate = -1;
00022    if ( pow(track.outerPosition().x()-track.vx(),2)+pow(track.outerPosition().y()-track.vy(),2) <
00023         pow(track.innerPosition().x()-track.vx(),2)+pow(track.innerPosition().y()-track.vy(),2) )
00024      {
00025        estimate = estimate_field( track.outerPosition().x(), 
00026                                   track.outerPosition().y(),
00027                                   track.vx(),
00028                                   track.vy(),
00029                                   track.px(),
00030                                   track.py() );
00031      }
00032    else
00033      {
00034        estimate = estimate_field( track.innerPosition().x(), 
00035                                   track.innerPosition().y(),
00036                                   track.vx(),
00037                                   track.vy(),
00038                                   track.px(),
00039                                   track.py() );
00040      }
00041    
00042    if ( highQuality ){
00043      if ( fabs( track.outerMomentum().rho()/track.pt()-1 )<0.1 && 
00044           track.innerPosition().rho()<129 &&
00045           track.outerPosition().rho()<129 ){
00046        /*printf("outer-poca: \tPOCA Pt: %0.2f, \tinner Rho: %0.1f, \touter Rho: %0.1f, \tchange in pt: %0.1f%%, \testimate: %0.2f\n",
00047               track.pt(), track.innerPosition().rho(), track.outerPosition().rho(), 
00048               fabs( track.outerMomentum().rho()/track.pt()-1 )*100, estimate);*/
00049        return estimate;
00050      } else {
00051        return -1;
00052      }
00053    } else
00054      return estimate;
00055 }
00056 
00057 double
00058 fw::estimate_field( double vx1, double vy1, double vx2, double vy2, double px, double py )
00059 {
00060   math::XYZVector displacement(vx2-vx1, vy2-vy1, 0);
00061   math::XYZVector transverseMomentum(px, py, 0);
00062   double cosAlpha = transverseMomentum.Dot(displacement)/transverseMomentum.r()/displacement.r();
00063   return 200*sqrt(1-cosAlpha*cosAlpha)/0.2998*transverseMomentum.r()/displacement.r();
00064 }