1 #ifndef CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 25 #include "TObjArray.h" 26 #include "TPaveText.h" 32 using MetaData = std::tuple<cond::Time_t, cond::Hash>;
44 double tmean =
mean();
77 void Fill(
int apv,
int det,
double vx) {
131 :
entryx_(),
entryy_(),
mode_(
mode),
obj_(
name,
title,
nbinsx,
xmin,
xmax,
nbinsy,
ymin,
ymax) {}
137 void Fill(
int apv,
int det,
double vx,
double vy) {
194 return "should never be here";
212 return "should never be here";
262 auto region =
static_cast<std::underlying_type_t<SiStripPI::TrackerRegion>
>(
index);
266 return std::make_pair(1,
"TIB L1 r-#varphi");
268 return std::make_pair(2,
"TIB L1 stereo");
270 return std::make_pair(3,
"TIB L2 r-#varphi");
272 return std::make_pair(4,
"TIB L2 stereo");
274 return std::make_pair(5,
"TIB L3");
276 return std::make_pair(6,
"TIB L4");
278 return std::make_pair(7,
"TOB L1 r-#varphi");
280 return std::make_pair(8,
"TOB L1 stereo");
282 return std::make_pair(9,
"TOB L2 r-#varphi");
284 return std::make_pair(10,
"TOB L2 stereo");
286 return std::make_pair(11,
"TOB L3 r-#varphi");
288 return std::make_pair(12,
"TOB L4");
290 return std::make_pair(13,
"TOB L5");
292 return std::make_pair(14,
"TOB L6");
294 return std::make_pair(15,
"TEC D1 r-#varphi");
296 return std::make_pair(16,
"TEC D1 stereo");
298 return std::make_pair(17,
"TEC D2 r-#varphi");
300 return std::make_pair(18,
"TEC D2 stereo");
302 return std::make_pair(19,
"TEC D3 r-#varphi");
304 return std::make_pair(20,
"TEC D3 stereo");
306 return std::make_pair(21,
"TEC D4 r-#varphi");
308 return std::make_pair(22,
"TEC D4 stereo");
310 return std::make_pair(23,
"TEC D5 r-#varphi");
312 return std::make_pair(24,
"TEC D5 stereo");
314 return std::make_pair(25,
"TEC D6 r-#varphi");
316 return std::make_pair(26,
"TEC D6 stereo");
318 return std::make_pair(27,
"TEC D7 r-#varphi");
320 return std::make_pair(28,
"TEC D7 stereo");
322 return std::make_pair(29,
"TEC D8 r-#varphi");
324 return std::make_pair(30,
"TEC D8 stereo");
326 return std::make_pair(31,
"TEC D9 r-#varphi");
328 return std::make_pair(32,
"TEC D9 stereo");
330 return std::make_pair(33,
"TID D1 r-#varphi");
332 return std::make_pair(34,
"TID D1 stereo");
334 return std::make_pair(35,
"TID D2 r-#varphi");
336 return std::make_pair(36,
"TID D2 stereo");
338 return std::make_pair(37,
"TID D3 r-#varphi");
340 return std::make_pair(38,
"TID D3 stereo");
342 return std::make_pair(-1,
"undefined");
344 return std::make_pair(999,
"should never be here");
349 inline std::pair<float, float>
getTheRange(std::map<uint32_t, float>
values,
const float nsigma)
352 float sum = std::accumulate(
361 accum += (
p.second -
m) * (
p.second -
m);
367 return std::make_pair(
m - nsigma *
stdev,
m + nsigma *
stdev);
369 return std::make_pair(
m > 0. ? 0.95 *
m : 1.05 *
m,
m > 0 ? 1.05 *
m : 0.95 *
m);
375 std::map<std::string, int> colormap,
376 std::vector<std::string>
legend,
386 for (
const auto& element :
legend) {
387 TPaveText*
stat =
new TPaveText(
X,
Y - (
i *
H),
X + W,
Y - (
i + 1) *
H,
"NDC");
389 auto Histo =
histos[element];
390 sprintf(
buffer,
"Entries : %i\n", (
int)Histo->GetEntries());
393 sprintf(
buffer,
"Mean : %6.2f\n", Histo->GetMean());
396 sprintf(
buffer,
"RMS : %6.2f\n", Histo->GetRMS());
399 stat->SetFillColor(0);
400 stat->SetLineColor(colormap[element]);
401 stat->SetTextColor(colormap[element]);
402 stat->SetTextSize(0.03);
403 stat->SetBorderSize(0);
404 stat->SetMargin(0.05);
405 stat->SetTextAlign(12);
414 float theMax(-9999.);
416 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
417 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
419 float add_min = theMin > 0. ? -0.05 : 0.05;
420 float add_max = theMax > 0. ? 0.05 : -0.05;
422 auto result = std::make_pair(theMin * (1 + add_min), theMax * (1 + add_max));
430 double theMaximum = (
static_cast<TH1*
>(
array->At(0)))->GetMaximum();
431 for (
int i = 0;
i <
array->GetSize();
i++) {
432 if ((static_cast<TH1*>(
array->At(
i)))->GetMaximum() > theMaximum) {
433 theMaximum = (
static_cast<TH1*
>(
array->At(
i)))->GetMaximum();
443 hist->SetStats(kFALSE);
444 hist->SetLineWidth(2);
445 hist->GetXaxis()->CenterTitle(
true);
446 hist->GetYaxis()->CenterTitle(
true);
447 hist->GetXaxis()->SetTitleFont(42);
448 hist->GetYaxis()->SetTitleFont(42);
449 hist->GetXaxis()->SetTitleSize(0.05);
450 hist->GetYaxis()->SetTitleSize(0.05);
451 hist->GetXaxis()->SetTitleOffset(0.9);
452 hist->GetYaxis()->SetTitleOffset(1.3);
453 hist->GetXaxis()->SetLabelFont(42);
454 hist->GetYaxis()->SetLabelFont(42);
455 hist->GetYaxis()->SetLabelSize(.05);
456 hist->GetXaxis()->SetLabelSize(.05);
466 hist->SetStats(kFALSE);
467 hist->SetLineWidth(2);
469 hist->GetXaxis()->CenterTitle(
true);
470 hist->GetYaxis()->CenterTitle(
true);
471 hist->GetXaxis()->SetTitleFont(42);
472 hist->GetYaxis()->SetTitleFont(42);
473 hist->GetXaxis()->SetTitleSize(0.05);
474 hist->GetYaxis()->SetTitleSize(0.05);
475 hist->GetXaxis()->SetTitleOffset(0.9);
476 hist->GetYaxis()->SetTitleOffset(1.3);
477 hist->GetXaxis()->SetLabelFont(42);
478 hist->GetYaxis()->SetLabelFont(42);
479 hist->GetYaxis()->SetLabelSize(.05);
480 hist->GetXaxis()->SetLabelSize(.05);
484 inline void printSummary(
const std::map<unsigned int, SiStripDetSummary::Values>&
map)
487 for (
const auto& element :
map) {
488 int count = element.second.count;
498 switch ((element.first) / 1000) {
513 int layer = (element.first) / 10 - (element.first) / 1000 * 100;
514 int stereo = (element.first) - (layer * 10) - (element.first) / 1000 * 1000;
516 std::cout <<
"key of the map:" << element.first <<
" ( region: " <<
regionType(element.first).second <<
" ) " 517 <<
detector <<
" layer: " << layer <<
" stereo:" << stereo <<
"| count:" <<
count <<
" mean: " <<
mean 518 <<
" rms: " <<
rms << std::endl;
529 NBadComponent[
i][0][2] += std::bitset<16>(BC.
BadApvs & 0x3f).
count();
530 NBadComponent[
i][component][2] += std::bitset<16>(BC.
BadApvs & 0x3f).
count();
535 NBadComponent[
i][component][1] += std::bitset<4>(BC.
BadFibers & 0x7).
count();
539 NBadComponent[
i][0][0]++;
540 NBadComponent[
i][component][0]++;
547 std::shared_ptr<SiStripNoises>
payload,
553 std::vector<float> vstripnoise;
555 for (; rit != erit; ++rit) {
556 Nstrips = (rit->iend - rit->ibegin) * 8 / 9;
557 vstripnoise.resize(Nstrips);
560 make_pair(
payload->getDataVectorBegin() + rit->ibegin,
payload->getDataVectorBegin() + rit->iend));
569 for (
size_t i = 0;
i < Nstrips; ++
i) {
570 mean += vstripnoise[
i];
571 rms += vstripnoise[
i] * vstripnoise[
i];
572 if (vstripnoise[
i] <
min)
573 min = vstripnoise[
i];
574 if (vstripnoise[
i] >
max)
575 max = vstripnoise[
i];
611 for (
const auto& det : detInfo.getAllData()) {
612 int nAPVs = detInfo.getNumberOfApvsAndStripLength(det.first).first;
614 int nFibers = nAPVs / 2;
617 NTkComponents[1] += nFibers;
618 NTkComponents[2] += nAPVs;
624 int subDetIndex = -1;
628 component = m_trackerTopo.
tibLayer(det.first);
631 component = m_trackerTopo.
tidSide(det.first) == 2 ? m_trackerTopo.
tidWheel(det.first)
632 : m_trackerTopo.
tidWheel(det.first) + 3;
635 component = m_trackerTopo.
tobLayer(det.first);
638 component = m_trackerTopo.
tecSide(det.first) == 2 ? m_trackerTopo.
tecWheel(det.first)
639 : m_trackerTopo.
tecWheel(det.first) + 9;
642 NComponents[subDetIndex][0][0]++;
643 NComponents[subDetIndex][0][1] += nFibers;
644 NComponents[subDetIndex][0][2] += nAPVs;
645 NComponents[subDetIndex][0][3] +=
nStrips;
647 NComponents[subDetIndex][component][0]++;
648 NComponents[subDetIndex][component][1] += nFibers;
649 NComponents[subDetIndex][component][2] += nAPVs;
650 NComponents[subDetIndex][component][3] +=
nStrips;
657 int NTkBadComponent[4],
658 int NBadComponent[4][19][4],
664 for (
size_t i = 0;
i < BC.size(); ++
i) {
669 if (BC.at(
i).BadModule)
670 NTkBadComponent[0]++;
671 if (BC.at(
i).BadFibers)
672 NTkBadComponent[1] +=
673 ((BC.at(
i).BadFibers >> 2) & 0x1) + ((BC.at(
i).BadFibers >> 1) & 0x1) + ((BC.at(
i).BadFibers) & 0x1);
674 if (BC.at(
i).BadApvs)
675 NTkBadComponent[2] += ((BC.at(
i).BadApvs >> 5) & 0x1) + ((BC.at(
i).BadApvs >> 4) & 0x1) +
676 ((BC.at(
i).BadApvs >> 3) & 0x1) + ((BC.at(
i).BadApvs >> 2) & 0x1) +
677 ((BC.at(
i).BadApvs >> 1) & 0x1) + ((BC.at(
i).BadApvs) & 0x1);
690 component = m_trackerTopo.
tibLayer(BC.at(
i).detid);
698 component = m_trackerTopo.
tidSide(BC.at(
i).detid) == 2 ? m_trackerTopo.
tidWheel(BC.at(
i).detid)
699 : m_trackerTopo.
tidWheel(BC.at(
i).detid) + 3;
707 component = m_trackerTopo.
tobLayer(BC.at(
i).detid);
715 component = m_trackerTopo.
tecSide(BC.at(
i).detid) == 2 ? m_trackerTopo.
tecWheel(BC.at(
i).detid)
716 : m_trackerTopo.
tecWheel(BC.at(
i).detid) + 9;
728 float percentage = 0;
734 uint32_t detid = rp->detid;
737 int component = -999;
742 component = m_trackerTopo.
tibLayer(detid);
749 component = m_trackerTopo.
tobLayer(detid);
760 for (
int it = 0;
it < sqrange.second - sqrange.first;
it++) {
762 NTkBadComponent[3] +=
range;
763 NBadComponent[subdet][0][3] +=
range;
764 NBadComponent[subdet][component][3] +=
range;
771 <<
"PROBLEM detid " << detid <<
" value " << percentage << std::endl;
776 inline void printBCDebug(
int NTkBadComponent[4],
int NBadComponent[4][19][4])
783 std::stringstream
ss;
785 ss <<
"\n-----------------\nGlobal Info\n-----------------";
786 ss <<
"\nBadComponent \t Modules \tFibers " 787 "\tApvs\tStrips\n----------------------------------------------------------------";
788 ss <<
"\nTracker:\t\t" << NTkBadComponent[0] <<
"\t" << NTkBadComponent[1] <<
"\t" << NTkBadComponent[2] <<
"\t" 789 << NTkBadComponent[3];
791 ss <<
"\nTIB:\t\t\t" << NBadComponent[0][0][0] <<
"\t" << NBadComponent[0][0][1] <<
"\t" << NBadComponent[0][0][2]
792 <<
"\t" << NBadComponent[0][0][3];
793 ss <<
"\nTID:\t\t\t" << NBadComponent[1][0][0] <<
"\t" << NBadComponent[1][0][1] <<
"\t" << NBadComponent[1][0][2]
794 <<
"\t" << NBadComponent[1][0][3];
795 ss <<
"\nTOB:\t\t\t" << NBadComponent[2][0][0] <<
"\t" << NBadComponent[2][0][1] <<
"\t" << NBadComponent[2][0][2]
796 <<
"\t" << NBadComponent[2][0][3];
797 ss <<
"\nTEC:\t\t\t" << NBadComponent[3][0][0] <<
"\t" << NBadComponent[3][0][1] <<
"\t" << NBadComponent[3][0][2]
798 <<
"\t" << NBadComponent[3][0][3];
801 for (
int i = 1;
i < 5; ++
i)
802 ss <<
"\nTIB Layer " <<
i <<
" :\t\t" << NBadComponent[0][
i][0] <<
"\t" << NBadComponent[0][
i][1] <<
"\t" 803 << NBadComponent[0][
i][2] <<
"\t" << NBadComponent[0][
i][3];
805 for (
int i = 1;
i < 4; ++
i)
806 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 807 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
808 for (
int i = 4;
i < 7; ++
i)
809 ss <<
"\nTID- Disk " <<
i - 3 <<
" :\t\t" << NBadComponent[1][
i][0] <<
"\t" << NBadComponent[1][
i][1] <<
"\t" 810 << NBadComponent[1][
i][2] <<
"\t" << NBadComponent[1][
i][3];
812 for (
int i = 1;
i < 7; ++
i)
813 ss <<
"\nTOB Layer " <<
i <<
" :\t\t" << NBadComponent[2][
i][0] <<
"\t" << NBadComponent[2][
i][1] <<
"\t" 814 << NBadComponent[2][
i][2] <<
"\t" << NBadComponent[2][
i][3];
816 for (
int i = 1;
i < 10; ++
i)
817 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 818 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
819 for (
int i = 10;
i < 19; ++
i)
820 ss <<
"\nTEC- Disk " <<
i - 9 <<
" :\t\t" << NBadComponent[3][
i][0] <<
"\t" << NBadComponent[3][
i][1] <<
"\t" 821 << NBadComponent[3][
i][2] <<
"\t" << NBadComponent[3][
i][3];
828 enum palette {
HALFGRAY,
GRAY,
BLUES,
REDS,
ANTIGRAY,
FIRE,
ANTIFIRE,
LOGREDBLUE,
BLUERED,
LOGBLUERED,
DEFAULT };
834 TStyle* palettestyle =
new TStyle(
"palettestyle",
"Style for P-TDR");
837 const int NCont = 255;
841 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
842 double red[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
843 double green[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
844 double blue[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
845 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
849 double stops[NRGBs] = {0.00, 0.01, 0.05, 0.09, 0.1};
850 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
851 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
852 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
853 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
857 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
858 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
859 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
860 double blue[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
861 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
866 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
867 double red[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
868 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
869 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
870 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
874 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
875 double red[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
876 double green[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
877 double blue[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
878 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
883 double stops[NCOLs] = {0.00, 0.20, 0.80, 1.00};
884 double red[NCOLs] = {1.00, 1.00, 1.00, 0.50};
885 double green[NCOLs] = {1.00, 1.00, 0.00, 0.00};
886 double blue[NCOLs] = {0.20, 0.00, 0.00, 0.00};
887 TColor::CreateGradientColorTable(NCOLs, stops,
red, green,
blue, NCont);
892 double stops[NCOLs] = {0.00, 0.20, 0.80, 1.00};
893 double red[NCOLs] = {0.50, 1.00, 1.00, 1.00};
894 double green[NCOLs] = {0.00, 0.00, 1.00, 1.00};
895 double blue[NCOLs] = {0.00, 0.00, 0.00, 0.20};
896 TColor::CreateGradientColorTable(NCOLs, stops,
red, green,
blue, NCont);
900 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
901 double red[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
902 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
903 double blue[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
904 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
908 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
909 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
910 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
911 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
912 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
916 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
917 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
918 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
919 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
920 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
924 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
925 double red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
926 double green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
927 double blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
928 TColor::CreateGradientColorTable(NRGBs, stops,
red, green,
blue, NCont);
931 std::cout <<
"should nevere be here" << std::endl;
935 palettestyle->SetNumberContours(NCont);
static constexpr auto TEC
ContainerIterator getDataVectorBegin() const
unsigned int tobLayer(const DetId &id) const
std::pair< int, const char * > regionType(int index)
unsigned int tidSide(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
void Fill(int apv, int det, double vx)
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)
nStrips
1.2 is to make the matching window safely the two nearest strips 0.35 is the size of an ME0 chamber i...
const std::vector< BadComponent > & getBadComponentList() const
double getMaximum(TObjArray *array)
void printSummary(const std::map< unsigned int, SiStripDetSummary::Values > &map)
std::tuple< cond::Time_t, cond::Hash > MetaData
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
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)
unsigned int tecSide(const DetId &id) const
void Fill(int apv, int det, double vx, double vy)
void printBCDebug(int NTkBadComponent[4], int NBadComponent[4][19][4])
RegistryIterator getRegistryVectorEnd() const
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)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
SiStripDetInfo read(std::string filePath)
std::string getStringFromSubdet(StripSubdetector::SubDetector sub)
static constexpr auto TOB
std::string estimatorType(SiStripPI::estimator e)
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
static constexpr auto TIB
Constants and enumerated types for FED/FEC systems.
Monitor1D(OpMode mode, const char *name, const char *title, int nbinsx, double xmin, double xmax)
void fillTotalComponents(int NTkComponents[4], int NComponents[4][19][4], const TrackerTopology m_trackerTopo)
static const uint16_t STRIPS_PER_APV
std::pair< ContainerIterator, ContainerIterator > Range
data decode(const unsigned int &value) const
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)
unsigned int tibLayer(const DetId &id) const
Log< level::Warning, false > LogWarning
static constexpr auto TID
RegistryIterator getRegistryVectorBegin() const
void makeNiceStyle(T *hist)