00001 #include "FWCore/Framework/interface/EDProducer.h" 00002 #include "DataFormats/Common/interface/Handle.h" 00003 #include "FWCore/Framework/interface/ESHandle.h" 00004 #include "SimMuon/RPCDigitizer/src/RPCSimSetUp.h" 00005 #include "SimMuon/RPCDigitizer/src/RPCDigiProducer.h" 00006 #include "SimMuon/RPCDigitizer/src/RPCDigitizer.h" 00007 #include "Geometry/Records/interface/MuonGeometryRecord.h" 00008 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" 00009 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h" 00010 #include "DataFormats/Common/interface/Handle.h" 00011 #include "FWCore/Framework/interface/ESHandle.h" 00012 #include "Geometry/Records/interface/MuonGeometryRecord.h" 00013 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" 00014 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h" 00015 #include "FWCore/ServiceRegistry/interface/Service.h" 00016 #include "FWCore/Utilities/interface/RandomNumberGenerator.h" 00017 #include "FWCore/Framework/interface/Event.h" 00018 #include "FWCore/Framework/interface/EventSetup.h" 00019 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00020 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" 00021 #include "SimMuon/RPCDigitizer/src/RPCSynchronizer.h" 00022 #include <sstream> 00023 #include <string> 00024 00025 #include <map> 00026 #include <vector> 00027 00028 #include "FWCore/Framework/interface/MakerMacros.h" 00029 #include "DataFormats/MuonDetId/interface/RPCDetId.h" 00030 00031 RPCDigiProducer::RPCDigiProducer(const edm::ParameterSet& ps) { 00032 00033 theRPCSimSetUp = new RPCSimSetUp(ps); 00034 theDigitizer = new RPCDigitizer(ps); 00035 00036 produces<RPCDigiCollection>(); 00037 produces<RPCDigitizerSimLinks>("RPCDigiSimLink"); 00038 00039 //Name of Collection used for create the XF 00040 collection_for_XF = ps.getParameter<std::string>("InputCollection"); 00041 } 00042 00043 RPCDigiProducer::~RPCDigiProducer() { 00044 delete theDigitizer; 00045 delete theRPCSimSetUp; 00046 } 00047 00048 void RPCDigiProducer::beginRun( edm::Run& r, const edm::EventSetup& eventSetup){ 00049 00050 edm::ESHandle<RPCGeometry> hGeom; 00051 eventSetup.get<MuonGeometryRecord>().get( hGeom ); 00052 const RPCGeometry *pGeom = &*hGeom; 00053 00054 edm::ESHandle<RPCStripNoises> noiseRcd; 00055 eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd); 00056 00057 theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), noiseRcd->getCls()); 00058 00059 theDigitizer->setGeometry( pGeom ); 00060 theRPCSimSetUp->setGeometry( pGeom ); 00061 theDigitizer->setRPCSimSetUp( theRPCSimSetUp ); 00062 } 00063 00064 void RPCDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) { 00065 00066 edm::Handle<CrossingFrame<PSimHit> > cf; 00067 e.getByLabel("mix", collection_for_XF, cf); 00068 00069 std::auto_ptr<MixCollection<PSimHit> > 00070 hits( new MixCollection<PSimHit>(cf.product()) ); 00071 00072 // Create empty output 00073 std::auto_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection()); 00074 std::auto_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks() ); 00075 00076 // run the digitizer 00077 theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink); 00078 00079 // store them in the event 00080 e.put(pDigis); 00081 e.put(RPCDigitSimLink,"RPCDigiSimLink"); 00082 } 00083