CMS 3D CMS Logo

CSCDigiProducer.cc
Go to the documentation of this file.
2 
4 
7 
17 
18 #include <string>
19 
20 CSCDigiProducer::CSCDigiProducer(const edm::ParameterSet &ps) : theDigitizer(ps), theStripConditions(nullptr) {
21  geom_Token =
22  esConsumes<CSCGeometry, MuonGeometryRecord>(edm::ESInputTag("", ps.getParameter<std::string>("GeometryType")));
23  magfield_Token = esConsumes<MagneticField, IdealMagneticFieldRecord>();
24  pdt_Token = esConsumes<ParticleDataTable, edm::DefaultRecord>();
25  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
26  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
27  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
28  produces<DigiSimLinks>("MuonCSCWireDigiSimLinks");
29  produces<DigiSimLinks>("MuonCSCStripDigiSimLinks");
30  std::string stripConditions(ps.getParameter<std::string>("stripConditions"));
31 
32  edm::ParameterSet stripPSet = ps.getParameter<edm::ParameterSet>("strips");
33  if (stripConditions == "Configurable") {
35  } else if (stripConditions == "Database") {
36  theStripConditions = new CSCDbStripConditions(stripPSet, consumesCollector());
37  } else {
38  throw cms::Exception("CSCDigiProducer") << "Bad option for strip conditions: " << stripConditions;
39  }
41 
43  if (!rng.isAvailable()) {
44  throw cms::Exception("Configuration") << "CSCDigitizer requires the RandomNumberGeneratorService\n"
45  "which is not present in the configuration file. You must add the "
46  "service\n"
47  "in the configuration file or remove the modules that require it.";
48  }
49 
50  std::string mix_ = ps.getParameter<std::string>("mixLabel");
51  std::string collection_ = ps.getParameter<std::string>("InputCollection");
52  cf_token = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_));
53 }
54 
56 
58  edm::LogVerbatim("CSCDigitizer") << "[CSCDigiProducer::produce] starting event " << ev.id().event() << " of run "
59  << ev.id().run();
61  CLHEP::HepRandomEngine *engine = &rng->getEngine(ev.streamID());
62 
64  ev.getByToken(cf_token, cf);
65 
66  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
67 
68  // Create empty output
69 
70  std::unique_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
71  std::unique_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
72  std::unique_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
73  std::unique_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks());
74  std::unique_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks());
75 
76  //@@ DOES NOTHING IF NO HITS. Remove this for when there's real neutrons
77  if (hits->size() > 0) {
78  // find the geometry & conditions for this event
80  const CSCGeometry *pGeom = &*hGeom;
81 
83 
84  // find the magnetic field
86 
88 
89  // set the particle table
92 
94 
95  // run the digitizer
97  *hits, *pWireDigis, *pStripDigis, *pComparatorDigis, *pWireDigiSimLinks, *pStripDigiSimLinks, engine);
98  }
99 
100  // store them in the event
101  ev.put(std::move(pWireDigis), "MuonCSCWireDigi");
102  ev.put(std::move(pStripDigis), "MuonCSCStripDigi");
103  ev.put(std::move(pComparatorDigis), "MuonCSCComparatorDigi");
104  ev.put(std::move(pWireDigiSimLinks), "MuonCSCWireDigiSimLinks");
105  ev.put(std::move(pStripDigiSimLinks), "MuonCSCStripDigiSimLinks");
106 }
Log< level::Info, true > LogVerbatim
CSCDigiProducer(const edm::ParameterSet &ps)
CSCDigitizer::DigiSimLinks DigiSimLinks
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void produce(edm::Event &e, const edm::EventSetup &c) override
CSCDigitizer theDigitizer
T const * product() const
Definition: Handle.h:70
MuonDigiCollection< CSCDetId, CSCStripDigi > CSCStripDigiCollection
CSCStripConditions * theStripConditions
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
virtual void initializeEvent(const edm::EventSetup &es)
MuonDigiCollection< CSCDetId, CSCComparatorDigi > CSCComparatorDigiCollection
~CSCDigiProducer() override
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfield_Token
void setStripConditions(CSCStripConditions *cond)
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > geom_Token
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
void setParticleDataTable(const ParticleDataTable *pdt)
void doAction(MixCollection< PSimHit > &simHits, CSCWireDigiCollection &wireDigis, CSCStripDigiCollection &stripDigis, CSCComparatorDigiCollection &comparators, DigiSimLinks &wireDigiSimLinks, DigiSimLinks &stripDigiSimLinks, CLHEP::HepRandomEngine *)
Definition: CSCDigitizer.cc:39
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdt_Token
void setGeometry(const CSCGeometry *geom)
sets geometry
Definition: CSCDigitizer.h:62
bool isAvailable() const
Definition: Service.h:40
void setMagneticField(const MagneticField *field)
sets the magnetic field
def move(src, dest)
Definition: eostools.py:511