19void SampleRange(
const double xmin,
const double ymin,
20 const double xmax,
const double ymax, TF2* f,
21 double& zmin,
double& zmax) {
23 const unsigned int n = 1000;
24 const double dx = xmax - xmin;
25 const double dy = ymax - ymin;
26 zmin = std::numeric_limits<double>::max();
28 for (
unsigned int i = 0; i < n; ++i) {
31 if (z < zmin) zmin = z;
32 if (z > zmax) zmax = z;
36void SampleRange(TF1* f,
double& ymin,
double& ymax) {
38 const unsigned int n = 1000;
39 ymin = std::numeric_limits<double>::max();
41 for (
unsigned int i = 0; i < n; ++i) {
43 if (y < ymin) ymin = y;
44 if (y > ymax) ymax = y;
53 : m_className(
"ViewField"),
71 m_nContours(m_nMaxContours),
77 m_hasExternalCanvas(false),
89 if (!m_hasExternalCanvas && m_canvas)
delete m_canvas;
90 if (m_f2d)
delete m_f2d;
91 if (m_f2dW)
delete m_f2dW;
92 if (m_fProfile)
delete m_fProfile;
93 if (m_fProfileW)
delete m_fProfileW;
99 std::cerr << m_className <<
"::SetSensor: Null pointer.\n";
110 std::cerr << m_className <<
"::SetComponent: Null pointer.\n";
121 if (!m_hasExternalCanvas && m_canvas) {
126 m_hasExternalCanvas =
true;
130 const double xmax,
const double ymax) {
133 if (xmin == xmax || ymin == ymax) {
134 std::cerr << m_className <<
"::SetArea: Null area range is not permitted.\n"
135 <<
" " << xmin <<
" < x < " << xmax <<
"\n"
136 <<
" " << ymin <<
" < y < " << ymax <<
"\n";
139 m_xmin = std::min(xmin, xmax);
140 m_ymin = std::min(ymin, ymax);
141 m_xmax = std::max(xmin, xmax);
142 m_ymax = std::max(ymin, ymax);
143 m_hasUserArea =
true;
148 m_vmin = std::min(vmin, vmax);
149 m_vmax = std::max(vmin, vmax);
150 m_useAutoRange =
false;
155 m_emin = std::min(emin, emax);
156 m_emax = std::max(emin, emax);
157 m_useAutoRange =
false;
162 m_wmin = std::min(wmin, wmax);
163 m_wmax = std::max(wmin, wmax);
164 m_useAutoRange =
false;
169 if (n <= m_nMaxContours) {
172 std::cerr << m_className <<
"::SetNumberOfContours:\n"
173 <<
" Max. number of contours is " << m_nMaxContours <<
".\n";
179 const unsigned int nmin = 10;
180 const unsigned int nmax = 100000;
181 if (n < nmin || n > nmax) {
182 std::cerr << m_className <<
"::SetNumberOfSamples1d:\n"
183 <<
" Number of points (" << n <<
") out of range.\n"
184 <<
" " << nmin <<
" <= n <= " << nmax <<
"\n";
192 const unsigned int ny) {
194 const unsigned int nmin = 10;
195 const unsigned int nmax = 10000;
196 if (nx < nmin || nx > nmax) {
197 std::cerr << m_className <<
"::SetNumberOfSamples2d:\n"
198 <<
" Number of x-points (" << nx <<
") out of range.\n"
199 <<
" " << nmin <<
" <= nx <= " << nmax <<
"\n";
204 if (ny < nmin || ny > nmax) {
205 std::cerr << m_className <<
"::SetNumberOfSamples2d:\n"
206 <<
" Number of y-points (" << ny <<
") out of range.\n"
207 <<
" " << nmin <<
" <= ny <= " << nmax <<
"\n";
216 if (!SetupFunction(option, m_f2d,
true,
false))
return;
217 m_f2d->Draw(
"CONT4Z");
218 gPad->SetRightMargin(0.15);
225 if (!SetupFunction(option, m_f2d,
false,
false))
return;
226 m_f2d->Draw(drawopt.c_str());
227 gPad->SetRightMargin(0.15);
232 const double x1,
const double y1,
const double z1,
233 const std::string& option) {
237 if (!SetupProfile(x0, y0, z0, x1, y1, z1, option, m_fProfile,
false))
return;
243 const std::string& option,
244 const std::string& drawopt) {
248 if (!SetupFunction(option, m_f2dW,
false,
true))
return;
249 m_f2dW->Draw(drawopt.c_str());
250 gPad->SetRightMargin(0.15);
255 const std::string& option) {
259 if (!SetupFunction(option, m_f2dW,
true,
true))
return;
260 m_f2dW->Draw(
"CONT4Z");
261 gPad->SetRightMargin(0.15);
266 const double x0,
const double y0,
const double z0,
267 const double x1,
const double y1,
const double z1,
268 const std::string& option) {
272 if (!SetupProfile(x0, y0, z0, x1, y1, z1, option, m_fProfileW,
true))
return;
277std::string ViewField::FindUnusedFunctionName(
const std::string& s) {
280 std::string fname = s +
"_0";
281 while (gROOT->GetListOfFunctions()->FindObject(fname.c_str())) {
283 std::stringstream ss;
316 if (!m_sensor && !m_component)
return 0.;
319 const double u = pos[0];
320 const double v = pos[1];
321 const double x = m_project[0][0] * u + m_project[1][0] * v + m_project[2][0];
322 const double y = m_project[0][1] * u + m_project[1][1] * v + m_project[2][1];
323 const double z = m_project[0][2] * u + m_project[1][2] * v + m_project[2][2];
326 const PlotType plotType =
static_cast<PlotType
>(int(fabs(par[0]) / 10.));
329 double ex = 0., ey = 0., ez = 0., volt = 0.;
335 m_component->
ElectricField(x, y, z, ex, ey, ez, volt, medium, status);
337 m_sensor->
ElectricField(x, y, z, ex, ey, ez, volt, medium, status);
342 if (plotType == Potential) {
348 if (plotType == Potential) {
357 std::cout << m_className <<
"::Evaluate2D:\n"
358 <<
" At (u, v) = (" << u <<
", " << v <<
"), "
359 <<
" (x,y,z) = (" << x <<
"," << y <<
"," << z <<
")\n"
360 <<
" E = " << ex <<
", " << ey <<
", " << ez
361 <<
"), V = " << volt <<
", status = " << status <<
"\n";
363 if (m_useStatus && status != 0)
return m_vBkg;
370 return sqrt(ex * ex + ey * ey + ez * ez);
389 if (!m_sensor && !m_component)
return 0.;
392 const double x0 = par[0];
393 const double y0 = par[1];
394 const double z0 = par[2];
395 const double x1 = par[3];
396 const double y1 = par[4];
397 const double z1 = par[5];
399 const double dx = x1 - x0;
400 const double dy = y1 - y0;
401 const double dz = z1 - z0;
403 const double t = pos[0];
404 const double x = x0 + t * dx;
405 const double y = y0 + t * dy;
406 const double z = z0 + t * dz;
408 const PlotType plotType =
static_cast<PlotType
>(int(fabs(par[6]) / 10.));
411 double ex = 0., ey = 0., ez = 0., volt = 0.;
417 m_component->
ElectricField(x, y, z, ex, ey, ez, volt, medium, status);
419 m_sensor->
ElectricField(x, y, z, ex, ey, ez, volt, medium, status);
424 if (plotType == Potential) {
430 if (plotType == Potential) {
437 if (m_useStatus && status != 0) volt = m_vBkg;
444 return sqrt(ex * ex + ey * ey + ez * ez);
461void ViewField::Labels() {
464 strcpy(m_xLabel,
"\0");
467 const double tol = 1.e-4;
469 if (fabs(m_project[0][0] - 1) < tol) {
470 strcat(m_xLabel,
"x");
471 }
else if (fabs(m_project[0][0] + 1) < tol) {
472 strcat(m_xLabel,
"-x");
473 }
else if (m_project[0][0] > tol) {
474 sprintf(buf,
"%g x", m_project[0][0]);
475 strcat(m_xLabel, buf);
476 }
else if (m_project[0][0] < -tol) {
477 sprintf(buf,
"%g x", m_project[0][0]);
478 strcat(m_xLabel, buf);
482 if (strlen(m_xLabel) > 0) {
483 if (m_project[0][1] < -tol) {
484 strcat(m_xLabel,
" - ");
485 }
else if (m_project[0][1] > tol) {
486 strcat(m_xLabel,
" + ");
488 if (
fabs(m_project[0][1] - 1) < tol ||
fabs(m_project[0][1] + 1) < tol) {
489 strcat(m_xLabel,
"y");
490 }
else if (
fabs(m_project[0][1]) > tol) {
491 sprintf(buf,
"%g y",
fabs(m_project[0][1]));
492 strcat(m_xLabel, buf);
495 if (
fabs(m_project[0][1] - 1) < tol) {
496 strcat(m_xLabel,
"y");
497 }
else if (
fabs(m_project[0][1] + 1) < tol) {
498 strcat(m_xLabel,
"-y");
499 }
else if (m_project[0][1] > tol) {
500 sprintf(buf,
"%g y", m_project[0][1]);
501 strcat(m_xLabel, buf);
502 }
else if (m_project[0][1] < -tol) {
503 sprintf(buf,
"%g y", m_project[0][1]);
504 strcat(m_xLabel, buf);
509 if (strlen(m_xLabel) > 0) {
510 if (m_project[0][2] < -tol) {
511 strcat(m_xLabel,
" - ");
512 }
else if (m_project[0][2] > tol) {
513 strcat(m_xLabel,
" + ");
515 if (
fabs(m_project[0][2] - 1) < tol ||
fabs(m_project[0][2] + 1) < tol) {
516 strcat(m_xLabel,
"z");
517 }
else if (
fabs(m_project[0][2]) > tol) {
518 sprintf(buf,
"%g z",
fabs(m_project[0][2]));
519 strcat(m_xLabel, buf);
522 if (
fabs(m_project[0][2] - 1) < tol) {
523 strcat(m_xLabel,
"z");
524 }
else if (
fabs(m_project[0][2] + 1) < tol) {
525 strcat(m_xLabel,
"-z");
526 }
else if (m_project[0][2] > tol) {
527 sprintf(buf,
"%g z", m_project[0][2]);
528 strcat(m_xLabel, buf);
529 }
else if (m_project[0][2] < -tol) {
530 sprintf(buf,
"%g z", m_project[0][2]);
531 strcat(m_xLabel, buf);
536 strcat(m_xLabel,
" [cm]");
539 strcpy(m_yLabel,
"\0");
542 if (
fabs(m_project[1][0] - 1) < tol) {
543 strcat(m_yLabel,
"x");
544 }
else if (
fabs(m_project[1][0] + 1) < tol) {
545 strcat(m_yLabel,
"-x");
546 }
else if (m_project[1][0] > tol) {
547 sprintf(buf,
"%g x", m_project[1][0]);
548 strcat(m_yLabel, buf);
549 }
else if (m_project[1][0] < -tol) {
550 sprintf(buf,
"%g x", m_project[1][0]);
551 strcat(m_yLabel, buf);
555 if (strlen(m_yLabel) > 0) {
556 if (m_project[1][1] < -tol) {
557 strcat(m_yLabel,
" - ");
558 }
else if (m_project[1][1] > tol) {
559 strcat(m_yLabel,
" + ");
561 if (
fabs(m_project[1][1] - 1) < tol ||
562 fabs(m_project[1][1] + 1) < tol) {
563 strcat(m_yLabel,
"y");
564 }
else if (
fabs(m_project[1][1]) > tol) {
565 sprintf(buf,
"%g y",
fabs(m_project[1][1]));
566 strcat(m_yLabel, buf);
569 if (
fabs(m_project[1][1] - 1) < tol) {
570 strcat(m_yLabel,
"y");
571 }
else if (
fabs(m_project[1][1] + 1) < tol) {
572 strcat(m_yLabel,
"-y");
573 }
else if (m_project[1][1] > tol) {
574 sprintf(buf,
"%g y", m_project[1][1]);
575 strcat(m_yLabel, buf);
576 }
else if (m_project[1][1] < -tol) {
577 sprintf(buf,
"%g y", m_project[1][1]);
578 strcat(m_yLabel, buf);
583 if (strlen(m_yLabel) > 0) {
584 if (m_project[1][2] < -tol) {
585 strcat(m_yLabel,
" - ");
586 }
else if (m_project[1][2] > tol) {
587 strcat(m_yLabel,
" + ");
589 if (
fabs(m_project[1][2] - 1) < tol ||
fabs(m_project[1][2] + 1) < tol) {
590 strcat(m_yLabel,
"z");
591 }
else if (
fabs(m_project[1][2]) > tol) {
592 sprintf(buf,
"%g z",
fabs(m_project[1][2]));
593 strcat(m_yLabel, buf);
596 if (
fabs(m_project[1][2] - 1) < tol) {
597 strcat(m_yLabel,
"z");
598 }
else if (
fabs(m_project[1][2] + 1) < tol) {
599 strcat(m_yLabel,
"-z");
600 }
else if (m_project[1][2] > tol) {
601 sprintf(buf,
"%g z", m_project[1][2]);
602 strcat(m_yLabel, buf);
603 }
else if (m_project[1][2] < -tol) {
604 sprintf(buf,
"%g z", m_project[1][2]);
605 strcat(m_yLabel, buf);
610 strcat(m_yLabel,
" [cm]");
613 strcpy(m_description,
"\0");
616 if (
fabs(m_plane[0] - 1) < tol) {
617 strcat(m_description,
"x");
618 }
else if (
fabs(m_plane[0] + 1) < tol) {
619 strcat(m_description,
"-x");
620 }
else if (m_plane[0] > tol) {
621 sprintf(buf,
"%g x", m_plane[0]);
622 strcat(m_description, buf);
623 }
else if (m_plane[0] < -tol) {
624 sprintf(buf,
"%g x", m_plane[0]);
625 strcat(m_description, buf);
629 if (strlen(m_description) > 0) {
630 if (m_plane[1] < -tol) {
631 strcat(m_description,
" - ");
632 }
else if (m_plane[1] > tol) {
633 strcat(m_description,
" + ");
635 if (
fabs(m_plane[1] - 1) < tol ||
fabs(m_plane[1] + 1) < tol) {
636 strcat(m_description,
"y");
637 }
else if (
fabs(m_plane[1]) > tol) {
638 sprintf(buf,
"%g y",
fabs(m_plane[1]));
639 strcat(m_description, buf);
642 if (
fabs(m_plane[1] - 1) < tol) {
643 strcat(m_description,
"y");
644 }
else if (
fabs(m_plane[1] + 1) < tol) {
645 strcat(m_description,
"-y");
646 }
else if (m_plane[1] > tol) {
647 sprintf(buf,
"%g y", m_plane[1]);
648 strcat(m_description, buf);
649 }
else if (m_plane[1] < -tol) {
650 sprintf(buf,
"%g y", m_plane[1]);
651 strcat(m_description, buf);
656 if (strlen(m_description) > 0) {
657 if (m_plane[2] < -tol) {
658 strcat(m_description,
" - ");
659 }
else if (m_plane[2] > tol) {
660 strcat(m_description,
" + ");
662 if (
fabs(m_plane[2] - 1) < tol ||
fabs(m_plane[2] + 1) < tol) {
663 strcat(m_description,
"z");
664 }
else if (
fabs(m_plane[2]) > tol) {
665 sprintf(buf,
"%g z",
fabs(m_plane[2]));
666 strcat(m_description, buf);
669 if (
fabs(m_plane[2] - 1) < tol) {
670 strcat(m_description,
"z");
671 }
else if (
fabs(m_plane[2] + 1) < tol) {
672 strcat(m_description,
"-z");
673 }
else if (m_plane[2] > tol) {
674 sprintf(buf,
"%g z", m_plane[2]);
675 strcat(m_description, buf);
676 }
else if (m_plane[2] < -tol) {
677 sprintf(buf,
"%g z", m_plane[2]);
678 strcat(m_description, buf);
683 sprintf(buf,
" = %g", m_plane[3]);
684 strcat(m_description, buf);
687 std::cout << m_className <<
"::Labels:\n"
688 <<
" x label: |" << m_xLabel <<
"|\n"
689 <<
" y label: |" << m_yLabel <<
"|\n"
690 <<
" plane: |" << m_description <<
"|\n";
695 const double x0,
const double y0,
const double z0) {
698 const double fnorm = sqrt(fx * fx + fy * fy + fz * fz);
699 if (fnorm > 0 && fx * fx + fz * fz > 0) {
700 const double fxz = sqrt(fx * fx + fz * fz);
701 m_project[0][0] = fz / fxz;
703 m_project[0][2] = -fx / fxz;
704 m_project[1][0] = -fx * fy / (fxz * fnorm);
705 m_project[1][1] = (fx * fx + fz * fz) / (fxz * fnorm);
706 m_project[1][2] = -fy * fz / (fxz * fnorm);
707 m_project[2][0] = x0;
708 m_project[2][1] = y0;
709 m_project[2][2] = z0;
710 }
else if (fnorm > 0 && fy * fy + fz * fz > 0) {
711 const double fyz = sqrt(fy * fy + fz * fz);
712 m_project[0][0] = (fy * fy + fz * fz) / (fyz * fnorm);
713 m_project[0][1] = -fx * fz / (fyz * fnorm);
714 m_project[0][2] = -fy * fz / (fyz * fnorm);
716 m_project[1][1] = fz / fyz;
717 m_project[1][2] = -fy / fyz;
718 m_project[2][0] = x0;
719 m_project[2][1] = y0;
720 m_project[2][2] = z0;
722 std::cout << m_className <<
"::SetPlane:\n"
723 <<
" Normal vector has zero norm. No new projection set.\n";
730 m_plane[3] = fx * x0 + fy * y0 + fz * z0;
739 double auxu[3], auxv[3];
740 const double ctheta = cos(theta);
741 const double stheta = sin(theta);
742 for (
int i = 0; i < 3; ++i) {
743 auxu[i] = ctheta * m_project[0][i] - stheta * m_project[1][i];
744 auxv[i] = stheta * m_project[0][i] + ctheta * m_project[1][i];
746 for (
int i = 0; i < 3; ++i) {
747 m_project[0][i] = auxu[i];
748 m_project[1][i] = auxv[i];
755void ViewField::SetupCanvas() {
758 m_canvas =
new TCanvas();
759 m_canvas->SetTitle(
"Field View");
760 m_hasExternalCanvas =
false;
765ViewField::PlotType ViewField::GetPlotType(
const std::string& option,
766 std::string& title)
const {
768 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
769 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
772 }
else if (option ==
"e" || option ==
"field") {
775 }
else if (option ==
"ex") {
776 title =
"field (x-component)";
778 }
else if (option ==
"ey") {
779 title =
"field (y-component)";
781 }
else if (option ==
"ez") {
782 title =
"field (z-component)";
785 std::cerr << m_className <<
"::GetPlotType:\n Unknown option ("
791bool ViewField::SetupFunction(
const std::string& option, TF2*& f,
792 const bool contour,
const bool wfield) {
794 if (!m_sensor && !m_component) {
795 std::cerr << m_className <<
"::SetupFunction:\n"
796 <<
" Neither sensor nor component are defined.\n";
801 if (!m_hasUserArea) {
806 if (!m_sensor->
GetArea(bbmin[0], bbmin[1], bbmin[2],
807 bbmax[0], bbmax[1], bbmax[2])) {
808 std::cerr << m_className <<
"::SetupFunction:\n"
809 <<
" Sensor area is not defined.\n"
810 <<
" Please set the plot range explicitly (SetArea).\n";
815 bbmax[0], bbmax[1], bbmax[2])) {
816 std::cerr << m_className <<
"::SetupFunction:\n"
817 <<
" Bounding box of the component is not defined.\n"
818 <<
" Please set the plot range explicitly (SetArea).\n";
822 const double tol = 1.e-4;
823 double umin[2] = {-std::numeric_limits<double>::max(),
824 -std::numeric_limits<double>::max()};
825 double umax[2] = {std::numeric_limits<double>::max(),
826 std::numeric_limits<double>::max()};
827 for (
unsigned int i = 0; i < 3; ++i) {
828 bbmin[i] -= m_project[2][i];
829 bbmax[i] -= m_project[2][i];
830 for (
unsigned int j = 0; j < 2; ++j) {
831 if (
fabs(m_project[j][i]) < tol)
continue;
832 const double t1 = bbmin[i] / m_project[j][i];
833 const double t2 = bbmax[i] / m_project[j][i];
834 const double tmin = std::min(t1, t2);
835 const double tmax = std::max(t1, t2);
836 if (tmin > umin[j] && tmin < umax[j]) umin[j] = tmin;
837 if (tmax < umax[j] && tmax > umin[j]) umax[j] =
tmax;
844 std::cout << m_className <<
"::SetupFunction:\n Setting plot range to "
845 << m_xmin <<
" < x < " << m_xmax <<
", "
846 << m_ymin <<
" < y < " << m_ymax <<
".\n";
849 const std::string fname = FindUnusedFunctionName(
"f2D");
851 m_xmin, m_xmax, m_ymin, m_ymax, 1,
"ViewField",
"Evaluate2D");
854 f->SetRange(m_xmin, m_ymin, m_xmax, m_ymax);
858 const PlotType plotType = GetPlotType(option, title);
859 const int parPlotType = 10 * int(plotType) + 1;
862 double zmin = m_vmin;
863 double zmax = m_vmax;
865 title =
"weighting " + title;
866 f->SetParameter(0, -parPlotType);
867 if (plotType == Potential) {
870 }
else if (m_useAutoRange) {
871 SampleRange(m_xmin, m_ymin, m_xmax, m_ymax, f, zmin, zmax);
877 f->SetParameter(0, parPlotType);
878 if (plotType == Potential) {
879 if (m_useAutoRange) {
882 SampleRange(m_xmin, m_ymin, m_xmax, m_ymax, f, zmin, zmax);
884 }
else if (m_sensor) {
886 SampleRange(m_xmin, m_ymin, m_xmax, m_ymax, f, zmin, zmax);
894 title =
"electric " + title;
895 if (m_useAutoRange) {
896 SampleRange(m_xmin, m_ymin, m_xmax, m_ymax, f, zmin, zmax);
908 title =
"Contours of the " + title;
909 double level[m_nMaxContours];
910 if (m_nContours > 1) {
911 const double step = (zmax - zmin) / (m_nContours - 1.);
912 for (
unsigned int i = 0; i < m_nContours; ++i) {
913 level[i] = zmin + i * step;
916 level[0] = 0.5 * (zmax + zmin);
919 std::cout << m_className <<
"::SetupFunction:\n"
920 <<
" Number of contours: " << m_nContours <<
"\n";
921 for (
unsigned int i = 0; i < m_nContours; ++i) {
922 std::cout <<
" Level " << i <<
" = " << level[i] <<
"\n";
925 f->SetContour(m_nContours, level);
929 f->SetNpx(m_nSamples2dX);
930 f->SetNpy(m_nSamples2dY);
933 f->GetXaxis()->SetTitle(m_xLabel);
934 f->GetYaxis()->SetTitle(m_yLabel);
935 f->SetTitle(title.c_str());
940bool ViewField::SetupProfile(
const double x0,
const double y0,
const double z0,
941 const double x1,
const double y1,
const double z1,
942 const std::string& option, TF1*& f,
945 if (!m_sensor && !m_component) {
946 std::cerr << m_className <<
"::SetupProfile:\n"
947 <<
" Neither sensor nor component are defined.\n";
952 const double dx = x1 - x0;
953 const double dy = y1 - y0;
954 const double dz = z1 - z0;
955 if (dx * dx + dy * dy + dz * dz <= 0.) {
956 std::cerr << m_className <<
"::SetupProfile:\n"
957 <<
" Start and end points coincide.\n";
962 const std::string fname = FindUnusedFunctionName(
"fProfile");
964 0., 1., 7,
"ViewField",
"EvaluateProfile");
966 f->SetParameter(0, x0);
967 f->SetParameter(1, y0);
968 f->SetParameter(2, z0);
969 f->SetParameter(3, x1);
970 f->SetParameter(4, y1);
971 f->SetParameter(5, z1);
975 const PlotType plotType = GetPlotType(option, title);
976 const int parPlotType = 10 * int(plotType) + 1;
978 double fmin = m_vmin;
979 double fmax = m_vmax;
981 f->SetParameter(6, -parPlotType);
982 title =
"weighting " + title;
983 if (plotType == Potential) {
987 if (m_useAutoRange) {
988 SampleRange(f, fmin, fmax);
995 f->SetParameter(6, parPlotType);
996 if (plotType == Potential) {
997 if (m_useAutoRange) {
1000 SampleRange(f, fmin, fmax);
1002 }
else if (m_sensor) {
1004 SampleRange(f, fmin, fmax);
1012 title =
"electric " + title;
1013 if (m_useAutoRange) {
1014 SampleRange(f, fmin, fmax);
1021 f->SetMinimum(fmin);
1022 f->SetMaximum(fmax);
1024 std::cout << m_className <<
"::SetupProfile:\n"
1025 <<
" Plotting " << title <<
" along\n ("
1026 << f->GetParameter(0) <<
", " << f->GetParameter(1) <<
", "
1027 << f->GetParameter(2) <<
") - ("
1028 << f->GetParameter(3) <<
", " << f->GetParameter(4) <<
", "
1029 << f->GetParameter(5) <<
")\n";
1032 title =
"Profile plot of the " + title;
1033 f->SetTitle(title.c_str());
1034 f->GetXaxis()->SetTitle(
"normalised distance");
1035 if (plotType == Potential) {
1036 f->GetYaxis()->SetTitle(
"potential [V]");
1038 f->GetYaxis()->SetTitle(
"field [V/cm]");
1040 f->SetNpx(m_nSamples1d);
Abstract base class for components.
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
virtual double WeightingPotential(const double x, const double y, const double z, const std::string &label)
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
virtual void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
virtual bool GetVoltageRange(double &vmin, double &vmax)=0
Calculate the voltage range [V].
Abstract base class for media.
bool GetVoltageRange(double &vmin, double &vmax)
Return the voltage range.
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
Get the weighting field at (x, y, z).
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&medium, int &status)
Get the drift field and potential at (x, y, z).
double WeightingPotential(const double x, const double y, const double z, const std::string &label)
Get the weighting potential at (x, y, z).
bool GetArea(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Return the current user area.
void SetPlane(const double fx, const double fy, const double fz, const double x0, const double y0, const double z0)
void SetElectricFieldRange(const double emin, const double emax)
Set the plot limits for the electric field.
double Evaluate2D(double *pos, double *par)
void PlotWeightingField(const std::string &label, const std::string &option, const std::string &drawopt)
void PlotProfileWeightingField(const std::string &label, const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const std::string &option="v")
void SetNumberOfSamples2d(const unsigned int nx, const unsigned int ny)
Set the number of points used for drawing 2D functions.
void Rotate(const double angle)
Rotate the viewing plane (angle in radian).
void SetArea()
Set the viewing area based on the bounding box of the sensor/component.
void SetComponent(ComponentBase *c)
Set the component from which to retrieve the field.
void SetNumberOfSamples1d(const unsigned int n)
Set the number of points used for drawing 1D functions.
void SetVoltageRange(const double vmin, const double vmax)
Set the plot limits for the potential.
void PlotContour(const std::string &option="v")
void Plot(const std::string &option="v", const std::string &drawopt="arr")
void SetNumberOfContours(const unsigned int n)
Set the number of contour levels (at most 50).
void SetWeightingFieldRange(const double wmin, const double wmax)
Set the plot limits for the weighting field.
void SetSensor(Sensor *s)
Set the sensor from which to retrieve the field.
void SetDefaultProjection()
Set the default viewing plane ( - at ).
double EvaluateProfile(double *pos, double *par)
void PlotContourWeightingField(const std::string &label, const std::string &option)
void PlotProfile(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const std::string &option="v")
void SetCanvas(TCanvas *c)
Set the canvas to be painted on.
double RndmUniform()
Draw a random number uniformly distributed in the range [0, 1).
PlottingEngineRoot plottingEngine
DoubleAc fabs(const DoubleAc &f)