CMS 3D CMS Logo

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

#include <BeamSpotPayloadInspectorHelper.h>

Inheritance diagram for beamSpotPI::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
 
virtual std::shared_ptr< TH2F > fillTheExtraHistogram () const
 
- 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
 
bool isOnline_
 
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 beamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >

Definition at line 561 of file BeamSpotPayloadInspectorHelper.h.

Constructor & Destructor Documentation

◆ DisplayParametersDiff()

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

Member Function Documentation

◆ fill()

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

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

Definition at line 572 of file BeamSpotPayloadInspectorHelper.h.

References cms::cuda::assert(), svgfig::canvas(), beamSpotPI::BSParamsHelper< PayloadType >::diffCentralValues(), beamSpotPI::BSParamsHelper< PayloadType >::diffErrors(), dydz, beamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::f_payload, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload(), MillePedeFileConverter_cfg::fileName, custom_jme_cff::foo, beamSpotPI::getStringFromParamEnum(), beamSpotPI::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, beamSpotPI::BSParamsHelper< PayloadType >::printDebug(), AlCaHLTBitMon_QueryRunRegistry::string, to_string(), beamSpotPI::unpack(), X, and photonAnalyzer_cfi::yBin.

572  {
573  // trick to deal with the multi-ioved tag and two tag case at the same time
574  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
575  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
576  std::string l_tagname = "";
577  auto firstiov = theIOVs.front();
578  std::tuple<cond::Time_t, cond::Hash> lastiov;
579 
580  // we don't support (yet) comparison with more than 2 tags
581  assert(this->m_plotAnnotations.ntags < 3);
582 
583  if (this->m_plotAnnotations.ntags == 2) {
584  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
585  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
586  lastiov = tag2iovs.front();
587  } else {
588  lastiov = theIOVs.back();
589  }
590 
591  l_payload = this->fetchPayload(std::get<1>(lastiov));
592  f_payload = this->fetchPayload(std::get<1>(firstiov));
593 
594  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
595  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
596 
597  TCanvas canvas("Beam Spot Parameters Difference Summary", "Beam Spot Parameters Difference summary", 1000, 1000);
598  canvas.cd(1);
599 
600  canvas.cd(1)->SetTopMargin(0.08);
601  canvas.cd(1)->SetBottomMargin(0.06);
602  canvas.cd(1)->SetLeftMargin(0.14);
603  canvas.cd(1)->SetRightMargin(0.16);
604  canvas.cd(1)->Modified();
605  canvas.cd(1)->SetGrid();
606 
607  // for the "text"-filled histogram
608  auto h2_BSParameters = std::make_unique<TH2F>("Parameters", "", 2, 0.0, 2.0, 8, 0, 8.);
609  h2_BSParameters->SetStats(false);
610  h2_BSParameters->GetXaxis()->SetBinLabel(1, "Value");
611  h2_BSParameters->GetXaxis()->SetBinLabel(2, "Error");
612  h2_BSParameters->GetXaxis()->LabelsOption("h");
613  h2_BSParameters->GetYaxis()->SetLabelSize(0.05);
614  h2_BSParameters->GetXaxis()->SetLabelSize(0.05);
615  h2_BSParameters->SetMarkerSize(1.5);
616 
617  // prepare the arrays to fill the histogram
620 
621 #ifdef MM_DEBUG
622  std::stringstream ss1, ss2;
623  edm::LogPrint("") << "**** first payload";
624  fBS.printDebug(ss1);
625  edm::LogPrint("") << ss1.str();
626  edm::LogPrint("") << "**** last payload";
627  lBS.printDebug(ss2);
628  edm::LogPrint("") << ss2.str();
629 #endif
630 
631  const auto diffPars = fBS.diffCentralValues(lBS);
632  const auto diffErrors = fBS.diffErrors(lBS);
633  //const auto pullPars = fBS.diffCentralValues(lBS,true /*normalize*/);
634  //const auto pullErrors = fBS.diffErrors(lBS,true /*normalize*/);
635 
636  unsigned int yBin = 8;
637  for (int foo = parameters::X; foo <= parameters::dydz; foo++) {
638  parameters param = static_cast<parameters>(foo);
639  std::string theLabel = beamSpotPI::getStringFromParamEnum(param, true /*use units*/);
640  h2_BSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
641  h2_BSParameters->SetBinContent(1, yBin, diffPars[foo]); /* profiting of the parameters enum indexing */
642  h2_BSParameters->SetBinContent(2, yBin, diffErrors[foo]);
643  yBin--;
644  }
645 
646  // for the "colz"-filled histogram (clonde from the text-based one)
647  auto h2_BSShadow = (TH2F*)(h2_BSParameters->Clone("shadow"));
648  h2_BSShadow->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
649  h2_BSShadow->GetZaxis()->CenterTitle();
650  h2_BSShadow->GetZaxis()->SetTitleOffset(1.5);
651 
652  // this is the fine gradient palette (blue to red)
653  double max = h2_BSShadow->GetMaximum();
654  double min = h2_BSShadow->GetMinimum();
655  double val_white = 0.;
656  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
657 
658  const int number = 3;
659  double Red[number] = {0., 1., 1.};
660  double Green[number] = {0., 1., 0.};
661  double Blue[number] = {1., 1., 0.};
662  double Stops[number] = {0., per_white, 1.};
663  int nb = 256;
664  h2_BSShadow->SetContour(nb);
665  TColor::CreateGradientColorTable(number, Stops, Red, Green, Blue, nb);
666 
667  h2_BSShadow->Draw("colz");
668  h2_BSParameters->Draw("TEXTsame");
669 
670  auto ltx = TLatex();
671  ltx.SetTextFont(62);
672  ltx.SetTextSize(0.025);
673  ltx.SetTextAlign(11);
674 
675  // compute the (run,LS) pairs
676  auto l_runLS = beamSpotPI::unpack(std::get<0>(lastiov));
677  std::string l_runLSs = "(" + std::to_string(l_runLS.first) + "," + std::to_string(l_runLS.second) + ")";
678  auto f_runLS = beamSpotPI::unpack(std::get<0>(firstiov));
679  std::string f_runLSs = "(" + std::to_string(f_runLS.first) + "," + std::to_string(f_runLS.second) + ")";
680 
681  if (this->m_plotAnnotations.ntags == 2) {
682  ltx.DrawLatexNDC(
683  gPad->GetLeftMargin() - 0.1,
684  1 - gPad->GetTopMargin() + 0.015,
685  (fmt::sprintf(
686  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
687  .c_str());
688  } else {
689  ltx.DrawLatexNDC(
690  gPad->GetLeftMargin() - 0.1,
691  1 - gPad->GetTopMargin() + 0.015,
692  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
693  }
694 
696  canvas.SaveAs(fileName.c_str());
697 
698  return true;
699  }
float dydz
#define X(str)
Definition: MuonsGrabber.cc:38
std::string getStringFromParamEnum(const parameters &parameter, const bool addUnits=false)
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::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

◆ fillTheExtraHistogram()

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
virtual std::shared_ptr<TH2F> beamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::fillTheExtraHistogram ( ) const
inlinevirtual

In case an extension to the BeamSpotOnlineObjects case will be needed in future

Definition at line 705 of file BeamSpotPayloadInspectorHelper.h.

705 { return nullptr; }

Member Data Documentation

◆ f_payload

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

◆ isOnline_

template<class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
bool beamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::isOnline_
protected

◆ l_payload

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