Go to the documentation of this file.00001 #include "DataFormats/Common/interface/Handle.h"
00002 #include "FWCore/Framework/interface/ESHandle.h"
00003 #include "SimMuon/CSCDigitizer/src/CSCDigiProducer.h"
00004 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00005 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00006 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00007 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00008 #include "SimMuon/CSCDigitizer/src/CSCConfigurableStripConditions.h"
00009 #include "SimMuon/CSCDigitizer/src/CSCDbStripConditions.h"
00010 #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
00017
00018
00019
00020 CSCDigiProducer::CSCDigiProducer(const edm::ParameterSet& ps)
00021 : theDigitizer(ps),
00022 theStripConditions(0)
00023 {
00024 produces<CSCWireDigiCollection>("MuonCSCWireDigi");
00025 produces<CSCStripDigiCollection>("MuonCSCStripDigi");
00026 produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
00027 produces<DigiSimLinks>("MuonCSCWireDigiSimLinks");
00028 produces<DigiSimLinks>("MuonCSCStripDigiSimLinks");
00029 std::string stripConditions( ps.getParameter<std::string>("stripConditions") );
00030 geometryType = ps.getParameter<std::string>("GeometryType");
00031 edm::ParameterSet stripPSet = ps.getParameter<edm::ParameterSet>("strips");
00032 if( stripConditions == "Configurable" )
00033 {
00034 theStripConditions = new CSCConfigurableStripConditions(stripPSet);
00035 }
00036 else if ( stripConditions == "Database" )
00037 {
00038 theStripConditions = new CSCDbStripConditions(stripPSet);
00039 }
00040 else
00041 {
00042 throw cms::Exception("CSCDigiProducer")
00043 << "Bad option for strip conditions: "
00044 << stripConditions;
00045 }
00046 theDigitizer.setStripConditions(theStripConditions);
00047
00048 edm::Service<edm::RandomNumberGenerator> rng;
00049 if ( ! rng.isAvailable()) {
00050 throw cms::Exception("Configuration")
00051 << "CSCDigitizer requires the RandomNumberGeneratorService\n"
00052 "which is not present in the configuration file. You must add the service\n"
00053 "in the configuration file or remove the modules that require it.";
00054 }
00055
00056 CLHEP::HepRandomEngine& engine = rng->getEngine();
00057
00058 theDigitizer.setRandomEngine(engine);
00059 theStripConditions->setRandomEngine(engine);
00060
00061
00062 mix_ = ps.getParameter<std::string>("mixLabel");
00063 collection_for_XF = ps.getParameter<std::string>("InputCollection");
00064
00065 }
00066
00067
00068 CSCDigiProducer::~CSCDigiProducer()
00069 {
00070 delete theStripConditions;
00071 }
00072
00073
00074 void CSCDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
00075
00076 edm::Handle<CrossingFrame<PSimHit> > cf;
00077 e.getByLabel(mix_, collection_for_XF, cf);
00078
00079 std::auto_ptr<MixCollection<PSimHit> >
00080 hits( new MixCollection<PSimHit>(cf.product()) );
00081
00082
00083
00084 std::auto_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
00085 std::auto_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
00086 std::auto_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
00087 std::auto_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks() );
00088 std::auto_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks() );
00089
00090
00091 if(hits->size() > 0)
00092 {
00093
00094 edm::ESHandle<CSCGeometry> hGeom;
00095 eventSetup.get<MuonGeometryRecord>().get(geometryType,hGeom);
00096 const CSCGeometry *pGeom = &*hGeom;
00097
00098 theDigitizer.setGeometry( pGeom );
00099
00100
00101 edm::ESHandle<MagneticField> magfield;
00102 eventSetup.get<IdealMagneticFieldRecord>().get(magfield);
00103
00104 theDigitizer.setMagneticField(&*magfield);
00105
00106
00107
00108 edm::ESHandle < ParticleDataTable > pdt;
00109 eventSetup.getData( pdt );
00110 theDigitizer.setParticleDataTable(&*pdt);
00111
00112 theStripConditions->initializeEvent(eventSetup);
00113
00114
00115 theDigitizer.doAction(*hits, *pWireDigis, *pStripDigis, *pComparatorDigis,
00116 *pWireDigiSimLinks, *pStripDigiSimLinks);
00117 }
00118
00119
00120
00121 e.put(pWireDigis, "MuonCSCWireDigi");
00122 e.put(pStripDigis, "MuonCSCStripDigi");
00123 e.put(pComparatorDigis, "MuonCSCComparatorDigi");
00124 e.put(pWireDigiSimLinks, "MuonCSCWireDigiSimLinks");
00125 e.put(pStripDigiSimLinks, "MuonCSCStripDigiSimLinks");
00126 }
00127