I intend to study the motion of electrons ionized by 6MeV alpha particles in the drift electric field ( assuming a uniform electric field ). I want to obtain the drift time of the electron ( moving from the top of the drift electric field to the bottom ) and the position of the electron reaching the bottom of the drift electric field ( in order to evaluate the position resolution ).
However, the 6MeV alpha particles produce a large number of electrons, so I simulate an electron ( assuming that this electron is a primary electron produced by alpha ionization ). The initial position of the electron is at the top of the drift electric field, and the direction is -z.
I use avalMicro.DriftElectron( and avalMicro.AvalancheElectron) to simulate the drift of electron,avalMicro.GetNumberOfElectronEndpoints() to get drift time and position
The code is as follows :
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <TCanvas.h>
#include <TROOT.h>
#include <TApplication.h>
#include "Garfield/Random.hh"
#include "Garfield/ViewCell.hh"
#include "Garfield/ViewDrift.hh"
#include "Garfield/ViewSignal.hh"
#include "Garfield/ViewField.hh"
#include "Garfield/ComponentAnalyticField.hh"
#include "Garfield/ComponentConstant.hh"
#include "Garfield/MediumMagboltz.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/DriftLineRKF.hh"
#include "Garfield/AvalancheMicroscopic.hh"
#include "Garfield/AvalancheMC.hh"
#include "Garfield/TrackHeed.hh"
using namespace Garfield;
using namespace std;
int main(int argc, char *argv[])
{
TApplication app("app", &argc, argv);
// Set gas
MediumMagboltz gas;
gas.SetTemperature(293.15);
gas.SetPressure(760.);
gas.SetMaxElectronEnergy(200.);
gas.SetComposition("Ar", 0.94, "CO2", 0.03, "H2O", 0.03, "O2", 20.9, "N2", 78.1);
gas.Initialise(true); // prepares the table of microscopic scattering rates
gas.LoadGasFile("gas_293_1atm_10-100000nE20.gas");
const string ionpath = std::getenv("GARFIELD_INSTALL");
gas.LoadIonMobility(ionpath + "/share/Garfield/Data/IonMobility_Ar+_Ar.txt");
// uniform field
ComponentConstant cmp;
constexpr double xlength = 10.; // cm
constexpr double ylength = 10.;
constexpr double zlength = 10.;
const double xmin = -0.5 * xlength;
const double xmax = 0.5 * xlength;
const double ymin = -0.5 * ylength;
const double ymax = 0.5 * ylength;
const double zmin = 0;
const double zmax = zlength;
cmp.SetArea(xmin, ymin, zmin, xmax, ymax, zmax);
cmp.SetMedium(&gas);
cmp.SetElectricField(0., 0., 800.); // V/cm
ViewField fieldView;
constexpr bool plotField = true;
if (plotField)
{
fieldView.SetComponent(&cmp);
fieldView.SetPlaneXZ(); // viewing plane (xz plane).
fieldView.SetArea(xmin, zmin, xmax, zmax);
TCanvas *cf = new TCanvas("cf", "", 600, 600);
cf->SetLeftMargin(0.16);
fieldView.SetCanvas(cf);
// fieldView.PlotContour("v");
fieldView.Plot("v", "CONT1");
std::vector<double> xf;
std::vector<double> yf;
std::vector<double> zf;
fieldView.EqualFluxIntervals(xmin, 0, 0.99 * zmax, xmax, 0, 0.99 * zmax, xf, yf, zf, 20);
fieldView.PlotFieldLines(xf, yf, zf, true, false);
}
Sensor sensor;
sensor.AddComponent(&cmp);
DriftLineRKF drift;
drift.SetSensor(&sensor);
AvalancheMicroscopic avalMicro;
avalMicro.SetSensor(&sensor);
AvalancheMC avalMC;
avalMC.SetSensor(&sensor);
TrackHeed track;
track.SetParticle("e-");
track.SetEnergy(1e6);
track.SetSensor(&sensor);
TCanvas *cD = nullptr;
ViewDrift driftView;
constexpr bool plotDrift = true;
if (plotDrift)
{
cD = new TCanvas("cD", "", 600, 600);
driftView.SetCanvas(cD);
avalMicro.EnablePlotting(&driftView);
drift.EnablePlotting(&driftView);
avalMC.EnablePlotting(&driftView);
}
const unsigned int nEvents = 10;
const double x0 = 0;
const double y0 = 0;
const double z0 = 9;
const double t0 = 0.;
const double e0 = 0.1;
const double dx0 = 0.;
const double dy0 = 0;
const double dz0 = -1.;
std::ofstream datafile;
std::string filename = "data_drift.txt";
datafile.open(filename);
for (unsigned int i = 0; i < nEvents; ++i)
{
// track.NewTrack(x0, y0, z0, t0, dx0, dy0,dz0);
avalMicro.DriftElectron(x0, y0, z0, t0, e0, dx0, dy0, dz0);
// avalMicro.AvalancheElectron(x0, y0, z0, t0, e0, dx0, dy0, dz0);
const unsigned int np = avalMicro.GetNumberOfElectronEndpoints();
// const unsigned int numdriPoint = avalMicro.GetNumberOfElectronDriftLinePoints();
cout << "np: " << np << "\n";
double xe1, ye1, ze1, te1, e1;
double xe2, ye2, ze2, te2, e2;
int status;
std::ostringstream out;
for (unsigned int j = 0; j < np; ++j)
{
avalMicro.GetElectronEndpoint(j, xe1, ye1, ze1, te1, e1,
xe2, ye2, ze2, te2, e2, status);
out << "i=" << i << " ,"
<< "j=" << j << ","
<< " ze1=" << ze1 << " ze2=" << ze2
<< " xe1=" << xe1 << " xe2=" << xe2
<< " ye1=" << ye1 << " ye2=" << ye2 << std::endl;
}
std::string out_str = out.str();
datafile << out_str;
out.clear();
}
datafile.close();
app.Run(true);
}
However, the result shows that the position of the electron changes little.
Can you help me have a look if the idea is correct?How can I get the drift time and drift line from the top of the drift electric field to the bottom, should I use TrackHeed ?
I would appreciate it if you could provide some advice,Thanks a lot!