1 #ifndef CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_SISTRIPPLUGINS_SISTRIPPAYLOADINSPECTORHELPER_H 40 default:
return "should never be here";
53 default :
return "should never be here";
88 auto region =
static_cast<std::underlying_type_t<SiStripPI::TrackerRegion>
>(
index);
130 default :
return std::make_pair(999,
"should never be here");
138 float sum = std::accumulate(
std::begin(values),
142 {
return value + p.second; }
145 float m = sum / values.size();
151 {accum += (p.second -
m) * (p.second - m);}
154 float stdev =
sqrt(accum / (values.size()-1));
157 return std::make_pair(m-nsigma*stdev,m+nsigma*stdev);
159 return std::make_pair(m>0.? 0.95*m : 1.05*m, m>0? 1.05*m : 0.95*m);
170 for (
const auto &element : legend ){
171 TPaveText*
stat =
new TPaveText(
X,
Y-(i*
H),
X+W,
Y-(i+1)*H,
"NDC");
173 auto Histo =
histos[element];
174 sprintf(buffer,
"Entries : %i\n",(
int)Histo->GetEntries());
175 stat->AddText(buffer);
177 sprintf(buffer,
"Mean : %6.2f\n",Histo->GetMean());
178 stat->AddText(buffer);
180 sprintf(buffer,
"RMS : %6.2f\n",Histo->GetRMS());
181 stat->AddText(buffer);
183 stat->SetFillColor(0);
184 stat->SetLineColor(colormap[element]);
185 stat->SetTextColor(colormap[element]);
186 stat->SetTextSize(0.03);
187 stat->SetBorderSize(0);
188 stat->SetMargin(0.05);
189 stat->SetTextAlign(12);
198 float theMax(-9999.);
200 theMax = h1->GetMaximum() > h2->GetMaximum() ? h1->GetMaximum() : h2->GetMaximum();
201 theMin = h1->GetMinimum() < h2->GetMaximum() ? h1->GetMinimum() : h2->GetMinimum();
203 float add_min = theMin>0. ? -0.05 : 0.05;
204 float add_max = theMax>0. ? 0.05 : -0.05;
206 auto result = std::make_pair(theMin*(1+add_min),theMax*(1+add_max));
216 hist->SetStats(kFALSE);
217 hist->SetLineWidth(2);
218 hist->GetXaxis()->CenterTitle(
true);
219 hist->GetYaxis()->CenterTitle(
true);
220 hist->GetXaxis()->SetTitleFont(42);
221 hist->GetYaxis()->SetTitleFont(42);
222 hist->GetXaxis()->SetTitleSize(0.05);
223 hist->GetYaxis()->SetTitleSize(0.05);
224 hist->GetXaxis()->SetTitleOffset(0.9);
225 hist->GetYaxis()->SetTitleOffset(1.3);
226 hist->GetXaxis()->SetLabelFont(42);
227 hist->GetYaxis()->SetLabelFont(42);
228 hist->GetYaxis()->SetLabelSize(.05);
229 hist->GetXaxis()->SetLabelSize(.05);
237 for (
const auto &element : map){
238 int count = element.second.count;
239 double mean = count>0 ? (element.second.mean)/count : 0. ;
240 double rms = count>0 ? (element.second.rms)/count - mean*mean : 0.;
248 switch ((element.first)/1000)
264 int layer = (element.first)/10 - (element.first)/1000*100;
265 int stereo = (element.first) - (layer*10) -(element.first)/1000*1000;
267 std::cout<<
"key of the map:"<<element.first <<
" ( region: "<<
regionType(element.first).second <<
" ) " 268 << detector<<
" layer: "<<layer<<
" stereo:"<<stereo
269 <<
"| count:"<<count<<
" mean: "<<mean<<
" rms: "<<rms<<std::endl;
282 NBadComponent[
i][0][2]+= std::bitset<16>(BC.
BadApvs&0x3f).
count();
283 NBadComponent[
i][component][2]+= std::bitset<16>(BC.
BadApvs&0x3f).
count();
288 NBadComponent[
i][component][1]+= std::bitset<4>(BC.
BadFibers&0x7).
count();
292 NBadComponent[
i][0][0]++;
293 NBadComponent[
i][component][0]++;
305 std::vector<float> vstripnoise;
307 for(;rit!=erit;++rit){
308 Nstrips = (rit->iend-rit->ibegin)*8/9;
309 vstripnoise.resize(Nstrips);
310 payload->allNoises(vstripnoise,make_pair(payload->getDataVectorBegin()+rit->ibegin,payload->getDataVectorBegin()+rit->iend));
312 mean=0; rms=0; min=10000; max=0;
314 DetId detId(rit->detid);
316 for(
size_t i=0;
i<Nstrips;++
i){
317 mean+=vstripnoise[
i];
318 rms+=vstripnoise[
i]*vstripnoise[
i];
319 if(vstripnoise[
i]<min) min=vstripnoise[
i];
320 if(vstripnoise[
i]>max) max=vstripnoise[
i];
324 if((rms/Nstrips-mean*mean)>0.){
325 rms =
sqrt(rms/Nstrips-mean*mean);
332 summaryNoise.
add(detId,min);
335 summaryNoise.
add(detId,max);
338 summaryNoise.
add(detId,mean);
341 summaryNoise.
add(detId,rms);
356 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >& DetInfos = reader->
getAllData();
357 for (
const auto& det : DetInfos){
361 int nFibers = nAPVs/2;
364 NTkComponents[1]+=nFibers;
365 NTkComponents[2]+=nAPVs;
366 NTkComponents[3]+=nStrips;
371 int subDetIndex = -1;
375 component=m_trackerTopo.
tibLayer(det.first);
378 component=m_trackerTopo.
tidSide(det.first)==2?m_trackerTopo.
tidWheel(det.first):m_trackerTopo.
tidWheel(det.first)+3;
381 component=m_trackerTopo.
tobLayer(det.first);
384 component=m_trackerTopo.
tecSide(det.first)==2?m_trackerTopo.
tecWheel(det.first):m_trackerTopo.
tecWheel(det.first)+9;
387 NComponents[subDetIndex][0][0]++;
388 NComponents[subDetIndex][0][1]+=nFibers;
389 NComponents[subDetIndex][0][2]+=nAPVs;
390 NComponents[subDetIndex][0][3]+=nStrips;
392 NComponents[subDetIndex][component][0]++;
393 NComponents[subDetIndex][component][1]+=nFibers;
394 NComponents[subDetIndex][component][2]+=nAPVs;
395 NComponents[subDetIndex][component][3]+=nStrips;
408 for (
size_t i=0;
i<BC.size();++
i){
414 if (BC.at(
i).BadModule)
415 NTkBadComponent[0]++;
416 if (BC.at(
i).BadFibers)
417 NTkBadComponent[1]+= ( (BC.at(
i).BadFibers>>2)&0
x1 )+ ( (BC.at(
i).BadFibers>>1)&0x1 ) + ( (BC.at(
i).BadFibers)&0x1 );
418 if (BC.at(
i).BadApvs)
419 NTkBadComponent[2]+= ( (BC.at(
i).BadApvs>>5)&0x1 )+ ( (BC.at(
i).BadApvs>>4)&0x1 ) + ( (BC.at(
i).BadApvs>>3)&0x1 ) +
420 ( (BC.at(
i).BadApvs>>2)&0x1 )+ ( (BC.at(
i).BadApvs>>1)&0x1 ) + ( (BC.at(
i).BadApvs)&0x1 );
433 component=m_trackerTopo.
tibLayer(BC.at(
i).detid);
441 component=m_trackerTopo.
tidSide(BC.at(
i).detid)==2?m_trackerTopo.
tidWheel(BC.at(
i).detid):m_trackerTopo.
tidWheel(BC.at(
i).detid)+3;
449 component=m_trackerTopo.
tobLayer(BC.at(
i).detid);
457 component=m_trackerTopo.
tecSide(BC.at(
i).detid)==2?m_trackerTopo.
tecWheel(BC.at(
i).detid):m_trackerTopo.
tecWheel(BC.at(
i).detid)+9;
475 uint32_t detid=rp->detid;
477 int subdet=-999;
int component=-999;
482 component=m_trackerTopo.
tibLayer(detid);
488 component=m_trackerTopo.
tobLayer(detid);
497 for(
int it=0;it<sqrange.second-sqrange.first;it++){
498 unsigned int range=siStripQuality_->
decode( *(sqrange.first+it) ).
range;
499 NTkBadComponent[3]+=range;
500 NBadComponent[subdet][0][3]+=range;
501 NBadComponent[subdet][component][3]+=range;
507 edm::LogError(
"SiStripBadStrip_PayloadInspector") <<
"PROBLEM detid " << detid <<
" value " << percentage<< std::endl;
522 std::stringstream ss;
524 ss <<
"\n-----------------\nGlobal Info\n-----------------";
525 ss <<
"\nBadComponent \t Modules \tFibers \tApvs\tStrips\n----------------------------------------------------------------";
526 ss <<
"\nTracker:\t\t"<<NTkBadComponent[0]<<
"\t"<<NTkBadComponent[1]<<
"\t"<<NTkBadComponent[2]<<
"\t"<<NTkBadComponent[3];
528 ss <<
"\nTIB:\t\t\t"<<NBadComponent[0][0][0]<<
"\t"<<NBadComponent[0][0][1]<<
"\t"<<NBadComponent[0][0][2]<<
"\t"<<NBadComponent[0][0][3];
529 ss <<
"\nTID:\t\t\t"<<NBadComponent[1][0][0]<<
"\t"<<NBadComponent[1][0][1]<<
"\t"<<NBadComponent[1][0][2]<<
"\t"<<NBadComponent[1][0][3];
530 ss <<
"\nTOB:\t\t\t"<<NBadComponent[2][0][0]<<
"\t"<<NBadComponent[2][0][1]<<
"\t"<<NBadComponent[2][0][2]<<
"\t"<<NBadComponent[2][0][3];
531 ss <<
"\nTEC:\t\t\t"<<NBadComponent[3][0][0]<<
"\t"<<NBadComponent[3][0][1]<<
"\t"<<NBadComponent[3][0][2]<<
"\t"<<NBadComponent[3][0][3];
534 for (
int i=1;
i<5;++
i)
535 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];
537 for (
int i=1;
i<4;++
i)
538 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];
539 for (
int i=4;
i<7;++
i)
540 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];
542 for (
int i=1;
i<7;++
i)
543 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];
545 for (
int i=1;
i<10;++
i)
546 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];
547 for (
int i=10;
i<19;++
i)
548 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];
557 enum palette {
HALFGRAY,
GRAY,
BLUES,
REDS,
ANTIGRAY,
FIRE,
ANTIFIRE,
LOGREDBLUE,
BLUERED,
LOGBLUERED,
DEFAULT};
564 TStyle *palettestyle =
new TStyle(
"palettestyle",
"Style for P-TDR");
567 const int NCont = 255;
573 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
574 double red[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
575 double green[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
576 double blue[NRGBs] = {1.00, 0.91, 0.80, 0.67, 1.00};
577 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
583 double stops[NRGBs] = {0.00, 0.01, 0.05, 0.09, 0.1};
584 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
585 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
586 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
587 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
593 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
594 double red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
595 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
596 double blue[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
597 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
604 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
605 double red[NRGBs] = {1.00, 1.00, 1.00, 1.00, 1.00};
606 double green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
607 double blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
608 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
614 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
615 double red[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
616 double green[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
617 double blue[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
618 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
624 double stops[NRGBs] = {0.00, 0.20, 0.80, 1.00};
625 double red[NRGBs] = {1.00, 1.00, 1.00, 0.50};
626 double green[NRGBs] = {1.00, 1.00, 0.00, 0.00};
627 double blue[NRGBs] = {0.20, 0.00, 0.00, 0.00};
628 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
634 double stops[NRGBs] = {0.00, 0.20, 0.80, 1.00};
635 double red[NRGBs] = {0.50, 1.00, 1.00, 1.00};
636 double green[NRGBs] = {0.00, 0.00, 1.00, 1.00};
637 double blue[NRGBs] = {0.00, 0.00, 0.00, 0.20};
638 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
644 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
645 double red[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
646 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
647 double blue[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
648 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
654 double stops[NRGBs] = {0.0001, 0.0010, 0.0100, 0.1000, 1.0000};
655 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
656 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
657 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
658 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
664 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
665 double red[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
666 double green[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
667 double blue[NRGBs] = {1.00, 0.75, 0.50, 0.25, 0.00};
668 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
674 double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
675 double red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
676 double green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
677 double blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
678 TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
682 std::cout<<
"should nevere be here" << std::endl;
686 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
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 printBCDebug(int NTkBadComponent[4], int NBadComponent[4][19][4])
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)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
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])
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
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