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 
68 
69 private:
70  void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override;
71 
73 
74  // ----------member data ---------------------------
75 
79 };
80 
81 //
82 // constants, enums and typedefs
83 //
84 
85 //
86 // constructors and destructor
87 //
89  : m_digiToken(consumes(iConfig.getParameter<edm::InputTag>("digiTag"))),
90  m_putToken(produces()),
91  m_agingObjToken(esConsumes()) {}
92 
93 //
94 // member functions
95 //
96 
97 // ------------ method called to produce the data ------------
100  CLHEP::HepRandomEngine &randGen = randGenService->getEngine(event.streamID());
101 
102  MuonSystemAging const &agingObj = conditions.getData(m_agingObjToken);
103 
104  auto const &chEffs = agingObj.m_DTChambEffs;
105 
106  DTDigiCollection filteredDigis;
107 
108  if (!m_digiToken.isUninitialized()) {
110  event.getByToken(m_digiToken, dtDigis);
111 
112  for (const auto &dtLayerId : (*dtDigis)) {
113  uint32_t rawId = (dtLayerId.first).chamberId().rawId();
114  auto chEffIt = chEffs.find(rawId);
115 
116  if (chEffIt == chEffs.end() || randGen.flat() <= chEffIt->second)
117  filteredDigis.put(dtLayerId.second, dtLayerId.first);
118  }
119  }
120 
121  event.emplace(m_putToken, std::move(filteredDigis));
122 }
123 
124 // ------------ method fills 'descriptions' with the allowed parameters for the
125 // module ------------
128  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonDTDigis"));
129  descriptions.add("dtChamberMasker", desc);
130 }
131 
132 // define this as a plug-in
const edm::EDPutTokenT< DTDigiCollection > m_putToken
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
DTChamberMasker(const edm::ParameterSet &)
const edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObjToken
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void createMaskedChamberCollection(edm::ESHandle< DTGeometry > &)
static void fillDescriptions(edm::ConfigurationDescriptions &)
std::map< unsigned int, float > m_DTChambEffs
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< DTDigiCollection > m_digiToken
Definition: event.py:1