CMS 3D CMS Logo

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

#include <GsfTrackRefitter.h>

Inheritance diagram for GsfTrackRefitter:
GsfTrackProducerBase edm::stream::EDProducer<> TrackProducerBase< reco::GsfTrack > AlgoProductTraits< reco::GsfTrack >

Public Member Functions

 GsfTrackRefitter (const edm::ParameterSet &iConfig)
 Constructor. More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 Implementation of produce method. More...
 
- Public Member Functions inherited from GsfTrackProducerBase
 GsfTrackProducerBase (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::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. More...
 
- Public Member Functions inherited from TrackProducerBase< reco::GsfTrack >
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::GsfTrack &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, vertex }
 

Private Attributes

Constraint constraint_
 
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollectiongsfTrackVtxConstraintTag_
 
TrackProducerAlgorithm< reco::GsfTracktheAlgo
 
edm::ESGetToken< TrackerTopology, TrackerTopologyRcdttopoToken_
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::GsfTrack >
using AlgoProductCollection = typename Base::AlgoProductCollection
 
using Base = AlgoProductTraits< reco::GsfTrack >
 
using TrackCollection = typename Base::TrackCollection
 
using TrackView = typename Base::TrackView
 
- Public Types inherited from AlgoProductTraits< reco::GsfTrack >
using AlgoProductCollection = std::vector< AlgoProduct >
 
using TrackCollection = std::vector< reco::GsfTrack >
 
using TrackView = edm::View< reco::GsfTrack >
 
- 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 GsfTrackProducerBase
void fillMode (reco::GsfTrack &track, const TrajectoryStateOnSurface innertsos, const Propagator &gsfProp, const TransverseImpactPointExtrapolator &tipExtrapolator, TrajectoryStateClosestToBeamLineBuilder &tscblBuilder, const reco::BeamSpot &bs) const
 
void fillStates (TrajectoryStateOnSurface tsos, std::vector< reco::GsfComponent5D > &states) const
 
- Protected Attributes inherited from TrackProducerBase< reco::GsfTrack >
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 GSF Tracks. Based on the TrackRefitter.

Definition at line 14 of file GsfTrackRefitter.h.

Member Enumeration Documentation

◆ Constraint

Enumerator
none 
vertex 

Definition at line 24 of file GsfTrackRefitter.h.

24  {
25  none,
26  // momentum,
27  vertex
28  };

Constructor & Destructor Documentation

◆ GsfTrackRefitter()

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

Constructor.

Definition at line 18 of file GsfTrackRefitter.cc.

References TrackProducerBase< reco::GsfTrack >::alias_, constraint_, deDxTools::esConsumes(), Exception, edm::ParameterSet::getParameter(), gsfTrackVtxConstraintTag_, TrackProducerBase< reco::GsfTrack >::initTrackProducerBase(), none, TrackProducerBase< reco::GsfTrack >::setAlias(), AlCaHLTBitMon_QueryRunRegistry::string, ttopoToken_, and vertex.

19  : GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
20  iConfig.getParameter<bool>("useHitsSplitting")),
21  theAlgo(iConfig) {
23  iConfig, consumesCollector(), consumes<edm::View<reco::GsfTrack>>(iConfig.getParameter<edm::InputTag>("src")));
24  setAlias(iConfig.getParameter<std::string>("@module_label"));
25  std::string constraint_str = iConfig.getParameter<std::string>("constraint");
26 
27  if (constraint_str.empty())
28  constraint_ = none;
29  // else if (constraint_str == "momentum") constraint_ = momentum;
30  else if (constraint_str == "vertex") {
32  gsfTrackVtxConstraintTag_ = consumes<GsfTrackVtxConstraintAssociationCollection>(
33  iConfig.getParameter<edm::InputTag>("gsfTrackVtxConstraintTag"));
34  } else {
35  edm::LogError("GsfTrackRefitter") << "constraint: " << constraint_str
36  << " not understood. Set it to 'momentum', 'vertex' or leave it empty";
37  throw cms::Exception("GsfTrackRefitter")
38  << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";
39  }
40 
41  //register your products
42  produces<reco::GsfTrackCollection>().setBranchAlias(alias_ + "GsfTracks");
43  produces<reco::TrackExtraCollection>().setBranchAlias(alias_ + "TrackExtras");
44  produces<reco::GsfTrackExtraCollection>().setBranchAlias(alias_ + "GsfTrackExtras");
45  produces<TrackingRecHitCollection>().setBranchAlias(alias_ + "RecHits");
46  produces<std::vector<Trajectory>>();
47  produces<TrajGsfTrackAssociationCollection>();
48 
50 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Constraint constraint_
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
GsfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollection > gsfTrackVtxConstraintTag_

Member Function Documentation

◆ produce()

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

Implementation of produce method.

Implements TrackProducerBase< reco::GsfTrack >.

Definition at line 52 of file GsfTrackRefitter.cc.

References cms::cuda::bs, TrackProducerBase< reco::GsfTrack >::bsSrc_, constraint_, MillePedeFileConverter_cfg::e, edm::HandleBase::failedToGet(), edm::Event::getByToken(), TrackProducerBase< reco::GsfTrack >::getFromES(), TrackProducerBase< reco::GsfTrack >::getFromEvt(), gsfTrackVtxConstraintTag_, edm::EventBase::id(), LogDebug, none, edm::ESHandle< T >::product(), GsfTrackProducerBase::putInEvt(), TrackProducerAlgorithm< T >::runWithTrack(), TrackProducerAlgorithm< T >::runWithVertex(), singleTopDQM_cfi::setup, theAlgo, ttopoToken_, and vertex.

52  {
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 
77  //
78  //declare and get TrackCollection to be retrieved from the event
79  //
80  AlgoProductCollection algoResults;
82  switch (constraint_) {
83  case none: {
85  getFromEvt(theEvent, theTCollection, bs);
86  if (theTCollection.failedToGet()) {
87  edm::LogError("GsfTrackRefitter") << "could not get the reco::GsfTrackCollection.";
88  return;
89  }
90  LogDebug("GsfTrackRefitter") << "run the algorithm"
91  << "\n";
92  try {
94  theMF.product(),
95  *theTCollection,
96  theFitter.product(),
97  thePropagator.product(),
98  theBuilder.product(),
99  bs,
100  algoResults);
101  } catch (cms::Exception& e) {
102  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack."
103  << "\n"
104  << e << "\n";
105  throw;
106  }
107  break;
108  }
109  case vertex: {
110  edm::Handle<GsfTrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
111  theEvent.getByToken(gsfTrackVtxConstraintTag_, theTCollectionWithConstraint);
112  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
113  theEvent.getByToken(bsSrc_, recoBeamSpotHandle);
114  bs = *recoBeamSpotHandle;
115  if (theTCollectionWithConstraint.failedToGet()) {
116  edm::LogError("TrackRefitter") << "could not get TrackVtxConstraintAssociationCollection product.";
117  break;
118  }
119  LogDebug("TrackRefitter") << "run the algorithm"
120  << "\n";
121  try {
123  theMF.product(),
124  *theTCollectionWithConstraint,
125  theFitter.product(),
126  thePropagator.product(),
127  theBuilder.product(),
128  bs,
129  algoResults);
130  } catch (cms::Exception& e) {
131  edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack."
132  << "\n"
133  << e << "\n";
134  throw;
135  }
136  }
137  //default... there cannot be any other possibility due to the check in the ctor
138  }
139 
140  //put everything in th event
141  putInEvt(theEvent,
142  thePropagator.product(),
143  theMeasTk.product(),
144  outputRHColl,
145  outputTColl,
146  outputTEColl,
147  outputGsfTEColl,
148  outputTrajectoryColl,
149  algoResults,
150  theBuilder.product(),
151  bs,
152  httopo.product());
153  LogDebug("GsfTrackRefitter") << "end"
154  << "\n";
155 }
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
typename Base::AlgoProductCollection AlgoProductCollection
Constraint constraint_
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:540
Log< level::Error, false > LogError
bool failedToGet() const
Definition: HandleBase.h:72
T const * product() const
Definition: ESHandle.h:86
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > ttopoToken_
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)
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
edm::EventID id() const
Definition: EventBase.h:63
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.
Log< level::Info, false > LogInfo
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
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollection > gsfTrackVtxConstraintTag_
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 GsfTrackRefitter::constraint_
private

Definition at line 29 of file GsfTrackRefitter.h.

Referenced by GsfTrackRefitter(), and produce().

◆ gsfTrackVtxConstraintTag_

edm::EDGetTokenT<GsfTrackVtxConstraintAssociationCollection> GsfTrackRefitter::gsfTrackVtxConstraintTag_
private

Definition at line 30 of file GsfTrackRefitter.h.

Referenced by GsfTrackRefitter(), and produce().

◆ theAlgo

TrackProducerAlgorithm<reco::GsfTrack> GsfTrackRefitter::theAlgo
private

Definition at line 23 of file GsfTrackRefitter.h.

Referenced by produce().

◆ ttopoToken_

edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> GsfTrackRefitter::ttopoToken_
private

Definition at line 31 of file GsfTrackRefitter.h.

Referenced by GsfTrackRefitter(), and produce().