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 };
72 
73 //
74 // constants, enums and typedefs
75 //
76 
77 //
78 // static data member definitions
79 //
80 
81 //
82 // constructors and destructor
83 //
85  : digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")) {
86  m_digiTag = consumes<RPCDigiCollection>(digiTag_);
87  produces<RPCDigiCollection>();
88 
89  theRE31_off = iConfig.getParameter<bool>("descopeRE31");
90  theRE41_off = iConfig.getParameter<bool>("descopeRE41");
91 }
92 
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
101  using namespace edm;
103  CLHEP::HepRandomEngine& randGen = randGenService->getEngine(iEvent.streamID());
104 
105  std::unique_ptr<RPCDigiCollection> filteredDigis(new RPCDigiCollection());
106  if (!digiTag_.label().empty()) {
108  iEvent.getByToken(m_digiTag, rpcDigis);
109 
110  for (const auto& rpcLayerId : (*rpcDigis)) {
111  int id = (rpcLayerId.first).rawId();
112  auto chEffIt = m_ChEffs.find(id);
113  if ((chEffIt != m_ChEffs.end()) && (randGen.flat() <= chEffIt->second))
114  filteredDigis->put(rpcLayerId.second, rpcLayerId.first);
115  }
116  }
117  iEvent.put(std::move(filteredDigis));
118 }
119 
120 // ------------ method called when starting to processes a run ------------
121 
123  m_ChEffs.clear();
124 
126  iSetup.get<MuonGeometryRecord>().get(rpcGeom);
127 
129  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
130 
131  const auto rolls = rpcGeom->rolls();
132 
133  for (const auto* roll : rolls) {
134  RPCDetId rollId = roll->id();
135  uint32_t rollRawId = rollId.rawId();
136 
137  Float_t chamberEff = 1.;
138  for (const auto& agingPair : agingObj->m_RPCChambEffs) {
139  if (agingPair.first == rollRawId) {
140  chamberEff = agingPair.second;
141  break;
142  }
143 
144  if (theRE31_off && (roll->isIRPC() && (rollId.station() == 3))) {
145  chamberEff = 0;
146  }
147  if (theRE41_off && (roll->isIRPC() && (rollId.station() == 4))) {
148  chamberEff = 0;
149  }
150  }
151  m_ChEffs[rollId] = chamberEff;
152  }
153 }
154 
155 // ------------ method called when ending the processing of a run ------------
156 
158 
159 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
162  desc.add<edm::InputTag>("digiTag", edm::InputTag("preRPCDigis"));
163  desc.add<bool>("descopeRE31", false);
164  desc.add<bool>("descopeRE41", false);
165  descriptions.add("rpcChamberMasker", desc);
166 }
167 
168 //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.
MuonSystemAging::m_RPCChambEffs
std::map< unsigned int, float > m_RPCChambEffs
Definition: MuonSystemAging.h:16
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
RPCDetId::station
int station() const
Definition: RPCDetId.h:78
ESHandle.h
MuonSystemAging.h
MuonSystemAgingRcd
Definition: MuonSystemAgingRcd.h:20
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
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
RPCChamberMasker::~RPCChamberMasker
~RPCChamberMasker() override
Definition: RPCChamberMasker.cc:93
EDProducer.h
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:84
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:157
Service.h
edm::ESHandle< RPCGeometry >
RPCChamberMasker::theRE41_off
bool theRE41_off
Definition: RPCChamberMasker.cc:70
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
RPCDetId.h
MuonSystemAgingRcd.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
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:122
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
RPCChamberMasker::digiTag_
edm::InputTag digiTag_
Definition: RPCChamberMasker.cc:66
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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:100
EventSetup.h
RPCDigiCollection.h
RPCChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: RPCChamberMasker.cc:160
ConsumesCollector.h
RPCGeometry::rolls
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:44
ParameterSet.h
MuonGeometryRecord.h
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
RPCGeometry.h
edm::InputTag
Definition: InputTag.h:15