CMS 3D CMS Logo

Functions
PixelROCMapHelper Namespace Reference

Functions

void draw_line (double x1, double x2, double y1, double y2, int width, int style, int color)
 
void dress_plot (TCanvas &canv, TH2 *h, int lay, int ring, int phase, bool half_shift, bool mark_zero, bool standard_palette)
 

Function Documentation

◆ draw_line()

void PixelROCMapHelper::draw_line ( double  x1,
double  x2,
double  y1,
double  y2,
int  width = 2,
int  style = 1,
int  color = 1 
)

Definition at line 280 of file Phase1PixelROCMaps.cc.

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 }

References cmsLHEtoEOSManager::l, ApeEstimator_cff::width, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

Referenced by SiPixelPI::dress_occup_plot(), and dress_plot().

◆ dress_plot()

void PixelROCMapHelper::dress_plot ( TCanvas &  canv,
TH2 *  h,
int  lay,
int  ring = 0,
int  phase = 0,
bool  half_shift = true,
bool  mark_zero = true,
bool  standard_palette = true 
)

Definition at line 293 of file Phase1PixelROCMaps.cc.

302 {
303  std::string s_title;
304 
305  if (lay > 0) {
306  canv.cd(lay);
307  s_title = "Barrel Pixel Layer " + std::to_string(lay);
308  } else {
309  canv.cd(ring);
310  if (ring > 4) {
311  ring = ring - 4;
312  }
313  s_title = "Forward Pixel Ring " + std::to_string(ring);
314  }
315 
316  gStyle->SetPadRightMargin(0.125);
317 
318  if (standard_palette) {
319  gStyle->SetPalette(1);
320  } else {
321  // this is the fine gradient palette
322  const Int_t NRGBs = 5;
323  const Int_t NCont = 255;
324 
325  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
326  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
327  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
328  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
329  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
330  gStyle->SetNumberContours(NCont);
331  }
332 
333  h->SetMarkerSize(0.7);
334  h->Draw("colz1");
335 
336  auto ltx = TLatex();
337  ltx.SetTextFont(62);
338  ltx.SetTextColor(1);
339  ltx.SetTextSize(0.06);
340  ltx.SetTextAlign(31);
341  ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
342 
343  // Draw Lines around modules
344  if (lay > 0) {
345  std::vector<std::vector<int>> nladder = {{10, 16, 22}, {6, 14, 22, 32}};
346  int nlad = nladder[phase][lay - 1];
347  for (int xsign = -1; xsign <= 1; xsign += 2)
348  for (int ysign = -1; ysign <= 1; ysign += 2) {
349  float xlow = xsign * (half_shift * 0.5);
350  float xhigh = xsign * (half_shift * 0.5 + 4);
351  float ylow = ysign * (half_shift * 0.5 + (phase == 0) * 0.5);
352  float yhigh = ysign * (half_shift * 0.5 - (phase == 0) * 0.5 + nlad);
353  // Outside box
354  PixelROCMapHelper::draw_line(xlow, xhigh, ylow, ylow, 1); // bottom
355  PixelROCMapHelper::draw_line(xlow, xhigh, yhigh, yhigh, 1); // top
356  PixelROCMapHelper::draw_line(xlow, xlow, ylow, yhigh, 1); // left
357  PixelROCMapHelper::draw_line(xhigh, xhigh, ylow, yhigh, 1); // right
358  // Inner Horizontal lines
359  for (int lad = 1; lad < nlad; ++lad) {
360  float y = ysign * (lad + half_shift * 0.5);
361  PixelROCMapHelper::draw_line(xlow, xhigh, y, y, 1);
362  }
363  for (int lad = 1; lad <= nlad; ++lad)
364  if (!(phase == 0 && (lad == 1 || lad == nlad))) {
365  float y = ysign * (lad + half_shift * 0.5 - 0.5);
366  PixelROCMapHelper::draw_line(xlow, xhigh, y, y, 1, 3);
367  }
368  // Inner Vertical lines
369  for (int mod = 1; mod < 4; ++mod) {
370  float x = xsign * (mod + half_shift * 0.5);
371  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1);
372  }
373  // Make a BOX around ROC 0
374  // Phase 0 - ladder +1 is always non-flipped
375  // Phase 1 - ladder +1 is always flipped
376  if (mark_zero) {
377  for (int mod = 1; mod <= 4; ++mod)
378  for (int lad = 1; lad <= nlad; ++lad) {
379  bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
380  if (phase == 1)
381  flipped = !flipped;
382  int roc0_orientation = flipped ? -1 : 1;
383  if (xsign == -1)
384  roc0_orientation *= -1;
385  if (ysign == -1)
386  roc0_orientation *= -1;
387  float x1 = xsign * (mod + half_shift * 0.5);
388  float x2 = xsign * (mod + half_shift * 0.5 - 1. / 8);
389  float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
390  float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
391  if (!(phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
392  if (lay == 1 && xsign <= -1) {
393  float x1 = xsign * ((mod - 1) + half_shift * 0.5);
394  float x2 = xsign * ((mod - 1) + half_shift * 0.5 + 1. / 8);
395  float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
396  float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
399  } else {
401  //PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1);
402  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
404  }
405  }
406  }
407  }
408  }
409  } else {
410  // FPIX
411  for (int dsk = 1, ndsk = 2 + (phase == 1); dsk <= ndsk; ++dsk) {
412  for (int xsign = -1; xsign <= 1; xsign += 2)
413  for (int ysign = -1; ysign <= 1; ysign += 2) {
414  if (phase == 0) {
415  int first_roc = 3, nbin = 16;
416  for (int bld = 1, nbld = 12; bld <= nbld; ++bld) {
417  // Horizontal lines
418  for (int plq = 1, nplq = 7; plq <= nplq; ++plq) {
419  float xlow =
420  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (float)nbin);
421  float xhigh =
422  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (float)nbin);
423  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
424  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
425  PixelROCMapHelper::draw_line(xlow, xhigh, ylow, ylow, 1); // bottom
426  PixelROCMapHelper::draw_line(xlow, xhigh, yhigh, yhigh, 1); // top
427  }
428  // Vertical lines
429  for (int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
430  float x = xsign * (half_shift * 0.5 + dsk - 1 +
431  (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (float)nbin);
432  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
433  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
434  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1);
435  }
436  // Panel 2 has dashed mid-plane
437  for (int plq = 2, nplq = 6; plq <= nplq; ++plq)
438  if (plq % 2 == 0) {
439  float x = xsign * (half_shift * 0.5 + dsk - 1 +
440  (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (float)nbin);
441  float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
442  float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
443  PixelROCMapHelper::draw_line(x, x, ylow, yhigh, 1, 2);
444  }
445  // Make a BOX around ROC 0
446  for (int plq = 1, nplq = 7; plq <= nplq; ++plq) {
447  float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (float)nbin);
448  float x2 =
449  xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (float)nbin);
450  int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
451  float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (2 + plq / 2) * 0.1);
452  float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (plq / 2) * 0.1);
453  //PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1);
455  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
457  }
458  }
459  } else if (phase == 1) {
460  if (ring == 0) { // both
461  for (int ring = 1; ring <= 2; ++ring)
462  for (int bld = 1, nbld = 5 + ring * 6; bld <= nbld; ++bld) {
463  float scale = (ring == 1) ? 1.5 : 1;
464  Color_t p1_color = 1, p2_color = 1;
465  // Horizontal lines
466  // Panel 2 has dashed mid-plane
467  float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (ring - 1) * 0.5);
468  float x2 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5);
469  int sign = ysign;
470  float y1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.5);
471  //float yp1_mid = ysign * (half_shift*0.5 - 0.5 + scale*bld + sign*0.25);
472  float y2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld);
473  float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
474  float y3 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.5);
475  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1, 1, p1_color);
476  //PixelROCMapHelper::draw_line(x1, x2, yp1_mid, yp1_mid, 1, 3);
477  PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1, 1, p1_color);
478  PixelROCMapHelper::draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
479  PixelROCMapHelper::draw_line(x1, x2, y3, y3, 1, 1, p2_color);
480  // Vertical lines
481  float x = xsign * (half_shift * 0.5 + dsk - 1 + (ring - 1) * 0.5);
482  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
483  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
484  if (ring == 2) {
485  //PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p1_color);
486  x = xsign * (half_shift * 0.5 + dsk);
487  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
488  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
489  }
490  // Make a BOX around ROC 0
491  x1 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5 - 1 / 16.);
492  x2 = xsign * (half_shift * 0.5 + dsk - 1 + ring * 0.5);
493  float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25);
494  float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25 + xsign * ysign * 0.25);
495  PixelROCMapHelper::draw_line(x1, x2, y1_p1, y1_p1, 1);
496  //PixelROCMapHelper::draw_line(x1, x2, y2_p1, y2_p1, 1);
497  PixelROCMapHelper::draw_line(x1, x1, y1_p1, y2_p1, 1);
498  //PixelROCMapHelper::draw_line(x2, x2, y1_p1, y2_p1, 1);
499  float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
500  float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25 - xsign * ysign * 0.25);
501  PixelROCMapHelper::draw_line(x1, x2, y1_p2, y1_p2, 1);
502  //PixelROCMapHelper::draw_line(x1, x2, y2_p2, y2_p2, 1);
503  PixelROCMapHelper::draw_line(x1, x1, y1_p2, y2_p2, 1);
504  //PixelROCMapHelper::draw_line(x2, x2, y1_p2, y2_p2, 1);
505  }
506  } else { // only one ring, 1 or 2
507  for (int bld = 1, nbld = 5 + ring * 6; bld <= nbld; ++bld) {
508  Color_t p1_color = 1, p2_color = 1;
509  // Horizontal lines
510  // Panel 2 has dashed mid-plane
511  float x1 = xsign * (half_shift * 0.5 + dsk - 1);
512  float x2 = xsign * (half_shift * 0.5 + dsk);
513  int sign = ysign;
514  float y1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.5);
515  //float yp1_mid = ysign * (half_shift*0.5 - 0.5 + bld + sign*0.25);
516  float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
517  float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
518  float y3 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.5);
519  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1, 1, p1_color);
520  //PixelROCMapHelper::draw_line(x1, x2, yp1_mid, yp1_mid, 1, 3);
521  PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1, 1, p1_color);
522  PixelROCMapHelper::draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
523  PixelROCMapHelper::draw_line(x1, x2, y3, y3, 1, 1, p2_color);
524  // Vertical lines
525  float x = xsign * (half_shift * 0.5 + dsk - 1);
526  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
527  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
528  if (ring == 2) {
529  //PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p1_color);
530  x = xsign * (half_shift * 0.5 + dsk);
531  PixelROCMapHelper::draw_line(x, x, y1, y2, 1, 1, p1_color);
532  PixelROCMapHelper::draw_line(x, x, y2, y3, 1, 1, p2_color);
533  }
534  // Make a BOX around ROC 0
535  x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
536  x2 = xsign * (half_shift * 0.5 + dsk);
537  float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25);
538  float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25 + xsign * ysign * 0.25);
539  PixelROCMapHelper::draw_line(x1, x2, y1_p1, y1_p1, 1);
540  //PixelROCMapHelper::draw_line(x1, x2, y2_p1, y2_p1, 1);
541  PixelROCMapHelper::draw_line(x1, x1, y1_p1, y2_p1, 1);
542  //PixelROCMapHelper::draw_line(x2, x2, y1_p1, y2_p1, 1);
543  float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
544  float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25 - xsign * ysign * 0.25);
545  PixelROCMapHelper::draw_line(x1, x2, y1_p2, y1_p2, 1);
546  //PixelROCMapHelper::draw_line(x1, x2, y2_p2, y2_p2, 1);
547  PixelROCMapHelper::draw_line(x1, x1, y1_p2, y2_p2, 1);
548  //PixelROCMapHelper::draw_line(x2, x2, y1_p2, y2_p2, 1);
549  }
550  }
551  }
552  }
553  }
554  // Special shifted "rebin" for Phase 0
555  // Y axis should always have at least half-roc granularity because
556  // there are half-ROC size shifts implemented in the coordinates
557  // To remove this and show full ROC granularity
558  // We merge bin contents in each pair of bins corresponding to one ROC
559  // TODO: make sure this works for Profiles
560  if (phase == 0 && h->GetNbinsY() == 250 && h->GetNbinsX() == 80) {
561  int nentries = h->GetEntries();
562  for (int binx = 1; binx <= 80; ++binx) {
563  double sum = 0;
564  for (int biny = 1; biny <= 250; ++biny) {
565  bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
566  if (biny % 2 == odd_nrocy)
567  sum += h->GetBinContent(binx, biny);
568  else {
569  sum += h->GetBinContent(binx, biny);
570  if (sum) {
571  h->SetBinContent(binx, biny, sum);
572  h->SetBinContent(binx, biny - 1, sum);
573  }
574  sum = 0;
575  }
576  }
577  }
578  h->SetEntries(nentries);
579  }
580  }
581 }

References DivergingColor::blue, draw_line(), dqmMemoryStats::float, mod(), DivergingColor::red, relativeConstraints::ring, L1EGammaCrystalsEmulatorProducer_cfi::scale, Validation_hcalonly_cfi::sign, AlCaHLTBitMon_QueryRunRegistry::string, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, detailsBasic3DVector::y, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

Referenced by Phase1PixelROCMaps::drawBarrelMaps(), Phase1PixelROCMaps::drawForwardMaps(), and Phase1PixelROCMaps::drawMaps().

ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
PixelROCMapHelper::draw_line
void draw_line(double x1, double x2, double y1, double y2, int width, int style, int color)
Definition: Phase1PixelROCMaps.cc:280
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
DivergingColor.red
list red
Definition: DivergingColor.py:172
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
h
style
Definition: style.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiPixelPI::phase
phase
Definition: SiPixelPayloadInspectorHelper.h:39
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
DivergingColor.blue
list blue
Definition: DivergingColor.py:173
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
genVertex_cff.x
x
Definition: genVertex_cff.py:12
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14