CMS 3D CMS Logo

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

#include <ME0DigiProducer.h>

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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
 
ME0DigiModelME0DigiModel_
 
std::string me0digiModelString_
 

Detailed Description

Definition at line 20 of file ME0DigiProducer.h.

Member Typedef Documentation

Definition at line 26 of file ME0DigiProducer.h.

Definition at line 24 of file ME0DigiProducer.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file ME0DigiProducer.cc.

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

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

Definition at line 52 of file ME0DigiProducer.cc.

References ME0DigiModel_.

53 {
54  delete ME0DigiModel_;
55 }
ME0DigiModel * ME0DigiModel_

Member Function Documentation

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

Definition at line 58 of file ME0DigiProducer.cc.

References edm::EventSetup::get(), ME0DigiModel_, ME0DigiModel::setGeometry(), and ME0DigiModel::setup().

59 {
61  eventSetup.get<MuonGeometryRecord>().get(hGeom);
62  ME0DigiModel_->setGeometry(&*hGeom);
64 }
ME0DigiModel * ME0DigiModel_
virtual void setup()=0
void setGeometry(const ME0Geometry *geom)
Definition: ME0DigiModel.h:41
T get() const
Definition: EventSetup.h:62
void ME0DigiProducer::produce ( edm::Event e,
const edm::EventSetup eventSetup 
)
override

Definition at line 67 of file ME0DigiProducer.cc.

References cf_token, ME0Geometry::etaPartitions(), ME0DigiModel::fillDigis(), edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), ME0DigiModel::getGeometry(), hfClusterShapes_cfi::hits, LogDebug, ME0DigiModel_, ME0DigiModel::me0DigiSimLinks(), eostools::move(), edm::Handle< T >::product(), edm::Event::put(), trackerHits::simHits, ME0DigiModel::simulateNoise(), ME0DigiModel::simulateSignal(), edm::Event::streamID(), and ME0DigiModel::stripDigiSimLinks().

68 {
70  CLHEP::HepRandomEngine* engine = &rng->getEngine(e.streamID());
71 
73  e.getByToken(cf_token, cf);
74 
75  std::unique_ptr<MixCollection<PSimHit> > hits(new MixCollection<PSimHit>(cf.product()));
76 
77  // Create empty output
78  std::unique_ptr<ME0DigiCollection> digis(new ME0DigiCollection());
79  std::unique_ptr<StripDigiSimLinks> stripDigiSimLinks(new StripDigiSimLinks() );
80  std::unique_ptr<ME0DigiSimLinks> me0DigiSimLinks(new ME0DigiSimLinks() );
81 
82  // arrange the hits by eta partition
83  std::map<uint32_t, edm::PSimHitContainer> hitMap;
84  for (const auto& hit: *hits){
85  hitMap[hit.detUnitId()].emplace_back(hit);
86  }
87 
88  // simulate signal and noise for each eta partition
89  const auto & etaPartitions(ME0DigiModel_->getGeometry()->etaPartitions());
90 
91  for (const auto& roll: etaPartitions){
92  const ME0DetId detId(roll->id());
93  const uint32_t rawId(detId.rawId());
94  const auto & simHits(hitMap[rawId]);
95 
96  LogDebug("ME0DigiProducer")
97  << "ME0DigiProducer: found " << simHits.size() << " hit(s) in eta partition" << rawId;
98 
99  ME0DigiModel_->simulateSignal(roll, simHits, engine);
100  ME0DigiModel_->simulateNoise(roll, engine);
101  ME0DigiModel_->fillDigis(rawId, *digis);
102  (*stripDigiSimLinks).insert(ME0DigiModel_->stripDigiSimLinks());
103  (*me0DigiSimLinks).insert(ME0DigiModel_->me0DigiSimLinks());
104  }
105 
106  // store them in the event
107  e.put(std::move(digis));
108  e.put(std::move(stripDigiSimLinks),"ME0");
109  e.put(std::move(me0DigiSimLinks),"ME0");
110 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void fillDigis(int rollDetId, ME0DigiCollection &)
Definition: ME0DigiModel.cc:5
ME0DigiModel * ME0DigiModel_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
MuonDigiCollection< ME0DetId, ME0Digi > ME0DigiCollection
virtual void simulateNoise(const ME0EtaPartition *, CLHEP::HepRandomEngine *engine)=0
edm::DetSetVector< ME0DigiSimLink > ME0DigiSimLinks
const std::vector< ME0EtaPartition const * > & etaPartitions() const
Return a vector of all ME0 eta partitions.
Definition: ME0Geometry.cc:59
edm::DetSetVector< StripDigiSimLink > StripDigiSimLinks
T const * product() const
Definition: Handle.h:81
const StripDigiSimLinks & stripDigiSimLinks() const
Definition: ME0DigiModel.h:56
const ME0DigiSimLinks & me0DigiSimLinks() const
Definition: ME0DigiModel.h:57
const ME0Geometry * getGeometry()
Definition: ME0DigiModel.h:43
StreamID streamID() const
Definition: Event.h:96
edm::EDGetTokenT< CrossingFrame< PSimHit > > cf_token
virtual void simulateSignal(const ME0EtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *engine)=0
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

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

Definition at line 39 of file ME0DigiProducer.h.

Referenced by ME0DigiProducer(), and produce().

ME0DigiModel* ME0DigiProducer::ME0DigiModel_
private

Definition at line 42 of file ME0DigiProducer.h.

Referenced by beginRun(), ME0DigiProducer(), produce(), and ~ME0DigiProducer().

std::string ME0DigiProducer::me0digiModelString_
private

Definition at line 41 of file ME0DigiProducer.h.

Referenced by ME0DigiProducer().