CMS 3D CMS Logo

RPCTnPEfficiencyTask.cc
Go to the documentation of this file.
1 /*
2  * \file RPCTnPEfficiencyTask.cc
3  *
4  * \author L. Lunerti - INFN Bologna
5  *
6  */
7 
9 
12 
14 
16 public:
19 
21  ~RPCTnPEfficiencyTask() override;
22 
23 protected:
24  std::string topFolder() const override;
25 
26  void bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const& context) override;
27 
29  void bookWheelHistos(DQMStore::IBooker& iBooker, int wheel, std::string folder = "");
30 
32  void bookEndcapHistos(DQMStore::IBooker& iBooker, int stations, std::string folder = "");
33 
34  int get_barrel_histo_ycoord(int ring, int station, int sector, int layer, int subsector, int roll);
35 
37  void analyze(const edm::Event& event, const edm::EventSetup& context) override;
38 };
39 
41  LogTrace("DQMOffline|MuonDPG|RPCTnPEfficiencyTask") << "[RPCTnPEfficiencyTask]: Constructor" << std::endl;
42 }
43 
45  LogTrace("DQMOffline|MuonDPG|RPCTnPEfficiencyTask")
46  << "[RPCTnPEfficiencyTask]: analyzed " << m_nEvents << " events" << std::endl;
47 }
48 
50  edm::Run const& run,
51  edm::EventSetup const& context) {
53 
54  LogTrace("DQMOffline|MuonDPG|RPCTnPEfficiencyTask") << "[RPCTnPEfficiencyTask]: bookHistograms" << std::endl;
55 
56  for (int wheel = -2; wheel <= 2; ++wheel) {
57  bookWheelHistos(iBooker, wheel, "Task");
58  }
59 
60  for (int station = -4; station <= 4; ++station) {
61  if (station == 0)
62  continue;
63  bookEndcapHistos(iBooker, station, "Task");
64  }
65 
66  auto baseDir = topFolder() + "Task/";
67  iBooker.setCurrentFolder(baseDir);
68 
69  MonitorElement* me_RPC_barrel_pass_allCh_1D =
70  iBooker.book1D("RPC_nPassingProbe_Barrel_allCh_1D", "RPC_nPassingProbe_Barrel_allCh_1D", 20, 0.5, 20.5);
71  MonitorElement* me_RPC_barrel_fail_allCh_1D =
72  iBooker.book1D("RPC_nFailingProbe_Barrel_allCh_1D", "RPC_nFailingProbe_Barrel_allCh_1D", 20, 0.5, 20.5);
73 
74  MonitorElement* me_RPC_endcap_pass_allCh_1D =
75  iBooker.book1D("RPC_nPassingProbe_Endcap_allCh_1D", "RPC_nPassingProbe_Endcap_allCh_1D", 9, -4., 5.);
76  MonitorElement* me_RPC_endcap_fail_allCh_1D =
77  iBooker.book1D("RPC_nFailingProbe_Endcap_allCh_1D", "RPC_nFailingProbe_Endcap_allCh_1D", 9, -4., 5.);
78 
79  me_RPC_barrel_pass_allCh_1D->setBinLabel(1, "RB1/YB-2", 1);
80  me_RPC_barrel_pass_allCh_1D->setBinLabel(2, "RB2/YB-2", 1);
81  me_RPC_barrel_pass_allCh_1D->setBinLabel(3, "RB3/YB-2", 1);
82  me_RPC_barrel_pass_allCh_1D->setBinLabel(4, "RB4/YB-2", 1);
83  me_RPC_barrel_pass_allCh_1D->setBinLabel(5, "RB1/YB-1", 1);
84  me_RPC_barrel_pass_allCh_1D->setBinLabel(6, "RB2/YB-1", 1);
85  me_RPC_barrel_pass_allCh_1D->setBinLabel(7, "RB3/YB-1", 1);
86  me_RPC_barrel_pass_allCh_1D->setBinLabel(8, "RB4/YB-1", 1);
87  me_RPC_barrel_pass_allCh_1D->setBinLabel(9, "RB1/YB0", 1);
88  me_RPC_barrel_pass_allCh_1D->setBinLabel(10, "RB2/YB0", 1);
89  me_RPC_barrel_pass_allCh_1D->setBinLabel(11, "RB3/YB0", 1);
90  me_RPC_barrel_pass_allCh_1D->setBinLabel(12, "RB4/YB0", 1);
91  me_RPC_barrel_pass_allCh_1D->setBinLabel(13, "RB1/YB1", 1);
92  me_RPC_barrel_pass_allCh_1D->setBinLabel(14, "RB2/YB1", 1);
93  me_RPC_barrel_pass_allCh_1D->setBinLabel(15, "RB3/YB1", 1);
94  me_RPC_barrel_pass_allCh_1D->setBinLabel(16, "RB4/YB1", 1);
95  me_RPC_barrel_pass_allCh_1D->setBinLabel(17, "RB1/YB2", 1);
96  me_RPC_barrel_pass_allCh_1D->setBinLabel(18, "RB2/YB2", 1);
97  me_RPC_barrel_pass_allCh_1D->setBinLabel(19, "RB3/YB2", 1);
98  me_RPC_barrel_pass_allCh_1D->setBinLabel(20, "RB4/YB2", 1);
99  me_RPC_barrel_pass_allCh_1D->setAxisTitle("Number of passing probes", 2);
100 
101  me_RPC_barrel_fail_allCh_1D->setBinLabel(1, "RB1/YB-2", 1);
102  me_RPC_barrel_fail_allCh_1D->setBinLabel(2, "RB2/YB-2", 1);
103  me_RPC_barrel_fail_allCh_1D->setBinLabel(3, "RB3/YB-2", 1);
104  me_RPC_barrel_fail_allCh_1D->setBinLabel(4, "RB4/YB-2", 1);
105  me_RPC_barrel_fail_allCh_1D->setBinLabel(5, "RB1/YB-1", 1);
106  me_RPC_barrel_fail_allCh_1D->setBinLabel(6, "RB2/YB-1", 1);
107  me_RPC_barrel_fail_allCh_1D->setBinLabel(7, "RB3/YB-1", 1);
108  me_RPC_barrel_fail_allCh_1D->setBinLabel(8, "RB4/YB-1", 1);
109  me_RPC_barrel_fail_allCh_1D->setBinLabel(9, "RB1/YB0", 1);
110  me_RPC_barrel_fail_allCh_1D->setBinLabel(10, "RB2/YB0", 1);
111  me_RPC_barrel_fail_allCh_1D->setBinLabel(11, "RB3/YB0", 1);
112  me_RPC_barrel_fail_allCh_1D->setBinLabel(12, "RB4/YB0", 1);
113  me_RPC_barrel_fail_allCh_1D->setBinLabel(13, "RB1/YB1", 1);
114  me_RPC_barrel_fail_allCh_1D->setBinLabel(14, "RB2/YB1", 1);
115  me_RPC_barrel_fail_allCh_1D->setBinLabel(15, "RB3/YB1", 1);
116  me_RPC_barrel_fail_allCh_1D->setBinLabel(16, "RB4/YB1", 1);
117  me_RPC_barrel_fail_allCh_1D->setBinLabel(17, "RB1/YB2", 1);
118  me_RPC_barrel_fail_allCh_1D->setBinLabel(18, "RB2/YB2", 1);
119  me_RPC_barrel_fail_allCh_1D->setBinLabel(19, "RB3/YB2", 1);
120  me_RPC_barrel_fail_allCh_1D->setBinLabel(20, "RB4/YB2", 1);
121  me_RPC_barrel_fail_allCh_1D->setAxisTitle("Number of failing probes", 2);
122 
123  me_RPC_endcap_pass_allCh_1D->setBinLabel(1, "RE-4", 1);
124  me_RPC_endcap_pass_allCh_1D->setBinLabel(2, "RE-3", 1);
125  me_RPC_endcap_pass_allCh_1D->setBinLabel(3, "RE-2", 1);
126  me_RPC_endcap_pass_allCh_1D->setBinLabel(4, "RE-1", 1);
127  me_RPC_endcap_pass_allCh_1D->setBinLabel(6, "RE1", 1);
128  me_RPC_endcap_pass_allCh_1D->setBinLabel(7, "RE2", 1);
129  me_RPC_endcap_pass_allCh_1D->setBinLabel(8, "RE3", 1);
130  me_RPC_endcap_pass_allCh_1D->setBinLabel(9, "RE4", 1);
131  me_RPC_endcap_pass_allCh_1D->setAxisTitle("Number of passing probes", 2);
132 
133  me_RPC_endcap_fail_allCh_1D->setBinLabel(1, "RE-4", 1);
134  me_RPC_endcap_fail_allCh_1D->setBinLabel(2, "RE-3", 1);
135  me_RPC_endcap_fail_allCh_1D->setBinLabel(3, "RE-2", 1);
136  me_RPC_endcap_fail_allCh_1D->setBinLabel(4, "RE-1", 1);
137  me_RPC_endcap_fail_allCh_1D->setBinLabel(6, "RE1", 1);
138  me_RPC_endcap_fail_allCh_1D->setBinLabel(7, "RE2", 1);
139  me_RPC_endcap_fail_allCh_1D->setBinLabel(8, "RE3", 1);
140  me_RPC_endcap_fail_allCh_1D->setBinLabel(9, "RE4", 1);
141  me_RPC_endcap_fail_allCh_1D->setAxisTitle("Number of failing probes", 2);
142 
143  m_histos["RPC_nPassingProbe_Barrel_allCh_1D"] = me_RPC_barrel_pass_allCh_1D;
144  m_histos["RPC_nFailingProbe_Barrel_allCh_1D"] = me_RPC_barrel_fail_allCh_1D;
145 
146  m_histos["RPC_nPassingProbe_Endcap_allCh_1D"] = me_RPC_endcap_pass_allCh_1D;
147  m_histos["RPC_nFailingProbe_Endcap_allCh_1D"] = me_RPC_endcap_fail_allCh_1D;
148 }
149 
152 
154  event.getByToken(m_muToken, muons);
155 
156  //RPC variables
157  std::vector<std::vector<int>> probe_coll_RPC_region;
158  std::vector<std::vector<int>> probe_coll_RPC_ring;
159  std::vector<std::vector<int>> probe_coll_RPC_sta;
160  std::vector<std::vector<int>> probe_coll_RPC_sec;
161  std::vector<std::vector<int>> probe_coll_RPC_lay;
162  std::vector<std::vector<int>> probe_coll_RPC_sub;
163  std::vector<std::vector<int>> probe_coll_RPC_roll;
164  std::vector<std::vector<float>> probe_coll_RPC_dx;
165  std::vector<uint8_t> probe_coll_RPC_staMatch;
166 
167  std::vector<unsigned> probe_indices;
168  if (!m_probeIndices.empty())
169  probe_indices = m_probeIndices.back();
170 
171  //Fill probe dx + subdetector coordinates
172  for (const auto i : probe_indices) {
173  //RPC variables
174  std::vector<int> probe_RPC_region;
175  std::vector<int> probe_RPC_ring;
176  std::vector<int> probe_RPC_sta;
177  std::vector<int> probe_RPC_sec;
178  std::vector<int> probe_RPC_lay;
179  std::vector<int> probe_RPC_sub;
180  std::vector<int> probe_RPC_roll;
181  std::vector<float> probe_RPC_dx;
182  uint8_t RPC_stationMatching = 0;
183 
184  float rpc_matched = false; // fill detailed plots only for probes matching RPC
185 
186  for (const auto& chambMatch : (*muons).at(i).matches()) {
187  // look in RPCs
188  if (chambMatch.detector() == MuonSubdetId::RPC) {
189  if (chambMatch.edgeX < m_borderCut && chambMatch.edgeY < m_borderCut) {
190  rpc_matched = true; //fill detailed plots if at least one RPC match
191 
192  RPCDetId chId(chambMatch.id.rawId());
193 
194  int region = chId.region(); // barrel if 0, endcap if -/+ 1
195  int ring = chId.ring(); // means wheel in the barrel and ring in the endcap
196  int station = chId.station();
197  int sector = chId.sector();
198  int subsector = chId.subsector();
199  int layer = chId.layer();
200  int roll = chId.roll();
201 
202  reco::MuonRPCHitMatch closest_matchedRPCHit;
203  double smallestDx = 999.;
204  for (auto& seg : chambMatch.rpcMatches) {
205  float dx = std::abs(chambMatch.x - seg.x);
206 
207  if (dx < smallestDx) {
208  smallestDx = dx;
209  closest_matchedRPCHit = seg;
210  }
211  }
212 
213  RPC_stationMatching = RPC_stationMatching | (1 << (station - 1));
214 
215  probe_RPC_region.push_back(region);
216  probe_RPC_ring.push_back(ring);
217  probe_RPC_sta.push_back(station);
218  probe_RPC_sec.push_back(sector);
219  probe_RPC_lay.push_back(layer);
220  probe_RPC_sub.push_back(subsector);
221  probe_RPC_roll.push_back(roll);
222  probe_RPC_dx.push_back(smallestDx);
223  }
224  } else
225  continue;
226  } //loop over chamber matches
227 
228  //Fill detailed plots
229  if (m_detailedAnalysis && rpc_matched) {
230  m_histos.find("probeEta")->second->Fill((*muons).at(i).eta());
231  m_histos.find("probePhi")->second->Fill((*muons).at(i).phi());
232  m_histos.find("probeNumberOfMatchedStations")->second->Fill((*muons).at(i).numberOfMatchedStations());
233  m_histos.find("probePt")->second->Fill((*muons).at(i).pt());
234  }
235 
236  //Fill RPC variables
237  probe_coll_RPC_region.push_back(probe_RPC_region);
238  probe_coll_RPC_ring.push_back(probe_RPC_ring);
239  probe_coll_RPC_sta.push_back(probe_RPC_sta);
240  probe_coll_RPC_sec.push_back(probe_RPC_sec);
241  probe_coll_RPC_lay.push_back(probe_RPC_lay);
242  probe_coll_RPC_sub.push_back(probe_RPC_sub);
243  probe_coll_RPC_roll.push_back(probe_RPC_roll);
244  probe_coll_RPC_dx.push_back(probe_RPC_dx);
245  probe_coll_RPC_staMatch.push_back(RPC_stationMatching);
246  } //loop over probe collection
247 
248  //Loop over probes
249  for (unsigned i = 0; i < probe_indices.size(); ++i) {
250  uint8_t RPC_matchPatt = probe_coll_RPC_staMatch.at(i);
251 
252  //Loop over RPC matches
253  unsigned nRPC_matches = probe_coll_RPC_region.at(i).size();
254  for (unsigned j = 0; j < nRPC_matches; ++j) {
255  //RPC variables
256  int RPC_region = probe_coll_RPC_region.at(i).at(j);
257  int RPC_ring = probe_coll_RPC_ring.at(i).at(j);
258  int RPC_sta = probe_coll_RPC_sta.at(i).at(j);
259  int RPC_sec = probe_coll_RPC_sec.at(i).at(j);
260  int RPC_lay = probe_coll_RPC_lay.at(i).at(j);
261  int RPC_subsec = probe_coll_RPC_sub.at(i).at(j);
262  int RPC_roll = probe_coll_RPC_roll.at(i).at(j);
263  float RPC_dx = probe_coll_RPC_dx.at(i).at(j);
264 
265  //Fill RPC plots
266  if ((RPC_matchPatt & (1 << (RPC_sta - 1))) != 0) //avoids 0 station matching
267  {
268  if (RPC_dx < m_dxCut) {
269  //Barrel region
270  if (RPC_region == 0) {
271  int barrel_histo_xcoord = RPC_sec;
272  int barrel_histo_ycoord =
273  get_barrel_histo_ycoord(RPC_ring, RPC_sta, RPC_sec, RPC_lay, RPC_subsec, RPC_roll);
274 
275  std::string hName = std::string("RPC_nPassingProbePerRoll_Barrel_W") + std::to_string(RPC_ring);
276  m_histos.find(hName)->second->Fill(barrel_histo_xcoord, barrel_histo_ycoord);
277 
278  std::string hName_1D = std::string("RPC_nPassingProbePerRoll_Barrel_1D_W") + std::to_string(RPC_ring);
279  m_histos.find(hName_1D)->second->Fill(barrel_histo_ycoord);
280 
281  m_histos.find("RPC_nPassingProbe_Barrel_allCh_1D")->second->Fill((RPC_sta) + 4 * (RPC_ring + 2));
282  }
283  //Endcap region
284  else {
285  int endcap_histo_xcoord = (6 * (RPC_sec - 1)) + RPC_subsec;
286  int endcap_histo_ycoord = (3 * (RPC_ring - 2)) + RPC_roll;
287 
288  std::string hName =
289  std::string("RPC_nPassingProbePerRoll_Endcap_Sta") + std::to_string(RPC_sta * RPC_region);
290  m_histos.find(hName)->second->Fill(endcap_histo_xcoord, endcap_histo_ycoord);
291 
292  std::string hName_1D =
293  std::string("RPC_nPassingProbePerRoll_Endcap_1D_Sta") + std::to_string(RPC_sta * RPC_region);
294  m_histos.find(hName_1D)->second->Fill(endcap_histo_ycoord);
295 
296  m_histos.find("RPC_nPassingProbe_Endcap_allCh_1D")->second->Fill(RPC_region * RPC_sta);
297  }
298  } else {
299  //Barrel region
300  if (RPC_region == 0) {
301  int barrel_histo_xcoord = RPC_sec;
302  int barrel_histo_ycoord =
303  get_barrel_histo_ycoord(RPC_ring, RPC_sta, RPC_sec, RPC_lay, RPC_subsec, RPC_roll);
304 
305  std::string hName = std::string("RPC_nFailingProbePerRoll_Barrel_W") + std::to_string(RPC_ring);
306  m_histos.find(hName)->second->Fill(barrel_histo_xcoord, barrel_histo_ycoord);
307 
308  std::string hName_1D = std::string("RPC_nFailingProbePerRoll_Barrel_1D_W") + std::to_string(RPC_ring);
309  m_histos.find(hName_1D)->second->Fill(barrel_histo_ycoord);
310 
311  m_histos.find("RPC_nFailingProbe_Barrel_allCh_1D")->second->Fill((RPC_sta) + 4 * (RPC_ring + 2));
312  }
313  //Endcap region
314  else {
315  int endcap_histo_xcoord = (6 * (RPC_sec - 1)) + RPC_subsec;
316  int endcap_histo_ycoord = (3 * (RPC_ring - 2)) + RPC_roll;
317 
318  std::string hName =
319  std::string("RPC_nFailingProbePerRoll_Endcap_Sta") + std::to_string(RPC_sta * RPC_region);
320  m_histos.find(hName)->second->Fill(endcap_histo_xcoord, endcap_histo_ycoord);
321 
322  std::string hName_1D =
323  std::string("RPC_nFailingProbePerRoll_Endcap_1D_Sta") + std::to_string(RPC_sta * RPC_region);
324  m_histos.find(hName_1D)->second->Fill(endcap_histo_ycoord);
325 
326  m_histos.find("RPC_nFailingProbe_Endcap_allCh_1D")->second->Fill(RPC_region * RPC_sta);
327  }
328  }
329  }
330  }
331  }
332 }
333 
335  auto baseDir = topFolder() + folder + "/";
336  iBooker.setCurrentFolder(baseDir);
337 
338  LogTrace("DQMOffline|MuonDPG|RPCTnPEfficiencyTask")
339  << "[RPCTnPEfficiencyTask]: booking histos in " << baseDir << std::endl;
340 
341  auto hName_RPC_pass = std::string("RPC_nPassingProbePerRoll_Barrel_W") + std::to_string(wheel);
342  auto hName_RPC_fail = std::string("RPC_nFailingProbePerRoll_Barrel_W") + std::to_string(wheel);
343 
344  auto hName_RPC_pass_1D = std::string("RPC_nPassingProbePerRoll_Barrel_1D_W") + std::to_string(wheel);
345  auto hName_RPC_fail_1D = std::string("RPC_nFailingProbePerRoll_Barrel_1D_W") + std::to_string(wheel);
346 
347  MonitorElement* me_RPC_pass =
348  iBooker.book2D(hName_RPC_pass.c_str(), hName_RPC_pass.c_str(), 12, 0.5, 12.5, 21, 0., 21.5);
349  MonitorElement* me_RPC_fail =
350  iBooker.book2D(hName_RPC_fail.c_str(), hName_RPC_fail.c_str(), 12, 0.5, 12.5, 21, 0., 21.5);
351 
352  MonitorElement* me_RPC_pass_1D = iBooker.book1D(hName_RPC_pass_1D.c_str(), hName_RPC_pass_1D.c_str(), 21, 0., 21.5);
353  MonitorElement* me_RPC_fail_1D = iBooker.book1D(hName_RPC_fail_1D.c_str(), hName_RPC_fail_1D.c_str(), 21, 0., 21.5);
354 
355  me_RPC_pass->setBinLabel(1, "RB1in B", 2);
356  me_RPC_pass->setBinLabel(2, "RB1in F", 2);
357  me_RPC_pass->setBinLabel(3, "RB1out B", 2);
358  me_RPC_pass->setBinLabel(4, "RB1out F", 2);
359  if (std::abs(wheel) < 2) {
360  me_RPC_pass->setBinLabel(5, "RB2in B", 2);
361  me_RPC_pass->setBinLabel(6, "RB2in M", 2);
362  me_RPC_pass->setBinLabel(7, "RB2in F", 2);
363  me_RPC_pass->setBinLabel(8, "RB2out B", 2);
364  me_RPC_pass->setBinLabel(9, "RB2out F", 2);
365  } else {
366  me_RPC_pass->setBinLabel(5, "RB2in B", 2);
367  me_RPC_pass->setBinLabel(6, "RB2in F", 2);
368  me_RPC_pass->setBinLabel(7, "RB2out B", 2);
369  me_RPC_pass->setBinLabel(8, "RB2out M", 2);
370  me_RPC_pass->setBinLabel(9, "RB2out F", 2);
371  }
372  me_RPC_pass->setBinLabel(10, "RB3- B", 2);
373  me_RPC_pass->setBinLabel(11, "RB3- F", 2);
374  me_RPC_pass->setBinLabel(12, "RB3+ B", 2);
375  me_RPC_pass->setBinLabel(13, "RB3+ F", 2);
376  me_RPC_pass->setBinLabel(14, "RB4- B", 2);
377  me_RPC_pass->setBinLabel(15, "RB4- F", 2);
378  me_RPC_pass->setBinLabel(16, "RB4+ B", 2);
379  me_RPC_pass->setBinLabel(17, "RB4+ F", 2);
380  me_RPC_pass->setBinLabel(18, "RB4-- B", 2);
381  me_RPC_pass->setBinLabel(19, "RB4-- F", 2);
382  me_RPC_pass->setBinLabel(20, "RB4++ B", 2);
383  me_RPC_pass->setBinLabel(21, "RB4++ F", 2);
384  for (int i = 1; i < 13; ++i) {
385  me_RPC_pass->setBinLabel(i, std::to_string(i), 1);
386  }
387  me_RPC_pass->setAxisTitle("Sector", 1);
388  me_RPC_pass->setAxisTitle("Number of passing probes", 3);
389 
390  me_RPC_fail->setBinLabel(1, "RB1in B", 2);
391  me_RPC_fail->setBinLabel(2, "RB1in F", 2);
392  me_RPC_fail->setBinLabel(3, "RB1out B", 2);
393  me_RPC_fail->setBinLabel(4, "RB1out F", 2);
394  if (std::abs(wheel) < 2) {
395  me_RPC_fail->setBinLabel(5, "RB2in B", 2);
396  me_RPC_fail->setBinLabel(6, "RB2in M", 2);
397  me_RPC_fail->setBinLabel(7, "RB2in F", 2);
398  me_RPC_fail->setBinLabel(8, "RB2out B", 2);
399  me_RPC_fail->setBinLabel(9, "RB2out F", 2);
400  } else {
401  me_RPC_fail->setBinLabel(5, "RB2in B", 2);
402  me_RPC_fail->setBinLabel(6, "RB2in F", 2);
403  me_RPC_fail->setBinLabel(7, "RB2out B", 2);
404  me_RPC_fail->setBinLabel(8, "RB2out M", 2);
405  me_RPC_fail->setBinLabel(9, "RB2out F", 2);
406  }
407  me_RPC_fail->setBinLabel(10, "RB3- B", 2);
408  me_RPC_fail->setBinLabel(11, "RB3- F", 2);
409  me_RPC_fail->setBinLabel(12, "RB3+ B", 2);
410  me_RPC_fail->setBinLabel(13, "RB3+ F", 2);
411  me_RPC_fail->setBinLabel(14, "RB4- B", 2);
412  me_RPC_fail->setBinLabel(15, "RB4- F", 2);
413  me_RPC_fail->setBinLabel(16, "RB4+ B", 2);
414  me_RPC_fail->setBinLabel(17, "RB4+ F", 2);
415  me_RPC_fail->setBinLabel(18, "RB4-- B", 2);
416  me_RPC_fail->setBinLabel(19, "RB4-- F", 2);
417  me_RPC_fail->setBinLabel(20, "RB4++ B", 2);
418  me_RPC_fail->setBinLabel(21, "RB4++ F", 2);
419  for (int i = 1; i < 13; ++i) {
420  me_RPC_fail->setBinLabel(i, std::to_string(i), 1);
421  }
422  me_RPC_fail->setAxisTitle("Sector", 1);
423  me_RPC_fail->setAxisTitle("Number of failing probes", 3);
424 
425  me_RPC_pass_1D->setBinLabel(1, "RB1in B", 1);
426  me_RPC_pass_1D->setBinLabel(2, "RB1in F", 1);
427  me_RPC_pass_1D->setBinLabel(3, "RB1out B", 1);
428  me_RPC_pass_1D->setBinLabel(4, "RB1out F", 1);
429  if (std::abs(wheel) < 2) {
430  me_RPC_pass_1D->setBinLabel(5, "RB2in B", 1);
431  me_RPC_pass_1D->setBinLabel(6, "RB2in M", 1);
432  me_RPC_pass_1D->setBinLabel(7, "RB2in F", 1);
433  me_RPC_pass_1D->setBinLabel(8, "RB2out B", 1);
434  me_RPC_pass_1D->setBinLabel(9, "RB2out F", 1);
435  } else {
436  me_RPC_pass_1D->setBinLabel(5, "RB2in B", 1);
437  me_RPC_pass_1D->setBinLabel(6, "RB2in F", 1);
438  me_RPC_pass_1D->setBinLabel(7, "RB2out B", 1);
439  me_RPC_pass_1D->setBinLabel(8, "RB2out M", 1);
440  me_RPC_pass_1D->setBinLabel(9, "RB2out F", 1);
441  }
442  me_RPC_pass_1D->setBinLabel(10, "RB3- B", 1);
443  me_RPC_pass_1D->setBinLabel(11, "RB3- F", 1);
444  me_RPC_pass_1D->setBinLabel(12, "RB3+ B", 1);
445  me_RPC_pass_1D->setBinLabel(13, "RB3+ F", 1);
446  me_RPC_pass_1D->setBinLabel(14, "RB4- B", 1);
447  me_RPC_pass_1D->setBinLabel(15, "RB4- F", 1);
448  me_RPC_pass_1D->setBinLabel(16, "RB4+ B", 1);
449  me_RPC_pass_1D->setBinLabel(17, "RB4+ F", 1);
450  me_RPC_pass_1D->setBinLabel(18, "RB4-- B", 1);
451  me_RPC_pass_1D->setBinLabel(19, "RB4-- F", 1);
452  me_RPC_pass_1D->setBinLabel(20, "RB4++ B", 1);
453  me_RPC_pass_1D->setBinLabel(21, "RB4++ F", 1);
454  me_RPC_pass->setAxisTitle("Number of passing probes", 2);
455 
456  me_RPC_fail_1D->setBinLabel(1, "RB1in B", 1);
457  me_RPC_fail_1D->setBinLabel(2, "RB1in F", 1);
458  me_RPC_fail_1D->setBinLabel(3, "RB1out B", 1);
459  me_RPC_fail_1D->setBinLabel(4, "RB1out F", 1);
460  if (std::abs(wheel) < 2) {
461  me_RPC_fail_1D->setBinLabel(5, "RB2in B", 1);
462  me_RPC_fail_1D->setBinLabel(6, "RB2in M", 1);
463  me_RPC_fail_1D->setBinLabel(7, "RB2in F", 1);
464  me_RPC_fail_1D->setBinLabel(8, "RB2out B", 1);
465  me_RPC_fail_1D->setBinLabel(9, "RB2out F", 1);
466  } else {
467  me_RPC_fail_1D->setBinLabel(5, "RB2in B", 1);
468  me_RPC_fail_1D->setBinLabel(6, "RB2in F", 1);
469  me_RPC_fail_1D->setBinLabel(7, "RB2out B", 1);
470  me_RPC_fail_1D->setBinLabel(8, "RB2out M", 1);
471  me_RPC_fail_1D->setBinLabel(9, "RB2out F", 1);
472  }
473  me_RPC_fail_1D->setBinLabel(10, "RB3- B", 1);
474  me_RPC_fail_1D->setBinLabel(11, "RB3- F", 1);
475  me_RPC_fail_1D->setBinLabel(12, "RB3+ B", 1);
476  me_RPC_fail_1D->setBinLabel(13, "RB3+ F", 1);
477  me_RPC_fail_1D->setBinLabel(14, "RB4- B", 1);
478  me_RPC_fail_1D->setBinLabel(15, "RB4- F", 1);
479  me_RPC_fail_1D->setBinLabel(16, "RB4+ B", 1);
480  me_RPC_fail_1D->setBinLabel(17, "RB4+ F", 1);
481  me_RPC_fail_1D->setBinLabel(18, "RB4-- B", 1);
482  me_RPC_fail_1D->setBinLabel(19, "RB4-- F", 1);
483  me_RPC_fail_1D->setBinLabel(20, "RB4++ B", 1);
484  me_RPC_fail_1D->setBinLabel(21, "RB4++ F", 1);
485  me_RPC_fail_1D->setAxisTitle("Number of failing probes", 2);
486 
487  m_histos[hName_RPC_pass] = me_RPC_pass;
488  m_histos[hName_RPC_fail] = me_RPC_fail;
489 
490  m_histos[hName_RPC_pass_1D] = me_RPC_pass_1D;
491  m_histos[hName_RPC_fail_1D] = me_RPC_fail_1D;
492 }
493 
495  auto baseDir = topFolder() + folder + "/";
496  iBooker.setCurrentFolder(baseDir);
497 
498  LogTrace("DQMOffline|MuonDPG|RPCTnPEfficiencyTask")
499  << "[RPCTnPEfficiencyTask]: booking histos in " << baseDir << std::endl;
500 
501  auto hName_RPC_pass = std::string("RPC_nPassingProbePerRoll_Endcap_Sta") + std::to_string(station);
502  auto hName_RPC_fail = std::string("RPC_nFailingProbePerRoll_Endcap_Sta") + std::to_string(station);
503 
504  auto hName_RPC_pass_1D = std::string("RPC_nPassingProbePerRoll_Endcap_1D_Sta") + std::to_string(station);
505  auto hName_RPC_fail_1D = std::string("RPC_nFailingProbePerRoll_Endcap_1D_Sta") + std::to_string(station);
506 
507  MonitorElement* me_RPC_pass =
508  iBooker.book2D(hName_RPC_pass.c_str(), hName_RPC_pass.c_str(), 36, 0.5, 36.5, 6, 0.5, 6.5);
509  MonitorElement* me_RPC_fail =
510  iBooker.book2D(hName_RPC_fail.c_str(), hName_RPC_fail.c_str(), 36, 0.5, 36.5, 6, 0.5, 6.5);
511 
512  MonitorElement* me_RPC_pass_1D = iBooker.book1D(hName_RPC_pass_1D.c_str(), hName_RPC_pass_1D.c_str(), 6, 0.5, 6.5);
513  MonitorElement* me_RPC_fail_1D = iBooker.book1D(hName_RPC_fail_1D.c_str(), hName_RPC_fail_1D.c_str(), 6, 0.5, 6.5);
514 
515  me_RPC_pass->setBinLabel(1, "R2_A", 2);
516  me_RPC_pass->setBinLabel(2, "R2_B", 2);
517  me_RPC_pass->setBinLabel(3, "R2_C", 2);
518  me_RPC_pass->setBinLabel(4, "R3_A", 2);
519  me_RPC_pass->setBinLabel(5, "R3_B", 2);
520  me_RPC_pass->setBinLabel(6, "R3_C", 2);
521  for (int i = 1; i < 37; ++i) {
522  me_RPC_pass->setBinLabel(i, std::to_string(i), 1);
523  }
524  me_RPC_pass->setAxisTitle("Sector", 1);
525  me_RPC_pass->setAxisTitle("Number of passing probes", 3);
526  me_RPC_pass->setTitle("RE" + std::to_string(station));
527 
528  me_RPC_fail->setBinLabel(1, "R2_A", 2);
529  me_RPC_fail->setBinLabel(2, "R2_B", 2);
530  me_RPC_fail->setBinLabel(3, "R2_C", 2);
531  me_RPC_fail->setBinLabel(4, "R3_A", 2);
532  me_RPC_fail->setBinLabel(5, "R3_B", 2);
533  me_RPC_fail->setBinLabel(6, "R3_C", 2);
534  for (int i = 1; i < 37; ++i) {
535  me_RPC_fail->setBinLabel(i, std::to_string(i), 1);
536  }
537  me_RPC_fail->setAxisTitle("Sector", 1);
538  me_RPC_fail->setAxisTitle("Number of failing probes", 3);
539  me_RPC_fail->setTitle("RE" + std::to_string(station));
540 
541  me_RPC_pass_1D->setBinLabel(1, "R2_A", 1);
542  me_RPC_pass_1D->setBinLabel(2, "R2_B", 1);
543  me_RPC_pass_1D->setBinLabel(3, "R2_C", 1);
544  me_RPC_pass_1D->setBinLabel(4, "R3_A", 1);
545  me_RPC_pass_1D->setBinLabel(5, "R3_B", 1);
546  me_RPC_pass_1D->setBinLabel(6, "R3_C", 1);
547  me_RPC_pass_1D->setAxisTitle("Number of passing probes", 2);
548  me_RPC_pass_1D->setTitle("RE" + std::to_string(station));
549 
550  me_RPC_fail_1D->setBinLabel(1, "R2_A", 1);
551  me_RPC_fail_1D->setBinLabel(2, "R2_B", 1);
552  me_RPC_fail_1D->setBinLabel(3, "R2_C", 1);
553  me_RPC_fail_1D->setBinLabel(4, "R3_A", 1);
554  me_RPC_fail_1D->setBinLabel(5, "R3_B", 1);
555  me_RPC_fail_1D->setBinLabel(6, "R3_C", 1);
556  me_RPC_fail_1D->setAxisTitle("Number of failing probes", 2);
557  me_RPC_fail_1D->setTitle("RE" + std::to_string(station));
558 
559  m_histos[hName_RPC_pass] = me_RPC_pass;
560  m_histos[hName_RPC_fail] = me_RPC_fail;
561 
562  m_histos[hName_RPC_pass_1D] = me_RPC_pass_1D;
563  m_histos[hName_RPC_fail_1D] = me_RPC_fail_1D;
564 }
565 
567  int ring, int station, int sector, int layer, int subsector, int roll) {
568  int ycoord;
569 
570  if (station < 3) {
571  //There are three rolls in RB2in for wheel=-1,0,+1 and in RB2out for wheel=-2,+2
572  bool three_rolls = station == 2 && ((std::abs(ring) > 1 && layer == 2) || (std::abs(ring) < 2 && layer == 1));
573 
574  int layer_roll;
575 
576  if (!three_rolls) {
577  roll = roll > 1 ? 2 : 1;
578  int a = station == 2 && std::abs(ring) < 2 && layer == 2 ? 3 : 2;
579  layer_roll = (a * (layer - 1)) + roll;
580  } else {
581  layer_roll = (2 * (layer - 1)) + roll;
582  }
583 
584  ycoord = (4 * (station - 1)) + layer_roll;
585  } else if (station == 3) {
586  roll = roll > 1 ? 2 : 1;
587  ycoord = 9 + (4 * (station - 3)) + (2 * (subsector - 1)) + roll;
588  } else {
589  int my_subsector = subsector;
590  //The numbering scheme of subsector in sector 4
591  //of station 4 does not match the bins order in the plot:
592  //_____SUBSECTOR_____|_______BIN_ORDERING_____
593  // ++ --> subsector 4| RB4++ --> my_subsector 4
594  // + --> subsector 3| RB4-- --> my_subsector 3
595  // - --> subsector 2| RB4+ --> my_subsector 2
596  // -- --> subsector 1| RB4- --> my_subsector 1
597 
598  if (sector == 4) {
599  switch (subsector) {
600  case 1:
601  my_subsector = 3;
602  break;
603  case 2:
604  my_subsector = 1;
605  break;
606  case 3:
607  my_subsector = 2;
608  break;
609  case 4:
610  my_subsector = 4;
611  break;
612  }
613  }
614  roll = roll > 1 ? 2 : 1;
615  ycoord = 9 + (4 * (station - 3)) + (2 * (my_subsector - 1)) + roll;
616  }
617 
618  return ycoord;
619 }
620 
621 std::string RPCTnPEfficiencyTask::topFolder() const { return "RPC/Segment_TnP/"; };
622 
virtual void setTitle(const std::string &title)
set (ie. change) histogram/profile title
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
RPCTnPEfficiencyTask(const edm::ParameterSet &config)
Constructor.
const edm::EDGetTokenT< reco::MuonCollection > m_muToken
int get_barrel_histo_ycoord(int ring, int station, int sector, int layer, int subsector, int roll)
void analyze(const edm::Event &event, const edm::EventSetup &context) override
Analyze.
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Definition: config.py:1
#define LogTrace(id)
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
void bookEndcapHistos(DQMStore::IBooker &iBooker, int stations, std::string folder="")
Book endcap histograms.
std::vector< std::vector< unsigned > > m_probeIndices
std::string topFolder() const override
Return the top folder.
~RPCTnPEfficiencyTask() override
Destructor.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< std::string, MonitorElement * > m_histos
void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &context) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void analyze(const edm::Event &event, const edm::EventSetup &context) override
Analyze.
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &run, edm::EventSetup const &context) override
void bookWheelHistos(DQMStore::IBooker &iBooker, int wheel, std::string folder="")
Book wheel granularity histograms.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
static constexpr int RPC
Definition: MuonSubdetId.h:13
double a
Definition: hdecay.h:119
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: event.py:1
Definition: Run.h:45
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)