CMS 3D CMS Logo

ME0ChamberMasker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Class: ME0ChamberMasker
3 //
4 
5 // system include files
6 #include <memory>
7 #include <string>
8 #include <vector>
9 #include <iostream>
10 #include <algorithm>
11 #include <regex>
12 
13 // user include files
23 
30 //
31 // class declaration
32 //
33 
35 public:
36  explicit ME0ChamberMasker(const edm::ParameterSet&);
37  ~ME0ChamberMasker() override;
38 
39  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
40 
41 private:
42  void produce(edm::Event&, const edm::EventSetup&) override;
43 
44  void beginRun(edm::Run const&, edm::EventSetup const&) override;
45  void endRun(edm::Run const&, edm::EventSetup const&) override;
46 
47  // ----------member data ---------------------------
48  bool me0Minus_;
49  bool me0Plus_;
53  std::map<unsigned int, float> m_maskedME0IDs;
54 };
55 
56 //
57 // constants, enums and typedefs
58 //
59 
60 //
61 // static data member definitions
62 //
63 
64 //
65 // constructors and destructor
66 //
68  : me0Minus_(iConfig.getParameter<bool>("me0Minus")),
69  me0Plus_(iConfig.getParameter<bool>("me0Plus")),
70  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")) {
71  m_digiTag = consumes<ME0DigiPreRecoCollection>(digiTag_);
72  m_agingObjTag = esConsumes<MuonSystemAging, MuonSystemAgingRcd, edm::Transition::BeginRun>();
73  produces<ME0DigiPreRecoCollection>();
74 }
75 
77 
78 //
79 // member functions
80 //
81 
82 // ------------ method called to produce the data ------------
84  using namespace edm;
85  std::unique_ptr<ME0DigiPreRecoCollection> filteredDigis(new ME0DigiPreRecoCollection());
86 
87  if (!digiTag_.label().empty()) {
89  iEvent.getByToken(m_digiTag, me0Digis);
90 
91  for (const auto& me0LayerId : (*me0Digis)) {
92  auto chambId = me0LayerId.first.chamberId();
93 
94  bool keepDigi = (!me0Minus_ && chambId.region() < 0) || (!me0Plus_ && chambId.region() > 0);
95 
96  uint32_t rawId = chambId.rawId();
97  if (keepDigi || m_maskedME0IDs.find(rawId) == m_maskedME0IDs.end()) {
98  filteredDigis->put(me0LayerId.second, me0LayerId.first);
99  }
100  }
101  }
102 
103  iEvent.put(std::move(filteredDigis));
104 }
105 
106 // ------------ method called when starting to processes a run ------------
107 
110 
111  m_maskedME0IDs = agingObj->m_ME0ChambEffs;
112 }
113 
114 // ------------ method called when ending the processing of a run ------------
115 
117 
118 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
121  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonME0Digis"));
122  desc.add<bool>("me0Minus", true);
123  desc.add<bool>("me0Plus", true);
124  descriptions.add("me0ChamberMasker", desc);
125 }
126 
127 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
std::string const & label() const
Definition: InputTag.h:36
ME0ChamberMasker(const edm::ParameterSet &)
std::map< unsigned int, float > m_ME0ChambEffs
int iEvent
Definition: GenABIO.cc:224
void beginRun(edm::Run const &, edm::EventSetup const &) override
MuonDigiCollection< ME0DetId, ME0DigiPreReco > ME0DigiPreRecoCollection
void endRun(edm::Run const &, edm::EventSetup const &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::InputTag digiTag_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
~ME0ChamberMasker() override
HLT enums.
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObjTag
std::map< unsigned int, float > m_maskedME0IDs
edm::EDGetTokenT< ME0DigiPreRecoCollection > m_digiTag
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45