CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/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 CSCRecHitDProducer::CSCRecHitDProducer( const edm::ParameterSet& ps ) : 
00022   iRun( 0 ),   
00023   useCalib( ps.getParameter<bool>("CSCUseCalibrations") ),
00024   useStaticPedestals( ps.getParameter<bool>("CSCUseStaticPedestals") ),
00025   useTimingCorrections(ps.getParameter<bool>("CSCUseTimingCorrections") ),
00026   useGasGainCorrections(ps.getParameter<bool>("CSCUseGasGainCorrections") ),
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   // Dumps the message TWICE if both categories are set!
00051   //  LogTrace("CSCRecHitDProducer|CSCRecHit")<< "[CSCRecHitDProducer] starting event " << ev.id().event() << " of run " << ev.id().run();
00052   LogTrace("CSCRecHit")<< "[CSCRecHitDProducer] starting event " << ev.id().event() << " of run " << ev.id().run();
00053   // find the geometry for this event & cache it in the builder
00054   edm::ESHandle<CSCGeometry> h;
00055   setup.get<MuonGeometryRecord>().get( h );
00056   const CSCGeometry* pgeom = &*h;
00057   recHitBuilder_->setGeometry( pgeom );
00058 
00059   // access conditions data for this event 
00060   if ( useCalib || useStaticPedestals || useTimingCorrections || useGasGainCorrections) {  
00061     recoConditions_->initializeEvent( setup ); 
00062   }
00063         
00064   // Get the collections of strip & wire digis from event
00065   edm::Handle<CSCStripDigiCollection> stripDigis;
00066   edm::Handle<CSCWireDigiCollection> wireDigis;
00067   ev.getByLabel( stripDigiTag_, stripDigis);
00068   ev.getByLabel( wireDigiTag_,  wireDigis);
00069 
00070   // Create empty collection of rechits  
00071   std::auto_ptr<CSCRecHit2DCollection> oc( new CSCRecHit2DCollection );
00072 
00073   // Fill the CSCRecHit2DCollection
00074   recHitBuilder_->build( stripDigis.product(), wireDigis.product(), *oc);
00075 
00076   // Put collection in event
00077   LogTrace("CSCRecHit")<< "[CSCRecHitDProducer] putting collection of " << oc->size() << " rechits into event.";
00078   ev.put( oc );
00079 
00080 }
00081 
00082 //define this as a plug-in
00083 DEFINE_FWK_MODULE(CSCRecHitDProducer);
00084