CMS 3D CMS Logo

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

#include <SiPixelGainCalibHelper.h>

Inheritance diagram for gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >:
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags > cond::payloadInspector::PlotImpl< IOV_M, NTAGS > cond::payloadInspector::PlotBase

Public Member Functions

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

bool isForHLT_
 
std::string label_
 
- 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<bool isBarrel, gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType>
class gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >

Definition at line 548 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationValuesComparisonPerRegion()

template<bool isBarrel, gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::SiPixelGainCalibrationValuesComparisonPerRegion ( )
inline

Definition at line 551 of file SiPixelGainCalibHelper.h.

References cond::payloadInspector::PlotBase::addInputParam(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::isForHLT_, and gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::label_.

553  Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) {
555 
556  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
557  isForHLT_ = false;
558  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
559  } else {
560  isForHLT_ = true;
561  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
562  }
563  }
constexpr char const * TypeName[2]
void addInputParam(const std::string &paramName)

Member Function Documentation

◆ fill()

template<bool isBarrel, gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::fill ( )
inlineoverridevirtual

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

Definition at line 565 of file SiPixelGainCalibHelper.h.

References SiPixelPI::adjustCanvasMargins(), cms::cuda::assert(), PixelRegions::attachedDets(), PixelRegions::PixelRegionContainers::bookAll(), HltBtagPostValidation_cff::c, svgfig::canvas(), SiPixelPI::checkAnswerOK(), COUT, SiPixelPI::displayNotSupported(), Exception, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload(), MillePedeFileConverter_cfg::fileName, gainCalibHelper::gainCalibPI::fillTheHisto(), StandaloneTrackerTopology::fromTrackerParametersXMLFile(), contentValuesFiles::fullPath, PixelRegions::IDlabels, cond::payloadInspector::PlotBase::inputParamValues(), PixelPluginsPhase0_cfi::isBarrel, gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::isForHLT_, PixelRegions::L1, gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::label_, compareTotals::legend, 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, cond::payloadInspector::PlotBase::ntags(), SiPixelPI::PhaseInfo::pathToTopoXML(), SiPixelPI::phase1size, PixelRegions::PixelIDs, PixelRegions::Rm1l, AlCaHLTBitMon_QueryRunRegistry::string, gainCalibHelper::gainCalibPI::t_gain, gainCalibHelper::gainCalibPI::t_pedestal, to_string(), and gainCalibHelper::TypeName.

565  {
566  gStyle->SetOptStat("mr");
567 
568  COUT << "ntags: " << ntags << " this->m_plotAnnotations.ntags: " << this->m_plotAnnotations.ntags << std::endl;
569 
570  // trick to deal with the multi-ioved tag and two tag case at the same time
571  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
572  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
573  std::string l_tagname = "";
574  auto firstiov = theIOVs.front();
575  std::tuple<cond::Time_t, cond::Hash> lastiov;
576 
577  // we don't support (yet) comparison with more than 2 tags
578  assert(this->m_plotAnnotations.ntags < 3);
579 
580  if (this->m_plotAnnotations.ntags == 2) {
581  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
582  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
583  lastiov = tag2iovs.front();
584  } else {
585  lastiov = theIOVs.back();
586  }
587 
588  // parse first if log
589  bool setLog(true);
591  auto ip = paramValues.find("SetLog");
592  if (ip != paramValues.end()) {
593  auto answer = ip->second;
594  if (!SiPixelPI::checkAnswerOK(answer, setLog)) {
595  throw cms::Exception(label_)
596  << "\nERROR: " << answer
597  << " is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n";
598  }
599  }
600 
601  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
602  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
603 
604  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
605  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
606 
607  std::vector<uint32_t> f_detids, l_detids;
608  last_payload->getDetIds(l_detids);
609  first_payload->getDetIds(f_detids);
610 
611  float minimum(9999.);
612  float maximum(-9999.);
613 
614  switch (myType) {
615  case gainCalibPI::t_gain:
616  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
617  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
618  break;
620  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
621  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
622  break;
623  default:
624  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
625  break;
626  }
627 
628  TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200);
629  if (std::max(l_detids.size(), f_detids.size()) > SiPixelPI::phase1size) {
630  SiPixelPI::displayNotSupported(canvas, std::max(f_detids.size(), l_detids.size()));
632  canvas.SaveAs(fileName.c_str());
633  return false;
634  }
635 
636  canvas.cd();
637 
638  SiPixelPI::PhaseInfo l_phaseInfo(l_detids.size());
639  SiPixelPI::PhaseInfo f_phaseInfo(f_detids.size());
640  const char* path_toTopologyXML = l_phaseInfo.pathToTopoXML();
641 
642  auto l_tTopo =
644 
645  auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, l_phaseInfo.phase());
646  l_myPlots.bookAll(
647  Form("Last SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
648  Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
649  Form("# %ss", (isForHLT_ ? "column" : "pixel")),
650  200,
651  minimum,
652  maximum);
653 
654  path_toTopologyXML = f_phaseInfo.pathToTopoXML();
655 
656  auto f_tTopo =
658 
659  auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, f_phaseInfo.phase());
660  f_myPlots.bookAll(
661  Form("First SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
662  Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
663  Form("# %ss", (isForHLT_ ? "column" : "pixel")),
664  200,
665  minimum,
666  maximum);
667 
668  // fill the histograms
669  for (const auto& pixelId : PixelRegions::PixelIDs) {
670  auto f_wantedDets = PixelRegions::attachedDets(pixelId, &f_tTopo, f_phaseInfo.phase());
671  auto l_wantedDets = PixelRegions::attachedDets(pixelId, &l_tTopo, l_phaseInfo.phase());
672  gainCalibPI::fillTheHisto(first_payload, f_myPlots.getHistoFromMap(pixelId), myType, f_wantedDets);
673  gainCalibPI::fillTheHisto(last_payload, l_myPlots.getHistoFromMap(pixelId), myType, l_wantedDets);
674  }
675 
676  if (setLog) {
677  f_myPlots.setLogScale();
678  l_myPlots.setLogScale();
679  }
680 
681  l_myPlots.beautify(kRed, -1);
682  f_myPlots.beautify(kAzure, -1);
683 
684  l_myPlots.draw(canvas, isBarrel, "HIST", f_phaseInfo.isPhase1Comparison(l_phaseInfo));
685  f_myPlots.draw(canvas, isBarrel, "HISTsames", f_phaseInfo.isPhase1Comparison(l_phaseInfo));
686 
687  // rescale the y-axis ranges in order to fit the canvas
688  l_myPlots.rescaleMax(f_myPlots);
689 
690  // done dealing with IOVs
691  auto colorTag = isBarrel ? PixelRegions::L1 : PixelRegions::Rm1l;
692  std::unique_ptr<TLegend> legend;
693  if (this->m_plotAnnotations.ntags == 2) {
694  legend = std::make_unique<TLegend>(0.36, 0.86, 0.94, 0.92);
695  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + l_tagname + "}").c_str(), "F");
696  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + f_tagname + "}").c_str(), "F");
697  legend->SetTextSize(0.024);
698  } else {
699  legend = std::make_unique<TLegend>(0.58, 0.80, 0.90, 0.92);
700  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + lastIOVsince + "}").c_str(), "F");
701  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + firstIOVsince + "}").c_str(), "F");
702  legend->SetTextSize(0.040);
703  }
704  legend->SetLineColor(10);
705 
706  unsigned int maxPads = isBarrel ? 4 : 12;
707  for (unsigned int c = 1; c <= maxPads; c++) {
708  canvas.cd(c);
709  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
710  legend->Draw("same");
711  canvas.cd(c)->Update();
712  }
713 
714  f_myPlots.stats(0);
715  l_myPlots.stats(1);
716 
717  auto ltx = TLatex();
718  ltx.SetTextFont(62);
719  ltx.SetTextSize(0.05);
720  ltx.SetTextAlign(11);
721 
722  for (unsigned int c = 1; c <= maxPads; c++) {
723  auto index = isBarrel ? c - 1 : c + 3;
724  canvas.cd(c);
725  auto leftX = setLog ? 0. : 0.1;
726  ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX,
727  1 - gPad->GetTopMargin() + 0.01,
728  (PixelRegions::IDlabels.at(index) + " : #color[4]{" + std::to_string(std::get<0>(firstiov)) +
729  "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) + "}")
730  .c_str());
731  }
732 
734  canvas.SaveAs(fileName.c_str());
735 
736  return true;
737  }
const std::vector< std::string > IDlabels
Log< level::Error, false > LogError
assert(be >=bs)
bool checkAnswerOK(std::string &answer, bool &result)
static std::string to_string(const XMLCh *ch)
static const unsigned int phase1size
constexpr char const * TypeName[2]
const std::vector< PixelId > PixelIDs
#define COUT
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, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::isForHLT_
protected

◆ label_

template<bool isBarrel, gainCalibPI::type myType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags, class PayloadType >
std::string gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::label_
protected