CMS 3D CMS Logo

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

#include <SiPixelGainCalibHelper.h>

Inheritance diagram for gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >:
cond::payloadInspector::PlotImage< PayloadType > cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 > cond::payloadInspector::PlotBase gainCalibHelper::SiPixelGainCalibrationByRegionComparisonSingleTag< myType, PayloadType > gainCalibHelper::SiPixelGainCalibrationByRegionComparisonTwoTags< myType, PayloadType >

Public Member Functions

bool fill (const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs) override
 
 SiPixelGainCalibrationByRegionComparisonBase ()
 
- Public Member Functions inherited from cond::payloadInspector::PlotImage< PayloadType >
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< UNSPECIFIED_IOV, 0 >
virtual bool fill ()
 
virtual bool fill (const std::vector< std::tuple< cond::Time_t, cond::Hash >> &iovs)
 
 PlotImpl (const std::string &type, const std::string &title)
 
std::string processData () override
 
void setSingleIov (bool flag)
 
void setTwoTags (bool flag)
 
 ~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 >
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 >
typedef PlotImpl< UNSPECIFIED_IOV, 0 > Base
 
- Public Attributes inherited from cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 >
bool m_singleIovSet = false
 

Detailed Description

template<gainCalibPI::type myType, class PayloadType>
class gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >

Definition at line 1350 of file SiPixelGainCalibHelper.h.

Constructor & Destructor Documentation

◆ SiPixelGainCalibrationByRegionComparisonBase()

template<gainCalibPI::type myType, class PayloadType >
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >::SiPixelGainCalibrationByRegionComparisonBase ( )
inline

Definition at line 1353 of file SiPixelGainCalibHelper.h.

1360  public:
1362  : cond::payloadInspector::PlotImage<PayloadType>(
1363  Form("SiPixelGainCalibration %s Comparison by Region", TypeName[myType])) {

Member Function Documentation

◆ fill()

template<gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >::fill ( const std::vector< std::tuple< cond::Time_t, cond::Hash >> &  iovs)
inlineoverride

Definition at line 1364 of file SiPixelGainCalibHelper.h.

1364  {
1365  isForHLT_ = false;
1366  label_ = "SiPixelGainCalibrationOffline_PayloadInspector";
1367  } else {
1368  isForHLT_ = true;
1369  label_ = "SiPixelGainCalibrationForHLT_PayloadInspector";
1370  }
1371  }
1372  bool fill(const std::vector<std::tuple<cond::Time_t, cond::Hash>>& iovs) override {
1373  gStyle->SetPaintTextFormat(".3f");
1374 
1375  std::vector<std::tuple<cond::Time_t, cond::Hash>> sorted_iovs = iovs;
1376 
1377  // make absolute sure the IOVs are sortd by since
1378  std::sort(begin(sorted_iovs), end(sorted_iovs), [](auto const& t1, auto const& t2) {
1379  return std::get<0>(t1) < std::get<0>(t2);
1380  });
1381 
1382  auto firstiov = sorted_iovs.front();
1383  auto lastiov = sorted_iovs.back();
1384 
1385  std::shared_ptr<PayloadType> last_payload = this->fetchPayload(std::get<1>(lastiov));
1386  std::shared_ptr<PayloadType> first_payload = this->fetchPayload(std::get<1>(firstiov));
1387 
1388  std::map<uint32_t, float> f_GainsMap_;
1389  gainCalibPI::fillThePerModuleMap(first_payload, f_GainsMap_, myType);
1390 
1391  std::map<uint32_t, float> l_GainsMap_;
1392  gainCalibPI::fillThePerModuleMap(last_payload, l_GainsMap_, myType);
1393 
1394  std::string lastIOVsince = std::to_string(std::get<0>(lastiov));
1395  std::string firstIOVsince = std::to_string(std::get<0>(firstiov));
1396 
1397  TCanvas canvas("Comparison", "Comparison", 1600, 800);
1398 
1399  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> FirstGains_spectraByRegion;
1400  std::map<SiPixelPI::regions, std::shared_ptr<TH1F>> LastGains_spectraByRegion;
1401  std::shared_ptr<TH1F> summaryFirst;
1402  std::shared_ptr<TH1F> summaryLast;
1403 
1404  float minimum(9999.);
1405  float maximum(-9999.);
1406 
1407  switch (myType) {
1408  case gainCalibPI::t_gain:
1409  maximum = std::max(last_payload->getGainHigh(), first_payload->getGainHigh());
1410  minimum = std::min(last_payload->getGainLow(), first_payload->getGainLow());
1411  break;
1413  maximum = std::max(last_payload->getPedHigh(), first_payload->getPedHigh());
1414  minimum = std::min(last_payload->getPedLow(), first_payload->getPedLow());
1415  break;
1416  default:
1417  edm::LogError(label_) << "Unrecognized type " << myType << std::endl;
1418  break;
1419  }
1420 
1421  // book the intermediate histograms
1422  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1423  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1425 
1426  FirstGains_spectraByRegion[part] =
1427  std::make_shared<TH1F>(Form("hfirstGains_%s", s_part.c_str()),
1428  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1429  200,
1430  minimum,
1431  maximum);
1432 
1433  LastGains_spectraByRegion[part] =
1434  std::make_shared<TH1F>(Form("hlastGains_%s", s_part.c_str()),
1435  Form(";%s #LT %s #GT;n. of modules", s_part.c_str(), TypeName[myType]),
1436  200,
1437  minimum,
1438  maximum);
1439  }
1440 
1441  summaryFirst = std::make_shared<TH1F>("first Summary",
1442  Form("Summary of #LT per %s %s #GT;;average %s",
1443  (isForHLT_ ? "Column" : "Pixel"),
1444  TypeName[myType],
1445  TypeName[myType]),
1446  FirstGains_spectraByRegion.size(),
1447  0,
1448  FirstGains_spectraByRegion.size());
1449 
1450  summaryLast = std::make_shared<TH1F>("last Summary",
1451  Form("Summary of #LT per %s %s #GT;;average %s",
1452  (isForHLT_ ? "Column" : "Pixel"),
1453  TypeName[myType],
1454  TypeName[myType]),
1455  LastGains_spectraByRegion.size(),
1456  0,
1457  LastGains_spectraByRegion.size());
1458 
1459  const char* path_toTopologyXML = (f_GainsMap_.size() == SiPixelPI::phase0size)
1460  ? "Geometry/TrackerCommonData/data/trackerParameters.xml"
1461  : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1462  TrackerTopology f_tTopo =
1464 
1465  bool isPhase0(false);
1466  if (f_GainsMap_.size() == SiPixelPI::phase0size) {
1467  isPhase0 = true;
1468  }
1469 
1470  // -------------------------------------------------------------------
1471  // loop on the first Gains Map
1472  // -------------------------------------------------------------------
1473  for (const auto& it : f_GainsMap_) {
1474  if (DetId(it.first).det() != DetId::Tracker) {
1475  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1476  return false;
1477  }
1478 
1479  SiPixelPI::topolInfo t_info_fromXML;
1480  t_info_fromXML.init();
1481  DetId detid(it.first);
1482  t_info_fromXML.fillGeometryInfo(detid, f_tTopo, isPhase0);
1483 
1484  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1485  FirstGains_spectraByRegion[thePart]->Fill(it.second);
1486  } // ends loop on the vector of error transforms
1487 
1488  path_toTopologyXML = (l_GainsMap_.size() == SiPixelPI::phase0size)
1489  ? "Geometry/TrackerCommonData/data/trackerParameters.xml"
1490  : "Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml";
1491  TrackerTopology l_tTopo =
1493 
1494  if (l_GainsMap_.size() == SiPixelPI::phase0size) {
1495  isPhase0 = true;
1496  }
1497 
1498  // -------------------------------------------------------------------
1499  // loop on the second Gains Map
1500  // -------------------------------------------------------------------
1501  for (const auto& it : l_GainsMap_) {
1502  if (DetId(it.first).det() != DetId::Tracker) {
1503  edm::LogWarning(label_) << "Encountered invalid Tracker DetId:" << it.first << " - terminating ";
1504  return false;
1505  }
1506 
1507  SiPixelPI::topolInfo t_info_fromXML;
1508  t_info_fromXML.init();
1509  DetId detid(it.first);
1510  t_info_fromXML.fillGeometryInfo(detid, l_tTopo, isPhase0);
1511 
1512  SiPixelPI::regions thePart = t_info_fromXML.filterThePartition();
1513  LastGains_spectraByRegion[thePart]->Fill(it.second);
1514  } // ends loop on the vector of error transforms
1515 
1516  // fill the summary plots
1517  int bin = 1;
1518  for (int r = SiPixelPI::BPixL1o; r != SiPixelPI::NUM_OF_REGIONS; r++) {
1519  SiPixelPI::regions part = static_cast<SiPixelPI::regions>(r);
1520 
1521  summaryFirst->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1522  // avoid filling the histogram with numerical noise
1523  float f_mean =
1524  FirstGains_spectraByRegion[part]->GetMean() > 10.e-6 ? FirstGains_spectraByRegion[part]->GetMean() : 0.;
1525  summaryFirst->SetBinContent(bin, f_mean);
1526  //summaryFirst->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1527 
1528  summaryLast->GetXaxis()->SetBinLabel(bin, SiPixelPI::getStringFromRegionEnum(part).c_str());
1529  // avoid filling the histogram with numerical noise
1530  float l_mean =
1531  LastGains_spectraByRegion[part]->GetMean() > 10.e-6 ? LastGains_spectraByRegion[part]->GetMean() : 0.;
1532  summaryLast->SetBinContent(bin, l_mean);
1533  //summaryLast->SetBinError(bin,Gains_spectraByRegion[hash]->GetRMS());
1534  bin++;
1535  }
1536 
1537  SiPixelPI::makeNicePlotStyle(summaryFirst.get()); //, kBlue);
1538  summaryFirst->SetMarkerColor(kRed);
1539  summaryFirst->GetXaxis()->LabelsOption("v");
1540  summaryFirst->GetXaxis()->SetLabelSize(0.05);
1541  summaryFirst->GetYaxis()->SetTitleOffset(0.9);
1542 
1543  SiPixelPI::makeNicePlotStyle(summaryLast.get()); //, kRed);
1544  summaryLast->SetMarkerColor(kBlue);
1545  summaryLast->GetYaxis()->SetTitleOffset(0.9);
1546  summaryLast->GetXaxis()->LabelsOption("v");
1547  summaryLast->GetXaxis()->SetLabelSize(0.05);
1548 
1549  canvas.cd()->SetGridy();
1550 
1551  SiPixelPI::adjustCanvasMargins(canvas.cd(), -1, 0.18, 0.11, 0.02);
1552  canvas.Modified();
1553 
1554  summaryFirst->SetFillColor(kRed);
1555  summaryLast->SetFillColor(kBlue);
1556 
1557  summaryFirst->SetBarWidth(0.45);
1558  summaryFirst->SetBarOffset(0.1);
1559 
1560  summaryLast->SetBarWidth(0.4);
1561  summaryLast->SetBarOffset(0.55);
1562 
1563  summaryLast->SetMarkerSize(1.2);
1564  summaryFirst->SetMarkerSize(1.2);
1565 
1566  float max = (summaryFirst->GetMaximum() > summaryLast->GetMaximum()) ? summaryFirst->GetMaximum()
1567  : summaryLast->GetMaximum();
1568 
1569  summaryFirst->GetYaxis()->SetRangeUser(0., std::max(0., max * 1.40));
1570 
1571  summaryFirst->Draw("b text0");
1572  summaryLast->Draw("b text0 same");
1573 
1574  TLegend legend = TLegend(0.52, 0.80, 0.98, 0.9);
1575  legend.SetHeader(Form("#LT %s #GT value comparison", TypeName[myType]),
1576  "C"); // option "C" allows to center the header
1577  legend.AddEntry(
1578  summaryLast.get(),
1579  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(lastiov)) + "} | #color[4]{" + std::get<1>(lastiov) + "}")
1580  .c_str(),
1581  "F");
1582  legend.AddEntry(
1583  summaryFirst.get(),
1584  ("IOV: #scale[1.2]{" + std::to_string(std::get<0>(firstiov)) + "} | #color[2]{" + std::get<1>(firstiov) + "}")
1585  .c_str(),

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

Member Data Documentation

◆ isForHLT_

template<gainCalibPI::type myType, class PayloadType >
bool gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >::isForHLT_
protected

◆ label_

template<gainCalibPI::type myType, class PayloadType >
std::string gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase< myType, PayloadType >::label_
protected
gainCalibHelper::gainCalibPI::t_pedestal
Definition: SiPixelGainCalibHelper.h:37
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
gainCalibHelper::gainCalibPI::t_gain
Definition: SiPixelGainCalibHelper.h:37
min
T min(T a, T b)
Definition: MathUtil.h:58
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
TrackerTopology
Definition: TrackerTopology.h:16
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:520
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::SiPixelGainCalibrationByRegionComparisonBase
SiPixelGainCalibrationByRegionComparisonBase()
Definition: SiPixelGainCalibHelper.h:1353
cond::payloadInspector::PlotImage< PayloadType >::PlotImage
PlotImage(const std::string &title)
Definition: PayloadInspector.h:832
SiPixelPI::phase0size
static const unsigned int phase0size
Definition: SiPixelPayloadInspectorHelper.h:40
end
#define end
Definition: vmac.h:39
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
part
part
Definition: HCALResponse.h:20
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
gainCalibHelper::TypeName
constexpr char const * TypeName[2]
Definition: SiPixelGainCalibHelper.h:200
SiPixelPI::BPixL1o
Definition: SiPixelPayloadInspectorHelper.h:502
cond::payloadInspector::PlotImpl< UNSPECIFIED_IOV, 0 >::fill
virtual bool fill()
Definition: PayloadInspector.h:379
SiPixelPI::topolInfo::filterThePartition
SiPixelPI::regions filterThePartition()
Definition: SiPixelPayloadInspectorHelper.h:651
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogWarning
Definition: MessageLogger.h:141
cond
Definition: plugin.cc:23
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::label_
std::string label_
Definition: SiPixelGainCalibHelper.h:1589
gainCalibHelper::gainCalibPI::fillThePerModuleMap
static void fillThePerModuleMap(const std::shared_ptr< PayloadType > &payload, AvgMap &map, gainCalibPI::type theType)
Definition: SiPixelGainCalibHelper.h:99
edm::LogError
Definition: MessageLogger.h:183
DetId::Tracker
Definition: DetId.h:25
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
cond::payloadInspector::PlotImage< PayloadType >::fetchPayload
std::shared_ptr< PayloadType > fetchPayload(const cond::Hash &payloadHash)
Definition: PayloadInspector.h:840
listHistos.legend
legend
Definition: listHistos.py:41
SiPixelPI::regions
regions
Definition: SiPixelPayloadInspectorHelper.h:501
SiPixelPI::NUM_OF_REGIONS
Definition: SiPixelPayloadInspectorHelper.h:516
alignCSCRings.r
r
Definition: alignCSCRings.py:93
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
SiPixelPI::topolInfo
Definition: SiPixelPayloadInspectorHelper.h:582
cond::payloadInspector::PlotImage< PayloadType >
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:475
gainCalibHelper::SiPixelGainCalibrationByRegionComparisonBase::isForHLT_
bool isForHLT_
Definition: SiPixelGainCalibHelper.h:1588
SiPixelPI::topolInfo::init
void init()
Definition: SiPixelPayloadInspectorHelper.h:609
SiPixelPI::topolInfo::fillGeometryInfo
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, bool isPhase0)
Definition: SiPixelPayloadInspectorHelper.h:631
StandaloneTrackerTopology::fromTrackerParametersXMLFile
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)
Definition: StandaloneTrackerTopology.cc:168
begin
#define begin
Definition: vmac.h:32
SiPixelPI::adjustCanvasMargins
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Definition: SiPixelPayloadInspectorHelper.h:435