CMS 3D CMS Logo

ME0DigiPreRecoProducer.cc
Go to the documentation of this file.
1 #ifndef SimMuon_GEMDigitizer_ME0DigiPreRecoProducer_h
2 #define SimMuon_GEMDigitizer_ME0DigiPreRecoProducer_h
3 
15 
20 
23 
26 
27 #include <sstream>
28 #include <string>
29 #include <map>
30 #include <vector>
31 
32 namespace CLHEP {
33  class HepRandomEngine;
34 }
35 
37 public:
38  explicit ME0DigiPreRecoProducer(const edm::ParameterSet& ps);
39 
40  ~ME0DigiPreRecoProducer() override;
41 
42  void beginRun(const edm::Run&, const edm::EventSetup&) override;
43 
44  void produce(edm::Event&, const edm::EventSetup&) override;
45 
46 private:
47  //Name of Collection used for create the XF
49 
51  std::unique_ptr<ME0DigiPreRecoModel> me0DigiPreRecoModel_;
52 };
53 
55  : digiPreRecoModelString_(ps.getParameter<std::string>("digiPreRecoModelString")),
56  me0DigiPreRecoModel_{ME0DigiPreRecoModelFactory::get()->create("ME0" + digiPreRecoModelString_ + "Model", ps)} {
57  produces<ME0DigiPreRecoCollection>();
58 
60  if (!rng.isAvailable()) {
61  throw cms::Exception("Configuration")
62  << "ME0DigiPreRecoProducer::ME0PreRecoDigiProducer() - RandomNumberGeneratorService is not present in "
63  "configuration file.\n"
64  << "Add the service in the configuration file or remove the modules that require it.";
65  }
66  LogDebug("ME0DigiPreRecoProducer") << "Using ME0" + digiPreRecoModelString_ + "Model";
67 
68  std::string mix_(ps.getParameter<std::string>("mixLabel"));
69  std::string collection_(ps.getParameter<std::string>("inputCollection"));
70 
71  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_));
72 }
73 
75 
77  // set geometry
79  eventSetup.get<MuonGeometryRecord>().get(hGeom);
80  me0DigiPreRecoModel_->setGeometry(&*hGeom);
81  me0DigiPreRecoModel_->setup();
82 }
83 
86  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
87 
89  e.getByToken(cf_token, cf);
90 
92 
93  // Create empty output
94  auto digis = std::make_unique<ME0DigiPreRecoCollection>();
95 
96  // arrange the hits by eta partition
97  std::map<uint32_t, edm::PSimHitContainer> hitMap;
98  for (const auto& hit : hits) {
99  hitMap[hit.detUnitId()].push_back(hit);
100  }
101 
102  // simulate signal and noise for each eta partition
103  const auto& etaPartitions(me0DigiPreRecoModel_->getGeometry()->etaPartitions());
104 
105  for (const auto& roll : etaPartitions) {
106  const ME0DetId detId(roll->id());
107  const uint32_t rawId(detId.rawId());
108  const auto& simHits(hitMap[rawId]);
109 
110  LogDebug("ME0DigiPreRecoProducer") << "ME0DigiPreRecoProducer: found " << simHits.size()
111  << " hit(s) in eta partition" << rawId;
112 
113  me0DigiPreRecoModel_->simulateSignal(roll, simHits, engine);
114  me0DigiPreRecoModel_->simulateNoise(roll, engine);
115  me0DigiPreRecoModel_->fillDigis(rawId, *digis);
116  }
117 
118  // store them in the event
119  e.put(std::move(digis));
120 }
121 
123 #endif
ME0DigiPreRecoModel.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
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
ESHandle.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
RandomNumberGenerator.h
CrossingFrame.h
PSimHitContainer.h
EDProducer.h
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
ME0DigiPreRecoProducer::~ME0DigiPreRecoProducer
~ME0DigiPreRecoProducer() override
edm::Handle
Definition: AssociativeIterator.h:50
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
MakerMacros.h
ME0DigiPreRecoProducer::digiPreRecoModelString_
std::string digiPreRecoModelString_
Definition: ME0DigiPreRecoProducer.cc:50
ME0DigiPreRecoProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ME0DigiPreRecoProducer.cc:84
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 >
ME0DigiPreRecoProducer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: ME0DigiPreRecoProducer.cc:76
ME0DigiPreRecoProducer
Definition: ME0DigiPreRecoProducer.cc:36
CLHEP
Definition: CocoaGlobals.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ME0DigiPreRecoProducer::me0DigiPreRecoModel_
std::unique_ptr< ME0DigiPreRecoModel > me0DigiPreRecoModel_
Definition: ME0DigiPreRecoProducer.cc:51
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 >
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
ME0DetId
Definition: ME0DetId.h:16
ME0DigiPreRecoProducer::ME0DigiPreRecoProducer
ME0DigiPreRecoProducer(const edm::ParameterSet &ps)
Definition: ME0DigiPreRecoProducer.cc:54
get
#define get
ME0Geometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
EventSetup.h
Exception.h
ConsumesCollector.h
ParameterSet.h
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
ME0DigiPreRecoModelFactory.h
hit
Definition: SiStripHitEffFromCalibTree.cc:88
ME0DigiPreRecoProducer::cf_token
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
Definition: ME0DigiPreRecoProducer.cc:48
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37