# How to get cross section and energy distribution of electrons in Garfield++

**URL:** <https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567>\
**Category:** Garfield++\
**Created:** [April 20, 2023, 4:19am UTC](https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567 "2023-04-20T04:19:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiangjc-github](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jiangjc-github/32/27278_2.png) [@jiangjc-github](https://root-forum.cern.ch/u/jiangjc-github)\
**Post date:** [April 20, 2023, 4:19am UTC](https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567/1 "2023-04-20T04:19:39Z")

</div>

@hschindl  
Hi, hschindl, Are there some ways to get distribution of cross section versus electrons energy for given gas, and probability of energy distribution of electrons for given electric field in the Garfield++?  
Thanks very much.

BR,  
Jiechen

---

<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:** [April 20, 2023, 9:31am UTC](https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567/2 "2023-04-20T09:31:27Z")

</div>

Hi,  
if you call `EnableCrossSectionOutput` before loading the cross-sections from Magboltz, `MediumMagboltz` saves a table of the cross-sections as function of energy to a text file.  
In PyROOT you can do something like this:

```auto
gas = ROOT.Garfield.MediumMagboltz("ar")
gas.SetMaxElectronEnergy(200.)
gas.EnableCrossSectionOutput()
gas.Initialise()

```

For a quick plot you can also use [this tool](https://garfieldpp.web.cern.ch/garfieldpp/examples/magboltzcs/) on the Garfield++ website:

To fill a histogram of the electron energy distribution in an avalanche you can use the function `AvalancheMicroscopic::EnableElectronEnergyHistogramming`, see [this example](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/GasFile/microscopic.py) or [this example](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/GainFluctuations/arco2.C).

---

<div class="post-metadata">

**Author:** ![jiangjc-github](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jiangjc-github/32/27278_2.png) [@jiangjc-github](https://root-forum.cern.ch/u/jiangjc-github)\
**Post date:** [April 20, 2023, 10:39am UTC](https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567/3 "2023-04-20T10:39:12Z")

</div>

> [@hschindl](#):
>
> o fill a histogram of the electron energy distribution in an avalanc

That’s so great and convenient, many thank hschindl.

BR,  
Jiechen

---

<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:** [May 4, 2023, 10:39am UTC](https://root-forum.cern.ch/t/how-to-get-cross-section-and-energy-distribution-of-electrons-in-garfield/54567/4 "2023-05-04T10:39:26Z")

</div>

Closed on May 4, 2023, 10:39am UTC

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