00001 #include "RecoTracker/TrackProducer/plugins/GsfTrackRefitter.h"
00002
00003 #include <memory>
00004
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00010 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00011 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00012
00013 GsfTrackRefitter::GsfTrackRefitter(const edm::ParameterSet& iConfig):
00014 GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
00015 iConfig.getParameter<bool>("useHitsSplitting")),
00016 theAlgo(iConfig)
00017 {
00018 setConf(iConfig);
00019 setSrc( iConfig.getParameter<edm::InputTag>( "src" ), iConfig.getParameter<edm::InputTag>( "beamSpot" ));
00020 setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
00033 produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
00034 produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
00035 produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
00036 produces<std::vector<Trajectory> >() ;
00037 produces<TrajTrackAssociationCollection>();
00038
00039 }
00040
00041 void GsfTrackRefitter::produce(edm::Event& theEvent, const edm::EventSetup& setup)
00042 {
00043 edm::LogInfo("GsfTrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
00044
00045
00046
00047 std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
00048 std::auto_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
00049 std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
00050 std::auto_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
00051 std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
00052
00053
00054
00055
00056 edm::ESHandle<TrackerGeometry> theG;
00057 edm::ESHandle<MagneticField> theMF;
00058 edm::ESHandle<TrajectoryFitter> theFitter;
00059 edm::ESHandle<Propagator> thePropagator;
00060
00061 edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
00062 getFromES(setup,theG,theMF,theFitter,thePropagator,theBuilder);
00063
00064
00065
00066
00067 AlgoProductCollection algoResults;
00068 reco::BeamSpot bs;
00069 {
00070 edm::Handle<reco::GsfTrackCollection> theTCollection;
00071 getFromEvt(theEvent,theTCollection,bs);
00072 if (theTCollection.failedToGet()){
00073 edm::LogError("GsfTrackRefitter")<<"could not get the reco::GsfTrackCollection."; return;}
00074 LogDebug("GsfTrackRefitter") << "run the algorithm" << "\n";
00075 try {
00076 theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection,
00077 theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
00078 }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
00079 }
00080
00081
00082
00083 putInEvt(theEvent, outputRHColl, outputTColl, outputTEColl, outputGsfTEColl, outputTrajectoryColl, algoResults, bs);
00084 LogDebug("GsfTrackRefitter") << "end" << "\n";
00085 }
00086