CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
34 namespace CLHEP {
35  class HepRandomEngine;
36 }
37 
39 
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){
65 
67  eventSetup.get<MuonGeometryRecord>().get( hGeom );
68  const RPCGeometry *pGeom = &*hGeom;
69 
71  eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
72 
74  eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
75 
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 
85 
87  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
88 
90  // Obsolate code, based on getByLabel
91  // e.getByLabel(mix_, collection_for_XF, cf);
92  //New code, based on tokens
94 
95  std::auto_ptr<MixCollection<PSimHit> >
96  hits( new MixCollection<PSimHit>(cf.product()) );
97 
98  // Create empty output
99  std::auto_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
100  std::auto_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks() );
101 
102  // run the digitizer
103  theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine);
104 
105  // store them in the event
106  e.put(pDigis);
107  e.put(RPCDigitSimLink,"RPCDigiSimLink");
108 }
109 
T getParameter(std::string const &) const
std::string mix_
std::string collection_for_XF
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
RPCDigiProducer(const edm::ParameterSet &ps)
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCDigitizer.h:50
void setGeometry(const RPCGeometry *geom)
sets geometry
Definition: RPCSimSetUp.h:48
RPCSimSetUp * theRPCSimSetUp
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCDigitizer.h:52
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
void doAction(MixCollection< PSimHit > &simHits, RPCDigiCollection &rpcDigis, RPCDigiSimLinks &rpcDigiSimLink, CLHEP::HepRandomEngine *)
Definition: RPCDigitizer.cc:24
virtual ~RPCDigiProducer()
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
RPCDigitizer::RPCDigiSimLinks RPCDigitizerSimLinks
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
StreamID streamID() const
Definition: Event.h:72
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
RPCDigitizer * theDigitizer
void setRPCSetUp(const std::vector< RPCStripNoises::NoiseItem > &vnoise, const std::vector< float > &vcls)
Definition: RPCSimSetUp.cc:45
Definition: Run.h:41
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken