CMS 3D CMS Logo

List of all members | Public Member Functions | 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
 

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

Constructor & Destructor Documentation

◆ DisplayParameters()

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

Definition at line 285 of file BeamSpotPayloadInspectorHelper.h.

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

287  "Display of BeamSpot parameters") {
288  if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) {
289  isOnline_ = true;
290  } else {
291  isOnline_ = false;
292  }
293  }

Member Function Documentation

◆ fill()

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

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

Definition at line 295 of file BeamSpotPayloadInspectorHelper.h.

References newFWLiteAna::bin, svgfig::canvas(), BeamSpotPI::dxdz, BeamSpotPI::dydz, dydz, BeamSpotPI::END_OF_TYPES, 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, AlCaHLTBitMon_QueryRunRegistry::string, makeGlobalPositionRcd_cfg::tag, createPayload::tagname, cond::impl::to_string(), BeamSpotPI::unpack(), BeamSpotPI::X, X, BeamSpotPI::Y, photonAnalyzer_cfi::yBin, and BeamSpotPI::Z.

295  {
296  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
297  auto tagname = tag.name;
298  auto iov = tag.iovs.front();
299 
300  gStyle->SetHistMinimumZero(kTRUE);
301 
302  m_payload = this->fetchPayload(std::get<1>(iov));
303 
304  TCanvas canvas("Beam Spot Parameters Summary", "BeamSpot Parameters summary", isOnline_ ? 1500 : 1000, 1000);
305  if (isOnline_) {
306  canvas.Divide(2, 1);
307  }
308  canvas.cd(1);
309 
310  canvas.cd(1)->SetTopMargin(0.05);
311  canvas.cd(1)->SetBottomMargin(0.06);
312  canvas.cd(1)->SetLeftMargin(0.15);
313  canvas.cd(1)->SetRightMargin(0.01);
314  canvas.cd(1)->Modified();
315  canvas.cd(1)->SetGrid();
316 
317  auto h2_BSParameters = std::make_unique<TH2F>("Parameters", "", 2, 0.0, 2.0, 8, 0, 8.);
318  h2_BSParameters->SetStats(false);
319 
320  std::function<double(parameters, bool)> cutFunctor = [this](parameters my_param, bool isError) {
321  double ret(-999.);
322  if (!isError) {
323  switch (my_param) {
324  case X:
325  return m_payload->x();
326  case Y:
327  return m_payload->y();
328  case Z:
329  return m_payload->z();
330  case sigmaX:
331  return m_payload->beamWidthX();
332  case sigmaY:
333  return m_payload->beamWidthY();
334  case sigmaZ:
335  return m_payload->sigmaZ();
336  case dxdz:
337  return m_payload->dxdz();
338  case dydz:
339  return m_payload->dydz();
340  case END_OF_TYPES:
341  return ret;
342  default:
343  return ret;
344  }
345  } else {
346  switch (my_param) {
347  case X:
348  return m_payload->xError();
349  case Y:
350  return m_payload->yError();
351  case Z:
352  return m_payload->zError();
353  case sigmaX:
354  return m_payload->beamWidthXError();
355  case sigmaY:
356  return m_payload->beamWidthYError();
357  case sigmaZ:
358  return m_payload->sigmaZError();
359  case dxdz:
360  return m_payload->dxdzError();
361  case dydz:
362  return m_payload->dydzError();
363  case END_OF_TYPES:
364  return ret;
365  default:
366  return ret;
367  }
368  }
369  };
370 
371  h2_BSParameters->GetXaxis()->SetBinLabel(1, "Value");
372  h2_BSParameters->GetXaxis()->SetBinLabel(2, "Error");
373 
374  unsigned int yBin = 8;
375  for (int foo = parameters::X; foo <= parameters::dydz; foo++) {
376  parameters param = static_cast<parameters>(foo);
377  std::string theLabel = getStringFromTypeEnum(param);
378  h2_BSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
379  h2_BSParameters->SetBinContent(1, yBin, cutFunctor(param, false));
380  h2_BSParameters->SetBinContent(2, yBin, cutFunctor(param, true));
381  yBin--;
382  }
383 
384  h2_BSParameters->GetXaxis()->LabelsOption("h");
385  h2_BSParameters->GetYaxis()->SetLabelSize(0.05);
386  h2_BSParameters->GetXaxis()->SetLabelSize(0.05);
387  h2_BSParameters->SetMarkerSize(1.5);
388  h2_BSParameters->Draw("TEXT");
389 
390  auto ltx = TLatex();
391  ltx.SetTextFont(62);
392  if (isOnline_) {
393  ltx.SetTextSize(0.030);
394  } else {
395  ltx.SetTextSize(0.025);
396  }
397  ltx.SetTextAlign(11);
398 
399  auto runLS = BeamSpotPI::unpack(std::get<0>(iov));
400 
401  ltx.DrawLatexNDC(
402  gPad->GetLeftMargin(),
403  1 - gPad->GetTopMargin() + 0.01,
404  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
405  .c_str());
406 
407  if (isOnline_) {
408  canvas.cd(2);
409  canvas.cd(2)->SetTopMargin(0.05);
410  canvas.cd(2)->SetBottomMargin(0.06);
411  canvas.cd(2)->SetLeftMargin(0.25);
412  canvas.cd(2)->SetRightMargin(0.01);
413  canvas.cd(2)->Modified();
414  canvas.cd(2)->SetGrid();
415 
416  auto extras = fillTheExtraHistogram();
417  if (extras) {
418  for (int bin = 1; bin <= extras->GetNbinsY(); bin++) {
419  edm::LogVerbatim("BeamSpotPayloadInspectorHelper")
420  << extras->GetYaxis()->GetBinLabel(bin) << ": " << extras->GetBinContent(1, bin) << "\n";
421  }
422  }
423  extras->Draw("TEXT");
424 
425  ltx.DrawLatexNDC(
426  gPad->GetLeftMargin(),
427  1 - gPad->GetTopMargin() + 0.01,
428  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
429  .c_str());
430 
432  canvas.SaveAs(fileName.c_str());
433 
434  return true;
435  } else {
437  canvas.SaveAs(fileName.c_str());
438 
439  return true;
440  }
441  }
Log< level::Info, true > LogVerbatim
float dydz
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
ret
prodAgent to be discontinued
#define X(str)
Definition: MuonsGrabber.cc:38
std::string to_string(const V &value)
Definition: OMSAccess.h:77
virtual std::shared_ptr< TH2F > fillTheExtraHistogram() const
virtual std::string getStringFromTypeEnum(const parameters &parameter) const
def canvas(sub, attr)
Definition: svgfig.py:482
std::shared_ptr< PayloadType > m_payload
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 444 of file BeamSpotPayloadInspectorHelper.h.

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

444 { 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 454 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().

454  {
455  switch (parameter) {
456  case X:
457  return "X [cm]";
458  case Y:
459  return "Y [cm]";
460  case Z:
461  return "Z [cm]";
462  case sigmaX:
463  return "#sigma_{X} [cm]";
464  case sigmaY:
465  return "#sigma_{Y} [cm]";
466  case sigmaZ:
467  return "#sigma_{Z} [cm]";
468  case dxdz:
469  return "#frac{dX}{dZ} [rad]";
470  case dydz:
471  return "#frac{dY}{dZ} [rad]";
472  default:
473  return "should never be here";
474  }
475  }

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