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::EDProducer TrackProducerBase< reco::Track > edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 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 &)
 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 (edm::ParameterSet conf)
 Set parameter set. More...
 
void setSecondHitPattern (Trajectory *traj, reco::Track &track, const Propagator *prop, const MeasurementTracker *measTk)
 
void setSrc (edm::InputTag src, edm::InputTag bsSrc)
 set label of source collection More...
 
 TrackProducerBase (bool trajectoryInEvent=false)
 Constructor. More...
 
virtual ~TrackProducerBase ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Types

enum  Constraint { none, momentum, vertex }
 

Private Attributes

Constraint constraint_
 
TrackProducerAlgorithm
< reco::Track
theAlgo
 
edm::InputTag 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::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 
- Protected Attributes inherited from TrackProducerBase< reco::Track >
std::string alias_
 
edm::InputTag bsSrc_
 
edm::InputTag clusterRemovalInfo_
 
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.

Date:
2007/12/07 02:20:40
Revision:
1.2
Author
cerati

Definition at line 15 of file TrackRefitter.h.

Member Enumeration Documentation

Enumerator
none 
momentum 
vertex 

Definition at line 26 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(), trkconstrcoll_, and vertex.

13  :
14  KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
15  iConfig.getParameter<bool>("useHitsSplitting")),
16  theAlgo(iConfig)
17 {
18  setConf(iConfig);
19  setSrc( iConfig.getParameter<edm::InputTag>( "src" ), iConfig.getParameter<edm::InputTag>( "beamSpot" ));
20  setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
21  std::string constraint_str = iConfig.getParameter<std::string>( "constraint" );
22  trkconstrcoll_=iConfig.getParameter<edm::InputTag>( "srcConstr" );
23 
24 
25  if (constraint_str == "") constraint_ = none;
26  else if (constraint_str == "momentum") constraint_ = momentum;
27  else if (constraint_str == "vertex") constraint_ = vertex;
28  else {
29  edm::LogError("TrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex' or leave it empty";
30  throw cms::Exception("TrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";
31  }
32 
33  //register your products
34  produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
35  produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
36  produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
37  produces<std::vector<Trajectory> >() ;
38  produces<TrajTrackAssociationCollection>();
39 
40 }
T getParameter(std::string const &) const
void setAlias(std::string alias)
set the aliases of produced collections
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:25
void setConf(edm::ParameterSet conf)
Set parameter set.
edm::InputTag trkconstrcoll_
Definition: TrackRefitter.h:28
void setSrc(edm::InputTag src, edm::InputTag bsSrc)
set label of source collection
KfTrackProducerBase(bool trajectoryInEvent, bool split)
Constructor.
Constraint constraint_
Definition: TrackRefitter.h:27

Member Function Documentation

void TrackRefitter::produce ( edm::Event theEvent,
const edm::EventSetup setup 
)
virtual

Implementation of produce method.

Implements edm::EDProducer.

Definition at line 42 of file TrackRefitter.cc.

References TrackProducerBase< reco::Track >::bsSrc_, constraint_, edm::HandleBase::failedToGet(), edm::Event::getByLabel(), TrackProducerBase< reco::Track >::getFromES(), TrackProducerBase< reco::Track >::getFromEvt(), edm::EventBase::id(), LogDebug, momentum, none, edm::ESHandle< class >::product(), KfTrackProducerBase::putInEvt(), TrackProducerAlgorithm< T >::runWithMomentum(), TrackProducerAlgorithm< T >::runWithTrack(), TrackProducerAlgorithm< T >::runWithVertex(), theAlgo, trkconstrcoll_, and vertex.

43 {
44  edm::LogInfo("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
45  //
46  // create empty output collections
47  //
48  std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
49  std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection);
50  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
51  std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
52 
53  //
54  //declare and get stuff to be retrieved from ES
55  //
59  edm::ESHandle<Propagator> thePropagator;
62  getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder);
63 
64  //
65  //declare and get TrackCollection to be retrieved from the event
66  //
67  AlgoProductCollection algoResults;
68  reco::BeamSpot bs;
69  switch(constraint_){
70  case none :
71  {
73  getFromEvt(theEvent,theTCollection,bs);
74  if (theTCollection.failedToGet()){
75  edm::LogError("TrackRefitter")<<"could not get the reco::TrackCollection."; break;}
76  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
77 
78  try {
79  theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection,
80  theFitter.product(), thePropagator.product(),
81  theBuilder.product(), bs, algoResults);
82  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
83  break;
84  }
85  case momentum :
86  {
87  edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint;
88  theEvent.getByLabel(trkconstrcoll_,theTCollectionWithConstraint);
89 
90 
91  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
92  theEvent.getByLabel(bsSrc_,recoBeamSpotHandle);
93  bs = *recoBeamSpotHandle;
94  if (theTCollectionWithConstraint.failedToGet()){
95  edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product."; break;}
96  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
97  try {
98  theAlgo.runWithMomentum(theG.product(), theMF.product(), *theTCollectionWithConstraint,
99  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
100  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
101  break;}
102  case vertex :
103  {
104  edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
105  theEvent.getByLabel(trkconstrcoll_,theTCollectionWithConstraint);
106  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
107  theEvent.getByLabel(bsSrc_,recoBeamSpotHandle);
108  bs = *recoBeamSpotHandle;
109  if (theTCollectionWithConstraint.failedToGet()){
110  edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;}
111  LogDebug("TrackRefitter") << "run the algorithm" << "\n";
112  try {
113  theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint,
114  theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
115  }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
116  }
117  //default... there cannot be any other possibility due to the check in the ctor
118  }
119 
120 
121  //put everything in th event
122  putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults);
123  LogDebug("TrackRefitter") << "end" << "\n";
124 }
#define LogDebug(id)
virtual void getFromEvt(edm::Event &, edm::Handle< TrackCandidateCollection > &, reco::BeamSpot &)
Get TrackCandidateCollection from the Event (needed by TrackProducer)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
TrackProducerAlgorithm< reco::Track > theAlgo
Definition: TrackRefitter.h:25
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) ...
edm::InputTag trkconstrcoll_
Definition: TrackRefitter.h:28
std::vector< AlgoProduct > AlgoProductCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
Constraint constraint_
Definition: TrackRefitter.h:27
void runWithVertex(const TrackingGeometry *, const MagneticField *, const VtxConstraintAssociationCollection &, const TrajectoryFitter *, const Propagator *, const TransientTrackingRecHitBuilder *, const reco::BeamSpot &, AlgoProductCollection &)
bool failedToGet() const
Definition: HandleBase.h:80
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:9
T const * product() const
Definition: ESHandle.h:62
edm::EventID id() const
Definition: EventBase.h:56
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 &)
Put produced collections in the event.
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 27 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().

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

Definition at line 25 of file TrackRefitter.h.

Referenced by produce().

edm::InputTag TrackRefitter::trkconstrcoll_
private

Definition at line 28 of file TrackRefitter.h.

Referenced by produce(), and TrackRefitter().