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 collection_for_XF = ps.getParameter<std::string>("InputCollection");
00063
00064 }
00065
00066
00067 CSCDigiProducer::~CSCDigiProducer()
00068 {
00069 delete theStripConditions;
00070 }
00071
00072
00073 void CSCDigiProducer::produce(edm::Event& e, const edm::EventSetup& eventSetup) {
00074
00075 edm::Handle<CrossingFrame<PSimHit> > cf;
00076 e.getByLabel("mix", collection_for_XF, cf);
00077
00078 std::auto_ptr<MixCollection<PSimHit> >
00079 hits( new MixCollection<PSimHit>(cf.product()) );
00080
00081
00082
00083 std::auto_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
00084 std::auto_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
00085 std::auto_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
00086 std::auto_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks() );
00087 std::auto_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks() );
00088
00089
00090 if(hits->size() > 0)
00091 {
00092
00093 edm::ESHandle<CSCGeometry> hGeom;
00094 eventSetup.get<MuonGeometryRecord>().get(geometryType,hGeom);
00095 const CSCGeometry *pGeom = &*hGeom;
00096
00097 theDigitizer.setGeometry( pGeom );
00098
00099
00100 edm::ESHandle<MagneticField> magfield;
00101 eventSetup.get<IdealMagneticFieldRecord>().get(magfield);
00102
00103 theDigitizer.setMagneticField(&*magfield);
00104
00105
00106
00107 edm::ESHandle < ParticleDataTable > pdt;
00108 eventSetup.getData( pdt );
00109 theDigitizer.setParticleDataTable(&*pdt);
00110
00111 theStripConditions->initializeEvent(eventSetup);
00112
00113
00114 theDigitizer.doAction(*hits, *pWireDigis, *pStripDigis, *pComparatorDigis,
00115 *pWireDigiSimLinks, *pStripDigiSimLinks);
00116 }
00117
00118
00119
00120 e.put(pWireDigis, "MuonCSCWireDigi");
00121 e.put(pStripDigis, "MuonCSCStripDigi");
00122 e.put(pComparatorDigis, "MuonCSCComparatorDigi");
00123 e.put(pWireDigiSimLinks, "MuonCSCWireDigiSimLinks");
00124 e.put(pStripDigiSimLinks, "MuonCSCStripDigiSimLinks");
00125 }
00126