CMS 3D CMS Logo

TrackRefitter Class Reference

Refit Tracks: Produce Tracks from TrackCollection. More...

#include <RecoTracker/TrackProducer/plugins/TrackRefitter.h>

Inheritance diagram for TrackRefitter:

KfTrackProducerBase edm::EDProducer TrackProducerBase< reco::Track > edm::ProducerBase edm::ProductRegistryHelper

List of all members.

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


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

enum TrackRefitter::Constraint [private]

Enumerator:
none 
momentum 
vertex 

Definition at line 26 of file TrackRefitter.h.

00026 { none, momentum, vertex };


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_, Exception, edm::ParameterSet::getParameter(), momentum, none, TrackProducerBase< reco::Track >::setAlias(), TrackProducerBase< reco::Track >::setConf(), TrackProducerBase< reco::Track >::setSrc(), and vertex.

00013                                                           :
00014   KfTrackProducerBase(iConfig.getParameter<bool>("TrajectoryInEvent"),
00015                       iConfig.getParameter<bool>("useHitsSplitting")),
00016   theAlgo(iConfig)
00017 {
00018   setConf(iConfig);
00019   setSrc( iConfig.getParameter<edm::InputTag>( "src" ), iConfig.getParameter<edm::InputTag>( "beamSpot" ));
00020   setAlias( iConfig.getParameter<std::string>( "@module_label" ) );
00021   std::string  constraint_str = iConfig.getParameter<std::string>( "constraint" );
00022 
00023   if (constraint_str == "") constraint_ = none;
00024   else if (constraint_str == "momentum") constraint_ = momentum;
00025   else if (constraint_str == "vertex") constraint_ = vertex;
00026   else {
00027     edm::LogError("TrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex' or leave it empty";    
00028     throw cms::Exception("TrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";    
00029   }
00030 
00031   //register your products
00032   produces<reco::TrackCollection>().setBranchAlias( alias_ + "Tracks" );
00033   produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
00034   produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
00035   produces<std::vector<Trajectory> >() ;
00036   produces<TrajTrackAssociationCollection>();
00037 
00038 }


Member Function Documentation

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

Implementation of produce method.

Implements edm::EDProducer.

Definition at line 40 of file TrackRefitter.cc.

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

00041 {
00042   edm::LogInfo("TrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
00043   //
00044   // create empty output collections
00045   //
00046   std::auto_ptr<TrackingRecHitCollection>   outputRHColl (new TrackingRecHitCollection);
00047   std::auto_ptr<reco::TrackCollection>      outputTColl(new reco::TrackCollection);
00048   std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
00049   std::auto_ptr<std::vector<Trajectory> >   outputTrajectoryColl(new std::vector<Trajectory>);
00050 
00051   //
00052   //declare and get stuff to be retrieved from ES
00053   //
00054   edm::ESHandle<TrackerGeometry> theG;
00055   edm::ESHandle<MagneticField> theMF;
00056   edm::ESHandle<TrajectoryFitter> theFitter;
00057   edm::ESHandle<Propagator> thePropagator;
00058   //  getFromES(setup,theG,theMF,theFitter,thePropagator);
00059   edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
00060   getFromES(setup,theG,theMF,theFitter,thePropagator,theBuilder);
00061 
00062   //
00063   //declare and get TrackCollection to be retrieved from the event
00064   //
00065   AlgoProductCollection algoResults;
00066   reco::BeamSpot bs;
00067   switch(constraint_){
00068   case none :
00069     {
00070       edm::Handle<reco::TrackCollection> theTCollection;
00071       getFromEvt(theEvent,theTCollection,bs);
00072       if (theTCollection.failedToGet()){
00073         edm::LogError("TrackRefitter")<<"could not get the reco::TrackCollection."; break;}
00074       LogDebug("TrackRefitter") << "run the algorithm" << "\n";
00075       try {
00076         theAlgo.runWithTrack(theG.product(), theMF.product(), *theTCollection, 
00077                              theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
00078       }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
00079       break;
00080     }
00081   case momentum :
00082     {
00083       edm::Handle<TrackMomConstraintAssociationCollection> theTCollectionWithConstraint;
00084       theEvent.getByType(theTCollectionWithConstraint);
00085       edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00086       theEvent.getByLabel(bsSrc_,recoBeamSpotHandle);
00087       bs = *recoBeamSpotHandle;      
00088       if (theTCollectionWithConstraint.failedToGet()){
00089         edm::LogError("TrackRefitter")<<"could not get TrackMomConstraintAssociationCollection product."; break;}
00090       LogDebug("TrackRefitter") << "run the algorithm" << "\n";
00091       try {
00092         theAlgo.runWithMomentum(theG.product(), theMF.product(), *theTCollectionWithConstraint, 
00093                                 theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);
00094       }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
00095       break;}
00096   case  vertex :
00097     {
00098       edm::Handle<TrackVtxConstraintAssociationCollection> theTCollectionWithConstraint;
00099       theEvent.getByType(theTCollectionWithConstraint);
00100       edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00101       theEvent.getByLabel(bsSrc_,recoBeamSpotHandle);
00102       bs = *recoBeamSpotHandle;      
00103       if (theTCollectionWithConstraint.failedToGet()){
00104         edm::LogError("TrackRefitter")<<"could not get TrackVtxConstraintAssociationCollection product."; break;}
00105       LogDebug("TrackRefitter") << "run the algorithm" << "\n";
00106       try {
00107       theAlgo.runWithVertex(theG.product(), theMF.product(), *theTCollectionWithConstraint, 
00108                             theFitter.product(), thePropagator.product(), theBuilder.product(), bs, algoResults);      
00109       }catch (cms::Exception &e){ edm::LogError("TrackProducer") << "cms::Exception caught during theAlgo.runWithTrack." << "\n" << e << "\n"; throw; }
00110     }
00111     //default... there cannot be any other possibility due to the check in the ctor
00112   }
00113 
00114   
00115   //put everything in th event
00116   putInEvt(theEvent, outputRHColl, outputTColl, outputTEColl, outputTrajectoryColl, algoResults);
00117   LogDebug("TrackRefitter") << "end" << "\n";
00118 }


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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:18 2009 for CMSSW by  doxygen 1.5.4