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 937 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 943 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(), run_AlCaRecoTriggerBitsUpdateWorkflow::iovs, simBeamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::l_payload, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::m_imageFileName, cond::payloadInspector::PlotBase::m_plotAnnotations, WZElectronSkims53X_cff::max, SiStripPI::min, mergeVDriftHistosByStation::name, cond::payloadInspector::PlotAnnotations::ntags, ConfigBuilder::number, simBeamSpotPI::SimBSParamsHelper< PayloadType >::printDebug(), AlCaHLTBitMon_QueryRunRegistry::string, simBeamSpotHLLHCPI::timeOffset, to_string(), beamSpotPI::unpack(), X, and photonAnalyzer_cfi::yBin.

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