CMS 3D CMS Logo

SiStripRecHitConverter.cc

Go to the documentation of this file.
00001 // File: SiStripRecHitConverter.cc
00002 // Description:  see SiStripRecHitConverter.h
00003 // Author:  C.Genta
00004 // Creation Date:  OGU Aug. 1 2005 Initial version.
00005 //
00006 //--------------------------------------------
00007 #include <memory>
00008 #include <string>
00009 #include <iostream>
00010 
00011 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00012 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00013 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00014 #include "DataFormats/Common/interface/DetSetVector.h"
00015 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00016 
00017 
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/Framework/interface/EventSetup.h"
00020 
00021 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00022 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00023 
00024 #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitConverter.h"
00025 #include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h"
00026 #include "RecoLocalTracker/ClusterParameterEstimator/interface/StripClusterParameterEstimator.h"
00027 #include "RecoLocalTracker/Records/interface/TkStripCPERecord.h"
00028 
00029 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00030 
00031 namespace cms
00032 {
00033 
00034   SiStripRecHitConverter::SiStripRecHitConverter(edm::ParameterSet const& conf) : 
00035     recHitConverterAlgorithm_(conf) ,
00036     conf_(conf),
00037     matchedRecHitsTag_( conf.getParameter<std::string>( "matchedRecHits" ) ), 
00038     rphiRecHitsTag_( conf.getParameter<std::string>( "rphiRecHits" ) ), 
00039     stereoRecHitsTag_( conf.getParameter<std::string>( "stereoRecHits" ) )
00040   {
00041     produces<SiStripMatchedRecHit2DCollection>( matchedRecHitsTag_ );
00042     produces<SiStripRecHit2DCollection>( rphiRecHitsTag_ );
00043     produces<SiStripRecHit2DCollection>( stereoRecHitsTag_ );
00044   }
00045 
00046 
00047   // Virtual destructor needed.
00048   SiStripRecHitConverter::~SiStripRecHitConverter() { }  
00049 
00050   // Functions that gets called by framework every event
00051   void SiStripRecHitConverter::produce(edm::Event& e, const edm::EventSetup& es)
00052   {
00053     //get tracker geometry
00054     using namespace edm;
00055     edm::ESHandle<TrackerGeometry> pDD;
00056     es.get<TrackerDigiGeometryRecord>().get( pDD );
00057     const TrackerGeometry &tracker(*pDD);
00058     
00059     //get Cluster Parameter Estimator
00060     std::string cpe = conf_.getParameter<std::string>("StripCPE");
00061     edm::ESHandle<StripClusterParameterEstimator> parameterestimator;
00062     es.get<TkStripCPERecord>().get(cpe, parameterestimator); 
00063     const StripClusterParameterEstimator &stripcpe(*parameterestimator);
00064     
00065     //get matcher
00066     std::string matcher = conf_.getParameter<std::string>("Matcher");
00067     edm::ESHandle<SiStripRecHitMatcher> rechitmatcher;
00068     es.get<TkStripCPERecord>().get(matcher, rechitmatcher); 
00069     const SiStripRecHitMatcher &rhmatcher(*rechitmatcher);
00070    
00071     //maybe get the SiStripQuality
00072     const SiStripQuality *ptr_stripQuality = 0;
00073     edm::ESHandle<SiStripQuality>   stripQuality;
00074     if (conf_.existsAs<bool>("useSiStripQuality") && conf_.getParameter<bool>("useSiStripQuality")) {
00075         std::string qualityLabel = conf_.getParameter<std::string>("siStripQualityLabel");
00076         es.get<SiStripQualityRcd>().get(stripQuality);
00077         ptr_stripQuality = stripQuality.product();
00078     }
00079  
00080     // Step A: Get Inputs 
00081     std::string clusterProducer = conf_.getParameter<std::string>("ClusterProducer");
00082     bool regional = conf_.getParameter<bool>("Regional");
00083     edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters;
00084     edm::Handle<edm::RefGetter<SiStripCluster> > refclusters;
00085     edm::Handle<edm::LazyGetter<SiStripCluster> > lazygetter;
00086 
00087     if (regional){
00088       std::string lazyGetterProducer=conf_.getParameter<std::string>("LazyGetterProducer");
00089       e.getByLabel(clusterProducer, refclusters);
00090       e.getByLabel(lazyGetterProducer, lazygetter);
00091     }
00092     else e.getByLabel(clusterProducer, clusters);
00093 
00094     // Step B: create empty output collection
00095     std::auto_ptr<SiStripMatchedRecHit2DCollection> outputmatched(new SiStripMatchedRecHit2DCollection);
00096     std::auto_ptr<SiStripRecHit2DCollection> outputrphi(new SiStripRecHit2DCollection);
00097     std::auto_ptr<SiStripRecHit2DCollection> outputstereo(new SiStripRecHit2DCollection);
00098 
00099     // Step C: Invoke the seed finding algorithm
00100     if (regional) recHitConverterAlgorithm_.run(refclusters,lazygetter,*outputmatched,*outputrphi,*outputstereo,tracker,stripcpe,rhmatcher,ptr_stripQuality);
00101     else recHitConverterAlgorithm_.run(clusters,*outputmatched,*outputrphi,*outputstereo,tracker,stripcpe,rhmatcher,ptr_stripQuality);
00102 
00103     // Step D: write output to file
00104     e.put(outputmatched, matchedRecHitsTag_ );
00105     e.put(outputrphi, rphiRecHitsTag_ );
00106     e.put(outputstereo,stereoRecHitsTag_ );
00107   }
00108 
00109 }

Generated on Tue Jun 9 17:44:00 2009 for CMSSW by  doxygen 1.5.4