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 initTrackProducerBase (const edm::ParameterSet &conf, edm::ConsumesCollector cc, const edm::EDGetToken &src)
 Call this method in inheriting class' constructor. More...
 
void setAlias (std::string alias)
 set the aliases of produced collections More...
 
void setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTrackerEvent *measTk, const TrackerTopology *ttopo)
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase () noexcept(false)
 Destructor. More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

enum  Constraint { none, momentum, vertex, trackParameters }
 

Private Attributes

Constraint constraint_
 
TrackProducerAlgorithm< reco::TracktheAlgo
 
edm::EDGetToken trkconstrcoll_
 
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcdttopoToken_
 

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Member Functions inherited from KfTrackProducerBase
void setClusterRemovalInfo (const edm::InputTag &clusterRemovalInfo)
 Sets the information on cluster removal, and turns it on. More...
 
- Protected Attributes inherited from KfTrackProducerBase
edm::InputTag clusterRemovalInfo_
 
bool rekeyClusterRefs_
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::EDGetTokenT< reco::BeamSpotbsSrc_
 
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecordbuilderSrc_
 
edm::ParameterSet conf_
 
edm::ESGetToken< TrajectoryFitter, TrajectoryFitter::RecordfitterSrc_
 
edm::ESGetToken< MeasurementTracker, CkfComponentsRecordmeasTkSrc_
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmfSrc_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
edm::ESGetToken< Propagator, TrackingComponentsRecordpropagatorSrc_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::ESGetToken< NavigationSchool, NavigationSchoolRecordschoolSrc_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackGeomSrc_
 
bool trajectoryInEvent_
 
bool useSchool_
 

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.

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

17  : KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
18  iConfig.getParameter<bool>("useHitsSplitting")),
19  theAlgo(iConfig),
22  iConfig, consumesCollector(), consumes<edm::View<reco::Track>>(iConfig.getParameter<edm::InputTag>("src")));
23  setAlias(iConfig.getParameter<std::string>("@module_label"));
24  std::string constraint_str = iConfig.getParameter<std::string>("constraint");
25  edm::InputTag trkconstrcoll = iConfig.getParameter<edm::InputTag>("srcConstr");
26 
27  if (constraint_str.empty())
28  constraint_ = none;
29  else if (constraint_str == "momentum") {
31  trkconstrcoll_ = consumes<TrackMomConstraintAssociationCollection>(trkconstrcoll);
32  } else if (constraint_str == "vertex") {
34  trkconstrcoll_ = consumes<TrackVtxConstraintAssociationCollection>(trkconstrcoll);
35  } else if (constraint_str == "trackParameters") {
37  trkconstrcoll_ = consumes<TrackParamConstraintAssociationCollection>(trkconstrcoll);
38  } else {
39  edm::LogError("TrackRefitter")
40  << "constraint: " << constraint_str
41  << " not understood. Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
42  throw cms::Exception("TrackRefitter")
43  << "unknown type of contraint! Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
44  }
45 
46  //register your products
47  produces<reco::TrackCollection>().setBranchAlias(alias_ + "Tracks");
48  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
49  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
50  produces<std::vector<Trajectory>>();
51  produces<std::vector<int>>();
52  produces<TrajTrackAssociationCollection>();
53 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetToken trkconstrcoll_
Definition: TrackRefitter.h:26
void initTrackProducerBase(const edm::ParameterSet &conf, edm::ConsumesCollector cc, const edm::EDGetToken &src)
Call this method in inheriting class&#39; constructor.
Log< level::Error, false > LogError
void setAlias(std::string alias)
set the aliases of produced collections
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
Definition: TrackRefitter.h:28
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:23
KfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
Constraint constraint_
Definition: TrackRefitter.h:25

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 55 of file TrackRefitter.cc.

References cms::cuda::bs, TrackProducerBase< reco::Track >::bsSrc_, constraint_, MillePedeFileConverter_cfg::e, edm::HandleBase::failedToGet(), 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_, ttopoToken_, reco::BeamSpot::Unknown, and vertex.

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

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

◆ ttopoToken_

const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> TrackRefitter::ttopoToken_
private

Definition at line 28 of file TrackRefitter.h.

Referenced by produce().