CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 (TPad *&canv, TH2 *h, int lay, int ring, int phase, bool half_shift, bool mark_zero, bool standard_palette)
 

Function Documentation

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

Definition at line 280 of file Phase1PixelROCMaps.cc.

References cmsLHEtoEOSManager::l.

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

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 }
void PixelROCMapHelper::dress_plot ( TPad *&  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.

References draw_line(), SiStripPI::max, min(), mod(), relativeConstraints::ring, pileupReCalc_HLTpaths::scale, jetcorrextractor::sign(), AlCaHLTBitMon_QueryRunRegistry::string, gpuClustering::x, and detailsBasic3DVector::y.

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

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);
435  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1);
436  PixelROCMapHelper::draw_line(x2, x2, y1, y2, 1);
437  } else {
438  PixelROCMapHelper::draw_line(x1, x2, y1, y1, 1);
439  //PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1);
440  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
441  PixelROCMapHelper::draw_line(x2, x2, 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);
492  PixelROCMapHelper::draw_line(x1, x2, y2, y2, 1);
493  //PixelROCMapHelper::draw_line(x1, x1, y1, y2, 1);
494  PixelROCMapHelper::draw_line(x2, x2, 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 }
double sign(double x)
void draw_line(double x1, double x2, double y1, double y2, int width, int style, int color)
if(conf_.getParameter< bool >("UseStripCablingDB"))
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
T min(T a, T b)
Definition: MathUtil.h:58
void draw_line(double x1, double x2, double y1, double y2, int width=2, int style=1, int color=1)
for(Iditer=Id.begin();Iditer!=Id.end();Iditer++)
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