CMS 3D CMS Logo

DTChamberMasker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimMuon/DTDigitizer
4 // Class: DTChamberMasker
5 //
12 //
13 // Original Author: Carlo Battilana
14 // Created: Sun, 11 Jan 2015 15:12:51 GMT
15 //
16 //
17 
18 // system include files
19 #include <algorithm>
20 #include <iostream>
21 #include <map>
22 #include <memory>
23 #include <string>
24 
25 // user include files
30 
34 
37 
39 
42 
45 
50 
53 
54 #include "CLHEP/Random/RandomEngine.h"
57 
58 //
59 // class declaration
60 //
61 
63 public:
64  explicit DTChamberMasker(const edm::ParameterSet &);
65  ~DTChamberMasker() override;
66 
68 
69 private:
70  void produce(edm::Event &, const edm::EventSetup &) override;
71 
72  void beginRun(edm::Run const &, edm::EventSetup const &) override;
73 
75 
76  // ----------member data ---------------------------
77 
79  std::map<unsigned int, float> m_ChEffs;
80 };
81 
82 //
83 // constants, enums and typedefs
84 //
85 
86 //
87 // constructors and destructor
88 //
90  : m_digiToken(consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("digiTag"))) {
91  produces<DTDigiCollection>();
92 }
93 
95 
96 //
97 // member functions
98 //
99 
100 // ------------ method called to produce the data ------------
103  CLHEP::HepRandomEngine &randGen = randGenService->getEngine(event.streamID());
104 
105  std::unique_ptr<DTDigiCollection> filteredDigis(new DTDigiCollection());
106 
107  if (!m_digiToken.isUninitialized()) {
109  event.getByToken(m_digiToken, dtDigis);
110 
111  for (const auto &dtLayerId : (*dtDigis)) {
112  uint32_t rawId = (dtLayerId.first).chamberId().rawId();
113  auto chEffIt = m_ChEffs.find(rawId);
114 
115  if (chEffIt == m_ChEffs.end() || randGen.flat() <= chEffIt->second)
116  filteredDigis->put(dtLayerId.second, dtLayerId.first);
117  }
118  }
119 
120  event.put(std::move(filteredDigis));
121 }
122 
123 // ------------ method called when starting to processes a run ------------
125  m_ChEffs.clear();
126 
128  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
129 
130  m_ChEffs = agingObj->m_DTChambEffs;
131 }
132 
133 // ------------ method fills 'descriptions' with the allowed parameters for the
134 // module ------------
137  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonDTDigis"));
138  descriptions.add("dtChamberMasker", desc);
139 }
140 
141 // define this as a plug-in
DTChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: DTChamberMasker.cc:135
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Handle.h
DTChamberMasker::m_ChEffs
std::map< unsigned int, float > m_ChEffs
Definition: DTChamberMasker.cc:79
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
ESHandle.h
MuonSystemAging.h
MuonSystemAgingRcd
Definition: MuonSystemAgingRcd.h:20
edm::Run
Definition: Run.h:45
DTLayerId.h
edm::EDGetTokenT< DTDigiCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
RandomNumberGenerator.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
DTDigiCollection
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
Definition: DTDigiCollection.h:15
edm::Handle< DTDigiCollection >
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
DTChamberMasker::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: DTChamberMasker.cc:101
edm::EDGetTokenT::isUninitialized
bool isUninitialized() const
Definition: EDGetToken.h:70
Run.h
edm::ESHandle< DTGeometry >
DTChamberId.h
DTChamberMasker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: DTChamberMasker.cc:124
DTLayer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
DTGeometry.h
MuonSystemAgingRcd.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
DTDigiCollection
edm::Service< edm::RandomNumberGenerator >
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
DTChamberMasker::~DTChamberMasker
~DTChamberMasker() override
Definition: DTChamberMasker.cc:94
DTChamberMasker::createMaskedChamberCollection
void createMaskedChamberCollection(edm::ESHandle< DTGeometry > &)
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTWireId.h
Frameworkfwd.h
DTChamberMasker
Definition: DTChamberMasker.cc:62
EventSetup.h
DTChamberMasker::m_digiToken
edm::EDGetTokenT< DTDigiCollection > m_digiToken
Definition: DTChamberMasker.cc:78
DTChamber.h
ConsumesCollector.h
DTDigiCollection.h
ParameterSet.h
MuonGeometryRecord.h
MuonSystemAging::m_DTChambEffs
std::map< unsigned int, float > m_DTChambEffs
Definition: MuonSystemAging.h:19
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
DTChamberMasker::DTChamberMasker
DTChamberMasker(const edm::ParameterSet &)
Definition: DTChamberMasker.cc:89
edm::InputTag
Definition: InputTag.h:15