8 #include <fmt/printf.h>
10 #include <boost/tokenizer.hpp>
11 #include <boost/range/adaptor/indexed.hpp>
25 <<
". It's not possible to reset it.";
32 std::shared_ptr<TH2Poly> th2p;
34 for (
unsigned i = 0;
i < 4; ++
i) {
35 histName =
"barrel_layer_";
37 th2p = std::make_shared<TH2Poly>(
38 (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);
42 th2p->GetXaxis()->SetTitle(
"z [cm]");
43 th2p->GetYaxis()->SetTitle(
"ladder");
44 th2p->GetZaxis()->SetTitle(
zaxis);
45 th2p->GetZaxis()->CenterTitle();
46 th2p->SetStats(
false);
51 th2p = std::make_shared<TH2Poly>(
"barrel_summary", Form(
"Barrel Pixel Map of %s", what), -5.0, 5.0, 0.0, 15.0);
54 th2p->GetXaxis()->SetTitle(
"");
55 th2p->GetYaxis()->SetTitle(
"");
56 th2p->GetZaxis()->SetTitle(
zaxis);
57 th2p->GetZaxis()->CenterTitle();
58 th2p->SetStats(
false);
66 std::shared_ptr<TH2Poly> th2p;
68 for (
unsigned side = 1; side <= 2; ++side) {
69 for (
unsigned disk = 1; disk <= 3; ++disk) {
70 histName =
"forward_disk_";
72 th2p = std::make_shared<TH2Poly>((histName + std::to_string((side == 1 ? -(
int(disk)) : (
int)disk))).c_str(),
73 Form(
"PXFMap of %s - Side %i Disk %i", what, side, disk),
79 th2p->GetXaxis()->SetTitle(
"x [cm]");
80 th2p->GetYaxis()->SetTitle(
"y [cm]");
81 th2p->GetZaxis()->SetTitle(
zaxis);
82 th2p->GetZaxis()->CenterTitle();
83 th2p->SetStats(
false);
89 th2p = std::make_shared<TH2Poly>(
"forward_summary", Form(
"Forward Pixel Map of %s", what), -40.0, 40.0, -20.0, 90.0);
92 th2p->GetXaxis()->SetTitle(
"");
93 th2p->GetYaxis()->SetTitle(
"");
94 th2p->GetZaxis()->SetTitle(
zaxis);
95 th2p->GetZaxis()->CenterTitle();
96 th2p->SetStats(
false);
105 for (
const auto&
entry : theIndexedCorners) {
106 auto id =
entry.first;
107 auto detid =
DetId(
id);
114 auto theVectX =
entry.second.first;
115 auto theVectY =
entry.second.second;
117 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]};
120 bins[
id] = std::make_shared<TGraph>(5, vertX, vertY);
121 bins[
id]->SetName(TString::Format(
"%u",
id));
124 for (
unsigned k = 0;
k < 5; ++
k) {
126 vertY[
k] += ((
layer > 2) ? 30.0
f : 0.0
f);
135 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Barrel map! Aborting.";
141 throw cms::Exception(
"LocalError") << currentHistoName <<
" is not found in the Barrel Summary map! Aborting.";
150 for (
const auto&
entry : theIndexedCorners) {
151 auto id =
entry.first;
152 auto detid =
DetId(
id);
159 unsigned mapIdx = disk + (side - 1) * 3 - 1;
161 auto theVectX =
entry.second.first;
162 auto theVectY =
entry.second.second;
164 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]};
165 float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]};
167 bins[
id] = std::make_shared<TGraph>(4, vertX, vertY);
168 bins[
id]->SetName(TString::Format(
"%u",
id));
171 for (
unsigned k = 0;
k < 4; ++
k) {
172 vertX[
k] += (
float(side) - 1.5f) * 40.0
f;
173 vertY[
k] += (disk - 1) * 35.0
f;
182 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward map! Aborting.";
188 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward Summary map! Aborting.";
195 auto detid =
DetId(
id);
197 edm::LogError(
"Phase1PixelMaps") <<
"fillBarrelBin() The following detid " <<
id <<
" is not Pixel Barrel!"
208 auto detid =
DetId(
id);
210 edm::LogError(
"Phase1PixelMaps") <<
"fillForwardBin() The following detid " <<
id <<
" is not Pixel Forward!"
216 unsigned mapIdx = disk + (side - 1) * 3 - 1;
224 for (
const auto&
plot : vec.second) {
226 plot->GetXaxis()->SetTitleOffset(0.9);
227 plot->GetYaxis()->SetTitleOffset(0.9);
228 plot->GetZaxis()->SetTitleOffset(1.2);
229 plot->GetZaxis()->SetTitleSize(0.05);
234 for (
const auto&
plot : vec.second) {
236 plot->GetXaxis()->SetTitleOffset(0.9);
237 plot->GetYaxis()->SetTitleOffset(0.9);
238 plot->GetZaxis()->SetTitleOffset(1.2);
239 plot->GetZaxis()->SetTitleSize(0.05);
247 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
254 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
261 for (
int i = 1;
i <= 4;
i++) {
263 if (strcmp(
m_option,
"text") == 0) {
264 canvas.cd(
i)->SetRightMargin(0.02);
284 for (
int i = 1;
i <= 6;
i++) {
286 if (strcmp(
m_option,
"text") == 0) {
287 canvas.cd(
i)->SetRightMargin(0.02);
310 if (
temp.find(
"text") != 0) {
319 if (
temp.find(
"text") != 0) {
329 const unsigned int reads) {
332 for (
const auto&
file : cornerFiles) {
333 auto cornerFileName =
file.fullPath();
334 std::ifstream cornerFile(cornerFileName.c_str());
335 if (!cornerFile.good()) {
336 throw cms::Exception(
"FileError") <<
"Problem opening corner file: " << cornerFileName;
339 while (std::getline(cornerFile,
line)) {
341 std::istringstream iss(
line);
344 std::vector<std::string> corners(reads,
"");
345 std::vector<float> xP, yP;
348 for (
unsigned int i = 0;
i < reads; ++
i) {
349 iss >> corners.at(
i);
352 LOGDEBUG(
"Phase1PixelMaps") <<
id <<
" : ";
353 for (
unsigned int i = 0;
i < reads;
i++) {
355 (corners[
i]).erase(
std::remove(corners[
i].begin(), corners[
i].
end(),
'"'), corners[
i].end());
356 LOGDEBUG(
"Phase1PixelMaps") << corners.at(
i) <<
" ";
357 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
358 boost::char_separator<char> sep{
","};
359 tokenizer tok{corners.at(
i), sep};
360 for (
const auto&
t : tok | boost::adaptors::indexed(0)) {
361 if (
t.index() == 0) {
362 xP.push_back(atof((
t.value()).c_str()));
363 }
else if (
t.index() == 1) {
364 yP.push_back(atof((
t.value()).c_str()));
366 edm::LogError(
"LogicError") <<
"There should not be any token with index " <<
t.index() << std::endl;
370 LOGDEBUG(
"Phase1PixelMaps") << std::endl;
372 xP.push_back(xP.front());
373 yP.push_back(yP.front());
375 for (
unsigned int i = 0;
i < xP.size();
i++) {
376 LOGDEBUG(
"Phase1PixelMaps") <<
"x[" <<
i <<
"]=" << xP[
i] <<
" y[" <<
i <<
"]" << yP[
i] << std::endl;
379 theOutMap[
id] = std::make_pair(xP, yP);
389 hist->SetStats(kFALSE);
390 hist->SetLineWidth(2);
391 hist->GetXaxis()->CenterTitle(
true);
392 hist->GetYaxis()->CenterTitle(
true);
393 hist->GetXaxis()->SetTitleFont(42);
394 hist->GetYaxis()->SetTitleFont(42);
395 hist->GetXaxis()->SetTitleSize(0.05);
396 hist->GetYaxis()->SetTitleSize(0.05);
397 hist->GetXaxis()->SetTitleOffset(1.1);
398 hist->GetYaxis()->SetTitleOffset(1.3);
399 hist->GetXaxis()->SetLabelFont(42);
400 hist->GetYaxis()->SetLabelFont(42);
401 hist->GetYaxis()->SetLabelSize(.05);
402 hist->GetXaxis()->SetLabelSize(.05);
405 hist->GetZaxis()->SetLabelFont(42);
406 hist->GetZaxis()->SetLabelFont(42);
407 hist->GetZaxis()->SetLabelSize(.05);
408 hist->GetZaxis()->SetLabelSize(.05);
415 pad->SetTopMargin(top);
417 pad->SetBottomMargin(bottom);
419 pad->SetLeftMargin(left);
421 pad->SetRightMargin(right);
426 std::vector<float> maxima;
429 std::back_inserter(maxima),
430 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
431 std::vector<float> minima;
434 std::back_inserter(minima),
435 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
437 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
438 auto globalMin = *std::min_element(minima.begin(), minima.end());
441 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
447 std::vector<float> maxima;
450 std::back_inserter(maxima),
451 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
452 std::vector<float> minima;
455 std::back_inserter(minima),
456 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
458 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
459 auto globalMin = *std::min_element(minima.begin(), minima.end());
462 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);