1 #ifndef CONDCORE_SIPIXELPLUGINS_SIPIXELTEMPLATEHELPER_H 2 #define CONDCORE_SIPIXELPLUGINS_SIPIXELTEMPLATEHELPER_H 15 #include <type_traits> 18 #include <fmt/printf.h> 19 #include <boost/range/adaptor/indexed.hpp> 30 #include "TPaveStats.h" 38 template <
class PayloadType,
class StoreType,
class TransientType>
44 "Table of SiPixelTemplate/GenError titles") {
45 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
47 label_ =
"SiPixelGenErrorDBObject_PayloadInspector";
50 label_ =
"SiPixelTemplateDBObject_PayloadInspector";
55 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
56 auto iov =
tag.iovs.front();
58 std::vector<StoreType> thePixelTemp_;
64 if (!TransientType::pushfile(*
payload, thePixelTemp_)) {
66 <<
" not filled correctly." 67 <<
" Check the conditions. Using " 68 << (
isTemplate_ ?
"SiPixelTemplateDBObject" :
"SiPixelGenErrorDBObject")
69 <<
" version " <<
payload->version() <<
"\n\n";
72 unsigned int mapsize = thePixelTemp_.size();
73 float pitch = 1. / (mapsize * 1.1);
76 std::vector<float> y_x1, y_x2, y_line;
77 std::vector<std::string> s_x1, s_x2, s_x3;
87 s_x1.push_back(Form(
"#scale[1.2]{%s}", (
isTemplate_ ?
"Template ID" :
"GenError ID")));
89 s_x2.push_back(Form(
"#scale[1.2]{#color[4]{%s} in IOV: #color[4]{%s}}",
tagname.c_str(), IOVsince.c_str()));
94 for (
const auto& element : thePixelTemp_) {
100 s_x2.push_back(Form(
"#color[2]{%s}", element.head.title));
102 y_line.push_back(y - (pitch / 2.));
105 const auto& c_title = fmt::sprintf(
"%s titles", (
isTemplate_ ?
"Template" :
"GenError"));
106 TCanvas
canvas(c_title.c_str(), c_title.c_str(), 2000,
std::max(y_x1.size(), y_x2.size()) * 40);
111 float newpitch = 1 / (
std::max(y_x1.size(), y_x2.size()) * 1.1);
112 float factor = newpitch / pitch;
113 l.SetTextSize(newpitch - 0.002);
115 for (
unsigned int i = 0;
i < y_x1.size();
i++) {
116 l.DrawLatexNDC(x1, 1 - (1 - y_x1[
i]) *
factor, s_x1[
i].c_str());
119 for (
unsigned int i = 0;
i < y_x2.size();
i++) {
120 l.DrawLatexNDC(x2, 1 - (1 - y_x2[
i]) *
factor, s_x2[
i].c_str());
126 TLine
lines[y_line.size()];
128 for (
const auto&
line : y_line) {
130 lines[iL].SetLineWidth(1);
131 lines[iL].SetLineStyle(9);
132 lines[iL].SetLineColor(2);
133 lines[iL].Draw(
"same");
152 template <
class PayloadType,
class StoreType,
class TransientType>
157 "SiPixel CPE Conditions Header summary") {
158 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
160 label_ =
"SiPixelGenErrorDBObject_PayloadInspector";
163 label_ =
"SiPixelTemplateDBObject_PayloadInspector";
168 gStyle->SetHistMinimumZero();
169 gStyle->SetPalette(kMint);
171 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
172 auto iov =
tag.iovs.front();
174 std::vector<StoreType> thePixelTemp_;
178 if (!TransientType::pushfile(*
payload, thePixelTemp_)) {
180 <<
" not filled correctly." 181 <<
" Check the conditions. Using " 182 << (
isTemplate_ ?
"SiPixelTemplateDBObject" :
"SiPixelGenErrorDBObject")
183 <<
payload->version() <<
"\n\n";
187 TransientType templ(thePixelTemp_);
188 TCanvas
canvas(
"Header Summary",
"Header summary", 1400, 1000);
191 unsigned int tempSize = thePixelTemp_.size();
193 canvas.SetTopMargin(0.07);
194 canvas.SetBottomMargin(0.06);
195 canvas.SetLeftMargin(0.17);
196 canvas.SetRightMargin(0.03);
200 auto h2_Header = std::make_unique<TH2F>(
"Header",
";;", tempSize, 0, tempSize, 12, 0., 12.);
201 auto h2_ghost = std::make_unique<TH2F>(
"ghost",
";;", tempSize, 0, tempSize, 12, 0., 12.);
202 h2_Header->SetStats(
false);
203 h2_ghost->SetStats(
false);
205 int tempVersion = -999;
207 for (
const auto& theTemp : thePixelTemp_ | boost::adaptors::indexed(1)) {
208 auto tempValue = theTemp.value();
209 auto idx = theTemp.index();
211 if (tempValue.head.Bfield != 0.) {
212 uH =
roundoff(tempValue.head.lorxwidth / tempValue.head.zsize / tempValue.head.Bfield, 4);
216 h2_Header->SetBinContent(
idx, 12, tempValue.head.ID);
217 h2_Header->SetBinContent(
idx, 11, tempValue.head.Bfield);
218 h2_Header->SetBinContent(
idx, 10, uH);
219 h2_Header->SetBinContent(
idx, 9, tempValue.head.xsize);
220 h2_Header->SetBinContent(
idx, 8, tempValue.head.ysize);
221 h2_Header->SetBinContent(
idx, 7, tempValue.head.zsize);
222 h2_Header->SetBinContent(
idx, 6, tempValue.head.NTy);
223 h2_Header->SetBinContent(
idx, 5, tempValue.head.NTyx);
224 h2_Header->SetBinContent(
idx, 4, tempValue.head.NTxx);
225 h2_Header->SetBinContent(
idx, 3, tempValue.head.Dtype);
226 h2_Header->SetBinContent(
idx, 2, tempValue.head.qscale);
227 h2_Header->SetBinContent(
idx, 1, tempValue.head.Vbias);
230 h2_Header->GetYaxis()->SetBinLabel(12, (
isTemplate_ ?
"TemplateID" :
"GenErrorID"));
231 h2_Header->GetYaxis()->SetBinLabel(11,
"B-field [T]");
232 h2_Header->GetYaxis()->SetBinLabel(10,
"#mu_{H} [1/T]");
233 h2_Header->GetYaxis()->SetBinLabel(9,
"x-size [#mum]");
234 h2_Header->GetYaxis()->SetBinLabel(8,
"y-size [#mum]");
235 h2_Header->GetYaxis()->SetBinLabel(7,
"z-size [#mum]");
236 h2_Header->GetYaxis()->SetBinLabel(6,
"NTy");
237 h2_Header->GetYaxis()->SetBinLabel(5,
"NTyx");
238 h2_Header->GetYaxis()->SetBinLabel(4,
"NTxx");
239 h2_Header->GetYaxis()->SetBinLabel(3,
"DetectorType");
240 h2_Header->GetYaxis()->SetBinLabel(2,
"qScale");
241 h2_Header->GetYaxis()->SetBinLabel(1,
"VBias [V]");
242 h2_Header->GetXaxis()->SetBinLabel(
idx,
"");
244 for (
unsigned int iy = 1; iy <= 12; iy++) {
248 if (tempValue.head.Dtype != 0 || (uH < 0 && uH > -99)) {
249 h2_ghost->SetBinContent(
idx, iy, 1);
251 h2_ghost->SetBinContent(
idx, iy, -1);
253 h2_ghost->GetYaxis()->SetBinLabel(iy, h2_Header->GetYaxis()->GetBinLabel(iy));
254 h2_ghost->GetXaxis()->SetBinLabel(
idx,
"");
257 if (tempValue.head.templ_version != tempVersion) {
258 tempVersion = tempValue.head.templ_version;
262 h2_Header->GetXaxis()->LabelsOption(
"h");
263 h2_Header->GetXaxis()->SetNdivisions(500 + tempSize,
false);
264 h2_Header->GetYaxis()->SetLabelSize(0.05);
265 h2_Header->SetMarkerSize(1.5);
267 h2_ghost->GetXaxis()->LabelsOption(
"h");
268 h2_ghost->GetXaxis()->SetNdivisions(500 + tempSize,
false);
269 h2_ghost->GetYaxis()->SetLabelSize(0.05);
272 h2_ghost->Draw(
"col");
273 h2_Header->Draw(
"TEXTsame");
275 TPaveText ksPt(0, 0, 0.88, 0.04,
"NDC");
276 ksPt.SetBorderSize(0);
277 ksPt.SetFillColor(0);
278 const char* textToAdd = Form(
"%s Version: #color[2]{%i}. Payload hash: #color[2]{%s}",
281 (std::get<1>(iov)).c_str());
282 ksPt.AddText(textToAdd);
287 ltx.SetTextSize(0.040);
288 ltx.SetTextAlign(11);
290 gPad->GetLeftMargin(),
291 1 - gPad->GetTopMargin() + 0.01,
301 float pow_10 =
pow(10.0
f, (
float)prec);
302 return round(
value * pow_10) / pow_10;
313 template <
class PayloadType, SiPixelPI::DetType myType>
318 "SiPixelMap of Template / GenError ID Values") {
319 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
321 label_ =
"SiPixelGenErrorDBObject_PayloadInspector";
324 label_ =
"SiPixelTemplateDBObject_PayloadInspector";
329 gStyle->SetPalette(kRainBow);
331 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
332 auto iov =
tag.iovs.front();
350 std::map<unsigned int, short> templMap;
351 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
352 templMap =
payload->getGenErrorIDs();
354 templMap =
payload->getTemplateIDs();
359 <<
"There are " << templMap.size()
360 <<
" DetIds in this payload. SiPixelIDs maps are not supported for non-Phase1 Pixel geometries !";
361 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
369 <<
" DetIds in this payload !" 370 <<
"\n **************************** \n";
382 for (
auto const&
entry : templMap) {
383 COUT <<
"DetID: " <<
entry.first << fmt::sprintf(
"%s ID ", (
isTemplate_ ?
"Template" :
"GenError"))
384 <<
entry.second << std::endl;
418 template <
class PayloadType,
class StoreType,
class TransientType>
424 "SiPixel CPE conditions Map of IDs") {
425 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
427 label_ =
"SiPixelGenErrorDBObject_PayloadInspector";
430 label_ =
"SiPixelTemplateDBObject_PayloadInspector";
435 gStyle->SetPalette(1);
436 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
437 auto iov =
tag.iovs.front();
438 std::vector<StoreType> thePixelTemp_;
444 if (!TransientType::pushfile(*
payload, thePixelTemp_)) {
446 <<
" not filled correctly. Check the conditions. Using " 447 << (
isTemplate_ ?
"SiPixelTemplateDBObject" :
"SiPixelGenErrorDBObject")
448 <<
payload->version() <<
"\n\n";
451 Phase1PixelSummaryMap fullMap(
"", fmt::sprintf(
"%s IDs", payloadString), fmt::sprintf(
"%s ID", payloadString));
454 std::map<unsigned int, short> templMap;
455 if constexpr (std::is_same_v<PayloadType, SiPixelGenErrorDBObject>) {
456 templMap =
payload->getGenErrorIDs();
458 templMap =
payload->getTemplateIDs();
461 for (
const auto&
entry : templMap) {
467 <<
"There are " << templMap.size()
468 <<
" DetIds in this payload. SiPixelIDs maps are not supported for non-Phase1 Pixel geometries !";
469 TCanvas
canvas(
"Canv",
"Canv", 1200, 1000);
477 <<
" DetIds in this payload !" 478 <<
"\n **************************** \n";
482 TCanvas
canvas(
"Canv",
"Canv", 3000, 2000);
489 ltx.SetTextSize(0.025);
490 ltx.SetTextAlign(11);
492 gPad->GetLeftMargin() + 0.01,
493 gPad->GetBottomMargin() + 0.01,
494 (
"#color[4]{" +
tag.name +
"}, IOV: #color[4]{" +
std::to_string(std::get<0>(iov)) +
"}").c_str());
std::string m_imageFileName
void drawForwardMaps(const std::string ¤tHistoName, TCanvas &canvas, const char *drawOption=nullptr)
PlotImage(const std::string &title)
void createTrackerBaseMap()
static const unsigned int phase0size
std::string to_string(const V &value)
Log< level::Error, false > LogError
void fillForwardBin(const std::string ¤tHistoName, unsigned int id, double value)
void drawBarrelMaps(const std::string ¤tHistoName, TCanvas &canvas, const char *drawOption=nullptr)
static const unsigned int phase1size
void beautifyAllHistograms()
void bookBarrelHistograms(const std::string ¤tHistoName, const char *what, const char *zaxis)
void displayNotSupported(TCanvas &canv, const unsigned int size)
void printTrackerMap(TCanvas &canvas, const float topMargin=0.02, int index=0)
void bookForwardHistograms(const std::string ¤tHistoName, const char *what, const char *zaxis)
void fillBarrelBin(const std::string ¤tHistoName, unsigned int id, double value)
bool fillTrackerMap(unsigned int id, double value)
Log< level::Warning, false > LogWarning
Power< A, B >::type pow(const A &a, const B &b)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)