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.getUntrackedParameter<bool>("CSCUseCalibrations") ), 00025 stripDigiTag_( ps.getParameter<edm::InputTag>("stripDigiTag") ), 00026 wireDigiTag_( ps.getParameter<edm::InputTag>("wireDigiTag") ) 00027 00028 { 00029 recHitBuilder_ = new CSCRecHitDBuilder( ps ); // pass on the parameter sets 00030 recoConditions_ = new CSCRecoConditions( ps ); // access to conditions data 00031 00032 recHitBuilder_->setConditions( recoConditions_ ); // pass down to who needs access 00033 00034 // register what this produces 00035 produces<CSCRecHit2DCollection>(); 00036 00037 } 00038 00039 CSCRecHitDProducer::~CSCRecHitDProducer() 00040 { 00041 delete recHitBuilder_; 00042 delete recoConditions_; 00043 } 00044 00045 00046 void CSCRecHitDProducer::produce( edm::Event& ev, const edm::EventSetup& setup ) 00047 { 00048 // find the geometry for this event & cache it in the builder 00049 edm::ESHandle<CSCGeometry> h; 00050 setup.get<MuonGeometryRecord>().get( h ); 00051 const CSCGeometry* pgeom = &*h; 00052 recHitBuilder_->setGeometry( pgeom ); 00053 00054 // access conditions data for this event 00055 if ( useCalib ) { 00056 recoConditions_->initializeEvent( setup ); 00057 } 00058 00059 // Get the collections of strip & wire digis from event 00060 edm::Handle<CSCStripDigiCollection> stripDigis; 00061 edm::Handle<CSCWireDigiCollection> wireDigis; 00062 ev.getByLabel( stripDigiTag_, stripDigis); 00063 ev.getByLabel( wireDigiTag_, wireDigis); 00064 00065 // Create empty collection of rechits 00066 std::auto_ptr<CSCRecHit2DCollection> oc( new CSCRecHit2DCollection ); 00067 00068 00069 // Fill the CSCRecHit2DCollection 00070 recHitBuilder_->build( stripDigis.product(), wireDigis.product(),*oc); 00071 00072 00073 // Put collection in event 00074 LogTrace("CSCRecHit")<< "Will output rechits collection to event" << "\n"; 00075 ev.put( oc ); 00076 00077 } 00078 00079 //define this as a plug-in 00080 DEFINE_FWK_MODULE(CSCRecHitDProducer); 00081