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 
16 
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 
45 
46  explicit ME0DigiProducer(const edm::ParameterSet& ps);
47 
48  ~ME0DigiProducer() override;
49 
50  void beginRun(const edm::Run&, const edm::EventSetup&) override;
51 
52  void produce(edm::Event&, const edm::EventSetup&) override;
53 
54 private:
55  //Name of Collection used for create the XF
57 
58  std::unique_ptr<ME0DigiModel> ME0DigiModel_;
59 };
60 
62  : ME0DigiModel_{
63  ME0DigiModelFactory::get()->create("ME0" + ps.getParameter<std::string>("digiModelString") + "Model", ps)} {
64  produces<ME0DigiCollection>();
65  produces<StripDigiSimLinks>("ME0");
66  produces<ME0DigiSimLinks>("ME0");
67 
69  if (!rng.isAvailable()) {
70  throw cms::Exception("Configuration")
71  << "ME0DigiProducer::ME0DigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
72  << "Add the service in the configuration file or remove the modules that require it.";
73  }
74 
75  LogDebug("ME0DigiProducer") << "Using ME0" + ps.getParameter<std::string>("digiModelString") + "Model";
76 
77  std::string mix_(ps.getParameter<std::string>("mixLabel"));
78  std::string collection_(ps.getParameter<std::string>("inputCollection"));
79 
80  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_));
81 }
82 
84 
85 void ME0DigiProducer::beginRun(const edm::Run&, const edm::EventSetup& eventSetup) {
87  eventSetup.get<MuonGeometryRecord>().get(hGeom);
88  ME0DigiModel_->setGeometry(&*hGeom);
89  ME0DigiModel_->setup();
90 }
91 
94  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
95 
97  e.getByToken(cf_token, cf);
98 
100 
101  // Create empty output
102  auto digis = std::make_unique<ME0DigiCollection>();
103  auto stripDigiSimLinks = std::make_unique<StripDigiSimLinks>();
104  auto me0DigiSimLinks = std::make_unique<ME0DigiSimLinks>();
105 
106  // arrange the hits by eta partition
107  std::map<uint32_t, edm::PSimHitContainer> hitMap;
108  for (const auto& hit : hits) {
109  hitMap[hit.detUnitId()].emplace_back(hit);
110  }
111 
112  // simulate signal and noise for each eta partition
113  const auto& etaPartitions(ME0DigiModel_->getGeometry()->etaPartitions());
114 
115  for (const auto& roll : etaPartitions) {
116  const ME0DetId detId(roll->id());
117  const uint32_t rawId(detId.rawId());
118  const auto& simHits(hitMap[rawId]);
119 
120  LogDebug("ME0DigiProducer") << "ME0DigiProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId;
121 
122  ME0DigiModel_->simulateSignal(roll, simHits, engine);
123  ME0DigiModel_->simulateNoise(roll, engine);
124  ME0DigiModel_->fillDigis(rawId, *digis);
125  (*stripDigiSimLinks).insert(ME0DigiModel_->stripDigiSimLinks());
126  (*me0DigiSimLinks).insert(ME0DigiModel_->me0DigiSimLinks());
127  }
128 
129  // store them in the event
130  e.put(std::move(digis));
131  e.put(std::move(stripDigiSimLinks), "ME0");
132  e.put(std::move(me0DigiSimLinks), "ME0");
133 }
134 
136 #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
ME0DigiProducer::StripDigiSimLinks
edm::DetSetVector< StripDigiSimLink > StripDigiSimLinks
Definition: ME0DigiProducer.cc:42
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:92
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
RandomNumberGenerator.h
ME0DigiProducer::ME0DigiProducer
ME0DigiProducer(const edm::ParameterSet &ps)
Definition: ME0DigiProducer.cc:61
CrossingFrame.h
PSimHitContainer.h
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
ME0DigiProducer::ME0DigiModel_
std::unique_ptr< ME0DigiModel > ME0DigiModel_
Definition: ME0DigiProducer.cc:58
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MixCollection.h
MixCollection
Definition: MixCollection.h:11
Service.h
edm::ESHandle< ME0Geometry >
ME0DigiModelFactory.h
CLHEP
Definition: CocoaGlobals.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ME0DigiProducer::cf_token
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
Definition: ME0DigiProducer.cc:56
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
edm::Service< edm::RandomNumberGenerator >
ME0DigiProducer::~ME0DigiProducer
~ME0DigiProducer() override
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
ME0DetId
Definition: ME0DetId.h:16
DetSetVector.h
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ME0Geometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:246
EventSetup.h
Exception.h
ConsumesCollector.h
ME0DigiProducer
Definition: ME0DigiProducer.cc:40
ParameterSet.h
MuonGeometryRecord.h
ME0DigiProducer::ME0DigiSimLinks
edm::DetSetVector< ME0DigiSimLink > ME0DigiSimLinks
Definition: ME0DigiProducer.cc:44
edm::Event
Definition: Event.h:73
ME0DigiProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: ME0DigiProducer.cc:85
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37