I want to show the tracks of electrons and ions using AvalancheMC class. The key codes are:
AvalancheMC drift;
drift.SetSensor(&sensor);
drift.EnablePlotting(&driftView);
const unsigned int nTracks = 1;
for (unsigned int j = 0; j < nTracks; ++j) {
track.NewTrack(x0, y0, 0, 0, 0, 1, 0);
std::cout<<"the total numbers of clusters is: "<<track.GetClusters().size()<<std::endl;
for (const auto& cluster : track.GetClusters()) {
int num_electrons=cluster.n;
std::cout<<"the total electron numbers of evergy cluster is: "<<num_electrons<<std::endl;
for(int jj=0;jj<num_electrons;jj++)
{
drift.DriftElectron(cluster.x,cluster.y,cluster.z,cluster.t);
drift.DriftIon(cluster.x,cluster.y,cluster.z,cluster.t);
}
}
}
when running the application, the memory leak occured.
by the way, the simple codes are:
AvalancheMC drift;
drift.SetSensor(&sensor);
drift.EnablePlotting(&driftView);
drift.DriftElectron(0.3,0.3,0,0);
with little probability, the codes worked; in most cases, the memory leak occured.