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";
119 return std::make_pair(
run,
lumi);
140 if (
quadrant(detid, &tTopo_, phase_) % 2)
152 if (
quadrant(detid, &tTopo_, phase_) < 3)
170 }
else if (phase_ == 1) {
183 if (
quadrant(detid, &tTopo_, phase_) % 2)
203 if (
quadrant(detid, &tTopo_, phase_) < 3)
210 TLine*
l =
new TLine(x1,
y1, x2,
y2);
211 l->SetBit(kCanDelete);
214 l->SetLineColor(color);
224 bool half_shift =
true,
225 bool mark_zero =
true,
226 bool standard_palette =
true) {
240 gStyle->SetPadRightMargin(0.125);
242 if (standard_palette) {
243 gStyle->SetPalette(1);
246 const Int_t NRGBs = 5;
247 const Int_t NCont = 255;
249 Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
250 Double_t
red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
251 Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
252 Double_t
blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
253 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
254 gStyle->SetNumberContours(NCont);
257 h->SetMarkerSize(0.7);
263 ltx.SetTextSize(0.06);
264 ltx.SetTextAlign(31);
265 ltx.DrawLatexNDC(1 - gPad->GetRightMargin(), 1 - gPad->GetTopMargin() + 0.01, (s_title).c_str());
269 std::vector<std::vector<int>> nladder = {{10, 16, 22}, {6, 14, 22, 32}};
270 int nlad = nladder[
phase][lay - 1];
271 for (
int xsign = -1; xsign <= 1; xsign += 2)
272 for (
int ysign = -1; ysign <= 1; ysign += 2) {
273 float xlow = xsign * (half_shift * 0.5);
274 float xhigh = xsign * (half_shift * 0.5 + 4);
275 float ylow = ysign * (half_shift * 0.5 + (
phase == 0) * 0.5);
276 float yhigh = ysign * (half_shift * 0.5 - (
phase == 0) * 0.5 + nlad);
283 for (
int lad = 1; lad < nlad; ++lad) {
284 float y = ysign * (lad + half_shift * 0.5);
287 for (
int lad = 1; lad <= nlad; ++lad)
288 if (!(
phase == 0 && (lad == 1 || lad == nlad))) {
289 float y = ysign * (lad + half_shift * 0.5 - 0.5);
294 float x = xsign * (
mod + half_shift * 0.5);
302 for (
int lad = 1; lad <= nlad; ++lad) {
303 bool flipped = ysign == 1 ? lad % 2 == 0 : lad % 2 == 1;
306 int roc0_orientation = flipped ? -1 : 1;
308 roc0_orientation *= -1;
310 roc0_orientation *= -1;
311 float x1 = xsign * (
mod + half_shift * 0.5);
312 float x2 = xsign * (
mod + half_shift * 0.5 - 1. / 8);
313 float y1 = ysign * (lad + half_shift * 0.5 - 0.5);
314 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 1. / 2);
315 if (!(
phase == 0 && (lad == 1 || lad == nlad) && xsign == -1)) {
316 if (lay == 1 && xsign <= -1) {
317 float x1 = xsign * ((
mod - 1) + half_shift * 0.5);
318 float x2 = xsign * ((
mod - 1) + half_shift * 0.5 + 1. / 8);
319 float y1 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation);
320 float y2 = ysign * (lad + half_shift * 0.5 - 0.5 + roc0_orientation * 3. / 2);
335 for (
int dsk = 1, ndsk = 2 + (
phase == 1); dsk <= ndsk; ++dsk) {
336 for (
int xsign = -1; xsign <= 1; xsign += 2)
337 for (
int ysign = -1; ysign <= 1; ysign += 2) {
339 int first_roc = 3, nbin = 16;
340 for (
int bld = 1, nbld = 12; bld <= nbld; ++bld) {
342 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
344 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
346 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * (plq + 1) - (plq == 7)) / (
float)nbin);
347 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + plq / 2) * 0.1);
348 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + plq / 2) * 0.1);
353 for (
int plq = 1, nplq = 7 + 1; plq <= nplq; ++plq) {
354 float x = xsign * (half_shift * 0.5 + dsk - 1 +
355 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8)) / (
float)nbin);
356 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
357 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
361 for (
int plq = 2, nplq = 6; plq <= nplq; ++plq)
363 float x = xsign * (half_shift * 0.5 + dsk - 1 +
364 (first_roc - 3 + 2 * plq + (plq == 1) - (plq == 8) + 1) / (
float)nbin);
365 float ylow = ysign * (half_shift * 0.5 + (bld - 0.5) - (2 + (plq - (plq == 8)) / 2) * 0.1);
366 float yhigh = ysign * (half_shift * 0.5 + (bld - 0.5) + (2 + (plq - (plq == 8)) / 2) * 0.1);
370 for (
int plq = 1, nplq = 7; plq <= nplq; ++plq) {
372 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1)) / (
float)nbin);
374 xsign * (half_shift * 0.5 + dsk - 1 + (first_roc - 3 + 2 * plq + (plq == 1) + 1) / (
float)nbin);
375 int sign = xsign * ysign * ((plq % 2) ? 1 : -1);
376 float y1 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (2 + plq / 2) * 0.1);
377 float y2 = ysign * (half_shift * 0.5 + (bld - 0.5) +
sign * (plq / 2) * 0.1);
384 }
else if (
phase == 1) {
387 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
389 Color_t p1_color = 1, p2_color = 1;
392 float x1 = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
393 float x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
395 float y1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.5);
397 float y2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld);
398 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
399 float y3 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.5);
403 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
404 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
406 float x = xsign * (half_shift * 0.5 + dsk - 1 + (
ring - 1) * 0.5);
411 x = xsign * (half_shift * 0.5 + dsk);
416 x1 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5 - 1 / 16.);
417 x2 = xsign * (half_shift * 0.5 + dsk - 1 +
ring * 0.5);
418 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25);
419 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld +
sign * 0.25 + xsign * ysign * 0.25);
424 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25);
425 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 +
scale * bld -
sign * 0.25 - xsign * ysign * 0.25);
432 for (
int bld = 1, nbld = 5 +
ring * 6; bld <= nbld; ++bld) {
433 Color_t p1_color = 1, p2_color = 1;
436 float x1 = xsign * (half_shift * 0.5 + dsk - 1);
437 float x2 = xsign * (half_shift * 0.5 + dsk);
439 float y1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.5);
441 float y2 = ysign * (half_shift * 0.5 - 0.5 + bld);
442 float yp2_mid = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
443 float y3 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.5);
447 draw_line(x1, x2, yp2_mid, yp2_mid, 1, 2);
448 draw_line(x1, x2, y3, y3, 1, 1, p2_color);
450 float x = xsign * (half_shift * 0.5 + dsk - 1);
455 x = xsign * (half_shift * 0.5 + dsk);
460 x1 = xsign * (half_shift * 0.5 + dsk - 1 / 8.);
461 x2 = xsign * (half_shift * 0.5 + dsk);
462 float y1_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25);
463 float y2_p1 = ysign * (half_shift * 0.5 - 0.5 + bld +
sign * 0.25 + xsign * ysign * 0.25);
468 float y1_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25);
469 float y2_p2 = ysign * (half_shift * 0.5 - 0.5 + bld -
sign * 0.25 - xsign * ysign * 0.25);
485 if (
phase == 0 &&
h->GetNbinsY() == 250 &&
h->GetNbinsX() == 80) {
486 int nentries =
h->GetEntries();
487 for (
int binx = 1; binx <= 80; ++binx) {
489 for (
int biny = 1; biny <= 250; ++biny) {
490 bool odd_nrocy = (binx - 1 < 40) != (((binx - 1) / 4) % 2);
491 if (biny % 2 == odd_nrocy)
492 sum +=
h->GetBinContent(binx, biny);
494 sum +=
h->GetBinContent(binx, biny);
496 h->SetBinContent(binx, biny, sum);
497 h->SetBinContent(binx, biny - 1, sum);
503 h->SetEntries(nentries);
513 pad->SetTopMargin(top);
515 pad->SetBottomMargin(bottom);
517 pad->SetLeftMargin(left);
519 pad->SetRightMargin(right);
536 float theMax(-9999.);
538 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
539 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
541 float add_min = theMin > 0. ? -0.05 : 0.05;
542 float add_max = theMax > 0. ? 0.05 : -0.05;
544 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
552 hist->SetStats(kFALSE);
553 hist->SetLineWidth(2);
554 hist->GetXaxis()->CenterTitle(
true);
555 hist->GetYaxis()->CenterTitle(
true);
556 hist->GetXaxis()->SetTitleFont(42);
557 hist->GetYaxis()->SetTitleFont(42);
558 hist->GetXaxis()->SetTitleSize(0.05);
559 hist->GetYaxis()->SetTitleSize(0.05);
560 hist->GetXaxis()->SetTitleOffset(1.1);
561 hist->GetYaxis()->SetTitleOffset(1.3);
562 hist->GetXaxis()->SetLabelFont(42);
563 hist->GetYaxis()->SetLabelFont(42);
564 hist->GetYaxis()->SetLabelSize(.05);
565 hist->GetXaxis()->SetLabelSize(.05);
568 hist->GetZaxis()->SetLabelFont(42);
569 hist->GetZaxis()->SetLabelFont(42);
570 hist->GetZaxis()->SetLabelSize(.05);
571 hist->GetZaxis()->SetLabelSize(.05);
576 const std::array<std::string, 3>
DetNames = {{
"Barrel",
"End Caps",
"Whole"}};
639 bool isOuter =
false;
644 isOuter = !odd_ladder;
646 isOuter = odd_ladder;
649 isOuter = odd_ladder;
651 isOuter = !odd_ladder;
714 unsigned int subdetId =
static_cast<unsigned int>(detId.
subdetId());
737 throw cms::Exception(
"LogicError") <<
"Cannot call filterThePartition BEFORE filling the geometry info!";
792 t2.SetTextColor(kRed);
794 t2.DrawLatexNDC(0.6, 0.50, Form(
"%s NOT SUPPORTED!",
phase.c_str()));
796 t2.DrawLatexNDC(0.6, 0.50,
"MISMATCHED PAYLOAD SIZE!");
801 template <
typename T>
805 using pairtype = std::pair<unsigned int, T>;
806 auto max = *std::max_element(
807 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
808 auto min = *std::min_element(
809 theMap.begin(), theMap.end(), [](
const pairtype&
p1,
const pairtype&
p2) {
return p1.second <
p2.second; });
810 return std::make_pair(
min.second,
max.second);
817 std::transform(answer.begin(), answer.end(), answer.begin(), [](
unsigned char x) { return ::tolower(
x); });
819 bool answer_valid = (answer ==
"y") || (answer ==
"n") || (answer ==
"yes") || (answer ==
"no") ||
820 (answer ==
"true") || (answer ==
"false") || (answer ==
"1") || (answer ==
"0");
822 result = answer_valid && (answer[0] ==
'y' || answer[0] ==
't' || answer[0] ==
'1');
unsigned int pxbLayer(const DetId &id) const
int ringName() const
ring Id
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()
SiPixelPI::phase * m_Phase
const Time_t kLowMask(0xFFFFFFFF)
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
std::string to_string(const V &value)
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)
const SiPixelPI::phase phase() const
int signed_ladder(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
unsigned long long Time_t
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)
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