1 #ifndef CONDCORE_SIPIXELPLUGINS_SIPIXELPAYLOADINSPECTORHELPER_H
2 #define CONDCORE_SIPIXELPLUGINS_SIPIXELPAYLOADINSPECTORHELPER_H
16 #include "TPaveStats.h"
17 #include "TPaveText.h"
32 #define COUT std::cout << "MM "
34 #define COUT edm::LogVerbatim("")
65 edm::LogError(
"PhaseInfo") <<
"undefined phase: " << thePhase;
83 return "Geometry/TrackerCommonData/data/trackerParameters.xml";
85 return "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
87 return "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml";
118 return std::make_pair(
run,
lumi);
139 if (
quadrant(detid, &tTopo_, phase_) % 2)
151 if (
quadrant(detid, &tTopo_, phase_) < 3)
169 }
else if (phase_ == 1) {
182 if (
quadrant(detid, &tTopo_, phase_) % 2)
202 if (
quadrant(detid, &tTopo_, phase_) < 3)
210 l->SetBit(kCanDelete);
213 l->SetLineColor(color);
223 bool half_shift =
true,
224 bool mark_zero =
true,
225 bool standard_palette =
true) {
230 s_title =
"Barrel Pixel Layer " + std::to_string(lay);
236 s_title =
"Forward Pixel Ring " + std::to_string(
ring);
239 gStyle->SetPadRightMargin(0.125);
241 if (standard_palette) {
242 gStyle->SetPalette(1);
245 const Int_t NRGBs = 5;
246 const Int_t NCont = 255;
248 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
249 Double_t
red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
250 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
251 Double_t
blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
252 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
253 gStyle->SetNumberContours(NCont);
256 h->SetMarkerSize(0.7);
262 ltx.SetTextSize(0.06);
263 ltx.SetTextAlign(31);
264 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
268 std::vector<std::vector<int>> nladder = {{10, 16, 22}, {6, 14, 22, 32}};
269 int nlad = nladder[
phase][lay - 1];
270 for (
int xsign = -1; xsign <= 1; xsign += 2)
271 for (
int ysign = -1; ysign <= 1; ysign += 2) {
272 float xlow = xsign * (half_shift * 0.5);
273 float xhigh = xsign * (half_shift * 0.5 + 4);
274 float ylow = ysign * (half_shift * 0.5 + (
phase == 0) * 0.5);
275 float yhigh = ysign * (half_shift * 0.5 - (
phase == 0) * 0.5 + nlad);
282 for (
int lad = 1; lad < nlad; ++lad) {
283 float y = ysign * (lad + half_shift * 0.5);
286 for (
int lad = 1; lad <= nlad; ++lad)
287 if (!(
phase == 0 && (lad == 1 || lad == nlad))) {
288 float y = ysign * (lad + half_shift * 0.5 - 0.5);
293 float x = xsign * (
mod + half_shift * 0.5);
301 for (
int lad = 1; lad <= nlad; ++lad) {
302 bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
305 int roc0_orientation = flipped ? -1 : 1;
307 roc0_orientation *= -1;
309 roc0_orientation *= -1;
310 float x1 = xsign * (
mod + half_shift * 0.5);
311 float x2 = xsign * (
mod + half_shift * 0.5 - 1. / 8);
312 float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
313 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
314 if (!(
phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
315 if (lay == 1 && xsign <= -1) {
316 float x1 = xsign * ((
mod - 1) + half_shift * 0.5);
317 float x2 = xsign * ((
mod - 1) + half_shift * 0.5 + 1. / 8);
318 float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
319 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
334 for (
int dsk = 1, ndsk = 2 + (
phase == 1); dsk <= ndsk; ++dsk) {
335 for (
int xsign = -1; xsign <= 1; xsign += 2)
336 for (
int ysign = -1; ysign <= 1; ysign += 2) {
338 int first_roc = 3, nbin = 16;
339 for (
int bld = 1, nbld = 12; bld <= nbld; ++bld) {
341 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
343 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
345 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (
float)nbin);
346 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
347 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
352 for (
int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
353 float x = xsign * (half_shift * 0.5 + dsk - 1 +
354 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (
float)nbin);
355 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
356 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
360 for (
int plq = 2, nplq = 6; plq <= nplq; ++plq)
362 float x = xsign * (half_shift * 0.5 + dsk - 1 +
363 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (
float)nbin);
364 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
365 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
369 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
371 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
373 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (
float)nbin);
374 int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
375 float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (2 + plq / 2) * 0.1);
376 float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (plq / 2) * 0.1);
383 }
else if (
phase == 1) {
386 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
388 Color_t p1_color = 1, p2_color = 1;
391 float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
392 float x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
394 float y1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.5);
396 float y2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld);
397 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
398 float y3 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.5);
405 float x = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
410 x = xsign * (half_shift * 0.5 + dsk);
415 x1 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5 - 1 / 16.);
416 x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
417 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25);
418 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25 + xsign * ysign * 0.25);
423 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
424 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25 - xsign * ysign * 0.25);
431 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
432 Color_t p1_color = 1, p2_color = 1;
435 float x1 = xsign * (half_shift * 0.5 + dsk - 1);
436 float x2 = xsign * (half_shift * 0.5 + dsk);
438 float y1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.5);
440 float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
441 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
442 float y3 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.5);
449 float x = xsign * (half_shift * 0.5 + dsk - 1);
454 x = xsign * (half_shift * 0.5 + dsk);
459 x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
460 x2 = xsign * (half_shift * 0.5 + dsk);
461 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25);
462 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25 + xsign * ysign * 0.25);
467 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
468 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25 - xsign * ysign * 0.25);
484 if (
phase == 0 &&
h->GetNbinsY() == 250 &&
h->GetNbinsX() == 80) {
485 int nentries =
h->GetEntries();
486 for (
int binx = 1; binx <= 80; ++binx) {
488 for (
int biny = 1; biny <= 250; ++biny) {
489 bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
490 if (biny % 2 == odd_nrocy)
491 sum +=
h->GetBinContent(binx, biny);
493 sum +=
h->GetBinContent(binx, biny);
495 h->SetBinContent(binx, biny, sum);
496 h->SetBinContent(binx, biny - 1, sum);
502 h->SetEntries(nentries);
512 pad->SetTopMargin(top);
514 pad->SetBottomMargin(bottom);
516 pad->SetLeftMargin(left);
518 pad->SetRightMargin(right);
535 float theMax(-9999.);
537 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
538 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
540 float add_min = theMin > 0. ? -0.05 : 0.05;
541 float add_max = theMax > 0. ? 0.05 : -0.05;
543 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
551 hist->SetStats(kFALSE);
552 hist->SetLineWidth(2);
553 hist->GetXaxis()->CenterTitle(
true);
554 hist->GetYaxis()->CenterTitle(
true);
555 hist->GetXaxis()->SetTitleFont(42);
556 hist->GetYaxis()->SetTitleFont(42);
557 hist->GetXaxis()->SetTitleSize(0.05);
558 hist->GetYaxis()->SetTitleSize(0.05);
559 hist->GetXaxis()->SetTitleOffset(1.1);
560 hist->GetYaxis()->SetTitleOffset(1.3);
561 hist->GetXaxis()->SetLabelFont(42);
562 hist->GetYaxis()->SetLabelFont(42);
563 hist->GetYaxis()->SetLabelSize(.05);
564 hist->GetXaxis()->SetLabelSize(.05);
567 hist->GetZaxis()->SetLabelFont(42);
568 hist->GetZaxis()->SetLabelFont(42);
569 hist->GetZaxis()->SetLabelSize(.05);
570 hist->GetZaxis()->SetLabelSize(.05);
637 bool isOuter =
false;
642 isOuter = !odd_ladder;
644 isOuter = odd_ladder;
647 isOuter = odd_ladder;
649 isOuter = !odd_ladder;
711 m_Phase = const_cast<SiPixelPI::phase*>(&ph);
712 unsigned int subdetId = static_cast<unsigned int>(detId.
subdetId());
735 throw cms::Exception(
"LogicError") <<
"Cannot call filterThePartition BEFORE filling the geometry info!";
790 t2.SetTextColor(kRed);
791 t2.DrawLatexNDC(0.6, 0.50, Form(
"%s NOT SUPPORTED!",
phase.c_str()));
795 template <
typename T>
799 using pairtype = std::pair<unsigned int, T>;
800 auto max = *std::max_element(
801 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
802 auto min = *std::min_element(
803 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
804 return std::make_pair(
min.second,
max.second);