CMS 3D CMS Logo

GsfTrackRefitter.cc
Go to the documentation of this file.
2 // system include files
3 #include <memory>
4 // user include files
6 
8 
14 
17 
19  : GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
20  iConfig.getParameter<bool>("useHitsSplitting")),
21  theAlgo(iConfig) {
22  setConf(iConfig);
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  std::string constraint_str = iConfig.getParameter<std::string>("constraint");
28 
29  if (constraint_str.empty())
30  constraint_ = none;
31  // else if (constraint_str == "momentum") constraint_ = momentum;
32  else if (constraint_str == "vertex") {
34  gsfTrackVtxConstraintTag_ = consumes<GsfTrackVtxConstraintAssociationCollection>(
35  iConfig.getParameter<edm::InputTag>("gsfTrackVtxConstraintTag"));
36  } else {
37  edm::LogError("GsfTrackRefitter") << "constraint: " << constraint_str
38  << " not understood. Set it to 'momentum', 'vertex' or leave it empty";
39  throw cms::Exception("GsfTrackRefitter")
40  << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";
41  }
42 
43  //register your products
44  produces<reco::GsfTrackCollection>().setBranchAlias(alias_ + "GsfTracks");
45  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
46  produces<reco::GsfTrackExtraCollection>().setBranchAlias(alias_ + "GsfTrackExtras");
47  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
48  produces<std::vector<Trajectory>>();
49  produces<TrajGsfTrackAssociationCollection>();
50 }
51 
53  edm::LogInfo("GsfTrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
54  //
55  // create empty output collections
56  //
57  std::unique_ptr<TrackingRecHitCollection> outputRHColl(new TrackingRecHitCollection);
58  std::unique_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
59  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
60  std::unique_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
61  std::unique_ptr<std::vector<Trajectory>> outputTrajectoryColl(new std::vector<Trajectory>);
62 
63  //
64  //declare and get stuff to be retrieved from ES
65  //
69  edm::ESHandle<Propagator> thePropagator;
71  // getFromES(setup,theG,theMF,theFitter,thePropagator);
73  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
74 
76  setup.get<TrackerTopologyRcd>().get(httopo);
77 
78  //
79  //declare and get TrackCollection to be retrieved from the event
80  //
81  AlgoProductCollection algoResults;
83  switch (constraint_) {
84  case none: {
86  getFromEvt(theEvent, theTCollection, bs);
87  if (theTCollection.failedToGet()) {
88  edm::LogError("GsfTrackRefitter") << "could not get the reco::GsfTrackCollection.";
89  return;
90  }
91  LogDebug("GsfTrackRefitter") << "run the algorithm"
92  << "\n";
93  try {
95  theMF.product(),
96  *theTCollection,
97  theFitter.product(),
98  thePropagator.product(),
99  theBuilder.product(),
100  bs,
101  algoResults);
102  } catch (cms::Exception& e) {
103  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack."
104  << "\n"
105  << e << "\n";
106  throw;
107  }
108  break;
109  }
110  case vertex: {
111  edm::Handle<GsfTrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
112  theEvent.getByToken(gsfTrackVtxConstraintTag_, theTCollectionWithConstraint);
113  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
114  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
115  bs = *recoBeamSpotHandle;
116  if (theTCollectionWithConstraint.failedToGet()) {
117  edm::LogError("TrackRefitter") << "could not get TrackVtxConstraintAssociationCollection product.";
118  break;
119  }
120  LogDebug("TrackRefitter") << "run the algorithm"
121  << "\n";
122  try {
124  theMF.product(),
125  *theTCollectionWithConstraint,
126  theFitter.product(),
127  thePropagator.product(),
128  theBuilder.product(),
129  bs,
130  algoResults);
131  } catch (cms::Exception& e) {
132  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack."
133  << "\n"
134  << e << "\n";
135  throw;
136  }
137  }
138  //default... there cannot be any other possibility due to the check in the ctor
139  }
140 
141  //put everything in th event
142  putInEvt(theEvent,
143  thePropagator.product(),
144  theMeasTk.product(),
145  outputRHColl,
146  outputTColl,
147  outputTEColl,
148  outputGsfTEColl,
149  outputTrajectoryColl,
150  algoResults,
151  theBuilder.product(),
152  bs,
153  httopo.product());
154  LogDebug("GsfTrackRefitter") << "end"
155  << "\n";
156 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
TrackProducerBase< reco::GsfTrack >::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::GsfTrack >::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
TrackProducerAlgorithm::runWithVertex
void runWithVertex(const TrackingGeometry *, const MagneticField *, const VtxConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
GsfTrackRefitter::vertex
Definition: GsfTrackRefitter.h:27
GsfTrackRefitter::GsfTrackRefitter
GsfTrackRefitter(const edm::ParameterSet &iConfig)
Constructor.
Definition: GsfTrackRefitter.cc:18
TrackProducerBase< reco::GsfTrack >::setConf
void setConf(const edm::ParameterSet &conf)
Set parameter set.
Definition: TrackProducerBase.h:71
reco::GsfTrackExtraCollection
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
Definition: GsfTrackExtraFwd.h:9
GsfTrackRefitter::theAlgo
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
Definition: GsfTrackRefitter.h:23
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
AlgoProductTraits< reco::GsfTrack >::AlgoProductCollection
std::vector< AlgoProduct > AlgoProductCollection
Definition: AlgoProductTraits.h:20
TrajGsfTrackAssociation.h
GsfTrackRefitter::gsfTrackVtxConstraintTag_
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollection > gsfTrackVtxConstraintTag_
Definition: GsfTrackRefitter.h:30
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TrackerTopology.h
cms::cuda::bs
bs
Definition: HistoContainer.h:127
TrackerTopologyRcd.h
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ESHandle< TrackerGeometry >
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
TrackProducerBase< reco::GsfTrack >::setAlias
void setAlias(std::string alias)
set the aliases of produced collections
Definition: TrackProducerBase.h:83
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
TrajTrackAssociation.h
GsfTrackProducerBase
Definition: GsfTrackProducerBase.h:26
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
GsfTrackProducerBase::putInEvt
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.
Definition: GsfTrackProducerBase.cc:30
GsfTrackRefitter::constraint_
Constraint constraint_
Definition: GsfTrackRefitter.h:29
GsfTrackRefitter::none
Definition: GsfTrackRefitter.h:25
TrackProducerBase< reco::GsfTrack >::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::GsfTrack >::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
GsfTrackRefitter.h
TrackProducerBase< reco::GsfTrack >::bsSrc_
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
Definition: TrackProducerBase.h:110
Trajectory.h
GsfTrackRefitter::produce
void produce(edm::Event &, const edm::EventSetup &) override
Implementation of produce method.
Definition: GsfTrackRefitter.cc:52
reco::GsfTrackCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
Frameworkfwd.h
Exception
Definition: hltDiff.cc:246
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
GsfTrackConstraintAssociation.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
cms::Exception
Definition: Exception.h:70
TrackerTopologyRcd
Definition: TrackerTopologyRcd.h:10
TrackProducerAlgorithm::runWithTrack
void runWithTrack(const TrackingGeometry *, const MagneticField *, const TrackView &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
Run the Final Fit taking Tracks as input (for Refitter)
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::OwnVector< TrackingRecHit >
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37