Go to the documentation of this file.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
00032 #include "FWCore/ServiceRegistry/interface/Service.h"
00033 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00034 #include "FWCore/Utilities/interface/Exception.h"
00035 #include "CLHEP/Random/RandomEngine.h"
00036
00037
00038
00039 RPCDigiProducer::RPCDigiProducer(const edm::ParameterSet& ps) {
00040
00041 produces<RPCDigiCollection>();
00042 produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
00043
00044
00045 collection_for_XF = ps.getParameter<std::string>("InputCollection");
00046
00047 edm::Service<edm::RandomNumberGenerator> rng;
00048 if ( ! rng.isAvailable()) {
00049 throw cms::Exception("Configuration")
00050 << "RPCDigitizer requires the RandomNumberGeneratorService\n"
00051 "which is not present in the configuration file. You must add the service\n"
00052 "in the configuration file or remove the modules that require it.";
00053 }
00054
00055
00056 CLHEP::HepRandomEngine& engine = rng->getEngine();
00057
00058 theRPCSimSetUp = new RPCSimSetUp(ps);
00059 theDigitizer = new RPCDigitizer(ps,engine);
00060
00061
00062 }
00063
00064 RPCDigiProducer::~RPCDigiProducer() {
00065 delete theDigitizer;
00066 delete theRPCSimSetUp;
00067 }
00068
00069 void RPCDigiProducer::beginRun( edm::Run& r, const edm::EventSetup& eventSetup){
00070
00071 edm::ESHandle<RPCGeometry> hGeom;
00072 eventSetup.get<MuonGeometryRecord>().get( hGeom );
00073 const RPCGeometry *pGeom = &*hGeom;
00074
00075 edm::ESHandle<RPCStripNoises> noiseRcd;
00076 eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
00077
00078 edm::ESHandle<RPCClusterSize> clsRcd;
00079 eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
00080
00081 theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
00082
00083
00084 theDigitizer->setGeometry( pGeom );
00085 theRPCSimSetUp->setGeometry( pGeom );
00086 theDigitizer->setRPCSimSetUp( theRPCSimSetUp );
00087 }
00088
00089 void RPCDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
00090
00091 edm::Handle<CrossingFrame<PSimHit> > cf;
00092 e.getByLabel("mix", collection_for_XF, cf);
00093
00094 std::auto_ptr<MixCollection<PSimHit> >
00095 hits( new MixCollection<PSimHit>(cf.product()) );
00096
00097
00098 std::auto_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
00099 std::auto_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks() );
00100
00101
00102 theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink);
00103
00104
00105 e.put(pDigis);
00106 e.put(RPCDigitSimLink,"RPCDigiSimLink");
00107 }
00108