18 : className(
"ViewField"),
34 nContours(nMaxContours),
40 hasExternalCanvas(false),
51 if (!hasExternalCanvas && canvas != 0)
delete canvas;
52 if (fPot != 0)
delete fPot;
53 if (fWfield != 0)
delete fWfield;
54 if (fPotProfile != 0)
delete fPotProfile;
60 std::cerr << className <<
"::SetSensor:\n";
61 std::cerr <<
" Sensor pointer is null.\n";
68 bool ok = sensor->
GetArea(pxmin, pymin, pzmin, pxmax, pymax, pzmax);
70 std::cerr << className <<
"::SetSensor:\n";
71 std::cerr <<
" Warning: bounding box of sensor is not defined.\n";
76 std::cerr << className <<
"::SetSensor:\n";
77 std::cerr <<
" Warning: voltage range of sensor is not defined.\n";
84 std::cerr << className <<
"::SetComponent:\n";
85 std::cerr <<
" Component pointer is null.\n";
92 bool ok = component->
GetBoundingBox(pxmin, pymin, pzmin, pxmax, pymax, pzmax);
94 std::cerr << className <<
"::SetComponent:\n";
95 std::cerr <<
" Warning: bounding box of component is not defined.\n";
100 std::cerr << className <<
"::SetComponent:\n";
101 std::cerr <<
" Warning: voltage range of component is not defined.\n";
108 if (!hasExternalCanvas && canvas != 0) {
113 hasExternalCanvas =
true;
119 if (xmin == xmax || ymin == ymax) {
120 std::cerr << className <<
"::SetArea:\n";
121 std::cerr <<
" Null area range not permitted.\n";
122 std::cerr <<
" " << xmin <<
" < x < " << xmax <<
"\n";
123 std::cerr <<
" " << ymin <<
" < y < " << ymax <<
"\n";
126 pxmin = std::min(xmin, xmax);
127 pymin = std::min(ymin, ymax);
128 pxmax = std::max(xmin, xmax);
129 pymax = std::max(ymin, ymax);
134 fmin = std::min(minval, maxval);
135 fmax = std::max(minval, maxval);
139 const double maxval) {
141 emin = std::min(minval, maxval);
142 emax = std::max(minval, maxval);
146 const double maxval) {
148 wmin = std::min(minval, maxval);
149 wmax = std::max(minval, maxval);
154 if (n <= nMaxContours) {
157 std::cerr << className <<
"::SetNumberOfContours:\n";
158 std::cerr <<
" Max. number of contours is " << nMaxContours <<
".\n";
165 const int nmax = 100000;
167 if (n < nmin || n > nmax) {
168 std::cerr << className <<
"::SetNumberOfSamples1d:\n";
169 std::cerr <<
" Number of points (" << n <<
") out of range.\n";
170 std::cerr <<
" " << nmin <<
" <= n <= " << nmax <<
"\n";
180 const int nmax = 10000;
181 if (nx < nmin || nx > nmax) {
182 std::cerr << className <<
"::SetNumberOfSamples2d:\n";
183 std::cerr <<
" Number of x-points (" << nx <<
") out of range.\n";
184 std::cerr <<
" " << nmin <<
" <= nx <= " << nmax <<
"\n";
189 if (ny < nmin || ny > nmax) {
190 std::cerr << className <<
"::SetNumberOfSamples2d:\n";
191 std::cerr <<
" Number of y-points (" << ny <<
") out of range.\n";
192 std::cerr <<
" " << nmin <<
" <= ny <= " << nmax <<
"\n";
202 canvas =
new TCanvas();
203 canvas->SetTitle(
"Field View");
204 if (hasExternalCanvas) hasExternalCanvas =
false;
207 canvas->Range(pxmin, pymin, pxmax, pymax);
209 if (fPot == 0) CreateFunction();
212 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
213 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
214 fPot->SetParameter(0, -1.);
215 fPot->SetRange(pxmin, pymin, pxmax, pymax);
216 fPot->SetMinimum(fmin);
217 fPot->SetMaximum(fmax);
218 }
else if (option ==
"e" || option ==
"field") {
219 fPot->SetParameter(0, 1.);
221 fPot->SetMinimum(emin);
222 fPot->SetMaximum(emax);
223 }
else if (option ==
"ex") {
224 fPot->SetParameter(0, 11.);
226 fPot->SetMinimum(emin);
227 fPot->SetMaximum(emax);
228 }
else if (option ==
"ey") {
229 fPot->SetParameter(0, 21.);
231 fPot->SetMinimum(emin);
232 fPot->SetMaximum(emax);
233 }
else if (option ==
"ez") {
234 fPot->SetParameter(0, 31.);
236 fPot->SetMinimum(emin);
237 fPot->SetMaximum(emax);
239 std::cerr << className <<
"::PlotContour:\n";
240 std::cerr <<
" Unknown option (" << option <<
")\n";
241 std::cerr <<
" Plotting the potential.\n";
242 fPot->SetParameter(0, -1.);
243 fPot->SetMinimum(fmin);
244 fPot->SetMaximum(fmax);
247 double level[nMaxContours];
248 for (
int i = 0; i < nContours; ++i) {
251 level[i] = fmin + i * (fmax - fmin) / (nContours - 1.);
253 level[i] = emin + i * (emax - emin) / (nContours - 1.);
257 level[i] = (fmax + fmin) / 2.;
259 level[i] = (emax + emin) / 2.;
263 fPot->SetContour(nContours, level);
266 std::cout << className <<
"::PlotContour:\n";
267 std::cout <<
" Number of contours: " << nContours <<
"\n";
268 for (
int i = 0; i < nContours; ++i) {
269 std::cout <<
" Level " << i <<
" = " << level[i] <<
"\n";
272 fPot->SetNpx(nSamples2dX);
273 fPot->SetNpy(nSamples2dY);
274 fPot->GetXaxis()->SetTitle(xLabel);
275 fPot->GetYaxis()->SetTitle(yLabel);
277 fPot->SetTitle(
"Contours of the potential");
278 }
else if (plotType == 1) {
279 fPot->SetTitle(
"Contours of the electric field");
280 }
else if (plotType == 2) {
281 fPot->SetTitle(
"Contours of the electric field (x-component)");
282 }
else if (plotType == 3) {
283 fPot->SetTitle(
"Contours of the electric field (y-component)");
284 }
else if (plotType == 4) {
285 fPot->SetTitle(
"Contours of the electric field (z-component)");
287 fPot->Draw(
"CONT4Z");
295 canvas =
new TCanvas();
296 canvas->SetTitle(
"Field View");
297 if (hasExternalCanvas) hasExternalCanvas =
false;
300 canvas->Range(pxmin, pymin, pxmax, pymax);
302 if (fPot == 0) CreateFunction();
305 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
306 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
307 fPot->SetParameter(0, -1.);
308 fPot->SetMinimum(fmin);
309 fPot->SetMinimum(fmax);
310 }
else if (option ==
"e" || option ==
"field") {
311 fPot->SetParameter(0, 1.);
313 fPot->SetMinimum(emin);
314 fPot->SetMinimum(emax);
315 }
else if (option ==
"ex") {
316 fPot->SetParameter(0, 11.);
318 fPot->SetMinimum(emin);
319 fPot->SetMinimum(emax);
320 }
else if (option ==
"ey") {
321 fPot->SetParameter(0, 21.);
323 fPot->SetMinimum(emin);
324 fPot->SetMinimum(emax);
325 }
else if (option ==
"ez") {
326 fPot->SetParameter(0, 31.);
328 fPot->SetMinimum(emin);
329 fPot->SetMinimum(emax);
331 std::cerr << className <<
"::PlotSurface:\n";
332 std::cerr <<
" Unknown option (" << option <<
")\n";
333 std::cerr <<
" Plotting the potential.\n";
334 fPot->SetParameter(0, -1.);
335 fPot->SetMinimum(fmin);
336 fPot->SetMinimum(fmax);
338 fPot->SetNpx(nSamples2dX);
339 fPot->SetNpy(nSamples2dY);
340 fPot->GetXaxis()->SetTitle(xLabel);
341 fPot->GetYaxis()->SetTitle(yLabel);
343 fPot->SetTitle(
"Surface plot of the potential");
344 }
else if (plotType == 1) {
345 fPot->SetTitle(
"Surface plot of the electric field");
346 }
else if (plotType == 2) {
347 fPot->SetTitle(
"Surface plot of the electric field (x-component)");
348 }
else if (plotType == 3) {
349 fPot->SetTitle(
"Surface plot of the electric field (y-component)");
350 }
else if (plotType == 4) {
351 fPot->SetTitle(
"Surface plot of the electric field (z-component)");
358 const double x1,
const double y1,
const double z1,
359 const std::string option) {
362 const double d =
sqrt(
pow(x1 - x0, 2) +
pow(y1 - y0, 2) +
pow(z1 - z0, 2));
364 std::cerr << className <<
"::PlotProfile:\n";
365 std::cerr <<
" Start and end point coincide.\n";
371 canvas =
new TCanvas();
372 canvas->SetTitle(
"Field View");
373 if (hasExternalCanvas) hasExternalCanvas =
false;
377 if (fPotProfile == 0) CreateProfileFunction();
379 fPotProfile->SetParameter(0, x0);
380 fPotProfile->SetParameter(1, y0);
381 fPotProfile->SetParameter(2, z0);
382 fPotProfile->SetParameter(3, x1);
383 fPotProfile->SetParameter(4, y1);
384 fPotProfile->SetParameter(5, z1);
386 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
387 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
388 fPotProfile->SetParameter(6, -1.);
389 fPotProfile->SetMinimum(fmin);
390 fPotProfile->SetMaximum(fmax);
391 }
else if (option ==
"e" || option ==
"field") {
392 fPotProfile->SetParameter(6, 1.);
394 fPotProfile->SetMinimum(emin);
395 fPotProfile->SetMaximum(emax);
396 }
else if (option ==
"ex") {
397 fPotProfile->SetParameter(6, 11.);
399 fPotProfile->SetMinimum(emin);
400 fPotProfile->SetMaximum(emax);
401 }
else if (option ==
"ey") {
402 fPotProfile->SetParameter(6, 21.);
404 fPotProfile->SetMinimum(emin);
405 fPotProfile->SetMaximum(emax);
406 }
else if (option ==
"ez") {
407 fPotProfile->SetParameter(6, 31.);
409 fPotProfile->SetMinimum(emin);
410 fPotProfile->SetMaximum(emax);
412 std::cerr << className <<
"::PlotProfile:\n";
413 std::cerr <<
" Unknown option (" << option <<
")\n";
414 std::cerr <<
" Plotting the potential.\n";
415 fPotProfile->SetParameter(6, -1.);
416 fPotProfile->SetMinimum(fmin);
417 fPotProfile->SetMaximum(fmax);
420 std::cout << className <<
"::PlotProfile:\n";
422 std::cout <<
" Plotting potential along\n";
424 std::cout <<
" Plotting field along\n";
426 std::cout <<
" (" << fPotProfile->GetParameter(0) <<
", "
427 << fPotProfile->GetParameter(1) <<
", "
428 << fPotProfile->GetParameter(2) <<
") - ("
429 << fPotProfile->GetParameter(3) <<
", "
430 << fPotProfile->GetParameter(4) <<
", "
431 << fPotProfile->GetParameter(5) <<
")\n";
433 fPotProfile->GetXaxis()->SetTitle(
"normalised distance");
435 fPotProfile->SetTitle(
"Profile plot of the potential");
436 fPotProfile->GetYaxis()->SetTitle(
"potential [V]");
437 }
else if (plotType == 1) {
438 fPotProfile->SetTitle(
"Profile plot of the electric field");
439 fPotProfile->GetYaxis()->SetTitle(
"field [V/cm]");
440 }
else if (plotType == 2) {
441 fPotProfile->SetTitle(
"Profile plot of the electric field (x-component)");
442 fPotProfile->GetYaxis()->SetTitle(
"field [V/cm]");
443 }
else if (plotType == 3) {
444 fPotProfile->SetTitle(
"Profile plot of the electric field (y-component)");
445 fPotProfile->GetYaxis()->SetTitle(
"field [V/cm]");
446 }
else if (plotType == 4) {
447 fPotProfile->SetTitle(
"Profile plot of the electric field (z-component)");
448 fPotProfile->GetYaxis()->SetTitle(
"field [V/cm]");
450 fPotProfile->SetNpx(nSamples1d);
456 const std::string option) {
460 canvas =
new TCanvas();
461 canvas->SetTitle(
"Field View");
462 if (hasExternalCanvas) hasExternalCanvas =
false;
465 canvas->Range(pxmin, pymin, pxmax, pymax);
469 if (fWfield == 0) CreateFunctionWeightingField();
472 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
473 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
474 fWfield->SetParameter(0, -1.);
475 }
else if (option ==
"e" || option ==
"field") {
476 fWfield->SetParameter(0, 1.);
478 }
else if (option ==
"ex") {
479 fWfield->SetParameter(0, 11.);
481 }
else if (option ==
"ey") {
482 fWfield->SetParameter(0, 21.);
484 }
else if (option ==
"ez") {
485 fWfield->SetParameter(0, 31.);
488 std::cerr << className <<
"::PlotSurfaceWeightingField:\n";
489 std::cerr <<
" Unknown option (" << option <<
")\n";
490 std::cerr <<
" Plotting the absolute value of the field.\n";
491 fWfield->SetParameter(0, 1.);
493 fWfield->SetNpx(nSamples2dX);
494 fWfield->SetNpy(nSamples2dY);
495 fWfield->GetXaxis()->SetTitle(xLabel);
496 fWfield->GetYaxis()->SetTitle(yLabel);
498 fWfield->SetTitle(
"Surface plot of the weighting potential");
499 }
else if (plotType == 1) {
500 fWfield->SetTitle(
"Surface plot of the weighting field");
501 }
else if (plotType == 2) {
502 fWfield->SetTitle(
"Surface plot of the weighting field (x-component)");
503 }
else if (plotType == 3) {
504 fWfield->SetTitle(
"Surface plot of the weighting field (y-component)");
505 }
else if (plotType == 4) {
506 fWfield->SetTitle(
"Surface plot of the weighting field (z-component)");
508 fWfield->Draw(
"SURF4");
513 const std::string option) {
517 canvas =
new TCanvas();
518 canvas->SetTitle(
"Field View");
519 if (hasExternalCanvas) hasExternalCanvas =
false;
522 canvas->Range(pxmin, pymin, pxmax, pymax);
526 if (fWfield == 0) CreateFunctionWeightingField();
529 if (option ==
"v" || option ==
"p" || option ==
"phi" || option ==
"volt" ||
530 option ==
"voltage" || option ==
"pot" || option ==
"potential") {
531 fWfield->SetParameter(0, -1.);
532 }
else if (option ==
"e" || option ==
"field") {
533 fWfield->SetParameter(0, 1.);
535 }
else if (option ==
"ex") {
536 fWfield->SetParameter(0, 11.);
538 }
else if (option ==
"ey") {
539 fWfield->SetParameter(0, 21.);
541 }
else if (option ==
"ez") {
542 fWfield->SetParameter(0, 31.);
545 std::cerr << className <<
"::PlotContourWeightingField:\n";
546 std::cerr <<
" Unknown option (" << option <<
")\n";
547 std::cerr <<
" Plotting the absolute value of the field.\n";
548 fWfield->SetParameter(0, 1.);
550 fWfield->SetMinimum(wmin);
551 fWfield->SetMaximum(wmax);
553 double level[nMaxContours];
554 for (
int i = 0; i < nContours; ++i) {
556 level[i] = i / (nContours - 1.);
558 level[i] = wmin + (wmax - wmin) * level[i];
563 level[i] *= (wmax + wmin);
567 fWfield->SetContour(nContours, level);
570 std::cout << className <<
"::PlotContour:\n";
571 std::cout <<
" Number of contours: " << nContours <<
"\n";
572 for (
int i = 0; i < nContours; ++i) {
573 std::cout <<
" Level " << i <<
" = " << level[i] <<
"\n";
576 fWfield->SetNpx(nSamples2dX);
577 fWfield->SetNpy(nSamples2dY);
578 fWfield->GetXaxis()->SetTitle(xLabel);
579 fWfield->GetYaxis()->SetTitle(yLabel);
581 fWfield->SetTitle(
"Contours of the weighting potential");
582 }
else if (plotType == 1) {
583 fWfield->SetTitle(
"Contours of the weighting field");
584 }
else if (plotType == 2) {
585 fWfield->SetTitle(
"Contours of the weighting field (x-component)");
586 }
else if (plotType == 3) {
587 fWfield->SetTitle(
"Contours of the weighting field (y-component)");
588 }
else if (plotType == 4) {
589 fWfield->SetTitle(
"Contours of the weighting field (z-component)");
591 fWfield->Draw(
"CONT4Z");
595void ViewField::CreateFunction() {
598 std::string fname =
"fPotential_0";
599 while (gROOT->GetListOfFunctions()->FindObject(fname.c_str())) {
601 std::stringstream ss;
608 pxmax, pymin, pymax, 1,
"ViewField",
"EvaluatePotential");
611void ViewField::CreateProfileFunction() {
614 std::string fname =
"fPotentialProfile_0";
615 while (gROOT->GetListOfFunctions()->FindObject(fname.c_str())) {
617 std::stringstream ss;
618 ss <<
"fPotentialProfile_";
623 const int nParameters = 7;
626 nParameters,
"ViewField",
"EvaluatePotentialProfile");
629void ViewField::CreateFunctionWeightingField() {
632 std::string fname =
"fWfield_0";
633 while (gROOT->GetListOfFunctions()->FindObject(fname.c_str())) {
635 std::stringstream ss;
643 pxmax, pymin, pymax, 1,
"ViewField",
"EvaluateWeightingField");
671 if (sensor == 0 && component == 0)
return 0.;
674 double ex = 0., ey = 0., ez = 0., volt = 0.;
678 project[0][0] * pos[0] + project[1][0] * pos[1] + project[2][0];
680 project[0][1] * pos[0] + project[1][1] * pos[1] + project[2][1];
682 project[0][2] * pos[0] + project[1][2] * pos[1] + project[2][2];
685 component->
ElectricField(xpos, ypos, zpos, ex, ey, ez, volt, medium,
688 sensor->
ElectricField(xpos, ypos, zpos, ex, ey, ez, volt, medium, status);
691 std::cout << className <<
"::EvaluatePotential:\n";
692 std::cout <<
" At (u, v) = (" << pos[0] <<
", " << pos[1] <<
"), "
693 <<
" (x,y,z) = (" << xpos <<
"," << ypos <<
"," << zpos <<
")\n";
694 std::cout <<
" E = " << ex <<
", " << ey <<
", " << ez
695 <<
"), V = " << volt <<
", status = " << status <<
"\n";
698 if (useStatus && status != 0)
return vBkg;
703 }
else if (par[0] > 20.) {
705 }
else if (par[0] > 10.) {
707 }
else if (par[0] > 0.) {
708 return sqrt(ex * ex + ey * ey + ez * ez);
716 if (sensor == 0 && component == 0)
return 0.;
719 const double x0 = par[0];
720 const double y0 = par[1];
721 const double z0 = par[2];
722 const double x1 = par[3];
723 const double y1 = par[4];
724 const double z1 = par[5];
726 const double dx = x1 - x0;
727 const double dy = y1 - y0;
728 const double dz = z1 - z0;
730 const double t = pos[0];
733 double ex = 0., ey = 0., ez = 0., volt = 0.;
738 component->
ElectricField(x0 + t * dx, y0 + t * dy, z0 + t * dz, ex, ey, ez,
739 volt, medium, status);
741 sensor->
ElectricField(x0 + t * dx, y0 + t * dy, z0 + t * dz, ex, ey, ez,
742 volt, medium, status);
745 if (useStatus && status != 0) volt = vBkg;
750 }
else if (par[6] > 20.) {
752 }
else if (par[6] > 10.) {
754 }
else if (par[6] > 0.) {
755 return sqrt(ex * ex + ey * ey + ez * ez);
763 if (sensor == 0 && component == 0)
return 0.;
766 double ex = 0., ey = 0., ez = 0., v = 0.;
768 project[0][0] * pos[0] + project[1][0] * pos[1] + project[2][0];
770 project[0][1] * pos[0] + project[1][1] * pos[1] + project[2][1];
772 project[0][2] * pos[0] + project[1][2] * pos[1] + project[2][2];
776 component->
WeightingField(xpos, ypos, zpos, ex, ey, ez, electrode);
788 std::cout << className <<
"::EvaluateWeightingField:\n";
789 std::cout <<
" At (u, v) = (" << pos[0] <<
", " << pos[1] <<
"), "
790 <<
" (x, y, z) = (" << xpos <<
"," << ypos <<
"," << zpos
793 std::cout <<
" E = (" << ex <<
", " << ey <<
", " << ez <<
")\n";
795 std::cout <<
" V = " << v <<
"\n";
802 }
else if (par[0] > 30.) {
804 }
else if (par[0] > 20.) {
806 }
else if (par[0] > 10.) {
809 return sqrt(ex * ex + ey * ey + ez * ez);
813void ViewField::Labels() {
816 strcpy(xLabel,
"\0");
820 if (
fabs(project[0][0] - 1) < 1.0e-4) {
822 }
else if (
fabs(project[0][0] + 1) < 1.0e-4) {
823 strcat(xLabel,
"-x");
824 }
else if (project[0][0] > 1.0e-4) {
825 sprintf(buf,
"%g x", project[0][0]);
827 }
else if (project[0][0] < -1.0e-4) {
828 sprintf(buf,
"%g x", project[0][0]);
833 if (strlen(xLabel) > 0) {
834 if (project[0][1] < -1.0e-4) {
835 strcat(xLabel,
" - ");
836 }
else if (project[0][1] > 1.0e-4) {
837 strcat(xLabel,
" + ");
839 if (
fabs(project[0][1] - 1) < 1.0e-4 ||
fabs(project[0][1] + 1) < 1.0e-4) {
841 }
else if (
fabs(project[0][1]) > 1.0e-4) {
842 sprintf(buf,
"%g y",
fabs(project[0][1]));
846 if (
fabs(project[0][1] - 1) < 1.0e-4) {
848 }
else if (
fabs(project[0][1] + 1) < 1.0e-4) {
849 strcat(xLabel,
"-y");
850 }
else if (project[0][1] > 1.0e-4) {
851 sprintf(buf,
"%g y", project[0][1]);
853 }
else if (project[0][1] < -1.0e-4) {
854 sprintf(buf,
"%g y", project[0][1]);
860 if (strlen(xLabel) > 0) {
861 if (project[0][2] < -1.0e-4) {
862 strcat(xLabel,
" - ");
863 }
else if (project[0][2] > 1.0e-4) {
864 strcat(xLabel,
" + ");
866 if (
fabs(project[0][2] - 1) < 1.0e-4 ||
fabs(project[0][2] + 1) < 1.0e-4) {
868 }
else if (
fabs(project[0][2]) > 1.0e-4) {
869 sprintf(buf,
"%g z",
fabs(project[0][2]));
873 if (
fabs(project[0][2] - 1) < 1.0e-4) {
875 }
else if (
fabs(project[0][2] + 1) < 1.0e-4) {
876 strcat(xLabel,
"-z");
877 }
else if (project[0][2] > 1.0e-4) {
878 sprintf(buf,
"%g z", project[0][2]);
880 }
else if (project[0][2] < -1.0e-4) {
881 sprintf(buf,
"%g z", project[0][2]);
887 strcat(xLabel,
" [cm]");
890 strcpy(yLabel,
"\0");
893 if (
fabs(project[1][0] - 1) < 1.0e-4) {
895 }
else if (
fabs(project[1][0] + 1) < 1.0e-4) {
896 strcat(yLabel,
"-x");
897 }
else if (project[1][0] > 1.0e-4) {
898 sprintf(buf,
"%g x", project[1][0]);
900 }
else if (project[1][0] < -1.0e-4) {
901 sprintf(buf,
"%g x", project[1][0]);
906 if (strlen(yLabel) > 0) {
907 if (project[1][1] < -1.0e-4) {
908 strcat(yLabel,
" - ");
909 }
else if (project[1][1] > 1.0e-4) {
910 strcat(yLabel,
" + ");
912 if (
fabs(project[1][1] - 1) < 1.0e-4 ||
fabs(project[1][1] + 1) < 1.0e-4) {
914 }
else if (
fabs(project[1][1]) > 1.0e-4) {
915 sprintf(buf,
"%g y",
fabs(project[1][1]));
919 if (
fabs(project[1][1] - 1) < 1.0e-4) {
921 }
else if (
fabs(project[1][1] + 1) < 1.0e-4) {
922 strcat(yLabel,
"-y");
923 }
else if (project[1][1] > 1.0e-4) {
924 sprintf(buf,
"%g y", project[1][1]);
926 }
else if (project[1][1] < -1.0e-4) {
927 sprintf(buf,
"%g y", project[1][1]);
933 if (strlen(yLabel) > 0) {
934 if (project[1][2] < -1.0e-4) {
935 strcat(yLabel,
" - ");
936 }
else if (project[1][2] > 1.0e-4) {
937 strcat(yLabel,
" + ");
939 if (
fabs(project[1][2] - 1) < 1.0e-4 ||
fabs(project[1][2] + 1) < 1.0e-4) {
941 }
else if (
fabs(project[1][2]) > 1.0e-4) {
942 sprintf(buf,
"%g z",
fabs(project[1][2]));
946 if (
fabs(project[1][2] - 1) < 1.0e-4) {
948 }
else if (
fabs(project[1][2] + 1) < 1.0e-4) {
949 strcat(yLabel,
"-z");
950 }
else if (project[1][2] > 1.0e-4) {
951 sprintf(buf,
"%g z", project[1][2]);
953 }
else if (project[1][2] < -1.0e-4) {
954 sprintf(buf,
"%g z", project[1][2]);
960 strcat(yLabel,
" [cm]");
963 strcpy(description,
"\0");
966 if (
fabs(plane[0] - 1) < 1.0e-4) {
967 strcat(description,
"x");
968 }
else if (
fabs(plane[0] + 1) < 1.0e-4) {
969 strcat(description,
"-x");
970 }
else if (plane[0] > 1.0e-4) {
971 sprintf(buf,
"%g x", plane[0]);
972 strcat(description, buf);
973 }
else if (plane[0] < -1.0e-4) {
974 sprintf(buf,
"%g x", plane[0]);
975 strcat(description, buf);
979 if (strlen(description) > 0) {
980 if (plane[1] < -1.0e-4) {
981 strcat(description,
" - ");
982 }
else if (plane[1] > 1.0e-4) {
983 strcat(description,
" + ");
985 if (
fabs(plane[1] - 1) < 1.0e-4 ||
fabs(plane[1] + 1) < 1.0e-4) {
986 strcat(description,
"y");
987 }
else if (
fabs(plane[1]) > 1.0e-4) {
988 sprintf(buf,
"%g y",
fabs(plane[1]));
989 strcat(description, buf);
992 if (
fabs(plane[1] - 1) < 1.0e-4) {
993 strcat(description,
"y");
994 }
else if (
fabs(plane[1] + 1) < 1.0e-4) {
995 strcat(description,
"-y");
996 }
else if (plane[1] > 1.0e-4) {
997 sprintf(buf,
"%g y", plane[1]);
998 strcat(description, buf);
999 }
else if (plane[1] < -1.0e-4) {
1000 sprintf(buf,
"%g y", plane[1]);
1001 strcat(description, buf);
1006 if (strlen(description) > 0) {
1007 if (plane[2] < -1.0e-4) {
1008 strcat(description,
" - ");
1009 }
else if (plane[2] > 1.0e-4) {
1010 strcat(description,
" + ");
1012 if (
fabs(plane[2] - 1) < 1.0e-4 ||
fabs(plane[2] + 1) < 1.0e-4) {
1013 strcat(description,
"z");
1014 }
else if (
fabs(plane[2]) > 1.0e-4) {
1015 sprintf(buf,
"%g z",
fabs(plane[2]));
1016 strcat(description, buf);
1019 if (
fabs(plane[2] - 1) < 1.0e-4) {
1020 strcat(description,
"z");
1021 }
else if (
fabs(plane[2] + 1) < 1.0e-4) {
1022 strcat(description,
"-z");
1023 }
else if (plane[2] > 1.0e-4) {
1024 sprintf(buf,
"%g z", plane[2]);
1025 strcat(description, buf);
1026 }
else if (plane[2] < -1.0e-4) {
1027 sprintf(buf,
"%g z", plane[2]);
1028 strcat(description, buf);
1033 sprintf(buf,
" = %g", plane[3]);
1034 strcat(description, buf);
1037 std::cout << className <<
"::Labels:\n";
1038 std::cout <<
" x label: |" << xLabel <<
"|\n";
1039 std::cout <<
" y label: |" << yLabel <<
"|\n";
1040 std::cout <<
" plane: |" << description <<
"|\n";
1045 const double x0,
const double y0,
const double z0) {
1048 double fnorm =
sqrt(fx * fx + fy * fy + fz * fz);
1049 if (fnorm > 0 && fx * fx + fz * fz > 0) {
1050 project[0][0] = fz /
sqrt(fx * fx + fz * fz);
1052 project[0][2] = -fx /
sqrt(fx * fx + fz * fz);
1053 project[1][0] = -fx * fy / (
sqrt(fx * fx + fz * fz) * fnorm);
1054 project[1][1] = (fx * fx + fz * fz) / (
sqrt(fx * fx + fz * fz) * fnorm);
1055 project[1][2] = -fy * fz / (
sqrt(fx * fx + fz * fz) * fnorm);
1059 }
else if (fnorm > 0 && fy * fy + fz * fz > 0) {
1060 project[0][0] = (fy * fy + fz * fz) / (
sqrt(fy * fy + fz * fz) * fnorm);
1061 project[0][1] = -fx * fz / (
sqrt(fy * fy + fz * fz) * fnorm);
1062 project[0][2] = -fy * fz / (
sqrt(fy * fy + fz * fz) * fnorm);
1064 project[1][1] = fz /
sqrt(fy * fy + fz * fz);
1065 project[1][2] = -fy /
sqrt(fy * fy + fz * fz);
1070 std::cout << className <<
"::SetPlane:\n";
1071 std::cout <<
" Normal vector has zero norm.\n";
1072 std::cout <<
" No new projection set.\n";
1079 plane[3] = fx * x0 + fy * y0 + fz * z0;
1088 double auxu[3], auxv[3];
1089 for (
int i = 0; i < 3; ++i) {
1090 auxu[i] =
cos(angle) * project[0][i] -
sin(angle) * project[1][i];
1091 auxv[i] =
sin(angle) * project[0][i] +
cos(angle) * project[1][i];
1093 for (
int i = 0; i < 3; ++i) {
1094 project[0][i] = auxu[i];
1095 project[1][i] = auxv[i];
DoubleAc cos(const DoubleAc &f)
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
DoubleAc fabs(const DoubleAc &f)
virtual void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
virtual void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
virtual double WeightingPotential(const double x, const double y, const double z, const std::string label)
virtual bool GetVoltageRange(double &vmin, double &vmax)=0
bool GetVoltageRange(double &vmin, double &vmax)
double WeightingPotential(const double x, const double y, const double z, const std::string label)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string label)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&medium, int &status)
bool GetArea(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
void SetNumberOfContours(const int n)
void SetElectricFieldRange(const double minval, const double maxval)
double EvaluatePotentialProfile(double *pos, double *par)
void SetNumberOfSamples2d(const int nx, const int ny)
void PlotContourWeightingField(const std::string label, const std::string option)
void SetArea(double xmin, double ymin, double xmax, double ymax)
void SetComponent(ComponentBase *c)
double EvaluatePotential(double *pos, double *par)
void Rotate(double angle)
void PlotSurface(const std::string option="v")
double EvaluateWeightingField(double *pos, double *par)
void SetSensor(Sensor *s)
void SetVoltageRange(const double minval, const double maxval)
void SetDefaultProjection()
void PlotSurfaceWeightingField(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 SetWeightingFieldRange(const double minval, const double maxval)
void SetCanvas(TCanvas *c)
void SetPlane(double fx, double fy, double fz, double x0, double y0, double z0)
void SetNumberOfSamples1d(const int n)
void PlotContour(const std::string option="v")
PlottingEngineRoot plottingEngine