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

463  public:
465  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(
466  Form("SiPixelGainCalibration %s Values Per Region %i tag(s)", TypeName[myType], ntags)) {
468 
469  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
470  isForHLT_ = false;
471  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
472  } else {
473  isForHLT_ = true;
474  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 476 of file SiPixelGainCalibHelper.h.

478  {
479  gStyle->SetOptStat("mr");
480 
481  COUT << "ntags: " << ntags << " this->m_plotAnnotations.ntags: " << this->m_plotAnnotations.ntags << std::endl;
482 
483  // trick to deal with the multi-ioved tag and two tag case at the same time
484  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
485  auto tagname1 = cond::payloadInspector::PlotBase::getTag<0>().name;
486  std::string tagname2 = "";
487  auto firstiov = theIOVs.front();
488  std::tuple<cond::Time_t, cond::Hash> lastiov;
489 
490  // we don't support (yet) comparison with more than 2 tags
491  assert(this->m_plotAnnotations.ntags < 3);
492 
493  if (this->m_plotAnnotations.ntags == 2) {
494  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
495  tagname2 = cond::payloadInspector::PlotBase::getTag<1>().name;
496  lastiov = tag2iovs.front();
497  } else {
498  lastiov = theIOVs.back();
499  }
500 
501  // parse first if log
502  bool setLog(true);
504  auto ip = paramValues.find("SetLog");
505  if (ip != paramValues.end()) {
506  auto answer = boost::lexical_cast<std::string>(ip->second);
507  if (!SiPixelPI::checkAnswerOK(answer, setLog)) {
508  throw cms::Exception(label_)
509  << "\nERROR: " << answer
510  << " is not a valid setting for this parameter, please use True,False,1,0,Yes,No \n\n";
511  }
512  }
513 
514  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
515  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
516 
517  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
518  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
519 
520  std::vector<uint32_t> f_detids, l_detids;
521  last_payload->getDetIds(l_detids);
522  first_payload->getDetIds(f_detids);
523 
524  float minimum(9999.);
525  float maximum(-9999.);
526 
527  switch (myType) {
528  case gainCalibPI::t_gain:
529  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
530  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
531  break;
533  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
534  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
535  break;
536  default:
537  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
538  break;
539  }
540 
541  TCanvas canvas("Canv", "Canv", isBarrel ? 1400 : 1800, 1200);
542  if (std::max(l_detids.size(), f_detids.size()) > SiPixelPI::phase1size) {
543  SiPixelPI::displayNotSupported(canvas, std::max(f_detids.size(), l_detids.size()));
545  canvas.SaveAs(fileName.c_str());
546  return false;
547  }
548 
549  canvas.Divide(isBarrel ? 2 : 4, isBarrel ? 2 : 3);
550  canvas.cd();
551 
552  bool is_l_phase0 = (l_detids.size() == SiPixelPI::phase0size);
553  bool is_f_phase0 = (f_detids.size() == SiPixelPI::phase0size);
554 
555  const char* path_toTopologyXML = is_l_phase0 ? "Geometry/TrackerCommonData/data/trackerParameters.xml"
556  : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
557  auto l_tTopo =
559 
560  auto l_myPlots = PixelRegions::PixelRegionContainers(&l_tTopo, !is_l_phase0);
561  l_myPlots.bookAll(
562  Form("Last SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
563  Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
564  Form("# %ss", (isForHLT_ ? "column" : "pixel")),
565  200,
566  minimum,
567  maximum);
568 
569  path_toTopologyXML = is_f_phase0 ? "Geometry/TrackerCommonData/data/trackerParameters.xml"
570  : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
571  auto f_tTopo =
573 
574  auto f_myPlots = PixelRegions::PixelRegionContainers(&f_tTopo, !is_f_phase0);
575  f_myPlots.bookAll(
576  Form("First SiPixel Gain Calibration %s - %s", (isForHLT_ ? "ForHLT" : "Offline"), TypeName[myType]),
577  Form("per %s %s", (isForHLT_ ? "Column" : "Pixel"), TypeName[myType]),
578  Form("# %ss", (isForHLT_ ? "column" : "pixel")),
579  200,
580  minimum,
581  maximum);
582 
583  // fill the histograms
584  for (const auto& pixelId : PixelRegions::PixelIDs) {
585  auto f_wantedDets = PixelRegions::attachedDets(pixelId, &f_tTopo, !is_f_phase0);
586  auto l_wantedDets = PixelRegions::attachedDets(pixelId, &l_tTopo, !is_l_phase0);
587  gainCalibPI::fillTheHisto(first_payload, f_myPlots.getHistoFromMap(pixelId), myType, f_wantedDets);
588  gainCalibPI::fillTheHisto(last_payload, l_myPlots.getHistoFromMap(pixelId), myType, l_wantedDets);
589  }
590 
591  if (setLog) {
592  f_myPlots.setLogScale();
593  l_myPlots.setLogScale();
594  }
595 
596  l_myPlots.beautify(kRed, -1);
597  f_myPlots.beautify(kAzure, -1);
598 
599  l_myPlots.draw(canvas, isBarrel, "HIST", (!is_f_phase0 || !is_l_phase0));
600  f_myPlots.draw(canvas, isBarrel, "HISTsames", (!is_f_phase0 || !is_l_phase0));
601 
602  // rescale the y-axis ranges in order to fit the canvas
603  l_myPlots.rescaleMax(f_myPlots);
604 
605  // done dealing with IOVs
606  auto colorTag = isBarrel ? PixelRegions::L1 : PixelRegions::Rm1l;
607  std::unique_ptr<TLegend> legend;
608  if (this->m_plotAnnotations.ntags == 2) {
609  legend = std::make_unique<TLegend>(0.36, 0.86, 0.94, 0.92);
610  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + tagname2 + "}").c_str(), "F");
611  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + tagname1 + "}").c_str(), "F");
612  legend->SetTextSize(0.024);
613  } else {
614  legend = std::make_unique<TLegend>(0.58, 0.80, 0.90, 0.92);
615  legend->AddEntry(l_myPlots.getHistoFromMap(colorTag).get(), ("#color[2]{" + lastIOVsince + "}").c_str(), "F");
616  legend->AddEntry(f_myPlots.getHistoFromMap(colorTag).get(), ("#color[4]{" + firstIOVsince + "}").c_str(), "F");
617  legend->SetTextSize(0.040);
618  }
619  legend->SetLineColor(10);
620 
621  unsigned int maxPads = isBarrel ? 4 : 12;
622  for (unsigned int c = 1; c <= maxPads; c++) {
623  canvas.cd(c);
624  SiPixelPI::adjustCanvasMargins(canvas.cd(c), 0.06, 0.12, 0.12, 0.05);
625  legend->Draw("same");
626  canvas.cd(c)->Update();
627  }
628 
629  f_myPlots.stats(0);
630  l_myPlots.stats(1);
631 
632  auto ltx = TLatex();
633  ltx.SetTextFont(62);
634  ltx.SetTextSize(0.05);
635  ltx.SetTextAlign(11);
636 
637  for (unsigned int c = 1; c <= maxPads; c++) {
638  auto index = isBarrel ? c - 1 : c + 3;
639  canvas.cd(c);
640  auto leftX = setLog ? 0. : 0.1;
641  ltx.DrawLatexNDC(gPad->GetLeftMargin() + leftX,
642  1 - gPad->GetTopMargin() + 0.01,
643  (PixelRegions::IDlabels.at(index) + " : #color[4]{" + std::to_string(std::get<0>(firstiov)) +
644  "} vs #color[2]{" + std::to_string(std::get<0>(lastiov)) + "}")
645  .c_str());
646  }
647 
649  canvas.SaveAs(fileName.c_str());
650 

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:37
PixelRegions::L1
Definition: PixelRegionContainers.h:27
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:845
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:37
PixelRegions::PixelIDs
const std::vector< PixelId > PixelIDs
Definition: PixelRegionContainers.h:46
min
T min(T a, T b)
Definition: MathUtil.h:58
cond::payloadInspector::PlotAnnotations::ntags
int ntags
Definition: PayloadInspector.h:54
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
PixelRegions::Rm1l
Definition: PixelRegionContainers.h:31
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:832
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
SiPixelPI::displayNotSupported
void displayNotSupported(TCanvas &canv, const unsigned int size)
Definition: SiPixelPayloadInspectorHelper.h:971
SiPixelPI::phase0size
static const unsigned int phase0size
Definition: SiPixelPayloadInspectorHelper.h:40
SiPixelPI::checkAnswerOK
bool checkAnswerOK(std::string &answer, bool &result)
Definition: SiPixelPayloadInspectorHelper.h:998
edm::FileInPath
Definition: FileInPath.h:64
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:653
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:200
cond::payloadInspector::PlotBase::ntags
unsigned int ntags() const
Definition: PayloadInspector.cc:48
PixelRegions::PixelRegionContainers
Definition: PixelRegionContainers.h:160
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
edm::LogError
Definition: MessageLogger.h:183
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
SiPixelPI::phase1size
static const unsigned int phase1size
Definition: SiPixelPayloadInspectorHelper.h:41
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
listHistos.legend
legend
Definition: listHistos.py:41
PixelRegions::IDlabels
const std::vector< std::string > IDlabels
Definition: PixelRegionContainers.h:64
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:42
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
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
PixelRegions::attachedDets
const std::vector< uint32_t > attachedDets(const PixelRegions::PixelId theId, const TrackerTopology *trackTopo, const bool phase1)
Definition: PixelRegionContainers.h:119
cond::payloadInspector::PlotBase::addInputParam
void addInputParam(const std::string &paramName)
Definition: PayloadInspector.cc:35
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:654
cond::payloadInspector::PlotBase::m_plotAnnotations
PlotAnnotations m_plotAnnotations
Definition: PayloadInspector.h:252
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168
SiPixelPI::adjustCanvasMargins
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Definition: SiPixelPayloadInspectorHelper.h:435
gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion::SiPixelGainCalibrationValuesComparisonPerRegion
SiPixelGainCalibrationValuesComparisonPerRegion()
Definition: SiPixelGainCalibHelper.h:462