359 {
360
361
362 const double d =
sqrt(
pow(x1 - x0, 2) +
pow(y1 - y0, 2) +
pow(z1 - z0, 2));
363 if (d <= 0.) {
364 std::cerr << className << "::PlotProfile:\n";
365 std::cerr << " Start and end point coincide.\n";
366 return;
367 }
368
369
370 if (canvas == 0) {
371 canvas = new TCanvas();
372 canvas->SetTitle("Field View");
373 if (hasExternalCanvas) hasExternalCanvas = false;
374 }
375 canvas->cd();
376
377 if (fPotProfile == 0) CreateProfileFunction();
378
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);
385 int plotType = 0;
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.);
393 plotType = 1;
394 fPotProfile->SetMinimum(emin);
395 fPotProfile->SetMaximum(emax);
396 } else if (option == "ex") {
397 fPotProfile->SetParameter(6, 11.);
398 plotType = 2;
399 fPotProfile->SetMinimum(emin);
400 fPotProfile->SetMaximum(emax);
401 } else if (option == "ey") {
402 fPotProfile->SetParameter(6, 21.);
403 plotType = 3;
404 fPotProfile->SetMinimum(emin);
405 fPotProfile->SetMaximum(emax);
406 } else if (option == "ez") {
407 fPotProfile->SetParameter(6, 31.);
408 plotType = 4;
409 fPotProfile->SetMinimum(emin);
410 fPotProfile->SetMaximum(emax);
411 } else {
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);
418 }
419 if (debug) {
420 std::cout << className << "::PlotProfile:\n";
421 if (plotType == 0) {
422 std::cout << " Plotting potential along\n";
423 } else {
424 std::cout << " Plotting field along\n";
425 }
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";
432 }
433 fPotProfile->GetXaxis()->SetTitle("normalised distance");
434 if (plotType == 0) {
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]");
449 }
450 fPotProfile->SetNpx(nSamples1d);
451 fPotProfile->Draw();
452 canvas->Update();
453}
DoubleAc pow(const DoubleAc &f, double p)