Proportional Counter in Garfield++

ROOT Version: 6.32.12
Platform: wsl2 Ubuntu 24.04.1


Hi. I am a physics undergrad, and I am learning Garfield++ as part of my Summer Project. I am building a proportional counter and I would like to “visualize” the electric fields in my detector and maybe simulate some events of electron multiplication.
In the code: I am seeing the field lines from front (XY) which is okay.. but when i change it to XZ, I can see the field lines change their orientation but my detector body remains in XY view.

#include <TApplication.h>
#include <TAxis.h>
#include <TCanvas.h>
#include <TGraph.h>

#include <vector>

#include "Garfield/ComponentAnalyticField.hh"
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/Plotting.hh"
#include "Garfield/ViewCell.hh"
#include "Garfield/ViewField.hh"

using namespace Garfield;

int main(int argc, char* argv[])
{
    TApplication app("app", &argc, argv);
    plottingEngine.SetDefaultStyle();

    MediumMagboltz gas("ar", 100.);

    ComponentAnalyticField cmp;
    cmp.SetMedium(&gas);

    const double dWire = 70.e-4;
    const double lWire = 30.;
    
    const double rTube = 1.;
    
    cmp.AddWire(0., 0., dWire, 1000., "s", lWire);
    cmp.AddTube(rTube, 0., 0., "t");

    cmp.PrintCell();

    ViewField fieldView(&cmp);
    fieldView.SetArea(-2., -2., 2., 2.);
    fieldView.SetPlaneXY();   //change view

    TCanvas c1("c1", "", 600, 600);
    fieldView.SetCanvas(&c1);
    fieldView.PlotContour();

    ViewCell cellView(&cmp);
    cellView.SetCanvas(fieldView.GetCanvas());
    cellView.SetArea(-2., -2., 2., 2.);
    cellView.Plot2d();

    app.Run(true);
} 

Am I doing something wrong? Is there any other class which might help me?

Also for the electron multiplication part, which classes should I use?

Thanks in Advance!!

Dear @bardiel

You are using ComponentAnalyticField, which is inherently 2D, so you only have a XY view, the tube has infinite length in Z direction.

For the avalanche you can use DriftLineRKF or AvalancheMC. Please have a look at the usersguide there is a very brief but good explanation about the possible transport classes, targetting newcomers.

Have a look also at the examples page of the garfield++ webpage, there is an example on a proportional counter.

I read the userguide and am still confused on what classes to use.

Can you give me a basic skeleton of the code for my problem. I want to see the side view of the proportional counter (horizontal anode wire in the center), and when a particle, say beta, enters the counter it causes ionization of the gas medium and the electron produced accelerates towards the anode where it causes further avalanche. I want to visualize this for different particles.

Thanks!

Dear @bardiel a.f.a.i.k. we currently do not have a basic skeleton of the code for your problem. In case you stick with the 2D definition of the field with ComponentAnalyticField this would require some software development.
You could maybe try to use the ViewCell::Plot3d() and then rotate your 3D object to have a XZ view. This is however using ROOT’s TGeo class, of which I do not know all the details.

  TCanvas *Cc = new TCanvas("Cc","",600,600);
  ViewCell cellView;
  cellView.SetCanvas(Cc);
  cellView.SetComponent(&cmp);
  cellView.Plot3d();

Alternatively you could try to make your 3D geometry using FEM or BEM methods: e.g. Ansys, Comsol, neBEM and then use their plotting methods to visualize the XZ plane.

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