CMS 3D CMS Logo

ME0DigiProducer.cc
Go to the documentation of this file.
1 #ifndef SimMuon_GEMDigitizer_ME0DigiProducer_h
2 #define SimMuon_GEMDigitizer_ME0DigiProducer_h
3 
17 
24 
27 
30 
31 #include <sstream>
32 #include <string>
33 #include <map>
34 #include <vector>
35 
36 namespace CLHEP {
37  class HepRandomEngine;
38 }
39 
41 public:
43 
44  explicit ME0DigiProducer(const edm::ParameterSet& ps);
45 
46  ~ME0DigiProducer() override;
47 
48  void beginRun(const edm::Run&, const edm::EventSetup&) override;
49 
50  void produce(edm::Event&, const edm::EventSetup&) override;
51 
52 private:
53  //Name of Collection used for create the XF
56 
57  std::unique_ptr<ME0DigiModel> ME0DigiModel_;
58 };
59 
61  : ME0DigiModel_{
62  ME0DigiModelFactory::get()->create("ME0" + ps.getParameter<std::string>("digiModelString") + "Model", ps)} {
63  produces<ME0DigiCollection>();
64  produces<ME0DigiSimLinks>("ME0");
65 
67  if (!rng.isAvailable()) {
68  throw cms::Exception("Configuration")
69  << "ME0DigiProducer::ME0DigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
70  << "Add the service in the configuration file or remove the modules that require it.";
71  }
72 
73  LogDebug("ME0DigiProducer") << "Using ME0" + ps.getParameter<std::string>("digiModelString") + "Model";
74 
75  std::string mix_(ps.getParameter<std::string>("mixLabel"));
76  std::string collection_(ps.getParameter<std::string>("inputCollection"));
77 
78  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_));
79  geom_token_ = esConsumes<ME0Geometry, MuonGeometryRecord, edm::Transition::BeginRun>();
80 }
81 
83 
84 void ME0DigiProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup) {
86  ME0DigiModel_->setGeometry(&*hGeom);
87  ME0DigiModel_->setup();
88 }
89 
92  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
93 
95  e.getByToken(cf_token, cf);
96 
98 
99  // Create empty output
100  auto digis = std::make_unique<ME0DigiCollection>();
101  auto me0DigiSimLinks = std::make_unique<ME0DigiSimLinks>();
102 
103  // arrange the hits by eta partition
104  std::map<uint32_t, edm::PSimHitContainer> hitMap;
105  for (const auto& hit : hits) {
106  hitMap[hit.detUnitId()].emplace_back(hit);
107  }
108 
109  // simulate signal and noise for each eta partition
110  const auto& etaPartitions(ME0DigiModel_->getGeometry()->etaPartitions());
111 
112  for (const auto& roll : etaPartitions) {
113  const ME0DetId detId(roll->id());
114  const uint32_t rawId(detId.rawId());
115  const auto& simHits(hitMap[rawId]);
116 
117  LogDebug("ME0DigiProducer") << "ME0DigiProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId;
118 
119  ME0DigiModel_->simulateSignal(roll, simHits, engine);
120  ME0DigiModel_->simulateNoise(roll, engine);
121  ME0DigiModel_->fillDigis(rawId, *digis);
122  (*me0DigiSimLinks).insert(ME0DigiModel_->me0DigiSimLinks());
123  }
124 
125  // store them in the event
126  e.put(std::move(digis));
127  e.put(std::move(me0DigiSimLinks), "ME0");
128 }
129 
131 #endif
edm::DetSetVector
Definition: DetSetVector.h:61
ME0DigiModel.h
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Handle.h
MessageLogger.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
ME0DigiProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ME0DigiProducer.cc:90
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
RandomNumberGenerator.h
ME0DigiProducer::geom_token_
edm::ESGetToken< ME0Geometry, MuonGeometryRecord > geom_token_
Definition: ME0DigiProducer.cc:55
ME0DigiProducer::ME0DigiProducer
ME0DigiProducer(const edm::ParameterSet &ps)
Definition: ME0DigiProducer.cc:60
CrossingFrame.h
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
EDProducer.h
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
ESGetToken.h
ME0DigiProducer::ME0DigiModel_
std::unique_ptr< ME0DigiModel > ME0DigiModel_
Definition: ME0DigiProducer.cc:57
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MixCollection.h
MixCollection
Definition: MixCollection.h:10
Service.h
edm::ESHandle< ME0Geometry >
ME0DigiModelFactory.h
CLHEP
Definition: CocoaGlobals.h:27
ME0DigiProducer::cf_token
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
Definition: ME0DigiProducer.cc:54
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::Service< edm::RandomNumberGenerator >
ME0DigiProducer::~ME0DigiProducer
~ME0DigiProducer() override
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
ME0DetId
Definition: ME0DetId.h:16
DetSetVector.h
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< ME0Geometry, MuonGeometryRecord >
ME0Geometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
ConsumesCollector.h
ME0DigiProducer
Definition: ME0DigiProducer.cc:40
ParameterSet.h
MuonGeometryRecord.h
ME0DigiProducer::ME0DigiSimLinks
edm::DetSetVector< ME0DigiSimLink > ME0DigiSimLinks
Definition: ME0DigiProducer.cc:42
edm::Event
Definition: Event.h:73
ME0DigiProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: ME0DigiProducer.cc:84
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37