CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Attributes
TrackRefitter Class Reference

#include <TrackRefitter.h>

Inheritance diagram for TrackRefitter:
KfTrackProducerBase edm::stream::EDProducer<> TrackProducerBase< reco::Track > AlgoProductTraits< reco::Track >

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 Implementation of produce method. More...
 
 TrackRefitter (const edm::ParameterSet &iConfig)
 Constructor. More...
 
- Public Member Functions inherited from KfTrackProducerBase
 KfTrackProducerBase (bool trajectoryInEvent, bool split)
 Constructor. More...
 
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. More...
 
- Public Member Functions inherited from TrackProducerBase< reco::Track >
const edm::ParameterSetgetConf () const
 
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. More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
 Get TrackCandidateCollection from the Event (needed by TrackProducer) More...
 
virtual void getFromEvt (edm::Event &, edm::Handle< TrackView > &, reco::BeamSpot &)
 Get TrackCollection from the Event (needed by TrackRefitter) More...
 
void setAlias (std::string alias)
 set the aliases of produced collections More...
 
void setClusterRemovalInfo (const edm::InputTag &clusterRemovalInfo)
 Sets the information on cluster removal, and turns it on. More...
 
void setConf (const edm::ParameterSet &conf)
 Set parameter set. More...
 
void setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
 
void setSrc (const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
 set label of source collection More...
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase ()(false)
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Types

enum  Constraint { none, momentum, vertex, trackParameters }
 

Private Attributes

Constraint constraint_
 
TrackProducerAlgorithm< reco::TracktheAlgo
 
edm::EDGetToken trkconstrcoll_
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::Track >
 
using TrackCollection = typename Base::TrackCollection
 
using TrackView = typename Base::TrackView
 
- Public Types inherited from AlgoProductTraits< reco::Track >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::Track >
 
using TrackView = edm::View< reco::Track >
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::InputTag clusterRemovalInfo_
 
edm::ParameterSet conf_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
bool trajectoryInEvent_
 

Detailed Description

Refit Tracks: Produce Tracks from TrackCollection. It performs a new final fit on a TrackCollection.

Author
cerati

Definition at line 14 of file TrackRefitter.h.

Member Enumeration Documentation

Enumerator
none 
momentum 
vertex 
trackParameters 

Definition at line 24 of file TrackRefitter.h.

Constructor & Destructor Documentation

TrackRefitter::TrackRefitter ( const edm::ParameterSet iConfig)
explicit

Constructor.

Definition at line 16 of file TrackRefitter.cc.

References TrackProducerBase< reco::Track >::alias_, constraint_, Exception, edm::ParameterSet::getParameter(), momentum, none, TrackProducerBase< reco::Track >::setAlias(), TrackProducerBase< reco::Track >::setConf(), TrackProducerBase< reco::Track >::setSrc(), AlCaHLTBitMon_QueryRunRegistry::string, trackParameters, trkconstrcoll_, and vertex.

17  : KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
18  iConfig.getParameter<bool>("useHitsSplitting")),
19  theAlgo(iConfig) {
20  setConf(iConfig);
21  setSrc(consumes<edm::View<reco::Track>>(iConfig.getParameter<edm::InputTag>("src")),
22  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot")),
23  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent")));
24  setAlias(iConfig.getParameter<std::string>("@module_label"));
25  std::string constraint_str = iConfig.getParameter<std::string>("constraint");
26  edm::InputTag trkconstrcoll = iConfig.getParameter<edm::InputTag>("srcConstr");
27 
28  if (constraint_str.empty())
29  constraint_ = none;
30  else if (constraint_str == "momentum") {
32  trkconstrcoll_ = consumes<TrackMomConstraintAssociationCollection>(trkconstrcoll);
33  } else if (constraint_str == "vertex") {
35  trkconstrcoll_ = consumes<TrackVtxConstraintAssociationCollection>(trkconstrcoll);
36  } else if (constraint_str == "trackParameters") {
38  trkconstrcoll_ = consumes<TrackParamConstraintAssociationCollection>(trkconstrcoll);
39  } else {
40  edm::LogError("TrackRefitter")
41  << "constraint: " << constraint_str
42  << " not understood. Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
43  throw cms::Exception("TrackRefitter")
44  << "unknown type of contraint! Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
45  }
46 
47  //register your products
48  produces<reco::TrackCollection>().setBranchAlias(alias_ + "Tracks");
49  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
50  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
51  produces<std::vector<Trajectory>>();
52  produces<std::vector<int>>();
53  produces<TrajTrackAssociationCollection>();
54 }
T getParameter(std::string const &) const
edm::EDGetToken trkconstrcoll_
Definition: TrackRefitter.h:26
void setAlias(std::string alias)
set the aliases of produced collections
void setConf(const edm::ParameterSet &conf)
Set parameter set.
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:23
KfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
Constraint constraint_
Definition: TrackRefitter.h:25
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection

Member Function Documentation

void TrackRefitter::produce ( edm::Event theEvent,
const edm::EventSetup setup 
)
overridevirtual

Implementation of produce method.

Implements TrackProducerBase< reco::Track >.

Definition at line 56 of file TrackRefitter.cc.

References TrackProducerBase< reco::Track >::bsSrc_, constraint_, MillePedeFileConverter_cfg::e, edm::HandleBase::failedToGet(), edm::EventSetup::get(), edm::Event::getByToken(), TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), edm::EventBase::id(), edm::HandleBase::isValid(), SummaryClient_cfi::labels, LogDebug, edm::ProductLabels::module, momentum, none, reco::BeamSpot::position(), edm::ESHandle< T >::product(), KfTrackProducerBase::putInEvt(), TrackProducerAlgorithm< T >::runWithMomentum(), TrackProducerAlgorithm< T >::runWithTrack(), TrackProducerAlgorithm< T >::runWithTrackParameters(), TrackProducerAlgorithm< T >::runWithVertex(), TrackProducerBase< reco::Track >::src_, theAlgo, trackParameters, trkconstrcoll_, reco::BeamSpot::type(), reco::BeamSpot::Unknown, and vertex.

56  {
57  LogDebug("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
58  //
59  // create empty output collections
60  //
61  std::unique_ptr<TrackingRecHitCollection> outputRHColl(new TrackingRecHitCollection);
62  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
63  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
64  std::unique_ptr<std::vector<Trajectory>> outputTrajectoryColl(new std::vector<Trajectory>);
65  std::unique_ptr<std::vector<int>> outputIndecesInputColl(new std::vector<int>);
66 
67  //
68  //declare and get stuff to be retrieved from ES
69  //
73  edm::ESHandle<Propagator> thePropagator;
76  getFromES(setup, theG, theMF, theFitter, thePropagator, theMeasTk, theBuilder);
77 
79  setup.get<TrackerTopologyRcd>().get(httopo);
80 
81  //
82  //declare and get TrackCollection to be retrieved from the event
83  //
84  AlgoProductCollection algoResults;
85  reco::BeamSpot bs;
86  switch (constraint_) {
87  case none: {
88  edm::Handle<edm::View<reco::Track>> theTCollection;
89  getFromEvt(theEvent, theTCollection, bs);
90 
91  LogDebug("TrackRefitter") << "TrackRefitter::produce(none):Number of Trajectories:" << (*theTCollection).size();
92 
93  if (bs.position() == math::XYZPoint(0., 0., 0.) && bs.type() == reco::BeamSpot::Unknown) {
94  edm::LogError("TrackRefitter") << " BeamSpot is (0,0,0), it is probably because is not valid in the event";
95  break;
96  }
97 
98  if (theTCollection.failedToGet()) {
100  labelsForToken(src_, labels);
101  edm::LogError("TrackRefitter") << "could not get the reco::TrackCollection." << labels.module;
102  break;
103  }
104  LogDebug("TrackRefitter") << "run the algorithm"
105  << "\n";
106 
107  try {
109  theMF.product(),
110  *theTCollection,
111  theFitter.product(),
112  thePropagator.product(),
113  theBuilder.product(),
114  bs,
115  algoResults);
116  } catch (cms::Exception &e) {
117  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack."
118  << "\n"
119  << e << "\n";
120  throw;
121  }
122  break;
123  }
124  case momentum: {
125  edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint;
126  theEvent.getByToken(trkconstrcoll_, theTCollectionWithConstraint);
127 
128  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
129  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
130  if (!recoBeamSpotHandle.isValid())
131  break;
132  bs = *recoBeamSpotHandle;
133  if (theTCollectionWithConstraint.failedToGet()) {
134  //edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product.";
135  break;
136  }
137  LogDebug("TrackRefitter") << "run the algorithm"
138  << "\n";
139  try {
141  theMF.product(),
142  *theTCollectionWithConstraint,
143  theFitter.product(),
144  thePropagator.product(),
145  theBuilder.product(),
146  bs,
147  algoResults);
148  } catch (cms::Exception &e) {
149  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithMomentum."
150  << "\n"
151  << e << "\n";
152  throw;
153  }
154  break;
155  }
156  case vertex: {
157  edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
158  theEvent.getByToken(trkconstrcoll_, theTCollectionWithConstraint);
159  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
160  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
161  if (!recoBeamSpotHandle.isValid())
162  break;
163  bs = *recoBeamSpotHandle;
164  if (theTCollectionWithConstraint.failedToGet()) {
165  edm::LogError("TrackRefitter") << "could not get TrackVtxConstraintAssociationCollection product.";
166  break;
167  }
168  LogDebug("TrackRefitter") << "run the algorithm"
169  << "\n";
170  try {
172  theMF.product(),
173  *theTCollectionWithConstraint,
174  theFitter.product(),
175  thePropagator.product(),
176  theBuilder.product(),
177  bs,
178  algoResults);
179  } catch (cms::Exception &e) {
180  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithVertex."
181  << "\n"
182  << e << "\n";
183  throw;
184  }
185  break;
186  }
187  case trackParameters: {
188  edm::Handle<TrackParamConstraintAssociationCollection> theTCollectionWithConstraint;
189  theEvent.getByToken(trkconstrcoll_, theTCollectionWithConstraint);
190  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
191  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
192  if (!recoBeamSpotHandle.isValid())
193  break;
194  bs = *recoBeamSpotHandle;
195  if (theTCollectionWithConstraint.failedToGet()) {
196  //edm::LogError("TrackRefitter")<<"could not get TrackParamConstraintAssociationCollection product.";
197  break;
198  }
199  LogDebug("TrackRefitter") << "run the algorithm"
200  << "\n";
201  try {
203  theMF.product(),
204  *theTCollectionWithConstraint,
205  theFitter.product(),
206  thePropagator.product(),
207  theBuilder.product(),
208  bs,
209  algoResults);
210  } catch (cms::Exception &e) {
211  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrackParameters."
212  << "\n"
213  << e << "\n";
214  throw;
215  }
216  }
217  //default... there cannot be any other possibility due to the check in the ctor
218  }
219 
220  //put everything in th event
221  putInEvt(theEvent,
222  thePropagator.product(),
223  theMeasTk.product(),
224  outputRHColl,
225  outputTColl,
226  outputTEColl,
227  outputTrajectoryColl,
228  outputIndecesInputColl,
229  algoResults,
230  theBuilder.product(),
231  httopo.product());
232  LogDebug("TrackRefitter") << "end"
233  << "\n";
234 }
#define LogDebug(id)
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
typename Base::AlgoProductCollection AlgoProductCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
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.
edm::EDGetToken trkconstrcoll_
Definition: TrackRefitter.h:26
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:23
void runWithMomentum(const TrackingGeometry *, const MagneticField *, const TrackMomConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
Run the Final Fit taking TrackMomConstraintAssociation as input (Refitter with momentum constraint) ...
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)
bool isValid() const
Definition: HandleBase.h:70
char const * module
Definition: ProductLabels.h:5
Constraint constraint_
Definition: TrackRefitter.h:25
void runWithVertex(const TrackingGeometry *, const MagneticField *, const VtxConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
bool failedToGet() const
Definition: HandleBase.h:72
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void runWithTrackParameters(const TrackingGeometry *, const MagneticField *, const TrackParamConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:73
const Point & position() const
position
Definition: BeamSpot.h:59
T const * product() const
Definition: ESHandle.h:86
BeamType type() const
return beam type
Definition: BeamSpot.h:122
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.

Member Data Documentation

Constraint TrackRefitter::constraint_
private

Definition at line 25 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().

TrackProducerAlgorithm<reco::Track> TrackRefitter::theAlgo
private

Definition at line 23 of file TrackRefitter.h.

Referenced by produce().

edm::EDGetToken TrackRefitter::trkconstrcoll_
private

Definition at line 26 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().