CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RPCandIRPCDigiProducer.cc
Go to the documentation of this file.
18 #include <sstream>
19 #include <string>
20 
21 #include <map>
22 #include <vector>
23 
26 
27 //Random Number
31 #include "CLHEP/Random/RandFlat.h"
32 
33 namespace CLHEP {
34  class HepRandomEngine;
35 }
36 
38  produces<RPCDigiCollection>();
39  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
40 
41  //Name of Collection used for create the XF
42  mix_ = ps.getParameter<std::string>("mixLabel");
43  collection_for_XF = ps.getParameter<std::string>("InputCollection");
44 
46  if (!rng.isAvailable()) {
47  throw cms::Exception("Configuration")
48  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
49  "which is not present in the configuration file. You must add the service\n"
50  "in the configuration file or remove the modules that require it.";
51  };
52 
55  theRPCDigitizer = new RPCDigitizer(ps);
57  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
58  geomToken = esConsumes<RPCGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
59  noiseToken = esConsumes<RPCStripNoises, RPCStripNoisesRcd, edm::Transition::BeginRun>();
60  clsToken = esConsumes<RPCClusterSize, RPCClusterSizeRcd, edm::Transition::BeginRun>();
61 }
62 
64  delete theRPCDigitizer;
65  delete theIRPCDigitizer;
66  delete theRPCSimSetUpRPC;
67  delete theRPCSimSetUpIRPC;
68 }
69 
72  const RPCGeometry* pGeom = &*hGeom;
73  _pGeom = &*hGeom;
74  edm::ESHandle<RPCStripNoises> noiseRcd = eventSetup.getHandle(noiseToken);
75 
77 
78  //setup the two digi models
80  theRPCSimSetUpRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
82  theRPCSimSetUpIRPC->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
83 
84  //setup the two digitizers
89 }
90 
93  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
94 
95  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from "
96  "the edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
97  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing "
98  "once RandFlat ---- this must be the first time in SimMuon/RPCDigitizer";
99  LogDebug("RPCandIRPCDigiProducer") << "[RPCandIRPCDigiProducer::produce] to activate the test go in "
100  "RPCandIRPCDigiProducer.cc and uncomment the line below";
101 
104 
105  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
106 
107  // Create empty output
108  std::unique_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
109  std::unique_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks());
110 
111  theRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "bakelite RPC" digitizer do the action
112  theIRPCDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine); //make "IRPC" digitizer do the action
113 
114  e.put(std::move(pDigis));
115  //store the SimDigiLinks in the event
116  e.put(std::move(RPCDigitSimLink), "RPCDigiSimLink");
117 }
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken
RPCandIRPCDigiProducer(const edm::ParameterSet &ps)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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:47
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
def move
Definition: eostools.py:511
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
T const * product() const
Definition: Handle.h:70
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: IRPCDigitizer.h:48
const RPCGeometry * _pGeom
edm::ESGetToken< RPCStripNoises, RPCStripNoisesRcd > noiseToken
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken
StreamID streamID() const
Definition: Event.h:98
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157
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:42
Definition: Run.h:45
#define LogDebug(id)