CMS 3D CMS Logo

GsfTrackProducer.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
10 
12 
17 
20 
22  GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
23  iConfig.getParameter<bool>("useHitsSplitting")),
24  theAlgo(iConfig)
25 {
26  setConf(iConfig);
27  setSrc( consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>( "src" )),
28  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>( "beamSpot" )),
29  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>( "MeasurementTrackerEvent") ));
30  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
31 // string a = alias_;
32 // a.erase(a.size()-6,a.size());
33  //register your products
34  produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
35  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
36  produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
37  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
38  produces<std::vector<Trajectory> >() ;
39  produces<TrajGsfTrackAssociationCollection>();
40 
41 }
42 
43 
45 {
46  edm::LogInfo("GsfTrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
47  //
48  // create empty output collections
49  //
50  std::unique_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
51  std::unique_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
52  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
53  std::unique_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
54  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
55 
56  //
57  //declare and get stuff to be retrieved from ES
58  //
62  edm::ESHandle<Propagator> thePropagator;
65  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
66 
68  setup.get<TrackerTopologyRcd>().get(httopo);
69 
70  //
71  //declare and get TrackColection to be retrieved from the event
72  //
73  AlgoProductCollection algoResults;
74  reco::BeamSpot bs;
75  try{
77  getFromEvt(theEvent,theTCCollection,bs);
78 
79  //
80  //run the algorithm
81  //
82  LogDebug("GsfTrackProducer") << "run the algorithm" << "\n";
83  theAlgo.runWithCandidate(theG.product(), theMF.product(), *theTCCollection,
84  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
85  } catch (cms::Exception &e){ edm::LogInfo("GsfTrackProducer") << "cms::Exception caught!!!" << "\n" << e << "\n"; throw; }
86  //
87  //put everything in the event
88  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputGsfTEColl,
89  outputTrajectoryColl, algoResults, theBuilder.product(), bs, httopo.product());
90  LogDebug("GsfTrackProducer") << "end" << "\n";
91 }
92 
95 
96  desc.add<edm::InputTag>("src", edm::InputTag("CkfElectronCandidates"));
97  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
98  desc.add<std::string>("producer", std::string(""));
99  desc.add<std::string>("Fitter", std::string("GsfElectronFittingSmoother"));
100  desc.add<bool>("useHitsSplitting", false);
101  desc.add<bool>("TrajectoryInEvent", false);
102  desc.add<std::string>("TTRHBuilder", std::string("WithTrackAngle"));
103  desc.add<std::string>("Propagator", std::string("fwdElectronPropagator"));
104  desc.add<std::string>("NavigationSchool", std::string("SimpleNavigationSchool"));
105  desc.add<std::string>("MeasurementTracker", std::string(""));
106  desc.add<edm::InputTag>("MeasurementTrackerEvent", edm::InputTag("MeasurementTrackerEvent"));
107  desc.add<bool>("GeometricInnerState", false);
108  desc.add<std::string>("AlgorithmName", std::string("gsf"));
109 
110  descriptions.add("gsfTrackProducer", desc);
111 }
#define LogDebug(id)
T getParameter(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
Method where the procduction take place. To be implemented in concrete classes.
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
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
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
virtual void putInEvt(edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::unique_ptr< TrackingRecHitCollection > &, std::unique_ptr< reco::GsfTrackCollection > &, std::unique_ptr< reco::TrackExtraCollection > &, std::unique_ptr< reco::GsfTrackExtraCollection > &, std::unique_ptr< std::vector< Trajectory > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, const reco::BeamSpot &, const TrackerTopology *ttopo)
Put produced collections in the event.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const T & get() const
Definition: EventSetup.h:59
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< AlgoProduct > AlgoProductCollection
edm::EventID id() const
Definition: EventBase.h:60
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.
T const * product() const
Definition: ESHandle.h:86
GsfTrackProducer(const edm::ParameterSet &iConfig)
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.