1 #ifndef CONDCORE_SIPIXELPLUGINS_SIPIXELPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_SIPIXELPLUGINS_SIPIXELPAYLOADINSPECTORHELPER_H 13 #include "TPaveStats.h" 14 #include "TPaveText.h" 27 #define COUT std::cout << "MM " 29 #define COUT edm::LogVerbatim("") 39 auto run = (since >> 32);
41 return std::make_pair(
run,
lumi);
62 if (
quadrant(detid, &tTopo_, phase_) % 2)
74 if (
quadrant(detid, &tTopo_, phase_) < 3)
92 }
else if (phase_ == 1) {
105 if (
quadrant(detid, &tTopo_, phase_) % 2)
125 if (
quadrant(detid, &tTopo_, phase_) < 3)
132 TLine*
l =
new TLine(x1, y1, x2, y2);
133 l->SetBit(kCanDelete);
134 l->SetLineWidth(
width);
135 l->SetLineStyle(
style);
136 l->SetLineColor(color);
146 bool half_shift =
true,
147 bool mark_zero =
true,
148 bool standard_palette =
true) {
153 s_title =
"Barrel Pixel Layer" + std::to_string(lay);
156 s_title =
"Forward Pixel Ring" + std::to_string(
ring);
159 gStyle->SetPadRightMargin(0.125);
161 if (standard_palette) {
162 gStyle->SetPalette(1);
165 const Int_t NRGBs = 5;
166 const Int_t NCont = 255;
168 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
169 Double_t
red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
170 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
171 Double_t
blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
172 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
173 gStyle->SetNumberContours(NCont);
176 h->SetMarkerSize(0.7);
182 ltx.SetTextSize(0.06);
183 ltx.SetTextAlign(31);
184 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
188 std::vector<std::vector<int> > nladder = {{10, 16, 22}, {6, 14, 22, 32}};
189 int nlad = nladder[
phase][lay - 1];
190 for (
int xsign = -1; xsign <= 1; xsign += 2)
191 for (
int ysign = -1; ysign <= 1; ysign += 2) {
192 float xlow = xsign * (half_shift * 0.5);
193 float xhigh = xsign * (half_shift * 0.5 + 4);
194 float ylow = ysign * (half_shift * 0.5 + (
phase == 0) * 0.5);
195 float yhigh = ysign * (half_shift * 0.5 - (
phase == 0) * 0.5 + nlad);
202 for (
int lad = 1; lad < nlad; ++lad) {
203 float y = ysign * (lad + half_shift * 0.5);
206 for (
int lad = 1; lad <= nlad; ++lad)
207 if (!(
phase == 0 && (lad == 1 || lad == nlad))) {
208 float y = ysign * (lad + half_shift * 0.5 - 0.5);
213 float x = xsign * (
mod + half_shift * 0.5);
221 for (
int lad = 1; lad <= nlad; ++lad) {
222 bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
225 int roc0_orientation = flipped ? -1 : 1;
227 roc0_orientation *= -1;
229 roc0_orientation *= -1;
230 float x1 = xsign * (
mod + half_shift * 0.5);
231 float x2 = xsign * (
mod + half_shift * 0.5 - 1. / 8);
232 float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
233 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
234 if (!(
phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
235 if (lay == 1 && xsign <= -1) {
236 float x1 = xsign * ((
mod - 1) + half_shift * 0.5);
237 float x2 = xsign * ((
mod - 1) + half_shift * 0.5 + 1. / 8);
238 float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
239 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
254 for (
int dsk = 1, ndsk = 2 + (
phase == 1); dsk <= ndsk; ++dsk) {
255 for (
int xsign = -1; xsign <= 1; xsign += 2)
256 for (
int ysign = -1; ysign <= 1; ysign += 2) {
258 int first_roc = 3,
nbin = 16;
259 for (
int bld = 1, nbld = 12; bld <= nbld; ++bld) {
261 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
263 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)
nbin);
265 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (
float)
nbin);
266 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
267 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
272 for (
int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
273 float x = xsign * (half_shift * 0.5 + dsk - 1 +
274 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (
float)
nbin);
275 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
276 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
280 for (
int plq = 2, nplq = 6; plq <= nplq; ++plq)
282 float x = xsign * (half_shift * 0.5 + dsk - 1 +
283 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (
float)
nbin);
284 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
285 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
289 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
291 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)
nbin);
293 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (
float)
nbin);
294 int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
295 float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (2 + plq / 2) * 0.1);
296 float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) + sign * (plq / 2) * 0.1);
303 }
else if (
phase == 1) {
306 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
308 Color_t p1_color = 1, p2_color = 1;
311 float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
312 float x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
314 float y1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.5);
316 float y2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld);
317 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
318 float y3 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.5);
319 draw_line(x1, x2, y1, y1, 1, 1, p1_color);
321 draw_line(x1, x2, y2, y2, 1, 1, p1_color);
322 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
323 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
325 float x = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
330 x = xsign * (half_shift * 0.5 + dsk);
335 x1 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5 - 1 / 16.);
336 x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
337 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25);
338 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + scale * bld + sign * 0.25 + xsign * ysign * 0.25);
343 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25);
344 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + scale * bld - sign * 0.25 - xsign * ysign * 0.25);
351 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
352 Color_t p1_color = 1, p2_color = 1;
355 float x1 = xsign * (half_shift * 0.5 + dsk - 1);
356 float x2 = xsign * (half_shift * 0.5 + dsk);
358 float y1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.5);
360 float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
361 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
362 float y3 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.5);
363 draw_line(x1, x2, y1, y1, 1, 1, p1_color);
365 draw_line(x1, x2, y2, y2, 1, 1, p1_color);
366 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
367 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
369 float x = xsign * (half_shift * 0.5 + dsk - 1);
374 x = xsign * (half_shift * 0.5 + dsk);
379 x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
380 x2 = xsign * (half_shift * 0.5 + dsk);
381 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25);
382 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld + sign * 0.25 + xsign * ysign * 0.25);
387 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25);
388 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld - sign * 0.25 - xsign * ysign * 0.25);
404 if (
phase == 0 && h->GetNbinsY() == 250 && h->GetNbinsX() == 80) {
405 int nentries = h->GetEntries();
406 for (
int binx = 1; binx <= 80; ++binx) {
408 for (
int biny = 1; biny <= 250; ++biny) {
409 bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
410 if (biny % 2 == odd_nrocy)
411 sum += h->GetBinContent(binx, biny);
413 sum += h->GetBinContent(binx, biny);
415 h->SetBinContent(binx, biny, sum);
416 h->SetBinContent(binx, biny - 1, sum);
422 h->SetEntries(nentries);
431 float theMax(-9999.);
433 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
434 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
436 float add_min = theMin > 0. ? -0.05 : 0.05;
437 float add_max = theMax > 0. ? 0.05 : -0.05;
439 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
447 hist->SetStats(kFALSE);
448 hist->SetLineWidth(2);
449 hist->GetXaxis()->CenterTitle(
true);
450 hist->GetYaxis()->CenterTitle(
true);
451 hist->GetXaxis()->SetTitleFont(42);
452 hist->GetYaxis()->SetTitleFont(42);
453 hist->GetXaxis()->SetTitleSize(0.05);
454 hist->GetYaxis()->SetTitleSize(0.05);
455 hist->GetXaxis()->SetTitleOffset(1.1);
456 hist->GetYaxis()->SetTitleOffset(1.3);
457 hist->GetXaxis()->SetLabelFont(42);
458 hist->GetYaxis()->SetLabelFont(42);
459 hist->GetYaxis()->SetLabelSize(.05);
460 hist->GetXaxis()->SetLabelSize(.05);
524 bool isOuter =
false;
529 isOuter = !odd_ladder;
531 isOuter = odd_ladder;
534 isOuter = odd_ladder;
536 isOuter = !odd_ladder;
596 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
662 std::vector<std::pair<int, int> > rocsToMask;
664 int nlad_list[4] = {6, 14, 22, 32};
665 int nlad = nlad_list[layer - 1];
667 int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (
std::abs(module))) * 8) + 1;
668 int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (
std::abs(ladder))) * 2) + 1;
670 int end_x = start_x + 7;
671 int end_y = start_y + 1;
673 COUT <<
"module: " << module <<
" start_x:" << start_x <<
" end_x:" << end_x << std::endl;
674 COUT <<
"ladder: " << ladder <<
" start_y:" << start_y <<
" end_y:" << end_y << std::endl;
675 COUT <<
"==================================================================" << std::endl;
677 for (
int bin_x = 1; bin_x <= 72; bin_x++) {
678 for (
int bin_y = 1; bin_y <= (nlad * 4 + 2); bin_y++) {
679 if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
680 rocsToMask.push_back(std::make_pair(bin_x, bin_y));
690 int layer,
int ladder,
int module, std::bitset<16> bad_rocs,
bool isFlipped)
693 std::vector<std::tuple<int, int, int> > rocsToMask;
695 int nlad_list[4] = {6, 14, 22, 32};
696 int nlad = nlad_list[layer - 1];
698 int start_x = module > 0 ? ((module + 4) * 8) + 1 : ((4 - (
std::abs(module))) * 8) + 1;
699 int start_y = ladder > 0 ? ((ladder + nlad) * 2) + 1 : ((nlad - (
std::abs(ladder))) * 2) + 1;
701 int roc0_x = ((layer == 1) || (layer > 1 && module > 0)) ? start_x + 7 : start_x;
702 int roc0_y = start_y - 1;
705 while (idx < bad_rocs.size()) {
706 if (bad_rocs.test(idx)) {
730 int roc_x(0), roc_y(0);
732 if ((layer == 1) || (layer > 1 && module > 0)) {
734 roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
735 roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
737 roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
738 roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
742 roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
743 roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
745 roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
746 roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
750 COUT << bad_rocs <<
" : (idx)= " << idx << std::endl;
751 COUT <<
" layer: " << layer << std::endl;
752 COUT <<
"module: " << module <<
" roc_x:" << roc_x << std::endl;
753 COUT <<
"ladder: " << ladder <<
" roc_y:" << roc_y << std::endl;
754 COUT <<
"==================================================================" << std::endl;
756 rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
768 std::vector<std::pair<int, int> > rocsToMask;
771 int nybins_list[2] = {92, 140};
773 int nybins = nybins_list[ring - 1];
775 int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (
std::abs(disk))) * 8) + 1;
777 int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
778 : ((nybins / 2) - (
std::abs(blade) * 4) - panel * 2) + 3;
780 int end_x = start_x + 7;
781 int end_y = start_y + 1;
783 COUT <<
"==================================================================" << std::endl;
784 COUT <<
"disk: " << disk <<
" start_x:" << start_x <<
" end_x:" << end_x << std::endl;
785 COUT <<
"blade: " << blade <<
" start_y:" << start_y <<
" end_y:" << end_y << std::endl;
787 for (
int bin_x = 1; bin_x <= 56; bin_x++) {
788 for (
int bin_y = 1; bin_y <= nybins; bin_y++) {
789 if (bin_x >= start_x && bin_x <= end_x && bin_y >= start_y && bin_y <= end_y) {
790 rocsToMask.push_back(std::make_pair(bin_x, bin_y));
800 int ring,
int blade,
int panel,
int disk, std::bitset<16> bad_rocs,
bool isFlipped)
803 std::vector<std::tuple<int, int, int> > rocsToMask;
806 int nybins_list[2] = {92, 140};
808 int nybins = nybins_list[ring - 1];
810 int start_x = disk > 0 ? ((disk + 3) * 8) + 1 : ((3 - (
std::abs(disk))) * 8) + 1;
812 int start_y = blade > 0 ? (nybins / 2) + (blade * 4) - (panel * 2) + 3
813 : ((nybins / 2) - (
std::abs(blade) * 4) - panel * 2) + 3;
815 int roc0_x = disk > 0 ? start_x + 7 : start_x;
816 int roc0_y = start_y - 1;
819 while (idx < bad_rocs.size()) {
820 if (bad_rocs.test(idx)) {
821 int roc_x(0), roc_y(0);
848 roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
849 roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
851 roc_x = idx < 8 ? roc0_x - idx : (start_x - 8) + idx;
852 roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
856 roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
857 roc_y = idx < 8 ? roc0_y + 1 : roc0_y + 2;
859 roc_x = idx < 8 ? roc0_x + idx : (roc0_x + 7) - (idx - 8);
860 roc_y = idx < 8 ? roc0_y + 2 : roc0_y + 1;
864 COUT << bad_rocs <<
" : (idx)= " << idx << std::endl;
865 COUT <<
" panel: " << panel <<
" isFlipped: " << isFlipped << std::endl;
866 COUT <<
" disk: " << disk <<
" roc_x:" << roc_x << std::endl;
867 COUT <<
" blade: " << blade <<
" roc_y:" << roc_y << std::endl;
868 COUT <<
"===============================" << std::endl;
870 rocsToMask.push_back(std::make_tuple(roc_x, roc_y, idx));
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int signed_blade_panel(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
int moduleName() const
module id (index in z)
ret
prodAgent to be discontinued
static const unsigned int phase0size
unsigned int pxfDisk(const DetId &id) const
int quadrant(const DetId &detid, const TrackerTopology *tTopo_, bool phase_)
unsigned int pxbLadder(const DetId &id) const
constexpr uint32_t rawId() const
get the raw id
const Time_t kLowMask(0xFFFFFFFF)
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
int bladeName() const
blade id
std::vector< std::pair< int, int > > maskedForwardRocsToBins(int ring, int blade, int panel, int disk)
int signed_ladder(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
unsigned long long Time_t
int signed_disk(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
int signed_blade(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
SiPixelPI::regions filterThePartition()
void draw_line(double x1, double x2, double y1, double y2, int width=2, int style=1, int color=1)
unsigned int pxfModule(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
std::vector< std::pair< int, int > > maskedBarrelRocsToBins(int layer, int ladder, int module)
int ring(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
void makeNicePlotStyle(TH1 *hist)
int ladderName() const
ladder id (index in phi)
int signed_module(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
bool isBPixOuterLadder(const DetId &detid, const TrackerTopology &tTopo, bool isPhase0)
unsigned int pxfSide(const DetId &id) const
std::string getStringFromRegionEnum(SiPixelPI::regions e)
void dress_occup_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)
int ringName() const
ring Id
HalfCylinder halfCylinder() const
T mod(const T &a, const T &b)
unsigned int pxfPanel(const DetId &id) const
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, bool isPhase0)