1 #ifndef CONDCORE_PCLCONFIGPLUGINS_SIPIXELALIPCLTHRESHOLDSPAYLOADINSPECTORHELPER_H 2 #define CONDCORE_PCLCONFIGPLUGINS_SIPIXELALIPCLTHRESHOLDSPAYLOADINSPECTORHELPER_H 16 #include <fmt/printf.h> 46 return "should never be here";
56 return "#Delta/#sigma ";
62 return "fraction cut ";
64 return "should never be here";
75 while ((start_pos =
out.find(from, start_pos)) != std::string::npos) {
76 out.replace(start_pos, from.length(),
to);
77 start_pos +=
to.length();
85 template <
class PayloadType>
91 "Display of threshold parameters for SiPixelAli PCL") {
92 if constexpr (std::is_same_v<PayloadType, AlignPCLThresholdsHG>) {
94 label_ =
"AlignPCLThresholdsHG_PayloadInspector";
97 label_ =
"AlignPCLThresholds_PayloadInspector";
103 gStyle->SetHistMinimumZero(kTRUE);
105 auto tag = cond::payloadInspector::PlotBase::getTag<0>();
106 auto iov =
tag.iovs.front();
108 auto alignables =
payload->getAlignableList();
110 TCanvas
canvas(
"Alignment PCL thresholds summary",
"Alignment PCL thresholds summary", 1500, 800);
113 canvas.SetTopMargin(0.07);
115 canvas.SetLeftMargin(0.11);
116 canvas.SetRightMargin(0.05);
125 std::make_unique<TH2F>(
"Thresholds",
"", alignables.size(), 0, alignables.size(), N_Y_BINS, 0, N_Y_BINS);
129 std::function<float(types, std::string, AlignPCLThresholds::coordType)> cutFunctor =
134 return payload->getCut(alignable, coord);
136 return payload->getSigCut(alignable, coord);
138 return payload->getMaxMoveCut(alignable, coord);
140 return payload->getMaxErrorCut(alignable, coord);
142 if constexpr (std::is_same_v<PayloadType, AlignPCLThresholdsHG>) {
144 if (floatMap.find(alignable) != floatMap.end()) {
145 return payload->getFractionCut(alignable, coord);
160 unsigned int xBin = 0;
161 for (
const auto& alignable : alignables) {
165 unsigned int yBin = N_Y_BINS;
168 for (
int bar =
DELTA; bar != local_end_of_types; bar++) {
188 ltx.SetTextSize(0.047);
189 ltx.SetTextAlign(11);
191 fmt::sprintf(
"#color[4]{%s} IOV: #color[4]{%s}",
tag.name,
std::to_string(std::get<0>(iov)));
192 ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, ltxText.c_str());
208 template <
class PayloadType, cond::payloadInspector::IOVMultiplicity nIOVs,
int ntags>
212 :
cond::payloadInspector::
PlotImage<PayloadType, nIOVs,
ntags>(
"Table of AlignPCLThresholdsHG comparison") {
213 if constexpr (std::is_same_v<PayloadType, AlignPCLThresholdsHG>) {
215 label_ =
"AlignPCLThresholdsHG_PayloadInspector";
218 label_ =
"AlignPCLThresholds_PayloadInspector";
223 gStyle->SetPalette(kTemperatureMap);
226 gStyle->SetHistMinimumZero(kTRUE);
229 auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().
iovs;
230 auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().
name;
232 auto firstiov = theIOVs.front();
233 std::tuple<cond::Time_t, cond::Hash> lastiov;
239 auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().
iovs;
240 l_tagname = cond::payloadInspector::PlotBase::getTag<1>().
name;
241 lastiov = tag2iovs.front();
243 lastiov = theIOVs.back();
246 std::shared_ptr<PayloadType> l_payload = this->
fetchPayload(std::get<1>(lastiov));
247 std::shared_ptr<PayloadType> f_payload = this->
fetchPayload(std::get<1>(firstiov));
252 const auto& alignables = l_payload->getAlignableList();
253 const auto& alignables2 = f_payload->getAlignableList();
255 std::vector<std::string> v_intersection;
257 if (!
isEqual(alignables, alignables2)) {
259 <<
"Cannot compare directly the two AlignPCLThresholds objects, as the list of alignables differs";
264 std::back_inserter(v_intersection));
266 std::vector<std::string> not_in_first_keys, not_in_last_keys;
273 std::inserter(not_in_last_keys, not_in_last_keys.begin()));
275 std::stringstream
ss;
276 ss <<
"the following keys are not in the last IoV: ";
277 for (
const auto&
key : not_in_last_keys) {
288 std::inserter(not_in_first_keys, not_in_first_keys.begin()));
290 ss <<
"the following keys are not in the first IoV: ";
291 for (
const auto&
key : not_in_first_keys) {
298 v_intersection = alignables;
301 TCanvas
canvas(
"Alignment PCL thresholds summary",
"Alignment PCL thresholds summary", 1500, 800);
304 canvas.SetTopMargin(0.07);
306 canvas.SetLeftMargin(0.11);
307 canvas.SetRightMargin(0.12);
316 "Thresholds",
"", v_intersection.size(), 0, v_intersection.size(), N_Y_BINS, 0, N_Y_BINS);
320 auto ThresholdsColor = std::make_unique<TH2F>(
321 "ThresholdsC",
"", v_intersection.size(), 0, v_intersection.size(), N_Y_BINS, 0, N_Y_BINS);
322 ThresholdsColor->SetStats(
false);
323 ThresholdsColor->GetXaxis()->SetLabelSize(0.028);
325 std::function<float(types, std::string, AlignPCLThresholds::coordType)> cutFunctor =
330 return l_payload->getCut(alignable, coord) - f_payload->getCut(alignable, coord);
332 return l_payload->getSigCut(alignable, coord) - f_payload->getSigCut(alignable, coord);
334 return l_payload->getMaxMoveCut(alignable, coord) - f_payload->getMaxMoveCut(alignable, coord);
336 return l_payload->getMaxErrorCut(alignable, coord) - f_payload->getMaxErrorCut(alignable, coord);
338 if constexpr (std::is_same_v<PayloadType, AlignPCLThresholdsHG>) {
341 if (f_floatMap.find(alignable) != f_floatMap.end() &&
342 l_floatMap.find(alignable) != l_floatMap.end()) {
343 return l_payload->getFractionCut(alignable, coord) - f_payload->getFractionCut(alignable, coord);
358 unsigned int xBin = 0;
359 for (
const auto& alignable : v_intersection) {
363 ThresholdsColor->GetXaxis()->SetBinLabel(
xBin, (xLabel).c_str());
364 unsigned int yBin = N_Y_BINS;
367 for (
int bar =
DELTA; bar != local_end_of_types; bar++) {
372 ThresholdsColor->GetYaxis()->SetBinLabel(
yBin, theLabel.c_str());
375 const auto&
value = cutFunctor(
type, alignable, coord);
384 ThresholdsColor->Draw(
"COLZ0");
392 ltx.SetTextSize(0.047);
393 ltx.SetTextAlign(11);
396 ltxText = fmt::sprintf(
"#color[2]{%s, %s} vs #color[4]{%s, %s}",
402 ltxText = fmt::sprintf(
"%s IOV: #color[2]{%s} vs IOV: #color[4]{%s}",
407 ltx.DrawLatexNDC(gPad->GetLeftMargin(), 1 - gPad->GetTopMargin() + 0.01, ltxText.c_str());
416 template <
typename T>
417 bool isEqual(std::vector<T>
const& v1, std::vector<T>
const& v2) {
418 return (v1.size() == v2.size() &&
std::equal(v1.begin(), v1.end(), v2.begin()));
std::string m_imageFileName
PlotImage(const std::string &title)
std::unordered_map< std::string, std::vector< float > > param_map
const std::string getStringFromCoordEnum(const AlignPCLThresholds::coordType &coord)
bool isEqual(std::vector< T > const &v1, std::vector< T > const &v2)
ret
prodAgent to be discontinued
const std::string getStringFromTypeEnum(const types &type)
static std::string to_string(const XMLCh *ch)
bool equal(const T &first, const T &second)
std::string replaceAll(const std::string &str, const std::string &from, const std::string &to)
PlotAnnotations m_plotAnnotations
key
prepare the HTCondor submission files and eventually submit them
AlignPCLThresholds_DisplayBase()
Log< level::Warning, false > LogWarning
unsigned int ntags() const
AlignPCLThresholds_CompareBase()
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)