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

1610  public:
1612  : 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 1614 of file SiPixelGainCalibHelper.h.

1614  {
1615  isForHLT_ = false;
1616  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
1617  } else {
1618  isForHLT_ = true;
1619  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
1620  }
1621  }
1622 
1623  bool fill() override {
1624  gStyle->SetPaintTextFormat(".3f");
1625 
1626  // trick to deal with the multi-ioved tag and two tag case at the same time
1627  auto theIOVs = cond::payloadInspector::PlotBase::getTag<0>().iovs;
1628  auto f_tagname = cond::payloadInspector::PlotBase::getTag<0>().name;
1629  std::string l_tagname = "";
1630  auto firstiov = theIOVs.front();
1631  std::tuple<cond::Time_t, cond::Hash> lastiov;
1632 
1633  // we don't support (yet) comparison with more than 2 tags
1634  assert(this->m_plotAnnotations.ntags < 3);
1635 
1636  if (this->m_plotAnnotations.ntags == 2) {
1637  auto tag2iovs = cond::payloadInspector::PlotBase::getTag<1>().iovs;
1638  l_tagname = cond::payloadInspector::PlotBase::getTag<1>().name;
1639  lastiov = tag2iovs.front();
1640  } else {
1641  lastiov = theIOVs.back();
1642  }
1643 
1644  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1645  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1646 
1647  std::map<uint32_t, float> f_GainsMap_;
1648  gainCalibPI::fillThePerModuleMap(first_payload, f_GainsMap_, myType);
1649 
1650  std::map<uint32_t, float> l_GainsMap_;
1651  gainCalibPI::fillThePerModuleMap(last_payload, l_GainsMap_, myType);
1652 
1653  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1654  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1655 
1656  TCanvas canvas("Comparison", "Comparison", 1600, 800);
1657 
1658  SiPixelPI::PhaseInfo f_phaseInfo(f_GainsMap_.size());
1659  SiPixelPI::PhaseInfo l_phaseInfo(l_GainsMap_.size());
1660 
1661  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> FirstGains_spectraByRegion;
1662  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> LastGains_spectraByRegion;
1663  std::shared_ptr<TH1F> summaryFirst;
1664  std::shared_ptr<TH1F> summaryLast;
1665 
1666  float minimum(9999.);
1667  float maximum(-9999.);
1668 
1669  switch (myType) {
1670  case gainCalibPI::t_gain:
1671  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1672  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
1673  break;
1675  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1676  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
1677  break;
1678  default:
1679  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
1680  break;
1681  }
1682 
1683  // book the intermediate histograms
1684  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1685  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1687 
1688  FirstGains_spectraByRegion[part] =
1689  std::make_shared<TH1F>(Form("hfirstGains_%s", s_part.c_str()),
1690  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1691  200,
1692  minimum,
1693  maximum);
1694 
1695  LastGains_spectraByRegion[part] =
1696  std::make_shared<TH1F>(Form("hlastGains_%s", s_part.c_str()),
1697  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1698  200,
1699  minimum,
1700  maximum);
1701  }
1702 
1703  summaryFirst = std::make_shared<TH1F>("first Summary",
1704  Form("Summary of #LT per %s %s #GT;;average %s",
1705  (isForHLT_ ? "Column" : "Pixel"),
1706  TypeName[myType],
1707  TypeName[myType]),
1708  FirstGains_spectraByRegion.size(),
1709  0,
1710  FirstGains_spectraByRegion.size());
1711 
1712  summaryLast = std::make_shared<TH1F>("last Summary",
1713  Form("Summary of #LT per %s %s #GT;;average %s",
1714  (isForHLT_ ? "Column" : "Pixel"),
1715  TypeName[myType],
1716  TypeName[myType]),
1717  LastGains_spectraByRegion.size(),
1718  0,
1719  LastGains_spectraByRegion.size());
1720 
1721  // deal with first IOV
1722  const char* path_toTopologyXML = f_phaseInfo.pathToTopoXML();
1723 
1724  auto f_tTopo =
1726 
1727  // -------------------------------------------------------------------
1728  // loop on the first Gains Map
1729  // -------------------------------------------------------------------
1730  for (const auto& it : f_GainsMap_) {
1731  if (DetId(it.first).det() != DetId::Tracker) {
1732  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1733  return false;
1734  }
1735 
1736  SiPixelPI::topolInfo t_info_fromXML;
1737  t_info_fromXML.init();
1738  DetId detid(it.first);
1739  t_info_fromXML.fillGeometryInfo(detid, f_tTopo, f_phaseInfo.phase());
1740 
1741  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1742  FirstGains_spectraByRegion[thePart]->Fill(it.second);
1743  } // ends loop on the vector of error transforms
1744 
1745  // deal with last IOV
1746  path_toTopologyXML = l_phaseInfo.pathToTopoXML();
1747 
1748  auto l_tTopo =
1750 
1751  // -------------------------------------------------------------------
1752  // loop on the second Gains Map
1753  // -------------------------------------------------------------------
1754  for (const auto& it : l_GainsMap_) {
1755  if (DetId(it.first).det() != DetId::Tracker) {
1756  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1757  return false;
1758  }
1759 
1760  SiPixelPI::topolInfo t_info_fromXML;
1761  t_info_fromXML.init();
1762  DetId detid(it.first);
1763  t_info_fromXML.fillGeometryInfo(detid, l_tTopo, l_phaseInfo.phase());
1764 
1765  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1766  LastGains_spectraByRegion[thePart]->Fill(it.second);
1767  } // ends loop on the vector of error transforms
1768 
1769  // fill the summary plots
1770  int bin = 1;
1771  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1772  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1773 
1774  summaryFirst->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1775  // avoid filling the histogram with numerical noise
1776  float f_mean =
1777  FirstGains_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstGains_spectraByRegion[part]->GetMean() : 0.;
1778  summaryFirst->SetBinContent(bin, f_mean);
1779  //summaryFirst->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1780 
1781  summaryLast->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1782  // avoid filling the histogram with numerical noise
1783  float l_mean =
1784  LastGains_spectraByRegion[part]->GetMean() > 10.e-6 ? LastGains_spectraByRegion[part]->GetMean() : 0.;
1785  summaryLast->SetBinContent(bin, l_mean);
1786  //summaryLast->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1787  bin++;
1788  }
1789 
1790  SiPixelPI::makeNicePlotStyle(summaryFirst.get()); //, kBlue);
1791  summaryFirst->SetMarkerColor(kRed);
1792  summaryFirst->GetXaxis()->LabelsOption("v");
1793  summaryFirst->GetXaxis()->SetLabelSize(0.05);
1794  summaryFirst->GetYaxis()->SetTitleOffset(0.9);
1795 
1796  SiPixelPI::makeNicePlotStyle(summaryLast.get()); //, kRed);
1797  summaryLast->SetMarkerColor(kBlue);
1798  summaryLast->GetYaxis()->SetTitleOffset(0.9);
1799  summaryLast->GetXaxis()->LabelsOption("v");
1800  summaryLast->GetXaxis()->SetLabelSize(0.05);
1801 
1802  canvas.cd()->SetGridy();
1803 
1804  SiPixelPI::adjustCanvasMargins(canvas.cd(), -1, 0.18, 0.11, 0.02);
1805  canvas.Modified();
1806 
1807  summaryFirst->SetFillColor(kRed);
1808  summaryLast->SetFillColor(kBlue);
1809 
1810  summaryFirst->SetBarWidth(0.45);
1811  summaryFirst->SetBarOffset(0.1);
1812 
1813  summaryLast->SetBarWidth(0.4);
1814  summaryLast->SetBarOffset(0.55);
1815 
1816  summaryLast->SetMarkerSize(1.2);
1817  summaryFirst->SetMarkerSize(1.2);
1818 
1819  float max = (summaryFirst->GetMaximum() > summaryLast->GetMaximum()) ? summaryFirst->GetMaximum()
1820  : summaryLast->GetMaximum();
1821 
1822  summaryFirst->GetYaxis()->SetRangeUser(0., std::max(0., max * 1.40));
1823 
1824  summaryFirst->Draw("b text0");
1825  summaryLast->Draw("b text0 same");
1826 
1827  TLegend legend = TLegend(0.52, 0.80, 0.98, 0.9);
1828  legend.SetHeader(Form("#LT %s #GT value comparison", TypeName[myType]),
1829  "C"); // option "C" allows to center the header
1830 
1831  legend.SetHeader("#mu_{H} value comparison", "C"); // option "C" allows to center the header
1832  std::string l_tagOrHash, f_tagOrHash;
1833  if (this->m_plotAnnotations.ntags == 2) {
1834  l_tagOrHash = l_tagname;
1835  f_tagOrHash = f_tagname;
1836  } else {
1837  l_tagOrHash = std::get<1>(lastiov);
1838  f_tagOrHash = std::get<1>(firstiov);
1839  }
1840 
1841  legend.AddEntry(
1842  summaryLast.get(),
1843  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(lastiov)) + "} | #color[4]{" + l_tagOrHash + "}").c_str(),
1844  "F");
1845  legend.AddEntry(
1846  summaryFirst.get(),
1847  ("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:39
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:39
min
T min(T a, T b)
Definition: MathUtil.h:58
cond::payloadInspector::PlotAnnotations::ntags
int ntags
Definition: PayloadInspector.h:55
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:592
SiPixelPI::topolInfo::fillGeometryInfo
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, const SiPixelPI::phase &ph)
Definition: SiPixelPayloadInspectorHelper.h:704
cms::cuda::assert
assert(be >=bs)
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >::PlotImage
PlotImage(const std::string &title)
Definition: PayloadInspector.h:855
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::fill
bool fill() override
Definition: SiPixelGainCalibHelper.h:1614
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:1851
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:1850
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:286
cond::payloadInspector::PlotBase::ntags
unsigned int ntags() const
Definition: PayloadInspector.cc:48
SiPixelPI::BPixL1o
Definition: SiPixelPayloadInspectorHelper.h:574
SiPixelPI::topolInfo::filterThePartition
SiPixelPI::regions filterThePartition()
Definition: SiPixelPayloadInspectorHelper.h:726
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::SiPixelGainCalibrationByRegionComparisonBase
SiPixelGainCalibrationByRegionComparisonBase()
Definition: SiPixelGainCalibHelper.h:1602
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:185
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:863
listHistos.legend
legend
Definition: listHistos.py:41
SiPixelPI::PhaseInfo
Definition: SiPixelPayloadInspectorHelper.h:48
SiPixelPI::regions
regions
Definition: SiPixelPayloadInspectorHelper.h:573
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelPI::NUM_OF_REGIONS
Definition: SiPixelPayloadInspectorHelper.h:588
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
SiPixelPI::topolInfo
Definition: SiPixelPayloadInspectorHelper.h:654
cond::payloadInspector::PlotImage< PayloadType, nIOVs, ntags >
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:545
SiPixelPI::topolInfo::init
void init()
Definition: SiPixelPayloadInspectorHelper.h:682
cond::payloadInspector::PlotBase::m_plotAnnotations
PlotAnnotations m_plotAnnotations
Definition: PayloadInspector.h:276
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:505