CMS 3D CMS Logo

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
electrons_cff.bool
bool
Definition: electrons_cff.py:393
ESHandle.h
MuonSystemAging.h
GEMDigiCollection
MuonDigiCollection< GEMDetId, GEMDigi > GEMDigiCollection
Definition: GEMDigiCollection.h:13
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< GEMDigiCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
GEMChamberMasker::ge11Plus_
bool ge11Plus_
Definition: GEMChamberMasker.cc:46
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
GEMChamberMasker::m_agingObj
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd > m_agingObj
Definition: GEMChamberMasker.cc:51
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
GEMChamberMasker::GEMChamberMasker
GEMChamberMasker(const edm::ParameterSet &)
Definition: GEMChamberMasker.cc:66
edm::Handle< GEMDigiCollection >
ESGetToken.h
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GEMChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: GEMChamberMasker.cc:122
GEMChamberMasker::~GEMChamberMasker
~GEMChamberMasker() override
Definition: GEMChamberMasker.cc:77
edm::ESHandle
Definition: DTSurvey.h:22
GEMChamberMasker::m_digiTag
edm::EDGetTokenT< GEMDigiCollection > m_digiTag
Definition: GEMChamberMasker.cc:50
GEMChamberMasker::ge21Plus_
bool ge21Plus_
Definition: GEMChamberMasker.cc:48
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MuonSystemAgingRcd.h
GEMChamberMasker::m_maskedGEMIDs
std::map< unsigned int, float > m_maskedGEMIDs
Definition: GEMChamberMasker.cc:52
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
GEMChamberMasker::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEMChamberMasker.cc:84
GEMChamberMasker::ge21Minus_
bool ge21Minus_
Definition: GEMChamberMasker.cc:47
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:148
edm::stream::EDProducer
Definition: EDProducer.h:38
GEMChamberMasker::ge11Minus_
bool ge11Minus_
Definition: GEMChamberMasker.cc:45
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
GEMChamberMasker
Definition: GEMChamberMasker.cc:30
edm::ESGetToken< MuonSystemAging, MuonSystemAgingRcd >
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GEMDetId.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Frameworkfwd.h
EventSetup.h
GEMDigiCollection.h
ConsumesCollector.h
ParameterSet.h
GEMChamberMasker::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: GEMChamberMasker.cc:120
edm::Event
Definition: Event.h:73
GEMChamberMasker::digiTag_
edm::InputTag digiTag_
Definition: GEMChamberMasker.cc:44
edm::InputTag
Definition: InputTag.h:15
MuonSystemAging::m_GEMChambEffs
std::map< unsigned int, float > m_GEMChambEffs
Definition: MuonSystemAging.h:22
GEMChamberMasker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: GEMChamberMasker.cc:112