Go to the documentation of this file.00001 #include "RecoTracker/TrackProducer/plugins/MTFTrackProducer.h"
00002
00003 #include <memory>
00004
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/MakerMacros.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00009 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00010 #include "RecoTracker/SiTrackerMRHTools/interface/MultiTrackFilterHitCollector.h"
00011 #include "RecoTracker/Record/interface/MultiRecHitRecord.h"
00012 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00013 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00014
00015 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00016
00017
00018 MTFTrackProducer::MTFTrackProducer(const edm::ParameterSet& iConfig):
00019 KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),false),
00020 theAlgo(iConfig)
00021 {
00022 setConf(iConfig);
00023 setSrc( iConfig.getParameter<edm::InputTag>( "src" ), iConfig.getParameter<edm::InputTag>( "beamSpot" ));
00024 setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
00025
00026 produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
00027 produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
00028 produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
00029 produces<std::vector<Trajectory> >() ;
00030 produces<TrajTrackAssociationCollection>();
00031 }
00032
00033
00034 void MTFTrackProducer::produce(edm::Event& theEvent, const edm::EventSetup& setup)
00035 {
00036 edm::LogInfo("MTFTrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
00037
00038
00039
00040 std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
00041 std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
00042 std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
00043 std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
00044
00045
00046
00047
00048 edm::ESHandle<TrackerGeometry> theG;
00049 edm::ESHandle<MagneticField> theMF;
00050 edm::ESHandle<TrajectoryFitter> theFitter;
00051 edm::ESHandle<Propagator> thePropagator;
00052 edm::ESHandle<MeasurementTracker> theMeasTk;
00053 edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
00054 getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
00055
00056 edm::ESHandle<MultiTrackFilterHitCollector> measurementCollectorHandle;
00057 edm::ESHandle<SiTrackerMultiRecHitUpdatorMTF> updatorHandle;
00058 std::string measurementCollectorName = getConf().getParameter<std::string>("MeasurementCollector");
00059 setup.get<MultiRecHitRecord>().get(measurementCollectorName, measurementCollectorHandle);
00060 std::string updatorName = getConf().getParameter<std::string>("UpdatorName");
00061 setup.get<MultiRecHitRecord>().get(updatorName, updatorHandle);
00062
00063 AlgoProductCollection algoResults;
00064
00065 edm::Handle<std::vector<Trajectory> > theTrajectoryCollection;
00066
00067 reco::BeamSpot bs;
00068
00069
00070 getFromEvt(theEvent,theTrajectoryCollection,bs);
00071
00072 measurementCollectorHandle->updateEvent(theEvent);
00073
00074
00075
00076
00077 theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTrajectoryCollection,
00078 theFitter.product(), theBuilder.product(), measurementCollectorHandle.product(), updatorHandle.product(),bs,algoResults);
00079
00080
00081 putInEvt(theEvent, thePropagator.product(), theMeasTk.product(),
00082 outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults);
00083 LogDebug("MTFTrackProducer") << "end" << "\n";
00084 }
00085
00086
00087 void MTFTrackProducer::getFromEvt(edm::Event& theEvent,edm::Handle<TrajectoryCollection>& theTrajectoryCollection, reco::BeamSpot& bs)
00088 {
00089
00090 edm::InputTag src_=getConf().getParameter<edm::InputTag>( "src" );
00091 theEvent.getByLabel(src_,theTrajectoryCollection );
00092
00093
00094 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00095 theEvent.getByLabel(bsSrc_,recoBeamSpotHandle);
00096 bs = *recoBeamSpotHandle;
00097 }