1 #ifndef CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H
2 #define CONDCORE_SIPIXELPLUGINS_PHASE1PIXELMAPS_H
12 #include <boost/tokenizer.hpp>
13 #include <boost/range/adaptor/indexed.hpp>
18 #define MYOUT LogDebug("Phase1PixelMaps")
20 using indexedCorners = std::map<unsigned int, std::pair<std::vector<float>, std::vector<float>>>;
35 for (
unsigned int i = 1;
i <= 4;
i++) {
40 for (
int j : {-3, -2, -1, 1, 2, 3}) {
56 for (
const auto&
file : cornerFiles) {
57 auto cornerFileName =
file.fullPath();
58 std::ifstream cornerFile(cornerFileName.c_str());
59 if (!cornerFile.good()) {
60 throw cms::Exception(
"FileError") <<
"Problem opening corner file: " << cornerFileName;
63 while (std::getline(cornerFile,
line)) {
65 std::istringstream iss(
line);
68 std::vector<std::string> corners(reads,
"");
69 std::vector<float> xP, yP;
72 for (
unsigned int i = 0;
i < reads; ++
i) {
77 for (
unsigned int i = 0;
i < reads;
i++) {
79 (corners[
i]).erase(
std::remove(corners[
i].begin(), corners[
i].
end(),
'"'), corners[
i].end());
80 MYOUT << corners.at(
i) <<
" ";
81 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
82 boost::char_separator<char> sep{
","};
83 tokenizer tok{corners.at(
i), sep};
84 for (
const auto&
t : tok | boost::adaptors::indexed(0)) {
86 xP.push_back(atof((
t.value()).c_str()));
87 }
else if (
t.index() == 1) {
88 yP.push_back(atof((
t.value()).c_str()));
90 edm::LogError(
"LogicError") <<
"There should not be any token with index " <<
t.index() << std::endl;
96 xP.push_back(xP.front());
97 yP.push_back(yP.front());
99 for (
unsigned int i = 0;
i < xP.size();
i++) {
100 MYOUT <<
"x[" <<
i <<
"]=" << xP[
i] <<
" y[" <<
i <<
"]" << yP[
i] << std::endl;
103 theOutMap[
id] = std::make_pair(xP, yP);
115 hist->SetStats(kFALSE);
116 hist->SetLineWidth(2);
117 hist->GetXaxis()->CenterTitle(
true);
118 hist->GetYaxis()->CenterTitle(
true);
119 hist->GetXaxis()->SetTitleFont(42);
120 hist->GetYaxis()->SetTitleFont(42);
121 hist->GetXaxis()->SetTitleSize(0.05);
122 hist->GetYaxis()->SetTitleSize(0.05);
123 hist->GetXaxis()->SetTitleOffset(1.1);
124 hist->GetYaxis()->SetTitleOffset(1.3);
125 hist->GetXaxis()->SetLabelFont(42);
126 hist->GetYaxis()->SetLabelFont(42);
127 hist->GetYaxis()->SetLabelSize(.05);
128 hist->GetXaxis()->SetLabelSize(.05);
131 hist->GetZaxis()->SetLabelFont(42);
132 hist->GetZaxis()->SetLabelFont(42);
133 hist->GetZaxis()->SetLabelSize(.05);
134 hist->GetZaxis()->SetLabelSize(.05);
143 pad->SetTopMargin(top);
145 pad->SetBottomMargin(bottom);
147 pad->SetLeftMargin(left);
149 pad->SetRightMargin(right);
155 std::shared_ptr<TH2Poly> th2p;
157 for (
unsigned i = 0;
i < 4; ++
i) {
158 histName =
"barrel_layer_";
160 th2p = std::make_shared<TH2Poly>((histName + std::to_string(
i + 1)).c_str(),
161 Form(
"PXBMap of %s - Layer %i", what,
i + 1),
169 th2p->GetXaxis()->SetTitle(
"z [cm]");
170 th2p->GetYaxis()->SetTitle(
"ladder");
171 th2p->GetZaxis()->SetTitle(
zaxis);
172 th2p->GetZaxis()->CenterTitle();
173 th2p->SetStats(
false);
178 th2p = std::make_shared<TH2Poly>(
"barrel_summary",
"PXBMap", -5.0, 5.0, 0.0, 5.0);
181 th2p->GetXaxis()->SetTitle(
"");
182 th2p->GetYaxis()->SetTitle(
"~ladder");
183 th2p->SetStats(
false);
191 std::shared_ptr<TH2Poly> th2p;
193 for (
unsigned side = 1; side <= 2; ++side) {
194 for (
unsigned disk = 1; disk <= 3; ++disk) {
195 histName =
"forward_disk_";
197 th2p = std::make_shared<TH2Poly>((histName + std::to_string((side == 1 ? -(
int(disk)) : (
int)disk))).c_str(),
198 Form(
"PXFMap of %s - Side %i Disk %i", what, side, disk),
204 th2p->GetXaxis()->SetTitle(
"x [cm]");
205 th2p->GetYaxis()->SetTitle(
"y [cm]");
206 th2p->GetZaxis()->SetTitle(
zaxis);
207 th2p->GetZaxis()->CenterTitle();
208 th2p->SetStats(
false);
214 th2p = std::make_shared<TH2Poly>(
"forward_summary",
"PXFMap", -40.0, 50.0, -20.0, 90.0);
217 th2p->GetXaxis()->SetTitle(
"");
218 th2p->GetYaxis()->SetTitle(
"");
219 th2p->SetStats(
false);
228 for (
const auto&
entry : theIndexedCorners) {
229 auto id =
entry.first;
230 auto detid =
DetId(
id);
237 auto theVectX =
entry.second.first;
238 auto theVectY =
entry.second.second;
240 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3], theVectX[4]};
243 bins[
id] = std::make_shared<TGraph>(5, vertX, vertY);
244 bins[
id]->SetName(TString::Format(
"%u",
id));
247 for (
unsigned k = 0;
k < 5; ++
k) {
248 vertX[
k] += ((layer == 2 || layer == 3) ? 0.0
f : -60.0
f);
249 vertY[
k] += ((layer > 2) ? 30.0
f : 0.0
f);
258 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Barrel map! Aborting.";
264 throw cms::Exception(
"LocalError") << currentHistoName <<
" is not found in the Barrel Summary map! Aborting.";
273 for (
const auto&
entry : theIndexedCorners) {
274 auto id =
entry.first;
275 auto detid =
DetId(
id);
282 unsigned mapIdx = disk + (side - 1) * 3 - 1;
284 auto theVectX =
entry.second.first;
285 auto theVectY =
entry.second.second;
287 float vertX[] = {theVectX[0], theVectX[1], theVectX[2], theVectX[3]};
288 float vertY[] = {theVectY[0], theVectY[1], theVectY[2], theVectY[3]};
290 bins[
id] = std::make_shared<TGraph>(4, vertX, vertY);
291 bins[
id]->SetName(TString::Format(
"%u",
id));
294 for (
unsigned k = 0;
k < 4; ++
k) {
295 vertX[
k] += (
float(side) - 1.5f) * 40.0
f;
296 vertY[
k] += (disk - 1) * 35.0
f;
305 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward map! Aborting.";
311 throw cms::Exception(
"LogicError") << currentHistoName <<
" is not found in the Forward Summary map! Aborting.";
317 template <
typename type>
319 auto detid =
DetId(
id);
321 edm::LogError(
"Phase1PixelMaps") <<
"fillBarrelBin() The following detid " <<
id <<
" is not Pixel Barrel!"
330 template <
typename type>
332 auto detid =
DetId(
id);
334 edm::LogError(
"Phase1PixelMaps") <<
"fillForwardBin() The following detid " <<
id <<
" is not Pixel Forward!"
340 unsigned mapIdx = disk + (side - 1) * 3 - 1;
347 for (
const auto&
plot : vec.second) {
349 plot->GetXaxis()->SetTitleOffset(0.9);
350 plot->GetYaxis()->SetTitleOffset(0.9);
351 plot->GetZaxis()->SetTitleOffset(1.2);
352 plot->GetZaxis()->SetTitleSize(0.05);
357 for (
const auto&
plot : vec.second) {
359 plot->GetXaxis()->SetTitleOffset(0.9);
360 plot->GetYaxis()->SetTitleOffset(0.9);
361 plot->GetZaxis()->SetTitleOffset(1.2);
362 plot->GetZaxis()->SetTitleSize(0.05);
369 std::vector<float> maxima;
372 std::back_inserter(maxima),
373 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
374 std::vector<float> minima;
377 std::back_inserter(minima),
378 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
380 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
381 auto globalMin = *std::min_element(minima.begin(), minima.end());
384 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
390 std::vector<float> maxima;
393 std::back_inserter(maxima),
394 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMaximum(); });
395 std::vector<float> minima;
398 std::back_inserter(minima),
399 [](std::shared_ptr<TH2Poly> thp) ->
float {
return thp->GetMinimum(); });
401 auto globalMax = *std::max_element(maxima.begin(), maxima.end());
402 auto globalMin = *std::min_element(minima.begin(), minima.end());
405 histo->GetZaxis()->SetRangeUser(globalMin, globalMax);
412 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
419 histo->GetZaxis()->SetRangeUser(extrema.first, extrema.second);
426 for (
int i = 1;
i <= 4;
i++) {
428 if (strcmp(
m_option,
"text") == 0) {
429 canvas.cd(
i)->SetRightMargin(0.02);
443 for (
int i = 1;
i <= 6;
i++) {
445 if (strcmp(
m_option,
"text") == 0) {
446 canvas.cd(
i)->SetRightMargin(0.02);