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

Constructor & Destructor Documentation

◆ DisplayParametersDiff()

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

Definition at line 484 of file BeamSpotPayloadInspectorHelper.h.

References BeamSpotPI::DisplayParametersDiff< PayloadType, nIOVs, ntags >::isOnline_.

485  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>("Display of BeamSpot parameters differences") {
486  if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) {
487  isOnline_ = true;
488  } else {
489  isOnline_ = false;
490  }
491  }

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 493 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, HcalTBWriter_cfi::Number, BeamSpotPI::BSParamsHelper< PayloadType >::printDebug(), AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), BeamSpotPI::unpack(), X, and photonAnalyzer_cfi::yBin.

493  {
494  // trick to deal with the multi-ioved tag and two tag case at the same time
495  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
496  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
497  std::string l_tagname = "";
498  auto firstiov = theIOVs.front();
499  std::tuple<cond::Time_t, cond::Hash> lastiov;
500 
501  // we don't support (yet) comparison with more than 2 tags
502  assert(this->m_plotAnnotations.ntags < 3);
503 
504  if (this->m_plotAnnotations.ntags == 2) {
505  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
506  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
507  lastiov = tag2iovs.front();
508  } else {
509  lastiov = theIOVs.back();
510  }
511 
512  l_payload = this->fetchPayload(std::get<1>(lastiov));
513  f_payload = this->fetchPayload(std::get<1>(firstiov));
514 
515  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
516  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
517 
518  TCanvas canvas("Beam Spot Parameters Difference Summary", "Beam Spot Parameters Difference summary", 1000, 1000);
519  canvas.cd(1);
520 
521  canvas.cd(1)->SetTopMargin(0.08);
522  canvas.cd(1)->SetBottomMargin(0.06);
523  canvas.cd(1)->SetLeftMargin(0.14);
524  canvas.cd(1)->SetRightMargin(0.16);
525  canvas.cd(1)->Modified();
526  canvas.cd(1)->SetGrid();
527 
528  // for the "text"-filled histogram
529  auto h2_BSParameters = std::make_unique<TH2F>("Parameters", "", 2, 0.0, 2.0, 8, 0, 8.);
530  h2_BSParameters->SetStats(false);
531  h2_BSParameters->GetXaxis()->SetBinLabel(1, "Value");
532  h2_BSParameters->GetXaxis()->SetBinLabel(2, "Error");
533  h2_BSParameters->GetXaxis()->LabelsOption("h");
534  h2_BSParameters->GetYaxis()->SetLabelSize(0.05);
535  h2_BSParameters->GetXaxis()->SetLabelSize(0.05);
536  h2_BSParameters->SetMarkerSize(1.5);
537 
538  // prepare the arrays to fill the histogram
541 
542 #ifdef MM_DEBUG
543  std::stringstream ss1, ss2;
544  edm::LogPrint("") << "**** first payload";
545  fBS.printDebug(ss1);
546  edm::LogPrint("") << ss1.str();
547  edm::LogPrint("") << "**** last payload";
548  lBS.printDebug(ss2);
549  edm::LogPrint("") << ss2.str();
550 #endif
551 
552  const auto diffPars = fBS.diffCentralValues(lBS);
553  const auto diffErrors = fBS.diffErrors(lBS);
554  //const auto pullPars = fBS.diffCentralValues(lBS,true /*normalize*/);
555  //const auto pullErrors = fBS.diffErrors(lBS,true /*normalize*/);
556 
557  unsigned int yBin = 8;
558  for (int foo = parameters::X; foo <= parameters::dydz; foo++) {
559  parameters param = static_cast<parameters>(foo);
560  std::string theLabel = BeamSpotPI::getStringFromParamEnum(param, true /*use units*/);
561  h2_BSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
562  h2_BSParameters->SetBinContent(1, yBin, diffPars[foo]); /* profiting of the parameters enum indexing */
563  h2_BSParameters->SetBinContent(2, yBin, diffErrors[foo]);
564  yBin--;
565  }
566 
567  // for the "colz"-filled histogram (clonde from the text-based one)
568  auto h2_BSShadow = (TH2F*)(h2_BSParameters->Clone("shadow"));
569  h2_BSShadow->GetZaxis()->SetTitle("#Delta Parameter(payload A - payload B)");
570  h2_BSShadow->GetZaxis()->CenterTitle();
571  h2_BSShadow->GetZaxis()->SetTitleOffset(1.5);
572 
573  // this is the fine gradient palette (blue to red)
574  double max = h2_BSShadow->GetMaximum();
575  double min = h2_BSShadow->GetMinimum();
576  double val_white = 0.;
577  double per_white = (max != min) ? ((val_white - min) / (max - min)) : 0.5;
578 
579  const int Number = 3;
580  double Red[Number] = {0., 1., 1.};
581  double Green[Number] = {0., 1., 0.};
582  double Blue[Number] = {1., 1., 0.};
583  double Stops[Number] = {0., per_white, 1.};
584  int nb = 256;
585  h2_BSShadow->SetContour(nb);
586  TColor::CreateGradientColorTable(Number, Stops, Red, Green, Blue, nb);
587 
588  h2_BSShadow->Draw("colz");
589  h2_BSParameters->Draw("TEXTsame");
590 
591  auto ltx = TLatex();
592  ltx.SetTextFont(62);
593  ltx.SetTextSize(0.025);
594  ltx.SetTextAlign(11);
595 
596  // compute the (run,LS) pairs
597  auto l_runLS = BeamSpotPI::unpack(std::get<0>(lastiov));
598  std::string l_runLSs = "(" + std::to_string(l_runLS.first) + "," + std::to_string(l_runLS.second) + ")";
599  auto f_runLS = BeamSpotPI::unpack(std::get<0>(firstiov));
600  std::string f_runLSs = "(" + std::to_string(f_runLS.first) + "," + std::to_string(f_runLS.second) + ")";
601 
602  if (this->m_plotAnnotations.ntags == 2) {
603  ltx.DrawLatexNDC(
604  gPad->GetLeftMargin() - 0.1,
605  1 - gPad->GetTopMargin() + 0.015,
606  (fmt::sprintf(
607  "#splitline{A = #color[4]{%s}: %s}{B = #color[4]{%s}: %s}", f_tagname, f_runLSs, l_tagname, l_runLSs))
608  .c_str());
609  } else {
610  ltx.DrawLatexNDC(
611  gPad->GetLeftMargin() - 0.1,
612  1 - gPad->GetTopMargin() + 0.015,
613  (fmt::sprintf("#splitline{#color[4]{%s}}{A = %s | B = %s}", f_tagname, l_runLSs, f_runLSs)).c_str());
614  }
615 
617  canvas.SaveAs(fileName.c_str());
618 
619  return true;
620  }
float dydz
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
#define X(str)
Definition: MuonsGrabber.cc:38
std::string to_string(const V &value)
Definition: OMSAccess.h:77
assert(be >=bs)
Log< level::Warning, true > LogPrint
std::string getStringFromParamEnum(const parameters &parameter, const bool addUnits=false)
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 626 of file BeamSpotPayloadInspectorHelper.h.

626 { 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