CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoTracker/DebugTools/src/FTSFromSimHitFactory.cc

Go to the documentation of this file.
00001 #include "RecoTracker/DebugTools/interface/FTSFromSimHitFactory.h"
00002 #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
00003 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00004 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00005 #include <algorithm>
00006 
00007 FreeTrajectoryState FTSFromSimHitFactory::operator()( const PSimHit& hit, 
00008                                                       const GeomDetUnit& det,
00009                                                       const MagneticField& field) const
00010 {
00011   GlobalVector momenta = det.toGlobal( hit.momentumAtEntry());
00012   TrackCharge ch = charge( hit.particleType());
00013   GlobalTrajectoryParameters param( det.toGlobal( hit.localPosition()), momenta, ch, &field);
00014   return FreeTrajectoryState( param);
00015 }
00016 
00017 TrackCharge FTSFromSimHitFactory::charge( int particleId) const
00018 {
00019   if (std::abs( particleId) < 20) {
00020     // lepton 
00021     return TrackCharge( (particleId > 0) ? -1 : 1);
00022   }
00023   else {
00024     // only correct for stable mesoms and baryons
00025     return TrackCharge( (particleId > 0) ? 1 : -1);
00026   }
00027 }