CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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::auto_ptr< TrackingRecHitCollection > &, std::auto_ptr< reco::TrackCollection > &, std::auto_ptr< reco::TrackExtraCollection > &, std::auto_ptr< std::vector< Trajectory > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, 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< TrackCollection > &, 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)
 
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 ()
 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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

enum  Constraint { none, momentum, vertex, trackParameters }
 

Private Attributes

Constraint constraint_
 
TrackProducerAlgorithm
< reco::Track
theAlgo
 
edm::EDGetToken trkconstrcoll_
 

Additional Inherited Members

- Public Types inherited from TrackProducerBase< reco::Track >
typedef std::pair< Trajectory
*, std::pair< reco::Track
*, PropagationDirection > > 
AlgoProduct
 
typedef std::vector< AlgoProductAlgoProductCollection
 
typedef std::vector< reco::TrackTrackCollection
 
- 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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
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::EDGetTokenT
< MeasurementTrackerEvent
mteSrc_
 
bool rekeyClusterRefs_
 
edm::OrphanHandle
< TrackCollection
rTracks_
 
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 13 of file TrackRefitter.cc.

References TrackProducerBase< reco::Track >::alias_, constraint_, edm::hlt::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.

13  :
14  KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
15  iConfig.getParameter<bool>("useHitsSplitting")),
16  theAlgo(iConfig)
17 {
18  setConf(iConfig);
19  setSrc( consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>( "src" )),
20  consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>( "beamSpot" )),
21  consumes<MeasurementTrackerEvent>(iConfig.getParameter<edm::InputTag>( "MeasurementTrackerEvent") ));
22  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
23  std::string constraint_str = iConfig.getParameter<std::string>( "constraint" );
24  edm::InputTag trkconstrcoll = iConfig.getParameter<edm::InputTag>( "srcConstr" );
25 
26 
27  if (constraint_str == "") constraint_ = none;
28  else if (constraint_str == "momentum") { constraint_ = momentum; trkconstrcoll_ = consumes<TrackMomConstraintAssociationCollection>(trkconstrcoll); }
29  else if (constraint_str == "vertex") { constraint_ = vertex; trkconstrcoll_ = consumes<TrackVtxConstraintAssociationCollection>(trkconstrcoll); }
30  else if (constraint_str == "trackParameters") { constraint_ = trackParameters; trkconstrcoll_ = consumes<TrackParamConstraintAssociationCollection>(trkconstrcoll); }
31  else {
32  edm::LogError("TrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
33  throw cms::Exception("TrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex', 'trackParameters' or leave it empty";
34  }
35 
36  //register your products
37  produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
38  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
39  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
40  produces<std::vector<Trajectory> >() ;
41  produces<TrajTrackAssociationCollection>();
42 
43 }
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.
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 edm::stream::EDProducerBase.

Definition at line 45 of file TrackRefitter.cc.

References TrackProducerBase< reco::Track >::bsSrc_, constraint_, alignCSCRings::e, edm::HandleBase::failedToGet(), edm::Event::getByToken(), TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), edm::EventBase::id(), edm::HandleBase::isValid(), LogDebug, momentum, none, reco::BeamSpot::position(), edm::ESHandle< class >::product(), KfTrackProducerBase::putInEvt(), TrackProducerAlgorithm< T >::runWithMomentum(), TrackProducerAlgorithm< T >::runWithTrack(), TrackProducerAlgorithm< T >::runWithTrackParameters(), TrackProducerAlgorithm< T >::runWithVertex(), theAlgo, trackParameters, trkconstrcoll_, reco::BeamSpot::type(), reco::BeamSpot::Unknown, and vertex.

46 {
47  LogDebug("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
48  //
49  // create empty output collections
50  //
51  std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
52  std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
53  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
54  std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
55 
56  //
57  //declare and get stuff to be retrieved from ES
58  //
62  edm::ESHandle<Propagator> thePropagator;
65  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
66 
67  //
68  //declare and get TrackCollection to be retrieved from the event
69  //
70  AlgoProductCollection algoResults;
71  reco::BeamSpot bs;
72  switch(constraint_){
73  case none :
74  {
76  getFromEvt(theEvent,theTCollection,bs);
77 
78  LogDebug("TrackRefitter") << "TrackRefitter::produce(none):Number of Trajectories:" << (*theTCollection).size();
79 
80  if (bs.position()==math::XYZPoint(0.,0.,0.) && bs.type() == reco::BeamSpot::Unknown) {
81  edm::LogError("TrackRefitter") << " BeamSpot is (0,0,0), it is probably because is not valid in the event"; break; }
82 
83  if (theTCollection.failedToGet()){
84  edm::LogError("TrackRefitter")<<"could not get the reco::TrackCollection."; break;}
85  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
86 
87  try {
88  theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection,
89  theFitter.product(), thePropagator.product(),
90  theBuilder.product(), bs, algoResults);
91  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
92  break;
93  }
94  case momentum :
95  {
96  edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint;
97  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
98 
99 
100  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
101  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
102  if (!recoBeamSpotHandle.isValid()) break;
103  bs = *recoBeamSpotHandle;
104  if (theTCollectionWithConstraint.failedToGet()){
105  //edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product.";
106  break;}
107  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
108  try {
109  theAlgo.runWithMomentum(theG.product(), theMF.product(), *theTCollectionWithConstraint,
110  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
111  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
112  break;
113  }
114  case vertex :
115  {
116  edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
117  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
118  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
119  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
120  if (!recoBeamSpotHandle.isValid()) break;
121  bs = *recoBeamSpotHandle;
122  if (theTCollectionWithConstraint.failedToGet()){
123  edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;}
124  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
125  try {
126  theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint,
127  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
128  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
129  }
130  case trackParameters :
131  {
132  edm::Handle<TrackParamConstraintAssociationCollection> theTCollectionWithConstraint;
133  theEvent.getByToken(trkconstrcoll_,theTCollectionWithConstraint);
134  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
135  theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
136  if (!recoBeamSpotHandle.isValid()) break;
137  bs = *recoBeamSpotHandle;
138  if (theTCollectionWithConstraint.failedToGet()){
139  //edm::LogError("TrackRefitter")<<"could not get TrackParamConstraintAssociationCollection product.";
140  break;}
141  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
142  try {
143  theAlgo.runWithTrackParameters(theG.product(), theMF.product(), *theTCollectionWithConstraint,
144  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
145  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
146  }
147  //default... there cannot be any other possibility due to the check in the ctor
148  }
149 
150 
151  //put everything in th event
152  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults,theBuilder.product());
153  LogDebug("TrackRefitter") << "end" << "\n";
154 }
#define LogDebug(id)
virtual void putInEvt(edm::Event &, const Propagator *prop, const MeasurementTracker *measTk, std::auto_ptr< TrackingRecHitCollection > &, std::auto_ptr< reco::TrackCollection > &, std::auto_ptr< reco::TrackExtraCollection > &, std::auto_ptr< std::vector< Trajectory > > &, AlgoProductCollection &, TransientTrackingRecHitBuilder const *, int BeforeOrAfter=0)
Put produced collections in the event.
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:457
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:13
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) ...
bool isValid() const
Definition: HandleBase.h:75
std::vector< AlgoProduct > AlgoProductCollection
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:79
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
T const * product() const
Definition: ESHandle.h:86
void runWithTrackParameters(const TrackingGeometry *, const MagneticField *, const TrackParamConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
edm::EDGetTokenT< reco::BeamSpot > bsSrc_
edm::EventID id() const
Definition: EventBase.h:60
const Point & position() const
position
Definition: BeamSpot.h:62
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.
void runWithTrack(const TrackingGeometry *, const MagneticField *, const TrackCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
Run the Final Fit taking Tracks as input (for Refitter)

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