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 () noexcept(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

◆ Constraint

Enumerator
none 
momentum 
vertex 
trackParameters 

Definition at line 24 of file TrackRefitter.h.

Constructor & Destructor Documentation

◆ TrackRefitter()

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

Constructor.

Definition at line 16 of file TrackRefitter.cc.

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 }

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.

Member Function Documentation

◆ produce()

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.

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;
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 }

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

Member Data Documentation

◆ constraint_

Constraint TrackRefitter::constraint_
private

Definition at line 25 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().

◆ theAlgo

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

Definition at line 23 of file TrackRefitter.h.

Referenced by produce().

◆ trkconstrcoll_

edm::EDGetToken TrackRefitter::trkconstrcoll_
private

Definition at line 26 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().

SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
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.
TrackRefitter::none
Definition: TrackRefitter.h:24
TrackProducerBase< reco::Track >::getFromEvt
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
KfTrackProducerBase::KfTrackProducerBase
KfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
Definition: KfTrackProducerBase.h:19
TrackProducerAlgorithm::runWithVertex
void runWithVertex(const TrackingGeometry *, const MagneticField *, const VtxConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
TrackRefitter::constraint_
Constraint constraint_
Definition: TrackRefitter.h:25
TrackProducerBase< reco::Track >::setConf
void setConf(const edm::ParameterSet &conf)
Set parameter set.
Definition: TrackProducerBase.h:71
TrackProducerAlgorithm::runWithTrackParameters
void runWithTrackParameters(const TrackingGeometry *, const MagneticField *, const TrackParamConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
TrackProducerBase< reco::Track >::AlgoProductCollection
typename Base::AlgoProductCollection AlgoProductCollection
Definition: TrackProducerBase.h:44
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TrackRefitter::vertex
Definition: TrackRefitter.h:24
cms::cuda::bs
bs
Definition: HistoContainer.h:127
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::Track >::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:528
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
reco::BeamSpot::Unknown
Definition: BeamSpot.h:24
edm::View
Definition: CaloClusterFwd.h:14
edm::HandleBase::failedToGet
bool failedToGet() const
Definition: HandleBase.h:72
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::LogError
Definition: MessageLogger.h:183
TrackRefitter::trackParameters
Definition: TrackRefitter.h:24
TrackProducerBase< reco::Track >::src_
edm::EDGetToken src_
Definition: TrackProducerBase.h:104
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
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
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackProducerBase< reco::Track >::bsSrc_
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
Definition: TrackProducerBase.h:110
TrackRefitter::trkconstrcoll_
edm::EDGetToken trkconstrcoll_
Definition: TrackRefitter.h:26
Exception
Definition: hltDiff.cc:246
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
TrackRefitter::theAlgo
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:23
TrackProducerAlgorithm::runWithMomentum
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)
cms::Exception
Definition: Exception.h:70
TrackRefitter::momentum
Definition: TrackRefitter.h:24
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::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::OwnVector< TrackingRecHit >
edm::ProductLabels
Definition: ProductLabels.h:4
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37