CMS 3D CMS Logo

TrackProducer.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
10 
12 
14 
17 
19  : KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
20  iConfig.getParameter<bool>("useHitsSplitting")),
21  theAlgo(iConfig) {
22  setConf(iConfig);
23  setSrc(consumes<TrackCandidateCollection>(iConfig.getParameter<edm::InputTag>("src")),
24  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot")),
25  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent")));
26  setAlias(iConfig.getParameter<std::string>("@module_label"));
27 
28  if (iConfig.exists("clusterRemovalInfo")) {
29  edm::InputTag tag = iConfig.getParameter<edm::InputTag>("clusterRemovalInfo");
30  if (!(tag == edm::InputTag())) {
32  }
33  }
34 
35  //register your products
36  produces<reco::TrackCollection>().setBranchAlias(alias_ + "Tracks");
37  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
38  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
39  produces<std::vector<Trajectory> >();
40  produces<std::vector<int> >();
41  produces<TrajTrackAssociationCollection>();
42 }
43 
45  LogDebug("TrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
46  //
47  // create empty output collections
48  //
49  std::unique_ptr<TrackingRecHitCollection> outputRHColl(new TrackingRecHitCollection);
50  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
51  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
52  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
53  std::unique_ptr<std::vector<int> > outputIndecesInputColl(new std::vector<int>);
54 
55  //
56  //declare and get stuff to be retrieved from ES
57  //
61  edm::ESHandle<Propagator> thePropagator;
64  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
65 
67  setup.get<TrackerTopologyRcd>().get(httopo);
68 
69  //
70  //declare and get TrackColection to be retrieved from the event
71  //
72  AlgoProductCollection algoResults;
75  getFromEvt(theEvent, theTCCollection, bs);
76  //protect against missing product
77  if (theTCCollection.failedToGet()) {
78  edm::LogError("TrackProducer") << "could not get the TrackCandidateCollection.";
79  } else {
80  LogDebug("TrackProducer") << "run the algorithm"
81  << "\n";
82  try {
84  theMF.product(),
85  *theTCCollection,
86  theFitter.product(),
87  thePropagator.product(),
88  theBuilder.product(),
89  bs,
90  algoResults);
91  } catch (cms::Exception& e) {
92  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithCandidate."
93  << "\n"
94  << e << "\n";
95  throw;
96  }
97  }
98 
99  //put everything in the event
100  putInEvt(theEvent,
101  thePropagator.product(),
102  theMeasTk.product(),
103  outputRHColl,
104  outputTColl,
105  outputTEColl,
106  outputTrajectoryColl,
107  outputIndecesInputColl,
108  algoResults,
109  theBuilder.product(),
110  httopo.product());
111  LogDebug("TrackProducer") << "end"
112  << "\n";
113 }
114 
115 std::vector<reco::TransientTrack> TrackProducer::getTransient(edm::Event& theEvent, const edm::EventSetup& setup) {
116  LogDebug("TrackProducer") << "Analyzing event number: " << theEvent.id() << "\n";
117  //
118  // create empty output collections
119  //
120  std::vector<reco::TransientTrack> ttks;
121 
122  //
123  //declare and get stuff to be retrieved from ES
124  //
128  edm::ESHandle<Propagator> thePropagator;
131  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
132 
133  //
134  //declare and get TrackColection to be retrieved from the event
135  //
136  AlgoProductCollection algoResults;
139  getFromEvt(theEvent, theTCCollection, bs);
140  //protect against missing product
141  if (theTCCollection.failedToGet()) {
142  edm::LogError("TrackProducer") << "could not get the TrackCandidateCollection.";
143  } else {
144  LogDebug("TrackProducer") << "run the algorithm"
145  << "\n";
146  try {
148  theMF.product(),
149  *theTCCollection,
150  theFitter.product(),
151  thePropagator.product(),
152  theBuilder.product(),
153  bs,
154  algoResults);
155  } catch (cms::Exception& e) {
156  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithCandidate."
157  << "\n"
158  << e << "\n";
159  throw;
160  }
161  }
162  ttks.reserve(algoResults.size());
163  for (auto& prod : algoResults) {
164  ttks.push_back(reco::TransientTrack(*(prod.track), thePropagator.product()->magneticField()));
165  }
166 
167  LogDebug("TrackProducer") << "end"
168  << "\n";
169 
170  return ttks;
171 }
TrackProducer.h
Propagator.h
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrackProducerBase< reco::Track >::getFromES
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.
TrackProducerBase< reco::Track >::getFromEvt
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
electrons_cff.bool
bool
Definition: electrons_cff.py:393
MessageLogger.h
TrackerGeometry.h
TrackProducerBase< reco::Track >::setConf
void setConf(const edm::ParameterSet &conf)
Set parameter set.
Definition: TrackProducerBase.h:71
TrackProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Implementation of produce method.
Definition: TrackProducer.cc:44
TrackProducer::getTransient
std::vector< reco::TransientTrack > getTransient(edm::Event &, const edm::EventSetup &)
Get Transient Tracks.
Definition: TrackProducer.cc:115
Propagator::magneticField
virtual const MagneticField * magneticField() const =0
edm::Handle< TrackCandidateCollection >
AlgoProductTraits< reco::Track >::AlgoProductCollection
std::vector< AlgoProduct > AlgoProductCollection
Definition: AlgoProductTraits.h:20
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
KfTrackProducerBase
Definition: KfTrackProducerBase.h:16
MakerMacros.h
TrackerTopology.h
cms::cuda::bs
bs
Definition: HistoContainer.h:127
TrackerTopologyRcd.h
TrackProducerBase< reco::Track >::setClusterRemovalInfo
void setClusterRemovalInfo(const edm::InputTag &clusterRemovalInfo)
Sets the information on cluster removal, and turns it on.
Definition: TrackProducerBase.h:89
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
TrackProducerAlgorithm::runWithCandidate
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.
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ESHandle< TrackerGeometry >
TrackProducer::TrackProducer
TrackProducer(const edm::ParameterSet &iConfig)
Constructor.
Definition: TrackProducer.cc:18
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
TrackProducerBase< reco::Track >::setAlias
void setAlias(std::string alias)
set the aliases of produced collections
Definition: TrackProducerBase.h:83
TrajTrackAssociation.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
KfTrackProducerBase::putInEvt
virtual void putInEvt(edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::unique_ptr< TrackingRecHitCollection > &, std::unique_ptr< reco::TrackCollection > &, std::unique_ptr< reco::TrackExtraCollection > &, std::unique_ptr< std::vector< Trajectory > > &, std::unique_ptr< std::vector< int > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, const TrackerTopology *ttopo, int BeforeOrAfter=0)
Put produced collections in the event.
Definition: KfTrackProducerBase.cc:21
TrackProducerBase< reco::Track >::alias_
std::string alias_
Definition: TrackProducerBase.h:107
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
TrackProducerBase< reco::Track >::setSrc
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection
Definition: TrackProducerBase.h:74
TrackProducer::theAlgo
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackProducer.h:36
Trajectory.h
reco::TransientTrack
Definition: TransientTrack.h:19
Frameworkfwd.h
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cms::Exception
Definition: Exception.h:70
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::OwnVector< TrackingRecHit >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37