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 823 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 829 of file BeamSpotPayloadInspectorHelper.h.

References cms::cuda::assert(), svgfig::canvas(), simBeamSpotPI::SimBSParamsHelper< PayloadType >::diffCentralValues(), 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.

829  {
830  // trick to deal with the multi-ioved tag and two tag case at the same time
831  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
832  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
833  std::string l_tagname = "";
834  auto firstiov = theIOVs.front();
835  std::tuple<cond::Time_t, cond::Hash> lastiov;
836 
837  // we don't support (yet) comparison with more than 2 tags
838  assert(this->m_plotAnnotations.ntags < 3);
839 
840  if (this->m_plotAnnotations.ntags == 2) {
841  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
842  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
843  lastiov = tag2iovs.front();
844  } else {
845  lastiov = theIOVs.back();
846  }
847 
848  l_payload = this->fetchPayload(std::get<1>(lastiov));
849  f_payload = this->fetchPayload(std::get<1>(firstiov));
850 
851  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
852  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
853 
854  TCanvas canvas(
855  "Sim Beam Spot Parameters Difference Summary", "Sim Beam Spot Parameters Difference summary", 1000, 1000);
856  canvas.cd(1);
857  canvas.cd(1)->SetTopMargin(0.10);
858  canvas.cd(1)->SetBottomMargin(0.06);
859  canvas.cd(1)->SetLeftMargin(0.23);
860  canvas.cd(1)->SetRightMargin(0.16);
861  canvas.cd(1)->Modified();
862  canvas.cd(1)->SetGrid();
863 
864  // for the "text"-filled histogram
865  auto h2_SimBSParameters = std::make_unique<TH2F>("Parameters", "", 1, 0.0, 1.0, 9, 0, 9.);
866  h2_SimBSParameters->SetStats(false);
867  h2_SimBSParameters->GetXaxis()->SetBinLabel(1, "Value");
868  h2_SimBSParameters->GetXaxis()->LabelsOption("h");
869  h2_SimBSParameters->GetYaxis()->SetLabelSize(0.05);
870  h2_SimBSParameters->GetXaxis()->SetLabelSize(0.05);
871  h2_SimBSParameters->SetMarkerSize(1.5);
872 
873  // prepare the arrays to fill the histogram
876 
877 #ifdef MM_DEBUG
878  std::stringstream ss1, ss2;
879  edm::LogPrint("") << "**** first payload";
880  fBS.printDebug(ss1);
881  edm::LogPrint("") << ss1.str();
882  edm::LogPrint("") << "**** last payload";
883  lBS.printDebug(ss2);
884  edm::LogPrint("") << ss2.str();
885 #endif
886 
887  const auto diffPars = fBS.diffCentralValues(lBS);
888  //const auto pullPars = fBS.diffCentralValues(lBS,true /*normalize*/);
889 
890  unsigned int yBin = 9;
891  for (int foo = parameters::X; foo <= parameters::timeOffset; foo++) {
892  parameters param = static_cast<parameters>(foo);
893  std::string theLabel = simBeamSpotPI::getStringFromParamEnum(param, true /*use units*/);
894  h2_SimBSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
895  h2_SimBSParameters->SetBinContent(1, yBin, diffPars[foo]); /* profiting of the parameters enum indexing */
896  yBin--;
897  }
898 
899  // for the "colz"-filled histogram (clonde from the text-based one)
900  auto h2_SimBSShadow = (TH2F*)(h2_SimBSParameters->Clone("shadow"));
901  h2_SimBSShadow->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
902  h2_SimBSShadow->GetZaxis()->CenterTitle();
903  h2_SimBSShadow->GetZaxis()->SetTitleOffset(1.5);
904 
905  // this is the fine gradient palette (blue to red)
906  double max = h2_SimBSShadow->GetMaximum();
907  double min = h2_SimBSShadow->GetMinimum();
908  double val_white = 0.;
909  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
910 
911  const int number = 3;
912  double Red[number] = {0., 1., 1.};
913  double Green[number] = {0., 1., 0.};
914  double Blue[number] = {1., 1., 0.};
915  double Stops[number] = {0., per_white, 1.};
916  int nb = 256;
917  h2_SimBSShadow->SetContour(nb);
918  TColor::CreateGradientColorTable(number, Stops, Red, Green, Blue, nb);
919 
920  h2_SimBSShadow->Draw("colz");
921  h2_SimBSParameters->Draw("TEXTsame");
922 
923  auto ltx = TLatex();
924  ltx.SetTextFont(62);
925  ltx.SetTextSize(0.025);
926  ltx.SetTextAlign(11);
927 
928  // compute the (run,LS) pairs
929  auto l_runLS = beamSpotPI::unpack(std::get<0>(lastiov));
930  std::string l_runLSs = "(" + std::to_string(l_runLS.first) + "," + std::to_string(l_runLS.second) + ")";
931  auto f_runLS = beamSpotPI::unpack(std::get<0>(firstiov));
932  std::string f_runLSs = "(" + std::to_string(f_runLS.first) + "," + std::to_string(f_runLS.second) + ")";
933 
934  if (this->m_plotAnnotations.ntags == 2) {
935  ltx.DrawLatexNDC(
936  gPad->GetLeftMargin(),
937  1 - gPad->GetTopMargin() + 0.025,
938  (fmt::sprintf(
939  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
940  .c_str());
941  } else {
942  ltx.DrawLatexNDC(
943  gPad->GetLeftMargin(),
944  1 - gPad->GetTopMargin() + 0.025,
945  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
946  }
947 
949  canvas.SaveAs(fileName.c_str());
950 
951  return true;
952  }
#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