CMS 3D CMS Logo

DTChamberMasker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimMuon/DTDigitizer
4 // Class: DTChamberMasker
5 //
11 //
12 // Original Author: Carlo Battilana
13 // Created: Sun, 11 Jan 2015 15:12:51 GMT
14 //
15 //
16 
17 
18 // system include files
19 #include <map>
20 #include <memory>
21 #include <string>
22 #include <iostream>
23 #include <algorithm>
24 
25 // user include files
30 
34 
37 
39 
42 
45 
50 
53 
56 #include "CLHEP/Random/RandomEngine.h"
57 
58 
59 //
60 // class declaration
61 //
62 
64 {
65 
66 public:
67  explicit DTChamberMasker(const edm::ParameterSet&);
69 
71 
72 private:
73  virtual void produce(edm::Event&, const edm::EventSetup&) override;
74 
75  virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
76 
78 
79  // ----------member data ---------------------------
80 
82  std::map<unsigned int, float> m_ChEffs;
83 
84 };
85 
86 //
87 // constants, enums and typedefs
88 //
89 
90 //
91 // constructors and destructor
92 //
94  m_digiToken(consumes<DTDigiCollection>(iConfig.getParameter<edm::InputTag>("digiTag")) )
95 {
96 
97  produces<DTDigiCollection>();
98 
99 }
100 
101 
103 {
104 
105 }
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to produce the data ------------
112 void
114 {
115 
117  CLHEP::HepRandomEngine& randGen = randGenService->getEngine(event.streamID());
118 
119  std::unique_ptr<DTDigiCollection> filteredDigis(new DTDigiCollection());
120 
122  {
124  event.getByToken(m_digiToken, dtDigis);
125 
126  for ( const auto & dtLayerId : (*dtDigis) )
127  {
128 
129  uint32_t rawId = (dtLayerId.first).chamberId().rawId();
130  auto chEffIt = m_ChEffs.find(rawId);
131 
132  if (chEffIt == m_ChEffs.end() || randGen.flat() <= chEffIt->second)
133  filteredDigis->put(dtLayerId.second,dtLayerId.first);
134 
135  }
136 
137  }
138 
139  event.put(std::move(filteredDigis));
140 
141 }
142 
143 // ------------ method called when starting to processes a run ------------
144 void
146 {
147 
148  m_ChEffs.clear();
149 
151  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
152 
153  m_ChEffs = agingObj->m_DTChambEffs;
154 
155 }
156 
157 
158 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
159 void
161 {
162 
164  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonDTDigis"));
165  descriptions.add("dtChamberMasker",desc);
166 
167 }
168 
169 //define this as a plug-in
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< unsigned int, float > m_ChEffs
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
DTChamberMasker(const edm::ParameterSet &)
edm::EDGetTokenT< DTDigiCollection > m_digiToken
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
const T & get() const
Definition: EventSetup.h:56
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
StreamID streamID() const
Definition: Event.h:81
bool isUninitialized() const
Definition: EDGetToken.h:73
def move(src, dest)
Definition: eostools.py:510
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition: event.py:1
Definition: Run.h:42