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 
38 
40 
43 
46 
51 
54 
55 #include "CLHEP/Random/RandomEngine.h"
58 
59 //
60 // class declaration
61 //
62 
64 public:
65  explicit DTChamberMasker(const edm::ParameterSet &);
66  ~DTChamberMasker() override;
67 
69 
70 private:
71  void produce(edm::Event &, const edm::EventSetup &) override;
72 
73  void beginRun(edm::Run const &, edm::EventSetup const &) override;
74 
76 
77  // ----------member data ---------------------------
78 
81  std::map<unsigned int, float> m_ChEffs;
82 };
83 
84 //
85 // constants, enums and typedefs
86 //
87 
88 //
89 // constructors and destructor
90 //
92  : m_digiToken(consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("digiTag"))),
93  m_agingObjToken(esConsumes<MuonSystemAging, MuonSystemAgingRcd>()) {
94  produces<DTDigiCollection>();
95 }
96 
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to produce the data ------------
106  CLHEP::HepRandomEngine &randGen = randGenService->getEngine(event.streamID());
107 
108  std::unique_ptr<DTDigiCollection> filteredDigis(new DTDigiCollection());
109 
110  if (!m_digiToken.isUninitialized()) {
112  event.getByToken(m_digiToken, dtDigis);
113 
114  for (const auto &dtLayerId : (*dtDigis)) {
115  uint32_t rawId = (dtLayerId.first).chamberId().rawId();
116  auto chEffIt = m_ChEffs.find(rawId);
117 
118  if (chEffIt == m_ChEffs.end() || randGen.flat() <= chEffIt->second)
119  filteredDigis->put(dtLayerId.second, dtLayerId.first);
120  }
121  }
122 
123  event.put(std::move(filteredDigis));
124 }
125 
126 // ------------ method called when starting to processes a run ------------
128  m_ChEffs.clear();
129 
131 
132  m_ChEffs = agingObj->m_DTChambEffs;
133 }
134 
135 // ------------ method fills 'descriptions' with the allowed parameters for the
136 // module ------------
139  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonDTDigis"));
140  descriptions.add("dtChamberMasker", desc);
141 }
142 
143 // define this as a plug-in
DTChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: DTChamberMasker.cc:137
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:81
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
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
EDProducer.h
DTDigiCollection
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
Definition: DTDigiCollection.h:15
edm::Handle< DTDigiCollection >
ESGetToken.h
MakerMacros.h
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:104
Run.h
edm::ESHandle< DTGeometry >
DTChamberId.h
DTChamberMasker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: DTChamberMasker.cc:127
DTLayer.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
DTGeometry.h
MuonSystemAgingRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DTDigiCollection
edm::Service< edm::RandomNumberGenerator >
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd >
DTChamberMasker::~DTChamberMasker
~DTChamberMasker() override
Definition: DTChamberMasker.cc:97
MuonSystemAging
Definition: MuonSystemAging.h:13
DTChamberMasker::createMaskedChamberCollection
void createMaskedChamberCollection(edm::ESHandle< DTGeometry > &)
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTWireId.h
DTChamberMasker::m_agingObjToken
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObjToken
Definition: DTChamberMasker.cc:80
Frameworkfwd.h
DTChamberMasker
Definition: DTChamberMasker.cc:63
EventSetup.h
DTChamberMasker::m_digiToken
edm::EDGetTokenT< DTDigiCollection > m_digiToken
Definition: DTChamberMasker.cc:79
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
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
DTChamberMasker::DTChamberMasker
DTChamberMasker(const edm::ParameterSet &)
Definition: DTChamberMasker.cc:91
edm::InputTag
Definition: InputTag.h:15