CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType > Class Template Reference

#include <SiPixelGainCalibHelper.h>

Inheritance diagram for gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >:
cond::payloadInspector::PlotImage< PayloadType > cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 > cond::payloadInspector::PlotBase gainCalibHelper::SiPixelGainCalibrationValueComparisonSingleTag< myType, PayloadType > gainCalibHelper::SiPixelGainCalibrationValueComparisonTwoTags< myType, PayloadType >

Public Member Functions

bool fill (const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs) override
 
 SiPixelGainCalibrationValueComparisonBase ()
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< PayloadType >
std::shared_ptr< PayloadType > fetchPayload (const cond::Hash &payloadHash)
 
 PlotImage (const std::string &title)
 
std::string serializeData () override
 
- Public Member Functions inherited from cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 >
virtual bool fill ()
 
virtual bool fill (const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs)
 
 PlotImpl (const std::string &type, const std::string &title)
 
std::string processData () override
 
void setSingleIov (bool flag)
 
void setTwoTags (bool flag)
 
 ~PlotImpl () override=default
 
- Public Member Functions inherited from cond::payloadInspector::PlotBase
void addInputParam (const std::string &paramName)
 
cond::persistency::Session dbSession ()
 
template<typename PayloadType >
std::shared_ptr< PayloadType > fetchPayload (const cond::Hash &payloadHash)
 
template<int index>
TagReference getTag ()
 
cond::Tag_t getTagInfo (const std::string &tag)
 
virtual void init ()
 
const std::map< std::string, std::string > & inputParamValues () const
 
bool isSingleIov () const
 
bool isTwoTags () const
 
unsigned int ntags () const
 
std::string payloadType () const
 
 PlotBase ()
 
std::string title () const
 
std::string type () const
 
virtual ~PlotBase ()=default
 

Protected Attributes

bool isForHLT_
 
std::string label_
 
- Protected Attributes inherited from cond::payloadInspector::PlotImage< PayloadType >
std::string m_imageFileName
 
- Protected Attributes inherited from cond::payloadInspector::PlotBase
std::set< std::string > m_inputParams
 
std::map< std::string, std::string > m_inputParamValues
 
PlotAnnotations m_plotAnnotations
 
std::vector< std::pair< cond::Time_t, cond::Time_t > > m_tagBoundaries
 
std::vector< std::vector< std::tuple< cond::Time_t, cond::Hash > > > m_tagIovs
 
std::vector< std::string > m_tagNames
 

Additional Inherited Members

- Public Types inherited from cond::payloadInspector::PlotImage< PayloadType >
typedef PlotImpl< UNSPECIFIED_IOV, 0 > Base
 
- Public Attributes inherited from cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 >
bool m_singleIovSet = false
 

Detailed Description

template<gainCalibPI::type myType, class PayloadType>
class gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >

Definition at line 1019 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationValueComparisonBase()

template<gainCalibPI::type myType, class PayloadType >
gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::SiPixelGainCalibrationValueComparisonBase ( )
inline

Definition at line 1021 of file SiPixelGainCalibHelper.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), and gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::isForHLT_.

1023  Form("SiPixelGainCalibration %s Values Comparison", TypeName[myType])) {
1024  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1025  isForHLT_ = false;
1026  } else {
1027  isForHLT_ = true;
1028  }
1029  }
constexpr char const * TypeName[2]

Member Function Documentation

◆ fill()

template<gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::fill ( const std::vector< std::tuple< cond::Time_t, cond::Hash >> &  iovs)
inlineoverride

Definition at line 1030 of file SiPixelGainCalibHelper.h.

References SiPixelPI::adjustCanvasMargins(), SiPixelPI::adjustStats(), svgfig::canvas(), cond::payloadInspector::PlotImage< PayloadType >::fetchPayload(), MillePedeFileConverter_cfg::fileName, gainCalibHelper::gainCalibPI::fillTheHisto(), SiPixelPI::getExtrema(), gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::isForHLT_, gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::label_, compareTotals::legend, cond::payloadInspector::PlotImage< PayloadType >::m_imageFileName, SiPixelPI::makeNicePlotStyle(), SiStripPI::max, SiStripPI::min, jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, RandomServiceHelper::t1, RandomServiceHelper::t2, gainCalibHelper::gainCalibPI::t_gain, gainCalibHelper::gainCalibPI::t_pedestal, to_string(), and gainCalibHelper::TypeName.

1030  {
1031  gStyle->SetOptStat("emr");
1032  TGaxis::SetExponentOffset(-0.1, 0.01, "y"); // Y offset
1033  TH1F::SetDefaultSumw2(true);
1034 
1035  std::vector<std::tuple<cond::Time_t, cond::Hash>> sorted_iovs = iovs;
1036  // make absolute sure the IOVs are sortd by since
1037  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const& t1, auto const& t2) {
1038  return std::get<0>(t1) < std::get<0>(t2);
1039  });
1040  auto firstiov = sorted_iovs.front();
1041  auto lastiov = sorted_iovs.back();
1042 
1043  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1044  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1045 
1046  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1047  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1048 
1049  float minimum(9999.);
1050  float maximum(-9999.);
1051 
1052  switch (myType) {
1053  case gainCalibPI::t_gain:
1054  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1055  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
1056  break;
1058  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1059  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
1060  break;
1061  default:
1062  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
1063  break;
1064  }
1065 
1066  TCanvas canvas("Canv", "Canv", 1200, 1000);
1067  canvas.cd();
1068  auto hfirst = std::make_shared<TH1F>(Form("First, IOV %s", firstIOVsince.c_str()),
1069  Form("SiPixel Gain Calibration %s - %s;per %s %s;# %ss",
1070  (isForHLT_ ? "ForHLT" : "Offline"),
1071  TypeName[myType],
1072  (isForHLT_ ? "Column" : "Pixel"),
1073  TypeName[myType],
1074  (isForHLT_ ? "column" : "pixel")),
1075  200,
1076  minimum,
1077  maximum);
1078 
1079  auto hlast = std::make_shared<TH1F>(Form("Last, IOV %s", lastIOVsince.c_str()),
1080  Form("SiPixel Gain Calibration %s - %s;per %s %s;# %ss",
1081  (isForHLT_ ? "ForHLT" : "Offline"),
1082  TypeName[myType],
1083  (isForHLT_ ? "Column" : "Pixel"),
1084  TypeName[myType],
1085  (isForHLT_ ? "column" : "pixel")),
1086  200,
1087  minimum,
1088  maximum);
1089 
1090  SiPixelPI::adjustCanvasMargins(canvas.cd(), 0.05, 0.12, 0.12, 0.03);
1091  canvas.Modified();
1092 
1093  gainCalibPI::fillTheHisto(first_payload, hfirst, myType);
1094  gainCalibPI::fillTheHisto(last_payload, hlast, myType);
1095 
1096  canvas.cd()->SetLogy();
1097  auto extrema = SiPixelPI::getExtrema(hfirst.get(), hlast.get());
1098  //hfirst->GetYaxis()->SetRangeUser(extrema.first, extrema.second * 1.10);
1099  hfirst->GetYaxis()->SetRangeUser(1., extrema.second * 10);
1100 
1101  hfirst->SetTitle("");
1102  hfirst->SetLineColor(kRed);
1103  hfirst->SetBarWidth(0.95);
1104  hfirst->Draw("hist");
1105 
1106  hlast->SetTitle("");
1107  hlast->SetFillColorAlpha(kBlue, 0.20);
1108  hlast->SetBarWidth(0.95);
1109  hlast->Draw("histsames");
1110 
1111  SiPixelPI::makeNicePlotStyle(hfirst.get());
1112  hfirst->SetStats(true);
1113  SiPixelPI::makeNicePlotStyle(hlast.get());
1114  hlast->SetStats(true);
1115 
1116  canvas.Update();
1117 
1118  TLegend legend = TLegend(0.45, 0.86, 0.74, 0.94);
1119  //legend.SetHeader("#font[22]{SiPixel Offline Gain Calibration Comparison}", "C"); // option "C" allows to center the header
1120  //legend.AddEntry(hfirst.get(), ("IOV: " + std::to_string(std::get<0>(firstiov))).c_str(), "FL");
1121  //legend.AddEntry(hlast.get(), ("IOV: " + std::to_string(std::get<0>(lastiov))).c_str(), "FL");
1122  legend.AddEntry(hfirst.get(), ("payload: #color[2]{" + std::get<1>(firstiov) + "}").c_str(), "F");
1123  legend.AddEntry(hlast.get(), ("payload: #color[4]{" + std::get<1>(lastiov) + "}").c_str(), "F");
1124  legend.SetTextSize(0.022);
1125  legend.SetLineColor(10);
1126  legend.Draw("same");
1127 
1128  TPaveStats* st1 = (TPaveStats*)hfirst->FindObject("stats");
1129  st1->SetTextSize(0.021);
1130  st1->SetLineColor(kRed);
1131  st1->SetTextColor(kRed);
1132  SiPixelPI::adjustStats(st1, 0.13, 0.86, 0.31, 0.94);
1133 
1134  TPaveStats* st2 = (TPaveStats*)hlast->FindObject("stats");
1135  st2->SetTextSize(0.021);
1136  st2->SetLineColor(kBlue);
1137  st2->SetTextColor(kBlue);
1138  SiPixelPI::adjustStats(st2, 0.13, 0.77, 0.31, 0.85);
1139 
1140  auto ltx = TLatex();
1141  ltx.SetTextFont(62);
1142  //ltx.SetTextColor(kBlue);
1143  ltx.SetTextSize(0.047);
1144  ltx.SetTextAlign(11);
1145  ltx.DrawLatexNDC(gPad->GetLeftMargin(),
1146  1 - gPad->GetTopMargin() + 0.01,
1147  ("SiPixel Gain Calibration IOV:#color[2]{" + std::to_string(std::get<0>(firstiov)) +
1148  "} vs IOV:#color[4]{" + std::to_string(std::get<0>(lastiov)) + "}")
1149  .c_str());
1150 
1152  canvas.SaveAs(fileName.c_str());
1153 #ifdef MMDEBUG
1154  canvas.SaveAs("out.root");
1155 #endif
1156 
1157  return true;
1158  }
Log< level::Error, false > LogError
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
static std::string to_string(const XMLCh *ch)
constexpr char const * TypeName[2]
static void fillTheHisto(const std::shared_ptr< PayloadType > &payload, std::shared_ptr< TH1F > h1, gainCalibPI::type theType, const std::vector< uint32_t > &wantedIds={})
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)
void makeNicePlotStyle(TH1 *hist)
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

Member Data Documentation

◆ isForHLT_

template<gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::isForHLT_
protected

◆ label_

template<gainCalibPI::type myType, class PayloadType >
std::string gainCalibHelper::SiPixelGainCalibrationValueComparisonBase< myType, PayloadType >::label_
protected