CMS 3D CMS Logo

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

#include <BeamSpotPayloadInspectorHelper.h>

Inheritance diagram for simBeamSpotPI::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 simBeamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >

Definition at line 914 of file BeamSpotPayloadInspectorHelper.h.

Constructor & Destructor Documentation

◆ DisplayParametersDiff()

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

Member Function Documentation

◆ fill()

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

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

Definition at line 920 of file BeamSpotPayloadInspectorHelper.h.

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

920  {
921  // trick to deal with the multi-ioved tag and two tag case at the same time
922  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
923  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
924  std::string l_tagname = "";
925  auto firstiov = theIOVs.front();
926  std::tuple<cond::Time_t, cond::Hash> lastiov;
927 
928  // we don't support (yet) comparison with more than 2 tags
929  assert(this->m_plotAnnotations.ntags < 3);
930 
931  if (this->m_plotAnnotations.ntags == 2) {
932  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
933  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
934  lastiov = tag2iovs.front();
935  } else {
936  lastiov = theIOVs.back();
937  }
938 
939  l_payload = this->fetchPayload(std::get<1>(lastiov));
940  f_payload = this->fetchPayload(std::get<1>(firstiov));
941 
942  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
943  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
944 
945  TCanvas canvas(
946  "Sim Beam Spot Parameters Difference Summary", "Sim Beam Spot Parameters Difference summary", 1000, 1000);
947  canvas.cd(1);
948  canvas.cd(1)->SetTopMargin(0.10);
949  canvas.cd(1)->SetBottomMargin(0.06);
950  canvas.cd(1)->SetLeftMargin(0.23);
951  canvas.cd(1)->SetRightMargin(0.16);
952  canvas.cd(1)->Modified();
953  canvas.cd(1)->SetGrid();
954 
955  // for the "text"-filled histogram
956  auto h2_SimBSParameters = std::make_unique<TH2F>("Parameters", "", 1, 0.0, 1.0, END_OF_TYPES, 0, END_OF_TYPES);
957  h2_SimBSParameters->SetStats(false);
958  h2_SimBSParameters->GetXaxis()->SetBinLabel(1, "Value");
959  h2_SimBSParameters->GetXaxis()->LabelsOption("h");
960  h2_SimBSParameters->GetYaxis()->SetLabelSize(0.05);
961  h2_SimBSParameters->GetXaxis()->SetLabelSize(0.05);
962  h2_SimBSParameters->SetMarkerSize(1.5);
963 
964  // prepare the arrays to fill the histogram
967 
968 #ifdef MM_DEBUG
969  std::stringstream ss1, ss2;
970  edm::LogPrint("") << "**** first payload";
971  fBS.printDebug(ss1);
972  edm::LogPrint("") << ss1.str();
973  edm::LogPrint("") << "**** last payload";
974  lBS.printDebug(ss2);
975  edm::LogPrint("") << ss2.str();
976 #endif
977 
978  const auto diffPars = fBS.diffCentralValues(lBS);
979  //const auto pullPars = fBS.diffCentralValues(lBS,true /*normalize*/);
980 
981  unsigned int yBin = END_OF_TYPES;
982  for (int foo = parameters::X; foo <= parameters::timeOffset; foo++) {
983  parameters param = static_cast<parameters>(foo);
984  std::string theLabel = simBeamSpotPI::getStringFromParamEnum(param, true /*use units*/);
985  h2_SimBSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
986  h2_SimBSParameters->SetBinContent(1, yBin, diffPars[foo]); /* profiting of the parameters enum indexing */
987  yBin--;
988  }
989 
990  // for the "colz"-filled histogram (clonde from the text-based one)
991  auto h2_SimBSShadow = (TH2F*)(h2_SimBSParameters->Clone("shadow"));
992  h2_SimBSShadow->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
993  h2_SimBSShadow->GetZaxis()->CenterTitle();
994  h2_SimBSShadow->GetZaxis()->SetTitleOffset(1.5);
995 
996  // this is the fine gradient palette (blue to red)
997  double max = h2_SimBSShadow->GetMaximum();
998  double min = h2_SimBSShadow->GetMinimum();
999  double val_white = 0.;
1000  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
1001 
1002  const int number = 3;
1003  double Red[number] = {0., 1., 1.};
1004  double Green[number] = {0., 1., 0.};
1005  double Blue[number] = {1., 1., 0.};
1006  double Stops[number] = {0., per_white, 1.};
1007  int nb = 256;
1008  h2_SimBSShadow->SetContour(nb);
1009  TColor::CreateGradientColorTable(number, Stops, Red, Green, Blue, nb);
1010 
1011  h2_SimBSShadow->Draw("colz");
1012  h2_SimBSParameters->Draw("TEXTsame");
1013 
1014  auto ltx = TLatex();
1015  ltx.SetTextFont(62);
1016  ltx.SetTextSize(0.025);
1017  ltx.SetTextAlign(11);
1018 
1019  // compute the (run,LS) pairs
1020  auto l_runLS = beamSpotPI::unpack(std::get<0>(lastiov));
1021  std::string l_runLSs = "(" + std::to_string(l_runLS.first) + "," + std::to_string(l_runLS.second) + ")";
1022  auto f_runLS = beamSpotPI::unpack(std::get<0>(firstiov));
1023  std::string f_runLSs = "(" + std::to_string(f_runLS.first) + "," + std::to_string(f_runLS.second) + ")";
1024 
1025  if (this->m_plotAnnotations.ntags == 2) {
1026  ltx.DrawLatexNDC(
1027  gPad->GetLeftMargin(),
1028  1 - gPad->GetTopMargin() + 0.025,
1029  (fmt::sprintf(
1030  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
1031  .c_str());
1032  } else {
1033  ltx.DrawLatexNDC(
1034  gPad->GetLeftMargin(),
1035  1 - gPad->GetTopMargin() + 0.025,
1036  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
1037  }
1038 
1040  canvas.SaveAs(fileName.c_str());
1041 
1042  return true;
1043  }
#define X(str)
Definition: MuonsGrabber.cc:38
assert(be >=bs)
static std::string to_string(const XMLCh *ch)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
std::string getStringFromParamEnum(const parameters &parameter, const bool addUnits=false)
Log< level::Warning, true > LogPrint
def canvas(sub, attr)
Definition: svgfig.py:482
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> simBeamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::f_payload
protected

◆ l_payload

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