# How to get information of avalanche electron with AvalancheGridSpaceCharge class

**URL:** <https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051>\
**Category:** Garfield++\
**Created:** [February 28, 2025, 6:51am UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051 "2025-02-28T06:51:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![masato](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/masato/32/38079_2.png) [@masato](https://root-forum.cern.ch/u/masato)\
**Post date:** [February 28, 2025, 6:51am UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/1 "2025-02-28T06:51:42Z")

</div>

Dear experts,

Hello, I am a beginner of Garfield++ and want to get information about avalanche electrons in a parallel plate chamber with a space charge effect.  
I’m trying to use the `AvalancheMicroscopic` class to obtain the avalanche electrons’ information and the `AvalancheGridSpaceCharge` class to perform the gas avalanche process, but I don’t know how to make it work.  
Is it possible to process the above?

I attached my source code.  
This program was written with reference to `Example/Gem/gem.C` and `Example/RPCSpaceCharge/rpc_space_charge.cc`, which attempts to get energy of avalanche electrons and fill it in a histogram.

Any tips or solutions would be appreciated.

Thank you.

Best regards,  
Masato

[avalanche\_sc.cpp](https://root-forum.cern.ch/uploads/short-url/iYiTxkkOau47ooq4fKY1VwFciKe.cpp) (3.4 KB)

---

<div class="post-metadata">

**Author:** ![mczurylo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mczurylo/32/33269_2.png) [@mczurylo](https://root-forum.cern.ch/u/mczurylo)\
**Post date:** [February 28, 2025, 8:47am UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/2 "2025-02-28T08:47:48Z")

</div>

Hello @masato,

thank you for your question. Maybe @hschindl could help here?

Cheers,  
Marta

---

<div class="post-metadata">

**Author:** ![dastocco](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dastocco](https://root-forum.cern.ch/u/dastocco)\
**Post date:** [February 28, 2025, 10:20am UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/3 "2025-02-28T10:20:42Z")

</div>

Dear @masato

Thanks for your question. It is not entirely clear to me what you want to achieve. However, if you would like to know how the electron density evolves with time, you can export the grids, which hold information about the electrons, ions and field-strengths. To achieve this you can, following your code, evolve the electron using the AvalancheMicroscopic class for a few nanoseconds, import the electrons onto the grid and evolve it in time-steps with the AvalancheGridSpaceCharge while exporting the grids at each time-step.

```auto
 // Avalanche electron
aval.SetTimeWindow(0., 0.5.); // set the time window integration (in ns) for AvalancheMicroscopic
aval.AvalancheElectron(xi, yi, zi, ti, ei, 0., 0., 0.);
avalsc.ImportElectronsFromAvalancheMicroscopic(&aval); // import the electrons
double dt = 0.5; // time step in ns
for (int k = 0; k < 20.; k++) {
  avalsc.StartGridAvalanche(dt); // evolve the electrons on the grid with time step dt
  avalsc.ExportGrid("my_grid_at_time_" + std::to_string((k + 1) * dt)); // export the grids
}

```

Unfortunately, in the grid-based approaches you cannot extract the energy of the electrons.

If you have further question feel free to reach out again.

Best  
Dario Stocco

---

<div class="post-metadata">

**Author:** ![masato](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/masato/32/38079_2.png) [@masato](https://root-forum.cern.ch/u/masato)\
**Post date:** [February 28, 2025, 1:03pm UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/4 "2025-02-28T13:03:36Z")

</div>

Dear Dario,

thank you for your reply.

Specifically, what I wanted to do was get the energy of each electron at its endpoint after the avalanche process.  
I was not trying to get information in time-steps.

For example, in the framework of the `AvalancheMicroscopic` class, the following code should do it.

```auto
AvalancheMicroscopic aval;
aval.AvalancheElectron(xi, yi, zi, ti, ei, 0., 0., 0.);

for(const auto &electron : aval.GetElectron()) {
   const auto &p = electron.path[1];
   hist->Fill(p.energy);
}

```

or

```auto
for(unsigned int i = 0; i < aval.GetElectrons().size(); i++) {
   aval.GetElectronEndpoint(i, x0, y0, z0, t0, e0, x1, y1, z1, t1, e1 status);
   hist->Fill(e1);
}

```

I wanted to ask if there is a way to access each avalanche electron’s information in the `AvalancheGridSpaceCharge` framework, like `aval.GetElectron()` and `aval.GetElectronEndpoint()` in the example code above.

Sorry for the complications

Best regards,  
Masato

---

<div class="post-metadata">

**Author:** ![dastocco](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/a183cd/32.png) [@dastocco](https://root-forum.cern.ch/u/dastocco)\
**Post date:** [February 28, 2025, 1:21pm UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/5 "2025-02-28T13:21:06Z")

</div>

Dear @masato

Within the grid-based approaches (AvalancheGrid and AvalancheGridSpaceCharge) the algorithms do not track individual electrons but evolves them in bundles (sometimes called “Superparticles”). Therefore and unfortunately, it is not possible to retrieve information about the individual electrons.

Best  
Dario Stocco

---

<div class="post-metadata">

**Author:** ![masato](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/masato/32/38079_2.png) [@masato](https://root-forum.cern.ch/u/masato)\
**Post date:** [February 28, 2025, 1:50pm UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/6 "2025-02-28T13:50:55Z")

</div>

Dear Dario,

thank you very much for your reply.  
I understand the system of grid-based simulation.

Then, I will try to use `AvalancheMicroscopic` when I want to get the information.

Best regards,  
Masato

---

<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:** [March 14, 2025, 1:51pm UTC](https://root-forum.cern.ch/t/how-to-get-information-of-avalanche-electron-with-avalanchegridspacecharge-class/63051/7 "2025-03-14T13:51:27Z")

</div>

Closed on March 14, 2025, 1:51pm UTC

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