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
22 
29 //
30 // class declaration
31 //
32 
34 public:
35  explicit ME0ChamberMasker(const edm::ParameterSet&);
36  ~ME0ChamberMasker() override;
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
41  void produce(edm::Event&, const edm::EventSetup&) override;
42 
43  void beginRun(edm::Run const&, edm::EventSetup const&) override;
44  void endRun(edm::Run const&, edm::EventSetup const&) override;
45 
46  // ----------member data ---------------------------
47  bool me0Minus_;
48  bool me0Plus_;
51  std::map<unsigned int, float> m_maskedME0IDs;
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
66  : me0Minus_(iConfig.getParameter<bool>("me0Minus")),
67  me0Plus_(iConfig.getParameter<bool>("me0Plus")),
68  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")) {
69  m_digiTag = consumes<ME0DigiPreRecoCollection>(digiTag_);
70  produces<ME0DigiPreRecoCollection>();
71 }
72 
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
81  using namespace edm;
82  std::unique_ptr<ME0DigiPreRecoCollection> filteredDigis(new ME0DigiPreRecoCollection());
83 
84  if (!digiTag_.label().empty()) {
86  iEvent.getByToken(m_digiTag, me0Digis);
87 
88  for (const auto& me0LayerId : (*me0Digis)) {
89  auto chambId = me0LayerId.first.chamberId();
90 
91  bool keepDigi = (!me0Minus_ && chambId.region() < 0) || (!me0Plus_ && chambId.region() > 0);
92 
93  uint32_t rawId = chambId.rawId();
94  if (keepDigi || m_maskedME0IDs.find(rawId) == m_maskedME0IDs.end()) {
95  filteredDigis->put(me0LayerId.second, me0LayerId.first);
96  }
97  }
98  }
99 
100  iEvent.put(std::move(filteredDigis));
101 }
102 
103 // ------------ method called when starting to processes a run ------------
104 
107  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
108 
109  m_maskedME0IDs = agingObj->m_ME0ChambEffs;
110 }
111 
112 // ------------ method called when ending the processing of a run ------------
113 
115 
116 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
119  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonME0Digis"));
120  desc.add<bool>("me0Minus", true);
121  desc.add<bool>("me0Plus", true);
122  descriptions.add("me0ChamberMasker", desc);
123 }
124 
125 //define this as a plug-in
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
ME0ChamberMasker(const edm::ParameterSet &)
std::map< unsigned int, float > m_ME0ChambEffs
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::InputTag digiTag_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & label() const
Definition: InputTag.h:36
~ME0ChamberMasker() override
HLT enums.
T get() const
Definition: EventSetup.h:73
std::map< unsigned int, float > m_maskedME0IDs
edm::EDGetTokenT< ME0DigiPreRecoCollection > m_digiTag
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45