My code is as follows. I hope to collect electron and ion signals from sensors.
int main(int argc, char * argv[]) {
TApplication app("app", &argc, argv);
MediumMagboltz gas;
gas.LoadGasFile("ar_85_co2_15.gas");
const std::string path = std::getenv("GARFIELD_HOME");
gas.LoadIonMobility(path + "/Data/IonMobility_Ar+_Ar.txt");
ComponentAnalyticField cmp;
cmp.SetMedium(&gas);
//
const double rWire = 30.e-4;//cm
const double rTube = 3.5;//cm
//
const double vWire = 1100.;
const double vTube = 0.;
//
cmp.AddWire(0 , 0, 2* rWire, vWire, "s");
cmp.AddTube(rTube, vTube, 0 , "t");
cmp.AddReadout("s");
//
Sensor sensor;
sensor.AddComponent(&cmp);
sensor.AddElectrode(&cmp, "s");
const double tstep = 0.1;
const double tmin = 0;
const double tmax=20000;
const unsigned int nbins = (tmax-tmin)/tstep;
sensor.SetTimeWindow(tmin, tstep, nbins);
sensor.ClearSignal();
//----alpha in -----
// Read the SRIM output file.
TrackSrim track(&sensor);
const std::string file = "Li_in_Ar_CO2_gas.txt";
if (!track.ReadFile(file)) {
std::cerr << "Reading Li_in_Ar_CO2_gas.txt file failed.\n";
return 1;
}
// Set the initial kinetic energy of the particle (in eV).
track.SetKineticEnergy(0.84e6);
track.SetWorkFunction(27.7);
track.SetFanoFactor(0.172);
const double za = 0.85 * (18. / 39.948) +0.15 * (22. / 44.0095); // Set A and Z of the gas (not sure what's the correct mixing law).
track.SetAtomicMassNumbers(22. / za, 22);
// Specify how many electrons we want to be grouped to a cluster.
track.EnableTransverseStraggling(false);
track.EnableLongitudinalStraggling(false);
AvalancheMC mc;
mc.SetSensor(&sensor);
mc.EnableSignalCalculation();
const double rTrack =3.0;
const double projectilex= rTrack;
const double projectiley= sqrt(rTube * rTube - rTrack * rTrack);
const double projectilez= 0.;
const double projectiledx=0.;
const double projectiledy=-1.;
const double projectiledz=0.;
const double projectileT=0.;
//const unsigned int nTracks = 1;
track.NewTrack(projectilex, projectiley, projectilez, projectileT, projectiledx, projectiledy, projectiledz);
for (const auto& cluster : track.GetClusters()) {
//mc.SetElectronSignalScalingFactor(cluster.n);
mc.AvalancheElectron(cluster.x, cluster.y, cluster.z, cluster.t);
int status;
const unsigned int np = mc.GetNumberOfElectronEndpoints();
double xe1, ye1, ze1, te1, xe2, ye2, ze2, te2;
for (unsigned int i = 0; i < np; ++i) {
mc.GetElectronEndpoint(i, xe1, ye1, ze1, te1, xe2, ye2, ze2, te2, status);
mc.DriftIon(xe1, ye1, ze1, te1);
}
}
ViewSignal signalView;
signalView.SetSensor(&sensor);
signalView.PlotSignal("s");
app.Run();
return 0;
}
But I encountered the following problem: