CMS 3D CMS Logo

RPCandIRPCDigiProducer.cc
Go to the documentation of this file.
17 #include <sstream>
18 #include <string>
19 
20 #include <map>
21 #include <vector>
22 
25 
26 //Random Number
30 #include "CLHEP/Random/RandFlat.h"
31 
32 namespace CLHEP {
33  class HepRandomEngine;
34 }
35 
37  produces<RPCDigiCollection>();
38  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
39 
40  //Name of Collection used for create the XF
41  mix_ = ps.getParameter<std::string>("mixLabel");
42  collection_for_XF = ps.getParameter<std::string>("InputCollection");
43 
45  if (!rng.isAvailable()) {
46  throw cms::Exception("Configuration")
47  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
48  "which is not present in the configuration file. You must add the service\n"
49  "in the configuration file or remove the modules that require it.";
50  };
51 
54  theRPCDigitizer = new RPCDigitizer(ps);
56  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
57  geomToken = esConsumes<RPCGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
58  noiseToken = esConsumes<RPCStripNoises, RPCStripNoisesRcd, edm::Transition::BeginRun>();
59  clsToken = esConsumes<RPCClusterSize, RPCClusterSizeRcd, edm::Transition::BeginRun>();
60 }
61 
63  delete theRPCDigitizer;
64  delete theIRPCDigitizer;
65  delete theRPCSimSetUpRPC;
66  delete theRPCSimSetUpIRPC;
67 }
68 
71  const RPCGeometry* pGeom = &*hGeom;
72  _pGeom = &*hGeom;
74 
76 
77  //setup the two digi models
79  theRPCSimSetUpRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
81  theRPCSimSetUpIRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
82 
83  //setup the two digitizers
88 }
89 
92  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
93 
94  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from "
95  "the edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
96  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing "
97  "once RandFlat ---- this must be the first time in SimMuon/RPCDigitizer";
98  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] to activate the test go in "
99  "RPCandIRPCDigiProducer.cc and uncomment the line below";
100 
102  e.getByToken(crossingFrameToken, cf);
103 
104  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
105 
106  // Create empty output
107  std::unique_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
108  std::unique_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks());
109 
110  theRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "bakelite RPC" digitizer do the action
111  theIRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "IRPC" digitizer do the action
112 
113  e.put(std::move(pDigis));
114  //store the SimDigiLinks in the event
115  e.put(std::move(RPCDigitSimLink), "RPCDigiSimLink");
116 }
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken
RPCandIRPCDigiProducer(const edm::ParameterSet &ps)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const * product() const
Definition: Handle.h:70
std::vector< NoiseItem > const & getVNoise() const
void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCDigitizer.h:46
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCSimSetUp.h:46
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCDigitizer.h:48
void doAction(MixCollection< PSimHit > &simHits, RPCDigiCollection &rpcDigis, RPCDigiSimLinks &rpcDigiSimLink, CLHEP::HepRandomEngine *)
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
edm::ESGetToken< RPCClusterSize, RPCClusterSizeRcd > clsToken
void produce(edm::Event &e, const edm::EventSetup &c) override
void doAction(MixCollection< PSimHit > &simHits, RPCDigiCollection &rpcDigis, RPCDigiSimLinks &rpcDigiSimLink, CLHEP::HepRandomEngine *)
Definition: RPCDigitizer.cc:19
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: IRPCDigitizer.h:48
const RPCGeometry * _pGeom
edm::ESGetToken< RPCStripNoises, RPCStripNoisesRcd > noiseToken
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken
std::vector< ClusterSizeItem > const & getCls() const
RPCDigitizer::RPCDigiSimLinks RPCDigitizerSimLinks
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: IRPCDigitizer.h:46
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)
Definition: RPCSimSetUp.cc:41
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
#define LogDebug(id)