CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
GEMDigiProducer Class Reference

#include <GEMDigiProducer.h>

Inheritance diagram for GEMDigiProducer:
edm::stream::EDProducer<>

Public Types

typedef edm::DetSetVector< GEMDigiSimLinkGEMDigiSimLinks
 
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
 
 GEMDigiProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~GEMDigiProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

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

Detailed Description

Definition at line 20 of file GEMDigiProducer.h.

Member Typedef Documentation

Definition at line 26 of file GEMDigiProducer.h.

Definition at line 24 of file GEMDigiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file GEMDigiProducer.cc.

References cf_token, Exception, reco::get(), edm::ParameterSet::getParameter(), LogDebug, AlCaHLTBitMon_QueryRunRegistry::string, and ~GEMDigiProducer().

30  : gemDigiModel_{GEMDigiModelFactory::get()->create("GEM" + ps.getParameter<std::string>("digiModelString") + "Model",
31  ps)}
32 {
33  produces<GEMDigiCollection>();
34  produces<StripDigiSimLinks>("GEM");
35  produces<GEMDigiSimLinks>("GEM");
36 
38  if (!rng.isAvailable()){
39  throw cms::Exception("Configuration")
40  << "GEMDigiProducer::GEMDigiProducer() - RandomNumberGeneratorService is not present in configuration file.\n"
41  << "Add the service in the configuration file or remove the modules that require it.";
42  }
43 
44  LogDebug("GEMDigiProducer") << "Using GEM" + ps.getParameter<std::string>("digiModelString") + "Model";
45 
46  std::string mix_(ps.getParameter<std::string>("mixLabel"));
47  std::string collection_(ps.getParameter<std::string>("inputCollection"));
48 
49  cf_token = consumes<CrossingFrame<PSimHit> >(edm::InputTag(mix_, collection_));
50 }
#define LogDebug(id)
T getParameter(std::string const &) const
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
std::unique_ptr< GEMDigiModel > gemDigiModel_
T get(const Candidate &c)
Definition: component.h:55
GEMDigiProducer::~GEMDigiProducer ( )
overridedefault

Referenced by GEMDigiProducer().

Member Function Documentation

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

Definition at line 56 of file GEMDigiProducer.cc.

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

57 {
59  eventSetup.get<MuonGeometryRecord>().get(hGeom);
60  gemDigiModel_->setGeometry(&*hGeom);
61  gemDigiModel_->setup();
62 }
std::unique_ptr< GEMDigiModel > gemDigiModel_
T get() const
Definition: EventSetup.h:71
void GEMDigiProducer::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
override

Definition at line 65 of file GEMDigiProducer.cc.

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

66 {
68  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
69 
71  e.getByToken(cf_token, cf);
72 
74 
75  // Create empty output
76  auto digis = std::make_unique<GEMDigiCollection>();
77  auto stripDigiSimLinks = std::make_unique<StripDigiSimLinks>();
78  auto gemDigiSimLinks = std::make_unique<GEMDigiSimLinks>();
79 
80  // arrange the hits by eta partition
81  std::map<uint32_t, edm::PSimHitContainer> hitMap;
82  for (const auto& hit: hits){
83  hitMap[hit.detUnitId()].emplace_back(hit);
84  }
85 
86  // simulate signal and noise for each eta partition
87  const auto & etaPartitions(gemDigiModel_->getGeometry()->etaPartitions());
88 
89  for (const auto& roll: etaPartitions){
90  const GEMDetId detId(roll->id());
91  const uint32_t rawId(detId.rawId());
92  const auto & simHits(hitMap[rawId]);
93 
94  LogDebug("GEMDigiProducer")
95  << "GEMDigiProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId;
96 
97  gemDigiModel_->simulateSignal(roll, simHits, engine);
98  gemDigiModel_->simulateNoise(roll, engine);
99  gemDigiModel_->fillDigis(rawId, *digis);
100  (*stripDigiSimLinks).insert(gemDigiModel_->stripDigiSimLinks());
101  (*gemDigiSimLinks).insert(gemDigiModel_->gemDigiSimLinks());
102  }
103 
104  // store them in the event
105  e.put(std::move(digis));
106  e.put(std::move(stripDigiSimLinks),"GEM");
107  e.put(std::move(gemDigiSimLinks),"GEM");
108 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
T const * product() const
Definition: Handle.h:74
std::unique_ptr< GEMDigiModel > gemDigiModel_
StreamID streamID() const
Definition: Event.h:95
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 39 of file GEMDigiProducer.h.

Referenced by GEMDigiProducer(), and produce().

std::unique_ptr<GEMDigiModel> GEMDigiProducer::gemDigiModel_
private

Definition at line 41 of file GEMDigiProducer.h.

Referenced by beginRun(), and produce().