CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
ME0DigiProducer Class Reference
Inheritance diagram for ME0DigiProducer:
edm::stream::EDProducer<>

Public Types

typedef edm::DetSetVector< ME0DigiSimLinkME0DigiSimLinks
 
typedef edm::DetSetVector< StripDigiSimLinkStripDigiSimLinks
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 ME0DigiProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~ME0DigiProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
 
std::unique_ptr< ME0DigiModelME0DigiModel_
 

Detailed Description

Definition at line 40 of file ME0DigiProducer.cc.

Member Typedef Documentation

Definition at line 44 of file ME0DigiProducer.cc.

Definition at line 42 of file ME0DigiProducer.cc.

Constructor & Destructor Documentation

ME0DigiProducer::ME0DigiProducer ( const edm::ParameterSet ps)
explicit

Definition at line 61 of file ME0DigiProducer.cc.

References cf_token, Exception, timingPdfMaker::get, edm::ParameterSet::getParameter(), HLT_2018_cff::InputTag, LogDebug, AlCaHLTBitMon_QueryRunRegistry::string, and ~ME0DigiProducer().

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 }
#define LogDebug(id)
T getParameter(std::string const &) const
std::unique_ptr< ME0DigiModel > ME0DigiModel_
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
ME0DigiProducer::~ME0DigiProducer ( )
overridedefault

Referenced by ME0DigiProducer().

Member Function Documentation

void ME0DigiProducer::beginRun ( const edm::Run ,
const edm::EventSetup eventSetup 
)
override

Definition at line 85 of file ME0DigiProducer.cc.

References edm::EventSetup::get(), and ME0DigiModel_.

85  {
87  eventSetup.get<MuonGeometryRecord>().get(hGeom);
88  ME0DigiModel_->setGeometry(&*hGeom);
89  ME0DigiModel_->setup();
90 }
std::unique_ptr< ME0DigiModel > ME0DigiModel_
T get() const
Definition: EventSetup.h:73
void ME0DigiProducer::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
override

Definition at line 92 of file ME0DigiProducer.cc.

References cf_token, DEFINE_FWK_MODULE, edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), hfClusterShapes_cfi::hits, LogDebug, ME0DigiModel_, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), FastTrackerRecHitCombiner_cfi::simHits, and edm::Event::streamID().

92  {
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 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::unique_ptr< ME0DigiModel > ME0DigiModel_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
T const * product() const
Definition: Handle.h:69
StreamID streamID() const
Definition: Event.h:96
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<CrossingFrame<PSimHit> > ME0DigiProducer::cf_token
private

Definition at line 56 of file ME0DigiProducer.cc.

Referenced by ME0DigiProducer(), and produce().

std::unique_ptr<ME0DigiModel> ME0DigiProducer::ME0DigiModel_
private

Definition at line 58 of file ME0DigiProducer.cc.

Referenced by beginRun(), and produce().