CMS 3D CMS Logo

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

#include <SiPixelGainCalibHelper.h>

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

Public Member Functions

bool fill () override
 
 SiPixelGainCalibrationByRegionComparisonBase ()
 
- 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<gainCalibPI::type myType, class PayloadType, cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
class gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >

Definition at line 1495 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationByRegionComparisonBase()

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

Definition at line 1498 of file SiPixelGainCalibHelper.h.

References gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::isForHLT_, and gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::label_.

1500  Form("SiPixelGainCalibration %s Comparison by Region", TypeName[myType])) {
1501  if constexpr (std::is_same_v<PayloadType, SiPixelGainCalibrationOffline>) {
1502  isForHLT_ = false;
1503  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
1504  } else {
1505  isForHLT_ = true;
1506  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
1507  }
1508  }
constexpr char const * TypeName[2]

Member Function Documentation

◆ fill()

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

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

Definition at line 1510 of file SiPixelGainCalibHelper.h.

References SiPixelPI::adjustCanvasMargins(), cms::cuda::assert(), newFWLiteAna::bin, SiPixelPI::BPixL1o, svgfig::canvas(), DetId::det(), cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::fetchPayload(), MillePedeFileConverter_cfg::fileName, SiPixelPI::topolInfo::fillGeometryInfo(), gainCalibHelper::gainCalibPI::fillThePerModuleMap(), SiPixelPI::topolInfo::filterThePartition(), StandaloneTrackerTopology::fromTrackerParametersXMLFile(), contentValuesFiles::fullPath, SiPixelPI::getStringFromRegionEnum(), SiPixelPI::topolInfo::init(), gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::isForHLT_, gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::label_, compareTotals::legend, cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::m_imageFileName, cond::payloadInspector::PlotBase::m_plotAnnotations, SiPixelPI::makeNicePlotStyle(), SiStripPI::max, SiStripPI::min, Skims_PA_cff::name, cond::payloadInspector::PlotAnnotations::ntags, SiPixelPI::NUM_OF_REGIONS, AlCaHLTBitMon_QueryRunRegistry::string, gainCalibHelper::gainCalibPI::t_gain, gainCalibHelper::gainCalibPI::t_pedestal, to_string(), DetId::Tracker, and gainCalibHelper::TypeName.

1510  {
1511  gStyle->SetPaintTextFormat(".3f");
1512 
1513  // trick to deal with the multi-ioved tag and two tag case at the same time
1514  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
1515  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
1516  std::string l_tagname = "";
1517  auto firstiov = theIOVs.front();
1518  std::tuple<cond::Time_t, cond::Hash> lastiov;
1519 
1520  // we don't support (yet) comparison with more than 2 tags
1521  assert(this->m_plotAnnotations.ntags < 3);
1522 
1523  if (this->m_plotAnnotations.ntags == 2) {
1524  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
1525  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
1526  lastiov = tag2iovs.front();
1527  } else {
1528  lastiov = theIOVs.back();
1529  }
1530 
1531  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1532  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1533 
1534  std::map<uint32_t, float> f_GainsMap_;
1535  gainCalibPI::fillThePerModuleMap(first_payload, f_GainsMap_, myType);
1536 
1537  std::map<uint32_t, float> l_GainsMap_;
1538  gainCalibPI::fillThePerModuleMap(last_payload, l_GainsMap_, myType);
1539 
1540  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1541  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1542 
1543  TCanvas canvas("Comparison", "Comparison", 1600, 800);
1544 
1545  SiPixelPI::PhaseInfo f_phaseInfo(f_GainsMap_.size());
1546  SiPixelPI::PhaseInfo l_phaseInfo(l_GainsMap_.size());
1547 
1548  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> FirstGains_spectraByRegion;
1549  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> LastGains_spectraByRegion;
1550  std::shared_ptr<TH1F> summaryFirst;
1551  std::shared_ptr<TH1F> summaryLast;
1552 
1553  float minimum(9999.);
1554  float maximum(-9999.);
1555 
1556  switch (myType) {
1557  case gainCalibPI::t_gain:
1558  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1559  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
1560  break;
1562  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1563  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
1564  break;
1565  default:
1566  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
1567  break;
1568  }
1569 
1570  // book the intermediate histograms
1571  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1572  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1574 
1575  FirstGains_spectraByRegion[part] =
1576  std::make_shared<TH1F>(Form("hfirstGains_%s", s_part.c_str()),
1577  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1578  200,
1579  minimum,
1580  maximum);
1581 
1582  LastGains_spectraByRegion[part] =
1583  std::make_shared<TH1F>(Form("hlastGains_%s", s_part.c_str()),
1584  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1585  200,
1586  minimum,
1587  maximum);
1588  }
1589 
1590  summaryFirst = std::make_shared<TH1F>("first Summary",
1591  Form("Summary of #LT per %s %s #GT;;average %s",
1592  (isForHLT_ ? "Column" : "Pixel"),
1593  TypeName[myType],
1594  TypeName[myType]),
1595  FirstGains_spectraByRegion.size(),
1596  0,
1597  FirstGains_spectraByRegion.size());
1598 
1599  summaryLast = std::make_shared<TH1F>("last Summary",
1600  Form("Summary of #LT per %s %s #GT;;average %s",
1601  (isForHLT_ ? "Column" : "Pixel"),
1602  TypeName[myType],
1603  TypeName[myType]),
1604  LastGains_spectraByRegion.size(),
1605  0,
1606  LastGains_spectraByRegion.size());
1607 
1608  // deal with first IOV
1609  const char* path_toTopologyXML = f_phaseInfo.pathToTopoXML();
1610 
1611  auto f_tTopo =
1613 
1614  // -------------------------------------------------------------------
1615  // loop on the first Gains Map
1616  // -------------------------------------------------------------------
1617  for (const auto& it : f_GainsMap_) {
1618  if (DetId(it.first).det() != DetId::Tracker) {
1619  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1620  return false;
1621  }
1622 
1623  SiPixelPI::topolInfo t_info_fromXML;
1624  t_info_fromXML.init();
1625  DetId detid(it.first);
1626  t_info_fromXML.fillGeometryInfo(detid, f_tTopo, f_phaseInfo.phase());
1627 
1628  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1629  FirstGains_spectraByRegion[thePart]->Fill(it.second);
1630  } // ends loop on the vector of error transforms
1631 
1632  // deal with last IOV
1633  path_toTopologyXML = l_phaseInfo.pathToTopoXML();
1634 
1635  auto l_tTopo =
1637 
1638  // -------------------------------------------------------------------
1639  // loop on the second Gains Map
1640  // -------------------------------------------------------------------
1641  for (const auto& it : l_GainsMap_) {
1642  if (DetId(it.first).det() != DetId::Tracker) {
1643  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1644  return false;
1645  }
1646 
1647  SiPixelPI::topolInfo t_info_fromXML;
1648  t_info_fromXML.init();
1649  DetId detid(it.first);
1650  t_info_fromXML.fillGeometryInfo(detid, l_tTopo, l_phaseInfo.phase());
1651 
1652  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1653  LastGains_spectraByRegion[thePart]->Fill(it.second);
1654  } // ends loop on the vector of error transforms
1655 
1656  // fill the summary plots
1657  int bin = 1;
1658  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1659  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1660 
1661  summaryFirst->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1662  // avoid filling the histogram with numerical noise
1663  float f_mean =
1664  FirstGains_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstGains_spectraByRegion[part]->GetMean() : 0.;
1665  summaryFirst->SetBinContent(bin, f_mean);
1666  //summaryFirst->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1667 
1668  summaryLast->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1669  // avoid filling the histogram with numerical noise
1670  float l_mean =
1671  LastGains_spectraByRegion[part]->GetMean() > 10.e-6 ? LastGains_spectraByRegion[part]->GetMean() : 0.;
1672  summaryLast->SetBinContent(bin, l_mean);
1673  //summaryLast->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1674  bin++;
1675  }
1676 
1677  SiPixelPI::makeNicePlotStyle(summaryFirst.get()); //, kBlue);
1678  summaryFirst->SetMarkerColor(kRed);
1679  summaryFirst->GetXaxis()->LabelsOption("v");
1680  summaryFirst->GetXaxis()->SetLabelSize(0.05);
1681  summaryFirst->GetYaxis()->SetTitleOffset(0.9);
1682 
1683  SiPixelPI::makeNicePlotStyle(summaryLast.get()); //, kRed);
1684  summaryLast->SetMarkerColor(kBlue);
1685  summaryLast->GetYaxis()->SetTitleOffset(0.9);
1686  summaryLast->GetXaxis()->LabelsOption("v");
1687  summaryLast->GetXaxis()->SetLabelSize(0.05);
1688 
1689  canvas.cd()->SetGridy();
1690 
1691  SiPixelPI::adjustCanvasMargins(canvas.cd(), -1, 0.18, 0.11, 0.02);
1692  canvas.Modified();
1693 
1694  summaryFirst->SetFillColor(kRed);
1695  summaryLast->SetFillColor(kBlue);
1696 
1697  summaryFirst->SetBarWidth(0.45);
1698  summaryFirst->SetBarOffset(0.1);
1699 
1700  summaryLast->SetBarWidth(0.4);
1701  summaryLast->SetBarOffset(0.55);
1702 
1703  summaryLast->SetMarkerSize(1.2);
1704  summaryFirst->SetMarkerSize(1.2);
1705 
1706  float max = (summaryFirst->GetMaximum() > summaryLast->GetMaximum()) ? summaryFirst->GetMaximum()
1707  : summaryLast->GetMaximum();
1708 
1709  summaryFirst->GetYaxis()->SetRangeUser(0., std::max(0., max * 1.40));
1710 
1711  summaryFirst->Draw("b text0");
1712  summaryLast->Draw("b text0 same");
1713 
1714  TLegend legend = TLegend(0.52, 0.80, 0.98, 0.9);
1715  legend.SetHeader(Form("#LT %s #GT value comparison", TypeName[myType]),
1716  "C"); // option "C" allows to center the header
1717 
1718  legend.SetHeader("#mu_{H} value comparison", "C"); // option "C" allows to center the header
1719  std::string l_tagOrHash, f_tagOrHash;
1720  if (this->m_plotAnnotations.ntags == 2) {
1721  l_tagOrHash = l_tagname;
1722  f_tagOrHash = f_tagname;
1723  } else {
1724  l_tagOrHash = std::get<1>(lastiov);
1725  f_tagOrHash = std::get<1>(firstiov);
1726  }
1727 
1728  legend.AddEntry(
1729  summaryLast.get(),
1730  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(lastiov)) + "} | #color[4]{" + l_tagOrHash + "}").c_str(),
1731  "F");
1732  legend.AddEntry(
1733  summaryFirst.get(),
1734  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(firstiov)) + "} | #color[2]{" + f_tagOrHash + "}").c_str(),
1735  "F");
1736 
1737  legend.SetTextSize(0.025);
1738  legend.Draw("same");
1739 
1741  canvas.SaveAs(fileName.c_str());
1742  return true;
1743  }
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
Log< level::Error, false > LogError
assert(be >=bs)
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
static std::string to_string(const XMLCh *ch)
static void fillThePerModuleMap(const std::shared_ptr< PayloadType > &payload, AvgMap &map, gainCalibPI::type theType)
SiPixelPI::regions filterThePartition()
constexpr char const * TypeName[2]
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Definition: DetId.h:17
void makeNicePlotStyle(TH1 *hist)
part
Definition: HCALResponse.h:20
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
def canvas(sub, attr)
Definition: svgfig.py:482
std::string getStringFromRegionEnum(SiPixelPI::regions e)
Log< level::Warning, false > LogWarning
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)

Member Data Documentation

◆ isForHLT_

template<gainCalibPI::type myType, class PayloadType , cond::payloadInspector::IOVMultiplicity nIOVs, int ntags>
bool gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType, nIOVs, ntags >::isForHLT_
protected

◆ label_

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