CMS 3D CMS Logo

CSCDigiProducer.cc
Go to the documentation of this file.
2 
4 
7 
9 
12 
14 
24 
25 #include <string>
26 
27 CSCDigiProducer::CSCDigiProducer(const edm::ParameterSet &ps) : theDigitizer(ps), theStripConditions(nullptr) {
28  produces<CSCWireDigiCollection>("MuonCSCWireDigi");
29  produces<CSCStripDigiCollection>("MuonCSCStripDigi");
30  produces<CSCComparatorDigiCollection>("MuonCSCComparatorDigi");
31  produces<DigiSimLinks>("MuonCSCWireDigiSimLinks");
32  produces<DigiSimLinks>("MuonCSCStripDigiSimLinks");
33  std::string stripConditions(ps.getParameter<std::string>("stripConditions"));
34  geometryType = ps.getParameter<std::string>("GeometryType");
35  edm::ParameterSet stripPSet = ps.getParameter<edm::ParameterSet>("strips");
36  if (stripConditions == "Configurable") {
38  } else if (stripConditions == "Database") {
40  } else {
41  throw cms::Exception("CSCDigiProducer") << "Bad option for strip conditions: " << stripConditions;
42  }
44 
46  if (!rng.isAvailable()) {
47  throw cms::Exception("Configuration") << "CSCDigitizer requires the RandomNumberGeneratorService\n"
48  "which is not present in the configuration file. You must add the "
49  "service\n"
50  "in the configuration file or remove the modules that require it.";
51  }
52 
53  std::string mix_ = ps.getParameter<std::string>("mixLabel");
54  std::string collection_ = ps.getParameter<std::string>("InputCollection");
55  cf_token = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_));
56 }
57 
59 
61  edm::LogVerbatim("CSCDigitizer") << "[CSCDigiProducer::produce] starting event " << ev.id().event() << " of run "
62  << ev.id().run();
64  CLHEP::HepRandomEngine *engine = &rng->getEngine(ev.streamID());
65 
67  ev.getByToken(cf_token, cf);
68 
69  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
70 
71  // Create empty output
72 
73  std::unique_ptr<CSCWireDigiCollection> pWireDigis(new CSCWireDigiCollection());
74  std::unique_ptr<CSCStripDigiCollection> pStripDigis(new CSCStripDigiCollection());
75  std::unique_ptr<CSCComparatorDigiCollection> pComparatorDigis(new CSCComparatorDigiCollection());
76  std::unique_ptr<DigiSimLinks> pWireDigiSimLinks(new DigiSimLinks());
77  std::unique_ptr<DigiSimLinks> pStripDigiSimLinks(new DigiSimLinks());
78 
79  //@@ DOES NOTHING IF NO HITS. Remove this for when there's real neutrons
80  if (hits->size() > 0) {
81  // find the geometry & conditions for this event
83  eventSetup.get<MuonGeometryRecord>().get(geometryType, hGeom);
84  const CSCGeometry *pGeom = &*hGeom;
85 
87 
88  // find the magnetic field
90  eventSetup.get<IdealMagneticFieldRecord>().get(magfield);
91 
92  theDigitizer.setMagneticField(&*magfield);
93 
94  // set the particle table
96  eventSetup.getData(pdt);
98 
100 
101  // run the digitizer
103  *hits, *pWireDigis, *pStripDigis, *pComparatorDigis, *pWireDigiSimLinks, *pStripDigiSimLinks, engine);
104  }
105 
106  // store them in the event
107  ev.put(std::move(pWireDigis), "MuonCSCWireDigi");
108  ev.put(std::move(pStripDigis), "MuonCSCStripDigi");
109  ev.put(std::move(pComparatorDigis), "MuonCSCComparatorDigi");
110  ev.put(std::move(pWireDigiSimLinks), "MuonCSCWireDigiSimLinks");
111  ev.put(std::move(pStripDigiSimLinks), "MuonCSCStripDigiSimLinks");
112 }
RunNumber_t run() const
Definition: EventID.h:38
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:40
CSCDigiProducer(const edm::ParameterSet &ps)
CSCDigitizer::DigiSimLinks DigiSimLinks
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void produce(edm::Event &e, const edm::EventSetup &c) override
CSCDigitizer theDigitizer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
#define nullptr
MuonDigiCollection< CSCDetId, CSCStripDigi > CSCStripDigiCollection
CSCStripConditions * theStripConditions
bool ev
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
virtual void initializeEvent(const edm::EventSetup &es)
std::string geometryType
MuonDigiCollection< CSCDetId, CSCComparatorDigi > CSCComparatorDigiCollection
bool getData(T &iHolder) const
Definition: EventSetup.h:113
~CSCDigiProducer() override
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
bool isAvailable() const
Definition: Service.h:40
void setStripConditions(CSCStripConditions *cond)
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
T const * product() const
Definition: Handle.h:69
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::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:73
StreamID streamID() const
Definition: Event.h:96
void setGeometry(const CSCGeometry *geom)
sets geometry
Definition: CSCDigitizer.h:61
void setMagneticField(const MagneticField *field)
sets the magnetic field
def move(src, dest)
Definition: eostools.py:511