1 #ifndef CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H
2 #define CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H
35 double tmean =
mean();
68 void Fill(
int apv,
int det,
double vx) {
122 :
entryx_(),
entryy_(),
mode_(mode),
obj_(name, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax) {}
128 void Fill(
int apv,
int det,
double vx,
double vy) {
185 return "should never be here";
203 return "should never be here";
253 auto region =
static_cast<std::underlying_type_t<SiStripPI::TrackerRegion>
>(
index);
257 return std::make_pair(1,
"TIB L1 r-#varphi");
259 return std::make_pair(2,
"TIB L1 stereo");
261 return std::make_pair(3,
"TIB L2 r-#varphi");
263 return std::make_pair(4,
"TIB L2 stereo");
265 return std::make_pair(5,
"TIB L3");
267 return std::make_pair(6,
"TIB L4");
269 return std::make_pair(7,
"TOB L1 r-#varphi");
271 return std::make_pair(8,
"TOB L1 stereo");
273 return std::make_pair(9,
"TOB L2 r-#varphi");
275 return std::make_pair(10,
"TOB L2 stereo");
277 return std::make_pair(11,
"TOB L3 r-#varphi");
279 return std::make_pair(12,
"TOB L4");
281 return std::make_pair(13,
"TOB L5");
283 return std::make_pair(14,
"TOB L6");
285 return std::make_pair(15,
"TEC D1 r-#varphi");
287 return std::make_pair(16,
"TEC D1 stereo");
289 return std::make_pair(17,
"TEC D2 r-#varphi");
291 return std::make_pair(18,
"TEC D2 stereo");
293 return std::make_pair(19,
"TEC D3 r-#varphi");
295 return std::make_pair(20,
"TEC D3 stereo");
297 return std::make_pair(21,
"TEC D4 r-#varphi");
299 return std::make_pair(22,
"TEC D4 stereo");
301 return std::make_pair(23,
"TEC D5 r-#varphi");
303 return std::make_pair(24,
"TEC D5 stereo");
305 return std::make_pair(25,
"TEC D6 r-#varphi");
307 return std::make_pair(26,
"TEC D6 stereo");
309 return std::make_pair(27,
"TEC D7 r-#varphi");
311 return std::make_pair(28,
"TEC D7 stereo");
313 return std::make_pair(29,
"TEC D8 r-#varphi");
315 return std::make_pair(30,
"TEC D8 stereo");
317 return std::make_pair(31,
"TEC D9 r-#varphi");
319 return std::make_pair(32,
"TEC D9 stereo");
321 return std::make_pair(33,
"TID D1 r-#varphi");
323 return std::make_pair(34,
"TID D1 stereo");
325 return std::make_pair(35,
"TID D2 r-#varphi");
327 return std::make_pair(36,
"TID D2 stereo");
329 return std::make_pair(37,
"TID D3 r-#varphi");
331 return std::make_pair(38,
"TID D3 stereo");
333 return std::make_pair(-1,
"undefined");
335 return std::make_pair(999,
"should never be here");
340 inline std::pair<float, float>
getTheRange(std::map<uint32_t, float>
values,
const float nsigma)
343 float sum = std::accumulate(
345 return value + p.second;
348 float m = sum / values.size();
352 accum += (p.second -
m) * (p.second - m);
355 float stdev =
sqrt(accum / (values.size() - 1));
358 return std::make_pair(m - nsigma * stdev, m + nsigma * stdev);
360 return std::make_pair(m > 0. ? 0.95 * m : 1.05 * m, m > 0 ? 1.05 * m : 0.95 * m);
366 std::map<std::string, int> colormap,
367 std::vector<std::string> legend,
377 for (
const auto& element : legend) {
378 TPaveText*
stat =
new TPaveText(
X,
Y - (i *
H),
X + W,
Y - (i + 1) * H,
"NDC");
380 auto Histo =
histos[element];
381 sprintf(buffer,
"Entries : %i\n", (
int)Histo->GetEntries());
382 stat->AddText(buffer);
384 sprintf(buffer,
"Mean : %6.2f\n", Histo->GetMean());
385 stat->AddText(buffer);
387 sprintf(buffer,
"RMS : %6.2f\n", Histo->GetRMS());
388 stat->AddText(buffer);
390 stat->SetFillColor(0);
391 stat->SetLineColor(colormap[element]);
392 stat->SetTextColor(colormap[element]);
393 stat->SetTextSize(0.03);
394 stat->SetBorderSize(0);
395 stat->SetMargin(0.05);
396 stat->SetTextAlign(12);
405 float theMax(-9999.);
407 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
408 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
410 float add_min = theMin > 0. ? -0.05 : 0.05;
411 float add_max = theMax > 0. ? 0.05 : -0.05;
413 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
421 hist->SetStats(kFALSE);
422 hist->SetLineWidth(2);
423 hist->GetXaxis()->CenterTitle(
true);
424 hist->GetYaxis()->CenterTitle(
true);
425 hist->GetXaxis()->SetTitleFont(42);
426 hist->GetYaxis()->SetTitleFont(42);
427 hist->GetXaxis()->SetTitleSize(0.05);
428 hist->GetYaxis()->SetTitleSize(0.05);
429 hist->GetXaxis()->SetTitleOffset(0.9);
430 hist->GetYaxis()->SetTitleOffset(1.3);
431 hist->GetXaxis()->SetLabelFont(42);
432 hist->GetYaxis()->SetLabelFont(42);
433 hist->GetYaxis()->SetLabelSize(.05);
434 hist->GetXaxis()->SetLabelSize(.05);
438 inline void printSummary(
const std::map<unsigned int, SiStripDetSummary::Values>& map)
441 for (
const auto& element : map) {
442 int count = element.second.count;
443 double mean = count > 0 ? (element.second.mean) / count : 0.;
444 double rms = count > 0 ? (element.second.rms) / count - mean * mean : 0.;
452 switch ((element.first) / 1000) {
467 int layer = (element.first) / 10 - (element.first) / 1000 * 100;
468 int stereo = (element.first) - (layer * 10) - (element.first) / 1000 * 1000;
470 std::cout <<
"key of the map:" << element.first <<
" ( region: " <<
regionType(element.first).second <<
" ) "
471 << detector <<
" layer: " << layer <<
" stereo:" << stereo <<
"| count:" << count <<
" mean: " << mean
472 <<
" rms: " << rms << std::endl;
483 NBadComponent[
i][0][2] += std::bitset<16>(BC.
BadApvs & 0x3f).
count();
484 NBadComponent[
i][component][2] += std::bitset<16>(BC.
BadApvs & 0x3f).
count();
489 NBadComponent[
i][component][1] += std::bitset<4>(BC.
BadFibers & 0x7).
count();
493 NBadComponent[
i][0][0]++;
494 NBadComponent[
i][component][0]++;
501 std::shared_ptr<SiStripNoises>
payload,
507 std::vector<float> vstripnoise;
509 for (; rit != erit; ++rit) {
510 Nstrips = (rit->iend - rit->ibegin) * 8 / 9;
511 vstripnoise.resize(Nstrips);
514 make_pair(payload->getDataVectorBegin() + rit->ibegin, payload->getDataVectorBegin() + rit->iend));
521 DetId detId(rit->detid);
523 for (
size_t i = 0;
i < Nstrips; ++
i) {
524 mean += vstripnoise[
i];
525 rms += vstripnoise[
i] * vstripnoise[
i];
526 if (vstripnoise[
i] < min)
527 min = vstripnoise[
i];
528 if (vstripnoise[
i] > max)
529 max = vstripnoise[
i];
533 if ((rms / Nstrips - mean * mean) > 0.) {
534 rms =
sqrt(rms / Nstrips - mean * mean);
541 summaryNoise.
add(detId, min);
544 summaryNoise.
add(detId, max);
547 summaryNoise.
add(detId, mean);
550 summaryNoise.
add(detId, rms);
565 for (
const auto& det : detInfo.getAllData()) {
566 int nAPVs = detInfo.getNumberOfApvsAndStripLength(det.first).first;
568 int nFibers = nAPVs / 2;
569 int nStrips = (128 * detInfo.getNumberOfApvsAndStripLength(det.first).first);
571 NTkComponents[1] += nFibers;
572 NTkComponents[2] += nAPVs;
578 int subDetIndex = -1;
582 component = m_trackerTopo.
tibLayer(det.first);
585 component = m_trackerTopo.
tidSide(det.first) == 2 ? m_trackerTopo.
tidWheel(det.first)
586 : m_trackerTopo.
tidWheel(det.first) + 3;
589 component = m_trackerTopo.
tobLayer(det.first);
592 component = m_trackerTopo.
tecSide(det.first) == 2 ? m_trackerTopo.
tecWheel(det.first)
593 : m_trackerTopo.
tecWheel(det.first) + 9;
596 NComponents[subDetIndex][0][0]++;
597 NComponents[subDetIndex][0][1] += nFibers;
598 NComponents[subDetIndex][0][2] += nAPVs;
599 NComponents[subDetIndex][0][3] +=
nStrips;
601 NComponents[subDetIndex][component][0]++;
602 NComponents[subDetIndex][component][1] += nFibers;
603 NComponents[subDetIndex][component][2] += nAPVs;
604 NComponents[subDetIndex][component][3] +=
nStrips;
611 int NTkBadComponent[4],
612 int NBadComponent[4][19][4],
618 for (
size_t i = 0;
i < BC.size(); ++
i) {
623 if (BC.at(
i).BadModule)
624 NTkBadComponent[0]++;
625 if (BC.at(
i).BadFibers)
626 NTkBadComponent[1] +=
627 ((BC.at(
i).BadFibers >> 2) & 0x1) + ((BC.at(
i).BadFibers >> 1) & 0x1) + ((BC.at(
i).BadFibers) & 0x1);
628 if (BC.at(
i).BadApvs)
629 NTkBadComponent[2] += ((BC.at(
i).BadApvs >> 5) & 0x1) + ((BC.at(
i).BadApvs >> 4) & 0x1) +
630 ((BC.at(
i).BadApvs >> 3) & 0x1) + ((BC.at(
i).BadApvs >> 2) & 0x1) +
631 ((BC.at(
i).BadApvs >> 1) & 0x1) + ((BC.at(
i).BadApvs) & 0x1);
644 component = m_trackerTopo.
tibLayer(BC.at(
i).detid);
652 component = m_trackerTopo.
tidSide(BC.at(
i).detid) == 2 ? m_trackerTopo.
tidWheel(BC.at(
i).detid)
653 : m_trackerTopo.
tidWheel(BC.at(
i).detid) + 3;
661 component = m_trackerTopo.
tobLayer(BC.at(
i).detid);
669 component = m_trackerTopo.
tecSide(BC.at(
i).detid) == 2 ? m_trackerTopo.
tecWheel(BC.at(
i).detid)
670 : m_trackerTopo.
tecWheel(BC.at(
i).detid) + 9;
682 float percentage = 0;
688 uint32_t detid = rp->detid;
691 int component = -999;
696 component = m_trackerTopo.
tibLayer(detid);
703 component = m_trackerTopo.
tobLayer(detid);
714 for (
int it = 0; it < sqrange.second - sqrange.first; it++) {
716 NTkBadComponent[3] +=
range;
717 NBadComponent[subdet][0][3] +=
range;
718 NBadComponent[subdet][component][3] +=
range;
722 percentage /= 128. * detInfo.getNumberOfApvsAndStripLength(detid).first;
725 <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
730 inline void printBCDebug(
int NTkBadComponent[4],
int NBadComponent[4][19][4])
737 std::stringstream
ss;
739 ss <<
"\n-----------------\nGlobal Info\n-----------------";
740 ss <<
"\nBadComponent \t Modules \tFibers "
741 "\tApvs\tStrips\n----------------------------------------------------------------";
742 ss <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t"
743 << NTkBadComponent[3];
745 ss <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
746 <<
"\t" << NBadComponent[0][0][3];
747 ss <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
748 <<
"\t" << NBadComponent[1][0][3];
749 ss <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
750 <<
"\t" << NBadComponent[2][0][3];
751 ss <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
752 <<
"\t" << NBadComponent[3][0][3];
755 for (
int i = 1;
i < 5; ++
i)
756 ss <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t"
757 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
759 for (
int i = 1;
i < 4; ++
i)
760 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t"
761 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
762 for (
int i = 4;
i < 7; ++
i)
763 ss <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t"
764 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
766 for (
int i = 1;
i < 7; ++
i)
767 ss <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t"
768 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
770 for (
int i = 1;
i < 10; ++
i)
771 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t"
772 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
773 for (
int i = 10;
i < 19; ++
i)
774 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t"
775 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
782 enum palette {
HALFGRAY,
GRAY,
BLUES,
REDS,
ANTIGRAY,
FIRE,
ANTIFIRE,
LOGREDBLUE,
BLUERED,
LOGBLUERED,
DEFAULT };
788 TStyle* palettestyle =
new TStyle(
"palettestyle",
"Style for P-TDR");
791 const int NCont = 255;
795 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
796 double red[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
797 double green[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
798 double blue[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
799 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
803 double stops[NRGBs] = {0.00, 0.01, 0.05, 0.09, 0.1};
804 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
805 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
806 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
807 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
811 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
812 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
813 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
814 double blue[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
815 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
820 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
821 double red[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
822 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
823 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
824 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
828 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
829 double red[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
830 double green[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
831 double blue[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
832 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
837 double stops[NCOLs] = {0.00, 0.20, 0.80, 1.00};
838 double red[NCOLs] = {1.00, 1.00, 1.00, 0.50};
839 double green[NCOLs] = {1.00, 1.00, 0.00, 0.00};
840 double blue[NCOLs] = {0.20, 0.00, 0.00, 0.00};
841 TColor::CreateGradientColorTable(NCOLs, stops, red, green, blue, NCont);
846 double stops[NCOLs] = {0.00, 0.20, 0.80, 1.00};
847 double red[NCOLs] = {0.50, 1.00, 1.00, 1.00};
848 double green[NCOLs] = {0.00, 0.00, 1.00, 1.00};
849 double blue[NCOLs] = {0.00, 0.00, 0.00, 0.20};
850 TColor::CreateGradientColorTable(NCOLs, stops, red, green, blue, NCont);
854 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
855 double red[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
856 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
857 double blue[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
858 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
862 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
863 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
864 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
865 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
866 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
870 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
871 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
872 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
873 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
874 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
878 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
879 double red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
880 double green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
881 double blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
882 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
885 std::cout <<
"should nevere be here" << std::endl;
889 palettestyle->SetNumberContours(NCont);
static constexpr auto TEC
const std::vector< BadComponent > & getBadComponentList() const
unsigned int tibLayer(const DetId &id) const
std::pair< int, const char * > regionType(int index)
void Fill(int apv, int det, double vx)
unsigned int tidWheel(const DetId &id) const
Registry::const_iterator RegistryIterator
Log< level::Error, false > LogError
void setPaletteStyle(SiStripPI::palette palette)
void fillBCArrays(const SiStripQuality *siStripQuality_, int NTkBadComponent[4], int NBadComponent[4][19][4], const TrackerTopology m_trackerTopo)
tuple nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
constexpr std::array< uint8_t, layerIndexSize > layer
const uint16_t range(const Frame &aFrame)
void printSummary(const std::map< unsigned int, SiStripDetSummary::Values > &map)
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
void fillNoiseDetSummary(SiStripDetSummary &summaryNoise, std::shared_ptr< SiStripNoises > payload, SiStripPI::estimator est)
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
Container::value_type value_type
RegistryIterator getRegistryVectorEnd() const
unsigned int tidSide(const DetId &id) const
void drawStatBox(std::map< std::string, std::shared_ptr< TH1F >> histos, std::map< std::string, int > colormap, std::vector< std::string > legend, double X=0.15, double Y=0.93, double W=0.15, double H=0.10)
void Fill(int apv, int det, double vx, double vy)
void printBCDebug(int NTkBadComponent[4], int NBadComponent[4][19][4])
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Registry::const_iterator RegistryIterator
void add(DetId detid, float value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
void makeNicePlotStyle(TH1 *hist)
SiStripDetInfo read(std::string filePath)
std::string getStringFromSubdet(StripSubdetector::SubDetector sub)
static constexpr auto TOB
std::string estimatorType(SiStripPI::estimator e)
ContainerIterator getDataVectorBegin() const
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
static constexpr auto TIB
Monitor1D(OpMode mode, const char *name, const char *title, int nbinsx, double xmin, double xmax)
RegistryIterator getRegistryVectorBegin() const
void fillTotalComponents(int NTkComponents[4], int NComponents[4][19][4], const TrackerTopology m_trackerTopo)
std::pair< ContainerIterator, ContainerIterator > Range
static constexpr char const *const kDefaultFile
Monitor2D(OpMode mode, const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax)
Log< level::Warning, false > LogWarning
unsigned int tecWheel(const DetId &id) const
static constexpr auto TID
data decode(const unsigned int &value) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const