CMS 3D CMS Logo

ME0ChamberMasker.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Class: ME0ChamberMasker
3 //
4 
5 
6 // system include files
7 #include <memory>
8 #include <string>
9 #include <vector>
10 #include <iostream>
11 #include <algorithm>
12 #include <regex>
13 
14 // user include files
23 
30 //
31 // class declaration
32 //
33 
35 {
36 
37  public:
38  explicit ME0ChamberMasker(const edm::ParameterSet&);
39  ~ME0ChamberMasker() override;
40 
41  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
42 
43  private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  void beginRun(edm::Run const&, edm::EventSetup const&) override;
47  void endRun(edm::Run const&, edm::EventSetup const&) override;
48 
49  // ----------member data ---------------------------
50  bool me0Minus_;
51  bool me0Plus_;
54  std::map<unsigned int, float> m_maskedME0IDs;
55 
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 
63 //
64 // static data member definitions
65 //
66 
67 //
68 // constructors and destructor
69 //
71  me0Minus_(iConfig.getParameter<bool>("me0Minus") ),
72  me0Plus_(iConfig.getParameter<bool>("me0Plus") ),
73  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag") )
74 {
75 
76  m_digiTag = consumes<ME0DigiPreRecoCollection>(digiTag_);
77  produces<ME0DigiPreRecoCollection>();
78 
79 }
80 
81 
83 {
84 
85 }
86 
87 //
88 // member functions
89 //
90 
91 // ------------ method called to produce the data ------------
92 void
94 {
95 
96  using namespace edm;
97  std::unique_ptr<ME0DigiPreRecoCollection> filteredDigis(new ME0DigiPreRecoCollection());
98 
99  if (!digiTag_.label().empty())
100  {
102  iEvent.getByToken(m_digiTag, me0Digis);
103 
104  for ( const auto & me0LayerId : (*me0Digis) )
105  {
106 
107  auto chambId = me0LayerId.first.chamberId();
108 
109  bool keepDigi = (!me0Minus_ && chambId.region() < 0 ) ||
110  (!me0Plus_ && chambId.region() > 0 ) ;
111 
112  uint32_t rawId = chambId.rawId();
113  if(keepDigi || m_maskedME0IDs.find(rawId) == m_maskedME0IDs.end())
114  {
115  filteredDigis->put(me0LayerId.second,me0LayerId.first);
116  }
117 
118  }
119  }
120 
121  iEvent.put(std::move(filteredDigis));
122 
123 }
124 
125 // ------------ method called when starting to processes a run ------------
126 
127 void
129 {
130 
132  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
133 
134  m_maskedME0IDs = agingObj->m_ME0ChambEffs;
135 
136 }
137 
138 
139 // ------------ method called when ending the processing of a run ------------
140 
141 void
143 {
144 
145 }
146 
147 
148 
149 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
150 void
152 {
153 
155  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonME0Digis"));
156  desc.add<bool>("me0Minus", true);
157  desc.add<bool>("me0Plus", true);
158  descriptions.add("me0ChamberMasker",desc);
159 
160 }
161 
162 //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:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ME0ChamberMasker(const edm::ParameterSet &)
std::map< unsigned int, float > m_ME0ChambEffs
int iEvent
Definition: GenABIO.cc:230
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:62
std::map< unsigned int, float > m_maskedME0IDs
edm::EDGetTokenT< ME0DigiPreRecoCollection > m_digiTag
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:44