CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
Phase1PixelMaps Class Reference

#include <Phase1PixelMaps.h>

Public Member Functions

void beautifyAllHistograms ()
 
void book (const std::string &currentHistoName, const char *what, const char *zaxis)
 
void bookBarrelHistograms (const std::string &currentHistoName, const char *what, const char *zaxis)
 
void bookForwardHistograms (const std::string &currentHistoName, const char *what, const char *zaxis)
 
void drawBarrelMaps (const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
 
void drawForwardMaps (const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
 
void drawSummaryMaps (const std::string &currentHistoName, TCanvas &canvas, const char *drawOption=nullptr)
 
void fill (const std::string &currentHistoName, unsigned int id, double value)
 
void fillBarrelBin (const std::string &currentHistoName, unsigned int id, double value)
 
void fillForwardBin (const std::string &currentHistoName, unsigned int id, double value)
 
 Phase1PixelMaps (const char *option)
 
void resetOption (const char *option)
 
void setBarrelScale (const std::string &currentHistoName, std::pair< float, float > extrema)
 
void setForwardScale (const std::string &currentHistoName, std::pair< float, float > extrema)
 
void setNoRescale ()
 
 ~Phase1PixelMaps ()=default
 

Private Member Functions

void adjustCanvasMargins (TVirtualPad *pad, float top, float bottom, float left, float right)
 
void bookBarrelBins (const std::string &currentHistoName)
 
void bookForwardBins (const std::string &currentHistoName)
 
void makeNicePlotStyle (TH1 *hist)
 
void rescaleAllBarrel (const std::string &currentHistoName)
 
void rescaleAllForward (const std::string &currentHistoName)
 
const indexedCorners retrieveCorners (const std::vector< edm::FileInPath > &cornerFiles, const unsigned int reads)
 

Private Attributes

std::map< uint32_t, std::shared_ptr< TGraph > > bins
 
std::map< uint32_t, std::shared_ptr< TGraph > > binsSummary
 
bool m_autorescale
 
std::vector< edm::FileInPathm_cornersBPIX
 
std::vector< edm::FileInPathm_cornersFPIX
 
std::pair< bool, bool > m_isBooked
 
std::vector< std::string > m_knownNames
 
Option_t * m_option
 
TrackerTopology m_trackerTopo
 
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
 
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
 
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
 
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
 

Detailed Description

Definition at line 31 of file Phase1PixelMaps.h.

Constructor & Destructor Documentation

◆ Phase1PixelMaps()

Phase1PixelMaps::Phase1PixelMaps ( const char *  option)
inline

Definition at line 33 of file Phase1PixelMaps.h.

References fileinputsource_cfi::option.

34  : m_option{option},
35  m_isBooked{std::make_pair(false, false)},
36  m_knownNames{{}},
38  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
39  // set the rescale to true by default
40  m_autorescale = true;
41 
42  // store the file in path for the corners (BPIX)
43  for (unsigned int i = 1; i <= 4; i++) {
44  m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i)));
45  }
46 
47  // store the file in path for the corners (BPIX)
48  for (int j : {-3, -2, -1, 1, 2, 3}) {
49  m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j)));
50  }
51  }
std::vector< edm::FileInPath > m_cornersFPIX
Option_t * m_option
std::vector< edm::FileInPath > m_cornersBPIX
TrackerTopology m_trackerTopo
std::pair< bool, bool > m_isBooked
std::vector< std::string > m_knownNames
TrackerTopology fromTrackerParametersXMLFile(const std::string &xmlFileName)

◆ ~Phase1PixelMaps()

Phase1PixelMaps::~Phase1PixelMaps ( )
default

Member Function Documentation

◆ adjustCanvasMargins()

void Phase1PixelMaps::adjustCanvasMargins ( TVirtualPad *  pad,
float  top,
float  bottom,
float  left,
float  right 
)
private

Definition at line 514 of file Phase1PixelMaps.cc.

Referenced by drawBarrelMaps(), drawForwardMaps(), and drawSummaryMaps().

514  {
515  if (top > 0)
516  pad->SetTopMargin(top);
517  if (bottom > 0)
518  pad->SetBottomMargin(bottom);
519  if (left > 0)
520  pad->SetLeftMargin(left);
521  if (right > 0)
522  pad->SetRightMargin(right);
523 }

◆ beautifyAllHistograms()

void Phase1PixelMaps::beautifyAllHistograms ( )

Definition at line 288 of file Phase1PixelMaps.cc.

References m_isBooked, makeNicePlotStyle(), plotFactory::plot, pxbTh2PolyBarrel, and pxfTh2PolyForward.

Referenced by templateHelper::SiPixelIDs< PayloadType, myType >::fill().

288  {
289  if (!m_isBooked.first && !m_isBooked.second) {
290  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to beautify a histogram not booked";
291  return;
292  }
293 
294  // only if the barrel is booked
295  if (m_isBooked.first) {
296  for (const auto& vec : pxbTh2PolyBarrel) {
297  for (const auto& plot : vec.second) {
298  this->makeNicePlotStyle(plot.get());
299  plot->GetXaxis()->SetTitleOffset(0.9);
300  plot->GetYaxis()->SetTitleOffset(0.9);
301  plot->GetZaxis()->SetTitleOffset(1.2);
302  plot->GetZaxis()->SetTitleSize(0.05);
303  }
304  }
305  }
306 
307  // only if the forwards are booked
308  if (m_isBooked.second) {
309  for (const auto& vec : pxfTh2PolyForward) {
310  for (const auto& plot : vec.second) {
311  this->makeNicePlotStyle(plot.get());
312  plot->GetXaxis()->SetTitleOffset(0.9);
313  plot->GetYaxis()->SetTitleOffset(0.9);
314  plot->GetZaxis()->SetTitleOffset(1.2);
315  plot->GetZaxis()->SetTitleSize(0.05);
316  }
317  }
318  }
319 }
void makeNicePlotStyle(TH1 *hist)
Log< level::Error, false > LogError
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::pair< bool, bool > m_isBooked

◆ book()

void Phase1PixelMaps::book ( const std::string &  currentHistoName,
const char *  what,
const char *  zaxis 
)

Definition at line 215 of file Phase1PixelMaps.cc.

References bookBarrelHistograms(), bookForwardHistograms(), m_isBooked, and LaserClient_cfi::zaxis.

215  {
216  bookBarrelHistograms(currentHistoName, what, zaxis);
217  bookForwardHistograms(currentHistoName, what, zaxis);
218  m_isBooked = std::make_pair(true, true);
219 }
std::pair< bool, bool > m_isBooked
void bookBarrelHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)
void bookForwardHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)

◆ bookBarrelBins()

void Phase1PixelMaps::bookBarrelBins ( const std::string &  currentHistoName)
private

Definition at line 123 of file Phase1PixelMaps.cc.

References bins, binsSummary, mps_splice::entry, Exception, f, dqmMemoryStats::float, l1ctLayer2EG_cff::id, dqmdumpme::k, PVValHelper::ladder, phase1PixelTopology::layer, m_cornersBPIX, m_trackerTopo, PixelSubdetector::PixelBarrel, TrackerTopology::pxbLadder(), TrackerTopology::pxbLayer(), pxbTh2PolyBarrel, pxbTh2PolyBarrelSummary, and retrieveCorners().

Referenced by bookBarrelHistograms().

123  {
124  auto theIndexedCorners = this->retrieveCorners(m_cornersBPIX, 4);
125 
126  for (const auto& entry : theIndexedCorners) {
127  auto id = entry.first;
128  auto detid = DetId(id);
129  if (detid.subdetId() != PixelSubdetector::PixelBarrel)
130  continue;
131 
132  int layer = m_trackerTopo.pxbLayer(detid);
133  int ladder = m_trackerTopo.pxbLadder(detid);
134 
135  auto theVectX = entry.second.first;
136  auto theVectY = entry.second.second;
137 
138  float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]};
139  float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)};
140 
141  bins[id] = std::make_shared<TGraph>(5, vertX, vertY);
142  bins[id]->SetName(TString::Format("%u", id));
143 
144  // Summary plot
145  for (unsigned k = 0; k < 5; ++k) {
146  vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f);
147  vertY[k] += ((layer > 2) ? 30.0f : 0.0f);
148  }
149 
150  binsSummary[id] = std::make_shared<TGraph>(5, vertX, vertY);
151  binsSummary[id]->SetName(TString::Format("%u", id));
152 
153  if (pxbTh2PolyBarrel.find(currentHistoName) != pxbTh2PolyBarrel.end()) {
154  pxbTh2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone());
155  } else {
156  throw cms::Exception("LogicError") << currentHistoName << " is not found in the Barrel map! Aborting.";
157  }
158 
159  if (pxbTh2PolyBarrelSummary.find(currentHistoName) != pxbTh2PolyBarrelSummary.end()) {
160  pxbTh2PolyBarrelSummary[currentHistoName]->AddBin(binsSummary[id]->Clone());
161  } else {
162  throw cms::Exception("LocalError") << currentHistoName << " is not found in the Barrel Summary map! Aborting.";
163  }
164  }
165 }
unsigned int pxbLayer(const DetId &id) const
unsigned int pxbLadder(const DetId &id) const
constexpr std::array< uint8_t, layerIndexSize > layer
std::map< uint32_t, std::shared_ptr< TGraph > > binsSummary
std::vector< edm::FileInPath > m_cornersBPIX
std::map< uint32_t, std::shared_ptr< TGraph > > bins
const indexedCorners retrieveCorners(const std::vector< edm::FileInPath > &cornerFiles, const unsigned int reads)
TrackerTopology m_trackerTopo
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
double f[11][100]
Definition: DetId.h:17

◆ bookBarrelHistograms()

void Phase1PixelMaps::bookBarrelHistograms ( const std::string &  currentHistoName,
const char *  what,
const char *  zaxis 
)

Definition at line 30 of file Phase1PixelMaps.cc.

References bookBarrelBins(), spr::find(), mps_fire::i, m_isBooked, m_knownNames, m_option, pxbTh2PolyBarrel, pxbTh2PolyBarrelSummary, AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), and LaserClient_cfi::zaxis.

Referenced by book(), and templateHelper::SiPixelIDs< PayloadType, myType >::fill().

30  {
31  std::string histName;
32  std::shared_ptr<TH2Poly> th2p;
33 
34  // check if the passed histogram name already exists, if not store it
35  if (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) == m_knownNames.end()) {
36  m_knownNames.emplace_back(currentHistoName);
37  }
38 
39  for (unsigned i = 0; i < 4; ++i) {
40  histName = "barrel_layer_";
41 
42  th2p = std::make_shared<TH2Poly>(
43  (histName + std::to_string(i + 1)).c_str(), Form("PXBMap of %s - Layer %i", what, i + 1), -15.0, 15.0, 0.0, 5.0);
44 
45  th2p->SetFloat();
46 
47  th2p->GetXaxis()->SetTitle("z [cm]");
48  th2p->GetYaxis()->SetTitle("ladder");
49  th2p->GetZaxis()->SetTitle(zaxis);
50  th2p->GetZaxis()->CenterTitle();
51  th2p->SetStats(false);
52  th2p->SetOption(m_option);
53  pxbTh2PolyBarrel[currentHistoName].push_back(th2p);
54  }
55 
56  th2p = std::make_shared<TH2Poly>("barrel_summary", Form("Barrel Pixel Map of %s", what), -5.0, 5.0, 0.0, 15.0);
57  th2p->SetFloat();
58 
59  th2p->GetXaxis()->SetTitle("");
60  th2p->GetYaxis()->SetTitle("");
61  th2p->GetZaxis()->SetTitle(zaxis);
62  th2p->GetZaxis()->CenterTitle();
63  th2p->SetStats(false);
64  th2p->SetOption(m_option);
65  pxbTh2PolyBarrelSummary[currentHistoName] = th2p;
66 
67  // book the bins
68  bookBarrelBins(currentHistoName);
69 
70  // set the isBooked bit to true;
71  m_isBooked.first = true;
72 }
Option_t * m_option
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void bookBarrelBins(const std::string &currentHistoName)
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
std::pair< bool, bool > m_isBooked
std::vector< std::string > m_knownNames

◆ bookForwardBins()

void Phase1PixelMaps::bookForwardBins ( const std::string &  currentHistoName)
private

Definition at line 168 of file Phase1PixelMaps.cc.

References bins, binsSummary, mps_splice::entry, Exception, f, dqmMemoryStats::float, l1ctLayer2EG_cff::id, dqmdumpme::k, m_cornersFPIX, m_trackerTopo, PixelSubdetector::PixelEndcap, TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), pxfTh2PolyForward, pxfTh2PolyForwardSummary, and retrieveCorners().

Referenced by bookForwardHistograms().

168  {
169  auto theIndexedCorners = this->retrieveCorners(m_cornersFPIX, 3);
170 
171  for (const auto& entry : theIndexedCorners) {
172  auto id = entry.first;
173  auto detid = DetId(id);
174  if (detid.subdetId() != PixelSubdetector::PixelEndcap)
175  continue;
176 
177  int disk = m_trackerTopo.pxfDisk(detid);
178  int side = m_trackerTopo.pxfSide(detid);
179 
180  unsigned mapIdx = disk + (side - 1) * 3 - 1;
181 
182  auto theVectX = entry.second.first;
183  auto theVectY = entry.second.second;
184 
185  float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]};
186  float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]};
187 
188  bins[id] = std::make_shared<TGraph>(4, vertX, vertY);
189  bins[id]->SetName(TString::Format("%u", id));
190 
191  // Summary plot
192  for (unsigned k = 0; k < 4; ++k) {
193  vertX[k] += (float(side) - 1.5f) * 40.0f;
194  vertY[k] += (disk - 1) * 35.0f;
195  }
196 
197  binsSummary[id] = std::make_shared<TGraph>(4, vertX, vertY);
198  binsSummary[id]->SetName(TString::Format("%u", id));
199 
200  if (pxfTh2PolyForward.find(currentHistoName) != pxfTh2PolyForward.end()) {
201  pxfTh2PolyForward[currentHistoName][mapIdx]->AddBin(bins[id]->Clone());
202  } else {
203  throw cms::Exception("LogicError") << currentHistoName << " is not found in the Forward map! Aborting.";
204  }
205 
206  if (pxfTh2PolyForwardSummary.find(currentHistoName) != pxfTh2PolyForwardSummary.end()) {
207  pxfTh2PolyForwardSummary[currentHistoName]->AddBin(binsSummary[id]->Clone());
208  } else {
209  throw cms::Exception("LogicError") << currentHistoName << " is not found in the Forward Summary map! Aborting.";
210  }
211  }
212 }
std::vector< edm::FileInPath > m_cornersFPIX
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
std::map< uint32_t, std::shared_ptr< TGraph > > binsSummary
std::map< uint32_t, std::shared_ptr< TGraph > > bins
const indexedCorners retrieveCorners(const std::vector< edm::FileInPath > &cornerFiles, const unsigned int reads)
TrackerTopology m_trackerTopo
unsigned int pxfDisk(const DetId &id) const
double f[11][100]
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const

◆ bookForwardHistograms()

void Phase1PixelMaps::bookForwardHistograms ( const std::string &  currentHistoName,
const char *  what,
const char *  zaxis 
)

Definition at line 75 of file Phase1PixelMaps.cc.

References bookForwardBins(), spr::find(), m_isBooked, m_knownNames, m_option, pxfTh2PolyForward, pxfTh2PolyForwardSummary, AlCaHLTBitMon_QueryRunRegistry::string, cond::impl::to_string(), and LaserClient_cfi::zaxis.

Referenced by book(), and templateHelper::SiPixelIDs< PayloadType, myType >::fill().

75  {
76  std::string histName;
77  std::shared_ptr<TH2Poly> th2p;
78 
79  // check if the passed histogram name already exists, if not store it
80  if (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) == m_knownNames.end()) {
81  m_knownNames.emplace_back(currentHistoName);
82  }
83 
84  for (unsigned side = 1; side <= 2; ++side) {
85  for (unsigned disk = 1; disk <= 3; ++disk) {
86  histName = "forward_disk_";
87 
88  th2p = std::make_shared<TH2Poly>((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(),
89  Form("PXFMap of %s - Side %i Disk %i", what, side, disk),
90  -15.0,
91  15.0,
92  -15.0,
93  15.0);
94  th2p->SetFloat();
95  th2p->GetXaxis()->SetTitle("x [cm]");
96  th2p->GetYaxis()->SetTitle("y [cm]");
97  th2p->GetZaxis()->SetTitle(zaxis);
98  th2p->GetZaxis()->CenterTitle();
99  th2p->SetStats(false);
100  th2p->SetOption(m_option);
101  pxfTh2PolyForward[currentHistoName].push_back(th2p);
102  }
103  }
104 
105  th2p = std::make_shared<TH2Poly>("forward_summary", Form("Forward Pixel Map of %s", what), -40.0, 40.0, -20.0, 90.0);
106  th2p->SetFloat();
107 
108  th2p->GetXaxis()->SetTitle("");
109  th2p->GetYaxis()->SetTitle("");
110  th2p->GetZaxis()->SetTitle(zaxis);
111  th2p->GetZaxis()->CenterTitle();
112  th2p->SetStats(false);
113  th2p->SetOption(m_option);
114  pxfTh2PolyForwardSummary[currentHistoName] = th2p;
115 
116  // book the bins
117  bookForwardBins(currentHistoName);
118 
119  m_isBooked.second = true;
120 }
Option_t * m_option
std::string to_string(const V &value)
Definition: OMSAccess.h:71
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
void bookForwardBins(const std::string &currentHistoName)
std::pair< bool, bool > m_isBooked
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
std::vector< std::string > m_knownNames

◆ drawBarrelMaps()

void Phase1PixelMaps::drawBarrelMaps ( const std::string &  currentHistoName,
TCanvas &  canvas,
const char *  drawOption = nullptr 
)

Definition at line 336 of file Phase1PixelMaps.cc.

References adjustCanvasMargins(), svgfig::canvas(), histoStyle::drawOption, spr::find(), newFWLiteAna::found, mps_fire::i, m_autorescale, m_isBooked, m_knownNames, m_option, pxbTh2PolyBarrel, and rescaleAllBarrel().

Referenced by templateHelper::SiPixelIDs< PayloadType, myType >::fill().

336  {
337  canvas.Divide(2, 2);
338  auto found = (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) != m_knownNames.end());
339 
340  if (!m_isBooked.first || !found) {
341  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to draw a histogram not booked";
342  return;
343  }
344 
345  for (int i = 1; i <= 4; i++) {
346  canvas.cd(i);
347  if (strcmp(m_option, "text") == 0) {
348  canvas.cd(i)->SetRightMargin(0.02);
349  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->SetMarkerColor(kRed);
350  } else {
351  if (m_autorescale)
352  rescaleAllBarrel(currentHistoName);
353  adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
354  }
355  if (drawOption) {
356  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw("L");
357  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw(fmt::sprintf("%s%ssame", m_option, drawOption).c_str());
358  } else {
359  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw("L");
360  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw(fmt::sprintf("%ssame", m_option).c_str());
361  }
362  }
363 }
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Option_t * m_option
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void rescaleAllBarrel(const std::string &currentHistoName)
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::pair< bool, bool > m_isBooked
std::vector< std::string > m_knownNames
def canvas(sub, attr)
Definition: svgfig.py:482

◆ drawForwardMaps()

void Phase1PixelMaps::drawForwardMaps ( const std::string &  currentHistoName,
TCanvas &  canvas,
const char *  drawOption = nullptr 
)

Definition at line 366 of file Phase1PixelMaps.cc.

References adjustCanvasMargins(), svgfig::canvas(), histoStyle::drawOption, spr::find(), newFWLiteAna::found, mps_fire::i, m_autorescale, m_isBooked, m_knownNames, m_option, pxfTh2PolyForward, and rescaleAllForward().

Referenced by templateHelper::SiPixelIDs< PayloadType, myType >::fill().

366  {
367  canvas.Divide(3, 2);
368  auto found = (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) != m_knownNames.end());
369 
370  if (!m_isBooked.second || !found) {
371  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to draw a histogram not booked";
372  return;
373  }
374 
375  for (int i = 1; i <= 6; i++) {
376  canvas.cd(i);
377  if (strcmp(m_option, "text") == 0) {
378  canvas.cd(i)->SetRightMargin(0.02);
379  pxfTh2PolyForward[currentHistoName].at(i - 1)->SetMarkerColor(kRed);
380  } else {
381  if (m_autorescale)
382  rescaleAllForward(currentHistoName);
383  adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
384  }
385  if (drawOption) {
386  pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw("L");
387  pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw(fmt::sprintf("%s%ssame", m_option, drawOption).c_str());
388  } else {
389  pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw("L");
390  pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw(fmt::sprintf("%ssame", m_option).c_str());
391  }
392  }
393 }
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Option_t * m_option
void rescaleAllForward(const std::string &currentHistoName)
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
std::pair< bool, bool > m_isBooked
std::vector< std::string > m_knownNames
def canvas(sub, attr)
Definition: svgfig.py:482

◆ drawSummaryMaps()

void Phase1PixelMaps::drawSummaryMaps ( const std::string &  currentHistoName,
TCanvas &  canvas,
const char *  drawOption = nullptr 
)

Definition at line 396 of file Phase1PixelMaps.cc.

References adjustCanvasMargins(), svgfig::canvas(), histoStyle::drawOption, spr::find(), newFWLiteAna::found, m_isBooked, m_knownNames, m_option, pxbTh2PolyBarrelSummary, pxfTh2PolyForwardSummary, AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

396  {
397  auto found = (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) != m_knownNames.end());
398 
399  if (!m_isBooked.second || !m_isBooked.first || !found) {
400  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to draw a histogram not booked";
401  return;
402  }
403 
404  canvas.Divide(2, 1);
405  canvas.cd(1);
406  std::string temp(m_option); // create a std string
407  auto isText = (temp.find("text") != std::string::npos);
408  adjustCanvasMargins(canvas.cd(1), 0.07, 0.02, 0.01, isText ? 0.05 : 0.15);
409  if (isText) {
410  pxbTh2PolyBarrelSummary[currentHistoName]->SetMarkerColor(kRed);
411  pxbTh2PolyBarrelSummary[currentHistoName]->SetMarkerSize(0.5);
412  }
413  pxbTh2PolyBarrelSummary[currentHistoName]->GetZaxis()->SetTitleOffset(1.4);
414  pxbTh2PolyBarrelSummary[currentHistoName]->Draw("AL");
415  pxbTh2PolyBarrelSummary[currentHistoName]->Draw(fmt::sprintf("%s%ssame", m_option, drawOption).c_str());
416 
417  canvas.cd(2);
418  adjustCanvasMargins(canvas.cd(2), 0.07, 0.02, 0.01, isText ? 0.05 : 0.15);
419  if (isText) {
420  pxfTh2PolyForwardSummary[currentHistoName]->SetMarkerColor(kRed);
421  pxfTh2PolyForwardSummary[currentHistoName]->SetMarkerSize(0.5);
422  }
423  pxfTh2PolyForwardSummary[currentHistoName]->GetZaxis()->SetTitleOffset(1.4);
424  pxfTh2PolyForwardSummary[currentHistoName]->Draw("AL");
425  pxfTh2PolyForwardSummary[currentHistoName]->Draw(fmt::sprintf("%s%ssame", m_option, drawOption).c_str());
426 }
void adjustCanvasMargins(TVirtualPad *pad, float top, float bottom, float left, float right)
Option_t * m_option
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
std::pair< bool, bool > m_isBooked
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
std::vector< std::string > m_knownNames
def canvas(sub, attr)
Definition: svgfig.py:482

◆ fill()

void Phase1PixelMaps::fill ( const std::string &  currentHistoName,
unsigned int  id,
double  value 
)

Definition at line 222 of file Phase1PixelMaps.cc.

References phase1PixelTopology::layer, LogDebug, m_isBooked, m_trackerTopo, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLayer(), pxbTh2PolyBarrel, pxbTh2PolyBarrelSummary, TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), pxfTh2PolyForward, and pxfTh2PolyForwardSummary.

222  {
223  auto detid = DetId(id);
224  if (detid.subdetId() == PixelSubdetector::PixelBarrel) {
225  int layer = m_trackerTopo.pxbLayer(id);
226  if (!m_isBooked.first) {
227  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to fill a histogram not booked";
228  return;
229  }
230 
231  LogDebug("Phase1PixelMaps") << __func__ << " filling barrel with value: " << value << std::endl;
232 
233  pxbTh2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value);
234  pxbTh2PolyBarrelSummary[currentHistoName]->Fill(TString::Format("%u", id), value);
235  } else if (detid.subdetId() == PixelSubdetector::PixelEndcap) {
236  int disk = m_trackerTopo.pxfDisk(id);
237  int side = m_trackerTopo.pxfSide(id);
238  unsigned mapIdx = disk + (side - 1) * 3 - 1;
239  if (!m_isBooked.second) {
240  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to fill a histogram not booked";
241  return;
242  }
243 
244  LogDebug("Phase1PixelMaps") << __func__ << " filling endcaps with value: " << value << std::endl;
245 
246  pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value);
247  pxfTh2PolyForwardSummary[currentHistoName]->Fill(TString::Format("%u", id), value);
248  }
249 }
unsigned int pxbLayer(const DetId &id) const
Log< level::Error, false > LogError
constexpr std::array< uint8_t, layerIndexSize > layer
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
TrackerTopology m_trackerTopo
unsigned int pxfDisk(const DetId &id) const
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
Definition: value.py:1
std::pair< bool, bool > m_isBooked
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const
#define LogDebug(id)

◆ fillBarrelBin()

void Phase1PixelMaps::fillBarrelBin ( const std::string &  currentHistoName,
unsigned int  id,
double  value 
)

Definition at line 252 of file Phase1PixelMaps.cc.

References phase1PixelTopology::layer, m_isBooked, m_trackerTopo, PixelSubdetector::PixelBarrel, TrackerTopology::pxbLayer(), pxbTh2PolyBarrel, and pxbTh2PolyBarrelSummary.

Referenced by templateHelper::SiPixelIDs< PayloadType, myType >::fill().

252  {
253  auto detid = DetId(id);
254  if (detid.subdetId() != PixelSubdetector::PixelBarrel) {
255  edm::LogError("Phase1PixelMaps") << "fillBarrelBin() The following detid " << id << " is not Pixel Barrel!"
256  << std::endl;
257  return;
258  }
259  if (!m_isBooked.first) {
260  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to fill a histogram not booked";
261  return;
262  }
263  int layer = m_trackerTopo.pxbLayer(id);
264  pxbTh2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value);
265  pxbTh2PolyBarrelSummary[currentHistoName]->Fill(TString::Format("%u", id), value);
266 }
unsigned int pxbLayer(const DetId &id) const
Log< level::Error, false > LogError
constexpr std::array< uint8_t, layerIndexSize > layer
TrackerTopology m_trackerTopo
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
Definition: value.py:1
std::pair< bool, bool > m_isBooked
Definition: DetId.h:17

◆ fillForwardBin()

void Phase1PixelMaps::fillForwardBin ( const std::string &  currentHistoName,
unsigned int  id,
double  value 
)

Definition at line 269 of file Phase1PixelMaps.cc.

References m_isBooked, m_trackerTopo, PixelSubdetector::PixelEndcap, TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), pxfTh2PolyForward, and pxfTh2PolyForwardSummary.

Referenced by templateHelper::SiPixelIDs< PayloadType, myType >::fill().

269  {
270  auto detid = DetId(id);
271  if (detid.subdetId() != PixelSubdetector::PixelEndcap) {
272  edm::LogError("Phase1PixelMaps") << "fillForwardBin() The following detid " << id << " is not Pixel Forward!"
273  << std::endl;
274  return;
275  }
276  if (!m_isBooked.second) {
277  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to fill a histogram not booked";
278  return;
279  }
280  int disk = m_trackerTopo.pxfDisk(id);
281  int side = m_trackerTopo.pxfSide(id);
282  unsigned mapIdx = disk + (side - 1) * 3 - 1;
283  pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value);
284  pxfTh2PolyForwardSummary[currentHistoName]->Fill(TString::Format("%u", id), value);
285 }
Log< level::Error, false > LogError
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
TrackerTopology m_trackerTopo
unsigned int pxfDisk(const DetId &id) const
Definition: value.py:1
std::pair< bool, bool > m_isBooked
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
Definition: DetId.h:17
unsigned int pxfSide(const DetId &id) const

◆ makeNicePlotStyle()

void Phase1PixelMaps::makeNicePlotStyle ( TH1 *  hist)
private

Definition at line 489 of file Phase1PixelMaps.cc.

References HLT_2022v14_cff::Class, and gpuVertexFinder::hist.

Referenced by beautifyAllHistograms().

489  {
490  hist->SetStats(kFALSE);
491  hist->SetLineWidth(2);
492  hist->GetXaxis()->CenterTitle(true);
493  hist->GetYaxis()->CenterTitle(true);
494  hist->GetXaxis()->SetTitleFont(42);
495  hist->GetYaxis()->SetTitleFont(42);
496  hist->GetXaxis()->SetTitleSize(0.05);
497  hist->GetYaxis()->SetTitleSize(0.05);
498  hist->GetXaxis()->SetTitleOffset(1.1);
499  hist->GetYaxis()->SetTitleOffset(1.3);
500  hist->GetXaxis()->SetLabelFont(42);
501  hist->GetYaxis()->SetLabelFont(42);
502  hist->GetYaxis()->SetLabelSize(.05);
503  hist->GetXaxis()->SetLabelSize(.05);
504 
505  if (hist->InheritsFrom(TH2::Class())) {
506  hist->GetZaxis()->SetLabelFont(42);
507  hist->GetZaxis()->SetLabelFont(42);
508  hist->GetZaxis()->SetLabelSize(.05);
509  hist->GetZaxis()->SetLabelSize(.05);
510  }
511 }
__shared__ Hist hist

◆ rescaleAllBarrel()

void Phase1PixelMaps::rescaleAllBarrel ( const std::string &  currentHistoName)
private

Definition at line 526 of file Phase1PixelMaps.cc.

References mps_fire::end, spr::find(), timingPdfMaker::histo, m_knownNames, pxbTh2PolyBarrel, and HcalDetIdTransform::transform().

Referenced by drawBarrelMaps().

526  {
527  if (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) == m_knownNames.end()) {
528  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to manipulate a histogram not booked";
529  return;
530  }
531 
532  std::vector<float> maxima;
533  std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
534  pxbTh2PolyBarrel[currentHistoName].end(),
535  std::back_inserter(maxima),
536  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
537  std::vector<float> minima;
538  std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
539  pxbTh2PolyBarrel[currentHistoName].end(),
540  std::back_inserter(minima),
541  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });
542 
543  auto globalMax = *std::max_element(maxima.begin(), maxima.end());
544  auto globalMin = *std::min_element(minima.begin(), minima.end());
545 
546  for (auto& histo : pxbTh2PolyBarrel[currentHistoName]) {
547  histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
548  }
549 }
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
std::vector< std::string > m_knownNames
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ rescaleAllForward()

void Phase1PixelMaps::rescaleAllForward ( const std::string &  currentHistoName)
private

Definition at line 552 of file Phase1PixelMaps.cc.

References mps_fire::end, spr::find(), timingPdfMaker::histo, m_knownNames, pxfTh2PolyForward, and HcalDetIdTransform::transform().

Referenced by drawForwardMaps().

552  {
553  if (std::find(m_knownNames.begin(), m_knownNames.end(), currentHistoName) == m_knownNames.end()) {
554  edm::LogError("Phase1PixelMaps") << __func__ << ": trying to manipulate a histogram not booked";
555  return;
556  }
557 
558  std::vector<float> maxima;
559  std::transform(pxfTh2PolyForward[currentHistoName].begin(),
560  pxfTh2PolyForward[currentHistoName].end(),
561  std::back_inserter(maxima),
562  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
563  std::vector<float> minima;
564  std::transform(pxfTh2PolyForward[currentHistoName].begin(),
565  pxfTh2PolyForward[currentHistoName].end(),
566  std::back_inserter(minima),
567  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });
568 
569  auto globalMax = *std::max_element(maxima.begin(), maxima.end());
570  auto globalMin = *std::min_element(minima.begin(), minima.end());
571 
572  for (auto& histo : pxfTh2PolyForward[currentHistoName]) {
573  histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
574  }
575 }
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
std::vector< std::string > m_knownNames
unsigned transform(const HcalDetId &id, unsigned transformCode)

◆ resetOption()

void Phase1PixelMaps::resetOption ( const char *  option)

Definition at line 20 of file Phase1PixelMaps.cc.

References m_option, and fileinputsource_cfi::option.

20  {
21  if (m_option != nullptr && !m_option[0]) {
22  m_option = option;
23  } else {
24  edm::LogError("Phase1PixelMaps") << "Option has already been set to " << m_option
25  << ". It's not possible to reset it.";
26  }
27 }
Option_t * m_option
Log< level::Error, false > LogError

◆ retrieveCorners()

const indexedCorners Phase1PixelMaps::retrieveCorners ( const std::vector< edm::FileInPath > &  cornerFiles,
const unsigned int  reads 
)
private

Definition at line 429 of file Phase1PixelMaps.cc.

References mps_fire::end, Exception, geometryDiff::file, mps_fire::i, l1ctLayer2EG_cff::id, mps_splice::line, LOGDEBUG, Skims_PA_cff::name, MatrixUtil::remove(), AlCaHLTBitMon_QueryRunRegistry::string, and submitPVValidationJobs::t.

Referenced by bookBarrelBins(), and bookForwardBins().

430  {
431  indexedCorners theOutMap;
432 
433  for (const auto& file : cornerFiles) {
434  auto cornerFileName = file.fullPath();
435  std::ifstream cornerFile(cornerFileName.c_str());
436  if (!cornerFile.good()) {
437  throw cms::Exception("FileError") << "Problem opening corner file: " << cornerFileName;
438  }
440  while (std::getline(cornerFile, line)) {
441  if (!line.empty()) {
442  std::istringstream iss(line);
443  unsigned int id;
445  std::vector<std::string> corners(reads, "");
446  std::vector<float> xP, yP;
447 
448  iss >> id >> name;
449  for (unsigned int i = 0; i < reads; ++i) {
450  iss >> corners.at(i);
451  }
452 
453  LOGDEBUG("Phase1PixelMaps") << id << " : ";
454  for (unsigned int i = 0; i < reads; i++) {
455  // remove the leading and trailing " signs in the corners list
456  (corners[i]).erase(std::remove(corners[i].begin(), corners[i].end(), '"'), corners[i].end());
457  LOGDEBUG("Phase1PixelMaps") << corners.at(i) << " ";
458  typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
459  boost::char_separator<char> sep{","};
460  tokenizer tok{corners.at(i), sep};
461  for (const auto& t : tok | boost::adaptors::indexed(0)) {
462  if (t.index() == 0) {
463  xP.push_back(atof((t.value()).c_str()));
464  } else if (t.index() == 1) {
465  yP.push_back(atof((t.value()).c_str()));
466  } else {
467  edm::LogError("LogicError") << "There should not be any token with index " << t.index() << std::endl;
468  }
469  }
470  }
471  LOGDEBUG("Phase1PixelMaps") << std::endl;
472 
473  xP.push_back(xP.front());
474  yP.push_back(yP.front());
475 
476  for (unsigned int i = 0; i < xP.size(); i++) {
477  LOGDEBUG("Phase1PixelMaps") << "x[" << i << "]=" << xP[i] << " y[" << i << "]" << yP[i] << std::endl;
478  }
479 
480  theOutMap[id] = std::make_pair(xP, yP);
481 
482  } // if line is empty
483  } // loop on lines
484  } // loop on files
485  return theOutMap;
486 }
Log< level::Error, false > LogError
#define LOGDEBUG(x)
std::map< unsigned int, std::pair< std::vector< float >, std::vector< float > >> indexedCorners
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:223

◆ setBarrelScale()

void Phase1PixelMaps::setBarrelScale ( const std::string &  currentHistoName,
std::pair< float, float >  extrema 
)

Definition at line 322 of file Phase1PixelMaps.cc.

References timingPdfMaker::histo, and pxbTh2PolyBarrel.

322  {
323  for (auto& histo : pxbTh2PolyBarrel[currentHistoName]) {
324  histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
325  }
326 }
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel

◆ setForwardScale()

void Phase1PixelMaps::setForwardScale ( const std::string &  currentHistoName,
std::pair< float, float >  extrema 
)

Definition at line 329 of file Phase1PixelMaps.cc.

References timingPdfMaker::histo, and pxfTh2PolyForward.

329  {
330  for (auto& histo : pxfTh2PolyForward[currentHistoName]) {
331  histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
332  }
333 }
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward

◆ setNoRescale()

void Phase1PixelMaps::setNoRescale ( )
inline

Definition at line 56 of file Phase1PixelMaps.h.

References m_autorescale.

56 { m_autorescale = false; }

Member Data Documentation

◆ bins

std::map<uint32_t, std::shared_ptr<TGraph> > Phase1PixelMaps::bins
private

Definition at line 93 of file Phase1PixelMaps.h.

Referenced by bookBarrelBins(), and bookForwardBins().

◆ binsSummary

std::map<uint32_t, std::shared_ptr<TGraph> > Phase1PixelMaps::binsSummary
private

Definition at line 93 of file Phase1PixelMaps.h.

Referenced by bookBarrelBins(), and bookForwardBins().

◆ m_autorescale

bool Phase1PixelMaps::m_autorescale
private

Definition at line 87 of file Phase1PixelMaps.h.

Referenced by drawBarrelMaps(), drawForwardMaps(), and setNoRescale().

◆ m_cornersBPIX

std::vector<edm::FileInPath> Phase1PixelMaps::m_cornersBPIX
private

Definition at line 99 of file Phase1PixelMaps.h.

Referenced by bookBarrelBins().

◆ m_cornersFPIX

std::vector<edm::FileInPath> Phase1PixelMaps::m_cornersFPIX
private

Definition at line 100 of file Phase1PixelMaps.h.

Referenced by bookForwardBins().

◆ m_isBooked

std::pair<bool, bool> Phase1PixelMaps::m_isBooked
private

◆ m_knownNames

std::vector<std::string> Phase1PixelMaps::m_knownNames
private

◆ m_option

Option_t* Phase1PixelMaps::m_option
private

◆ m_trackerTopo

TrackerTopology Phase1PixelMaps::m_trackerTopo
private

◆ pxbTh2PolyBarrel

std::map<std::string, std::vector<std::shared_ptr<TH2Poly> > > Phase1PixelMaps::pxbTh2PolyBarrel
private

◆ pxbTh2PolyBarrelSummary

std::map<std::string, std::shared_ptr<TH2Poly> > Phase1PixelMaps::pxbTh2PolyBarrelSummary
private

◆ pxfTh2PolyForward

std::map<std::string, std::vector<std::shared_ptr<TH2Poly> > > Phase1PixelMaps::pxfTh2PolyForward
private

◆ pxfTh2PolyForwardSummary

std::map<std::string, std::shared_ptr<TH2Poly> > Phase1PixelMaps::pxfTh2PolyForwardSummary
private