CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PixelRegions::PixelRegionContainers Class Reference

#include <PixelRegionContainers.h>

Public Member Functions

void beautify (const int linecolor=kBlack, const int fillcolor=kRed)
 
void bookAll (std::string title_label, std::string x_label, std::string y_label, const int nbins, const float xmin, const float xmax)
 
void draw (TCanvas &canv, bool isBarrel, const char *option="bar2", bool isPhase1Comparison=false)
 
void fill (const unsigned int detid, const float value)
 
std::shared_ptr< TH1F > & getHistoFromMap (const PixelRegions::PixelId &theId)
 
const TrackerTopologygetTheTopo ()
 
 PixelRegionContainers (const TrackerTopology *t_topo, const SiPixelPI::phase &ph)
 
void rescaleMax (PixelRegionContainers &the2ndContainer)
 
void setLogScale ()
 
void setTheTopo (const TrackerTopology *t_topo)
 
void stats (int index=0)
 
 ~PixelRegionContainers ()
 

Private Attributes

bool m_isLog
 
bool m_isTrackerTopologySet
 
int m_nbins
 
SiPixelPI::phase m_Phase
 
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
 
const TrackerTopologym_trackerTopo
 
float m_xim
 
float m_xmax
 

Detailed Description

Definition at line 238 of file PixelRegionContainers.h.

Constructor & Destructor Documentation

◆ PixelRegionContainers()

PixelRegions::PixelRegionContainers::PixelRegionContainers ( const TrackerTopology t_topo,
const SiPixelPI::phase ph 
)
inline

Definition at line 240 of file PixelRegionContainers.h.

References m_isLog, m_isTrackerTopologySet, and m_trackerTopo.

241  : m_trackerTopo(t_topo), m_Phase(ph) {
242  // set log scale by default to false
243  m_isLog = false;
244  if (m_trackerTopo) {
245  m_isTrackerTopologySet = true;
246  } else {
247  m_isTrackerTopologySet = false;
248  }
249  }

◆ ~PixelRegionContainers()

PixelRegions::PixelRegionContainers::~PixelRegionContainers ( )
inline

Definition at line 251 of file PixelRegionContainers.h.

251 {}

Member Function Documentation

◆ beautify()

void PixelRegions::PixelRegionContainers::beautify ( const int  linecolor = kBlack,
const int  fillcolor = kRed 
)
inline

Definition at line 370 of file PixelRegionContainers.h.

References m_isLog, m_theMap, SiPixelPI::makeNicePlotStyle(), and plotFactory::plot.

370  {
371  for (const auto& plot : m_theMap) {
372  plot.second->SetTitle("");
373  if (!m_isLog) {
374  plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30);
375  } else {
376  plot.second->GetYaxis()->SetRangeUser(0.1, plot.second->GetMaximum() * 100.);
377  }
378  plot.second->SetLineColor(linecolor);
379  if (fillcolor > 0) {
380  plot.second->SetFillColor(fillcolor);
381  }
382  plot.second->SetMarkerStyle(20);
383  plot.second->SetMarkerSize(1);
384  SiPixelPI::makeNicePlotStyle(plot.second.get());
385  plot.second->SetStats(true);
386  }
387  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
void makeNicePlotStyle(TH1 *hist)

◆ bookAll()

void PixelRegions::PixelRegionContainers::bookAll ( std::string  title_label,
std::string  x_label,
std::string  y_label,
const int  nbins,
const float  xmin,
const float  xmax 
)
inline

Definition at line 263 of file PixelRegionContainers.h.

References PixelRegions::IDlabels, PixelRegions::itoa(), PixelRegions::L4, m_Phase, m_theMap, LaserClient_cfi::nbins, PixelRegions::Ph2EmR1, PixelRegions::PixelIDs, SiPixelPI::two, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by gainCalibHelper::SiPixelGainCalibrationValuesPerRegion< isBarrel, myType, PayloadType >::fill(), and gainCalibHelper::SiPixelGainCalibrationValuesComparisonPerRegion< isBarrel, myType, nIOVs, ntags, PayloadType >::fill().

268  {
269  using namespace SiPixelPI;
270  for (const auto& pixelId : PixelIDs | boost::adaptors::indexed(0)) {
271  if (m_Phase == phase::two && // if that's phase-2
272  pixelId.value() > PixelId::L4 && // if it's end-cap
273  pixelId.value() < PixelId::Ph2EmR1 // it's a phase-1 ring
274  ) {
275  continue;
276  }
277 
278  m_theMap[pixelId.value()] = std::make_shared<TH1F>((title_label + itoa(pixelId.value())).c_str(),
279  Form("%s %s;%s;%s",
280  (IDlabels.at(pixelId.index())).c_str(),
281  title_label.c_str(),
282  x_label.c_str(),
283  y_label.c_str()),
284  nbins,
285  xmin,
286  xmax);
287  }
288  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
const std::vector< std::string > IDlabels
std::string itoa(int i)
const std::vector< PixelId > PixelIDs

◆ draw()

void PixelRegions::PixelRegionContainers::draw ( TCanvas &  canv,
bool  isBarrel,
const char *  option = "bar2",
bool  isPhase1Comparison = false 
)
inline

Definition at line 306 of file PixelRegionContainers.h.

References PixelPluginsPhase0_cfi::isBarrel, dqmiolumiharvest::j, m_isLog, m_Phase, m_theMap, fileinputsource_cfi::option, PixelRegions::PixelIDs, RandomServiceHelper::t2, and SiPixelPI::two.

306  {
307  using namespace SiPixelPI;
308  if (isBarrel) {
309  if (canv.GetListOfPrimitives()->GetSize() == 0) {
310  // divide only if it was not already divided
311  canv.Divide(2, 2);
312  }
313  for (int j = 1; j <= 4; j++) {
314  if (!m_isLog) {
315  canv.cd(j);
316  } else {
317  canv.cd(j)->SetLogy();
318  }
319  if ((j == 4) && (m_Phase < 1) && !isPhase1Comparison) {
320  m_theMap.at(PixelIDs[j - 1])->Draw("AXIS");
321  TLatex t2;
322  t2.SetTextAlign(22);
323  t2.SetTextSize(0.1);
324  t2.SetTextAngle(45);
325  t2.SetTextFont(61);
326  t2.SetTextColor(kBlack);
327  t2.DrawLatexNDC(0.5, 0.5, "Not in Phase-0!");
328  } else {
329  m_theMap.at(PixelIDs[j - 1])->Draw(option);
330  }
331  }
332  } else { // forward
333  // pattern where to insert the plots in the canvas
334  // clang-format off
335  const std::array<int, 18> phase2Pattern = {{1, 2, 3, 4,
336  6, 7, 8, 9,
337  11, 12, 13, 14, 15,
338  16, 17, 18, 19, 20}};
339  // clang-format on
340 
341  if (canv.GetListOfPrimitives()->GetSize() == 0) {
342  canv.Divide(m_Phase == phase::two ? 5 : 4, m_Phase == phase::two ? 4 : 3);
343  }
344  const int maxPads = (m_Phase == phase::two) ? 18 : 12;
345  for (int j = 1; j <= maxPads; j++) {
346  unsigned int mapIndex = m_Phase == 2 ? j + 15 : j + 3;
347  if (!m_isLog) {
348  canv.cd((m_Phase == phase::two) ? phase2Pattern[j - 1] : j);
349  //canv.cd(j);
350  } else {
351  canv.cd(j)->SetLogy();
352  }
353  if ((j % 6 == 5 || j % 6 == 0) && (m_Phase < 1) && !isPhase1Comparison) {
354  m_theMap.at(PixelIDs[mapIndex])->Draw("AXIS");
355  TLatex t2;
356  t2.SetTextAlign(22);
357  t2.SetTextSize(0.1);
358  t2.SetTextAngle(45);
359  t2.SetTextFont(61);
360  t2.SetTextColor(kBlack);
361  t2.DrawLatexNDC(0.5, 0.5, "Not in Phase-0!");
362  } else {
363  m_theMap.at(PixelIDs[mapIndex])->Draw(option);
364  }
365  }
366  }
367  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
const std::vector< PixelId > PixelIDs

◆ fill()

void PixelRegions::PixelRegionContainers::fill ( const unsigned int  detid,
const float  value 
)
inline

Definition at line 291 of file PixelRegionContainers.h.

References cms::cuda::assert(), PixelRegions::detIdToPixelId(), Exception, m_Phase, m_theMap, m_trackerTopo, and TrackerTopology::print().

291  {
292  // first check that the topology is set
294 
295  // convert from detid to pixelid
297  if (m_theMap.find(myId) != m_theMap.end()) {
298  m_theMap[myId]->Fill(value);
299  } else {
300  throw cms::Exception("LogicError") << detid << " :=> " << myId << " is not a recongnized PixelId enumerator! \n"
301  << m_trackerTopo->print(detid);
302  }
303  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
std::string print(DetId detid) const
assert(be >=bs)
Definition: value.py:1
static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology *trackTopo, const SiPixelPI::phase &ph)

◆ getHistoFromMap()

std::shared_ptr<TH1F>& PixelRegions::PixelRegionContainers::getHistoFromMap ( const PixelRegions::PixelId theId)
inline

Definition at line 410 of file PixelRegionContainers.h.

References Exception, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and m_theMap.

Referenced by rescaleMax().

410  {
411  auto it = m_theMap.find(theId);
412  if (it != m_theMap.end()) {
413  return it->second;
414  } else {
415  throw cms::Exception("LogicError")
416  << "PixelRegionContainer::getHistoFromMap(): No histogram is available for PixelId: " << theId << "\n";
417  }
418  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap

◆ getTheTopo()

const TrackerTopology* PixelRegions::PixelRegionContainers::getTheTopo ( )
inline

Definition at line 260 of file PixelRegionContainers.h.

References m_trackerTopo.

260 { return m_trackerTopo; }

◆ rescaleMax()

void PixelRegions::PixelRegionContainers::rescaleMax ( PixelRegionContainers the2ndContainer)
inline

Definition at line 421 of file PixelRegionContainers.h.

References SiPixelPI::getExtrema(), getHistoFromMap(), m_theMap, and plotFactory::plot.

421  {
422  for (const auto& plot : m_theMap) {
423  auto thePixId = plot.first;
424  auto extrema = SiPixelPI::getExtrema((plot.second).get(), the2ndContainer.getHistoFromMap(thePixId).get());
425  plot.second->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
426  the2ndContainer.getHistoFromMap(thePixId)->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
427  }
428  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)

◆ setLogScale()

void PixelRegions::PixelRegionContainers::setLogScale ( )
inline

Definition at line 390 of file PixelRegionContainers.h.

References m_isLog.

◆ setTheTopo()

void PixelRegions::PixelRegionContainers::setTheTopo ( const TrackerTopology t_topo)
inline

Definition at line 254 of file PixelRegionContainers.h.

References m_isTrackerTopologySet, and m_trackerTopo.

254  {
255  m_trackerTopo = t_topo;
256  m_isTrackerTopologySet = true;
257  }

◆ stats()

void PixelRegions::PixelRegionContainers::stats ( int  index = 0)
inline

Definition at line 393 of file PixelRegionContainers.h.

References SiPixelPI::adjustStats(), m_theMap, and plotFactory::plot.

393  {
394  for (const auto& plot : m_theMap) {
395  TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats");
396  if (st) {
397  st->SetTextSize(0.03);
398  st->SetLineColor(10);
399  if (plot.second->GetFillColor() != 0) {
400  st->SetTextColor(plot.second->GetFillColor());
401  } else {
402  st->SetTextColor(plot.second->GetLineColor());
403  }
404  SiPixelPI::adjustStats(st, 0.13, 0.85 - index * 0.08, 0.36, 0.93 - index * 0.08);
405  }
406  }
407  }
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)

Member Data Documentation

◆ m_isLog

bool PixelRegions::PixelRegionContainers::m_isLog
private

Definition at line 437 of file PixelRegionContainers.h.

Referenced by beautify(), draw(), PixelRegionContainers(), and setLogScale().

◆ m_isTrackerTopologySet

bool PixelRegions::PixelRegionContainers::m_isTrackerTopologySet
private

Definition at line 432 of file PixelRegionContainers.h.

Referenced by PixelRegionContainers(), and setTheTopo().

◆ m_nbins

int PixelRegions::PixelRegionContainers::m_nbins
private

Definition at line 435 of file PixelRegionContainers.h.

◆ m_Phase

SiPixelPI::phase PixelRegions::PixelRegionContainers::m_Phase
private

Definition at line 433 of file PixelRegionContainers.h.

Referenced by bookAll(), draw(), and fill().

◆ m_theMap

std::map<PixelId, std::shared_ptr<TH1F> > PixelRegions::PixelRegionContainers::m_theMap
private

Definition at line 434 of file PixelRegionContainers.h.

Referenced by beautify(), bookAll(), draw(), fill(), getHistoFromMap(), rescaleMax(), and stats().

◆ m_trackerTopo

const TrackerTopology* PixelRegions::PixelRegionContainers::m_trackerTopo
private

Definition at line 431 of file PixelRegionContainers.h.

Referenced by fill(), getTheTopo(), PixelRegionContainers(), and setTheTopo().

◆ m_xim

float PixelRegions::PixelRegionContainers::m_xim
private

Definition at line 436 of file PixelRegionContainers.h.

◆ m_xmax

float PixelRegions::PixelRegionContainers::m_xmax
private

Definition at line 436 of file PixelRegionContainers.h.