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 371 of file PixelRegionContainers.h.

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

371  {
372  for (const auto& plot : m_theMap) {
373  plot.second->SetTitle("");
374  if (!m_isLog) {
375  plot.second->GetYaxis()->SetRangeUser(0., plot.second->GetMaximum() * 1.30);
376  } else {
377  plot.second->GetYaxis()->SetRangeUser(0.1, plot.second->GetMaximum() * 100.);
378  }
379  plot.second->SetLineColor(linecolor);
380  if (fillcolor > 0) {
381  plot.second->SetFillColor(fillcolor);
382  }
383  plot.second->SetMarkerStyle(20);
384  plot.second->SetMarkerSize(1);
385  SiPixelPI::makeNicePlotStyle(plot.second.get());
386  plot.second->SetStats(true);
387  }
388  }
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 307 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.

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

References Exception, and m_theMap.

Referenced by rescaleMax().

411  {
412  auto it = m_theMap.find(theId);
413  if (it != m_theMap.end()) {
414  return it->second;
415  } else {
416  throw cms::Exception("LogicError")
417  << "PixelRegionContainer::getHistoFromMap(): No histogram is available for PixelId: " << theId << "\n";
418  }
419  }
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 422 of file PixelRegionContainers.h.

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

422  {
423  for (const auto& plot : m_theMap) {
424  auto thePixId = plot.first;
425  auto extrema = SiPixelPI::getExtrema((plot.second).get(), the2ndContainer.getHistoFromMap(thePixId).get());
426  plot.second->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
427  the2ndContainer.getHistoFromMap(thePixId)->GetYaxis()->SetRangeUser(extrema.first, extrema.second);
428  }
429  }
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 391 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 394 of file PixelRegionContainers.h.

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

394  {
395  for (const auto& plot : m_theMap) {
396  TPaveStats* st = (TPaveStats*)plot.second->FindObject("stats");
397  if (st) {
398  st->SetTextSize(0.03);
399  st->SetLineColor(10);
400  if (plot.second->GetFillColor() != 0) {
401  st->SetTextColor(plot.second->GetFillColor());
402  } else {
403  st->SetTextColor(plot.second->GetLineColor());
404  }
405  SiPixelPI::adjustStats(st, 0.13, 0.85 - index * 0.08, 0.36, 0.93 - index * 0.08);
406  }
407  }
408  }
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 438 of file PixelRegionContainers.h.

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

◆ m_isTrackerTopologySet

bool PixelRegions::PixelRegionContainers::m_isTrackerTopologySet
private

Definition at line 433 of file PixelRegionContainers.h.

Referenced by PixelRegionContainers(), and setTheTopo().

◆ m_nbins

int PixelRegions::PixelRegionContainers::m_nbins
private

Definition at line 436 of file PixelRegionContainers.h.

◆ m_Phase

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

Definition at line 434 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 435 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 432 of file PixelRegionContainers.h.

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

◆ m_xim

float PixelRegions::PixelRegionContainers::m_xim
private

Definition at line 437 of file PixelRegionContainers.h.

◆ m_xmax

float PixelRegions::PixelRegionContainers::m_xmax
private

Definition at line 437 of file PixelRegionContainers.h.