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 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
41  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
42 
43  // ----------member data ---------------------------
44  const bool me0Minus_;
45  const bool me0Plus_;
50 };
51 
52 //
53 // constants, enums and typedefs
54 //
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64  : me0Minus_(iConfig.getParameter<bool>("me0Minus")),
65  me0Plus_(iConfig.getParameter<bool>("me0Plus")),
66  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")),
67  m_digiTag(consumes(digiTag_)),
68  m_putToken(produces()),
69  m_agingObjTag(esConsumes()) {}
70 
71 //
72 // member functions
73 //
74 
75 // ------------ method called to produce the data ------------
77  using namespace edm;
78 
79  MuonSystemAging const& agingObj = iSetup.getData(m_agingObjTag);
80 
81  auto const& maskedME0IDs = agingObj.m_ME0ChambEffs;
82 
83  ME0DigiPreRecoCollection filteredDigis;
84 
85  if (!digiTag_.label().empty()) {
86  ME0DigiPreRecoCollection const& me0Digis = iEvent.get(m_digiTag);
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 || maskedME0IDs.find(rawId) == maskedME0IDs.end()) {
95  filteredDigis.put(me0LayerId.second, me0LayerId.first);
96  }
97  }
98  }
99 
100  iEvent.emplace(m_putToken, std::move(filteredDigis));
101 }
102 
103 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
106  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonME0Digis"));
107  desc.add<bool>("me0Minus", true);
108  desc.add<bool>("me0Plus", true);
109  descriptions.add("me0ChamberMasker", desc);
110 }
111 
112 //define this as a plug-in
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
const edm::EDGetTokenT< ME0DigiPreRecoCollection > m_digiTag
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObjTag
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDPutTokenT< ME0DigiPreRecoCollection > m_putToken
HLT enums.
const edm::InputTag digiTag_
def move(src, dest)
Definition: eostools.py:511