Go to the documentation of this file.00001 #include "FWCore/Framework/interface/ESHandle.h"
00002 #include "FWCore/Framework/interface/EventSetup.h"
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00006 #include "Alignment/ReferenceTrajectories/interface/TrajectoryFactoryPlugin.h"
00007 #include "Alignment/ReferenceTrajectories/interface/ReferenceTrajectory.h"
00008
00009 #include "Alignment/ReferenceTrajectories/interface/TrajectoryFactoryBase.h"
00010
00012
00013 class ReferenceTrajectoryFactory : public TrajectoryFactoryBase
00014 {
00015 public:
00016 ReferenceTrajectoryFactory(const edm::ParameterSet &config);
00017 virtual ~ReferenceTrajectoryFactory();
00018
00020 virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup,
00021 const ConstTrajTrackPairCollection &tracks,
00022 const reco::BeamSpot &beamSpot) const;
00023
00024 virtual const ReferenceTrajectoryCollection trajectories(const edm::EventSetup &setup,
00025 const ConstTrajTrackPairCollection &tracks,
00026 const ExternalPredictionCollection &external,
00027 const reco::BeamSpot &beamSpot) const;
00028
00029 virtual ReferenceTrajectoryFactory* clone() const { return new ReferenceTrajectoryFactory(*this); }
00030
00031 protected:
00032
00033 double theMass;
00034 };
00035
00039
00040 ReferenceTrajectoryFactory::ReferenceTrajectoryFactory( const edm::ParameterSet & config ) :
00041 TrajectoryFactoryBase( config )
00042 {
00043 theMass = config.getParameter< double >( "ParticleMass" );
00044 }
00045
00046
00047 ReferenceTrajectoryFactory::~ReferenceTrajectoryFactory( void ) {}
00048
00049
00050 const ReferenceTrajectoryFactory::ReferenceTrajectoryCollection
00051 ReferenceTrajectoryFactory::trajectories(const edm::EventSetup &setup,
00052 const ConstTrajTrackPairCollection &tracks,
00053 const reco::BeamSpot &beamSpot) const
00054 {
00055 ReferenceTrajectoryCollection trajectories;
00056
00057 edm::ESHandle< MagneticField > magneticField;
00058 setup.get< IdealMagneticFieldRecord >().get( magneticField );
00059
00060 ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
00061
00062 while ( itTracks != tracks.end() )
00063 {
00064 TrajectoryInput input = this->innermostStateAndRecHits( *itTracks );
00065
00066
00067 if ( input.first.isValid() )
00068 {
00069
00070 trajectories.push_back(ReferenceTrajectoryPtr(new ReferenceTrajectory(input.first, input.second, false,
00071 magneticField.product(), materialEffects(),
00072 propagationDirection(), theMass,
00073 theUseBeamSpot, beamSpot)));
00074 }
00075
00076 ++itTracks;
00077 }
00078
00079 return trajectories;
00080 }
00081
00082
00083 const ReferenceTrajectoryFactory::ReferenceTrajectoryCollection
00084 ReferenceTrajectoryFactory::trajectories( const edm::EventSetup & setup,
00085 const ConstTrajTrackPairCollection& tracks,
00086 const ExternalPredictionCollection& external,
00087 const reco::BeamSpot &beamSpot) const
00088 {
00089 ReferenceTrajectoryCollection trajectories;
00090
00091 if ( tracks.size() != external.size() )
00092 {
00093 edm::LogInfo("ReferenceTrajectories") << "@SUB=ReferenceTrajectoryFactory::trajectories"
00094 << "Inconsistent input:\n"
00095 << "\tnumber of tracks = " << tracks.size()
00096 << "\tnumber of external predictions = " << external.size();
00097 return trajectories;
00098 }
00099
00100 edm::ESHandle< MagneticField > magneticField;
00101 setup.get< IdealMagneticFieldRecord >().get( magneticField );
00102
00103 ConstTrajTrackPairCollection::const_iterator itTracks = tracks.begin();
00104 ExternalPredictionCollection::const_iterator itExternal = external.begin();
00105
00106 while ( itTracks != tracks.end() )
00107 {
00108 TrajectoryInput input = innermostStateAndRecHits( *itTracks );
00109
00110 if ( input.first.isValid() )
00111 {
00112 if ( (*itExternal).isValid() && sameSurface( (*itExternal).surface(), input.first.surface() ) )
00113 {
00114
00115 ReferenceTrajectoryPtr refTraj( new ReferenceTrajectory( *itExternal, input.second, false,
00116 magneticField.product(), materialEffects(),
00117 propagationDirection(), theMass,
00118 theUseBeamSpot, beamSpot) );
00119
00120 AlgebraicSymMatrix externalParamErrors( asHepMatrix<5>( (*itExternal).localError().matrix() ) );
00121 refTraj->setParameterErrors( externalParamErrors );
00122
00123 trajectories.push_back( refTraj );
00124 }
00125 else
00126 {
00127 trajectories.push_back(ReferenceTrajectoryPtr(new ReferenceTrajectory(input.first, input.second, false,
00128 magneticField.product(), materialEffects(),
00129 propagationDirection(), theMass,
00130 theUseBeamSpot, beamSpot)));
00131 }
00132 }
00133
00134 ++itTracks;
00135 ++itExternal;
00136 }
00137
00138 return trajectories;
00139 }
00140
00141 DEFINE_EDM_PLUGIN( TrajectoryFactoryPlugin, ReferenceTrajectoryFactory, "ReferenceTrajectoryFactory" );