# When using neBEM to calculate the electric field, can the drift line be plotted superimposed on the geometry?

**URL:** <https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948>\
**Category:** Garfield++\
**Created:** [April 11, 2024, 8:52am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948 "2024-04-11T08:52:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [April 11, 2024, 8:52am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/1 "2024-04-11T08:52:49Z")

</div>

when using neBEM to calculate the electric field, can the drift line be plotted superimposed on the geometry?

---

<div class="post-metadata">

**Author:** ![Piet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/piet/32/12536_2.png) [@Piet](https://root-forum.cern.ch/u/Piet)\
**Post date:** [April 12, 2024, 8:54am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/2 "2024-04-12T08:54:12Z")

</div>

Dear @newconcept1979

I am also not 100% sure this can be done. While for ViewFEMesh there is the function SetViewDrift (see [doxygen documentation](https://garfieldpp.web.cern.ch/documentation/doxygen/html/classGarfield_1_1ViewFEMesh.html)), there is no such function in the ViewGeometry class. But I would think that one could try to plot the 2d geometry and the drift line on the same canvas, if one is careful to choose the same coordinates.

So I would suggest you try and eventually come back if you encounter a problem? A good starting point would be the [nebem example](https://garfieldpp.web.cern.ch/garfieldpp/examples/nebem/).

Eventually you could contribute to garfield++ development by implementing functions to draw 2D and 3D drift lines in the ViewGeometry class (following the [example of ViewFEMesh](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Source/ViewFEMesh.cc#L629-L660%5D)) or develop a ViewNeBEM class.

Kind regards  
Piet

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [April 15, 2024, 1:39am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/3 "2024-04-15T01:39:19Z")

</div>

@Piet , when plotting drift line firstly, everything worked well!

---

<div class="post-metadata">

**Author:** ![Piet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/piet/32/12536_2.png) [@Piet](https://root-forum.cern.ch/u/Piet)\
**Post date:** [April 15, 2024, 10:13am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/4 "2024-04-15T10:13:19Z")

</div>

Dear @newconcept1979 I am happy to hear you tried and it worked. Can you maybe post your code (or a minimal example that reproduces your result) such that we have this documented for future users?  
Thanks  
Piet

---

<div class="post-metadata">

**Author:** ![newconcept1979](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/newconcept1979/32/26349_2.png) [@newconcept1979](https://root-forum.cern.ch/u/newconcept1979)\
**Post date:** [April 16, 2024, 12:20am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/5 "2024-04-16T00:20:27Z")

</div>

The key codes is:

```auto
  GeometrySimple geo;
  geo.SetMedium(&gas);
  MediumConductor cu;
  SolidTube tubeA(0,0,1,1.8,0.02);
  tubeA.SetBoundaryPotential(3000.);
  tubeA.SetLabel("s");
  SolidTube tubeC(0,0,-1,1.8,0.02);
  tubeC.SetBoundaryPotential(0.);
  geo.AddSolid(&tubeA,&cu);
  geo.AddSolid(&tubeC,&cu);

  ComponentNeBem3d nebem;
  nebem.SetGeometry(&geo);
  nebem.SetTargetElementSize(0.1);
  nebem.Initialise();

  

  ViewGeometry geoView;
  geoView.SetGeometry(&geo);
  geoView.SetArea(-2.,-1.1,2.,1.1);
  geoView.SetPlane(0,-1,0,0,0,0);
  TCanvas* c1=new TCanvas("","",1200,1200);
  geoView.SetCanvas(c1);

  ViewDrift driftView;
  driftView.SetCanvas(c1);
  driftView.SetArea(-2.,-1.1,2.,1.1);
  driftView.SetPlane(0,-1,0,0,0,0);
  driftView.Plot2d(true);
  geoView.Plot2d();
  c1->Print("NeBem.ps");

```

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [April 30, 2024, 12:20am UTC](https://root-forum.cern.ch/t/when-using-nebem-to-calculate-the-electric-field-can-the-drift-line-be-plotted-superimposed-on-the-geometry/58948/6 "2024-04-30T00:20:36Z")

</div>

Closed on April 30, 2024, 12:20am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
