CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 217 of file BeamSpotPayloadInspectorHelper.h.

Constructor & Destructor Documentation

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

Definition at line 219 of file BeamSpotPayloadInspectorHelper.h.

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

221  "Display of BeamSpot parameters") {
222  if constexpr (std::is_same_v<PayloadType, BeamSpotOnlineObjects>) {
223  isOnline_ = true;
224  } else {
225  isOnline_ = false;
226  }
227  }

Member Function Documentation

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

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

Definition at line 229 of file BeamSpotPayloadInspectorHelper.h.

References newFWLiteAna::bin, svgfig::canvas(), BeamSpotPI::dxdz, BeamSpotPI::dydz, BeamSpotPI::END_OF_TYPES, cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >::fetchPayload(), MillePedeFileConverter_cfg::fileName, BeamSpotPI::DisplayParameters< PayloadType >::fillTheExtraHistogram(), 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, GlobalPosition_Frontier_DevDB_cff::tag, createPayload::tagname, BeamSpotPI::unpack(), BeamSpotPI::X, X, BeamSpotPI::Y, cuy::yBin, and BeamSpotPI::Z.

229  {
230  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
231  auto tagname = tag.name;
232  auto iov = tag.iovs.front();
233 
234  gStyle->SetHistMinimumZero(kTRUE);
235 
236  m_payload = this->fetchPayload(std::get<1>(iov));
237 
238  TCanvas canvas("Beam Spot Parameters Summary", "BeamSpot Parameters summary", isOnline_ ? 1500 : 1000, 1000);
239  if (isOnline_) {
240  canvas.Divide(2, 1);
241  }
242  canvas.cd(1);
243 
244  canvas.cd(1)->SetTopMargin(0.05);
245  canvas.cd(1)->SetBottomMargin(0.06);
246  canvas.cd(1)->SetLeftMargin(0.15);
247  canvas.cd(1)->SetRightMargin(0.01);
248  canvas.cd(1)->Modified();
249  canvas.cd(1)->SetGrid();
250 
251  auto h2_BSParameters = std::make_unique<TH2F>("Parameters", "", 2, 0.0, 2.0, 8, 0, 8.);
252  h2_BSParameters->SetStats(false);
253 
254  std::function<double(parameters, bool)> cutFunctor = [this](parameters my_param, bool isError) {
255  double ret(-999.);
256  if (!isError) {
257  switch (my_param) {
258  case X:
259  return m_payload->GetX();
260  case Y:
261  return m_payload->GetY();
262  case Z:
263  return m_payload->GetZ();
264  case sigmaX:
265  return m_payload->GetBeamWidthX();
266  case sigmaY:
267  return m_payload->GetBeamWidthY();
268  case sigmaZ:
269  return m_payload->GetSigmaZ();
270  case dxdz:
271  return m_payload->Getdxdz();
272  case dydz:
273  return m_payload->Getdydz();
274  case END_OF_TYPES:
275  return ret;
276  default:
277  return ret;
278  }
279  } else {
280  switch (my_param) {
281  case X:
282  return m_payload->GetXError();
283  case Y:
284  return m_payload->GetYError();
285  case Z:
286  return m_payload->GetZError();
287  case sigmaX:
288  return m_payload->GetBeamWidthXError();
289  case sigmaY:
290  return m_payload->GetBeamWidthYError();
291  case sigmaZ:
292  return m_payload->GetSigmaZError();
293  case dxdz:
294  return m_payload->GetdxdzError();
295  case dydz:
296  return m_payload->GetdydzError();
297  case END_OF_TYPES:
298  return ret;
299  default:
300  return ret;
301  }
302  }
303  };
304 
305  h2_BSParameters->GetXaxis()->SetBinLabel(1, "Value");
306  h2_BSParameters->GetXaxis()->SetBinLabel(2, "Error");
307 
308  unsigned int yBin = 8;
309  for (int foo = parameters::X; foo <= parameters::dydz; foo++) {
310  parameters param = static_cast<parameters>(foo);
311  std::string theLabel = getStringFromTypeEnum(param);
312  h2_BSParameters->GetYaxis()->SetBinLabel(yBin, theLabel.c_str());
313  h2_BSParameters->SetBinContent(1, yBin, cutFunctor(param, false));
314  h2_BSParameters->SetBinContent(2, yBin, cutFunctor(param, true));
315  yBin--;
316  }
317 
318  h2_BSParameters->GetXaxis()->LabelsOption("h");
319  h2_BSParameters->GetYaxis()->SetLabelSize(0.05);
320  h2_BSParameters->GetXaxis()->SetLabelSize(0.05);
321  h2_BSParameters->SetMarkerSize(1.5);
322  h2_BSParameters->Draw("TEXT");
323 
324  auto ltx = TLatex();
325  ltx.SetTextFont(62);
326  if (isOnline_) {
327  ltx.SetTextSize(0.030);
328  } else {
329  ltx.SetTextSize(0.025);
330  }
331  ltx.SetTextAlign(11);
332 
333  auto runLS = BeamSpotPI::unpack(std::get<0>(iov));
334 
335  ltx.DrawLatexNDC(
336  gPad->GetLeftMargin(),
337  1 - gPad->GetTopMargin() + 0.01,
338  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
339  .c_str());
340 
341  if (isOnline_) {
342  canvas.cd(2);
343  canvas.cd(2)->SetTopMargin(0.05);
344  canvas.cd(2)->SetBottomMargin(0.06);
345  canvas.cd(2)->SetLeftMargin(0.25);
346  canvas.cd(2)->SetRightMargin(0.01);
347  canvas.cd(2)->Modified();
348  canvas.cd(2)->SetGrid();
349 
350  auto extras = fillTheExtraHistogram();
351  if (extras) {
352  for (int bin = 1; bin <= extras->GetNbinsY(); bin++) {
353  edm::LogVerbatim("BeamSpotPayloadInspectorHelper")
354  << extras->GetYaxis()->GetBinLabel(bin) << ": " << extras->GetBinContent(1, bin) << "\n";
355  }
356  }
357  extras->Draw("TEXT");
358 
359  ltx.DrawLatexNDC(
360  gPad->GetLeftMargin(),
361  1 - gPad->GetTopMargin() + 0.01,
362  (tagname + " IOV: #color[4]{" + std::to_string(runLS.first) + "," + std::to_string(runLS.second) + "}")
363  .c_str());
364 
366  canvas.SaveAs(fileName.c_str());
367 
368  return true;
369  } else {
371  canvas.SaveAs(fileName.c_str());
372 
373  return true;
374  }
375  }
Log< level::Info, true > LogVerbatim
virtual std::string getStringFromTypeEnum(const parameters &parameter) const
tuple ret
prodAgent to be discontinued
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
tuple yBin
Definition: cuy.py:892
#define X(str)
Definition: MuonsGrabber.cc:38
virtual std::shared_ptr< TH2F > fillTheExtraHistogram() const
def canvas
Definition: svgfig.py:482
std::shared_ptr< PayloadType > m_payload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
template<class PayloadType >
virtual std::shared_ptr<TH2F> BeamSpotPI::DisplayParameters< PayloadType >::fillTheExtraHistogram ( ) const
inlinevirtual

Definition at line 378 of file BeamSpotPayloadInspectorHelper.h.

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

378 { return nullptr; }
template<class PayloadType >
virtual std::string BeamSpotPI::DisplayParameters< PayloadType >::getStringFromTypeEnum ( const parameters parameter) const
inlineprotectedvirtual

Definition at line 385 of file BeamSpotPayloadInspectorHelper.h.

References BeamSpotPI::dxdz, BeamSpotPI::dydz, BeamSpotPI::sigmaX, BeamSpotPI::sigmaY, BeamSpotPI::sigmaZ, BeamSpotPI::X, BeamSpotPI::Y, and BeamSpotPI::Z.

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

385  {
386  switch (parameter) {
387  case X:
388  return "X [cm]";
389  case Y:
390  return "Y [cm]";
391  case Z:
392  return "Z [cm]";
393  case sigmaX:
394  return "#sigma_{X} [cm]";
395  case sigmaY:
396  return "#sigma_{Y} [cm]";
397  case sigmaZ:
398  return "#sigma_{Z} [cm]";
399  case dxdz:
400  return "#frac{dX}{dZ} [rad]";
401  case dydz:
402  return "#frac{dY}{dZ} [rad]";
403  default:
404  return "should never be here";
405  }
406  }

Member Data Documentation

template<class PayloadType >
bool BeamSpotPI::DisplayParameters< PayloadType >::isOnline_
protected
template<class PayloadType >
std::shared_ptr<PayloadType> BeamSpotPI::DisplayParameters< PayloadType >::m_payload
protected