CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoTracker/TrackProducer/plugins/DAFTrackProducer.cc

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