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
void beginRun(edm::Run const &, edm::EventSetup const &) override
~DTChamberMasker() override
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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.
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
T get() const
Definition: EventSetup.h:73
StreamID streamID() const
Definition: Event.h:96
bool isUninitialized() const
Definition: EDGetToken.h:70
def move(src, dest)
Definition: eostools.py:511
void produce(edm::Event &, const edm::EventSetup &) override
Definition: event.py:1
Definition: Run.h:45