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("") 66 edm::LogError(
"PhaseInfo") <<
"undefined phase: " << thePhase;
84 return "Geometry/TrackerCommonData/data/trackerParameters.xml";
86 return "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
88 return "Geometry/TrackerCommonData/data/PhaseII/trackerParameters.xml";
95 ss <<
"---------------------------------------------------------------\n" 96 <<
" PhaseInfo Data \n\n" 97 <<
" Phase : " <<
phase() <<
"\n" 100 <<
"-------------------------------------------------------------\n\n";
126 std::stringstream
ss;
137 return std::make_pair(
run,
lumi);
158 if (
quadrant(detid, &tTopo_, phase_) % 2)
170 if (
quadrant(detid, &tTopo_, phase_) < 3)
188 }
else if (phase_ == 1) {
201 if (
quadrant(detid, &tTopo_, phase_) % 2)
221 if (
quadrant(detid, &tTopo_, phase_) < 3)
228 TLine*
l =
new TLine(x1,
y1, x2,
y2);
229 l->SetBit(kCanDelete);
232 l->SetLineColor(color);
242 bool half_shift =
true,
243 bool mark_zero =
true,
244 bool standard_palette =
true) {
258 gStyle->SetPadRightMargin(0.125);
260 if (standard_palette) {
261 gStyle->SetPalette(1);
264 const Int_t NRGBs = 5;
265 const Int_t NCont = 255;
267 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
268 Double_t
red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
269 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
270 Double_t
blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
271 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
272 gStyle->SetNumberContours(NCont);
275 h->SetMarkerSize(0.7);
281 ltx.SetTextSize(0.06);
282 ltx.SetTextAlign(31);
283 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
287 std::vector<std::vector<int>> nladder = {{10, 16, 22}, {6, 14, 22, 32}};
288 int nlad = nladder[
phase][lay - 1];
289 for (
int xsign = -1; xsign <= 1; xsign += 2)
290 for (
int ysign = -1; ysign <= 1; ysign += 2) {
291 float xlow = xsign * (half_shift * 0.5);
292 float xhigh = xsign * (half_shift * 0.5 + 4);
293 float ylow = ysign * (half_shift * 0.5 + (
phase == 0) * 0.5);
294 float yhigh = ysign * (half_shift * 0.5 - (
phase == 0) * 0.5 + nlad);
301 for (
int lad = 1; lad < nlad; ++lad) {
302 float y = ysign * (lad + half_shift * 0.5);
305 for (
int lad = 1; lad <= nlad; ++lad)
306 if (!(
phase == 0 && (lad == 1 || lad == nlad))) {
307 float y = ysign * (lad + half_shift * 0.5 - 0.5);
312 float x = xsign * (
mod + half_shift * 0.5);
320 for (
int lad = 1; lad <= nlad; ++lad) {
321 bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
324 int roc0_orientation = flipped ? -1 : 1;
326 roc0_orientation *= -1;
328 roc0_orientation *= -1;
329 float x1 = xsign * (
mod + half_shift * 0.5);
330 float x2 = xsign * (
mod + half_shift * 0.5 - 1. / 8);
331 float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
332 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
333 if (!(
phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
334 if (lay == 1 && xsign <= -1) {
335 float x1 = xsign * ((
mod - 1) + half_shift * 0.5);
336 float x2 = xsign * ((
mod - 1) + half_shift * 0.5 + 1. / 8);
337 float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
338 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
353 for (
int dsk = 1, ndsk = 2 + (
phase == 1); dsk <= ndsk; ++dsk) {
354 for (
int xsign = -1; xsign <= 1; xsign += 2)
355 for (
int ysign = -1; ysign <= 1; ysign += 2) {
357 int first_roc = 3, nbin = 16;
358 for (
int bld = 1, nbld = 12; bld <= nbld; ++bld) {
360 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
362 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
364 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (
float)nbin);
365 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
366 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
371 for (
int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
372 float x = xsign * (half_shift * 0.5 + dsk - 1 +
373 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (
float)nbin);
374 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
375 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
379 for (
int plq = 2, nplq = 6; plq <= nplq; ++plq)
381 float x = xsign * (half_shift * 0.5 + dsk - 1 +
382 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (
float)nbin);
383 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
384 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
388 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
390 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
392 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (
float)nbin);
393 int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
394 float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (2 + plq / 2) * 0.1);
395 float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (plq / 2) * 0.1);
402 }
else if (
phase == 1) {
405 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
407 Color_t p1_color = 1, p2_color = 1;
410 float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
411 float x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
413 float y1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.5);
415 float y2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld);
416 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
417 float y3 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.5);
421 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
422 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
424 float x = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
429 x = xsign * (half_shift * 0.5 + dsk);
434 x1 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5 - 1 / 16.);
435 x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
436 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25);
437 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25 + xsign * ysign * 0.25);
442 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
443 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25 - xsign * ysign * 0.25);
450 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
451 Color_t p1_color = 1, p2_color = 1;
454 float x1 = xsign * (half_shift * 0.5 + dsk - 1);
455 float x2 = xsign * (half_shift * 0.5 + dsk);
457 float y1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.5);
459 float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
460 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
461 float y3 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.5);
465 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
466 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
468 float x = xsign * (half_shift * 0.5 + dsk - 1);
473 x = xsign * (half_shift * 0.5 + dsk);
478 x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
479 x2 = xsign * (half_shift * 0.5 + dsk);
480 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25);
481 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25 + xsign * ysign * 0.25);
486 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
487 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25 - xsign * ysign * 0.25);
503 if (
phase == 0 &&
h->GetNbinsY() == 250 &&
h->GetNbinsX() == 80) {
504 int nentries =
h->GetEntries();
505 for (
int binx = 1; binx <= 80; ++binx) {
507 for (
int biny = 1; biny <= 250; ++biny) {
508 bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
509 if (biny % 2 == odd_nrocy)
510 sum +=
h->GetBinContent(binx, biny);
512 sum +=
h->GetBinContent(binx, biny);
514 h->SetBinContent(binx, biny, sum);
515 h->SetBinContent(binx, biny - 1, sum);
521 h->SetEntries(nentries);
531 pad->SetTopMargin(top);
533 pad->SetBottomMargin(bottom);
535 pad->SetLeftMargin(left);
537 pad->SetRightMargin(right);
554 float theMax(-9999.);
556 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
557 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
559 float add_min = theMin > 0. ? -0.05 : 0.05;
560 float add_max = theMax > 0. ? 0.05 : -0.05;
562 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
570 hist->SetStats(kFALSE);
571 hist->SetLineWidth(2);
572 hist->GetXaxis()->CenterTitle(
true);
573 hist->GetYaxis()->CenterTitle(
true);
574 hist->GetXaxis()->SetTitleFont(42);
575 hist->GetYaxis()->SetTitleFont(42);
576 hist->GetXaxis()->SetTitleSize(0.05);
577 hist->GetYaxis()->SetTitleSize(0.05);
578 hist->GetXaxis()->SetTitleOffset(1.1);
579 hist->GetYaxis()->SetTitleOffset(1.3);
580 hist->GetXaxis()->SetLabelFont(42);
581 hist->GetYaxis()->SetLabelFont(42);
582 hist->GetYaxis()->SetLabelSize(.05);
583 hist->GetXaxis()->SetLabelSize(.05);
586 hist->GetZaxis()->SetLabelFont(42);
587 hist->GetZaxis()->SetLabelFont(42);
588 hist->GetZaxis()->SetLabelSize(.05);
589 hist->GetZaxis()->SetLabelSize(.05);
594 const std::array<std::string, 3>
DetNames = {{
"Barrel",
"End Caps",
"Whole"}};
662 bool isOuter =
false;
667 isOuter = !odd_ladder;
669 isOuter = odd_ladder;
672 isOuter = !odd_ladder;
674 isOuter = odd_ladder;
711 ss <<
" detId: " << m_rawid <<
" subdetid: " << m_subdetid <<
" layer: " << m_layer <<
" side: " << m_side
712 <<
" ring: " << m_ring <<
" isInternal: " << m_isInternal;
744 unsigned int subdetId =
static_cast<unsigned int>(
detId.subdetId());
767 throw cms::Exception(
"LogicError") <<
"Cannot call filterThePartition BEFORE filling the geometry info!";
822 t2.SetTextColor(kRed);
824 t2.DrawLatexNDC(0.6, 0.50, Form(
"%s NOT SUPPORTED!",
phase.c_str()));
826 t2.DrawLatexNDC(0.6, 0.50,
"MISMATCHED PAYLOAD SIZE!");
831 template <
typename T>
835 using pairtype = std::pair<unsigned int, T>;
836 auto max = *std::max_element(
837 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
838 auto min = *std::min_element(
839 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
840 return std::make_pair(
min.second,
max.second);
847 std::transform(answer.begin(), answer.end(), answer.begin(), [](
unsigned char x) { return ::tolower(
x); });
849 bool answer_valid = (answer ==
"y") || (answer ==
"n") || (answer ==
"yes") || (answer ==
"no") ||
850 (answer ==
"true") || (answer ==
"false") || (answer ==
"1") || (answer ==
"0");
852 result = answer_valid && (answer[0] ==
'y' || answer[0] ==
't' || answer[0] ==
'1');
unsigned int pxbLayer(const DetId &id) const
int ringName() const
ring Id
const void print(std::stringstream &ss)
PhaseInfo(const phase &thePhase)
int signed_blade_panel(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
ret
prodAgent to be discontinued
static const unsigned int phase0size
int bladeName() const
blade id
int moduleName() const
module id (index in z)
unsigned int pxfModule(const DetId &id) const
int quadrant(const DetId &detid, const TrackerTopology *tTopo_, bool phase_)
const char * pathToTopoXML()
const Time_t kLowMask(0xFFFFFFFF)
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
unsigned int pxbLadder(const DetId &id) const
Log< level::Error, false > LogError
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
bool checkAnswerOK(std::string &answer, bool &result)
static std::string to_string(const XMLCh *ch)
const SiPixelPI::phase phase() const
int signed_ladder(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
unsigned long long Time_t
void printAll(std::stringstream &ss) const
std::pair< T, T > findMinMaxInMap(const std::map< unsigned int, T > &theMap)
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_)
HalfCylinder halfCylinder() const
static const unsigned int phase1size
unsigned int pxfDisk(const DetId &id) const
SiPixelPI::regions filterThePartition()
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void draw_line(double x1, double x2, double y1, double y2, int width=2, int style=1, int color=1)
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
std::ostream & operator<<(std::ostream &os, PhaseInfo phInfo)
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)
unsigned int pxfPanel(const DetId &id) const
Log< level::Info, false > LogInfo
int ring(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
const std::array< std::string, 3 > DetNames
unsigned int pxfSide(const DetId &id) const
void makeNicePlotStyle(TH1 *hist)
constexpr uint32_t rawId() const
get the raw id
int signed_module(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
void displayNotSupported(TCanvas &canv, const unsigned int size)
const bool isComparedWithPhase2(const PhaseInfo &theOtherPhase) const
bool isBPixOuterLadder(const DetId &detid, const TrackerTopology &tTopo, bool isPhase0)
PhaseInfo(unsigned int size)
int ladderName() const
ladder id (index in phi)
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)
Log< level::Warning, false > LogWarning
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)
static const unsigned int mismatched
static const unsigned int phase2size
const bool isPhase1Comparison(const PhaseInfo &theOtherPhase) const