How calculate effectieve gain as function of voltage

Hello! I’m new user to Garfield++. Please tell me, I want to calculate the effective gain for gem, I have a couple of questions and clarifications.

  1. To calculate the efffective gain, as i know Effective Gain= Number of Electrons Collected at the Anode/ Number of Electrons Dropped Down through the Cathode​ . I run the code that was given on the website (Examples/Elmer/lem/avalanche.cc · garfield / garfieldpp · GitLab ).
  2. Do I understand correctly, in order to change the voltage on the gem top and bottom, also on the cathode and anode, I have to re-download the files from Elmer and change the voltage there, or am I wrong?
  3. this is my code to calculate effective gain with voltage
    gain.txt (6.8 KB)
    this is the plot of effective gain as function of voltage
    Screenshot from 2024-11-30 21-33-00
    which is not well.
    Is it’s correct way to calculate effective gain? please help me :pray:

Hi,

  1. Yes, the effective gain corresponds to the number of electrons collected in the induction gap divided by the initial number of electrons released in the drift gap.
  2. Correct, if you want to simulate different voltage configurations, you’ll need to re-run Elmer.
  3. Your code calculates the “total gain”. To calculate the effective gain, you’ll need to loop over the electrons and count how many end up in the induction gap.

Dear @hschindl Sir, can you suggest some examples to calculate effective gain? i didn’t understood to loop over the electrons and count how many end up in the induction gap.

I think you can do something like this to count the number of avalanche electrons that made it into the induction gap (you might want to check if the line if p1.z < -axis_z + 10.e-4 makes sense for your geometry):

aval.AvalancheElectron(xi, yi, zi, 0., 1000, 0., 0., 0)
nInd = 0
for electron in aval.GetElectrons():
  # Get the end point of the electron trajectory.
  p1 = electron.path.back()
  # Check if the electron ended up close to the lower end of the active area.
  if p1.z < -axis_z + 10.e-4:
    nInd += 1

Dear @Dk_ntm

To correctly extract the gain from simulations you need to run at least 500 events (now you are running only 15) and make a histogram of the gain of the individual events. You can than check whether your histogram has a smooth distribution and eventually fit a function to extract the average value. This would remove your fluctuations in your plot. This procedure is valid both for total gain and for effective gain.
Kind regards
PIet