CMS 3D CMS Logo

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