40 #include "TPaveStats.h" 50 class SiPixelQualityTest :
public Histogram1D<SiPixelQuality, SINGLE_IOV> {
55 bool fill()
override {
56 auto tag = PlotBase::getTag<0>();
57 for (
auto const& iov :
tag.iovs) {
58 std::shared_ptr<SiPixelQuality>
payload = Base::fetchPayload(std::get<1>(iov));
62 auto theDisabledModules =
payload->getBadComponentList();
63 for (
const auto&
mod : theDisabledModules) {
65 for (
unsigned short n = 0;
n < 16;
n++) {
66 unsigned short mask = 1 <<
n;
70 COUT <<
"detId:" <<
mod.DetID <<
" error type:" <<
mod.errorType <<
" BadRocs:" << BadRocCount << std::endl;
82 class SiPixelQualityDebugger :
public Histogram1D<SiPixelQuality, SINGLE_IOV> {
84 SiPixelQualityDebugger()
87 bool fill()
override {
88 auto tag = PlotBase::getTag<0>();
89 for (
auto const& iov :
tag.iovs) {
90 std::shared_ptr<SiPixelQuality>
payload = Base::fetchPayload(std::get<1>(iov));
95 t_info_fromXML.
init();
97 auto theDisabledModules =
payload->getBadComponentList();
98 for (
const auto&
mod : theDisabledModules) {
101 const char* path_toTopologyXML = PhInfo.pathToTopoXML();
105 std::stringstream
ss;
107 std::bitset<16> bad_rocs(
mod.BadRocs);
109 if (t_info_fromXML.
subDetId() == 1 && t_info_fromXML.
layer() == 1) {
112 <<
" error type:" <<
mod.errorType <<
" BadRocs: " << bad_rocs.to_string(
'O',
'X') << std::endl;
125 class SiPixelQualityBadRocsSummary :
public PlotImage<SiPixelQuality, MULTI_IOV, 1> {
129 bool fill()
override {
130 auto tag = PlotBase::getTag<0>();
131 for (
const auto& iov :
tag.iovs) {
132 std::shared_ptr<SiPixelQuality>
payload = fetchPayload(std::get<1>(iov));
135 COUT <<
"======================= " << unpacked.first <<
" : " << unpacked.second << std::endl;
136 auto theDisabledModules =
payload->getBadComponentList();
137 for (
const auto&
mod : theDisabledModules) {
138 COUT <<
"detId: " <<
mod.DetID <<
" |error type: " <<
mod.errorType <<
" |BadRocs: " <<
mod.BadRocs
144 TCanvas canv(
"Partition summary",
"partition summary", 1200, 1000);
145 canv.SetBottomMargin(0.11);
146 canv.SetLeftMargin(0.13);
147 canv.SetRightMargin(0.05);
162 class SiPixelQualityBadRocsTimeHistory :
public TimeHistoryPlot<SiPixelQuality, std::pair<double, double> > {
164 SiPixelQualityBadRocsTimeHistory()
168 return std::make_pair(extractBadRocCount(
payload), 0.);
172 unsigned int BadRocCount(0);
173 auto theDisabledModules =
payload.getBadComponentList();
174 for (
const auto&
mod : theDisabledModules) {
175 for (
unsigned short n = 0;
n < 16;
n++) {
176 unsigned short mask = 1 <<
n;
188 template <SiPixelPI::DetType myType>
189 class SiPixelQualityMap :
public PlotImage<SiPixelQuality, SINGLE_IOV> {
196 bool fill()
override {
197 auto tag = PlotBase::getTag<0>();
198 auto iov =
tag.iovs.front();
200 std::shared_ptr<SiPixelQuality>
payload = fetchPayload(std::get<1>(iov));
204 auto theDisabledModules =
payload->getBadComponentList();
205 if (this->isPhase0(theDisabledModules)) {
207 <<
"SiPixelQuality maps are not supported for non-Phase1 Pixel geometries !";
208 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
215 for (
const auto&
mod : theDisabledModules) {
221 std::bitset<16> bad_rocs(
mod.BadRocs);
223 theMap.fillWholeModule(
mod.DetID, 1.);
225 theMap.fillSelectedRocs(
mod.DetID, bad_rocs, 1.);
230 gStyle->SetOptStat(0);
232 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
241 const auto headerText = fmt::sprintf(
"#color[4]{%s}, IOV: #color[4]{%s}",
tagname, IOVstring);
245 theMap.drawBarrelMaps(
canvas, headerText);
248 theMap.drawForwardMaps(
canvas, headerText);
251 theMap.drawMaps(
canvas, headerText);
254 throw cms::Exception(
"SiPixelQualityMap") <<
"\nERROR: unrecognized Pixel Detector part " << std::endl;
260 canvas.SaveAs(
"outAll.root");
267 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
271 bool isPhase0(std::vector<SiPixelQuality::disabledModuleType>
mods) {
274 const auto& p0detIds =
reader.getAllDetIds();
276 std::vector<uint32_t> ownDetIds;
279 std::back_inserter(ownDetIds),
282 for (
const auto& det : ownDetIds) {
284 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
292 using SiPixelBPixQualityMap = SiPixelQualityMap<SiPixelPI::t_barrel>;
293 using SiPixelFPixQualityMap = SiPixelQualityMap<SiPixelPI::t_forward>;
294 using SiPixelFullQualityMap = SiPixelQualityMap<SiPixelPI::t_all>;
299 template <SiPixelPI::DetType myType, IOVMultiplicity nIOVs,
int ntags>
300 class SiPixelQualityMapComparisonBase :
public PlotImage<SiPixelQuality, nIOVs, ntags> {
302 SiPixelQualityMapComparisonBase()
308 bool fill()
override {
310 auto theIOVs = PlotBase::getTag<0>().iovs;
311 auto f_tagname = PlotBase::getTag<0>().
name;
313 auto firstiov = theIOVs.front();
314 std::tuple<cond::Time_t, cond::Hash> lastiov;
317 assert(this->m_plotAnnotations.ntags < 3);
319 if (this->m_plotAnnotations.ntags == 2) {
320 auto tag2iovs = PlotBase::getTag<1>().iovs;
321 l_tagname = PlotBase::getTag<1>().
name;
322 lastiov = tag2iovs.front();
324 lastiov = theIOVs.back();
327 std::shared_ptr<SiPixelQuality> last_payload = this->fetchPayload(std::get<1>(lastiov));
328 std::shared_ptr<SiPixelQuality> first_payload = this->fetchPayload(std::get<1>(firstiov));
330 if (this->isPhase0(first_payload) || this->isPhase0(last_payload)) {
332 <<
"SiPixelQuality comparison maps are not supported for non-Phase1 Pixel geometries !";
333 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
342 gStyle->SetOptStat(0);
344 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
360 if (this->m_plotAnnotations.ntags == 2) {
361 headerText = fmt::sprintf(
362 "#Delta #color[2]{A: %s, %s} - #color[4]{B: %s, %s}", f_tagname, f_IOVstring, l_tagname, l_IOVstring);
365 fmt::sprintf(
"%s, #Delta IOV #color[2]{A: %s} - #color[4]{B: %s} ", f_tagname, f_IOVstring, l_IOVstring);
370 theMap.drawBarrelMaps(
canvas, headerText);
373 theMap.drawForwardMaps(
canvas, headerText);
376 theMap.drawMaps(
canvas, headerText);
380 <<
"\nERROR: unrecognized Pixel Detector part " << std::endl;
384 fillTheMapFromPayload(theMap, first_payload,
false);
387 fillTheMapFromPayload(theMap, last_payload,
true);
392 canvas.SaveAs(
"outAll.root");
399 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
403 bool isPhase0(
const std::shared_ptr<SiPixelQuality>&
payload) {
407 const auto& p0detIds =
reader.getAllDetIds();
409 std::vector<uint32_t> ownDetIds;
412 std::back_inserter(ownDetIds),
415 for (
const auto& det : ownDetIds) {
417 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
426 const std::shared_ptr<SiPixelQuality>&
payload,
428 const auto theDisabledModules =
payload->getBadComponentList();
429 for (
const auto&
mod : theDisabledModules) {
434 std::bitset<16> bad_rocs(
mod.BadRocs);
445 using SiPixelBPixQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_barrel, MULTI_IOV, 1>;
446 using SiPixelFPixQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_forward, MULTI_IOV, 1>;
447 using SiPixelFullQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_all, MULTI_IOV, 1>;
448 using SiPixelBPixQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_barrel, SINGLE_IOV, 2>;
449 using SiPixelFPixQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_forward, SINGLE_IOV, 2>;
450 using SiPixelFullQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_all, SINGLE_IOV, 2>;
455 class SiPixelQualityBadFractionMap :
public PlotImage<SiPixelQuality, SINGLE_IOV> {
458 label_ =
"SiPixelQualityFullPixelMap";
459 payloadString =
"Quality";
462 bool fill()
override {
463 gStyle->SetPalette(1);
464 auto tag = PlotBase::getTag<0>();
465 auto iov =
tag.iovs.front();
467 std::shared_ptr<SiPixelQuality>
payload = this->fetchPayload(std::get<1>(iov));
471 "", fmt::sprintf(
"%s", payloadString), fmt::sprintf(
"bad %s fraction [%%]", payloadString));
472 fullMap.createTrackerBaseMap();
474 auto theDisabledModules =
payload->getBadComponentList();
475 if (this->isPhase0(theDisabledModules)) {
477 <<
"SiPixelQuality maps are not supported for non-Phase1 Pixel geometries !";
478 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
485 for (
const auto&
mod : theDisabledModules) {
486 std::bitset<16> bad_rocs(
mod.BadRocs);
487 fullMap.fillTrackerMap(
mod.DetID, (bad_rocs.count() / 16.) * 100);
490 TCanvas
canvas(
"Canv",
"Canv", 3000, 2000);
491 fullMap.printTrackerMap(
canvas);
495 ltx.SetTextSize(0.025);
496 ltx.SetTextAlign(11);
497 ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
498 gPad->GetBottomMargin() + 0.01,
499 (
"#color[4]{" +
tag.name +
"}, IOV: #color[4]{" +
std::to_string(unpacked.first) +
"," +
515 bool isPhase0(std::vector<SiPixelQuality::disabledModuleType>
mods) {
518 const auto& p0detIds =
reader.getAllDetIds();
520 std::vector<uint32_t> ownDetIds;
523 std::back_inserter(ownDetIds),
526 for (
const auto& det : ownDetIds) {
528 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static std::string to_string(const XMLCh *ch)
void fillWholeModule(const uint32_t &detid, double value)
int signed_ladder(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
void printAll(std::stringstream &ss) const
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
static const unsigned int phase1size
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
#define PAYLOAD_INSPECTOR_MODULE(PAYLOAD_TYPENAME)
const std::array< std::string, 3 > DetNames
int signed_module(const DetId &detid, const TrackerTopology &tTopo_, bool phase_)
void displayNotSupported(TCanvas &canv, const unsigned int size)
void fillSelectedRocs(const uint32_t &detid, const std::bitset< 16 > &theROCs, double value)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
static constexpr char const *const kPh0DefaultFile
T mod(const T &a, const T &b)