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 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::GsfTrack &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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Types

enum  Constraint { none, vertex }
 

Private Attributes

Constraint constraint_
 
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollectiongsfTrackVtxConstraintTag_
 
TrackProducerAlgorithm< reco::GsfTracktheAlgo
 

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<>
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 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::InputTag clusterRemovalInfo_
 
edm::ParameterSet conf_
 
edm::EDGetTokenT< MeasurementTrackerEventmteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle< TrackCollectionrTracks_
 
edm::EDGetToken src_
 
edm::ESHandle< NavigationSchooltheSchool
 
bool trajectoryInEvent_
 

Detailed Description

Refit GSF Tracks. Based on the TrackRefitter.

Definition at line 14 of file GsfTrackRefitter.h.

Member Enumeration Documentation

Enumerator
none 
vertex 

Definition at line 25 of file GsfTrackRefitter.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 18 of file GsfTrackRefitter.cc.

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

18  :
19  GsfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
20  iConfig.getParameter<bool>("useHitsSplitting")),
21  theAlgo(iConfig)
22 {
23  setConf(iConfig);
24  setSrc( consumes<edm::View<reco::GsfTrack>>(iConfig.getParameter<edm::InputTag>( "src" )),
25  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>( "beamSpot" )),
26  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>( "MeasurementTrackerEvent") ));
27  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
28  std::string constraint_str = iConfig.getParameter<std::string>( "constraint" );
29 
30  if (constraint_str == "") constraint_ = none;
31 // else if (constraint_str == "momentum") constraint_ = momentum;
32  else if (constraint_str == "vertex") {
34  gsfTrackVtxConstraintTag_ = consumes<GsfTrackVtxConstraintAssociationCollection>(iConfig.getParameter<edm::InputTag>("gsfTrackVtxConstraintTag"));
35  } else {
36  edm::LogError("GsfTrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex' or leave it empty";
37  throw cms::Exception("GsfTrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";
38  }
39 
40  //register your products
41  produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
42  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
43  produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
44  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
45  produces<std::vector<Trajectory> >() ;
46  produces<TrajGsfTrackAssociationCollection>();
47 
48 }
T getParameter(std::string const &) const
Constraint constraint_
void setAlias(std::string alias)
set the aliases of produced collections
void setConf(const edm::ParameterSet &conf)
Set parameter set.
GsfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
void setSrc(const edm::EDGetToken &src, const edm::EDGetTokenT< reco::BeamSpot > &bsSrc, const edm::EDGetTokenT< MeasurementTrackerEvent > &mteSrc)
set label of source collection
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollection > gsfTrackVtxConstraintTag_

Member Function Documentation

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

Implementation of produce method.

Implements TrackProducerBase< reco::GsfTrack >.

Definition at line 50 of file GsfTrackRefitter.cc.

References TrackProducerBase< reco::GsfTrack >::bsSrc_, constraint_, MillePedeFileConverter_cfg::e, edm::HandleBase::failedToGet(), edm::EventSetup::get(), 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(), theAlgo, and vertex.

51 {
52  edm::LogInfo("GsfTrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
53  //
54  // create empty output collections
55  //
56  std::unique_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
57  std::unique_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
58  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
59  std::unique_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
60  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
61 
62  //
63  //declare and get stuff to be retrieved from ES
64  //
68  edm::ESHandle<Propagator> thePropagator;
70  // getFromES(setup,theG,theMF,theFitter,thePropagator);
72  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
73 
75  setup.get<TrackerTopologyRcd>().get(httopo);
76 
77  //
78  //declare and get TrackCollection to be retrieved from the event
79  //
80  AlgoProductCollection algoResults;
81  reco::BeamSpot bs;
82  switch(constraint_){
83  case none :
84  {
86  getFromEvt(theEvent,theTCollection,bs);
87  if (theTCollection.failedToGet()){
88  edm::LogError("GsfTrackRefitter")<<"could not get the reco::GsfTrackCollection."; return;}
89  LogDebug("GsfTrackRefitter") << "run the algorithm" << "\n";
90  try {
91  theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection,
92  theFitter.product(), thePropagator.product(),
93  theBuilder.product(), bs, algoResults);
94  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
95  break;
96  }
97  case vertex :
98  {
100  theEvent.getByToken(gsfTrackVtxConstraintTag_, theTCollectionWithConstraint);
101  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
102  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
103  bs = *recoBeamSpotHandle;
104  if (theTCollectionWithConstraint.failedToGet()){
105  edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;}
106  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
107  try {
108  theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint,
109  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
110  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
111  }
112  //default... there cannot be any other possibility due to the check in the ctor
113  }
114 
115  //put everything in th event
116  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(),
117  outputRHColl, outputTColl, outputTEColl, outputGsfTEColl, outputTrajectoryColl, algoResults, theBuilder.product(), bs, httopo.product());
118  LogDebug("GsfTrackRefitter") << "end" << "\n";
119 }
#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:517
typename Base::AlgoProductCollection AlgoProductCollection
Constraint constraint_
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
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
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.
void runWithVertex(const TrackingGeometry *, const MagneticField *, const VtxConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
bool failedToGet() const
Definition: HandleBase.h:78
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:71
TrackProducerAlgorithm< reco::GsfTrack > theAlgo
edm::EDGetTokenT< GsfTrackVtxConstraintAssociationCollection > gsfTrackVtxConstraintTag_
T const * product() const
Definition: ESHandle.h:86
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 GsfTrackRefitter::constraint_
private

Definition at line 28 of file GsfTrackRefitter.h.

Referenced by GsfTrackRefitter(), and produce().

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

Definition at line 29 of file GsfTrackRefitter.h.

Referenced by GsfTrackRefitter(), and produce().

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

Definition at line 24 of file GsfTrackRefitter.h.

Referenced by produce().