# Why do I use garfield++ to simulate the drift of electrons generated by avalanches very slow?

**URL:** <https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100>\
**Category:** Garfield++\
**Created:** [May 24, 2022, 1:46pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100 "2022-05-24T13:46:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yinxiaohao](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/e79b87/32.png) [@yinxiaohao](https://root-forum.cern.ch/u/yinxiaohao)\
**Post date:** [May 24, 2022, 1:46pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/1 "2022-05-24T13:46:44Z")

</div>

hello,  
I am trying to use garfield++ to simulate the drift track of electron ions generated by an electron avalanche amplification, and then draw the induced signal according to the drift track, so as to judge the contribution of electrons and ions to the signal of the amplifier. But I found that when I use the member function DriftElectron() in the AvalancheMC class to draw the drift track of electrons, the calculation speed is very, very slow, but the avalanche magnification at this time is very small; if I only draw the drift track speed of ions, it is still very slow. Fast. I’m wondering if this is the reason for my code or if the program is just that fast; is there a way I can make it run faster?Below is my program:  
[GridIonization-srim4.zip](https://root-forum.cern.ch/uploads/short-url/aOPhF4ol0g4eMmqa5k5mRFYWBAh.zip) (265.0 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 24, 2022, 1:54pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/2 "2022-05-24T13:54:27Z")

</div>

I think @hschindl can help.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [May 24, 2022, 2:10pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/3 "2022-05-24T14:10:15Z")

</div>

Hi,  
it would be helpful if you could provide a **minimal** working example to illustrate what you mean. The program you attached does not use `AvalancheMC::DriftElectron` but `AvalancheMicroscopic::AvalancheElectron`, and something like half of the lines in the program are commented out.

---

<div class="post-metadata">

**Author:** ![yinxiaohao](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/e79b87/32.png) [@yinxiaohao](https://root-forum.cern.ch/u/yinxiaohao)\
**Post date:** [May 25, 2022, 2:27am UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/4 "2022-05-25T02:27:24Z")

</div>

I’m sorry the previous code was too cluttered. This is my modified code. What I mean is that I want to simulate an electron amplifying in the avalanche region to generate electrons and ions, and then use the member functions DriftElectron() and DriftIon() in the AvalancheMC class to draw the drift tracks of the electrons and ions respectively, so as to get them in the amplification The induced signal generated on the pole; I mainly want to know how much the ions contribute to the total induced signal; but I found that the calculation is very, very slow when I use DriftElectron() to draw the electron drift track; but according to the voltage avalanche I set The magnification is small.So I want to know what is causing this, is it a problem with my code?  
[Grid.zip](https://root-forum.cern.ch/uploads/short-url/cvQgir9S8bSWhegHiXhJcZpJofV.zip) (255.1 KB)

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [May 26, 2022, 8:07pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/6 "2022-05-26T20:07:46Z")

</div>

I ran a simplified and slightly modified version of your program (which you can find attached) and it doesn’t seem particularly slow to me.  
Note that there is no point to call `AvalancheMC::DriftElectron` in the loop over the electron trajectories simulated using `AvalancheMicroscopic`.  
Can you try to narrow down which part of the program is slow for you?  
[signal.C](https://root-forum.cern.ch/uploads/short-url/aFsHX0kwuai0nYc2KhkmFIsiLg3.C) (5.0 KB)

---

<div class="post-metadata">

**Author:** ![yinxiaohao](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/e79b87/32.png) [@yinxiaohao](https://root-forum.cern.ch/u/yinxiaohao)\
**Post date:** [May 28, 2022, 12:24pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/7 "2022-05-28T12:24:50Z")

</div>

I have one more question, are the induced signals from electron and ion drift related to my chosen method of charge transport? Is there a big gap between the induced signals simulated by the three methods, DriftLineRKF(), AvalancheMicroscopic(), and AvalancheMC()?Do I have to plot the tracks of the amplified electrons and ions before I can get a sensed signal on an electrode?

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [May 30, 2022, 4:59am UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/8 "2022-05-30T04:59:25Z")

</div>

The average signals computed using `DriftLineRKF`, `AvalancheMicroscopic` and `AvalancheMC` should be compatible. With `AvalancheMicroscopic` and `AvalancheMC` the signal induced by an electron starting from a given point in space will fluctuate from call to call, while with `DriftLineRKF` it will always be the same.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [May 30, 2022, 5:01am UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/9 "2022-05-30T05:01:00Z")

</div>

> [@yinxiaohao](#):
>
> Do I have to plot the tracks of the amplified electrons and ions before I can get a sensed signal on an electrode?

No, not at all. You can safely switch off plotting of the drift lines, it has no effect on the induced signal.

---

<div class="post-metadata">

**Author:** ![yinxiaohao](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/e79b87/32.png) [@yinxiaohao](https://root-forum.cern.ch/u/yinxiaohao)\
**Post date:** [May 30, 2022, 1:57pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/10 "2022-05-30T13:57:51Z")

</div>

ok i got it, thank you very much for your answer

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [June 13, 2022, 1:57pm UTC](https://root-forum.cern.ch/t/why-do-i-use-garfield-to-simulate-the-drift-of-electrons-generated-by-avalanches-very-slow/50100/11 "2022-06-13T13:57:57Z")

</div>

Closed on June 13, 2022, 1:57pm UTC

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