3 using modBins = std::vector<std::pair<int, int>>;
4 using rocBins = std::vector<std::tuple<int, int, int>>;
13 auto myDetId =
DetId(t_detid);
23 isFlipped = !isFlipped;
36 throw cms::Exception(
"LogicError") <<
"Unknown Pixel SubDet ID " << std::endl;
58 int end_x = start_x + 7;
59 int end_y = start_y + 1;
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));
84 int roc0_y = start_y - 1;
87 while (
idx < myRocs.size()) {
88 if (myRocs.test(
idx)) {
112 int roc_x(0), roc_y(0);
116 roc_x =
idx < 8 ? roc0_x -
idx : (start_x - 8) +
idx;
117 roc_y =
idx < 8 ? roc0_y + 1 : roc0_y + 2;
119 roc_x =
idx < 8 ? roc0_x -
idx : (start_x - 8) +
idx;
120 roc_y =
idx < 8 ? roc0_y + 2 : roc0_y + 1;
124 roc_x =
idx < 8 ? roc0_x +
idx : (roc0_x + 7) - (
idx - 8);
125 roc_y =
idx < 8 ? roc0_y + 1 : roc0_y + 2;
127 roc_x =
idx < 8 ? roc0_x +
idx : (roc0_x + 7) - (
idx - 8);
128 roc_y =
idx < 8 ? roc0_y + 2 : roc0_y + 1;
131 rocsToMask.push_back(std::make_tuple(roc_x, roc_y,
idx));
150 int end_x = start_x + 7;
151 int end_y = start_y + 1;
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));
175 int roc0_x = coord.
m_s_disk > 0 ? start_x + 7 : start_x;
176 int roc0_y = start_y - 1;
179 while (
idx < myRocs.size()) {
180 if (myRocs.test(
idx)) {
181 int roc_x(0), roc_y(0);
208 roc_x =
idx < 8 ? roc0_x -
idx : (start_x - 8) +
idx;
209 roc_y =
idx < 8 ? roc0_y + 1 : roc0_y + 2;
211 roc_x =
idx < 8 ? roc0_x -
idx : (start_x - 8) +
idx;
212 roc_y =
idx < 8 ? roc0_y + 2 : roc0_y + 1;
216 roc_x =
idx < 8 ? roc0_x +
idx : (roc0_x + 7) - (
idx - 8);
217 roc_y =
idx < 8 ? roc0_y + 1 : roc0_y + 2;
219 roc_x =
idx < 8 ? roc0_x +
idx : (roc0_x + 7) - (
idx - 8);
220 roc_y =
idx < 8 ? roc0_y + 2 : roc0_y + 1;
224 rocsToMask.push_back(std::make_tuple(roc_x, roc_y,
idx));
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);
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);
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));
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));
281 double x1,
double x2,
double y1,
double y2,
int width = 2,
int style = 1,
int color = 1)
285 l->SetBit(kCanDelete);
288 l->SetLineColor(color);
298 bool standard_palette =
true,
299 bool half_shift =
true,
300 bool mark_zero =
true)
304 const auto zAxisTitle = fmt::sprintf(
"%s",
h->GetZaxis()->GetTitle());
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);
316 canv->cd(lay)->SetRightMargin(0.11);
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);
329 canv->cd(
ring)->SetRightMargin(0.11);
337 if (standard_palette) {
338 gStyle->SetPalette(1);
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;
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.};
365 TColor::CreateGradientColorTable(
Number, Stops, Red, Green, Blue, nb);
368 h->GetZaxis()->SetRangeUser(-1., 1.);
371 h->SetMarkerSize(0.7);
377 ltx.SetTextSize(0.06);
378 ltx.SetTextAlign(31);
379 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
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);
397 for (
int lad = 1; lad < nlad; ++lad) {
398 float y = ysign * (lad + half_shift * 0.5);
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);
408 float x = xsign * (
mod + half_shift * 0.5);
416 for (
int lad = 1; lad <= nlad; ++lad) {
417 bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
420 int roc0_orientation = flipped ? -1 : 1;
422 roc0_orientation *= -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);
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) {
453 int first_roc = 3, nbin = 16;
454 for (
int bld = 1, nbld = 12; bld <= nbld; ++bld) {
456 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
458 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
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);
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);
475 for (
int plq = 2, nplq = 6; plq <= nplq; ++plq)
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);
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);
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);
497 }
else if (
phase == 1) {
500 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
502 Color_t p1_color = 1, p2_color = 1;
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);
508 float y1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.5);
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);
519 float x = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
524 x = xsign * (half_shift * 0.5 + dsk);
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);
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);
545 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
546 Color_t p1_color = 1, p2_color = 1;
549 float x1 = xsign * (half_shift * 0.5 + dsk - 1);
550 float x2 = xsign * (half_shift * 0.5 + dsk);
552 float y1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.5);
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);
563 float x = xsign * (half_shift * 0.5 + dsk - 1);
568 x = xsign * (half_shift * 0.5 + dsk);
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);
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);
598 if (
phase == 0 &&
h->GetNbinsY() == 250 &&
h->GetNbinsX() == 80) {
599 int nentries =
h->GetEntries();
600 for (
int binx = 1; binx <= 80; ++binx) {
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);
607 sum +=
h->GetBinContent(binx, biny);
609 h->SetBinContent(binx, biny, sum);
610 h->SetBinContent(binx, biny - 1, sum);
616 h->SetEntries(nentries);
628 auto topPad =
new TPad(
"pad1",
"upper pad", 0.005, 0.96, 0.995, 0.995);
635 if (
found != std::string::npos) {
636 ltx.SetTextSize(0.7);
640 ltx.DrawLatexNDC(0.02, 0.3,
text.c_str());
643 auto bottomPad =
new TPad(
"pad2",
"lower pad", 0.005, 0.005, 0.995, 0.955);
646 bottomPad->Divide(2, 2);
647 for (
unsigned int lay = 1; lay <=
n_layers; lay++) {
660 auto topPad =
new TPad(
"pad1",
"upper pad", 0.005, 0.94, 0.995, 0.995);
667 if (
found != std::string::npos) {
668 ltx.SetTextSize(0.7);
672 ltx.DrawLatexNDC(0.02, 0.3,
text.c_str());
675 auto bottomPad =
new TPad(
"pad2",
"lower pad", 0.005, 0.005, 0.995, 0.935);
678 bottomPad->Divide(2, 1);
692 auto topPad =
new TPad(
"pad1",
"upper pad", 0.005, 0.97, 0.995, 0.995);
699 if (
found != std::string::npos) {
700 ltx.SetTextSize(0.7);
704 ltx.DrawLatexNDC(0.02, 0.2,
text.c_str());
707 auto bottomPad =
new TPad(
"pad2",
"lower pad", 0.005, 0.005, 0.995, 0.97);
710 bottomPad->Divide(2, 3);
713 for (
unsigned int lay = 1; lay <=
n_layers; lay++) {
719 bottomPad->Modified();
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)
std::string to_string(const V &value)
static constexpr int n_layers
std::array< std::shared_ptr< TH2D >, n_layers > h_bpix_maps
void drawBarrelMaps(TCanvas &canvas, const std::string &text="")
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)
const int nybins_list[n_rings]
Abs< T >::type abs(const T &t)
int signed_disk(const DetId &detid, bool phase_)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int ring(const DetId &detid, bool phase_)
unsigned int pxfPanel(const DetId &id) const
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
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.
T mod(const T &a, const T &b)