CMS 3D CMS Logo

GsfTrackRefitter.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TrackProducer/plugins/GsfTrackRefitter.h"
00002 // system include files
00003 #include <memory>
00004 // user include files
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 
00009 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00010 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00011 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00012 
00013 GsfTrackRefitter::GsfTrackRefitter(const edm::ParameterSet& iConfig):
00014   GsfTrackProducerBase(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("GsfTrackRefitter")<<"constraint: "<<constraint_str<<" not understood. Set it to 'momentum', 'vertex' or leave it empty";    
00028 //     throw cms::Exception("GsfTrackRefitter") << "unknown type of contraint! Set it to 'momentum', 'vertex' or leave it empty";    
00029 //   }
00030 
00031   //register your products
00032   produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
00033   produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
00034   produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
00035   produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
00036   produces<std::vector<Trajectory> >() ;
00037   produces<TrajTrackAssociationCollection>();
00038 
00039 }
00040 
00041 void GsfTrackRefitter::produce(edm::Event& theEvent, const edm::EventSetup& setup)
00042 {
00043   edm::LogInfo("GsfTrackRefitter") << "Analyzing event number: " << theEvent.id() << "\n";
00044   //
00045   // create empty output collections
00046   //
00047   std::auto_ptr<TrackingRecHitCollection>   outputRHColl (new TrackingRecHitCollection);
00048   std::auto_ptr<reco::GsfTrackCollection>      outputTColl(new reco::GsfTrackCollection);
00049   std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
00050   std::auto_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
00051   std::auto_ptr<std::vector<Trajectory> >   outputTrajectoryColl(new std::vector<Trajectory>);
00052 
00053   //
00054   //declare and get stuff to be retrieved from ES
00055   //
00056   edm::ESHandle<TrackerGeometry> theG;
00057   edm::ESHandle<MagneticField> theMF;
00058   edm::ESHandle<TrajectoryFitter> theFitter;
00059   edm::ESHandle<Propagator> thePropagator;
00060   //  getFromES(setup,theG,theMF,theFitter,thePropagator);
00061   edm::ESHandle<TransientTrackingRecHitBuilder> theBuilder;
00062   getFromES(setup,theG,theMF,theFitter,thePropagator,theBuilder);
00063 
00064   //
00065   //declare and get TrackCollection to be retrieved from the event
00066   //
00067   AlgoProductCollection algoResults;
00068   reco::BeamSpot bs;
00069     {
00070       edm::Handle<reco::GsfTrackCollection> theTCollection;
00071       getFromEvt(theEvent,theTCollection,bs);
00072       if (theTCollection.failedToGet()){
00073         edm::LogError("GsfTrackRefitter")<<"could not get the reco::GsfTrackCollection."; return;}
00074       LogDebug("GsfTrackRefitter") << "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     }
00080 
00081   
00082   //put everything in th event
00083   putInEvt(theEvent, outputRHColl, outputTColl, outputTEColl, outputGsfTEColl, outputTrajectoryColl, algoResults, bs);
00084   LogDebug("GsfTrackRefitter") << "end" << "\n";
00085 }
00086 

Generated on Tue Jun 9 17:45:59 2009 for CMSSW by  doxygen 1.5.4