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)
 
std::string data () const
 
cond::persistency::Session dbSession ()
 
bool exec_process (const std::string &connectionString, const std::vector< std::tuple< std::string, cond::Time_t, cond::Time_t >> &tagsWithTimeBoundaries)
 
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 ()
 
boost::python::list inputParams () const
 
const std::map< std::string, std::string > & inputParamValues () const
 
bool isSingleIov () const
 
bool isTwoTags () const
 
unsigned int ntags () const
 
std::string payloadType () const
 
 PlotBase ()
 
bool process (const std::string &connectionString, const boost::python::list &tagsWithTimeBoundaries)
 
void setInputParamValues (const boost::python::dict &values)
 
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 543 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 547 of file SiPixelGainCalibHelper.h.

548  public:
550  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(
551  Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) {
553 
554  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
555  isForHLT_ = false;
556  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
557  } else {
558  isForHLT_ = true;
559  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";

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

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 561 of file SiPixelGainCalibHelper.h.

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

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
gainCalibHelper::gainCalibPI::t_pedestal
Definition: SiPixelGainCalibHelper.h:39
PixelRegions::L1
Definition: PixelRegionContainers.h:32
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::m_imageFileName
std::string m_imageFileName
Definition: PayloadInspector.h:868
SiPixelPI::PhaseInfo::pathToTopoXML
const char * pathToTopoXML()
Definition: SiPixelPayloadInspectorHelper.h:81
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:39
PixelRegions::PixelIDs
const std::vector< PixelId > PixelIDs
Definition: PixelRegionContainers.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
cond::payloadInspector::PlotAnnotations::ntags
int ntags
Definition: PayloadInspector.h:55
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
PixelRegions::Rm1l
Definition: PixelRegionContainers.h:34
cms::cuda::assert
assert(be >=bs)
cond::payloadInspector::PlotBase::inputParamValues
const std::map< std::string, std::string > & inputParamValues() const
Definition: PayloadInspector.cc:139
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::PlotImage
PlotImage(const std::string &title)
Definition: PayloadInspector.h:855
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:990
SiPixelPI::checkAnswerOK
bool checkAnswerOK(std::string &answer, bool &result)
Definition: SiPixelPayloadInspectorHelper.h:1017
edm::FileInPath
Definition: FileInPath.h:64
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:736
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:286
PixelRegions::attachedDets
static const std::vector< uint32_t > attachedDets(const PixelRegions::PixelId theId, const TrackerTopology *trackTopo, const SiPixelPI::phase &ph)
Definition: PixelRegionContainers.h:187
cond::payloadInspector::PlotBase::ntags
unsigned int ntags() const
Definition: PayloadInspector.cc:48
PixelRegions::PixelRegionContainers
Definition: PixelRegionContainers.h:238
submit.answer
answer
Definition: submit.py:45
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
SiPixelPI::phase1size
static const unsigned int phase1size
Definition: SiPixelPayloadInspectorHelper.h:43
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:863
listHistos.legend
legend
Definition: listHistos.py:41
PixelRegions::IDlabels
const std::vector< std::string > IDlabels
Definition: PixelRegionContainers.h:62
SiPixelPI::PhaseInfo
Definition: SiPixelPayloadInspectorHelper.h:48
gainCalibHelper::gainCalibPI::fillTheHisto
static void fillTheHisto(const std::shared_ptr< PayloadType > &payload, std::shared_ptr< TH1F > h1, gainCalibPI::type theType, const std::vector< uint32_t > &wantedIds={})
Definition: SiPixelGainCalibHelper.h:128
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
COUT
#define COUT
Definition: PVValidationHelpers.h:13
Exception
Definition: hltDiff.cc:246
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
cond::payloadInspector::PlotBase::addInputParam
void addInputParam(const std::string &paramName)
Definition: PayloadInspector.cc:35
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:737
cond::payloadInspector::PlotBase::m_plotAnnotations
PlotAnnotations m_plotAnnotations
Definition: PayloadInspector.h:276
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168
PixelRegions::PixelRegionContainers::bookAll
void bookAll(std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax)
Definition: PixelRegionContainers.h:263
SiPixelPI::adjustCanvasMargins
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Definition: SiPixelPayloadInspectorHelper.h:505
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::SiPixelGainCalibrationValuesComparisonPerRegion
SiPixelGainCalibrationValuesComparisonPerRegion()
Definition: SiPixelGainCalibHelper.h:547