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 
26 
27 //
28 // class declaration
29 //
30 
32 {
33 
34  public:
35  explicit GEMChamberMasker(const edm::ParameterSet&);
36  ~GEMChamberMasker() 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 ---------------------------
48  bool ge11Minus_;
49  bool ge11Plus_;
50  bool ge21Minus_;
51  bool ge21Plus_;
52 
54  std::map<unsigned int, float> m_maskedGEMIDs;
55 
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 
63 //
64 // static data member definitions
65 //
66 
67 //
68 // constructors and destructor
69 //
71  digiTag_(iConfig.getParameter<edm::InputTag>("digiTag") ),
72  ge11Minus_(iConfig.getParameter<bool>("ge11Minus") ),
73  ge11Plus_(iConfig.getParameter<bool>("ge11Plus") ),
74  ge21Minus_(iConfig.getParameter<bool>("ge21Minus") ),
75  ge21Plus_(iConfig.getParameter<bool>("ge21Plus") )
76 {
77 
78  m_digiTag = consumes<GEMDigiCollection>(digiTag_);
79  produces<GEMDigiCollection>();
80 
81 }
82 
83 
85 {
86 
87 }
88 
89 
90 //
91 // member functions
92 //
93 
94 // ------------ method called to produce the data ------------
95 void
97 {
98 
99  using namespace edm;
100  std::unique_ptr<GEMDigiCollection> filteredDigis(new GEMDigiCollection());
101 
102  if (!digiTag_.label().empty())
103  {
105  iEvent.getByToken(m_digiTag, gemDigis);
106 
107 
108  for ( const auto & gemLayerId : (*gemDigis) )
109  {
110  auto chambId = gemLayerId.first.chamberId();
111 
112  bool keepDigi = (!ge11Minus_ && chambId.station()==1 && chambId.region()<0 ) ||
113  (!ge11Plus_ && chambId.station()==1 && chambId.region()>0 ) ||
114  (!ge21Minus_ && chambId.station()==2 && chambId.region()<0 ) ||
115  (!ge21Plus_ && chambId.station()==2 && chambId.region()>0 ) ;
116 
117  uint32_t rawId = chambId.rawId();
118  if(keepDigi || m_maskedGEMIDs.find(rawId) == m_maskedGEMIDs.end())
119  {
120  filteredDigis->put(gemLayerId.second,gemLayerId.first);
121  }
122  }
123 
124  }
125 
126  iEvent.put(std::move(filteredDigis));
127 
128 }
129 
130 // ------------ method called when starting to processes a run ------------
131 
132 void
134 {
135 
137  iSetup.get<MuonSystemAgingRcd>().get(agingObj);
138 
139  m_maskedGEMIDs = agingObj->m_GEMChambEffs;
140 
141 }
142 
143 
144 // ------------ method called when ending the processing of a run ------------
145 
146 void
148 {
149 
150 }
151 
152 void
154 {
155 
157  desc.add<edm::InputTag>("digiTag", edm::InputTag("simMuonGEMDigis"));
158  desc.add<bool>("ge11Minus", true);
159  desc.add<bool>("ge11Plus", true);
160  desc.add<bool>("ge21Minus", true);
161  desc.add<bool>("ge21Plus", true);
162 
163  descriptions.add("gemChamberMasker",desc);
164 
165 }
166 
167 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::EDGetTokenT< GEMDigiCollection > m_digiTag
MuonDigiCollection< GEMDetId, GEMDigi > GEMDigiCollection
void beginRun(edm::Run const &, edm::EventSetup const &) override
std::map< unsigned int, float > m_GEMChambEffs
int iEvent
Definition: GenABIO.cc:230
~GEMChamberMasker() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &, const edm::EventSetup &) override
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
HLT enums.
edm::InputTag digiTag_
T get() const
Definition: EventSetup.h:63
std::map< unsigned int, float > m_maskedGEMIDs
GEMChamberMasker(const edm::ParameterSet &)
void endRun(edm::Run const &, edm::EventSetup const &) override
def move(src, dest)
Definition: eostools.py:510
Definition: Run.h:44