39 #include "TPaveStats.h" 49 class SiPixelQualityTest :
public Histogram1D<SiPixelQuality, SINGLE_IOV> {
54 bool fill()
override {
55 auto tag = PlotBase::getTag<0>();
56 for (
auto const& iov :
tag.iovs) {
57 std::shared_ptr<SiPixelQuality>
payload = Base::fetchPayload(std::get<1>(iov));
61 auto theDisabledModules =
payload->getBadComponentList();
62 for (
const auto&
mod : theDisabledModules) {
64 for (
unsigned short n = 0;
n < 16;
n++) {
65 unsigned short mask = 1 <<
n;
69 COUT <<
"detId:" <<
mod.DetID <<
" error type:" <<
mod.errorType <<
" BadRocs:" << BadRocCount << std::endl;
81 class SiPixelQualityBadRocsSummary :
public PlotImage<SiPixelQuality, MULTI_IOV, 1> {
85 bool fill()
override {
86 auto tag = PlotBase::getTag<0>();
87 for (
const auto& iov :
tag.iovs) {
88 std::shared_ptr<SiPixelQuality>
payload = fetchPayload(std::get<1>(iov));
91 COUT <<
"======================= " << unpacked.first <<
" : " << unpacked.second << std::endl;
92 auto theDisabledModules =
payload->getBadComponentList();
93 for (
const auto&
mod : theDisabledModules) {
94 COUT <<
"detId: " <<
mod.DetID <<
" |error type: " <<
mod.errorType <<
" |BadRocs: " <<
mod.BadRocs
100 TCanvas canv(
"Partition summary",
"partition summary", 1200, 1000);
101 canv.SetBottomMargin(0.11);
102 canv.SetLeftMargin(0.13);
103 canv.SetRightMargin(0.05);
118 class SiPixelQualityBadRocsTimeHistory :
public TimeHistoryPlot<SiPixelQuality, std::pair<double, double> > {
120 SiPixelQualityBadRocsTimeHistory()
124 return std::make_pair(extractBadRocCount(
payload), 0.);
128 unsigned int BadRocCount(0);
129 auto theDisabledModules =
payload.getBadComponentList();
130 for (
const auto&
mod : theDisabledModules) {
131 for (
unsigned short n = 0;
n < 16;
n++) {
132 unsigned short mask = 1 <<
n;
144 template <SiPixelPI::DetType myType>
145 class SiPixelQualityMap :
public PlotImage<SiPixelQuality, SINGLE_IOV> {
152 bool fill()
override {
153 auto tag = PlotBase::getTag<0>();
154 auto iov =
tag.iovs.front();
156 std::shared_ptr<SiPixelQuality>
payload = fetchPayload(std::get<1>(iov));
160 auto theDisabledModules =
payload->getBadComponentList();
161 if (this->isPhase0(theDisabledModules)) {
163 <<
"SiPixelQuality maps are not supported for non-Phase1 Pixel geometries !";
164 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
171 for (
const auto&
mod : theDisabledModules) {
177 std::bitset<16> bad_rocs(
mod.BadRocs);
179 theMap.fillWholeModule(
mod.DetID, 1.);
181 theMap.fillSelectedRocs(
mod.DetID, bad_rocs, 1.);
186 gStyle->SetOptStat(0);
188 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
197 const auto headerText = fmt::sprintf(
"#color[4]{%s}, IOV: #color[4]{%s}",
tagname, IOVstring);
201 theMap.drawBarrelMaps(
canvas, headerText);
204 theMap.drawForwardMaps(
canvas, headerText);
207 theMap.drawMaps(
canvas, headerText);
210 throw cms::Exception(
"SiPixelQualityMap") <<
"\nERROR: unrecognized Pixel Detector part " << std::endl;
216 canvas.SaveAs(
"outAll.root");
223 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
227 bool isPhase0(std::vector<SiPixelQuality::disabledModuleType>
mods) {
230 const auto& p0detIds =
reader.getAllDetIds();
232 std::vector<uint32_t> ownDetIds;
235 std::back_inserter(ownDetIds),
238 for (
const auto& det : ownDetIds) {
240 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
248 using SiPixelBPixQualityMap = SiPixelQualityMap<SiPixelPI::t_barrel>;
249 using SiPixelFPixQualityMap = SiPixelQualityMap<SiPixelPI::t_forward>;
250 using SiPixelFullQualityMap = SiPixelQualityMap<SiPixelPI::t_all>;
255 template <SiPixelPI::DetType myType, IOVMultiplicity nIOVs,
int ntags>
256 class SiPixelQualityMapComparisonBase :
public PlotImage<SiPixelQuality, nIOVs, ntags> {
258 SiPixelQualityMapComparisonBase()
264 bool fill()
override {
266 auto theIOVs = PlotBase::getTag<0>().iovs;
267 auto f_tagname = PlotBase::getTag<0>().
name;
269 auto firstiov = theIOVs.front();
270 std::tuple<cond::Time_t, cond::Hash> lastiov;
273 assert(this->m_plotAnnotations.ntags < 3);
275 if (this->m_plotAnnotations.ntags == 2) {
276 auto tag2iovs = PlotBase::getTag<1>().iovs;
277 l_tagname = PlotBase::getTag<1>().
name;
278 lastiov = tag2iovs.front();
280 lastiov = theIOVs.back();
283 std::shared_ptr<SiPixelQuality> last_payload = this->fetchPayload(std::get<1>(lastiov));
284 std::shared_ptr<SiPixelQuality> first_payload = this->fetchPayload(std::get<1>(firstiov));
286 if (this->isPhase0(first_payload) || this->isPhase0(last_payload)) {
288 <<
"SiPixelQuality comparison maps are not supported for non-Phase1 Pixel geometries !";
289 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
298 gStyle->SetOptStat(0);
300 TCanvas
canvas(
"Summary",
"Summary", 1200, k_height[myType]);
316 if (this->m_plotAnnotations.ntags == 2) {
317 headerText = fmt::sprintf(
318 "#Delta #color[2]{A: %s, %s} - #color[4]{B: %s, %s}", f_tagname, f_IOVstring, l_tagname, l_IOVstring);
321 fmt::sprintf(
"%s, #Delta IOV #color[2]{A: %s} - #color[4]{B: %s} ", f_tagname, f_IOVstring, l_IOVstring);
326 theMap.drawBarrelMaps(
canvas, headerText);
329 theMap.drawForwardMaps(
canvas, headerText);
332 theMap.drawMaps(
canvas, headerText);
336 <<
"\nERROR: unrecognized Pixel Detector part " << std::endl;
340 fillTheMapFromPayload(theMap, first_payload,
false);
343 fillTheMapFromPayload(theMap, last_payload,
true);
348 canvas.SaveAs(
"outAll.root");
355 static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
359 bool isPhase0(
const std::shared_ptr<SiPixelQuality>&
payload) {
363 const auto& p0detIds =
reader.getAllDetIds();
365 std::vector<uint32_t> ownDetIds;
368 std::back_inserter(ownDetIds),
371 for (
const auto& det : ownDetIds) {
373 if (
std::find(p0detIds.begin(), p0detIds.end(), det) != p0detIds.end()) {
382 const std::shared_ptr<SiPixelQuality>&
payload,
384 const auto theDisabledModules =
payload->getBadComponentList();
385 for (
const auto&
mod : theDisabledModules) {
390 std::bitset<16> bad_rocs(
mod.BadRocs);
401 using SiPixelBPixQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_barrel, MULTI_IOV, 1>;
402 using SiPixelFPixQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_forward, MULTI_IOV, 1>;
403 using SiPixelFullQualityMapCompareSingleTag = SiPixelQualityMapComparisonBase<SiPixelPI::t_all, MULTI_IOV, 1>;
404 using SiPixelBPixQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_barrel, SINGLE_IOV, 2>;
405 using SiPixelFPixQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_forward, SINGLE_IOV, 2>;
406 using SiPixelFullQualityMapCompareTwoTags = SiPixelQualityMapComparisonBase<SiPixelPI::t_all, SINGLE_IOV, 2>;
std::string to_string(const V &value)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void fillWholeModule(const uint32_t &detid, double value)
#define PAYLOAD_INSPECTOR_CLASS(CLASS_NAME)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
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
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)