CMS 3D CMS Logo

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

#include <BeamSpotPayloadInspectorHelper.h>

Inheritance diagram for simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >:
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags > cond::payloadInspector::PlotImpl< IOV_M, NTAGS > cond::payloadInspector::PlotBase

Public Member Functions

 DisplayParametersDiff ()
 
bool fill () override
 
- 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

std::shared_ptr< PayloadType > f_payload
 
std::shared_ptr< PayloadType > l_payload
 
- 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<class PayloadType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
class simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >

Definition at line 1347 of file BeamSpotPayloadInspectorHelper.h.

Constructor & Destructor Documentation

◆ DisplayParametersDiff()

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::DisplayParametersDiff ( )
inline

Definition at line 1349 of file BeamSpotPayloadInspectorHelper.h.

Member Function Documentation

◆ fill()

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
bool simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::fill ( )
inlineoverridevirtual

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

Definition at line 1353 of file BeamSpotPayloadInspectorHelper.h.

References cms::cuda::assert(), svgfig::canvas(), simBeamSpotHLLHCPI::crabbingAngleCrossing, simBeamSpotHLLHCPI::crabbingAngleSeparation, simBeamSpotHLLHCPI::SimBSHLLHCParamsHelper< PayloadType >::diffCentralValues(), END_OF_TYPES, simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::f_payload, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload(), MillePedeFileConverter_cfg::fileName, custom_jme_cff::foo, simBeamSpotHLLHCPI::getStringFromParamEnum(), simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::l_payload, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::m_imageFileName, cond::payloadInspector::PlotBase::m_plotAnnotations, SiStripPI::max, simBeamSpotHLLHCPI::meanX, SiStripPI::min, Skims_PA_cff::name, cond::payloadInspector::PlotAnnotations::ntags, contentValuesFiles::number, simBeamSpotHLLHCPI::SimBSHLLHCParamsHelper< PayloadType >::printDebug(), AlCaHLTBitMon_QueryRunRegistry::string, simBeamSpotHLLHCPI::timeOffset, to_string(), beamSpotPI::unpack(), and photonAnalyzer_cfi::yBin.

1353  {
1354  // trick to deal with the multi-ioved tag and two tag case at the same time
1355  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
1356  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
1357  std::string l_tagname = "";
1358  auto firstiov = theIOVs.front();
1359  std::tuple<cond::Time_t, cond::Hash> lastiov;
1360 
1361  // we don't support (yet) comparison with more than 2 tags
1362  assert(this->m_plotAnnotations.ntags < 3);
1363 
1364  if (this->m_plotAnnotations.ntags == 2) {
1365  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
1366  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
1367  lastiov = tag2iovs.front();
1368  } else {
1369  lastiov = theIOVs.back();
1370  }
1371 
1372  l_payload = this->fetchPayload(std::get<1>(lastiov));
1373  f_payload = this->fetchPayload(std::get<1>(firstiov));
1374 
1375  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1376  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1377 
1378  TCanvas canvas("Sim Beam Spot HL-LHC Parameters Difference Summary",
1379  "Sim Beam Spot HL-LHC Parameters Difference summary",
1380  1500,
1381  1000);
1382  canvas.Divide(2, 1);
1383 
1384  // Histograms with parameters differences
1385  // for the "text"-filled histogram
1386  auto h2_SimBSHLLHCParameters = std::make_unique<TH2F>(
1387  "Parameters", "", 1, 0.0, 1.0, parameters::crabbingAngleCrossing, 0, parameters::crabbingAngleCrossing);
1388  h2_SimBSHLLHCParameters->SetStats(false);
1389  h2_SimBSHLLHCParameters->GetXaxis()->SetBinLabel(1, "Value");
1390  h2_SimBSHLLHCParameters->GetXaxis()->LabelsOption("h");
1391  h2_SimBSHLLHCParameters->GetYaxis()->SetLabelSize(0.05);
1392  h2_SimBSHLLHCParameters->GetXaxis()->SetLabelSize(0.05);
1393  h2_SimBSHLLHCParameters->SetMarkerSize(1.5);
1394 
1396  auto h2_SimBSHLLHCParameters_Extras =
1397  std::make_unique<TH2F>("Parameters Extras", "", 1, 0.0, 1.0, span, 0, static_cast<float>(span));
1398  h2_SimBSHLLHCParameters_Extras->SetStats(false);
1399  h2_SimBSHLLHCParameters_Extras->GetXaxis()->SetBinLabel(1, "Value");
1400  h2_SimBSHLLHCParameters_Extras->GetXaxis()->LabelsOption("h");
1401  h2_SimBSHLLHCParameters_Extras->GetYaxis()->SetLabelSize(0.05);
1402  h2_SimBSHLLHCParameters_Extras->GetXaxis()->SetLabelSize(0.05);
1403  h2_SimBSHLLHCParameters_Extras->SetMarkerSize(1.5);
1404 
1405  // prepare the arrays to fill the histogram
1408 
1409 #ifdef MM_DEBUG
1410  std::stringstream ss1, ss2;
1411  edm::LogPrint("") << "**** first payload";
1412  fBS.printDebug(ss1);
1413  edm::LogPrint("") << ss1.str();
1414  edm::LogPrint("") << "**** last payload";
1415  lBS.printDebug(ss2);
1416  edm::LogPrint("") << ss2.str();
1417 #endif
1418 
1419  const auto diffPars = fBS.diffCentralValues(lBS);
1420 
1421  // fill "text"-filled histograms
1422  unsigned int yBin = 8;
1424  parameters param = static_cast<parameters>(foo);
1425  std::string theLabel = simBeamSpotHLLHCPI::getStringFromParamEnum(param, true /*use units*/);
1426  h2_SimBSHLLHCParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
1427  h2_SimBSHLLHCParameters->SetBinContent(1, yBin, diffPars[foo]); /* profiting of the parameters enum indexing */
1428  yBin--;
1429  }
1430 
1431  unsigned int yBin_Extras = span;
1433  parameters param = static_cast<parameters>(foo);
1434  std::string theLabel = simBeamSpotHLLHCPI::getStringFromParamEnum(param, true /*use units*/);
1435  h2_SimBSHLLHCParameters_Extras->GetYaxis()->SetBinLabel(yBin_Extras, theLabel.c_str());
1436  h2_SimBSHLLHCParameters_Extras->SetBinContent(
1437  1, yBin_Extras, diffPars[foo]); /* profiting of the parameters enum indexing */
1438  yBin_Extras--;
1439  }
1440 
1441  // for the "colz"-filled histogram (clone from the text-based one)
1442  auto h2_SimBSHLLHCShadow = (TH2F*)(h2_SimBSHLLHCParameters->Clone("shadow"));
1443  h2_SimBSHLLHCShadow->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
1444  h2_SimBSHLLHCShadow->GetZaxis()->CenterTitle();
1445  h2_SimBSHLLHCShadow->GetZaxis()->SetTitleOffset(1.5);
1446 
1447  auto h2_SimBSHLLHCShadow_Extras = (TH2F*)(h2_SimBSHLLHCParameters_Extras->Clone("shadow"));
1448  h2_SimBSHLLHCShadow_Extras->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
1449  h2_SimBSHLLHCShadow_Extras->GetZaxis()->CenterTitle();
1450  h2_SimBSHLLHCShadow_Extras->GetZaxis()->SetTitleOffset(1.5);
1451 
1452  // this is the fine gradient palette (blue to red)
1453  double max = std::max(h2_SimBSHLLHCShadow->GetMaximum(), h2_SimBSHLLHCShadow_Extras->GetMaximum());
1454  double min = std::min(h2_SimBSHLLHCShadow->GetMinimum(), h2_SimBSHLLHCShadow_Extras->GetMinimum());
1455  double val_white = 0.;
1456  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
1457 
1458  const int number = 3;
1459  double Red[number] = {0., 1., 1.};
1460  double Green[number] = {0., 1., 0.};
1461  double Blue[number] = {1., 1., 0.};
1462  double Stops[number] = {0., per_white, 1.};
1463  int nb = 256;
1464  h2_SimBSHLLHCShadow->SetContour(nb);
1465  h2_SimBSHLLHCShadow_Extras->SetContour(nb);
1466  TColor::CreateGradientColorTable(number, Stops, Red, Green, Blue, nb);
1467 
1468  // Fill canvas (1,1) with first 9 parameters differences
1469  canvas.cd(1);
1470  canvas.cd(1)->SetTopMargin(0.10);
1471  canvas.cd(1)->SetBottomMargin(0.06);
1472  canvas.cd(1)->SetLeftMargin(0.35);
1473  canvas.cd(1)->SetRightMargin(0.25);
1474  canvas.cd(1)->Modified();
1475  canvas.cd(1)->SetGrid();
1476  h2_SimBSHLLHCShadow->Draw("colz");
1477  h2_SimBSHLLHCParameters->Draw("TEXTsame");
1478 
1479  auto ltx = TLatex();
1480  ltx.SetTextFont(62);
1481  ltx.SetTextSize(0.025);
1482  ltx.SetTextAlign(11);
1483 
1484  // compute the (run,LS) pairs
1485  auto l_runLS = beamSpotPI::unpack(std::get<0>(lastiov));
1486  std::string l_runLSs = "(" + std::to_string(l_runLS.first) + "," + std::to_string(l_runLS.second) + ")";
1487  auto f_runLS = beamSpotPI::unpack(std::get<0>(firstiov));
1488  std::string f_runLSs = "(" + std::to_string(f_runLS.first) + "," + std::to_string(f_runLS.second) + ")";
1489 
1490  if (this->m_plotAnnotations.ntags == 2) {
1491  ltx.DrawLatexNDC(
1492  gPad->GetLeftMargin(),
1493  1 - gPad->GetTopMargin() + 0.025,
1494  (fmt::sprintf(
1495  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
1496  .c_str());
1497  } else {
1498  ltx.DrawLatexNDC(
1499  gPad->GetLeftMargin(),
1500  1 - gPad->GetTopMargin() + 0.025,
1501  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
1502  }
1503 
1504  // Fill canvas (2,1) with first 9 parameters differences
1505  canvas.cd(2);
1506  canvas.cd(2)->SetTopMargin(0.10);
1507  canvas.cd(2)->SetBottomMargin(0.06);
1508  canvas.cd(2)->SetLeftMargin(0.35);
1509  canvas.cd(2)->SetRightMargin(0.20);
1510  canvas.cd(2)->Modified();
1511  canvas.cd(2)->SetGrid();
1512  h2_SimBSHLLHCShadow_Extras->Draw("colz");
1513  h2_SimBSHLLHCParameters_Extras->Draw("TEXTsame");
1514 
1515  if (this->m_plotAnnotations.ntags == 2) {
1516  ltx.DrawLatexNDC(
1517  gPad->GetLeftMargin(),
1518  1 - gPad->GetTopMargin() + 0.025,
1519  (fmt::sprintf(
1520  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
1521  .c_str());
1522  } else {
1523  ltx.DrawLatexNDC(
1524  gPad->GetLeftMargin(),
1525  1 - gPad->GetTopMargin() + 0.025,
1526  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
1527  }
1528 
1530  canvas.SaveAs(fileName.c_str());
1531 
1532  return true;
1533  }
assert(be >=bs)
static std::string to_string(const XMLCh *ch)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
Log< level::Warning, true > LogPrint
def canvas(sub, attr)
Definition: svgfig.py:482
std::string getStringFromParamEnum(const parameters &parameter, const bool addUnits=false)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

Member Data Documentation

◆ f_payload

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
std::shared_ptr<PayloadType> simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::f_payload
protected

◆ l_payload

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
std::shared_ptr<PayloadType> simBeamSpotHLLHCPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::l_payload
protected