I want to get the induced current signal, however the result show in the below, I don’t know what’s the reason for the error and I modify the code several times, it is still the same.
the code is in the below
#include <iostream>
#include <TApplication.h>
#include <TH1F.h>
#include <TCanvas.h>
#include "Garfield/MediumSilicon.hh"
#include "Garfield/ComponentConstant.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/TrackTrim.hh"
#include "Garfield/DriftLineRKF.hh"
#include "Garfield/ViewDrift.hh"
#include "Garfield/ViewSignal.hh"
#include "Garfield/ComponentAnsys123.hh"
#include "Garfield/MediumMagboltz.hh"
using namespace Garfield;
int main(int argc, char *argv[]) {
// Application
TApplication app("app", &argc, argv);
ComponentAnsys123 fm;
fm.Initialise("ELIST.lis", "NLIST.lis", "MPLIST.lis", "PRNSOL.lis", "cm");
fm.SetWeightingField("weight1.lis", "readout");
double x0, y0, z0, x1, y1, z1;
fm.GetBoundingBox(x0, y0, z0, x1, y1, z1);
// Define the medium.
MediumMagboltz gas;
gas.LoadGasFile("Ar_90_CH4_10.gas");
fm.SetMedium(0, &gas);
Sensor sensor;
sensor.AddComponent(&fm);
sensor.AddElectrode(&fm, "readout");
// Set the time bins for the induced current.
const unsigned int nTimeBins = 1000;
const double tmin = 0.;
const double tmax = 100.;
const double tstep = (tmax - tmin) / nTimeBins;
sensor.SetTimeWindow(tmin, tstep, nTimeBins);
// Read the TRIM output file.
TrackTrim tr;
const std::string filename = "EXYZ-P10.txt";
// Import the first 100 ions.
if (!tr.ReadFile(filename, 100)) {
std::cerr << "Reading TRIM EXYZ file failed.\n";
return 1;
}
tr.SetWorkFunction(26);
tr.SetFanoFactor(0.179);
// Connect the track to a sensor.
tr.SetSensor(&sensor);
DriftLineRKF drift;
drift.SetSensor(&sensor);
drift.SetMaximumStepSize(10.e-4);
// Plot the track and the drift lines.
ViewDrift driftView;
tr.EnablePlotting(&driftView);
drift.EnablePlotting(&driftView);
// Simulate an ion track.
tr.NewTrack(-0.1, 0.204, -0.07, 0., 0., -1., 0.);
// Loop over the clusters.
double xc, yc, zc, tc, ec, ekin;
int ne = 0;
while (tr.GetCluster(xc, yc, zc, tc, ne, ec, ekin)) {
// Simulate electron and ion drift lines starting
// from the cluster position.
// Scale the induced current by the number of electron/ion pairs
// in the cluster.
drift.SetElectronSignalScalingFactor(ne);
drift.DriftElectron(xc, yc, zc, tc);
drift.SetHoleSignalScalingFactor(ne);
drift.DriftHole(xc, yc, zc, tc);
}
driftView.SetArea(-1.67e-1, 0.17, -0.67e-1, 0.2);
driftView.Plot(true);
ViewSignal signalView;
signalView.SetSensor(&sensor);
signalView.PlotSignal("readout", true, true, true);
app.Run();
return 0;
}