Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TrackPtKick.cpp

Go to the documentation of this file.
00001 // $Id: TrackPtKick.cpp,v 1.2 2005/05/25 14:31:35 cattanem Exp $
00002 // Include files
00003 // -------------
00004 
00005 // from Gaudi
00006 #include "GaudiKernel/ToolFactory.h" 
00007 
00008 // from TrackEvent
00009 #include "Event/TrackParameters.h"
00010 #include "Event/State.h"
00011 
00012 // from CLHEP
00013 #include "CLHEP/Units/PhysicalConstants.h"
00014 
00015 // local
00016 #include "TrackPtKick.h"
00017 
00018 //-----------------------------------------------------------------------------
00019 // Implementation file for class : TrackPtKick
00020 //
00021 // 2000-08-16 : M. Needham
00022 // 2005-05-13 : J. Nardulli (adaptations to new track event model)
00023 //-----------------------------------------------------------------------------
00024 
00025 // Declaration of the Tool Factory
00026 static const  ToolFactory<TrackPtKick>          s_factory ;
00027 const        IToolFactory& TrackPtKickFactory = s_factory ; 
00028 
00029 
00030 //=============================================================================
00031 // Standard constructor, initializes variables
00032 //=============================================================================
00033 TrackPtKick::TrackPtKick( const std::string& type,
00034                           const std::string& name,
00035                           const IInterface* parent )
00036   : GaudiTool ( type, name , parent )
00037   , m_bIntegrator(0)
00038   , m_FieldPolarity(1)
00039 
00040 {
00041   declareInterface<ITrackPtKick>(this);
00042 
00043   declareProperty( "MomentumError",       m_MomentumError = 0.01);
00044   declareProperty( "ParabolicCorrection", m_ParabolicCorrection );
00045   declareProperty( "ConstantCorrection",  m_Constant = 0.*MeV );
00046 
00047   m_ParabolicCorrection.push_back( -0.0092 );
00048   m_ParabolicCorrection.push_back( 0.0 );
00049   m_ParabolicCorrection.push_back( -0.112 );
00050 
00051 }
00052 //=============================================================================
00053 // Destructor
00054 //=============================================================================
00055 TrackPtKick::~TrackPtKick() {}; 
00056 
00057 //=============================================================================
00058 // Initialization
00059 //=============================================================================
00060 StatusCode TrackPtKick::initialize()
00061 {
00062   StatusCode sc = GaudiTool::initialize();
00063   if (sc.isFailure()) return sc;  // error already reported by base class
00064 
00065   m_bIntegrator = tool<IBIntegrator>( "IBIntegrator" );
00066   
00067   info() << " Pt kick parameters(" << m_ParabolicCorrection.size()
00068          << ") ==" <<m_ParabolicCorrection[0] << " + " 
00069          << m_ParabolicCorrection[1]<<" tx + "
00070          << m_ParabolicCorrection[2] <<" tx^2 " <<endreq;
00071 
00072   determineFieldPolarity();
00073 
00074   return StatusCode::SUCCESS;
00075 }
00076 
00077 //=============================================================================
00078 // Estimate the momentum P of a State
00079 //=============================================================================
00080 StatusCode TrackPtKick::calculate( State* state ) const
00081 {
00082   // calculate intial estimate of track momentum assuming it came from
00083   // the primary vertex
00084 
00085   StatusCode sc = StatusCode::SUCCESS;
00086 
00087   // scan in cm steps  
00088   HepPoint3D  begin( 0., 0., 0. );
00089   HepPoint3D  end( state->x(), state->y(), state->z() );
00090   HepVector3D bdl;
00091   double zCenter;
00092 
00093   m_bIntegrator -> calculateBdlAndCenter( begin, end, state->tx(), 
00094                                           state->ty(), zCenter, bdl );
00095   double q = 0.;
00096   double p = 1e6 * MeV;
00097 
00098   if ( fabs(bdl[0]) > TrackParameters::hiTolerance ) {
00099     //can estimate momentum and charge
00100 
00101     //Rotate to the  0-0-z axis and do the ptkick 
00102     double tX = state -> tx();
00103     double xCenter = state -> x() + tX * ( zCenter - state->z() );
00104 
00105     double zeta_trk = -tX / sqrt( 1.0 + tX*tX );
00106     double tx_vtx   = xCenter / zCenter;
00107     double zeta_vtx = -tx_vtx/ sqrt( 1.0 + tx_vtx*tx_vtx );
00108   
00109     // curvature
00110     double curv = ( zeta_trk - zeta_vtx );
00111 
00112     // charge
00113     int sign = 1;
00114     if(curv< TrackParameters::hiTolerance ) {
00115       sign *= -1;
00116     }
00117     if ( bdl[0] < TrackParameters::hiTolerance ) {
00118       sign *= -1;      
00119     }
00120     q = -1. * m_FieldPolarity*sign;
00121 
00122     // momentum
00123     p = eplus * c_light *fabs(bdl[0]) 
00124         * sqrt((1.0 +tX*tX+pow(state->ty(),2.))
00125                                            /(1.0 +pow(tX,2.)))/fabs(curv);
00126 
00127     //   Addition Correction factor for the angle of the track!
00128     if ( m_ParabolicCorrection.size() == 3 ) {
00129       double tx = (float) state -> tx();
00130       //p*=(1 - (a + b*tx + c*tx*tx ) );
00131       p+= m_Constant;
00132       p*= ( 1 - ( m_ParabolicCorrection[0]
00133                    + m_ParabolicCorrection[1] * fabs(tx)
00134                    + m_ParabolicCorrection[2] * tx * tx ) );
00135     }
00136 
00137   }  
00138   else {
00139     // can't estimate momentum or charge
00140     error() << "B integral is 0!" << endreq;
00141     sc = StatusCode::FAILURE;
00142   }
00143 
00144   // set the state parameters
00145   state -> setQOverP( q / p );
00146   //state -> setEQdivP2(pow(m_MomentumError/p,2.0));
00147   HepSymMatrix& cov = state -> covariance();
00148   double errQOverP = m_MomentumError / p;
00149   cov.fast(5,5) = errQOverP * errQOverP;
00150 
00151   return sc;
00152 }
00153 
00154 //=============================================================================
00155 // Determination of the field polarity
00156 //=============================================================================
00157 void TrackPtKick::determineFieldPolarity()
00158 {
00159  // determine the field polarity by sending out a test particle
00160  HepPoint3D  begin( 0., 0., 0. );
00161  HepPoint3D  end( 0., 0., 100. );
00162  HepVector3D bdl;
00163  double z;
00164 
00165  m_bIntegrator -> calculateBdlAndCenter( begin, end, 0., 0., z, bdl );
00166  
00167  if ( bdl[0] > 0.0 ) {
00168    m_FieldPolarity =  1;
00169  } 
00170  else {
00171    m_FieldPolarity = -1; 
00172  }
00173 
00174 }
00175 
00176 //=============================================================================

Generated on Fri May 27 13:59:37 2005 for New Track Event Model by doxygen 1.4.1