CMS 3D CMS Logo

RPCDigiProducer.cc
Go to the documentation of this file.
20 #include <sstream>
21 #include <string>
22 
23 #include <map>
24 #include <vector>
25 
28 
29 //Random Number
33 #include "CLHEP/Random/RandFlat.h"
34 
35 namespace CLHEP {
36  class HepRandomEngine;
37 }
38 
40  produces<RPCDigiCollection>();
41  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
42 
43  //Name of Collection used for create the XF
44  mix_ = ps.getParameter<std::string>("mixLabel");
45  collection_for_XF = ps.getParameter<std::string>("InputCollection");
46 
48  if (!rng.isAvailable()) {
49  throw cms::Exception("Configuration")
50  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
51  "which is not present in the configuration file. You must add the service\n"
52  "in the configuration file or remove the modules that require it.";
53  }
54  theRPCSimSetUp = new RPCSimSetUp(ps);
55  theDigitizer = new RPCDigitizer(ps);
56  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_, collection_for_XF));
57 }
58 
60  delete theDigitizer;
61  delete theRPCSimSetUp;
62 }
63 
64 void RPCDigiProducer::beginRun(const edm::Run& r, const edm::EventSetup& eventSetup) {
66  eventSetup.get<MuonGeometryRecord>().get(hGeom);
67  const RPCGeometry* pGeom = &*hGeom;
68 
70  eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
71 
73  eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
74 
76  theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
77  // theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), noiseRcd->getCls());
78 
79  theDigitizer->setGeometry(pGeom);
80  // theRPCSimSetUp->setGeometry( pGeom );
82 }
83 
86  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
87 
88  LogDebug("RPCDigiProducer") << "[RPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from the "
89  "edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
90  LogDebug("RPCDigiProducer") << "[RPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing once RandFlat "
91  "---- this must be the first time in SimMuon/RPCDigitizer";
92  LogDebug("RPCDigiProducer")
93  << "[RPCDigiProducer::produce] to activate the test go in RPCDigiProducer.cc and uncomment the line below";
94  // LogDebug ("RPCDigiProducer")<<"[RPCDigiProducer::produce] Fired RandFlat :: "<<CLHEP::RandFlat::shoot(engine);
95 
97  // Obsolate code, based on getByLabel
98  // e.getByLabel(mix_, collection_for_XF, cf);
99  //New code, based on tokens
100  e.getByToken(crossingFrameToken, cf);
101 
102  std::unique_ptr<MixCollection<PSimHit>> hits(new MixCollection<PSimHit>(cf.product()));
103 
104  // Create empty output
105  std::unique_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
106  std::unique_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks());
107 
108  // run the digitizer
109  theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine);
110 
111  // store them in the event
112  e.put(std::move(pDigis));
113  e.put(std::move(RPCDigitSimLink), "RPCDigiSimLink");
114 }
RPCStripNoises::getVNoise
std::vector< NoiseItem > const & getVNoise() const
Definition: RPCStripNoises.h:24
RPCDigitizer::doAction
void doAction(MixCollection< PSimHit > &simHits, RPCDigiCollection &rpcDigis, RPCDigiSimLinks &rpcDigiSimLink, CLHEP::HepRandomEngine *)
Definition: RPCDigitizer.cc:19
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Handle.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
RPCClusterSizeRcd
Definition: RPCClusterSizeRcd.h:24
RPCDigiProducer::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: RPCDigiProducer.cc:84
edm::Run
Definition: Run.h:45
RPCStripNoisesRcd
Definition: RPCStripNoisesRcd.h:24
RandomNumberGenerator.h
CrossingFrame.h
PSimHitContainer.h
RPCClusterSize::getCls
std::vector< ClusterSizeItem > const & getCls() const
Definition: RPCClusterSize.h:23
RPCDigitizer::setRPCSimSetUp
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCDigitizer.h:48
RPCDigiProducer::theDigitizer
RPCDigitizer * theDigitizer
Definition: RPCDigiProducer.h:36
RPCDigiProducer::theRPCSimSetUp
RPCSimSetUp * theRPCSimSetUp
Definition: RPCDigiProducer.h:37
RPCDigitizer
Definition: RPCDigitizer.h:33
RPCSimSetUp::setGeometry
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCSimSetUp.h:47
RPCDigiProducer.h
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
MixCollection.h
MixCollection
Definition: MixCollection.h:11
Service.h
IdealMagneticFieldRecord.h
edm::ESHandle< RPCGeometry >
CLHEP
Definition: CocoaGlobals.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCDetId.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
RPCDigiCollection
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
Definition: RPCDigiCollection.h:13
edm::Service< edm::RandomNumberGenerator >
RPCDigiProducer::RPCDigitizerSimLinks
RPCDigitizer::RPCDigiSimLinks RPCDigitizerSimLinks
Definition: RPCDigiProducer.h:23
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
RPCDigitizer.h
RPCDigiProducer::collection_for_XF
std::string collection_for_XF
Definition: RPCDigiProducer.h:41
RPCDigiProducer::RPCDigiProducer
RPCDigiProducer(const edm::ParameterSet &ps)
Definition: RPCDigiProducer.cc:39
Exception
Definition: hltDiff.cc:246
RPCDigiProducer::mix_
std::string mix_
Definition: RPCDigiProducer.h:40
RPCDigitizer::setGeometry
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCDigitizer.h:46
EventSetup.h
Exception.h
RPCSimSetUp.h
RPCGeometry
Definition: RPCGeometry.h:20
RPCSimSetUp
Definition: RPCSimSetUp.h:28
ParameterSet.h
RPCSimSetUp::setRPCSetUp
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)
Definition: RPCSimSetUp.cc:44
RPCDigiProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: RPCDigiProducer.cc:64
MuonGeometryRecord.h
RPCDigiProducer::crossingFrameToken
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken
Definition: RPCDigiProducer.h:44
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
RPCSynchronizer.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
RPCDigiProducer::~RPCDigiProducer
~RPCDigiProducer() override
Definition: RPCDigiProducer.cc:59