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 > edm::stream::EDProducerBase AlgoProductTraits< reco::Track > edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual 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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- 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 25 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_, edm::EDConsumerBase::consumes(), 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.

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

50 {
51  LogDebug("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
52  //
53  // create empty output collections
54  //
55  std::unique_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
56  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
57  std::unique_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
58  std::unique_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
59  std::unique_ptr<std::vector<int> > outputIndecesInputColl(new std::vector<int>);
60 
61  //
62  //declare and get stuff to be retrieved from ES
63  //
67  edm::ESHandle<Propagator> thePropagator;
70  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
71 
73  setup.get<TrackerTopologyRcd>().get(httopo);
74 
75  //
76  //declare and get TrackCollection to be retrieved from the event
77  //
78  AlgoProductCollection algoResults;
79  reco::BeamSpot bs;
80  switch(constraint_){
81  case none :
82  {
83  edm::Handle<edm::View<reco::Track>> theTCollection;
84  getFromEvt(theEvent,theTCollection,bs);
85 
86  LogDebug("TrackRefitter") << "TrackRefitter::produce(none):Number of Trajectories:" << (*theTCollection).size();
87 
88  if (bs.position()==math::XYZPoint(0.,0.,0.) && bs.type() == reco::BeamSpot::Unknown) {
89  edm::LogError("TrackRefitter") << " BeamSpot is (0,0,0), it is probably because is not valid in the event"; break; }
90 
91  if (theTCollection.failedToGet()){
93  labelsForToken(src_, labels);
94  edm::LogError("TrackRefitter")<<"could not get the reco::TrackCollection." << labels.module; break;}
95  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
96 
97  try {
98  theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection,
99  theFitter.product(), thePropagator.product(),
100  theBuilder.product(), bs, algoResults);
101  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
102  break;
103  }
104  case momentum :
105  {
106  edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint;
107  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
108 
109 
110  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
111  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
112  if (!recoBeamSpotHandle.isValid()) break;
113  bs = *recoBeamSpotHandle;
114  if (theTCollectionWithConstraint.failedToGet()){
115  //edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product.";
116  break;}
117  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
118  try {
119  theAlgo.runWithMomentum(theG.product(), theMF.product(), *theTCollectionWithConstraint,
120  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
121  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
122  break;
123  }
124  case vertex :
125  {
126  edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
127  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
128  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
129  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
130  if (!recoBeamSpotHandle.isValid()) break;
131  bs = *recoBeamSpotHandle;
132  if (theTCollectionWithConstraint.failedToGet()){
133  edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;}
134  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
135  try {
136  theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint,
137  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
138  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
139  }
140  case trackParameters :
141  {
142  edm::Handle<TrackParamConstraintAssociationCollection> theTCollectionWithConstraint;
143  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
144  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
145  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
146  if (!recoBeamSpotHandle.isValid()) break;
147  bs = *recoBeamSpotHandle;
148  if (theTCollectionWithConstraint.failedToGet()){
149  //edm::LogError("TrackRefitter")<<"could not get TrackParamConstraintAssociationCollection product.";
150  break;}
151  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
152  try {
153  theAlgo.runWithTrackParameters(theG.product(), theMF.product(), *theTCollectionWithConstraint,
154  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
155  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
156  }
157  //default... there cannot be any other possibility due to the check in the ctor
158  }
159 
160 
161  //put everything in th event
162  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, outputIndecesInputColl, algoResults,theBuilder.product(), httopo.product());
163  LogDebug("TrackRefitter") << "end" << "\n";
164 }
#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:460
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:27
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:24
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:74
char const * module
Definition: ProductLabels.h:5
Constraint constraint_
Definition: TrackRefitter.h:26
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
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
const T & get() const
Definition: EventSetup.h:56
void runWithTrackParameters(const TrackingGeometry *, const MagneticField *, const TrackParamConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
edm::EventID id() const
Definition: EventBase.h:60
const Point & position() const
position
Definition: BeamSpot.h:62
T const * product() const
Definition: ESHandle.h:86
BeamType type() const
return beam type
Definition: BeamSpot.h:129
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 26 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().

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

Definition at line 24 of file TrackRefitter.h.

Referenced by produce().

edm::EDGetToken TrackRefitter::trkconstrcoll_
private

Definition at line 27 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().