CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoLocalMuon/CSCRecHitD/src/CSCRecHitDProducer.cc

Go to the documentation of this file.
00001 #include <RecoLocalMuon/CSCRecHitD/src/CSCRecHitDProducer.h>
00002 #include <RecoLocalMuon/CSCRecHitD/src/CSCRecHitDBuilder.h>
00003 #include <RecoLocalMuon/CSCRecHitD/src/CSCRecoConditions.h>
00004 
00005 #include <FWCore/Framework/interface/Frameworkfwd.h>
00006 #include <FWCore/Framework/interface/EDProducer.h>
00007 #include <FWCore/Framework/interface/Event.h>
00008 #include <FWCore/Framework/interface/MakerMacros.h>
00009 #include <DataFormats/Common/interface/Handle.h>
00010 #include <FWCore/Framework/interface/ESHandle.h>
00011 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00012 #include <FWCore/Utilities/interface/Exception.h>
00013 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00014 
00015 #include <Geometry/Records/interface/MuonGeometryRecord.h>
00016 
00017 #include <DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h>
00018 #include <DataFormats/CSCDigi/interface/CSCStripDigiCollection.h>
00019 #include <DataFormats/CSCDigi/interface/CSCWireDigiCollection.h>
00020 
00021 
00022 CSCRecHitDProducer::CSCRecHitDProducer( const edm::ParameterSet& ps ) : 
00023   iRun( 0 ),   
00024   useCalib( ps.getParameter<bool>("CSCUseCalibrations") ),
00025   useStaticPedestals( ps.getParameter<bool>("CSCUseStaticPedestals") ),
00026   useTimingCorrections(ps.getParameter<bool>("CSCUseTimingCorrections") ),
00027   stripDigiTag_( ps.getParameter<edm::InputTag>("stripDigiTag") ),
00028   wireDigiTag_(  ps.getParameter<edm::InputTag>("wireDigiTag") )
00029 
00030 {
00031   recHitBuilder_     = new CSCRecHitDBuilder( ps ); // pass on the parameter sets
00032   recoConditions_    = new CSCRecoConditions( ps ); // access to conditions data
00033 
00034   recHitBuilder_->setConditions( recoConditions_ ); // pass down to who needs access
00035   
00036   // register what this produces
00037   produces<CSCRecHit2DCollection>();
00038 
00039 }
00040 
00041 CSCRecHitDProducer::~CSCRecHitDProducer()
00042 {
00043   delete recHitBuilder_;
00044   delete recoConditions_;
00045 }
00046 
00047 
00048 void  CSCRecHitDProducer::produce( edm::Event& ev, const edm::EventSetup& setup )
00049 {
00050   // find the geometry for this event & cache it in the builder
00051   edm::ESHandle<CSCGeometry> h;
00052   setup.get<MuonGeometryRecord>().get( h );
00053   const CSCGeometry* pgeom = &*h;
00054   recHitBuilder_->setGeometry( pgeom );
00055 
00056   // access conditions data for this event 
00057   if ( useCalib || useStaticPedestals || useTimingCorrections ) {  
00058     recoConditions_->initializeEvent( setup ); 
00059   }
00060         
00061   // Get the collections of strip & wire digis from event
00062   edm::Handle<CSCStripDigiCollection> stripDigis;
00063   edm::Handle<CSCWireDigiCollection> wireDigis;
00064   ev.getByLabel( stripDigiTag_, stripDigis);
00065   ev.getByLabel( wireDigiTag_,  wireDigis);
00066 
00067   // Create empty collection of rechits
00068   std::auto_ptr<CSCRecHit2DCollection> oc( new CSCRecHit2DCollection );
00069 
00070 
00071   // Fill the CSCRecHit2DCollection
00072   recHitBuilder_->build( stripDigis.product(), wireDigis.product(),*oc);
00073 
00074 
00075   // Put collection in event
00076   LogTrace("CSCRecHit")<< "CSCRecHitDProducer: putting rechit collection in event.";
00077   ev.put( oc );
00078 
00079 }
00080 
00081 //define this as a plug-in
00082 DEFINE_FWK_MODULE(CSCRecHitDProducer);
00083