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

Definition at line 1550 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 1554 of file SiPixelGainCalibHelper.h.

1562  public:
1564  : cond::payloadInspector::PlotImage<PayloadType, nIOVs, ntags>(

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

1566  {
1567  isForHLT_ = false;
1568  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
1569  } else {
1570  isForHLT_ = true;
1571  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
1572  }
1573  }
1574 
1575  bool fill() override {
1576  gStyle->SetPaintTextFormat(".3f");
1577 
1578  // trick to deal with the multi-ioved tag and two tag case at the same time
1579  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
1580  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
1581  std::string l_tagname = "";
1582  auto firstiov = theIOVs.front();
1583  std::tuple<cond::Time_t, cond::Hash> lastiov;
1584 
1585  // we don't support (yet) comparison with more than 2 tags
1586  assert(this->m_plotAnnotations.ntags < 3);
1587 
1588  if (this->m_plotAnnotations.ntags == 2) {
1589  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
1590  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
1591  lastiov = tag2iovs.front();
1592  } else {
1593  lastiov = theIOVs.back();
1594  }
1595 
1596  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1597  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1598 
1599  std::map<uint32_t, float> f_GainsMap_;
1600  gainCalibPI::fillThePerModuleMap(first_payload, f_GainsMap_, myType);
1601 
1602  std::map<uint32_t, float> l_GainsMap_;
1603  gainCalibPI::fillThePerModuleMap(last_payload, l_GainsMap_, myType);
1604 
1605  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1606  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1607 
1608  TCanvas canvas("Comparison", "Comparison", 1600, 800);
1609 
1610  SiPixelPI::PhaseInfo f_phaseInfo(f_GainsMap_.size());
1611  SiPixelPI::PhaseInfo l_phaseInfo(l_GainsMap_.size());
1612 
1613  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> FirstGains_spectraByRegion;
1614  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> LastGains_spectraByRegion;
1615  std::shared_ptr<TH1F> summaryFirst;
1616  std::shared_ptr<TH1F> summaryLast;
1617 
1618  float minimum(9999.);
1619  float maximum(-9999.);
1620 
1621  switch (myType) {
1622  case gainCalibPI::t_gain:
1623  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1624  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
1625  break;
1627  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1628  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
1629  break;
1630  default:
1631  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
1632  break;
1633  }
1634 
1635  // book the intermediate histograms
1636  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1637  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1639 
1640  FirstGains_spectraByRegion[part] =
1641  std::make_shared<TH1F>(Form("hfirstGains_%s", s_part.c_str()),
1642  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1643  200,
1644  minimum,
1645  maximum);
1646 
1647  LastGains_spectraByRegion[part] =
1648  std::make_shared<TH1F>(Form("hlastGains_%s", s_part.c_str()),
1649  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1650  200,
1651  minimum,
1652  maximum);
1653  }
1654 
1655  summaryFirst = std::make_shared<TH1F>("first Summary",
1656  Form("Summary of #LT per %s %s #GT;;average %s",
1657  (isForHLT_ ? "Column" : "Pixel"),
1658  TypeName[myType],
1659  TypeName[myType]),
1660  FirstGains_spectraByRegion.size(),
1661  0,
1662  FirstGains_spectraByRegion.size());
1663 
1664  summaryLast = std::make_shared<TH1F>("last Summary",
1665  Form("Summary of #LT per %s %s #GT;;average %s",
1666  (isForHLT_ ? "Column" : "Pixel"),
1667  TypeName[myType],
1668  TypeName[myType]),
1669  LastGains_spectraByRegion.size(),
1670  0,
1671  LastGains_spectraByRegion.size());
1672 
1673  // deal with first IOV
1674  const char* path_toTopologyXML = f_phaseInfo.pathToTopoXML();
1675 
1676  auto f_tTopo =
1678 
1679  // -------------------------------------------------------------------
1680  // loop on the first Gains Map
1681  // -------------------------------------------------------------------
1682  for (const auto& it : f_GainsMap_) {
1683  if (DetId(it.first).det() != DetId::Tracker) {
1684  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1685  return false;
1686  }
1687 
1688  SiPixelPI::topolInfo t_info_fromXML;
1689  t_info_fromXML.init();
1690  DetId detid(it.first);
1691  t_info_fromXML.fillGeometryInfo(detid, f_tTopo, f_phaseInfo.phase());
1692 
1693  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1694  FirstGains_spectraByRegion[thePart]->Fill(it.second);
1695  } // ends loop on the vector of error transforms
1696 
1697  // deal with last IOV
1698  path_toTopologyXML = l_phaseInfo.pathToTopoXML();
1699 
1700  auto l_tTopo =
1702 
1703  // -------------------------------------------------------------------
1704  // loop on the second Gains Map
1705  // -------------------------------------------------------------------
1706  for (const auto& it : l_GainsMap_) {
1707  if (DetId(it.first).det() != DetId::Tracker) {
1708  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1709  return false;
1710  }
1711 
1712  SiPixelPI::topolInfo t_info_fromXML;
1713  t_info_fromXML.init();
1714  DetId detid(it.first);
1715  t_info_fromXML.fillGeometryInfo(detid, l_tTopo, l_phaseInfo.phase());
1716 
1717  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1718  LastGains_spectraByRegion[thePart]->Fill(it.second);
1719  } // ends loop on the vector of error transforms
1720 
1721  // fill the summary plots
1722  int bin = 1;
1723  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1724  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1725 
1726  summaryFirst->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1727  // avoid filling the histogram with numerical noise
1728  float f_mean =
1729  FirstGains_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstGains_spectraByRegion[part]->GetMean() : 0.;
1730  summaryFirst->SetBinContent(bin, f_mean);
1731  //summaryFirst->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1732 
1733  summaryLast->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1734  // avoid filling the histogram with numerical noise
1735  float l_mean =
1736  LastGains_spectraByRegion[part]->GetMean() > 10.e-6 ? LastGains_spectraByRegion[part]->GetMean() : 0.;
1737  summaryLast->SetBinContent(bin, l_mean);
1738  //summaryLast->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1739  bin++;
1740  }
1741 
1742  SiPixelPI::makeNicePlotStyle(summaryFirst.get()); //, kBlue);
1743  summaryFirst->SetMarkerColor(kRed);
1744  summaryFirst->GetXaxis()->LabelsOption("v");
1745  summaryFirst->GetXaxis()->SetLabelSize(0.05);
1746  summaryFirst->GetYaxis()->SetTitleOffset(0.9);
1747 
1748  SiPixelPI::makeNicePlotStyle(summaryLast.get()); //, kRed);
1749  summaryLast->SetMarkerColor(kBlue);
1750  summaryLast->GetYaxis()->SetTitleOffset(0.9);
1751  summaryLast->GetXaxis()->LabelsOption("v");
1752  summaryLast->GetXaxis()->SetLabelSize(0.05);
1753 
1754  canvas.cd()->SetGridy();
1755 
1756  SiPixelPI::adjustCanvasMargins(canvas.cd(), -1, 0.18, 0.11, 0.02);
1757  canvas.Modified();
1758 
1759  summaryFirst->SetFillColor(kRed);
1760  summaryLast->SetFillColor(kBlue);
1761 
1762  summaryFirst->SetBarWidth(0.45);
1763  summaryFirst->SetBarOffset(0.1);
1764 
1765  summaryLast->SetBarWidth(0.4);
1766  summaryLast->SetBarOffset(0.55);
1767 
1768  summaryLast->SetMarkerSize(1.2);
1769  summaryFirst->SetMarkerSize(1.2);
1770 
1771  float max = (summaryFirst->GetMaximum() > summaryLast->GetMaximum()) ? summaryFirst->GetMaximum()
1772  : summaryLast->GetMaximum();
1773 
1774  summaryFirst->GetYaxis()->SetRangeUser(0., std::max(0., max * 1.40));
1775 
1776  summaryFirst->Draw("b text0");
1777  summaryLast->Draw("b text0 same");
1778 
1779  TLegend legend = TLegend(0.52, 0.80, 0.98, 0.9);
1780  legend.SetHeader(Form("#LT %s #GT value comparison", TypeName[myType]),
1781  "C"); // option "C" allows to center the header
1782 
1783  legend.SetHeader("#mu_{H} value comparison", "C"); // option "C" allows to center the header
1784  std::string l_tagOrHash, f_tagOrHash;
1785  if (this->m_plotAnnotations.ntags == 2) {
1786  l_tagOrHash = l_tagname;
1787  f_tagOrHash = f_tagname;
1788  } else {
1789  l_tagOrHash = std::get<1>(lastiov);
1790  f_tagOrHash = std::get<1>(firstiov);
1791  }
1792 
1793  legend.AddEntry(
1794  summaryLast.get(),
1795  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(lastiov)) + "} | #color[4]{" + l_tagOrHash + "}").c_str(),
1796  "F");
1797  legend.AddEntry(
1798  summaryFirst.get(),
1799  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(firstiov)) + "} | #color[2]{" + f_tagOrHash + "}").c_str(),

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

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
gainCalibHelper::gainCalibPI::t_pedestal
Definition: SiPixelGainCalibHelper.h:40
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:40
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
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
SiPixelPI::getStringFromRegionEnum
std::string getStringFromRegionEnum(SiPixelPI::regions e)
Definition: SiPixelPayloadInspectorHelper.h:595
SiPixelPI::topolInfo::fillGeometryInfo
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
Definition: SiPixelPayloadInspectorHelper.h:707
cms::cuda::assert
assert(be >=bs)
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::PlotImage
PlotImage(const std::string &title)
Definition: PayloadInspector.h:897
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::fill
bool fill() override
Definition: SiPixelGainCalibHelper.h:1566
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:1803
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
part
part
Definition: HCALResponse.h:20
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:1802
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:287
cond::payloadInspector::PlotBase::ntags
unsigned int ntags() const
Definition: PayloadInspector.cc:48
SiPixelPI::BPixL1o
Definition: SiPixelPayloadInspectorHelper.h:577
SiPixelPI::topolInfo::filterThePartition
SiPixelPI::regions filterThePartition()
Definition: SiPixelPayloadInspectorHelper.h:729
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::SiPixelGainCalibrationByRegionComparisonBase
SiPixelGainCalibrationByRegionComparisonBase()
Definition: SiPixelGainCalibHelper.h:1554
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
gainCalibHelper::gainCalibPI::fillThePerModuleMap
static void fillThePerModuleMap(const std::shared_ptr< PayloadType > &payload, AvgMap &map, gainCalibPI::type theType)
Definition: SiPixelGainCalibHelper.h:186
DetId::Tracker
Definition: DetId.h:25
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
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
SiPixelPI::PhaseInfo
Definition: SiPixelPayloadInspectorHelper.h:48
SiPixelPI::regions
regions
Definition: SiPixelPayloadInspectorHelper.h:576
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelPI::NUM_OF_REGIONS
Definition: SiPixelPayloadInspectorHelper.h:591
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
SiPixelPI::topolInfo
Definition: SiPixelPayloadInspectorHelper.h:657
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:548
SiPixelPI::topolInfo::init
void init()
Definition: SiPixelPayloadInspectorHelper.h:685
cond::payloadInspector::PlotBase::m_plotAnnotations
PlotAnnotations m_plotAnnotations
Definition: PayloadInspector.h:282
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:508