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
18 
24 
25 //
26 // class declaration
27 //
28 
30 public:
31  explicit GEMChamberMasker(const edm::ParameterSet&);
32  ~GEMChamberMasker() override;
33 
34  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
35 
36 private:
37  void produce(edm::Event&, const edm::EventSetup&) override;
38 
39  void beginRun(edm::Run const&, edm::EventSetup const&) override;
40  void endRun(edm::Run const&, edm::EventSetup const&) override;
41 
42  // ----------member data ---------------------------
44  bool ge11Minus_;
45  bool ge11Plus_;
46  bool ge21Minus_;
47  bool ge21Plus_;
48 
50  std::map<unsigned int, float> m_maskedGEMIDs;
51 };
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 //
62 // constructors and destructor
63 //
65  : digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")),
66  ge11Minus_(iConfig.getParameter<bool>("ge11Minus")),
67  ge11Plus_(iConfig.getParameter<bool>("ge11Plus")),
68  ge21Minus_(iConfig.getParameter<bool>("ge21Minus")),
69  ge21Plus_(iConfig.getParameter<bool>("ge21Plus")) {
70  m_digiTag = consumes<GEMDigiCollection>(digiTag_);
71  produces<GEMDigiCollection>();
72 }
73 
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to produce the data ------------
82  using namespace edm;
83  std::unique_ptr<GEMDigiCollection> filteredDigis(new GEMDigiCollection());
84 
85  if (!digiTag_.label().empty()) {
87  iEvent.getByToken(m_digiTag, gemDigis);
88 
89  for (const auto& gemLayerId : (*gemDigis)) {
90  auto chambId = gemLayerId.first.chamberId();
91 
92  bool keepDigi = (!ge11Minus_ && chambId.station() == 1 && chambId.region() < 0) ||
93  (!ge11Plus_ && chambId.station() == 1 && chambId.region() > 0) ||
94  (!ge21Minus_ && chambId.station() == 2 && chambId.region() < 0) ||
95  (!ge21Plus_ && chambId.station() == 2 && chambId.region() > 0);
96 
97  uint32_t rawId = chambId.rawId();
98  if (keepDigi || m_maskedGEMIDs.find(rawId) == m_maskedGEMIDs.end()) {
99  filteredDigis->put(gemLayerId.second, gemLayerId.first);
100  }
101  }
102  }
103 
104  iEvent.put(std::move(filteredDigis));
105 }
106 
107 // ------------ method called when starting to processes a run ------------
108 
111  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
112 
113  m_maskedGEMIDs = agingObj->m_GEMChambEffs;
114 }
115 
116 // ------------ method called when ending the processing of a run ------------
117 
119 
122  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonGEMDigis"));
123  desc.add<bool>("ge11Minus", true);
124  desc.add<bool>("ge11Plus", true);
125  desc.add<bool>("ge21Minus", true);
126  desc.add<bool>("ge21Plus", true);
127 
128  descriptions.add("gemChamberMasker", desc);
129 }
130 
131 //define this as a plug-in
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
ESHandle.h
MuonSystemAging.h
MuonSystemAgingRcd
Definition: MuonSystemAgingRcd.h:20
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:45
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EDProducer.h
GEMChamberMasker::GEMChamberMasker
GEMChamberMasker(const edm::ParameterSet &)
Definition: GEMChamberMasker.cc:64
edm::Handle< GEMDigiCollection >
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
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:120
GEMChamberMasker::~GEMChamberMasker
~GEMChamberMasker() override
Definition: GEMChamberMasker.cc:74
edm::ESHandle
Definition: DTSurvey.h:22
GEMChamberMasker::m_digiTag
edm::EDGetTokenT< GEMDigiCollection > m_digiTag
Definition: GEMChamberMasker.cc:49
GEMChamberMasker::ge21Plus_
bool ge21Plus_
Definition: GEMChamberMasker.cc:47
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
MuonSystemAgingRcd.h
GEMChamberMasker::m_maskedGEMIDs
std::map< unsigned int, float > m_maskedGEMIDs
Definition: GEMChamberMasker.cc:50
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
GEMChamberMasker::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: GEMChamberMasker.cc:81
GEMChamberMasker::ge21Minus_
bool ge21Minus_
Definition: GEMChamberMasker.cc:46
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
GEMChamberMasker::ge11Minus_
bool ge11Minus_
Definition: GEMChamberMasker.cc:44
edm::EventSetup
Definition: EventSetup.h:57
DetSetVector.h
GEMChamberMasker
Definition: GEMChamberMasker.cc:29
get
#define get
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:118
edm::Event
Definition: Event.h:73
GEMChamberMasker::digiTag_
edm::InputTag digiTag_
Definition: GEMChamberMasker.cc:43
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:109