I am simulating an electron avalanche using the same method as shown in the GEM example. For my case, there are two main differences:
- Instead of creating 10 random electrons at a given z0, the primary electrons are created from a track using Heed.
- Instead of using the AvalancheMC to drift the ions, I use DriftLineRKF. This seems to speed things up by a little and doesn’t seem to create any significant difference to the signals.
As expected, this increases the runtime by a significant amount comparing to the example shown in GEM. Here is the part of my code that is responsible for creating the avalanche and drifting ions:
double xc = 0., yc = 0., zc = 0., tc = 0., ec = 0., extra = 0.;
int nc = 0;
while (track.GetCluster(xc, yc, zc, tc, nc, ec, extra)) {`
for (int k = 0; k < nc; ++k) {
double xe = 0., ye = 0., ze = 0., te = 0., ee = 0.;
double dx = 0., dy = 0., dz = 0.;
track.GetElectron(k, xe, ye, ze, te, ee, dx, dy, dz);
aval.AvalancheElectron(xe, ye, ze, te, ee, dx, dy, dz);
const int np = aval.GetNumberOfElectronEndpoints();
double xe1, ye1, ze1, te1, e1;
double xe2, ye2, ze2, te2, e2;
double xi1, yi1, zi1, ti1;
double xi2, yi2, zi2, ti2;
int status;
for (int j = np; j--;) {
aval.GetElectronEndpoint(j, xe1, ye1, ze1, te1, e1,
xe2, ye2, ze2, te2, e2, status);
drift.DriftIon(xe1, ye1, ze1, te1);
}
}
}
Is there any way to make this part of the program run faster?