CMS 3D CMS Logo

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

#include <SiPixelGainCalibHelper.h>

Inheritance diagram for gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >:
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags > cond::payloadInspector::PlotImpl< IOV_M, NTAGS > cond::payloadInspector::PlotBase

Public Member Functions

bool fill () override
 
 SiPixelGainCalibDiffAndRatioBase ()
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >
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< IOV_M, NTAGS >
 PlotImpl (const std::string &type, const std::string &title)
 
std::string processData () override
 
 ~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, nIOVs, ntags >
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, nIOVs, ntags >
typedef PlotImpl< IOV_M, NTAGS > Base
 

Detailed Description

template<gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType>
class gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >

Definition at line 1188 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibDiffAndRatioBase()

template<gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::SiPixelGainCalibDiffAndRatioBase ( )
inline

Definition at line 1190 of file SiPixelGainCalibHelper.h.

References gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::isForHLT_.

1192  Form("SiPixelGainCalibration %s Diff and Ratio %i tag(s)", TypeName[myType], ntags)) {
1193  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1194  isForHLT_ = false;
1195  } else {
1196  isForHLT_ = true;
1197  }
1198  }
constexpr char const * TypeName[2]

Member Function Documentation

◆ fill()

template<gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::fill ( )
inlineoverridevirtual

Implements cond::payloadInspector::PlotImpl< IOV_M, NTAGS >.

Definition at line 1200 of file SiPixelGainCalibHelper.h.

References SiPixelPI::adjustCanvasMargins(), SiPixelPI::adjustStats(), mps_check::array, cms::cuda::assert(), svgfig::canvas(), COUT, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload(), MillePedeFileConverter_cfg::fileName, gainCalibHelper::gainCalibPI::fillDiffAndRatio(), gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::isForHLT_, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::m_imageFileName, cond::payloadInspector::PlotBase::m_plotAnnotations, SiPixelPI::makeNicePlotStyle(), Skims_PA_cff::name, cond::payloadInspector::PlotAnnotations::ntags, cond::payloadInspector::PlotBase::ntags(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), and gainCalibHelper::TypeName.

1200  {
1201  gStyle->SetOptStat("emr");
1202  TGaxis::SetExponentOffset(-0.1, 0.01, "y"); // Y offset
1203  TH1F::SetDefaultSumw2(true);
1204 
1205  COUT << "ntags: " << ntags << " this->m_plotAnnotations.ntags: " << this->m_plotAnnotations.ntags << std::endl;
1206 
1207  // trick to deal with the multi-ioved tag and two tag case at the same time
1208  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
1209  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
1210  std::string l_tagname = "";
1211  auto firstiov = theIOVs.front();
1212  std::tuple<cond::Time_t, cond::Hash> lastiov;
1213 
1214  // we don't support (yet) comparison with more than 2 tags
1215  assert(this->m_plotAnnotations.ntags < 3);
1216 
1217  if (this->m_plotAnnotations.ntags == 2) {
1218  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
1219  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
1220  lastiov = tag2iovs.front();
1221  } else {
1222  lastiov = theIOVs.back();
1223  }
1224 
1225  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1226  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1227 
1228  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1229  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1230 
1231  TCanvas canvas("Canv", "Canv", 1300, 800);
1232  canvas.Divide(2, 1);
1233  canvas.cd();
1234 
1235  SiPixelPI::adjustCanvasMargins(canvas.cd(1), 0.05, 0.12, 0.12, 0.04);
1236  SiPixelPI::adjustCanvasMargins(canvas.cd(2), 0.05, 0.12, 0.12, 0.04);
1237  canvas.Modified();
1238 
1239  auto array = gainCalibPI::fillDiffAndRatio(first_payload, last_payload, myType);
1240 
1241  array[0]->SetTitle(Form("SiPixel Gain Calibration %s - %s;per %s %s ratio;# %ss",
1242  (isForHLT_ ? "ForHLT" : "Offline"),
1243  TypeName[myType],
1244  (isForHLT_ ? "Column" : "Pixel"),
1245  TypeName[myType],
1246  (isForHLT_ ? "column" : "pixel")));
1247 
1248  array[1]->SetTitle(Form("SiPixel Gain Calibration %s - %s;per %s %s difference;# %ss",
1249  (isForHLT_ ? "ForHLT" : "Offline"),
1250  TypeName[myType],
1251  (isForHLT_ ? "Column" : "Pixel"),
1252  TypeName[myType],
1253  (isForHLT_ ? "column" : "pixel")));
1254 
1255  canvas.cd(1)->SetLogy();
1256  array[0]->SetTitle("");
1257  array[0]->SetLineColor(kBlack);
1258  array[0]->SetFillColor(kRed);
1259  array[0]->SetBarWidth(0.90);
1260  array[0]->SetMaximum(array[0]->GetMaximum() * 10);
1261  array[0]->Draw("bar");
1263  array[0]->SetStats(true);
1264 
1265  canvas.cd(2)->SetLogy();
1266  array[1]->SetTitle("");
1267  array[1]->SetLineColor(kBlack);
1268  array[1]->SetFillColor(kBlue);
1269  array[1]->SetBarWidth(0.90);
1270  array[1]->SetMaximum(array[1]->GetMaximum() * 10);
1271  array[1]->Draw("bar");
1273  array[1]->SetStats(true);
1274 
1275  canvas.Update();
1276 
1277  canvas.cd(1);
1278  TLatex latex;
1279  latex.SetTextSize(0.024);
1280  latex.SetTextAlign(13); //align at top
1281  latex.DrawLatexNDC(
1282  .41,
1283  .94,
1284  fmt::sprintf("#scale[1.2]{SiPixelGainCalibration%s Ratio}", (isForHLT_ ? "ForHLT" : "Offline")).c_str());
1285  if (this->m_plotAnnotations.ntags == 2) {
1286  latex.DrawLatexNDC(
1287  .41, .91, ("#splitline{#font[12]{" + f_tagname + "}}{ / #font[12]{" + l_tagname + "}}").c_str());
1288  } else {
1289  latex.DrawLatexNDC(.41, .91, (firstIOVsince + " / " + lastIOVsince).c_str());
1290  }
1291 
1292  canvas.cd(2);
1293  TLatex latex2;
1294  latex2.SetTextSize(0.024);
1295  latex2.SetTextAlign(13); //align at top
1296  latex2.DrawLatexNDC(
1297  .41,
1298  .94,
1299  fmt::sprintf("#scale[1.2]{SiPixelGainCalibration%s Diff}", (isForHLT_ ? "ForHLT" : "Offline")).c_str());
1300  if (this->m_plotAnnotations.ntags == 2) {
1301  latex2.DrawLatexNDC(
1302  .41, .91, ("#splitline{#font[12]{" + f_tagname + "}}{ - #font[12]{" + l_tagname + "}}").c_str());
1303  } else {
1304  latex2.DrawLatexNDC(.41, .91, (firstIOVsince + " - " + lastIOVsince).c_str());
1305  }
1306 
1307  TPaveStats* st1 = (TPaveStats*)array[0]->FindObject("stats");
1308  st1->SetTextSize(0.027);
1309  st1->SetLineColor(kRed);
1310  st1->SetTextColor(kRed);
1311  SiPixelPI::adjustStats(st1, 0.13, 0.84, 0.40, 0.94);
1312 
1313  TPaveStats* st2 = (TPaveStats*)array[1]->FindObject("stats");
1314  st2->SetTextSize(0.027);
1315  st2->SetLineColor(kBlue);
1316  st2->SetTextColor(kBlue);
1317  SiPixelPI::adjustStats(st2, 0.13, 0.84, 0.40, 0.94);
1318 
1319  auto ltx = TLatex();
1320  ltx.SetTextFont(62);
1321  //ltx.SetTextColor(kBlue);
1322  ltx.SetTextSize(0.040);
1323  ltx.SetTextAlign(11);
1324  canvas.cd(1);
1325  ltx.DrawLatexNDC(
1326  gPad->GetLeftMargin(),
1327  1 - gPad->GetTopMargin() + 0.01,
1328  fmt::sprintf("SiPixel %s Ratio, IOV %s / %s", TypeName[myType], firstIOVsince, lastIOVsince).c_str());
1329 
1330  canvas.cd(2);
1331  ltx.DrawLatexNDC(
1332  gPad->GetLeftMargin(),
1333  1 - gPad->GetTopMargin() + 0.01,
1334  fmt::sprintf("SiPixel %s Diff, IOV %s - %s", TypeName[myType], firstIOVsince, lastIOVsince).c_str());
1335 
1337  canvas.SaveAs(fileName.c_str());
1338 #ifdef MMDEBUG
1339  canvas.SaveAs("out.root");
1340 #endif
1341 
1342  return true;
1343  }
std::string to_string(const V &value)
Definition: OMSAccess.h:71
assert(be >=bs)
static std::array< std::shared_ptr< TH1F >, 2 > fillDiffAndRatio(const std::shared_ptr< PayloadType > &payload_A, const std::shared_ptr< PayloadType > &payload_B, const gainCalibPI::type &theType)
constexpr char const * TypeName[2]
#define COUT
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, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::isForHLT_
protected

◆ label_

template<gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
std::string gainCalibHelper::SiPixelGainCalibDiffAndRatioBase< myType, nIOVs, ntags, PayloadType >::label_
protected