CMS 3D CMS Logo

Phase1PixelMaps.h
Go to the documentation of this file.
1 #ifndef CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H
2 #define CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H
3 
4 #include "TH2Poly.h"
7 
8 /*--------------------------------------------------------------------
9 / Ancillary class to build pixel phase-1 tracker maps
10 /--------------------------------------------------------------------*/
12 public:
13  Phase1PixelMaps(const char* option)
14  : m_option{option},
16  edm::FileInPath("Geometry/TrackerCommonData/data/PhaseI/trackerParameters.xml").fullPath())} {
17  // store the file in path for the corners (BPIX)
18  for (unsigned int i = 1; i <= 4; i++) {
19  m_cornersBPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_barrel_%i", i)));
20  }
21 
22  // store the file in path for the corners (BPIX)
23  for (int j : {-3, -2, -1, 1, 2, 3}) {
24  m_cornersFPIX.push_back(edm::FileInPath(Form("DQM/SiStripMonitorClient/data/Geometry/vertices_forward_%i", j)));
25  }
26  }
27 
29 
30  //============================================================================
31  void bookBarrelHistograms(const std::string& currentHistoName, const char* what, const char* zaxis) {
32  std::string histName;
33  std::shared_ptr<TH2Poly> th2p;
34 
35  for (unsigned i = 0; i < 4; ++i) {
36  histName = "barrel_layer_";
37 
38  th2p = std::make_shared<TH2Poly>((histName + std::to_string(i + 1)).c_str(),
39  Form("PXBMap of %s - Layer %i", what, i + 1),
40  -15.0,
41  15.0,
42  0.0,
43  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", "PXBMap", -5.0, 5.0, 0.0, 5.0);
57  th2p->SetFloat();
58 
59  th2p->GetXaxis()->SetTitle("");
60  th2p->GetYaxis()->SetTitle("~ladder");
61  th2p->SetStats(false);
62  th2p->SetOption(m_option);
63  pxbTh2PolyBarrelSummary[currentHistoName] = th2p;
64  }
65 
66  //============================================================================
67  void bookForwardHistograms(const std::string& currentHistoName, const char* what, const char* zaxis) {
68  std::string histName;
69  std::shared_ptr<TH2Poly> th2p;
70 
71  for (unsigned side = 1; side <= 2; ++side) {
72  for (unsigned disk = 1; disk <= 3; ++disk) {
73  histName = "forward_disk_";
74 
75  th2p = std::make_shared<TH2Poly>((histName + std::to_string((side == 1 ? -(int(disk)) : (int)disk))).c_str(),
76  Form("PXFMap of %s - Side %i Disk %i", what, side, disk),
77  -15.0,
78  15.0,
79  -15.0,
80  15.0);
81  th2p->SetFloat();
82  th2p->GetXaxis()->SetTitle("x [cm]");
83  th2p->GetYaxis()->SetTitle("y [cm]");
84  th2p->GetZaxis()->SetTitle(zaxis);
85  th2p->GetZaxis()->CenterTitle();
86  th2p->SetStats(false);
87  th2p->SetOption(m_option);
88  pxfTh2PolyForward[currentHistoName].push_back(th2p);
89  }
90  }
91 
92  th2p = std::make_shared<TH2Poly>("forward_summary", "PXFMap", -40.0, 50.0, -20.0, 90.0);
93  th2p->SetFloat();
94 
95  th2p->GetXaxis()->SetTitle("");
96  th2p->GetYaxis()->SetTitle("");
97  th2p->SetStats(false);
98  th2p->SetOption(m_option);
99  pxfTh2PolyForwardSummary[currentHistoName] = th2p;
100  }
101 
102  //============================================================================
103  void bookBarrelBins(const std::string& currentHistoName) {
104  auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersBPIX, 4);
105 
106  for (const auto& entry : theIndexedCorners) {
107  auto id = entry.first;
108  auto detid = DetId(id);
109  if (detid.subdetId() != PixelSubdetector::PixelBarrel)
110  continue;
111 
112  int layer = m_trackerTopo.pxbLayer(detid);
113  int ladder = m_trackerTopo.pxbLadder(detid);
114 
115  auto theVectX = entry.second.first;
116  auto theVectY = entry.second.second;
117 
118  float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]};
119  float vertY[] = {(ladder - 1.0f), (ladder - 1.0f), (float)ladder, (float)ladder, (ladder - 1.0f)};
120 
121  bins[id] = std::make_shared<TGraph>(5, vertX, vertY);
122  bins[id]->SetName(TString::Format("%u", id));
123 
124  // Summary plot
125  for (unsigned k = 0; k < 5; ++k) {
126  vertX[k] += ((layer == 2 || layer == 3) ? 0.0f : -60.0f);
127  vertY[k] += ((layer > 2) ? 30.0f : 0.0f);
128  }
129 
130  binsSummary[id] = std::make_shared<TGraph>(5, vertX, vertY);
131  binsSummary[id]->SetName(TString::Format("%u", id));
132 
133  pxbTh2PolyBarrel[currentHistoName][layer - 1]->AddBin(bins[id]->Clone());
134  pxbTh2PolyBarrelSummary[currentHistoName]->AddBin(binsSummary[id]->Clone());
135  }
136  }
137 
138  //============================================================================
139  void bookForwardBins(const std::string& currentHistoName) {
140  auto theIndexedCorners = SiPixelPI::retrieveCorners(m_cornersFPIX, 3);
141 
142  for (const auto& entry : theIndexedCorners) {
143  auto id = entry.first;
144  auto detid = DetId(id);
145  if (detid.subdetId() != PixelSubdetector::PixelEndcap)
146  continue;
147 
148  int disk = m_trackerTopo.pxfDisk(detid);
149  int side = m_trackerTopo.pxfSide(detid);
150 
151  unsigned mapIdx = disk + (side - 1) * 3 - 1;
152 
153  auto theVectX = entry.second.first;
154  auto theVectY = entry.second.second;
155 
156  float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]};
157  float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]};
158 
159  bins[id] = std::make_shared<TGraph>(4, vertX, vertY);
160  bins[id]->SetName(TString::Format("%u", id));
161 
162  // Summary plot
163  for (unsigned k = 0; k < 4; ++k) {
164  vertX[k] += (float(side) - 1.5f) * 40.0f;
165  vertY[k] += (disk - 1) * 35.0f;
166  }
167 
168  binsSummary[id] = std::make_shared<TGraph>(4, vertX, vertY);
169  binsSummary[id]->SetName(TString::Format("%u", id));
170 
171  pxfTh2PolyForward[currentHistoName][mapIdx]->AddBin(bins[id]->Clone());
172  pxfTh2PolyForwardSummary[currentHistoName]->AddBin(binsSummary[id]->Clone());
173  }
174  }
175 
176  //============================================================================
177  template <typename type>
178  void fillBarrelBin(const std::string& currentHistoName, unsigned int id, type value) {
179  auto detid = DetId(id);
180  if (detid.subdetId() != PixelSubdetector::PixelBarrel) {
181  edm::LogError("Phase1PixelMaps") << "fillBarrelBin() The following detid " << id << " is not Pixel Barrel!"
182  << std::endl;
183  return;
184  }
185  int layer = m_trackerTopo.pxbLayer(id);
186  pxbTh2PolyBarrel[currentHistoName][layer - 1]->Fill(TString::Format("%u", id), value);
187  }
188 
189  //============================================================================
190  template <typename type>
191  void fillForwardBin(const std::string& currentHistoName, unsigned int id, type value) {
192  auto detid = DetId(id);
193  if (detid.subdetId() != PixelSubdetector::PixelEndcap) {
194  edm::LogError("Phase1PixelMaps") << "fillForwardBin() The following detid " << id << " is not Pixel Forward!"
195  << std::endl;
196  return;
197  }
198  int disk = m_trackerTopo.pxfDisk(id);
199  int side = m_trackerTopo.pxfSide(id);
200  unsigned mapIdx = disk + (side - 1) * 3 - 1;
201  pxfTh2PolyForward[currentHistoName][mapIdx]->Fill(TString::Format("%u", id), value);
202  }
203 
204  //============================================================================
206  for (const auto& vec : pxbTh2PolyBarrel) {
207  for (const auto& plot : vec.second) {
209  plot->GetXaxis()->SetTitleOffset(0.9);
210  plot->GetYaxis()->SetTitleOffset(0.9);
211  plot->GetZaxis()->SetTitleOffset(1.2);
212  plot->GetZaxis()->SetTitleSize(0.05);
213  }
214  }
215 
216  for (const auto& vec : pxfTh2PolyForward) {
217  for (const auto& plot : vec.second) {
219  plot->GetXaxis()->SetTitleOffset(0.9);
220  plot->GetYaxis()->SetTitleOffset(0.9);
221  plot->GetZaxis()->SetTitleOffset(1.2);
222  plot->GetZaxis()->SetTitleSize(0.05);
223  }
224  }
225  }
226 
227  //============================================================================
228  void rescaleAllBarrel(const std::string& currentHistoName) {
229  std::vector<float> maxima;
230  std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
231  pxbTh2PolyBarrel[currentHistoName].end(),
232  std::back_inserter(maxima),
233  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
234  std::vector<float> minima;
235  std::transform(pxbTh2PolyBarrel[currentHistoName].begin(),
236  pxbTh2PolyBarrel[currentHistoName].end(),
237  std::back_inserter(minima),
238  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });
239 
240  auto globalMax = *std::max_element(maxima.begin(), maxima.end());
241  auto globalMin = *std::min_element(minima.begin(), minima.end());
242 
243  for (auto& histo : pxbTh2PolyBarrel[currentHistoName]) {
244  histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
245  }
246  }
247 
248  //============================================================================
249  void rescaleAllForward(const std::string& currentHistoName) {
250  std::vector<float> maxima;
251  std::transform(pxfTh2PolyForward[currentHistoName].begin(),
252  pxfTh2PolyForward[currentHistoName].end(),
253  std::back_inserter(maxima),
254  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMaximum(); });
255  std::vector<float> minima;
256  std::transform(pxfTh2PolyForward[currentHistoName].begin(),
257  pxfTh2PolyForward[currentHistoName].end(),
258  std::back_inserter(minima),
259  [](std::shared_ptr<TH2Poly> thp) -> float { return thp->GetMinimum(); });
260 
261  auto globalMax = *std::max_element(maxima.begin(), maxima.end());
262  auto globalMin = *std::min_element(minima.begin(), minima.end());
263 
264  for (auto& histo : pxfTh2PolyForward[currentHistoName]) {
265  histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
266  }
267  }
268 
269  //============================================================================
270  void DrawBarrelMaps(const std::string& currentHistoName, TCanvas& canvas) {
271  canvas.Divide(2, 2);
272  for (int i = 1; i <= 4; i++) {
273  canvas.cd(i);
274  if (strcmp(m_option, "text") == 0) {
275  canvas.cd(i)->SetRightMargin(0.02);
276  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->SetMarkerColor(kRed);
277  } else {
278  rescaleAllBarrel(currentHistoName);
279  SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
280  }
281  pxbTh2PolyBarrel[currentHistoName].at(i - 1)->Draw();
282  }
283  }
284 
285  //============================================================================
286  void DrawForwardMaps(const std::string& currentHistoName, TCanvas& canvas) {
287  canvas.Divide(3, 2);
288  for (int i = 1; i <= 6; i++) {
289  canvas.cd(i);
290  if (strcmp(m_option, "text") == 0) {
291  canvas.cd(i)->SetRightMargin(0.02);
292  pxfTh2PolyForward[currentHistoName].at(i - 1)->SetMarkerColor(kRed);
293  } else {
294  rescaleAllForward(currentHistoName);
295  SiPixelPI::adjustCanvasMargins(canvas.cd(i), 0.07, 0.12, 0.10, 0.18);
296  }
297  pxfTh2PolyForward[currentHistoName].at(i - 1)->Draw();
298  }
299  }
300 
301 private:
302  Option_t* m_option;
304 
305  std::map<uint32_t, std::shared_ptr<TGraph>> bins, binsSummary;
306  std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxbTh2PolyBarrel;
307  std::map<std::string, std::shared_ptr<TH2Poly>> pxbTh2PolyBarrelSummary;
308  std::map<std::string, std::vector<std::shared_ptr<TH2Poly>>> pxfTh2PolyForward;
309  std::map<std::string, std::shared_ptr<TH2Poly>> pxfTh2PolyForwardSummary;
310 
311  std::vector<edm::FileInPath> m_cornersBPIX;
312  std::vector<edm::FileInPath> m_cornersFPIX;
313 };
314 
315 #endif
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
Phase1PixelMaps::bins
std::map< uint32_t, std::shared_ptr< TGraph > > bins
Definition: Phase1PixelMaps.h:305
Phase1PixelMaps::m_cornersFPIX
std::vector< edm::FileInPath > m_cornersFPIX
Definition: Phase1PixelMaps.h:312
Phase1PixelMaps::fillBarrelBin
void fillBarrelBin(const std::string &currentHistoName, unsigned int id, type value)
Definition: Phase1PixelMaps.h:178
mps_fire.i
i
Definition: mps_fire.py:355
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
TrackerTopology::pxfSide
unsigned int pxfSide(const DetId &id) const
Definition: TrackerTopology.h:192
Phase1PixelMaps::bookBarrelHistograms
void bookBarrelHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)
Definition: Phase1PixelMaps.h:31
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
mps_splice.entry
entry
Definition: mps_splice.py:68
TrackerTopology
Definition: TrackerTopology.h:16
TrackerTopology::pxbLadder
unsigned int pxbLadder(const DetId &id) const
Definition: TrackerTopology.h:155
Phase1PixelMaps::pxfTh2PolyForward
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxfTh2PolyForward
Definition: Phase1PixelMaps.h:308
Phase1PixelMaps::beautifyAllHistograms
void beautifyAllHistograms()
Definition: Phase1PixelMaps.h:205
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
Phase1PixelMaps::bookBarrelBins
void bookBarrelBins(const std::string &currentHistoName)
Definition: Phase1PixelMaps.h:103
Phase1PixelMaps::rescaleAllBarrel
void rescaleAllBarrel(const std::string &currentHistoName)
Definition: Phase1PixelMaps.h:228
Phase1PixelMaps::Phase1PixelMaps
Phase1PixelMaps(const char *option)
Definition: Phase1PixelMaps.h:13
plotFactory.plot
plot
Definition: plotFactory.py:109
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:87
LaserClient_cfi.zaxis
zaxis
Definition: LaserClient_cfi.py:91
end
#define end
Definition: vmac.h:39
TrackerTopology::pxbLayer
unsigned int pxbLayer(const DetId &id) const
Definition: TrackerTopology.h:144
Phase1PixelMaps::pxbTh2PolyBarrel
std::map< std::string, std::vector< std::shared_ptr< TH2Poly > > > pxbTh2PolyBarrel
Definition: Phase1PixelMaps.h:306
DetId
Definition: DetId.h:17
edm::FileInPath
Definition: FileInPath.h:64
Phase1PixelMaps::bookForwardBins
void bookForwardBins(const std::string &currentHistoName)
Definition: Phase1PixelMaps.h:139
StandaloneTrackerTopology.h
SiPixelPI::retrieveCorners
const indexedCorners retrieveCorners(const std::vector< edm::FileInPath > &cornerFiles, const unsigned int reads)
Definition: SiPixelPayloadInspectorHelper.h:910
Phase1PixelMaps::DrawForwardMaps
void DrawForwardMaps(const std::string &currentHistoName, TCanvas &canvas)
Definition: Phase1PixelMaps.h:286
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Phase1PixelMaps
Definition: Phase1PixelMaps.h:11
Phase1PixelMaps::fillForwardBin
void fillForwardBin(const std::string &currentHistoName, unsigned int id, type value)
Definition: Phase1PixelMaps.h:191
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Phase1PixelMaps::DrawBarrelMaps
void DrawBarrelMaps(const std::string &currentHistoName, TCanvas &canvas)
Definition: Phase1PixelMaps.h:270
Phase1PixelMaps::pxbTh2PolyBarrelSummary
std::map< std::string, std::shared_ptr< TH2Poly > > pxbTh2PolyBarrelSummary
Definition: Phase1PixelMaps.h:307
edm::LogError
Definition: MessageLogger.h:183
Phase1PixelMaps::bookForwardHistograms
void bookForwardHistograms(const std::string &currentHistoName, const char *what, const char *zaxis)
Definition: Phase1PixelMaps.h:67
Phase1PixelMaps::binsSummary
std::map< uint32_t, std::shared_ptr< TGraph > > binsSummary
Definition: Phase1PixelMaps.h:305
value
Definition: value.py:1
TrackerTopology::pxfDisk
unsigned int pxfDisk(const DetId &id) const
Definition: TrackerTopology.h:446
Phase1PixelMaps::pxfTh2PolyForwardSummary
std::map< std::string, std::shared_ptr< TH2Poly > > pxfTh2PolyForwardSummary
Definition: Phase1PixelMaps.h:309
Phase1PixelMaps::rescaleAllForward
void rescaleAllForward(const std::string &currentHistoName)
Definition: Phase1PixelMaps.h:249
type
type
Definition: HCALResponse.h:21
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
SiPixelPI::makeNicePlotStyle
void makeNicePlotStyle(TH1 *hist)
Definition: SiPixelPayloadInspectorHelper.h:475
Phase1PixelMaps::m_cornersBPIX
std::vector< edm::FileInPath > m_cornersBPIX
Definition: Phase1PixelMaps.h:311
SiPixelPayloadInspectorHelper.h
Phase1PixelMaps::m_trackerTopo
TrackerTopology m_trackerTopo
Definition: Phase1PixelMaps.h:303
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Phase1PixelMaps::m_option
Option_t * m_option
Definition: Phase1PixelMaps.h:302
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
Phase1PixelMaps::~Phase1PixelMaps
~Phase1PixelMaps()
Definition: Phase1PixelMaps.h:28