Skip to content

Commit 9220ba5

Browse files
committed
Negative binning omits drawing the 1D distributions
1 parent 6dce44a commit 9220ba5

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

Detectors/TPC/base/src/Painter.cxx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
291291

292292
const Mapper& mapper = Mapper::instance();
293293

294+
const bool draw1D = nbins1D > 0;
295+
294296
// ===| name and title |======================================================
295297
std::string title = calDet.getName();
296298
std::string name = calDet.getName();
@@ -305,11 +307,13 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
305307
const int bufferSize = TH1::GetDefaultBufferSize();
306308
TH1::SetDefaultBufferSize(Sector::MAXSECTOR * mapper.getPadsInSector());
307309

308-
auto hAside1D = new TH1F(fmt::format("h_Aside_1D_{}", name).data(), fmt::format("{0} (A-Side);{0}", title).data(),
309-
nbins1D, xMin1D, xMax1D); // TODO: modify ranges
310+
auto hAside1D = draw1D ? new TH1F(fmt::format("h_Aside_1D_{}", name).data(), fmt::format("{0} (A-Side);{0}", title).data(),
311+
nbins1D, xMin1D, xMax1D)
312+
: nullptr; // TODO: modify ranges
310313

311-
auto hCside1D = new TH1F(fmt::format("h_Cside_1D_{}", name).data(), fmt::format("{0} (C-Side);{0}", title).data(),
312-
nbins1D, xMin1D, xMax1D); // TODO: modify ranges
314+
auto hCside1D = draw1D ? new TH1F(fmt::format("h_Cside_1D_{}", name).data(), fmt::format("{0} (C-Side);{0}", title).data(),
315+
nbins1D, xMin1D, xMax1D)
316+
: nullptr; // TODO: modify ranges
313317

314318
auto hAside2D = new TH2F(fmt::format("h_Aside_2D_{}", name).data(), fmt::format("{0} (A-Side);#it{{x}} (cm);#it{{y}} (cm);{0}", title).data(),
315319
330, -270, 270, 330, -270, 270);
@@ -336,7 +340,9 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
336340
if (!hist2D->GetBinContent(bin)) {
337341
hist2D->SetBinContent(bin, double(val));
338342
}
339-
hist1D->Fill(double(val));
343+
if (draw1D) {
344+
hist1D->Fill(double(val));
345+
}
340346
}
341347
}
342348
}
@@ -352,13 +358,13 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
352358
gStyle->SetOptStat("mr");
353359
auto c = outputCanvas;
354360
if (!c) {
355-
c = new TCanvas(fmt::format("c_{}", name).data(), title.data(), 1000, 1000);
361+
c = new TCanvas(fmt::format("c_{}", name).data(), title.data(), 1000, draw1D ? 1000 : 500);
356362
}
357363
gStyle->SetStatX(1. - gPad->GetRightMargin());
358364
gStyle->SetStatY(1. - gPad->GetTopMargin());
359365

360366
c->Clear();
361-
c->Divide(2, 2);
367+
c->Divide(2, draw1D ? 2 : 1);
362368

363369
c->cd(1);
364370
hAside2D->Draw("colz");
@@ -376,18 +382,22 @@ TCanvas* painter::draw(const CalDet<T>& calDet, int nbins1D, float xMin1D, float
376382
adjustPalette(hCside2D, 0.92);
377383
drawSectorsXY(Side::C);
378384

379-
c->cd(3);
380-
hAside1D->Draw();
385+
if (draw1D) {
386+
c->cd(3);
387+
hAside1D->Draw();
381388

382-
c->cd(4);
383-
hCside1D->Draw();
389+
c->cd(4);
390+
hCside1D->Draw();
391+
392+
// associate histograms to canvas
393+
hAside1D->SetBit(TObject::kCanDelete);
394+
hCside1D->SetBit(TObject::kCanDelete);
395+
}
384396

385397
// reset the buffer size
386398
TH1::SetDefaultBufferSize(bufferSize);
387399

388400
// associate histograms to canvas
389-
hAside1D->SetBit(TObject::kCanDelete);
390-
hCside1D->SetBit(TObject::kCanDelete);
391401
hAside2D->SetBit(TObject::kCanDelete);
392402
hCside2D->SetBit(TObject::kCanDelete);
393403

0 commit comments

Comments
 (0)