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 
21 // system include files
22 #include <memory>
23 #include <string>
24 #include <vector>
25 #include <iostream>
26 #include <algorithm>
27 #include <regex>
28 
29 // user include files
38 
45 
48 #include "CLHEP/Random/RandomEngine.h"
49 //
50 // class declaration
51 //
52 
54 {
55 
56  public:
57  explicit RPCChamberMasker(const edm::ParameterSet&);
59 
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
61 
62  private:
63  virtual void produce(edm::Event&, const edm::EventSetup&) override;
64 
65  virtual void beginRun(edm::Run const&, edm::EventSetup const&) override;
66  virtual void endRun(edm::Run const&, edm::EventSetup const&) override;
67 
68  // ----------member data ---------------------------
71  std::map<RPCDetId, float> m_ChEffs;
73  bool theRE41_off;
74 
75 };
76 
77 //
78 // constants, enums and typedefs
79 //
80 
81 //
82 // static data member definitions
83 //
84 
85 //
86 // constructors and destructor
87 //
89  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag") )
90 {
91 
92  m_digiTag = consumes<RPCDigiCollection>(digiTag_);
93  produces<RPCDigiCollection>();
94 
95  theRE31_off = iConfig.getParameter<bool>("descopeRE31");
96  theRE41_off =iConfig.getParameter<bool>("descopeRE41");
97 
98 }
99 
100 
102 {
103 
104 }
105 
106 
107 //
108 // member functions
109 //
110 
111 // ------------ method called to produce the data ------------
112 void
114 {
115 
116  using namespace edm;
118  CLHEP::HepRandomEngine& randGen = randGenService->getEngine(iEvent.streamID());
119 
120 
121  std::unique_ptr<RPCDigiCollection> filteredDigis(new RPCDigiCollection());
122  if (!digiTag_.label().empty())
123  {
125  iEvent.getByToken(m_digiTag, rpcDigis);
126 
127  for ( const auto & rpcLayerId : (*rpcDigis) )
128  {
129  int id = (rpcLayerId.first).rawId();
130  auto chEffIt = m_ChEffs.find(id);
131  if ((chEffIt != m_ChEffs.end()) && (randGen.flat() <= chEffIt->second))
132  filteredDigis->put(rpcLayerId.second,rpcLayerId.first);
133  }
134  }
135  iEvent.put(std::move(filteredDigis));
136 
137 }
138 
139 // ------------ method called when starting to processes a run ------------
140 
141 void
143 {
144 
145  m_ChEffs.clear();
146 
148  iSetup.get<MuonGeometryRecord>().get(rpcGeom);
149 
151  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
152 
153  const auto rolls = rpcGeom->rolls();
154 
155  for ( const auto * roll : rolls)
156  {
157  RPCDetId rollId = roll->id();
158  uint32_t rollRawId = rollId.rawId();
159 
160  Float_t chamberEff = 1.;
161  for ( const auto & agingPair : agingObj->m_RPCChambEffs)
162  {
163 
164  if ( agingPair.first == rollRawId)
165  {
166  chamberEff = agingPair.second;
167  break;
168  }
169 
170  if(theRE31_off && ( roll->isIRPC() && (rollId.station()==3) ) ){
171  chamberEff = 0;
172  }
173  if(theRE41_off && ( roll->isIRPC() && (rollId.station()==4) ) ){
174  chamberEff = 0;
175  }
176  }
177  m_ChEffs[rollId] = chamberEff;
178  }
179 
180 }
181 
182 
183 // ------------ method called when ending the processing of a run ------------
184 
185 void
187 {
188 
189 }
190 
191 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
192 void
194 {
195 
197  desc.add<edm::InputTag>("digiTag", edm::InputTag("preRPCDigis"));
198  desc.add<bool>("descopeRE31", false);
199  desc.add<bool>("descopeRE41", false);
200  descriptions.add("rpcChamberMasker",desc);
201 
202 }
203 
204 //define this as a plug-in
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
std::map< RPCDetId, float > m_ChEffs
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const std::vector< const RPCRoll * > & rolls() const
Return a vector of all RPC rolls.
Definition: RPCGeometry.cc:67
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int iEvent
Definition: GenABIO.cc:230
edm::InputTag digiTag_
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
virtual void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::map< unsigned int, float > m_RPCChambEffs
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
const T & get() const
Definition: EventSetup.h:56
void add(std::string const &label, ParameterSetDescription const &psetDescription)
RPCChamberMasker(const edm::ParameterSet &)
std::string const & label() const
Definition: InputTag.h:36
HLT enums.
edm::EDGetTokenT< RPCDigiCollection > m_digiTag
StreamID streamID() const
Definition: Event.h:81
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:42
int station() const
Definition: RPCDetId.h:96