Commit 6493b155 authored by Heinrich Schindler's avatar Heinrich Schindler
Browse files

Merge branch 'viewers' into 'master'

Small fixes in View classes

See merge request !244
parents 3a23acd6 49f32e9f
Pipeline #3130800 passed with stage
in 6 minutes
......@@ -130,7 +130,7 @@ int main(int argc, char * argv[]) {
meshView->SetColor(2, kYellow + 3);
meshView->EnableAxes();
meshView->SetViewDrift(&driftView);
constexpr bool twod = false;
constexpr bool twod = true;
if (!twod) {
meshView->SetArea(-0.5 * pitch, -0.5 * pitch, -0.02, 0.5 * pitch, 0.5 * pitch, 0.02);
}
......
......@@ -144,9 +144,9 @@ class ViewBase {
double& xmin, double& ymin,
double& xmax, double& ymax) const;
bool RangeSet(TPad*);
void SetRange(TPad* pad, const double x0, const double y0,
const double x1, const double y1);
static bool RangeSet(TVirtualPad*);
static void SetRange(TVirtualPad* pad, const double x0, const double y0,
const double x1, const double y1);
private:
// Current pad.
TPad* m_pad = nullptr;
......
......@@ -80,8 +80,8 @@ TPad* ViewBase::GetCanvas() {
return m_pad;
}
bool ViewBase::RangeSet(TPad* pad) {
bool ViewBase::RangeSet(TVirtualPad* pad) {
if (!pad) return false;
if (pad->GetListOfPrimitives()->GetSize() == 0 &&
pad->GetX1() == 0 && pad->GetX2() == 1 &&
pad->GetY1() == 0 && pad->GetY2() == 1) {
......@@ -90,7 +90,7 @@ bool ViewBase::RangeSet(TPad* pad) {
return true;
}
void ViewBase::SetRange(TPad* pad, const double x0, const double y0,
void ViewBase::SetRange(TVirtualPad* pad, const double x0, const double y0,
const double x1, const double y1) {
if (!pad) return;
const double bm = pad->GetBottomMargin();
......
......@@ -98,12 +98,7 @@ bool ViewCell::Plot(const bool twod) {
canvas->SetTitle("Cell layout");
if (twod) {
bool empty = false;
if (!gPad ||
(gPad->GetListOfPrimitives()->GetSize() == 0 && gPad->GetX1() == 0 &&
gPad->GetX2() == 1 && gPad->GetY1() == 0 && gPad->GetY2() == 1)) {
empty = true;
}
const bool empty = !RangeSet(gPad);
const double bm = canvas->GetBottomMargin();
const double lm = canvas->GetLeftMargin();
const double rm = canvas->GetRightMargin();
......
......@@ -114,7 +114,9 @@ bool ViewFEMesh::Plot(const bool twod) {
} else {
DrawElements2d();
}
DrawDriftLines2d();
if (m_drawViewRegion && !m_viewRegionX.empty()) {
TPolyLine poly;
poly.SetLineColor(kSpring + 4);
......
......@@ -229,12 +229,7 @@ void ViewGeometry::Plot2d() {
canvas->cd();
canvas->SetTitle("Geometry");
bool empty = false;
if (!gPad ||
(gPad->GetListOfPrimitives()->GetSize() == 0 && gPad->GetX1() == 0 &&
gPad->GetX2() == 1 && gPad->GetY1() == 0 && gPad->GetY2() == 1)) {
empty = true;
}
bool empty = !RangeSet(gPad);
const double bm = canvas->GetBottomMargin();
const double lm = canvas->GetLeftMargin();
const double rm = canvas->GetRightMargin();
......
......@@ -442,17 +442,17 @@ void ViewMedium::ResetX(const Axis xaxis) {
}
}
constexpr unsigned int nX = 1000;
constexpr size_t nX = 1000;
m_xPlot.assign(nX, 0.);
if (logx) {
m_xPlot[0] = xmin;
const double r = pow(xmax / xmin, 1. / (nX - 1));
for (unsigned int i = 1; i < nX; ++i) {
for (size_t i = 1; i < nX; ++i) {
m_xPlot[i] = m_xPlot[i - 1] * r;
}
} else {
const double dx = (xmax - xmin) / (nX - 1);
for (unsigned int i = 0; i < nX; ++i) {
for (size_t i = 0; i < nX; ++i) {
m_xPlot[i] = xmin + i * dx;
}
}
......@@ -478,16 +478,16 @@ void ViewMedium::PlotDiffusion(const Axis xaxis, const Charge charge,
ResetY();
}
}
const unsigned int nX = m_xPlot.size();
const size_t nX = m_xPlot.size();
std::array<std::vector<double>, 2> ypl;
for (unsigned int i = 0; i < 2; ++i) ypl[i].assign(nX, 0.);
for (size_t i = 0; i < 2; ++i) ypl[i].assign(nX, 0.);
double ex = m_efield;
double ctheta = cos(m_angle);
double stheta = sin(m_angle);
double bx = m_bfield * ctheta;
double by = m_bfield * stheta;
for (unsigned int i = 0; i < nX; ++i) {
for (size_t i = 0; i < nX; ++i) {
if (xaxis == Axis::E) {
ex = m_xPlot[i];
} else if (xaxis == Axis::B) {
......@@ -517,7 +517,7 @@ void ViewMedium::PlotDiffusion(const Axis xaxis, const Charge charge,
if (GetGrid(grid, ie, ib, ia, xaxis)) {
const auto nPoints = xaxis == Axis::E ? grid[0].size() :
xaxis == Axis::B ? grid[1].size() : grid[2].size();
for (unsigned int j = 0; j < nPoints; ++j) {
for (size_t j = 0; j < nPoints; ++j) {
double x = 0., y = 0.;
if (xaxis == Axis::E) {
ie = j;
......@@ -562,7 +562,7 @@ void ViewMedium::PlotDiffusion(const Axis xaxis, const Charge charge,
const std::array<Parameter, 2> pars = {Parameter::LongitudinalDiffusion,
Parameter::TransverseDiffusion};
for (unsigned int i = 0; i < 2; ++i) {
for (size_t i = 0; i < 2; ++i) {
if (!NonZero(ypl[i])) continue;
m_yPlot.push_back(std::move(ypl[i]));
m_par.push_back(pars[i]);
......@@ -592,16 +592,16 @@ void ViewMedium::PlotVelocity(const Axis xaxis, const Charge charge,
ResetY();
}
}
const unsigned int nX = m_xPlot.size();
const size_t nX = m_xPlot.size();
std::array<std::vector<double>, 3> ypl;
for (unsigned int i = 0; i < 3; ++i) ypl[i].assign(nX, 0.);
for (size_t i = 0; i < 3; ++i) ypl[i].assign(nX, 0.);
double e0 = m_efield;
double b0 = m_bfield;
double ctheta = cos(m_angle);
double stheta = sin(m_angle);
for (unsigned int i = 0; i < nX; ++i) {
for (size_t i = 0; i < nX; ++i) {
if (xaxis == Axis::E) {
e0 = m_xPlot[i];
} else if (xaxis == Axis::B) {
......@@ -640,7 +640,7 @@ void ViewMedium::PlotVelocity(const Axis xaxis, const Charge charge,
if (GetGrid(grid, ie, ib, ia, xaxis)) {
const auto nPoints = xaxis == Axis::E ? grid[0].size() :
xaxis == Axis::B ? grid[1].size() : grid[2].size();
for (unsigned int j = 0; j < nPoints; ++j) {
for (size_t j = 0; j < nPoints; ++j) {
double x = 0., y = 0.;
if (xaxis == Axis::E) {
ie = j;
......@@ -690,7 +690,7 @@ void ViewMedium::PlotVelocity(const Axis xaxis, const Charge charge,
const std::array<Parameter, 3> pars = {Parameter::VelocityE,
Parameter::VelocityB,
Parameter::VelocityExB};
for (unsigned int i = 0; i < 3; ++i) {
for (size_t i = 0; i < 3; ++i) {
if (!NonZero(ypl[i])) continue;
m_yPlot.push_back(std::move(ypl[i]));
m_par.push_back(pars[i]);
......@@ -721,14 +721,14 @@ void ViewMedium::Plot(const Axis xaxis, const Charge charge,
}
}
const unsigned int nX = m_xPlot.size();
const size_t nX = m_xPlot.size();
std::vector<double> ypl(nX, 0.);
double ex = m_efield;
double ctheta = cos(m_angle);
double stheta = sin(m_angle);
double bx = m_bfield * ctheta;
double by = m_bfield * stheta;
for (unsigned int i = 0; i < nX; ++i) {
for (size_t i = 0; i < nX; ++i) {
if (xaxis == Axis::E) {
ex = m_xPlot[i];
} else if (xaxis == Axis::B) {
......@@ -765,7 +765,7 @@ void ViewMedium::Plot(const Axis xaxis, const Charge charge,
if (GetGrid(grid, ie, ib, ia, xaxis)) {
const auto nPoints = xaxis == Axis::E ? grid[0].size() :
xaxis == Axis::B ? grid[1].size() : grid[2].size();
for (unsigned int j = 0; j < nPoints; ++j) {
for (size_t j = 0; j < nPoints; ++j) {
double x = 0., y = 0.;
if (xaxis == Axis::E) {
ie = j;
......@@ -831,14 +831,14 @@ void ViewMedium::PlotLorentzAngle(const Axis xaxis, const Charge charge,
if (m_par[0] != Parameter::LorentzAngle) ResetY();
}
const unsigned int nX = m_xPlot.size();
const size_t nX = m_xPlot.size();
std::vector<double> ypl(nX, 0.);
double ex = m_efield;
double ctheta = cos(m_angle);
double stheta = sin(m_angle);
double bx = m_bfield * ctheta;
double by = m_bfield * stheta;
for (unsigned int i = 0; i < nX; ++i) {
for (size_t i = 0; i < nX; ++i) {
if (xaxis == Axis::E) {
ex = m_xPlot[i];
} else if (xaxis == Axis::B) {
......@@ -861,7 +861,7 @@ void ViewMedium::PlotLorentzAngle(const Axis xaxis, const Charge charge,
if (GetGrid(grid, ie, ib, ia, xaxis)) {
const auto nPoints = xaxis == Axis::E ? grid[0].size() :
xaxis == Axis::B ? grid[1].size() : grid[2].size();
for (unsigned int j = 0; j < nPoints; ++j) {
for (size_t j = 0; j < nPoints; ++j) {
double x = 0., y = 0.;
if (xaxis == Axis::E) {
ie = j;
......
......@@ -65,6 +65,7 @@ void ViewSignal::PlotSignal(const std::string& label, const bool total,
ylabel = m_sensor->IsIntegrated(label) ? "signal [fC]" : "signal [fC / ns]";
}
unsigned int nPlots = same ? 1 : 0;
if (!RangeSet(gPad)) nPlots = 0;
if (total) {
const auto hname = FindUnusedHistogramName("hSignal_");
m_hSignal.reset(new TH1D(hname.c_str(), "", nBins, t0, t1));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment