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;
39 for (
unsigned i = 0;
i < 4; ++
i) {
40 histName =
"barrel_layer_";
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);
47 th2p->GetXaxis()->SetTitle(
"z [cm]");
48 th2p->GetYaxis()->SetTitle(
"ladder");
49 th2p->GetZaxis()->SetTitle(
zaxis);
50 th2p->GetZaxis()->CenterTitle();
51 th2p->SetStats(
false);
56 th2p = std::make_shared<TH2Poly>(
"barrel_summary", Form(
"Barrel Pixel Map of %s", what), -5.0, 5.0, 0.0, 15.0);
59 th2p->GetXaxis()->SetTitle(
"");
60 th2p->GetYaxis()->SetTitle(
"");
61 th2p->GetZaxis()->SetTitle(
zaxis);
62 th2p->GetZaxis()->CenterTitle();
63 th2p->SetStats(
false);
77 std::shared_ptr<TH2Poly> th2p;
84 for (
unsigned side = 1; side <= 2; ++side) {
85 for (
unsigned disk = 1; disk <= 3; ++disk) {
86 histName =
"forward_disk_";
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),
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);
105 th2p = std::make_shared<TH2Poly>(
"forward_summary", Form(
"Forward Pixel Map of %s", what), -40.0, 40.0, -20.0, 90.0);
108 th2p->GetXaxis()->SetTitle(
"");
109 th2p->GetYaxis()->SetTitle(
"");
110 th2p->GetZaxis()->SetTitle(
zaxis);
111 th2p->GetZaxis()->CenterTitle();
112 th2p->SetStats(
false);
126 for (
const auto&
entry : theIndexedCorners) {
127 auto id =
entry.first;
128 auto detid =
DetId(
id);
135 auto theVectX =
entry.second.first;
136 auto theVectY =
entry.second.second;
138 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]};
141 bins[
id] = std::make_shared<TGraph>(5, vertX, vertY);
142 bins[
id]->SetName(TString::Format(
"%u",
id));
145 for (
unsigned k = 0;
k < 5; ++
k) {
147 vertY[
k] += ((
layer > 2) ? 30.0
f : 0.0
f);
156 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Barrel map! Aborting.";
162 throw cms::Exception(
"LocalError") << currentHistoName <<
" is not found in the Barrel Summary map! Aborting.";
171 for (
const auto&
entry : theIndexedCorners) {
172 auto id =
entry.first;
173 auto detid =
DetId(
id);
180 unsigned mapIdx = disk + (side - 1) * 3 - 1;
182 auto theVectX =
entry.second.first;
183 auto theVectY =
entry.second.second;
185 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]};
186 float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]};
188 bins[
id] = std::make_shared<TGraph>(4, vertX, vertY);
189 bins[
id]->SetName(TString::Format(
"%u",
id));
192 for (
unsigned k = 0;
k < 4; ++
k) {
193 vertX[
k] += (
float(side) - 1.5f) * 40.0
f;
194 vertY[
k] += (disk - 1) * 35.0
f;
203 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward map! Aborting.";
209 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward Summary map! Aborting.";
223 auto detid =
DetId(
id);
227 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to fill a histogram not booked";
231 LogDebug(
"Phase1PixelMaps") << __func__ <<
" filling barrel with value: " <<
value << std::endl;
238 unsigned mapIdx = disk + (side - 1) * 3 - 1;
240 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to fill a histogram not booked";
244 LogDebug(
"Phase1PixelMaps") << __func__ <<
" filling endcaps with value: " <<
value << std::endl;
253 auto detid =
DetId(
id);
255 edm::LogError(
"Phase1PixelMaps") <<
"fillBarrelBin() The following detid " <<
id <<
" is not Pixel Barrel!"
260 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to fill a histogram not booked";
270 auto detid =
DetId(
id);
272 edm::LogError(
"Phase1PixelMaps") <<
"fillForwardBin() The following detid " <<
id <<
" is not Pixel Forward!"
277 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to fill a histogram not booked";
282 unsigned mapIdx = disk + (side - 1) * 3 - 1;
290 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to beautify a histogram not booked";
297 for (
const auto&
plot : vec.second) {
299 plot->GetXaxis()->SetTitleOffset(0.9);
300 plot->GetYaxis()->SetTitleOffset(0.9);
301 plot->GetZaxis()->SetTitleOffset(1.2);
302 plot->GetZaxis()->SetTitleSize(0.05);
310 for (
const auto&
plot : vec.second) {
312 plot->GetXaxis()->SetTitleOffset(0.9);
313 plot->GetYaxis()->SetTitleOffset(0.9);
314 plot->GetZaxis()->SetTitleOffset(1.2);
315 plot->GetZaxis()->SetTitleSize(0.05);
324 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
331 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
341 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to draw a histogram not booked";
345 for (
int i = 1;
i <= 4;
i++) {
347 if (strcmp(
m_option,
"text") == 0) {
348 canvas.cd(
i)->SetRightMargin(0.02);
371 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to draw a histogram not booked";
375 for (
int i = 1;
i <= 6;
i++) {
377 if (strcmp(
m_option,
"text") == 0) {
378 canvas.cd(
i)->SetRightMargin(0.02);
400 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to draw a histogram not booked";
407 auto isText = (
temp.find(
"text") != std::string::npos);
428 const unsigned int reads) {
431 for (
const auto&
file : cornerFiles) {
432 auto cornerFileName =
file.fullPath();
433 std::ifstream cornerFile(cornerFileName.c_str());
434 if (!cornerFile.good()) {
435 throw cms::Exception(
"FileError") <<
"Problem opening corner file: " << cornerFileName;
438 while (std::getline(cornerFile,
line)) {
440 std::istringstream iss(
line);
443 std::vector<std::string> corners(reads,
"");
444 std::vector<float> xP, yP;
447 for (
unsigned int i = 0;
i < reads; ++
i) {
448 iss >> corners.at(
i);
451 LOGDEBUG(
"Phase1PixelMaps") <<
id <<
" : ";
452 for (
unsigned int i = 0;
i < reads;
i++) {
454 (corners[
i]).erase(
std::remove(corners[
i].begin(), corners[
i].
end(),
'"'), corners[
i].end());
455 LOGDEBUG(
"Phase1PixelMaps") << corners.at(
i) <<
" ";
456 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
457 boost::char_separator<char> sep{
","};
458 tokenizer tok{corners.at(
i), sep};
459 for (
const auto&
t : tok | boost::adaptors::indexed(0)) {
460 if (
t.index() == 0) {
461 xP.push_back(atof((
t.value()).c_str()));
462 }
else if (
t.index() == 1) {
463 yP.push_back(atof((
t.value()).c_str()));
465 edm::LogError(
"LogicError") <<
"There should not be any token with index " <<
t.index() << std::endl;
469 LOGDEBUG(
"Phase1PixelMaps") << std::endl;
471 xP.push_back(xP.front());
472 yP.push_back(yP.front());
474 for (
unsigned int i = 0;
i < xP.size();
i++) {
475 LOGDEBUG(
"Phase1PixelMaps") <<
"x[" <<
i <<
"]=" << xP[
i] <<
" y[" <<
i <<
"]" << yP[
i] << std::endl;
478 theOutMap[
id] = std::make_pair(xP, yP);
488 hist->SetStats(kFALSE);
489 hist->SetLineWidth(2);
490 hist->GetXaxis()->CenterTitle(
true);
491 hist->GetYaxis()->CenterTitle(
true);
492 hist->GetXaxis()->SetTitleFont(42);
493 hist->GetYaxis()->SetTitleFont(42);
494 hist->GetXaxis()->SetTitleSize(0.05);
495 hist->GetYaxis()->SetTitleSize(0.05);
496 hist->GetXaxis()->SetTitleOffset(1.1);
497 hist->GetYaxis()->SetTitleOffset(1.3);
498 hist->GetXaxis()->SetLabelFont(42);
499 hist->GetYaxis()->SetLabelFont(42);
500 hist->GetYaxis()->SetLabelSize(.05);
501 hist->GetXaxis()->SetLabelSize(.05);
504 hist->GetZaxis()->SetLabelFont(42);
505 hist->GetZaxis()->SetLabelFont(42);
506 hist->GetZaxis()->SetLabelSize(.05);
507 hist->GetZaxis()->SetLabelSize(.05);
514 pad->SetTopMargin(top);
516 pad->SetBottomMargin(bottom);
518 pad->SetLeftMargin(left);
520 pad->SetRightMargin(right);
526 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to manipulate a histogram not booked";
530 std::vector<float> maxima;
533 std::back_inserter(maxima),
534 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
535 std::vector<float> minima;
538 std::back_inserter(minima),
539 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
541 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
542 auto globalMin = *std::min_element(minima.begin(), minima.end());
545 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
552 edm::LogError(
"Phase1PixelMaps") << __func__ <<
": trying to manipulate a histogram not booked";
556 std::vector<float> maxima;
559 std::back_inserter(maxima),
560 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
561 std::vector<float> minima;
564 std::back_inserter(minima),
565 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
567 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
568 auto globalMin = *std::min_element(minima.begin(), minima.end());
571 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);