CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
beamSpotPI::DisplayParameters< PayloadType > Class Template Reference

#include <BeamSpotPayloadInspectorHelper.h>

Inheritance diagram for beamSpotPI::DisplayParameters< PayloadType >:
cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV > cond::payloadInspector::PlotImpl< IOV_M, 0 > cond::payloadInspector::PlotBase

Public Member Functions

 DisplayParameters ()
 
bool fill () override
 
virtual std::shared_ptr< TH2F > fillTheExtraHistogram () const
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >
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, 0 >
 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 Member Functions

virtual std::string getStringFromTypeEnum (const parameters &parameter) const
 
template<typename T , class Except , class Func , class Response >
T test_ (Func f, Response r) const
 

Static Protected Member Functions

static void better_error (const std::exception &e)
 

Protected Attributes

bool isOnline_
 
std::shared_ptr< PayloadType > m_payload
 
- Protected Attributes inherited from cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >
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, cond::payloadInspector::SINGLE_IOV >
typedef PlotImpl< IOV_M, 0 > Base
 

Detailed Description

template<class PayloadType>
class beamSpotPI::DisplayParameters< PayloadType >

Definition at line 308 of file BeamSpotPayloadInspectorHelper.h.

Constructor & Destructor Documentation

◆ DisplayParameters()

template<class PayloadType >
beamSpotPI::DisplayParameters< PayloadType >::DisplayParameters ( )
inline

Definition at line 310 of file BeamSpotPayloadInspectorHelper.h.

References beamSpotPI::DisplayParameters< PayloadType >::isOnline_.

312  "Display of BeamSpot parameters") {
313  if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) {
314  isOnline_ = true;
315  } else {
316  isOnline_ = false;
317  }
318  }

Member Function Documentation

◆ better_error()

template<class PayloadType >
static void beamSpotPI::DisplayParameters< PayloadType >::better_error ( const std::exception &  e)
inlinestaticprotected

Definition at line 541 of file BeamSpotPayloadInspectorHelper.h.

References MillePedeFileConverter_cfg::e.

Referenced by beamSpotPI::DisplayParameters< PayloadType >::fill().

541 { edm::LogError("DisplayParameters") << e.what() << '\n'; }
Log< level::Error, false > LogError

◆ fill()

template<class PayloadType >
bool beamSpotPI::DisplayParameters< PayloadType >::fill ( )
inlineoverridevirtual

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

Definition at line 320 of file BeamSpotPayloadInspectorHelper.h.

References beamSpotPI::DisplayParameters< PayloadType >::better_error(), newFWLiteAna::bin, svgfig::canvas(), beamSpotPI::convertTimeToDateString(), beamSpotPI::creationTime, beamSpotPI::dxdz, beamSpotPI::dydz, dydz, beamSpotPI::END_OF_TYPES, beamSpotPI::endTime, cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >::fetchPayload(), MillePedeFileConverter_cfg::fileName, beamSpotPI::DisplayParameters< PayloadType >::fillTheExtraHistogram(), custom_jme_cff::foo, beamSpotPI::DisplayParameters< PayloadType >::getStringFromTypeEnum(), beamSpotPI::DisplayParameters< PayloadType >::isOnline_, cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >::m_imageFileName, beamSpotPI::DisplayParameters< PayloadType >::m_payload, runTheMatrix::ret, beamSpotPI::sigmaX, beamSpotPI::sigmaY, beamSpotPI::sigmaZ, beamSpotPI::startTime, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, createPayload::tagname, to_string(), beamSpotPI::unpack(), beamSpotPI::X, X, beamSpotPI::Y, photonAnalyzer_cfi::yBin, and beamSpotPI::Z.

320  {
321  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
322  auto tagname = tag.name;
323  auto iov = tag.iovs.front();
324 
325  gStyle->SetHistMinimumZero(kTRUE);
326 
327  m_payload = this->fetchPayload(std::get<1>(iov));
328 
329  TCanvas canvas("Beam Spot Parameters Summary", "BeamSpot Parameters summary", isOnline_ ? 1500 : 1000, 1000);
330  if (isOnline_) {
331  canvas.Divide(2, 1);
332  }
333  canvas.cd(1);
334 
335  canvas.cd(1)->SetTopMargin(0.05);
336  canvas.cd(1)->SetBottomMargin(0.06);
337  canvas.cd(1)->SetLeftMargin(0.15);
338  canvas.cd(1)->SetRightMargin(0.01);
339  canvas.cd(1)->Modified();
340  canvas.cd(1)->SetGrid();
341 
342  auto h2_BSParameters = std::make_unique<TH2F>("Parameters", "", 2, 0.0, 2.0, 8, 0, 8.);
343  h2_BSParameters->SetStats(false);
344 
345  std::function<double(parameters, bool)> cutFunctor = [this](parameters my_param, bool isError) {
346  double ret(-999.);
347  if (!isError) {
348  switch (my_param) {
349  case X:
350  return m_payload->x();
351  case Y:
352  return m_payload->y();
353  case Z:
354  return m_payload->z();
355  case sigmaX:
356  return m_payload->beamWidthX();
357  case sigmaY:
358  return m_payload->beamWidthY();
359  case sigmaZ:
360  return m_payload->sigmaZ();
361  case dxdz:
362  return m_payload->dxdz();
363  case dydz:
364  return m_payload->dydz();
365  case END_OF_TYPES:
366  return ret;
367  default:
368  return ret;
369  }
370  } else {
371  switch (my_param) {
372  case X:
373  return m_payload->xError();
374  case Y:
375  return m_payload->yError();
376  case Z:
377  return m_payload->zError();
378  case sigmaX:
379  return m_payload->beamWidthXError();
380  case sigmaY:
381  return m_payload->beamWidthYError();
382  case sigmaZ:
383  return m_payload->sigmaZError();
384  case dxdz:
385  return m_payload->dxdzError();
386  case dydz:
387  return m_payload->dydzError();
388  case END_OF_TYPES:
389  return ret;
390  default:
391  return ret;
392  }
393  }
394  };
395 
396  h2_BSParameters->GetXaxis()->SetBinLabel(1, "Value");
397  h2_BSParameters->GetXaxis()->SetBinLabel(2, "Error");
398 
399  unsigned int yBin = 8;
400  for (int foo = parameters::X; foo <= parameters::dydz; foo++) {
401  parameters param = static_cast<parameters>(foo);
402  std::string theLabel = getStringFromTypeEnum(param);
403  h2_BSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
404  h2_BSParameters->SetBinContent(1, yBin, cutFunctor(param, false));
405  h2_BSParameters->SetBinContent(2, yBin, cutFunctor(param, true));
406  yBin--;
407  }
408 
409  h2_BSParameters->GetXaxis()->LabelsOption("h");
410  h2_BSParameters->GetYaxis()->SetLabelSize(0.05);
411  h2_BSParameters->GetXaxis()->SetLabelSize(0.05);
412  h2_BSParameters->SetMarkerSize(1.5);
413  h2_BSParameters->Draw("TEXT");
414 
415  auto ltx = TLatex();
416  ltx.SetTextFont(62);
417  if (isOnline_) {
418  ltx.SetTextSize(0.030);
419  } else {
420  ltx.SetTextSize(0.025);
421  }
422  ltx.SetTextAlign(11);
423 
424  auto runLS = beamSpotPI::unpack(std::get<0>(iov));
425 
426  ltx.DrawLatexNDC(
427  gPad->GetLeftMargin(),
428  1 - gPad->GetTopMargin() + 0.01,
429  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
430  .c_str());
431 
432  if (isOnline_) {
433  canvas.cd(2);
434  canvas.cd(2)->SetTopMargin(0.05);
435  canvas.cd(2)->SetBottomMargin(0.06);
436  canvas.cd(2)->SetLeftMargin(0.25);
437  canvas.cd(2)->SetRightMargin(0.01);
438  canvas.cd(2)->Modified();
439  canvas.cd(2)->SetGrid();
440 
441  auto extras = fillTheExtraHistogram();
442  if (extras) {
443  for (int bin = 1; bin <= extras->GetNbinsY(); bin++) {
444  edm::LogVerbatim("BeamSpotPayloadInspectorHelper")
445  << extras->GetYaxis()->GetBinLabel(bin) << ": " << extras->GetBinContent(1, bin) << "\n";
446  }
447  }
448  extras->Draw("TEXT");
449 
450  ltx.DrawLatexNDC(
451  gPad->GetLeftMargin(),
452  1 - gPad->GetTopMargin() + 0.01,
453  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
454  .c_str());
455 
456  if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) {
457  // protections needed against old payload that do not have these data members persisted
458  const auto& creationTime = test_<cond::Time_t, std::out_of_range>(
459  [&]() {
460  return m_payload->creationTime();
461  }, // Lambda function capturing m_payload and calling creationTime
462  better_error);
463 
464  const auto& startTime = test_<cond::Time_t, std::out_of_range>(
465  [&]() {
466  return m_payload->startTimeStamp();
467  }, // Lambda function capturing m_payload and calling startTimeStamp
468  better_error);
469 
470  const auto& endTime = test_<cond::Time_t, std::out_of_range>(
471  [&]() {
472  return m_payload->endTimeStamp();
473  }, // Lambda function capturing m_payload and calling endTimeStamp
474  better_error);
475  canvas.cd(2);
476  ltx.SetTextSize(0.025);
477  ltx.DrawLatexNDC(
478  gPad->GetLeftMargin() + 0.01,
479  gPad->GetBottomMargin() + 0.15,
480  ("#color[2]{(" + beamSpotPI::convertTimeToDateString(creationTime, /*has us*/ true) + ")}").c_str());
481 
482  ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
483  gPad->GetBottomMargin() + 0.085,
484  ("#color[2]{(" + beamSpotPI::convertTimeToDateString(startTime) + ")}").c_str());
485 
486  ltx.DrawLatexNDC(gPad->GetLeftMargin() + 0.01,
487  gPad->GetBottomMargin() + 0.025,
488  ("#color[2]{(" + beamSpotPI::convertTimeToDateString(endTime) + ")}").c_str());
489 
490  ltx.DrawLatexNDC(
491  gPad->GetLeftMargin(), gPad->GetBottomMargin() - 0.05, "#color[4]{N.B.} TimeStamps are in UTC");
492  }
493 
495  canvas.SaveAs(fileName.c_str());
496 
497  return true;
498  } else {
500  canvas.SaveAs(fileName.c_str());
501 
502  return true;
503  }
504  }
Log< level::Info, true > LogVerbatim
float dydz
ret
prodAgent to be discontinued
#define X(str)
Definition: MuonsGrabber.cc:38
std::shared_ptr< PayloadType > m_payload
static std::string to_string(const XMLCh *ch)
std::string convertTimeToDateString(cond::Time_t timeValue, bool hasMicros=false, bool toUTC=true)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
virtual std::string getStringFromTypeEnum(const parameters &parameter) const
static void better_error(const std::exception &e)
def canvas(sub, attr)
Definition: svgfig.py:482
virtual std::shared_ptr< TH2F > fillTheExtraHistogram() const
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

◆ fillTheExtraHistogram()

template<class PayloadType >
virtual std::shared_ptr<TH2F> beamSpotPI::DisplayParameters< PayloadType >::fillTheExtraHistogram ( ) const
inlinevirtual

Definition at line 507 of file BeamSpotPayloadInspectorHelper.h.

Referenced by beamSpotPI::DisplayParameters< PayloadType >::fill().

507 { return nullptr; }

◆ getStringFromTypeEnum()

template<class PayloadType >
virtual std::string beamSpotPI::DisplayParameters< PayloadType >::getStringFromTypeEnum ( const parameters parameter) const
inlineprotectedvirtual

Can't use beamSpotPI::getStringFromParamEnum becasue it needs to be overridden for the BeamSpotOnlineObjects case.

Definition at line 517 of file BeamSpotPayloadInspectorHelper.h.

References beamSpotPI::dxdz, beamSpotPI::dydz, pfMETsysShiftCorrections_cfi::parameter, beamSpotPI::sigmaX, beamSpotPI::sigmaY, beamSpotPI::sigmaZ, beamSpotPI::X, beamSpotPI::Y, and beamSpotPI::Z.

Referenced by beamSpotPI::DisplayParameters< PayloadType >::fill().

517  {
518  switch (parameter) {
519  case X:
520  return "X [cm]";
521  case Y:
522  return "Y [cm]";
523  case Z:
524  return "Z [cm]";
525  case sigmaX:
526  return "#sigma_{X} [cm]";
527  case sigmaY:
528  return "#sigma_{Y} [cm]";
529  case sigmaZ:
530  return "#sigma_{Z} [cm]";
531  case dxdz:
532  return "#frac{dX}{dZ} [rad]";
533  case dydz:
534  return "#frac{dY}{dZ} [rad]";
535  default:
536  return "should never be here";
537  }
538  }

◆ test_()

template<class PayloadType >
template<typename T , class Except , class Func , class Response >
T beamSpotPI::DisplayParameters< PayloadType >::test_ ( Func  f,
Response  r 
) const
inlineprotected

Definition at line 545 of file BeamSpotPayloadInspectorHelper.h.

References MillePedeFileConverter_cfg::e, f, and LogDebug.

545  {
546  try {
547  LogDebug("DisplayParameters") << "I have tried" << std::endl;
548  return f();
549  } catch (const Except& e) {
550  LogDebug("DisplayParameters") << "I have caught!" << std::endl;
551  r(e);
552  return static_cast<T>(1);
553  }
554  }
double f[11][100]
long double T
#define LogDebug(id)

Member Data Documentation

◆ isOnline_

template<class PayloadType >
bool beamSpotPI::DisplayParameters< PayloadType >::isOnline_
protected

◆ m_payload

template<class PayloadType >
std::shared_ptr<PayloadType> beamSpotPI::DisplayParameters< PayloadType >::m_payload
protected