Go to the documentation of this file.00001 #include "SimMuon/GEMDigitizer/src/GEMDigiProducer.h"
00002 #include "SimMuon/GEMDigitizer/src/GEMSimSetUp.h"
00003 #include "SimMuon/GEMDigitizer/src/GEMSynchronizer.h"
00004
00005 #include "FWCore/Framework/interface/MakerMacros.h"
00006 #include "FWCore/Framework/interface/EDProducer.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/ServiceRegistry/interface/Service.h"
00009 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00012 #include "FWCore/Utilities/interface/Exception.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00015 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00016
00017 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00018 #include "CLHEP/Random/RandomEngine.h"
00019
00020 #include "CondFormats/DataRecord/interface/RPCStripNoisesRcd.h"
00021 #include "CondFormats/RPCObjects/interface/RPCClusterSize.h"
00022 #include "CondFormats/DataRecord/interface/RPCClusterSizeRcd.h"
00023
00024 #include <sstream>
00025 #include <string>
00026 #include <map>
00027 #include <vector>
00028
00029
00030 GEMDigiProducer::GEMDigiProducer(const edm::ParameterSet& ps)
00031 {
00032 produces<GEMDigiCollection>();
00033 produces<StripDigiSimLinks>("GEM");
00034
00035
00036 collectionXF_ = ps.getParameter<std::string>("InputCollection");
00037
00038 edm::Service<edm::RandomNumberGenerator> rng;
00039 if ( ! rng.isAvailable())
00040 {
00041 throw cms::Exception("Configuration")
00042 << "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
00043 << "Add the service in the configuration file or remove the modules that require it.";
00044 }
00045 CLHEP::HepRandomEngine& engine = rng->getEngine();
00046
00047 gemSimSetUp_ = new GEMSimSetUp(ps);
00048 digitizer_ = new GEMDigitizer(ps, engine);
00049 }
00050
00051
00052 GEMDigiProducer::~GEMDigiProducer()
00053 {
00054 delete digitizer_;
00055 delete gemSimSetUp_;
00056 }
00057
00058
00059 void GEMDigiProducer::beginRun( edm::Run& r, const edm::EventSetup& eventSetup)
00060 {
00061 edm::ESHandle<GEMGeometry> hGeom;
00062 eventSetup.get<MuonGeometryRecord>().get( hGeom );
00063 const GEMGeometry *pGeom = &*hGeom;
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 std::vector<RPCStripNoises::NoiseItem> vnoise;
00076 std::vector<float> vcls;
00077
00078 gemSimSetUp_->setGeometry( pGeom );
00079 if (vnoise.size()==0 && vcls.size()==0)
00080 gemSimSetUp_->setup();
00081 else
00082 gemSimSetUp_->setup(vnoise, vcls);
00083
00084 digitizer_->setGeometry( pGeom );
00085 digitizer_->setGEMSimSetUp( gemSimSetUp_ );
00086 }
00087
00088
00089 void GEMDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup)
00090 {
00091 edm::Handle<CrossingFrame<PSimHit> > cf;
00092 e.getByLabel("mix", collectionXF_, cf);
00093
00094 std::auto_ptr<MixCollection<PSimHit> > hits( new MixCollection<PSimHit>(cf.product()) );
00095
00096
00097 std::auto_ptr<GEMDigiCollection> pDigis(new GEMDigiCollection());
00098 std::auto_ptr<StripDigiSimLinks> digiSimLinks(new StripDigiSimLinks() );
00099
00100
00101 digitizer_->digitize(*hits, *pDigis, *digiSimLinks);
00102
00103
00104 e.put(pDigis);
00105 e.put(digiSimLinks,"GEM");
00106 }
00107