Go to the documentation of this file.00001 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackReconstruction.h"
00002
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
00008 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
00009
00010 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00011 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
00012 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
00013
00014 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitter.h"
00015 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelFitterFactory.h"
00016
00017 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackFilter.h"
00018 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackFilterFactory.h"
00019
00020 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackCleaner.h"
00021 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackCleanerFactory.h"
00022 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackCleanerWrapper.h"
00023
00024 #include "DataFormats/TrackReco/interface/Track.h"
00025 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00026 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00027
00028 #include <vector>
00029
00030 using namespace pixeltrackfitting;
00031 using namespace ctfseeding;
00032 using edm::ParameterSet;
00033
00034 PixelTrackReconstruction::PixelTrackReconstruction(const ParameterSet& cfg)
00035 : theConfig(cfg), theFitter(0), theFilter(0), theCleaner(0), theGenerator(0), theRegionProducer(0)
00036 { }
00037
00038 PixelTrackReconstruction::~PixelTrackReconstruction()
00039 {
00040 halt();
00041 }
00042
00043 void PixelTrackReconstruction::halt()
00044 {
00045 delete theFilter; theFilter=0;
00046 delete theFitter; theFitter=0;
00047 delete theCleaner; theCleaner=0;
00048 delete theGenerator; theGenerator=0;
00049 delete theRegionProducer; theRegionProducer=0;
00050 }
00051
00052 void PixelTrackReconstruction::init(const edm::EventSetup& es)
00053 {
00054 ParameterSet regfactoryPSet = theConfig.getParameter<ParameterSet>("RegionFactoryPSet");
00055 std::string regfactoryName = regfactoryPSet.getParameter<std::string>("ComponentName");
00056 theRegionProducer = TrackingRegionProducerFactory::get()->create(regfactoryName,regfactoryPSet);
00057
00058 ParameterSet orderedPSet =
00059 theConfig.getParameter<ParameterSet>("OrderedHitsFactoryPSet");
00060 std::string orderedName = orderedPSet.getParameter<std::string>("ComponentName");
00061 theGenerator = OrderedHitsGeneratorFactory::get()->create( orderedName, orderedPSet);
00062
00063 ParameterSet fitterPSet = theConfig.getParameter<ParameterSet>("FitterPSet");
00064 std::string fitterName = fitterPSet.getParameter<std::string>("ComponentName");
00065 theFitter = PixelFitterFactory::get()->create( fitterName, fitterPSet);
00066
00067 ParameterSet filterPSet = theConfig.getParameter<ParameterSet>("FilterPSet");
00068 std::string filterName = filterPSet.getParameter<std::string>("ComponentName");
00069 if (filterName != "none") {
00070 theFilter = theConfig.getParameter<bool>("useFilterWithES") ?
00071 PixelTrackFilterWithESFactory::get()->create( filterName, filterPSet, es) :
00072 PixelTrackFilterFactory::get()->create( filterName, filterPSet);
00073 }
00074
00075 ParameterSet cleanerPSet = theConfig.getParameter<ParameterSet>("CleanerPSet");
00076 std::string cleanerName = cleanerPSet.getParameter<std::string>("ComponentName");
00077 if (cleanerName != "none") theCleaner = PixelTrackCleanerFactory::get()->create( cleanerName, cleanerPSet);
00078
00079 }
00080
00081 void PixelTrackReconstruction::run(TracksWithTTRHs& tracks, edm::Event& ev, const edm::EventSetup& es)
00082 {
00083 typedef std::vector<TrackingRegion* > Regions;
00084 typedef Regions::const_iterator IR;
00085 Regions regions = theRegionProducer->regions(ev,es);
00086
00087 if (theFilter) theFilter->update(ev);
00088
00089 for (IR ir=regions.begin(), irEnd=regions.end(); ir < irEnd; ++ir) {
00090 const TrackingRegion & region = **ir;
00091
00092 const OrderedSeedingHits & triplets = theGenerator->run(region,ev,es);
00093 unsigned int nTriplets = triplets.size();
00094
00095
00096 for (unsigned int iTriplet = 0; iTriplet < nTriplets; ++iTriplet) {
00097 const SeedingHitSet & triplet = triplets[iTriplet];
00098
00099 std::vector<const TrackingRecHit *> hits;
00100 for (unsigned int iHit = 0, nHits = triplet.size(); iHit < nHits; ++iHit) {
00101 hits.push_back( triplet[iHit]->hit() );
00102 }
00103
00104
00105 reco::Track* track = theFitter->run(es, hits, region);
00106
00107
00108 if (theFilter && !(*theFilter)(track, hits) ) {
00109 delete track;
00110 continue;
00111 }
00112
00113
00114 tracks.push_back(TrackWithTTRHs(track, triplet));
00115 }
00116 theGenerator->clear();
00117 }
00118
00119
00120 if (theCleaner) tracks = PixelTrackCleanerWrapper(theCleaner).clean(tracks);
00121
00122
00123 for (IR ir=regions.begin(), irEnd=regions.end(); ir < irEnd; ++ir) delete (*ir);
00124 }