CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCandIRPCDigiProducer.cc
Go to the documentation of this file.
21 #include <sstream>
22 #include <string>
23 
24 #include <map>
25 #include <vector>
26 
29 
30 //Random Number
34 #include "CLHEP/Random/RandFlat.h"
35 
36 namespace CLHEP {
37  class HepRandomEngine;
38 }
39 
41  produces<RPCDigiCollection>();
42  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
43 
44  //Name of Collection used for create the XF
45  mix_ = ps.getParameter<std::string>("mixLabel");
46  collection_for_XF = ps.getParameter<std::string>("InputCollection");
47 
49  if (!rng.isAvailable()) {
50  throw cms::Exception("Configuration")
51  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
52  "which is not present in the configuration file. You must add the service\n"
53  "in the configuration file or remove the modules that require it.";
54  };
55 
56  theRPCSimSetUpRPC = new RPCSimSetUp(ps);
57  theRPCSimSetUpIRPC = new RPCSimSetUp(ps);
58  theRPCDigitizer = new RPCDigitizer(ps);
59  theIRPCDigitizer = new IRPCDigitizer(ps);
60  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
61 }
62 
64  delete theRPCDigitizer;
65  delete theIRPCDigitizer;
66  delete theRPCSimSetUpRPC;
67  delete theRPCSimSetUpIRPC;
68 }
69 
72  eventSetup.get<MuonGeometryRecord>().get(hGeom);
73  const RPCGeometry* pGeom = &*hGeom;
74  _pGeom = &*hGeom;
76  eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
77 
79  eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
80 
81  //setup the two digi models
82  theRPCSimSetUpRPC->setGeometry(pGeom);
83  theRPCSimSetUpRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
84  theRPCSimSetUpIRPC->setGeometry(pGeom);
85  theRPCSimSetUpIRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
86 
87  //setup the two digitizers
88  theRPCDigitizer->setGeometry(pGeom);
89  theIRPCDigitizer->setGeometry(pGeom);
90  theRPCDigitizer->setRPCSimSetUp(theRPCSimSetUpRPC);
91  theIRPCDigitizer->setRPCSimSetUp(theRPCSimSetUpIRPC);
92 }
93 
96  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
97 
98  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from "
99  "the edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
100  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing "
101  "once RandFlat ---- this must be the first time in SimMuon/RPCDigitizer";
102  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] to activate the test go in "
103  "RPCandIRPCDigiProducer.cc and uncomment the line below";
104 
106  e.getByToken(crossingFrameToken, cf);
107 
108  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
109 
110  // Create empty output
111  std::unique_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
112  std::unique_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks());
113 
114  theRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "bakelite RPC" digitizer do the action
115  theIRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "IRPC" digitizer do the action
116 
117  e.put(std::move(pDigis));
118  //store the SimDigiLinks in the event
119  e.put(std::move(RPCDigitSimLink), "RPCDigiSimLink");
120 }
#define LogDebug(id)
T getParameter(std::string const &) const
RPCandIRPCDigiProducer(const edm::ParameterSet &ps)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
std::vector< NoiseItem > const & getVNoise() const
void produce(edm::Event &e, const edm::EventSetup &c) override
T const * product() const
Definition: Handle.h:69
T get() const
Definition: EventSetup.h:73
StreamID streamID() const
Definition: Event.h:96
std::vector< ClusterSizeItem > const & getCls() const
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45