CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType > Class Template Reference

#include <SiPixelGainCalibHelper.h>

Inheritance diagram for gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >:
cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV > cond::payloadInspector::PlotImpl< IOV_M, 0 > cond::payloadInspector::PlotBase

Public Member Functions

bool fill () override
 
 SiPixelGainCalibrationValuesPerRegion ()
 
- 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 Attributes

bool isForHLT_
 
std::string label_
 
- 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<bool isBarrel, gainCalibPI::type myType, class PayloadType>
class gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >

Definition at line 401 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationValuesPerRegion()

template<bool isBarrel, gainCalibPI::type myType, class PayloadType >
gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::SiPixelGainCalibrationValuesPerRegion ( )
inline

Definition at line 404 of file SiPixelGainCalibHelper.h.

References cond::payloadInspector::PlotBase::addInputParam(), gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::isForHLT_, and gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::label_.

406  Form("SiPixelGainCalibration %s Values Per Region", TypeName[myType])) {
408 
409  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
410  isForHLT_ = false;
411  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
412  } else {
413  isForHLT_ = true;
414  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
415  }
416  }
constexpr char const * TypeName[2]
void addInputParam(const std::string &paramName)

Member Function Documentation

◆ fill()

template<bool isBarrel, gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::fill ( )
inlineoverridevirtual

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

Definition at line 418 of file SiPixelGainCalibHelper.h.

References SiPixelPI::adjustCanvasMargins(), PixelRegions::attachedDets(), PixelRegions::PixelRegionContainers::bookAll(), HltBtagPostValidation_cff::c, svgfig::canvas(), SiPixelPI::checkAnswerOK(), SiPixelPI::displayNotSupported(), Exception, cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >::fetchPayload(), MillePedeFileConverter_cfg::fileName, gainCalibHelper::gainCalibPI::fillTheHisto(), StandaloneTrackerTopology::fromTrackerParametersXMLFile(), contentValuesFiles::fullPath, PixelRegions::IDlabels, cond::payloadInspector::PlotBase::inputParamValues(), PixelPluginsPhase0_cfi::isBarrel, gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::isForHLT_, gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::label_, compareTotals::legend, cond::payloadInspector::PlotImage< PayloadType, cond::payloadInspector::SINGLE_IOV >::m_imageFileName, SiPixelPI::PhaseInfo::pathToTopoXML(), jetsAK4_Puppi_cff::payload, SiPixelPI::phase1size, PixelRegions::PixelIDs, AlCaHLTBitMon_QueryRunRegistry::string, gainCalibHelper::gainCalibPI::t_gain, gainCalibHelper::gainCalibPI::t_pedestal, makeGlobalPositionRcd_cfg::tag, cond::impl::to_string(), and gainCalibHelper::TypeName.

418  {
419  gStyle->SetOptStat("mr");
420 
421  auto tag = cond::payloadInspector::PlotBase::getTag<0>();
422  auto iov = tag.iovs.front();
423 
424  // parse first if log
425  bool setLog(true);
427  auto ip = paramValues.find("SetLog");
428  if (ip != paramValues.end()) {
429  auto answer = ip->second;
430  if (!SiPixelPI::checkAnswerOK(answer, setLog)) {
431  throw cms::Exception(label_)
432  << "\nERROR: " << answer
433  << " is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n";
434  }
435  }
436 
437  std::shared_ptr<PayloadType> payload = this->fetchPayload(std::get<1>(iov));
438 
439  std::vector<uint32_t> detids;
440  payload->getDetIds(detids);
441 
442  float minimum(9999.);
443  float maximum(-9999.);
444 
445  switch (myType) {
446  case gainCalibPI::t_gain:
447  maximum = payload->getGainHigh();
448  minimum = payload->getGainLow();
449  break;
451  maximum = payload->getPedHigh();
452  minimum = payload->getPedLow();
453  break;
454  default:
455  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
456  break;
457  }
458 
459  TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200);
460  if (detids.size() > SiPixelPI::phase1size) {
461  SiPixelPI::displayNotSupported(canvas, detids.size());
463  canvas.SaveAs(fileName.c_str());
464  return false;
465  }
466 
467  canvas.cd();
468 
469  SiPixelPI::PhaseInfo phaseInfo(detids.size());
470  const char* path_toTopologyXML = phaseInfo.pathToTopoXML();
471 
472  TrackerTopology tTopo =
474 
475  auto myPlots = PixelRegions::PixelRegionContainers(&tTopo, phaseInfo.phase());
476  myPlots.bookAll(Form("SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
477  Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
478  Form("# %ss", (isForHLT_ ? "column" : "pixel")),
479  200,
480  minimum,
481  maximum);
482 
483  canvas.Modified();
484 
485  // fill the histograms
486  for (const auto& pixelId : PixelRegions::PixelIDs) {
487  auto wantedDets = PixelRegions::attachedDets(pixelId, &tTopo, phaseInfo.phase());
488  gainCalibPI::fillTheHisto(payload, myPlots.getHistoFromMap(pixelId), myType, wantedDets);
489  }
490 
491  if (setLog) {
492  myPlots.setLogScale();
493  }
494  myPlots.beautify(kBlue, -1);
495  myPlots.draw(canvas, isBarrel, "HIST");
496 
497  TLegend legend = TLegend(0.45, 0.88, 0.91, 0.92);
498  legend.SetHeader(("hash: #bf{" + (std::get<1>(iov)) + "}").c_str(),
499  "C"); // option "C" allows to center the header
500  //legend.AddEntry(h1.get(), ("IOV: " + std::to_string(std::get<0>(iov))).c_str(), "PL");
501  legend.SetLineColor(10);
502  legend.SetTextSize(0.025);
503  legend.Draw("same");
504 
505  unsigned int maxPads = isBarrel ? 4 : 12;
506  for (unsigned int c = 1; c <= maxPads; c++) {
507  canvas.cd(c);
508  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
509  legend.Draw("same");
510  canvas.cd(c)->Update();
511  }
512 
513  myPlots.stats();
514 
515  auto ltx = TLatex();
516  ltx.SetTextFont(62);
517  ltx.SetTextSize(0.05);
518  ltx.SetTextAlign(11);
519 
520  for (unsigned int c = 1; c <= maxPads; c++) {
521  auto index = isBarrel ? c - 1 : c + 3;
522  canvas.cd(c);
523  auto leftX = setLog ? 0. : 0.1;
524  ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX,
525  1 - gPad->GetTopMargin() + 0.01,
526  (PixelRegions::IDlabels.at(index) + ", IOV:" + std::to_string(std::get<0>(iov))).c_str());
527  }
528 
530  canvas.SaveAs(fileName.c_str());
531 
532  return true;
533  }
const std::vector< std::string > IDlabels
std::string to_string(const V &value)
Definition: OMSAccess.h:71
Log< level::Error, false > LogError
bool checkAnswerOK(std::string &answer, bool &result)
static const unsigned int phase1size
constexpr char const * TypeName[2]
const std::vector< PixelId > PixelIDs
static void fillTheHisto(const std::shared_ptr< PayloadType > &payload, std::shared_ptr< TH1F > h1, gainCalibPI::type theType, const std::vector< uint32_t > &wantedIds={})
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
const std::map< std::string, std::string > & inputParamValues() const
void bookAll(std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax)
void displayNotSupported(TCanvas &canv, const unsigned int size)
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
def canvas(sub, attr)
Definition: svgfig.py:482
static const std::vector< uint32_t > attachedDets(const PixelRegions::PixelId theId, const TrackerTopology *trackTopo, const SiPixelPI::phase &ph)
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

Member Data Documentation

◆ isForHLT_

template<bool isBarrel, gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::isForHLT_
protected

◆ label_

template<bool isBarrel, gainCalibPI::type myType, class PayloadType >
std::string gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::label_
protected