1 #ifndef CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 38 double tmean =
mean();
66 obj_(name, title, nbinsx, xmin, xmax) {}
75 void Fill(
int apv,
int det,
double vx) {
78 if(!((apv == prev_apv_ && det == prev_det_) || prev_apv_ == 0)){
85 if(!(det == prev_det_ || prev_det_ == 0)){
98 obj_.Fill(entry_.mean());
112 int prev_apv_=0, prev_det_=0;
126 obj_(name, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax) {}
136 void Fill(
int apv,
int det,
double vx,
double vy) {
139 if(!((apv == prev_apv_ && det == prev_det_) || prev_apv_ == 0)){
146 if(!(det == prev_det_ || prev_det_ == 0)){
160 obj_.Fill(entryx_.mean(), entryy_.mean());
170 int prev_apv_=0, prev_det_=0;
192 default:
return "should never be here";
205 default :
return "should never be here";
240 auto region =
static_cast<std::underlying_type_t<SiStripPI::TrackerRegion>
>(
index);
282 default :
return std::make_pair(999,
"should never be here");
294 {
return value + p.second; }
297 float m = sum / values.size();
303 {accum += (p.second -
m) * (p.second - m);}
306 float stdev =
sqrt(accum / (values.size()-1));
309 return std::make_pair(m-nsigma*stdev,m+nsigma*stdev);
311 return std::make_pair(m>0.? 0.95*m : 1.05*m, m>0? 1.05*m : 0.95*m);
322 for (
const auto &element : legend ){
323 TPaveText*
stat =
new TPaveText(
X,
Y-(i*
H),
X+W,
Y-(i+1)*H,
"NDC");
325 auto Histo =
histos[element];
326 sprintf(buffer,
"Entries : %i\n",(
int)Histo->GetEntries());
327 stat->AddText(buffer);
329 sprintf(buffer,
"Mean : %6.2f\n",Histo->GetMean());
330 stat->AddText(buffer);
332 sprintf(buffer,
"RMS : %6.2f\n",Histo->GetRMS());
333 stat->AddText(buffer);
335 stat->SetFillColor(0);
336 stat->SetLineColor(colormap[element]);
337 stat->SetTextColor(colormap[element]);
338 stat->SetTextSize(0.03);
339 stat->SetBorderSize(0);
340 stat->SetMargin(0.05);
341 stat->SetTextAlign(12);
350 float theMax(-9999.);
352 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
353 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
355 float add_min = theMin>0. ? -0.05 : 0.05;
356 float add_max = theMax>0. ? 0.05 : -0.05;
358 auto result = std::make_pair(theMin*(1+add_min),theMax*(1+add_max));
368 hist->SetStats(kFALSE);
369 hist->SetLineWidth(2);
370 hist->GetXaxis()->CenterTitle(
true);
371 hist->GetYaxis()->CenterTitle(
true);
372 hist->GetXaxis()->SetTitleFont(42);
373 hist->GetYaxis()->SetTitleFont(42);
374 hist->GetXaxis()->SetTitleSize(0.05);
375 hist->GetYaxis()->SetTitleSize(0.05);
376 hist->GetXaxis()->SetTitleOffset(0.9);
377 hist->GetYaxis()->SetTitleOffset(1.3);
378 hist->GetXaxis()->SetLabelFont(42);
379 hist->GetYaxis()->SetLabelFont(42);
380 hist->GetYaxis()->SetLabelSize(.05);
381 hist->GetXaxis()->SetLabelSize(.05);
389 for (
const auto &element : map){
390 int count = element.second.count;
391 double mean = count>0 ? (element.second.mean)/count : 0. ;
392 double rms = count>0 ? (element.second.rms)/count - mean*mean : 0.;
400 switch ((element.first)/1000)
416 int layer = (element.first)/10 - (element.first)/1000*100;
417 int stereo = (element.first) - (layer*10) -(element.first)/1000*1000;
419 std::cout<<
"key of the map:"<<element.first <<
" ( region: "<<
regionType(element.first).second <<
" ) " 420 << detector<<
" layer: "<<layer<<
" stereo:"<<stereo
421 <<
"| count:"<<count<<
" mean: "<<mean<<
" rms: "<<rms<<std::endl;
434 NBadComponent[
i][0][2]+= std::bitset<16>(BC.
BadApvs&0x3f).
count();
435 NBadComponent[
i][component][2]+= std::bitset<16>(BC.
BadApvs&0x3f).
count();
440 NBadComponent[
i][component][1]+= std::bitset<4>(BC.
BadFibers&0x7).
count();
444 NBadComponent[
i][0][0]++;
445 NBadComponent[
i][component][0]++;
457 std::vector<float> vstripnoise;
459 for(;rit!=erit;++rit){
460 Nstrips = (rit->iend-rit->ibegin)*8/9;
461 vstripnoise.resize(Nstrips);
462 payload->allNoises(vstripnoise,make_pair(payload->getDataVectorBegin()+rit->ibegin,payload->getDataVectorBegin()+rit->iend));
464 mean=0; rms=0; min=10000; max=0;
466 DetId detId(rit->detid);
468 for(
size_t i=0;
i<Nstrips;++
i){
469 mean+=vstripnoise[
i];
470 rms+=vstripnoise[
i]*vstripnoise[
i];
471 if(vstripnoise[
i]<min) min=vstripnoise[
i];
472 if(vstripnoise[
i]>max) max=vstripnoise[
i];
476 if((rms/Nstrips-mean*mean)>0.){
477 rms =
sqrt(rms/Nstrips-mean*mean);
484 summaryNoise.
add(detId,min);
487 summaryNoise.
add(detId,max);
490 summaryNoise.
add(detId,mean);
493 summaryNoise.
add(detId,rms);
508 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >& DetInfos = reader->
getAllData();
509 for (
const auto& det : DetInfos){
513 int nFibers = nAPVs/2;
516 NTkComponents[1]+=nFibers;
517 NTkComponents[2]+=nAPVs;
518 NTkComponents[3]+=nStrips;
523 int subDetIndex = -1;
527 component=m_trackerTopo.
tibLayer(det.first);
530 component=m_trackerTopo.
tidSide(det.first)==2?m_trackerTopo.
tidWheel(det.first):m_trackerTopo.
tidWheel(det.first)+3;
533 component=m_trackerTopo.
tobLayer(det.first);
536 component=m_trackerTopo.
tecSide(det.first)==2?m_trackerTopo.
tecWheel(det.first):m_trackerTopo.
tecWheel(det.first)+9;
539 NComponents[subDetIndex][0][0]++;
540 NComponents[subDetIndex][0][1]+=nFibers;
541 NComponents[subDetIndex][0][2]+=nAPVs;
542 NComponents[subDetIndex][0][3]+=nStrips;
544 NComponents[subDetIndex][component][0]++;
545 NComponents[subDetIndex][component][1]+=nFibers;
546 NComponents[subDetIndex][component][2]+=nAPVs;
547 NComponents[subDetIndex][component][3]+=nStrips;
560 for (
size_t i=0;
i<BC.size();++
i){
566 if (BC.at(
i).BadModule)
567 NTkBadComponent[0]++;
568 if (BC.at(
i).BadFibers)
569 NTkBadComponent[1]+= ( (BC.at(
i).BadFibers>>2)&0
x1 )+ ( (BC.at(
i).BadFibers>>1)&0x1 ) + ( (BC.at(
i).BadFibers)&0x1 );
570 if (BC.at(
i).BadApvs)
571 NTkBadComponent[2]+= ( (BC.at(
i).BadApvs>>5)&0x1 )+ ( (BC.at(
i).BadApvs>>4)&0x1 ) + ( (BC.at(
i).BadApvs>>3)&0x1 ) +
572 ( (BC.at(
i).BadApvs>>2)&0x1 )+ ( (BC.at(
i).BadApvs>>1)&0x1 ) + ( (BC.at(
i).BadApvs)&0x1 );
585 component=m_trackerTopo.
tibLayer(BC.at(
i).detid);
593 component=m_trackerTopo.
tidSide(BC.at(
i).detid)==2?m_trackerTopo.
tidWheel(BC.at(
i).detid):m_trackerTopo.
tidWheel(BC.at(
i).detid)+3;
601 component=m_trackerTopo.
tobLayer(BC.at(
i).detid);
609 component=m_trackerTopo.
tecSide(BC.at(
i).detid)==2?m_trackerTopo.
tecWheel(BC.at(
i).detid):m_trackerTopo.
tecWheel(BC.at(
i).detid)+9;
627 uint32_t detid=rp->detid;
629 int subdet=-999;
int component=-999;
634 component=m_trackerTopo.
tibLayer(detid);
640 component=m_trackerTopo.
tobLayer(detid);
649 for(
int it=0;it<sqrange.second-sqrange.first;it++){
650 unsigned int range=siStripQuality_->
decode( *(sqrange.first+it) ).
range;
651 NTkBadComponent[3]+=range;
652 NBadComponent[subdet][0][3]+=range;
653 NBadComponent[subdet][component][3]+=range;
659 edm::LogError(
"SiStripBadStrip_PayloadInspector") <<
"PROBLEM detid " << detid <<
" value " << percentage<< std::endl;
674 std::stringstream ss;
676 ss <<
"\n-----------------\nGlobal Info\n-----------------";
677 ss <<
"\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
678 ss <<
"\nTracker:\t\t"<<NTkBadComponent[0]<<
"\t"<<NTkBadComponent[1]<<
"\t"<<NTkBadComponent[2]<<
"\t"<<NTkBadComponent[3];
680 ss <<
"\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<
"\t"<<NBadComponent[0][0][1]<<
"\t"<<NBadComponent[0][0][2]<<
"\t"<<NBadComponent[0][0][3];
681 ss <<
"\nTID:\t\t\t"<<NBadComponent[1][0][0]<<
"\t"<<NBadComponent[1][0][1]<<
"\t"<<NBadComponent[1][0][2]<<
"\t"<<NBadComponent[1][0][3];
682 ss <<
"\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<
"\t"<<NBadComponent[2][0][1]<<
"\t"<<NBadComponent[2][0][2]<<
"\t"<<NBadComponent[2][0][3];
683 ss <<
"\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<
"\t"<<NBadComponent[3][0][1]<<
"\t"<<NBadComponent[3][0][2]<<
"\t"<<NBadComponent[3][0][3];
686 for (
int i=1;
i<5;++
i)
687 ss <<
"\nTIB Layer " <<
i <<
" :\t\t"<<NBadComponent[0][
i][0]<<
"\t"<<NBadComponent[0][
i][1]<<
"\t"<<NBadComponent[0][
i][2]<<
"\t"<<NBadComponent[0][
i][3];
689 for (
int i=1;
i<4;++
i)
690 ss <<
"\nTID+ Disk " <<
i <<
" :\t\t"<<NBadComponent[1][
i][0]<<
"\t"<<NBadComponent[1][
i][1]<<
"\t"<<NBadComponent[1][
i][2]<<
"\t"<<NBadComponent[1][
i][3];
691 for (
int i=4;
i<7;++
i)
692 ss <<
"\nTID- Disk " <<
i-3 <<
" :\t\t"<<NBadComponent[1][
i][0]<<
"\t"<<NBadComponent[1][
i][1]<<
"\t"<<NBadComponent[1][
i][2]<<
"\t"<<NBadComponent[1][
i][3];
694 for (
int i=1;
i<7;++
i)
695 ss <<
"\nTOB Layer " <<
i <<
" :\t\t"<<NBadComponent[2][
i][0]<<
"\t"<<NBadComponent[2][
i][1]<<
"\t"<<NBadComponent[2][
i][2]<<
"\t"<<NBadComponent[2][
i][3];
697 for (
int i=1;
i<10;++
i)
698 ss <<
"\nTEC+ Disk " <<
i <<
" :\t\t"<<NBadComponent[3][
i][0]<<
"\t"<<NBadComponent[3][
i][1]<<
"\t"<<NBadComponent[3][
i][2]<<
"\t"<<NBadComponent[3][
i][3];
699 for (
int i=10;
i<19;++
i)
700 ss <<
"\nTEC- Disk " <<
i-9 <<
" :\t\t"<<NBadComponent[3][
i][0]<<
"\t"<<NBadComponent[3][
i][1]<<
"\t"<<NBadComponent[3][
i][2]<<
"\t"<<NBadComponent[3][
i][3];
709 enum palette {
HALFGRAY,
GRAY,
BLUES,
REDS,
ANTIGRAY,
FIRE,
ANTIFIRE,
LOGREDBLUE,
BLUERED,
LOGBLUERED,
DEFAULT};
716 TStyle *palettestyle =
new TStyle(
"palettestyle",
"Style for P-TDR");
719 const int NCont = 255;
725 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
726 double red[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
727 double green[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
728 double blue[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
729 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
735 double stops[NRGBs] = {0.00, 0.01, 0.05, 0.09, 0.1};
736 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
737 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
738 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
739 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
745 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
746 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
747 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
748 double blue[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
749 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
756 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
757 double red[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
758 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
759 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
760 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
766 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
767 double red[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
768 double green[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
769 double blue[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
770 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
776 double stops[NRGBs] = {0.00, 0.20, 0.80, 1.00};
777 double red[NRGBs] = {1.00, 1.00, 1.00, 0.50};
778 double green[NRGBs] = {1.00, 1.00, 0.00, 0.00};
779 double blue[NRGBs] = {0.20, 0.00, 0.00, 0.00};
780 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
786 double stops[NRGBs] = {0.00, 0.20, 0.80, 1.00};
787 double red[NRGBs] = {0.50, 1.00, 1.00, 1.00};
788 double green[NRGBs] = {0.00, 0.00, 1.00, 1.00};
789 double blue[NRGBs] = {0.00, 0.00, 0.00, 0.20};
790 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
796 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
797 double red[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
798 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
799 double blue[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
800 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
806 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
807 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
808 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
809 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
810 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
816 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
817 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
818 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
819 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
820 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
826 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
827 double red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
828 double green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
829 double blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
830 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
834 std::cout<<
"should nevere be here" << std::endl;
838 palettestyle->SetNumberContours(NCont);
const std::vector< BadComponent > & getBadComponentList() const
unsigned int tibLayer(const DetId &id) const
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void Fill(int apv, int det, double vx)
unsigned int tidWheel(const DetId &id) const
Registry::const_iterator RegistryIterator
void setPaletteStyle(SiStripPI::palette palette)
void fillBCArrays(const SiStripQuality *siStripQuality_, int NTkBadComponent[4], int NBadComponent[4][19][4], const TrackerTopology m_trackerTopo)
void printSummary(const std::map< unsigned int, SiStripDetSummary::Values > &map)
void fillNoiseDetSummary(SiStripDetSummary &summaryNoise, std::shared_ptr< SiStripNoises > payload, SiStripPI::estimator est)
const std::map< uint32_t, DetInfo > & getAllData() const
Container::value_type value_type
RegistryIterator getRegistryVectorEnd() const
unsigned int tidSide(const DetId &id) const
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
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) ...
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
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)
std::string getStringFromSubdet(StripSubdetector::SubDetector sub)
std::string estimatorType(SiStripPI::estimator e)
std::pair< int, const char * > regionType(int index)
ContainerIterator getDataVectorBegin() const
void setBadComponents(int i, int component, const SiStripQuality::BadComponent &BC, int NBadComponent[4][19][4])
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
std::string fullPath() const
Monitor2D(OpMode mode, const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax)
unsigned int tecWheel(const DetId &id) const
data decode(const unsigned int &value) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const