Problems in ViewDrift and ViewSignal

Hi everyone,
I am beginner of Garfieldpp.I tried to imitate Silicon in the example to output a gif of the drift lines and signals. I used the ComponentTcad2d and TrackHeed classes in the simulation, but the output remains the same instead of being updated.
I attach the Plot code and the result.

double t = 0.;
double dt = 0.1;
const unsigned int nFrames = 100;
for (unsigned int i = 0; i < 100; ++i) {
  vDrift.Clear();
  drift.SetTimeWindow(t, t + dt);
  vDrift.Plot2d(true, true);
  vSignal.PlotSignal("anode");
  gSystem->ProcessEvents();
  constexpr bool gif = true;
  if (!gif) {
      char filename[50];
      sprintf(filename, "frames/frame_%03d.png", i);
      canvas.SaveAs(filename);
  } else {
  if (i == nFrames - 1) {
      canvas.Print("movie.gif++");
  } else {
      canvas.Print("movie.gif+3");
  }`Preformatted text`
  }
std::cout << "Drift time window: [" << t << ", " << t + dt << "] ns\n";
t += dt;
}
    std::cout << "End of GIF" << "\n";

Hello! @hschindl will surely be able to help here.

Hi,
you’re missing a line like

drift.ResumeAvalanche();

after

drift.SetTimeWindow(t, t + dt);

Thanks for your reply!
I added this code as you suggested, but it doesn’t seem to work and the output is still the same as before.

Hi,
sorry for the late reply. The drift of the electrons and holes already happens in this loop:

track.NewTrack(x0, y0, z0, t0, 0., -1, 0.);
for (const auto& cluster : track.GetClusters()) {
  drift.SetElectronSignalScalingFactor(cluster.n);
  drift.DriftElectron(cluster.x, cluster.y, cluster.z, cluster.t);
  drift.SetHoleSignalScalingFactor(cluster.n);
  drift.DriftHole(cluster.x, cluster.y, cluster.z, cluster.t);
}

So the drift line calculation and signal are already once this loop is finished.
If you want to create an animation, you need to call AddElectron, AddHole instead of DriftElectron, DriftHole and then use SetTimeWindow, ResumeAvalanche in a subsequent loop to simulate the drift, as done in this example:

There is however a catch; if you do that, you cannot do the scaling of the signal (SetElectronSignalScalingFactor, SetHoleSignalScalingFactor) the way it’s done in your program. I’ll need to implement an additional functionality to set a weighting factor for each electron/hole.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.