CMS 3D CMS Logo

GsfTrackProducer.cc
Go to the documentation of this file.
14 
16 public:
17  explicit GsfTrackProducer(const edm::ParameterSet& iConfig);
18  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
19 
20  void produce(edm::Event&, const edm::EventSetup&) override;
21 
22 private:
24 
26 };
27 
29  : GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
30  iConfig.getParameter<bool>("useHitsSplitting")),
31  theAlgo(iConfig),
32  theTopoToken(esConsumes()) {
34  iConfig, consumesCollector(), consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>("src")));
35  setAlias(iConfig.getParameter<std::string>("@module_label"));
36  // string a = alias_;
37  // a.erase(a.size()-6,a.size());
38  //register your products
39  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
40  produces<reco::GsfTrackExtraCollection>().setBranchAlias(alias_ + "GsfTrackExtras");
41  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
42  // GsfTrackCollection refers to TrackingRechit, TrackExtra, and
43  // GsfTrackExtra collections, need to declare its production after
44  // them to work around a rare race condition in framework scheduling
45  produces<reco::GsfTrackCollection>().setBranchAlias(alias_ + "GsfTracks");
46  produces<std::vector<Trajectory> >();
47  produces<TrajGsfTrackAssociationCollection>();
48 }
49 
51  edm::LogInfo("GsfTrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
52  //
53  // create empty output collections
54  //
55  std::unique_ptr<TrackingRecHitCollection> outputRHColl(new TrackingRecHitCollection);
56  std::unique_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
57  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
58  std::unique_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
59  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
60 
61  //
62  //declare and get stuff to be retrieved from ES
63  //
67  edm::ESHandle<Propagator> thePropagator;
70  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
71 
72  TrackerTopology const& ttopo = setup.getData(theTopoToken);
73 
74  //
75  //declare and get TrackColection to be retrieved from the event
76  //
77  AlgoProductCollection algoResults;
79  try {
81  getFromEvt(theEvent, theTCCollection, bs);
82 
83  //
84  //run the algorithm
85  //
86  LogDebug("GsfTrackProducer") << "run the algorithm"
87  << "\n";
89  theMF.product(),
90  *theTCCollection,
91  theFitter.product(),
92  thePropagator.product(),
93  theBuilder.product(),
94  bs,
95  algoResults);
96  } catch (cms::Exception& e) {
97  edm::LogInfo("GsfTrackProducer") << "cms::Exception caught!!!"
98  << "\n"
99  << e << "\n";
100  throw;
101  }
102  //
103  //put everything in the event
104  putInEvt(theEvent,
105  thePropagator.product(),
106  theMeasTk.product(),
107  outputRHColl,
108  outputTColl,
109  outputTEColl,
110  outputGsfTEColl,
111  outputTrajectoryColl,
112  algoResults,
113  theBuilder.product(),
114  bs,
115  &ttopo);
116  LogDebug("GsfTrackProducer") << "end"
117  << "\n";
118 }
119 
122 
123  desc.add<edm::InputTag>("src", edm::InputTag("CkfElectronCandidates"));
124  desc.add<edm::InputTag>("beamSpot", edm::InputTag("offlineBeamSpot"));
125  desc.add<std::string>("producer", std::string(""));
126  desc.add<std::string>("Fitter", std::string("GsfElectronFittingSmoother"));
127  desc.add<bool>("useHitsSplitting", false);
128  desc.add<bool>("TrajectoryInEvent", false);
129  desc.add<std::string>("TTRHBuilder", std::string("WithTrackAngle"));
130  desc.add<std::string>("Propagator", std::string("fwdElectronPropagator"));
131  desc.add<std::string>("NavigationSchool", std::string("SimpleNavigationSchool"));
132  desc.add<std::string>("MeasurementTracker", std::string(""));
133  desc.add<edm::InputTag>("MeasurementTrackerEvent", edm::InputTag("MeasurementTrackerEvent"));
134  desc.add<bool>("GeometricInnerState", false);
135  desc.add<std::string>("AlgorithmName", std::string("gsf"));
136 
137  descriptions.add("gsfTrackProducer", desc);
138 }
139 
void produce(edm::Event &, const edm::EventSetup &) override
Method where the procduction take place. To be implemented in concrete classes.
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
void initTrackProducerBase(const edm::ParameterSet &conf, edm::ConsumesCollector cc, const edm::EDGetToken &src)
Call this method in inheriting class&#39; constructor.
void setAlias(std::string alias)
set the aliases of produced collections
T const * product() const
Definition: ESHandle.h:86
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTopoToken
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
edm::EventID id() const
Definition: EventBase.h:59
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.
Log< level::Info, false > LogInfo
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< AlgoProduct > AlgoProductCollection
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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)
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.
#define LogDebug(id)