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