#include <TrackRefitter.h>
Public Member Functions | |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Implementation of produce method. | |
TrackRefitter (const edm::ParameterSet &iConfig) | |
Constructor. | |
Private Types | |
enum | Constraint { none, momentum, vertex } |
Private Attributes | |
Constraint | constraint_ |
TrackProducerAlgorithm < reco::Track > | theAlgo |
edm::InputTag | trkconstrcoll_ |
Refit Tracks: Produce Tracks from TrackCollection. It performs a new final fit on a TrackCollection.
Definition at line 15 of file TrackRefitter.h.
enum TrackRefitter::Constraint [private] |
Definition at line 26 of file TrackRefitter.h.
TrackRefitter::TrackRefitter | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Constructor.
Definition at line 13 of file TrackRefitter.cc.
References TrackProducerBase< reco::Track >::alias_, constraint_, Exception, edm::ParameterSet::getParameter(), momentum, none, TrackProducerBase< reco::Track >::setAlias(), TrackProducerBase< reco::Track >::setConf(), TrackProducerBase< reco::Track >::setSrc(), trkconstrcoll_, and vertex.
: KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"), iConfig.getParameter<bool>("useHitsSplitting")), theAlgo(iConfig) { setConf(iConfig); setSrc( iConfig.getParameter<edm::InputTag>( "src" ), iConfig.getParameter<edm::InputTag>( "beamSpot" )); setAlias( iConfig.getParameter<std::string>( "@module_label" ) ); std::string constraint_str = iConfig.getParameter<std::string>( "constraint" ); trkconstrcoll_=iConfig.getParameter<edm::InputTag>( "srcConstr" ); if (constraint_str == "") constraint_ = none; else if (constraint_str == "momentum") constraint_ = momentum; else if (constraint_str == "vertex") constraint_ = vertex; else { edm::LogError("TrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex' or leave it empty"; throw cms::Exception("TrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty"; } //register your products produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" ); produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" ); produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" ); produces<std::vector<Trajectory> >() ; produces<TrajTrackAssociationCollection>(); }
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< T >::product(), KfTrackProducerBase::putInEvt(), TrackProducerAlgorithm< T >::runWithMomentum(), TrackProducerAlgorithm< T >::runWithTrack(), TrackProducerAlgorithm< T >::runWithVertex(), theAlgo, trkconstrcoll_, and vertex.
{ edm::LogInfo("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n"; // // create empty output collections // std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection); std::auto_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection); std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection); std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>); // //declare and get stuff to be retrieved from ES // edm::ESHandle<TrackerGeometry> theG; edm::ESHandle<MagneticField> theMF; edm::ESHandle<TrajectoryFitter> theFitter; edm::ESHandle<Propagator> thePropagator; edm::ESHandle<MeasurementTracker> theMeasTk; edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder; getFromES(setup,theG,theMF,theFitter,thePropagator,theMeasTk,theBuilder); // //declare and get TrackCollection to be retrieved from the event // AlgoProductCollection algoResults; reco::BeamSpot bs; switch(constraint_){ case none : { edm::Handle<reco::TrackCollection> theTCollection; getFromEvt(theEvent,theTCollection,bs); if (theTCollection.failedToGet()){ edm::LogError("TrackRefitter")<<"could not get the reco::TrackCollection."; break;} LogDebug("TrackRefitter") << "run the algorithm" << "\n"; try { theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection, theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults); }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; } break; } case momentum : { edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint; theEvent.getByLabel(trkconstrcoll_,theTCollectionWithConstraint); edm::Handle<reco::BeamSpot> recoBeamSpotHandle; theEvent.getByLabel(bsSrc_,recoBeamSpotHandle); bs = *recoBeamSpotHandle; if (theTCollectionWithConstraint.failedToGet()){ edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product."; break;} LogDebug("TrackRefitter") << "run the algorithm" << "\n"; try { theAlgo.runWithMomentum(theG.product(), theMF.product(), *theTCollectionWithConstraint, theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults); }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; } break;} case vertex : { edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint; theEvent.getByLabel(trkconstrcoll_,theTCollectionWithConstraint); edm::Handle<reco::BeamSpot> recoBeamSpotHandle; theEvent.getByLabel(bsSrc_,recoBeamSpotHandle); bs = *recoBeamSpotHandle; if (theTCollectionWithConstraint.failedToGet()){ edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;} LogDebug("TrackRefitter") << "run the algorithm" << "\n"; try { theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint, theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults); }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; } } //default... there cannot be any other possibility due to the check in the ctor } //put everything in th event putInEvt(theEvent, thePropagator.product(), theMeasTk.product(), outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults); LogDebug("TrackRefitter") << "end" << "\n"; }
Constraint TrackRefitter::constraint_ [private] |
Definition at line 27 of file TrackRefitter.h.
Referenced by produce(), and TrackRefitter().
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().