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 #include "CLHEP/Random/RandFlat.h"
34 
35 namespace CLHEP {
36  class HepRandomEngine;
37 }
38 
40 
41  produces<RPCDigiCollection>();
42  produces<RPCDigitizerSimLinks>("RPCDigiSimLink");
43 
44  //Name of Collection used for create the XF
45  mix_ = ps.getParameter<std::string>("mixLabel");
46  collection_for_XF = ps.getParameter<std::string>("InputCollection");
47 
49  if ( ! rng.isAvailable()) {
50  throw cms::Exception("Configuration")
51  << "RPCDigitizer requires the RandomNumberGeneratorService\n"
52  "which is not present in the configuration file. You must add the service\n"
53  "in the configuration file or remove the modules that require it.";
54  }
55  theRPCSimSetUp = new RPCSimSetUp(ps);
56  theDigitizer = new RPCDigitizer(ps);
57  crossingFrameToken = consumes<CrossingFrame<PSimHit>>(edm::InputTag(mix_,collection_for_XF));
58 }
59 
61  delete theDigitizer;
62  delete theRPCSimSetUp;
63 }
64 
65 void RPCDigiProducer::beginRun(const edm::Run& r, const edm::EventSetup& eventSetup){
66 
68  eventSetup.get<MuonGeometryRecord>().get( hGeom );
69  const RPCGeometry *pGeom = &*hGeom;
70 
72  eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
73 
75  eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
76 
77  theRPCSimSetUp->setGeometry( pGeom );
78  theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), clsRcd->getCls());
79 // theRPCSimSetUp->setRPCSetUp(noiseRcd->getVNoise(), noiseRcd->getCls());
80 
81  theDigitizer->setGeometry( pGeom );
82  // theRPCSimSetUp->setGeometry( pGeom );
84 }
85 
87 
89  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
90 
91  LogDebug ("RPCDigiProducer")<<"[RPCDigiProducer::produce] got the CLHEP::HepRandomEngine engine from the edm::Event.streamID() and edm::Service<edm::RandomNumberGenerator>";
92  LogDebug ("RPCDigiProducer")<<"[RPCDigiProducer::produce] test the CLHEP::HepRandomEngine by firing once RandFlat ---- this must be the first time in SimMuon/RPCDigitizer";
93  LogDebug ("RPCDigiProducer")<<"[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 
96 
98  // Obsolate code, based on getByLabel
99  // e.getByLabel(mix_, collection_for_XF, cf);
100  //New code, based on tokens
102 
103  std::auto_ptr<MixCollection<PSimHit> >
104  hits( new MixCollection<PSimHit>(cf.product()) );
105 
106  // Create empty output
107  std::auto_ptr<RPCDigiCollection> pDigis(new RPCDigiCollection());
108  std::auto_ptr<RPCDigitizerSimLinks> RPCDigitSimLink(new RPCDigitizerSimLinks() );
109 
110  // run the digitizer
111  theDigitizer->doAction(*hits, *pDigis, *RPCDigitSimLink, engine);
112 
113  // store them in the event
114  e.put(pDigis);
115  e.put(RPCDigitSimLink,"RPCDigiSimLink");
116 }
117 
#define LogDebug(id)
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:464
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:120
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:56
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:79
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:43
edm::EDGetTokenT< CrossingFrame< PSimHit > > crossingFrameToken