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

550  public:
552  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(
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";

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

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 = boost::lexical_cast<std::string>(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 

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:782
SiPixelPI::checkAnswerOK
bool checkAnswerOK(std::string &answer, bool &result)
Definition: SiPixelPayloadInspectorHelper.h:809
edm::FileInPath
Definition: FileInPath.h:61
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:738
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:288
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
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:130
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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:56
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:739
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:549