CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfTrackProducer.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
10 
12 
17 
19  GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
20  iConfig.getParameter<bool>("useHitsSplitting")),
21  theAlgo(iConfig)
22 {
23  setConf(iConfig);
24  setSrc( consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>( "src" )),
25  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>( "beamSpot" )),
26  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>( "MeasurementTrackerEvent") ));
27  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
28 // string a = alias_;
29 // a.erase(a.size()-6,a.size());
30  //register your products
31  produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
32  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
33  produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
34  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
35  produces<std::vector<Trajectory> >() ;
36  produces<TrajGsfTrackAssociationCollection>();
37 
38 }
39 
40 
42 {
43  edm::LogInfo("GsfTrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
44  //
45  // create empty output collections
46  //
47  std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
48  std::auto_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
49  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
50  std::auto_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
51  std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
52 
53  //
54  //declare and get stuff to be retrieved from ES
55  //
59  edm::ESHandle<Propagator> thePropagator;
62  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
63 
64  //
65  //declare and get TrackColection to be retrieved from the event
66  //
67  AlgoProductCollection algoResults;
68  reco::BeamSpot bs;
69  try{
71  getFromEvt(theEvent,theTCCollection,bs);
72 
73  //
74  //run the algorithm
75  //
76  LogDebug("GsfTrackProducer") << "run the algorithm" << "\n";
77  theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
78  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
79  } catch (cms::Exception &e){ edm::LogInfo("GsfTrackProducer") << "cms::Exception caught!!!" << "\n" << e << "\n"; throw; }
80  //
81  //put everything in the event
82  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputGsfTEColl,
83  outputTrajectoryColl, algoResults, theBuilder.product(), bs);
84  LogDebug("GsfTrackProducer") << "end" << "\n";
85 }
#define LogDebug(id)
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
void setAlias(std::string alias)
set the aliases of produced collections
void setConf(const edm::ParameterSet &conf)
Set parameter set.
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
std::vector< AlgoProduct > AlgoProductCollection
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
T const * product() const
Definition: ESHandle.h:86
edm::EventID id() const
Definition: EventBase.h:56
virtual void putInEvt(edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::auto_ptr< TrackingRecHitCollection > &, std::auto_ptr< reco::GsfTrackCollection > &, std::auto_ptr< reco::TrackExtraCollection > &, std::auto_ptr< reco::GsfTrackExtraCollection > &, std::auto_ptr< std::vector< Trajectory > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, const reco::BeamSpot &)
Put produced collections in the event.
void runWithCandidate(const TrackingGeometry *, const MagneticField *, const TrackCandidateCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
Run the Final Fit taking TrackCandidates as input.
GsfTrackProducer(const edm::ParameterSet &iConfig)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void getFromES(const edm::EventSetup &, edm::ESHandle< TrackerGeometry > &, edm::ESHandle< MagneticField > &, edm::ESHandle< TrajectoryFitter > &, edm::ESHandle< Propagator > &, edm::ESHandle< MeasurementTracker > &, edm::ESHandle< TransientTrackingRecHitBuilder > &)
Get needed services from the Event Setup.