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

549  public:
551  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(
552  Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) {
554 
555  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
556  isForHLT_ = false;
557  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
558  } else {
559  isForHLT_ = true;
560  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 562 of file SiPixelGainCalibHelper.h.

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

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:40
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:910
SiPixelPI::PhaseInfo::pathToTopoXML
const char * pathToTopoXML()
Definition: SiPixelPayloadInspectorHelper.h:81
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:40
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:56
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:897
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:781
SiPixelPI::checkAnswerOK
bool checkAnswerOK(std::string &answer, bool &result)
Definition: SiPixelPayloadInspectorHelper.h:808
edm::FileInPath
Definition: FileInPath.h:64
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:737
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:287
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:905
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:129
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
COUT
#define COUT
Definition: PVValidationHelpers.h:13
Exception
Definition: hltDiff.cc:245
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
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:738
cond::payloadInspector::PlotBase::m_plotAnnotations
PlotAnnotations m_plotAnnotations
Definition: PayloadInspector.h:282
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:508
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::SiPixelGainCalibrationValuesComparisonPerRegion
SiPixelGainCalibrationValuesComparisonPerRegion()
Definition: SiPixelGainCalibHelper.h:548