CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/RecoTracker/RoadSearchSeedFinder/src/RoadSearchSeedFinder.cc

Go to the documentation of this file.
00001 //
00002 // Package:         RecoTracker/RoadSearchSeedFinder
00003 // Class:           RoadSearchSeedFinder
00004 // 
00005 // Description:     Calls RoadSeachSeedFinderAlgorithm
00006 //                  to find RoadSearchSeeds.
00007 //
00008 // Original Author: Oliver Gutsche, gutsche@fnal.gov
00009 // Created:         Sat Jan 14 22:00:00 UTC 2006
00010 //
00011 // $Author: wmtan $
00012 // $Date: 2010/02/11 00:14:44 $
00013 // $Revision: 1.18 $
00014 //
00015 
00016 #include <iostream>
00017 #include <memory>
00018 #include <string>
00019 
00020 #include "RecoTracker/RoadSearchSeedFinder/interface/RoadSearchSeedFinder.h"
00021 
00022 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00023 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00024 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00025 
00026 #include "DataFormats/RoadSearchSeed/interface/RoadSearchSeedCollection.h"
00027 
00028 #include "DataFormats/Common/interface/Handle.h"
00029 #include "FWCore/Framework/interface/ESHandle.h"
00030 #include "FWCore/Framework/interface/EventSetup.h"
00031 
00032 #include "FWCore/Utilities/interface/InputTag.h"
00033 #include "RecoTracker/SpecialSeedGenerators/interface/ClusterChecker.h"
00034 
00035 RoadSearchSeedFinder::RoadSearchSeedFinder(edm::ParameterSet const& conf) : 
00036   roadSearchSeedFinderAlgorithm_(conf) ,
00037   conf_(conf)
00038 {
00039   produces<RoadSearchSeedCollection>();
00040 
00041 }
00042 
00043 
00044 // Virtual destructor needed.
00045 RoadSearchSeedFinder::~RoadSearchSeedFinder() { }  
00046 
00047 // Functions that gets called by framework every event
00048 void RoadSearchSeedFinder::produce(edm::Event& e, const edm::EventSetup& es)
00049 {
00050 
00051   // retrieve InputTags for strip rechits
00052   edm::InputTag matchedStripRecHitsInputTag = conf_.getParameter<edm::InputTag>("matchedStripRecHits");
00053   edm::InputTag rphiStripRecHitsInputTag    = conf_.getParameter<edm::InputTag>("rphiStripRecHits");
00054   edm::InputTag stereoStripRecHitsInputTag  = conf_.getParameter<edm::InputTag>("stereoStripRecHits");
00055   edm::InputTag clusterCollectionInputTag   = conf_.getParameter<edm::InputTag>("ClusterCollectionLabel");
00056   
00057   // get Inputs
00058   edm::Handle<SiStripMatchedRecHit2DCollection> matchedRecHits;
00059   e.getByLabel(matchedStripRecHitsInputTag ,matchedRecHits);
00060   edm::Handle<SiStripRecHit2DCollection> rphiRecHits;
00061   e.getByLabel(rphiStripRecHitsInputTag ,rphiRecHits);
00062   edm::Handle<SiStripRecHit2DCollection> stereoRecHits;
00063   e.getByLabel(stereoStripRecHitsInputTag ,stereoRecHits);
00064  
00065   // retrieve InputTag for pixel rechits
00066   edm::InputTag pixelRecHitsInputTag  = conf_.getParameter<edm::InputTag>("pixelRecHits");
00067 
00068   // special treatment for getting pixel collection
00069   // if collection exists in file, use collection from file
00070   // if collection does not exist in file, create empty collection
00071   static const SiPixelRecHitCollection s_empty;
00072   const SiPixelRecHitCollection *pixelRecHitCollection = &s_empty;
00073   edm::Handle<SiPixelRecHitCollection> pixelRecHits;
00074   if( e.getByLabel(pixelRecHitsInputTag, pixelRecHits)) {
00075     pixelRecHitCollection = pixelRecHits.product();
00076   } else {
00077     LogDebug("RoadSearch") << "Collection SiPixelRecHitCollection with InputTag " << pixelRecHitsInputTag << " cannot be found, using empty collection of same type. The RoadSearch algorithm is also fully functional without Pixel RecHits.";
00078   }
00079 
00080   // create empty output collection
00081   std::auto_ptr<RoadSearchSeedCollection> output(new RoadSearchSeedCollection);
00082 
00083   ClusterChecker check(conf_);
00084     
00085   // invoke the seed finding algorithm: check number of clusters per event *only* in cosmic tracking mode
00086   size_t clustsOrZero = check.tooManyClusters(e);
00087   if (!clustsOrZero) {
00088 
00089     roadSearchSeedFinderAlgorithm_.run(rphiRecHits.product(),  
00090                                        stereoRecHits.product(),
00091                                        matchedRecHits.product(),
00092                                        pixelRecHitCollection,
00093                                        es,
00094                                        *output);
00095   } else {
00096     edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";
00097   }
00098 
00099   // write output to file
00100   e.put(output);
00101 
00102 }