CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
87  theDigitizer.setMagneticField(&*magfield);
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 }
RunNumber_t run() const
Definition: EventID.h:38
Log< level::Info, true > LogVerbatim
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:133
void produce(edm::Event &e, const edm::EventSetup &c) override
CSCDigitizer theDigitizer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
def move
Definition: eostools.py:511
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfield_Token
bool isAvailable() const
Definition: Service.h:40
void setStripConditions(CSCStripConditions *cond)
edm::ESGetToken< CSCGeometry, MuonGeometryRecord > geom_Token
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
T const * product() const
Definition: Handle.h:70
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
StreamID streamID() const
Definition: Event.h:98
edm::ESGetToken< ParticleDataTable, edm::DefaultRecord > pdt_Token
void setGeometry(const CSCGeometry *geom)
sets geometry
Definition: CSCDigitizer.h:62
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
void setMagneticField(const MagneticField *field)
sets the magnetic field