CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GEMChamberMasker.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <string>
4 #include <vector>
5 #include <iostream>
6 #include <algorithm>
7 #include <regex>
8 
9 // user include files
19 
25 
26 //
27 // class declaration
28 //
29 
31 public:
32  explicit GEMChamberMasker(const edm::ParameterSet&);
33  ~GEMChamberMasker() override;
34 
35  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
36 
37 private:
38  void produce(edm::Event&, const edm::EventSetup&) override;
39 
40  void beginRun(edm::Run const&, edm::EventSetup const&) override;
41  void endRun(edm::Run const&, edm::EventSetup const&) override;
42 
43  // ----------member data ---------------------------
45  bool ge11Minus_;
46  bool ge11Plus_;
47  bool ge21Minus_;
48  bool ge21Plus_;
49 
52  std::map<unsigned int, float> m_maskedGEMIDs;
53 };
54 
55 //
56 // constants, enums and typedefs
57 //
58 
59 //
60 // static data member definitions
61 //
62 
63 //
64 // constructors and destructor
65 //
67  : digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")),
68  ge11Minus_(iConfig.getParameter<bool>("ge11Minus")),
69  ge11Plus_(iConfig.getParameter<bool>("ge11Plus")),
70  ge21Minus_(iConfig.getParameter<bool>("ge21Minus")),
71  ge21Plus_(iConfig.getParameter<bool>("ge21Plus")) {
72  m_digiTag = consumes<GEMDigiCollection>(digiTag_);
73  m_agingObj = esConsumes<MuonSystemAging, MuonSystemAgingRcd, edm::Transition::BeginRun>();
74  produces<GEMDigiCollection>();
75 }
76 
78 
79 //
80 // member functions
81 //
82 
83 // ------------ method called to produce the data ------------
85  using namespace edm;
86  std::unique_ptr<GEMDigiCollection> filteredDigis(new GEMDigiCollection());
87 
88  if (!digiTag_.label().empty()) {
90  iEvent.getByToken(m_digiTag, gemDigis);
91 
92  for (const auto& gemLayerId : (*gemDigis)) {
93  auto chambId = gemLayerId.first.chamberId();
94 
95  bool keepDigi = (!ge11Minus_ && chambId.station() == 1 && chambId.region() < 0) ||
96  (!ge11Plus_ && chambId.station() == 1 && chambId.region() > 0) ||
97  (!ge21Minus_ && chambId.station() == 2 && chambId.region() < 0) ||
98  (!ge21Plus_ && chambId.station() == 2 && chambId.region() > 0);
99 
100  uint32_t rawId = chambId.rawId();
101  if (keepDigi || m_maskedGEMIDs.find(rawId) == m_maskedGEMIDs.end()) {
102  filteredDigis->put(gemLayerId.second, gemLayerId.first);
103  }
104  }
105  }
106 
107  iEvent.put(std::move(filteredDigis));
108 }
109 
110 // ------------ method called when starting to processes a run ------------
111 
114 
115  m_maskedGEMIDs = agingObj->m_GEMChambEffs;
116 }
117 
118 // ------------ method called when ending the processing of a run ------------
119 
121 
124  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonGEMDigis"));
125  desc.add<bool>("ge11Minus", true);
126  desc.add<bool>("ge11Plus", true);
127  desc.add<bool>("ge21Minus", true);
128  desc.add<bool>("ge21Plus", true);
129 
130  descriptions.add("gemChamberMasker", desc);
131 }
132 
133 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< GEMDigiCollection > m_digiTag
MuonDigiCollection< GEMDetId, GEMDigi > GEMDigiCollection
void beginRun(edm::Run const &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:224
~GEMChamberMasker() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObj
void produce(edm::Event &, const edm::EventSetup &) override
def move
Definition: eostools.py:511
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & label() const
Definition: InputTag.h:36
edm::InputTag digiTag_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
std::map< unsigned int, float > m_maskedGEMIDs
GEMChamberMasker(const edm::ParameterSet &)
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:45