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.

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  }

References m_isLog, m_isTrackerTopologySet, and m_trackerTopo.

◆ ~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.

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  }

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

◆ 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.

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  }

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().

◆ 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.

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  }

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

◆ fill()

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

Definition at line 291 of file PixelRegionContainers.h.

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  }

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

◆ getHistoFromMap()

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

Definition at line 411 of file PixelRegionContainers.h.

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  }

References Exception, and m_theMap.

Referenced by rescaleMax().

◆ getTheTopo()

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

Definition at line 260 of file PixelRegionContainers.h.

260 { return m_trackerTopo; }

References m_trackerTopo.

◆ rescaleMax()

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

Definition at line 422 of file PixelRegionContainers.h.

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  }

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

◆ setLogScale()

void PixelRegions::PixelRegionContainers::setLogScale ( )
inline

Definition at line 391 of file PixelRegionContainers.h.

391 { m_isLog = true; }

References m_isLog.

◆ setTheTopo()

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

Definition at line 254 of file PixelRegionContainers.h.

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

References m_isTrackerTopologySet, and m_trackerTopo.

◆ stats()

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

Definition at line 394 of file PixelRegionContainers.h.

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  }

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

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.

RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
PixelRegions::PixelIDs
const std::vector< PixelId > PixelIDs
Definition: PixelRegionContainers.h:45
PixelRegions::PixelRegionContainers::m_trackerTopo
const TrackerTopology * m_trackerTopo
Definition: PixelRegionContainers.h:432
SiPixelPI
Definition: SiPixelPayloadInspectorHelper.h:37
cms::cuda::assert
assert(be >=bs)
PixelRegions::PixelId
PixelId
Definition: PixelRegionContainers.h:30
plotFactory.plot
plot
Definition: plotFactory.py:109
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:87
PixelRegions::detIdToPixelId
static const PixelId detIdToPixelId(const unsigned int detid, const TrackerTopology *trackTopo, const SiPixelPI::phase &ph)
Definition: PixelRegionContainers.h:151
TrackerTopology::print
std::string print(DetId detid) const
Definition: TrackerTopology.cc:252
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
PixelRegions::Ph2EmR1
Definition: PixelRegionContainers.h:38
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
PixelRegions::PixelRegionContainers::m_theMap
std::map< PixelId, std::shared_ptr< TH1F > > m_theMap
Definition: PixelRegionContainers.h:435
PixelRegions::IDlabels
const std::vector< std::string > IDlabels
Definition: PixelRegionContainers.h:62
PixelRegions::PixelRegionContainers::m_isTrackerTopologySet
bool m_isTrackerTopologySet
Definition: PixelRegionContainers.h:433
PixelRegions::L4
Definition: PixelRegionContainers.h:32
value
Definition: value.py:1
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiPixelPI::adjustStats
void adjustStats(TPaveStats *stats, float X1, float Y1, float X2, float Y2)
Definition: SiPixelPayloadInspectorHelper.h:522
SiPixelPI::two
Definition: SiPixelPayloadInspectorHelper.h:39
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
Exception
Definition: hltDiff.cc:245
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:548
PixelRegions::PixelRegionContainers::m_isLog
bool m_isLog
Definition: PixelRegionContainers.h:438
SiPixelPI::getExtrema
std::pair< float, float > getExtrema(TH1 *h1, TH1 *h2)
Definition: SiPixelPayloadInspectorHelper.h:532
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
PixelRegions::itoa
std::string itoa(int i)
Definition: PixelRegionContainers.h:18
PixelRegions::PixelRegionContainers::m_Phase
SiPixelPI::phase m_Phase
Definition: PixelRegionContainers.h:434
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66