CMS 3D CMS Logo

Phase1PixelROCMaps.cc
Go to the documentation of this file.
2 
3 using modBins = std::vector<std::pair<int, int>>;
4 using rocBins = std::vector<std::tuple<int, int, int>>;
5 
6 // find detector coordinates for filling
7 /*--------------------------------------------------------------------*/
9 /*--------------------------------------------------------------------*/
10 {
11  DetCoordinates coord;
12 
13  auto myDetId = DetId(t_detid);
14  int subid = DetId(t_detid).subdetId();
15 
16  if (subid == PixelSubdetector::PixelBarrel) {
17  coord.m_layer = m_trackerTopo.pxbLayer(myDetId);
18  coord.m_s_ladder = this->signed_ladder(myDetId, true);
19  coord.m_s_module = this->signed_module(myDetId, true);
20 
21  bool isFlipped = this->isBPixOuterLadder(myDetId, false);
22  if ((coord.m_layer > 1 && coord.m_s_module < 0))
23  isFlipped = !isFlipped;
24 
25  coord.m_isFlipped = isFlipped;
26 
27  } // if it's barrel
28  else if (subid == PixelSubdetector::PixelEndcap) {
29  coord.m_ring = this->ring(myDetId, true);
30  coord.m_s_blade = this->signed_blade(myDetId, true);
31  coord.m_s_disk = this->signed_disk(myDetId, true);
32  coord.m_panel = m_trackerTopo.pxfPanel(t_detid);
33  coord.m_isFlipped = (coord.m_s_disk > 0) ? (coord.m_panel == 1) : (coord.m_panel == 2);
34  } // it it's endcap
35  else {
36  throw cms::Exception("LogicError") << "Unknown Pixel SubDet ID " << std::endl;
37  }
38 
39  if (std::strcmp(m_option, kVerbose) == 0) {
40  coord.printCoordinates();
41  }
42 
43  return coord;
44 }
45 
46 // overloaded method: mask entire module
47 /*--------------------------------------------------------------------*/
49 /*--------------------------------------------------------------------*/
50 {
51  modBins rocsToMask;
52  int nlad = nlad_list[coord.m_layer - 1];
53 
54  int start_x = coord.m_s_module > 0 ? ((coord.m_s_module + 4) * 8) + 1 : ((4 - (std::abs(coord.m_s_module))) * 8) + 1;
55  int start_y =
56  coord.m_s_ladder > 0 ? ((coord.m_s_ladder + nlad) * 2) + 1 : ((nlad - (std::abs(coord.m_s_ladder))) * 2) + 1;
57 
58  int end_x = start_x + 7;
59  int end_y = start_y + 1;
60 
61  for (int bin_x = 1; bin_x <= 72; bin_x++) {
62  for (int bin_y = 1; bin_y <= (nlad * 4 + 2); bin_y++) {
63  if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
64  rocsToMask.push_back(std::make_pair(bin_x, bin_y));
65  }
66  }
67  }
68  return rocsToMask;
69 }
70 
71 // overloaded method: mask single ROCs
72 /*--------------------------------------------------------------------*/
74 /*--------------------------------------------------------------------*/
75 {
76  rocBins rocsToMask;
77  int nlad = nlad_list[coord.m_layer - 1];
78 
79  int start_x = coord.m_s_module > 0 ? ((coord.m_s_module + 4) * 8) + 1 : ((4 - (std::abs(coord.m_s_module))) * 8) + 1;
80  int start_y =
81  coord.m_s_ladder > 0 ? ((coord.m_s_ladder + nlad) * 2) + 1 : ((nlad - (std::abs(coord.m_s_ladder))) * 2) + 1;
82 
83  int roc0_x = ((coord.m_layer == 1) || (coord.m_layer > 1 && coord.m_s_module > 0)) ? start_x + 7 : start_x;
84  int roc0_y = start_y - 1;
85 
86  size_t idx = 0;
87  while (idx < myRocs.size()) {
88  if (myRocs.test(idx)) {
90  // | //
91  // In BPix Layer1 & module > 0 in L2,3,4 | In BPix Layer 2,3,4 module < 0 //
92  // | //
93  // ROCs are ordered in the following | ROCs are ordered in the following //
94  // fashion for unflipped modules | fashion for unflipped modules //
95  // | //
96  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
97  // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
98  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
99  // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
100  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
101  // | //
102  // if the module is flipped the ordering | if the module is flipped the ordering //
103  // is reveresed | is reversed //
104  // | //
105  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
106  // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
107  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
108  // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
109  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
111 
112  int roc_x(0), roc_y(0);
113 
114  if ((coord.m_layer == 1) || (coord.m_layer > 1 && coord.m_s_module > 0)) {
115  if (!coord.m_isFlipped) {
116  roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
117  roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
118  } else {
119  roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
120  roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
121  }
122  } else {
123  if (!coord.m_isFlipped) {
124  roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
125  roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
126  } else {
127  roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
128  roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
129  }
130  }
131  rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
132  }
133  ++idx;
134  }
135  return rocsToMask;
136 }
137 
138 // overloaded method: mask entire module
139 /*--------------------------------------------------------------------*/
141 /*--------------------------------------------------------------------*/
142 {
143  modBins rocsToMask;
144  int nybins = nybins_list[coord.m_ring - 1];
145 
146  int start_x = coord.m_s_disk > 0 ? ((coord.m_s_disk + 3) * 8) + 1 : ((3 - (std::abs(coord.m_s_disk))) * 8) + 1;
147  int start_y = coord.m_s_blade > 0 ? (nybins / 2) + (coord.m_s_blade * 4) - (coord.m_panel * 2) + 3
148  : ((nybins / 2) - (std::abs(coord.m_s_blade) * 4) - coord.m_panel * 2) + 3;
149 
150  int end_x = start_x + 7;
151  int end_y = start_y + 1;
152 
153  for (int bin_x = 1; bin_x <= 56; bin_x++) {
154  for (int bin_y = 1; bin_y <= nybins; bin_y++) {
155  if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
156  rocsToMask.push_back(std::make_pair(bin_x, bin_y));
157  }
158  }
159  }
160  return rocsToMask;
161 }
162 
163 // overloaded method: mask single ROCs
164 /*--------------------------------------------------------------------*/
166 /*--------------------------------------------------------------------*/
167 {
168  rocBins rocsToMask;
169  int nybins = nybins_list[coord.m_ring - 1];
170 
171  int start_x = coord.m_s_disk > 0 ? ((coord.m_s_disk + 3) * 8) + 1 : ((3 - (std::abs(coord.m_s_disk))) * 8) + 1;
172  int start_y = coord.m_s_blade > 0 ? (nybins / 2) + (coord.m_s_blade * 4) - (coord.m_panel * 2) + 3
173  : ((nybins / 2) - (std::abs(coord.m_s_blade) * 4) - coord.m_panel * 2) + 3;
174 
175  int roc0_x = coord.m_s_disk > 0 ? start_x + 7 : start_x;
176  int roc0_y = start_y - 1;
177 
178  size_t idx = 0;
179  while (idx < myRocs.size()) {
180  if (myRocs.test(idx)) {
181  int roc_x(0), roc_y(0);
182 
184  // | //
185  // In FPix + (Disk 1,2,3) | In FPix - (Disk -1,-2,-3) //
186  // | //
187  // ROCs are ordered in the following | ROCs are ordered in the following //
188  // fashion for unflipped modules | fashion for unflipped modules //
189  // | //
190  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
191  // | 8 |9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
192  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
193  // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
194  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
195  // | //
196  // if the module is flipped the ordering | if the module is flipped the ordering //
197  // is reveresed | is reversed //
198  // | //
199  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
200  // | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | //
201  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
202  // | 8 | 9 |10 |11 |12 |13 |14 |15 | | |15 |14 |13 |12 |11 |10 | 9 | 8 | //
203  // +---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ //
205 
206  if (coord.m_s_disk > 0) {
207  if (!coord.m_isFlipped) {
208  roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
209  roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
210  } else {
211  roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
212  roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
213  }
214  } else {
215  if (!coord.m_isFlipped) {
216  roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
217  roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
218  } else {
219  roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
220  roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
221  }
222  }
223 
224  rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
225  }
226  ++idx;
227  }
228  return rocsToMask;
229 }
230 
231 /*--------------------------------------------------------------------*/
232 void Phase1PixelROCMaps::fillWholeModule(const uint32_t& detid, double value)
233 /*--------------------------------------------------------------------*/
234 {
235  auto coord = findDetCoordinates(detid);
236  auto rocsToMark = coord.isBarrel() ? this->maskedBarrelRocsToBins(coord) : this->maskedForwardRocsToBins(coord);
237 
238  if (coord.isBarrel()) {
239  for (const auto& bin : rocsToMark) {
240  double x = h_bpix_maps[coord.m_layer - 1]->GetXaxis()->GetBinCenter(bin.first);
241  double y = h_bpix_maps[coord.m_layer - 1]->GetYaxis()->GetBinCenter(bin.second);
242  h_bpix_maps[coord.m_layer - 1]->Fill(x, y, value);
243  }
244  } else {
245  for (const auto& bin : rocsToMark) {
246  double x = h_fpix_maps[coord.m_ring - 1]->GetXaxis()->GetBinCenter(bin.first);
247  double y = h_fpix_maps[coord.m_ring - 1]->GetYaxis()->GetBinCenter(bin.second);
248  h_fpix_maps[coord.m_ring - 1]->Fill(x, y, value);
249  }
250  }
251  return;
252 }
253 
254 /*--------------------------------------------------------------------*/
255 void Phase1PixelROCMaps::fillSelectedRocs(const uint32_t& detid, const std::bitset<16>& theROCs, double value)
256 /*--------------------------------------------------------------------*/
257 {
258  auto coord = findDetCoordinates(detid);
259  auto rocsToMark =
260  coord.isBarrel() ? this->maskedBarrelRocsToBins(coord, theROCs) : this->maskedForwardRocsToBins(coord, theROCs);
261 
262  if (coord.isBarrel()) {
263  for (const auto& bin : rocsToMark) {
264  double x = h_bpix_maps[coord.m_layer - 1]->GetXaxis()->GetBinCenter(std::get<0>(bin));
265  double y = h_bpix_maps[coord.m_layer - 1]->GetYaxis()->GetBinCenter(std::get<1>(bin));
266  h_bpix_maps[coord.m_layer - 1]->Fill(x, y, value);
267  }
268  } else {
269  for (const auto& bin : rocsToMark) {
270  double x = h_fpix_maps[coord.m_ring - 1]->GetXaxis()->GetBinCenter(std::get<0>(bin));
271  double y = h_fpix_maps[coord.m_ring - 1]->GetYaxis()->GetBinCenter(std::get<1>(bin));
272  h_fpix_maps[coord.m_ring - 1]->Fill(x, y, value);
273  }
274  }
275 
276  return;
277 }
278 
279 /*--------------------------------------------------------------------*/
281  double x1, double x2, double y1, double y2, int width = 2, int style = 1, int color = 1)
282 /*--------------------------------------------------------------------*/
283 {
284  TLine* l = new TLine(x1, y1, x2, y2);
285  l->SetBit(kCanDelete);
286  l->SetLineWidth(width);
287  l->SetLineStyle(style);
288  l->SetLineColor(color);
289  l->Draw();
290 }
291 
292 /*--------------------------------------------------------------------*/
294  TH2* h,
295  int lay,
296  int ring = 0,
297  int phase = 0,
298  bool standard_palette = true,
299  bool half_shift = true,
300  bool mark_zero = true)
301 /*--------------------------------------------------------------------*/
302 {
303  std::string s_title;
304  const auto zAxisTitle = fmt::sprintf("%s", h->GetZaxis()->GetTitle());
305 
306  if (lay > 0) {
307  canv->cd(lay);
308  canv->cd(lay)->SetTopMargin(0.05);
309  canv->cd(lay)->SetBottomMargin(0.07);
310  canv->cd(lay)->SetLeftMargin(0.1);
311  if (!zAxisTitle.empty()) {
312  h->GetZaxis()->SetTitleOffset(1.3);
313  h->GetZaxis()->CenterTitle(true);
314  canv->cd(lay)->SetRightMargin(0.14);
315  } else {
316  canv->cd(lay)->SetRightMargin(0.11);
317  }
318  s_title = "Barrel Pixel Layer " + std::to_string(lay);
319  } else {
320  canv->cd(ring);
321  canv->cd(ring)->SetTopMargin(0.05);
322  canv->cd(ring)->SetBottomMargin(0.07);
323  canv->cd(ring)->SetLeftMargin(0.1);
324  if (!zAxisTitle.empty()) {
325  h->GetZaxis()->SetTitleOffset(1.3);
326  h->GetZaxis()->CenterTitle(true);
327  canv->cd(ring)->SetRightMargin(0.14);
328  } else {
329  canv->cd(ring)->SetRightMargin(0.11);
330  }
331  if (ring > 4) {
332  ring = ring - 4;
333  }
334  s_title = "Forward Pixel Ring " + std::to_string(ring);
335  }
336 
337  if (standard_palette) {
338  gStyle->SetPalette(1);
339  } else {
340  /*
341  const Int_t NRGBs = 5;
342  const Int_t NCont = 255;
343 
344  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
345  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
346  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
347  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
348  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
349  gStyle->SetNumberContours(NCont);
350  */
351 
352  // this is the fine gradient palette (blue to red)
353  double max = h->GetMaximum();
354  double min = h->GetMinimum();
355  double val_white = 0.;
356  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
357 
358  const int Number = 3;
359  double Red[Number] = {0., 1., 1.};
360  double Green[Number] = {0., 1., 0.};
361  double Blue[Number] = {1., 1., 0.};
362  double Stops[Number] = {0., per_white, 1.};
363  int nb = 256;
364  h->SetContour(nb);
365  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, nb);
366  // if max == min impose the range to be the same as it was a real diff
367  if (max == min)
368  h->GetZaxis()->SetRangeUser(-1., 1.);
369  }
370 
371  h->SetMarkerSize(0.7);
372  h->Draw("colz1");
373 
374  auto ltx = TLatex();
375  ltx.SetTextFont(62);
376  ltx.SetTextColor(1);
377  ltx.SetTextSize(0.06);
378  ltx.SetTextAlign(31);
379  ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
380 
381  // Draw Lines around modules
382  if (lay > 0) {
383  std::vector<std::vector<int>> nladder = {{10, 16, 22}, {6, 14, 22, 32}};
384  int nlad = nladder[phase][lay - 1];
385  for (int xsign = -1; xsign <= 1; xsign += 2)
386  for (int ysign = -1; ysign <= 1; ysign += 2) {
387  float xlow = xsign * (half_shift * 0.5);
388  float xhigh = xsign * (half_shift * 0.5 + 4);
389  float ylow = ysign * (half_shift * 0.5 + (phase == 0) * 0.5);
390  float yhigh = ysign * (half_shift * 0.5 - (phase == 0) * 0.5 + nlad);
391  // Outside box
392  PixelROCMapHelper::draw_line(xlow, xhigh, ylow, ylow, 1); // bottom
393  PixelROCMapHelper::draw_line(xlow, xhigh, yhigh, yhigh, 1); // top
394  PixelROCMapHelper::draw_line(xlow, xlow, ylow, yhigh, 1); // left
395  PixelROCMapHelper::draw_line(xhigh, xhigh, ylow, yhigh, 1); // right
396  // Inner Horizontal lines
397  for (int lad = 1; lad < nlad; ++lad) {
398  float y = ysign * (lad + half_shift * 0.5);
399  PixelROCMapHelper::draw_line(xlow, xhigh, y, y, 1);
400  }
401  for (int lad = 1; lad <= nlad; ++lad)
402  if (!(phase == 0 && (lad == 1 || lad == nlad))) {
403  float y = ysign * (lad + half_shift * 0.5 - 0.5);
404  PixelROCMapHelper::draw_line(xlow, xhigh, y, y, 1, 3);
405  }
406  // Inner Vertical lines
407  for (int mod = 1; mod < 4; ++mod) {
408  float x = xsign * (mod + half_shift * 0.5);
409  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1);
410  }
411  // Make a BOX around ROC 0
412  // Phase 0 - ladder +1 is always non-flipped
413  // Phase 1 - ladder +1 is always flipped
414  if (mark_zero) {
415  for (int mod = 1; mod <= 4; ++mod)
416  for (int lad = 1; lad <= nlad; ++lad) {
417  bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
418  if (phase == 1)
419  flipped = !flipped;
420  int roc0_orientation = flipped ? -1 : 1;
421  if (xsign == -1)
422  roc0_orientation *= -1;
423  if (ysign == -1)
424  roc0_orientation *= -1;
425  float x1 = xsign * (mod + half_shift * 0.5);
426  float x2 = xsign * (mod + half_shift * 0.5 - 1. / 8);
427  float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
428  float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
429  if (!(phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
430  if (lay == 1 && xsign <= -1) {
431  float x1 = xsign * ((mod - 1) + half_shift * 0.5);
432  float x2 = xsign * ((mod - 1) + half_shift * 0.5 + 1. / 8);
433  float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
434  float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
437  } else {
439  //PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1);
440  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
442  }
443  }
444  }
445  }
446  }
447  } else {
448  // FPIX
449  for (int dsk = 1, ndsk = 2 + (phase == 1); dsk <= ndsk; ++dsk) {
450  for (int xsign = -1; xsign <= 1; xsign += 2)
451  for (int ysign = -1; ysign <= 1; ysign += 2) {
452  if (phase == 0) {
453  int first_roc = 3, nbin = 16;
454  for (int bld = 1, nbld = 12; bld <= nbld; ++bld) {
455  // Horizontal lines
456  for (int plq = 1, nplq = 7; plq <= nplq; ++plq) {
457  float xlow =
458  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (float)nbin);
459  float xhigh =
460  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (float)nbin);
461  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
462  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
463  PixelROCMapHelper::draw_line(xlow, xhigh, ylow, ylow, 1); // bottom
464  PixelROCMapHelper::draw_line(xlow, xhigh, yhigh, yhigh, 1); // top
465  }
466  // Vertical lines
467  for (int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
468  float x = xsign * (half_shift * 0.5 + dsk - 1 +
469  (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (float)nbin);
470  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
471  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
472  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1);
473  }
474  // Panel 2 has dashed mid-plane
475  for (int plq = 2, nplq = 6; plq <= nplq; ++plq)
476  if (plq % 2 == 0) {
477  float x = xsign * (half_shift * 0.5 + dsk - 1 +
478  (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (float)nbin);
479  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
480  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
481  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1, 2);
482  }
483  // Make a BOX around ROC 0
484  for (int plq = 1, nplq = 7; plq <= nplq; ++plq) {
485  float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (float)nbin);
486  float x2 =
487  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (float)nbin);
488  int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
489  float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (2 + plq / 2) * 0.1);
490  float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (plq / 2) * 0.1);
491  //PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1);
493  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
495  }
496  }
497  } else if (phase == 1) {
498  if (ring == 0) { // both
499  for (int ring = 1; ring <= 2; ++ring)
500  for (int bld = 1, nbld = 5 + ring * 6; bld <= nbld; ++bld) {
501  float scale = (ring == 1) ? 1.5 : 1;
502  Color_t p1_color = 1, p2_color = 1;
503  // Horizontal lines
504  // Panel 2 has dashed mid-plane
505  float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (ring - 1) * 0.5);
506  float x2 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5);
507  int sign = ysign;
508  float y1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.5);
509  //float yp1_mid = ysign * (half_shift*0.5 - 0.5 + scale*bld + sign*0.25);
510  float y2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld);
511  float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
512  float y3 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.5);
513  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1, 1, p1_color);
514  //PixelROCMapHelper::draw_line(x1, x2, yp1_mid, yp1_mid, 1, 3);
515  PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1, 1, p1_color);
516  PixelROCMapHelper::draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
517  PixelROCMapHelper::draw_line(x1, x2, y3, y3, 1, 1, p2_color);
518  // Vertical lines
519  float x = xsign * (half_shift * 0.5 + dsk - 1 + (ring - 1) * 0.5);
520  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
521  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
522  if (ring == 2) {
523  //PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p1_color);
524  x = xsign * (half_shift * 0.5 + dsk);
525  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
526  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
527  }
528  // Make a BOX around ROC 0
529  x1 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5 - 1 / 16.);
530  x2 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5);
531  float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25);
532  float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25 + xsign * ysign * 0.25);
533  PixelROCMapHelper::draw_line(x1, x2, y1_p1, y1_p1, 1);
534  //PixelROCMapHelper::draw_line(x1, x2, y2_p1, y2_p1, 1);
535  PixelROCMapHelper::draw_line(x1, x1, y1_p1, y2_p1, 1);
536  //PixelROCMapHelper::draw_line(x2, x2, y1_p1, y2_p1, 1);
537  float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
538  float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25 - xsign * ysign * 0.25);
539  PixelROCMapHelper::draw_line(x1, x2, y1_p2, y1_p2, 1);
540  //PixelROCMapHelper::draw_line(x1, x2, y2_p2, y2_p2, 1);
541  PixelROCMapHelper::draw_line(x1, x1, y1_p2, y2_p2, 1);
542  //PixelROCMapHelper::draw_line(x2, x2, y1_p2, y2_p2, 1);
543  }
544  } else { // only one ring, 1 or 2
545  for (int bld = 1, nbld = 5 + ring * 6; bld <= nbld; ++bld) {
546  Color_t p1_color = 1, p2_color = 1;
547  // Horizontal lines
548  // Panel 2 has dashed mid-plane
549  float x1 = xsign * (half_shift * 0.5 + dsk - 1);
550  float x2 = xsign * (half_shift * 0.5 + dsk);
551  int sign = ysign;
552  float y1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.5);
553  //float yp1_mid = ysign * (half_shift*0.5 - 0.5 + bld + sign*0.25);
554  float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
555  float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
556  float y3 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.5);
557  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1, 1, p1_color);
558  //PixelROCMapHelper::draw_line(x1, x2, yp1_mid, yp1_mid, 1, 3);
559  PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1, 1, p1_color);
560  PixelROCMapHelper::draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
561  PixelROCMapHelper::draw_line(x1, x2, y3, y3, 1, 1, p2_color);
562  // Vertical lines
563  float x = xsign * (half_shift * 0.5 + dsk - 1);
564  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
565  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
566  if (ring == 2) {
567  //PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p1_color);
568  x = xsign * (half_shift * 0.5 + dsk);
569  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
570  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
571  }
572  // Make a BOX around ROC 0
573  x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
574  x2 = xsign * (half_shift * 0.5 + dsk);
575  float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25);
576  float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25 + xsign * ysign * 0.25);
577  PixelROCMapHelper::draw_line(x1, x2, y1_p1, y1_p1, 1);
578  //PixelROCMapHelper::draw_line(x1, x2, y2_p1, y2_p1, 1);
579  PixelROCMapHelper::draw_line(x1, x1, y1_p1, y2_p1, 1);
580  //PixelROCMapHelper::draw_line(x2, x2, y1_p1, y2_p1, 1);
581  float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
582  float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25 - xsign * ysign * 0.25);
583  PixelROCMapHelper::draw_line(x1, x2, y1_p2, y1_p2, 1);
584  //PixelROCMapHelper::draw_line(x1, x2, y2_p2, y2_p2, 1);
585  PixelROCMapHelper::draw_line(x1, x1, y1_p2, y2_p2, 1);
586  //PixelROCMapHelper::draw_line(x2, x2, y1_p2, y2_p2, 1);
587  }
588  }
589  }
590  }
591  }
592  // Special shifted "rebin" for Phase 0
593  // Y axis should always have at least half-roc granularity because
594  // there are half-ROC size shifts implemented in the coordinates
595  // To remove this and show full ROC granularity
596  // We merge bin contents in each pair of bins corresponding to one ROC
597  // TODO: make sure this works for Profiles
598  if (phase == 0 && h->GetNbinsY() == 250 && h->GetNbinsX() == 80) {
599  int nentries = h->GetEntries();
600  for (int binx = 1; binx <= 80; ++binx) {
601  double sum = 0;
602  for (int biny = 1; biny <= 250; ++biny) {
603  bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
604  if (biny % 2 == odd_nrocy)
605  sum += h->GetBinContent(binx, biny);
606  else {
607  sum += h->GetBinContent(binx, biny);
608  if (sum) {
609  h->SetBinContent(binx, biny, sum);
610  h->SetBinContent(binx, biny - 1, sum);
611  }
612  sum = 0;
613  }
614  }
615  }
616  h->SetEntries(nentries);
617  }
618  }
619 }
620 
621 /*--------------------------------------------------------------------*/
623 /*--------------------------------------------------------------------*/
624 {
625  canvas.cd();
626  canvas.Modified();
627 
628  auto topPad = new TPad("pad1", "upper pad", 0.005, 0.96, 0.995, 0.995);
629  topPad->Draw();
630  topPad->cd();
631  auto ltx = TLatex();
632  ltx.SetTextFont(62);
633 
634  std::size_t found = text.find("Delta");
635  if (found != std::string::npos) {
636  ltx.SetTextSize(0.7);
637  } else {
638  ltx.SetTextSize(1.);
639  }
640  ltx.DrawLatexNDC(0.02, 0.3, text.c_str());
641 
642  canvas.cd();
643  auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.955);
644  bottomPad->Draw();
645  bottomPad->cd();
646  bottomPad->Divide(2, 2);
647  for (unsigned int lay = 1; lay <= n_layers; lay++) {
648  h_bpix_maps[lay - 1]->SetStats(false);
649  PixelROCMapHelper::dress_plot(bottomPad, h_bpix_maps[lay - 1].get(), lay, 0, 1, found == std::string::npos);
650  }
651 }
652 
653 /*--------------------------------------------------------------------*/
655 /*--------------------------------------------------------------------*/
656 {
657  canvas.cd();
658  canvas.Modified();
659 
660  auto topPad = new TPad("pad1", "upper pad", 0.005, 0.94, 0.995, 0.995);
661  topPad->Draw();
662  topPad->cd();
663  auto ltx = TLatex();
664  ltx.SetTextFont(62);
665 
666  std::size_t found = text.find("Delta");
667  if (found != std::string::npos) {
668  ltx.SetTextSize(0.7);
669  } else {
670  ltx.SetTextSize(1.);
671  }
672  ltx.DrawLatexNDC(0.02, 0.3, text.c_str());
673 
674  canvas.cd();
675  auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.935);
676  bottomPad->Draw();
677  bottomPad->cd();
678  bottomPad->Divide(2, 1);
679  for (unsigned int ring = 1; ring <= n_rings; ring++) {
680  h_fpix_maps[ring - 1]->SetStats(false);
681  PixelROCMapHelper::dress_plot(bottomPad, h_fpix_maps[ring - 1].get(), 0, ring, 1, found == std::string::npos);
682  }
683 }
684 
685 /*--------------------------------------------------------------------*/
687 /*--------------------------------------------------------------------*/
688 {
689  canvas.cd();
690  canvas.Modified();
691 
692  auto topPad = new TPad("pad1", "upper pad", 0.005, 0.97, 0.995, 0.995);
693  topPad->Draw();
694  topPad->cd();
695  auto ltx = TLatex();
696  ltx.SetTextFont(62);
697 
698  std::size_t found = text.find("Delta");
699  if (found != std::string::npos) {
700  ltx.SetTextSize(0.7);
701  } else {
702  ltx.SetTextSize(1.);
703  }
704  ltx.DrawLatexNDC(0.02, 0.2, text.c_str());
705 
706  canvas.cd();
707  auto bottomPad = new TPad("pad2", "lower pad", 0.005, 0.005, 0.995, 0.97);
708  bottomPad->Draw();
709  bottomPad->cd();
710  bottomPad->Divide(2, 3);
711 
712  // dress the plots
713  for (unsigned int lay = 1; lay <= n_layers; lay++) {
714  h_bpix_maps[lay - 1]->SetStats(false);
715  PixelROCMapHelper::dress_plot(bottomPad, h_bpix_maps[lay - 1].get(), lay, 0, 1, found == std::string::npos);
716  }
717 
718  bottomPad->Update();
719  bottomPad->Modified();
720  bottomPad->cd();
721 
722  for (unsigned int ring = 1; ring <= n_rings; ring++) {
723  h_fpix_maps[ring - 1]->SetStats(false);
725  bottomPad, h_fpix_maps[ring - 1].get(), 0, n_layers + ring, 1, found == std::string::npos);
726  }
727 }
static constexpr const char * kVerbose
void drawMaps(TCanvas &canvas, const std::string &text="")
int signed_blade(const DetId &detid, bool phase_)
unsigned int pxbLayer(const DetId &id) const
std::vector< std::pair< int, int > > modBins
std::vector< std::tuple< int, int, int > > rocBins
DetCoordinates findDetCoordinates(const uint32_t &t_detid)
int signed_module(const DetId &detid, bool phase_)
std::vector< std::pair< int, int > > maskedForwardRocsToBins(DetCoordinates coord)
static constexpr int n_layers
std::array< std::shared_ptr< TH2D >, n_layers > h_bpix_maps
void drawBarrelMaps(TCanvas &canvas, const std::string &text="")
static std::string to_string(const XMLCh *ch)
void fillWholeModule(const uint32_t &detid, double value)
void draw_line(double x1, double x2, double y1, double y2, int width, int style, int color)
const int nlad_list[n_layers]
void drawForwardMaps(TCanvas &canvas, const std::string &text="")
bool isBPixOuterLadder(const DetId &detid, bool isPhase0)
static constexpr int n_rings
std::vector< std::pair< int, int > > maskedBarrelRocsToBins(DetCoordinates coord)
Definition: style.py:1
const int nybins_list[n_rings]
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int signed_disk(const DetId &detid, bool phase_)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: value.py:1
int ring(const DetId &detid, bool phase_)
unsigned int pxfPanel(const DetId &id) const
Definition: DetId.h:17
void fillSelectedRocs(const uint32_t &detid, const std::bitset< 16 > &theROCs, double value)
TrackerTopology m_trackerTopo
std::array< std::shared_ptr< TH2D >, n_rings > h_fpix_maps
def canvas(sub, attr)
Definition: svgfig.py:482
float x
int signed_ladder(const DetId &detid, bool phase_)
void dress_plot(TPad *&canv, TH2 *h, int lay, int ring, int phase, bool half_shift, bool mark_zero, bool standard_palette)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4