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
RPCChamberMasker::theRE31_off
bool theRE31_off
Definition: RPCChamberMasker.cc:69
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
ESHandle.h
MuonSystemAging.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< RPCDigiCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
RandomNumberGenerator.h
RPCDetId
Definition: RPCDetId.h:16
RPCChamberMasker::m_digiTag
edm::EDGetTokenT< RPCDigiCollection > m_digiTag
Definition: RPCChamberMasker.cc:67
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RPCChamberMasker::~RPCChamberMasker
~RPCChamberMasker() override
Definition: RPCChamberMasker.cc:98
EDProducer.h
RPCChamberMasker::agingObjToken_
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > agingObjToken_
Definition: RPCChamberMasker.cc:73
RPCChamberMasker::rpcGeomToken_
edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeomToken_
Definition: RPCChamberMasker.cc:72
edm::Handle< RPCDigiCollection >
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
RPCChamberMasker::RPCChamberMasker
RPCChamberMasker(const edm::ParameterSet &)
Definition: RPCChamberMasker.cc:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
RPCChamberMasker::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: RPCChamberMasker.cc:159
Service.h
RPCChamberMasker::theRE41_off
bool theRE41_off
Definition: RPCChamberMasker.cc:70
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
RPCDetId.h
MuonSystemAgingRcd.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
RPCDigiCollection
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
Definition: RPCDigiCollection.h:13
edm::Service< edm::RandomNumberGenerator >
iEvent
int iEvent
Definition: GenABIO.cc:224
RPCChamberMasker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: RPCChamberMasker.cc:127
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
RPCChamberMasker::digiTag_
edm::InputTag digiTag_
Definition: RPCChamberMasker.cc:66
edm::ESGetToken< RPCGeometry, MuonGeometryRecord >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
writedatasetfile.run
run
Definition: writedatasetfile.py:27
RPCChamberMasker::m_ChEffs
std::map< RPCDetId, float > m_ChEffs
Definition: RPCChamberMasker.cc:68
RPCChamberMasker
Definition: RPCChamberMasker.cc:52
Frameworkfwd.h
RPCChamberMasker::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: RPCChamberMasker.cc:105
EventSetup.h
RPCDigiCollection.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
RPCChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: RPCChamberMasker.cc:162
ConsumesCollector.h
ParameterSet.h
MuonGeometryRecord.h
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
RPCGeometry.h
edm::InputTag
Definition: InputTag.h:15