|
15 | 15 | #include "TH2Poly.h" |
16 | 16 | #include "TCanvas.h" |
17 | 17 | #include "TLatex.h" |
| 18 | +#include "TGraphErrors.h" |
| 19 | +#include "TMultiGraph.h" |
18 | 20 | #include <fmt/format.h> |
19 | 21 |
|
20 | 22 | unsigned int o2::tpc::IDCDrawHelper::getPad(const unsigned int pad, const unsigned int region, const unsigned int row, const Side side) |
@@ -266,8 +268,143 @@ std::string o2::tpc::IDCDrawHelper::getZAxisTitle(const IDCType type, const IDCD |
266 | 268 | } |
267 | 269 | } |
268 | 270 | case IDCType::IDCOne: { |
269 | | - return fmt::format("#Delta#it{{{}}}_{{1}}", stype); |
| 271 | + return fmt::format("#it{{{}}}_{{1}}", stype); |
270 | 272 | break; |
271 | 273 | } |
272 | 274 | } |
273 | 275 | } |
| 276 | + |
| 277 | +void o2::tpc::IDCDrawHelper::drawSideGIF(const IDCDrawGIF& idcs, const unsigned int slices, const std::string zAxisTitle, const std::string filename, const float minZ, const float maxZ, const int run) |
| 278 | +{ |
| 279 | + const int gifSpeed = 40; |
| 280 | + |
| 281 | + TCanvas can("canvas", "canvas", 3350, 2000); |
| 282 | + TPad padIDCA("padIDCA", "padIDCA", 0, 0.25, 0.5, 1); |
| 283 | + TPad padIDCC("padIDCC", "padIDCC", 0.5, 0.25, 1, 1); |
| 284 | + TPad padIDCOne("padIDCOne", "padIDCOne", 0, 0, 1, 0.25); |
| 285 | + |
| 286 | + const float tm = 0.04f; |
| 287 | + const float rm = 0.14f; |
| 288 | + const float lm = 0.1f; |
| 289 | + const float bm = 0.2f; |
| 290 | + padIDCA.SetTopMargin(tm); |
| 291 | + padIDCA.SetRightMargin(rm); |
| 292 | + padIDCA.SetLeftMargin(lm); |
| 293 | + padIDCC.SetTopMargin(tm); |
| 294 | + padIDCC.SetRightMargin(rm); |
| 295 | + padIDCC.SetLeftMargin(lm); |
| 296 | + padIDCOne.SetTopMargin(tm); |
| 297 | + padIDCOne.SetRightMargin(rm / 2); |
| 298 | + padIDCOne.SetLeftMargin(lm / 2); |
| 299 | + padIDCOne.SetBottomMargin(bm); |
| 300 | + |
| 301 | + padIDCA.Draw(); |
| 302 | + padIDCC.Draw(); |
| 303 | + padIDCOne.Draw(); |
| 304 | + |
| 305 | + std::array<TGraphErrors, SIDES> graphIDCOne; |
| 306 | + std::array<TGraphErrors, SIDES> graphIDCOneSlice; |
| 307 | + TMultiGraph multiGraph; |
| 308 | + float minY = 1000; |
| 309 | + float maxY = -1; |
| 310 | + const float widthLine = 0.005f; |
| 311 | + const float idcWH = 0.5; // IDC width half: 1ms/2 |
| 312 | + for (unsigned int sideT = 0; sideT < SIDES; ++sideT) { |
| 313 | + const Side side = (sideT == 0) ? Side::A : Side::C; |
| 314 | + const auto col = (sideT == 0) ? (kGreen + 2) : kBlue; |
| 315 | + graphIDCOne[sideT].SetFillColorAlpha(col, 0.3); |
| 316 | + graphIDCOne[sideT].SetLineWidth(5); |
| 317 | + graphIDCOneSlice[sideT] = graphIDCOne[sideT]; |
| 318 | + graphIDCOneSlice[sideT].Set(1); |
| 319 | + graphIDCOneSlice[sideT].SetFillColorAlpha(col, 1); |
| 320 | + for (unsigned int slice = 0; slice < slices; ++slice) { |
| 321 | + const auto idc = idcs.mIDCOneFunc(side, slice); |
| 322 | + if (idc < minY) { |
| 323 | + minY = idc; |
| 324 | + } |
| 325 | + if (idc > maxY) { |
| 326 | + maxY = idc; |
| 327 | + } |
| 328 | + graphIDCOne[sideT].AddPoint(slice + idcWH, idc); |
| 329 | + graphIDCOne[sideT].SetPointError(slice, idcWH, widthLine); |
| 330 | + } |
| 331 | + multiGraph.Add(&graphIDCOne[sideT]); |
| 332 | + } |
| 333 | + |
| 334 | + const int font = 63; |
| 335 | + const int fontsize = 50; |
| 336 | + multiGraph.GetXaxis()->SetTitleFont(font); |
| 337 | + multiGraph.GetXaxis()->SetLabelFont(font); |
| 338 | + multiGraph.GetYaxis()->SetTitleFont(font); |
| 339 | + multiGraph.GetYaxis()->SetLabelFont(font); |
| 340 | + multiGraph.GetXaxis()->SetLabelSize(fontsize); |
| 341 | + multiGraph.GetXaxis()->SetTitleSize(fontsize); |
| 342 | + multiGraph.GetYaxis()->SetLabelSize(fontsize); |
| 343 | + multiGraph.GetYaxis()->SetTitleSize(fontsize); |
| 344 | + multiGraph.GetXaxis()->SetTitle("#it{t} (ms)"); |
| 345 | + multiGraph.GetXaxis()->SetTitleOffset(0.9f); |
| 346 | + multiGraph.GetYaxis()->SetTitleOffset(1.5f); |
| 347 | + multiGraph.GetYaxis()->SetTitle(IDCDrawHelper::getZAxisTitle(IDCType::IDCOne).data()); |
| 348 | + multiGraph.SetMinimum(0.9 * minY); |
| 349 | + multiGraph.SetMaximum(1.1 * maxY); |
| 350 | + multiGraph.GetXaxis()->SetLimits(0, slices); |
| 351 | + |
| 352 | + for (unsigned int slice = 0; slice < slices; ++slice) { |
| 353 | + LOGP(info, "Drawing slice {} from {}", slice, slices - 1); |
| 354 | + IDCDrawHelper::IDCDraw drawFun; |
| 355 | + std::function<float(const unsigned int, const unsigned int, const unsigned int, const unsigned int)> idcFunc = [slice, idcs](const unsigned int sector, const unsigned int region, const unsigned int irow, const unsigned int pad) { |
| 356 | + return idcs.mIDCFunc(sector, region, irow, pad, slice); |
| 357 | + }; |
| 358 | + drawFun.mIDCFunc = idcFunc; |
| 359 | + |
| 360 | + TH2Poly* poly[SIDES]{nullptr, nullptr}; |
| 361 | + for (int sideT = 0; sideT < SIDES; ++sideT) { |
| 362 | + const Side side = (sideT == 0) ? Side::A : Side::C; |
| 363 | + poly[sideT] = o2::tpc::IDCDrawHelper::drawSide(drawFun, side, zAxisTitle); |
| 364 | + poly[sideT]->GetXaxis()->SetTitleFont(font); |
| 365 | + poly[sideT]->GetXaxis()->SetLabelFont(font); |
| 366 | + poly[sideT]->GetYaxis()->SetTitleFont(font); |
| 367 | + poly[sideT]->GetYaxis()->SetLabelFont(font); |
| 368 | + poly[sideT]->GetXaxis()->SetLabelSize(fontsize); |
| 369 | + poly[sideT]->GetXaxis()->SetTitleSize(fontsize); |
| 370 | + poly[sideT]->GetYaxis()->SetLabelSize(fontsize); |
| 371 | + poly[sideT]->GetYaxis()->SetTitleSize(fontsize); |
| 372 | + |
| 373 | + if (minZ < maxZ) { |
| 374 | + poly[sideT]->SetMinimum(minZ); |
| 375 | + poly[sideT]->SetMaximum(maxZ); |
| 376 | + } |
| 377 | + |
| 378 | + if (sideT == 0) { |
| 379 | + padIDCA.cd(); |
| 380 | + } else { |
| 381 | + padIDCC.cd(); |
| 382 | + } |
| 383 | + |
| 384 | + poly[sideT]->Draw("colz"); |
| 385 | + const std::string sideName = (side == Side::A) ? "A-Side" : "C-Side"; |
| 386 | + TLatex latex; |
| 387 | + const auto col = (side == Side::A) ? (kGreen + 2) : kBlue; |
| 388 | + latex.SetTextColor(col); |
| 389 | + latex.DrawLatexNDC(0.13, 0.9, sideName.data()); |
| 390 | + if (run > 0) { |
| 391 | + latex.DrawLatexNDC(0.62, 0.9, fmt::format("Run {}", run).data()); |
| 392 | + } |
| 393 | + graphIDCOneSlice[sideT].SetPoint(0, slice + idcWH, idcs.mIDCOneFunc(side, slice)); |
| 394 | + graphIDCOneSlice[sideT].SetPointError(0, idcWH, widthLine); |
| 395 | + } |
| 396 | + |
| 397 | + padIDCOne.cd(); |
| 398 | + multiGraph.Draw("ZA E2"); |
| 399 | + graphIDCOneSlice[0].Draw("Z E2 SAME"); |
| 400 | + graphIDCOneSlice[1].Draw("Z E2 SAME"); |
| 401 | + |
| 402 | + can.Print(Form("%s.gif+%i", filename.data(), gifSpeed)); |
| 403 | + if (slice == (slices - 1)) { |
| 404 | + can.Print(Form("%s.gif++", filename.data())); |
| 405 | + } |
| 406 | + |
| 407 | + delete poly[0]; |
| 408 | + delete poly[1]; |
| 409 | + } |
| 410 | +} |
0 commit comments