CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMDigiProducer.cc
Go to the documentation of this file.
4 
16 
18 #include "CLHEP/Random/RandomEngine.h"
19 
23 
24 #include <sstream>
25 #include <string>
26 #include <map>
27 #include <vector>
28 
29 
31 {
32  produces<GEMDigiCollection>();
33  produces<StripDigiSimLinks>("GEM");
34 
35  //Name of Collection used for create the XF
36  collectionXF_ = ps.getParameter<std::string>("InputCollection");
37 
39  if ( ! rng.isAvailable())
40  {
41  throw cms::Exception("Configuration")
42  << "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
43  << "Add the service in the configuration file or remove the modules that require it.";
44  }
45  CLHEP::HepRandomEngine& engine = rng->getEngine();
46 
47  gemSimSetUp_ = new GEMSimSetUp(ps);
48  digitizer_ = new GEMDigitizer(ps, engine);
49 }
50 
51 
53 {
54  delete digitizer_;
55  delete gemSimSetUp_;
56 }
57 
58 
59 void GEMDigiProducer::beginRun( const edm::Run& r, const edm::EventSetup& eventSetup)
60 {
62  eventSetup.get<MuonGeometryRecord>().get( hGeom );
63  const GEMGeometry *pGeom = &*hGeom;
64 
65  /*
66  edm::ESHandle<RPCStripNoises> noiseRcd;
67  eventSetup.get<RPCStripNoisesRcd>().get(noiseRcd);
68 
69  edm::ESHandle<RPCClusterSize> clsRcd;
70  eventSetup.get<RPCClusterSizeRcd>().get(clsRcd);
71 
72  auto vnoise = noiseRcd->getVNoise();
73  auto vcls = clsRcd->getCls();
74  */
75  std::vector<RPCStripNoises::NoiseItem> vnoise;
76  std::vector<float> vcls;
77 
78  gemSimSetUp_->setGeometry( pGeom );
79  if (vnoise.size()==0 && vcls.size()==0)
81  else
82  gemSimSetUp_->setup(vnoise, vcls);
83 
84  digitizer_->setGeometry( pGeom );
86 }
87 
88 
90 {
92  e.getByLabel("mix", collectionXF_, cf);
93 
94  std::auto_ptr<MixCollection<PSimHit> > hits( new MixCollection<PSimHit>(cf.product()) );
95 
96  // Create empty output
97  std::auto_ptr<GEMDigiCollection> pDigis(new GEMDigiCollection());
98  std::auto_ptr<StripDigiSimLinks> digiSimLinks(new StripDigiSimLinks() );
99 
100  // run the digitizer
101  digitizer_->digitize(*hits, *pDigis, *digiSimLinks);
102 
103  // store them in the event
104  e.put(pDigis);
105  e.put(digiSimLinks,"GEM");
106 }
107 
T getParameter(std::string const &) const
GEMDigitizer::StripDigiSimLinks StripDigiSimLinks
GEMSimSetUp * gemSimSetUp_
GEMDigitizer * digitizer_
void setGeometry(const GEMGeometry *geom)
Definition: GEMSimSetUp.h:41
MuonDigiCollection< GEMDetId, GEMDigi > GEMDigiCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
GEMDigiProducer(const edm::ParameterSet &ps)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void setGeometry(const GEMGeometry *geom)
sets geometry
Definition: GEMDigitizer.h:43
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
virtual ~GEMDigiProducer()
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override
void digitize(MixCollection< PSimHit > &simHits, GEMDigiCollection &rpcDigis, StripDigiSimLinks &digiSimLinks)
Definition: GEMDigitizer.cc:25
void setGEMSimSetUp(GEMSimSetUp *simsetup)
Definition: GEMDigitizer.h:45
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
std::string collectionXF_
Definition: Run.h:36
void setup()
Definition: GEMSimSetUp.cc:63