CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObjToken
void beginRun(edm::Run const &, edm::EventSetup const &) override
~DTChamberMasker() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
std::map< unsigned int, float > m_ChEffs
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
DTChamberMasker(const edm::ParameterSet &)
edm::EDGetTokenT< DTDigiCollection > m_digiToken
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void createMaskedChamberCollection(edm::ESHandle< DTGeometry > &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
StreamID streamID() const
Definition: Event.h:98
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Run.h:45