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
22 
29 //
30 // class declaration
31 //
32 
34 public:
35  explicit ME0ChamberMasker(const edm::ParameterSet&);
36  ~ME0ChamberMasker() override;
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40 private:
41  void produce(edm::Event&, const edm::EventSetup&) override;
42 
43  void beginRun(edm::Run const&, edm::EventSetup const&) override;
44  void endRun(edm::Run const&, edm::EventSetup const&) override;
45 
46  // ----------member data ---------------------------
47  bool me0Minus_;
48  bool me0Plus_;
51  std::map<unsigned int, float> m_maskedME0IDs;
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 //
59 // static data member definitions
60 //
61 
62 //
63 // constructors and destructor
64 //
66  : me0Minus_(iConfig.getParameter<bool>("me0Minus")),
67  me0Plus_(iConfig.getParameter<bool>("me0Plus")),
68  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag")) {
69  m_digiTag = consumes<ME0DigiPreRecoCollection>(digiTag_);
70  produces<ME0DigiPreRecoCollection>();
71 }
72 
74 
75 //
76 // member functions
77 //
78 
79 // ------------ method called to produce the data ------------
81  using namespace edm;
82  std::unique_ptr<ME0DigiPreRecoCollection> filteredDigis(new ME0DigiPreRecoCollection());
83 
84  if (!digiTag_.label().empty()) {
86  iEvent.getByToken(m_digiTag, me0Digis);
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 || m_maskedME0IDs.find(rawId) == m_maskedME0IDs.end()) {
95  filteredDigis->put(me0LayerId.second, me0LayerId.first);
96  }
97  }
98  }
99 
100  iEvent.put(std::move(filteredDigis));
101 }
102 
103 // ------------ method called when starting to processes a run ------------
104 
107  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
108 
109  m_maskedME0IDs = agingObj->m_ME0ChambEffs;
110 }
111 
112 // ------------ method called when ending the processing of a run ------------
113 
115 
116 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
119  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonME0Digis"));
120  desc.add<bool>("me0Minus", true);
121  desc.add<bool>("me0Plus", true);
122  descriptions.add("me0ChamberMasker", desc);
123 }
124 
125 //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
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< ME0DigiPreRecoCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ME0ChamberMasker::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ME0ChamberMasker.cc:80
EDProducer.h
ME0EtaPartitionSpecs.h
edm::Handle
Definition: AssociativeIterator.h:50
ME0ChamberMasker::me0Minus_
bool me0Minus_
Definition: ME0ChamberMasker.cc:47
ME0ChamberMasker::m_digiTag
edm::EDGetTokenT< ME0DigiPreRecoCollection > m_digiTag
Definition: ME0ChamberMasker.cc:50
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
MakerMacros.h
ME0ChamberMasker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ME0ChamberMasker.cc:117
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
ME0ChamberMasker::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: ME0ChamberMasker.cc:105
edm::ESHandle
Definition: DTSurvey.h:22
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ME0ChamberMasker::~ME0ChamberMasker
~ME0ChamberMasker() override
Definition: ME0ChamberMasker.cc:73
MuonSystemAgingRcd.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
ME0ChamberMasker::ME0ChamberMasker
ME0ChamberMasker(const edm::ParameterSet &)
Definition: ME0ChamberMasker.cc:65
Event.h
ME0ChamberMasker::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: ME0ChamberMasker.cc:114
ME0ChamberMasker
Definition: ME0ChamberMasker.cc:33
MuonSystemAging::m_ME0ChambEffs
std::map< unsigned int, float > m_ME0ChambEffs
Definition: MuonSystemAging.h:23
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
ME0ChamberMasker::me0Plus_
bool me0Plus_
Definition: ME0ChamberMasker.cc:48
ME0Geometry.h
GeomDet.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
ME0ChamberMasker::digiTag_
edm::InputTag digiTag_
Definition: ME0ChamberMasker.cc:49
writedatasetfile.run
run
Definition: writedatasetfile.py:27
ME0DigiPreRecoCollection.h
Frameworkfwd.h
EventSetup.h
ConsumesCollector.h
ParameterSet.h
edm::Event
Definition: Event.h:73
ME0ChamberMasker::m_maskedME0IDs
std::map< unsigned int, float > m_maskedME0IDs
Definition: ME0ChamberMasker.cc:51
edm::InputTag
Definition: InputTag.h:15
ME0DigiPreRecoCollection
MuonDigiCollection< ME0DetId, ME0DigiPreReco > ME0DigiPreRecoCollection
Definition: ME0DigiPreRecoCollection.h:13