CMS 3D CMS Logo

RPCDigiProducer.cc
Go to the documentation of this file.
16 #include <sstream>
17 #include <string>
18 
19 #include <map>
20 #include <vector>
21 
24 
25 //Random Number
29 #include "CLHEP/Random/RandFlat.h"
30 
31 namespace CLHEP {
32  class HepRandomEngine;
33 }
34 
36  produces<RPCDigiCollection>();
37  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
38 
39  //Name of Collection used for create the XF
40  mix_ = ps.getParameter<std::string>("mixLabel");
41  collection_for_XF = ps.getParameter<std::string>("InputCollection");
42 
44  if (!rng.isAvailable()) {
45  throw cms::Exception("Configuration")
46  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
47  "which is not present in the configuration file. You must add the service\n"
48  "in the configuration file or remove the modules that require it.";
49  }
50  theRPCSimSetUp = new RPCSimSetUp(ps);
51  theDigitizer = new RPCDigitizer(ps);
52  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
53  geomToken = esConsumes<RPCGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
54  noiseToken = esConsumes<RPCStripNoises, RPCStripNoisesRcd, edm::Transition::BeginRun>();
55  clsToken = esConsumes<RPCClusterSize, RPCClusterSizeRcd, edm::Transition::BeginRun>();
56 }
57 
59  delete theDigitizer;
60  delete theRPCSimSetUp;
61 }
62 
65  const RPCGeometry* pGeom = &*hGeom;
66 
68 
70 
72  theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
73  // theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), noiseRcd->getCls());
74 
75  theDigitizer->setGeometry(pGeom);
76  // theRPCSimSetUp->setGeometry( pGeom );
78 }
79 
82  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
83 
84  LogDebug("RPCDigiProducer") << "[RPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from the "
85  "edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
86  LogDebug("RPCDigiProducer") << "[RPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing once RandFlat "
87  "---- this must be the first time in SimMuon/RPCDigitizer";
88  LogDebug("RPCDigiProducer")
89  << "[RPCDigiProducer::produce] to activate the test go in RPCDigiProducer.cc and uncomment the line below";
90  // LogDebug ("RPCDigiProducer")<<"[RPCDigiProducer::produce] Fired RandFlat :: "<<CLHEP::RandFlat::shoot(engine);
91 
93  // Obsolate code, based on getByLabel
94  // e.getByLabel(mix_, collection_for_XF, cf);
95  //New code, based on tokens
96  e.getByToken(crossingFrameToken, cf);
97 
98  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
99 
100  // Create empty output
101  std::unique_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
102  std::unique_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks());
103 
104  // run the digitizer
105  theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine);
106 
107  // store them in the event
108  e.put(std::move(pDigis));
109  e.put(std::move(RPCDigitSimLink), "RPCDigiSimLink");
110 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string mix_
std::string collection_for_XF
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > geomToken
T const * product() const
Definition: Handle.h:70
std::vector< NoiseItem > const & getVNoise() const
RPCDigiProducer(const edm::ParameterSet &ps)
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
RPCSimSetUp * theRPCSimSetUp
edm::ESGetToken< RPCStripNoises, RPCStripNoisesRcd > noiseToken
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCDigitizer.h:48
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
void doAction(MixCollection< PSimHit > &simHits, RPCDigiCollection &rpcDigis, RPCDigiSimLinks &rpcDigiSimLink, CLHEP::HepRandomEngine *)
Definition: RPCDigitizer.cc:19
edm::ESGetToken< RPCClusterSize, RPCClusterSizeRcd > clsToken
RPCDigitizer::RPCDigiSimLinks RPCDigitizerSimLinks
std::vector< ClusterSizeItem > const & getCls() const
void produce(edm::Event &e, const edm::EventSetup &c) override
void beginRun(const edm::Run &, const edm::EventSetup &) override
RPCDigitizer * theDigitizer
~RPCDigiProducer() override
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
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken
#define LogDebug(id)