CMS 3D CMS Logo

RPCChamberMasker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SimMuon/RPCDigitizer/
4 // Class: RPCChamberMasker
5 //
14 //
15 // Original Author: Borislav Pavlov
16 // Created: Tue, 16 Jun 2015 13:02:20 GMT
17 //
18 //
19 
20 // system include files
21 #include <memory>
22 #include <string>
23 #include <vector>
24 #include <iostream>
25 #include <algorithm>
26 #include <regex>
27 
28 // user include files
37 
44 
47 #include "CLHEP/Random/RandomEngine.h"
48 //
49 // class declaration
50 //
51 
53 public:
54  explicit RPCChamberMasker(const edm::ParameterSet&);
55  ~RPCChamberMasker() override;
56 
57  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
58 
59 private:
60  void produce(edm::Event&, const edm::EventSetup&) override;
61 
62  void beginRun(edm::Run const&, edm::EventSetup const&) override;
63  void endRun(edm::Run const&, edm::EventSetup const&) override;
64 
65  // ----------member data ---------------------------
68  std::map<RPCDetId, float> m_ChEffs;
71 
74 };
75 
76 //
77 // constants, enums and typedefs
78 //
79 
80 //
81 // static data member definitions
82 //
83 
84 //
85 // constructors and destructor
86 //
88  : digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")) {
89  m_digiTag = consumes<RPCDigiCollection>(digiTag_);
90  produces<RPCDigiCollection>();
91 
92  theRE31_off = iConfig.getParameter<bool>("descopeRE31");
93  theRE41_off = iConfig.getParameter<bool>("descopeRE41");
96 }
97 
99 
100 //
101 // member functions
102 //
103 
104 // ------------ method called to produce the data ------------
106  using namespace edm;
108  CLHEP::HepRandomEngine& randGen = randGenService->getEngine(iEvent.streamID());
109 
110  std::unique_ptr<RPCDigiCollection> filteredDigis(new RPCDigiCollection());
111  if (!digiTag_.label().empty()) {
113  iEvent.getByToken(m_digiTag, rpcDigis);
114 
115  for (const auto& rpcLayerId : (*rpcDigis)) {
116  int id = (rpcLayerId.first).rawId();
117  auto chEffIt = m_ChEffs.find(id);
118  if ((chEffIt != m_ChEffs.end()) && (randGen.flat() <= chEffIt->second))
119  filteredDigis->put(rpcLayerId.second, rpcLayerId.first);
120  }
121  }
122  iEvent.put(std::move(filteredDigis));
123 }
124 
125 // ------------ method called when starting to processes a run ------------
126 
128  m_ChEffs.clear();
129 
130  auto rpcGeom = iSetup.getHandle(rpcGeomToken_);
131  auto agingObj = iSetup.getHandle(agingObjToken_);
132 
133  const auto rolls = rpcGeom->rolls();
134 
135  for (const auto* roll : rolls) {
136  RPCDetId rollId = roll->id();
137  uint32_t rollRawId = rollId.rawId();
138 
139  Float_t chamberEff = 1.;
140  for (const auto& agingPair : agingObj->m_RPCChambEffs) {
141  if (agingPair.first == rollRawId) {
142  chamberEff = agingPair.second;
143  break;
144  }
145 
146  if (theRE31_off && (roll->isIRPC() && (rollId.station() == 3))) {
147  chamberEff = 0;
148  }
149  if (theRE41_off && (roll->isIRPC() && (rollId.station() == 4))) {
150  chamberEff = 0;
151  }
152  }
153  m_ChEffs[rollId] = chamberEff;
154  }
155 }
156 
157 // ------------ method called when ending the processing of a run ------------
158 
160 
161 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
164  desc.add<edm::InputTag>("digiTag", edm::InputTag("preRPCDigis"));
165  desc.add<bool>("descopeRE31", false);
166  desc.add<bool>("descopeRE41", false);
167  descriptions.add("rpcChamberMasker", desc);
168 }
169 
170 //define this as a plug-in
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::map< RPCDetId, float > m_ChEffs
std::string const & label() const
Definition: InputTag.h:36
void beginRun(edm::Run const &, edm::EventSetup const &) override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
int iEvent
Definition: GenABIO.cc:224
edm::InputTag digiTag_
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
~RPCChamberMasker() override
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void endRun(edm::Run const &, edm::EventSetup const &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int station() const
Definition: RPCDetId.h:78
RPCChamberMasker(const edm::ParameterSet &)
HLT enums.
edm::EDGetTokenT< RPCDigiCollection > m_digiTag
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > agingObjToken_