# Simulate alpha particle incidence to induce and output electrical signals, but with "No valid medium at initial position."

**URL:** <https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085>\
**Category:** Garfield++\
**Tags:** root\
**Created:** [April 22, 2024, 11:24am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085 "2024-04-22T11:24:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [April 22, 2024, 11:24am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/1 "2024-04-22T11:24:34Z")

</div>

![1](https://root-forum.cern.ch/uploads/default/original/3X/f/1/f1fb37982e22915c92dc5a826d3e0949721149fa.png)

Hi! I am trying to simulate the current signal caused by the alpha particle incident on a gas medium sensor, and I have generated gas files for 85% Ar and 15% CO2 through the generate.c.  
The TrackSrim file I imported is Alpha\_in-Ar.txt, and I encountered the issue shown in the above picture.

---

<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 22, 2024, 11:47am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/2 "2024-04-22T11:47:00Z")

</div>

Hi,  
I can think of two explanations off-hand:

- Did you perhaps forget to associate the gas medium to the ComponentAnalyticField object?
- Or is the starting point of your track outside the active area?

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [April 22, 2024, 11:51am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/3 "2024-04-22T11:51:11Z")

</div>

Thank you for your answer. I will check if it is caused by one of these two reasons.

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [April 22, 2024, 12:18pm UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/5 "2024-04-22T12:18:24Z")

</div>

Thanks for your reply! I have changed the starting point to:

 ![9346d7525a28e88f613baf6af8380a8](https://root-forum.cern.ch/uploads/default/original/3X/e/a/ea7740411379da0df8443f2c4955b8cc6b1ab3cd.jpeg)  
The output is:  
 ![1713788025585](https://root-forum.cern.ch/uploads/default/original/3X/a/b/ab13bdf25cef1c68eff2797019659b7b2afb0a06.jpeg)  
But I still can`t see any current signal output. ![1713788082361|477x499](upload://g51eSkqLL4mgkHorYTcQ6pZvtqj.png) New users can`t post links so I put the screenshot of my code here.  
 ![1713788223146](https://root-forum.cern.ch/uploads/default/original/3X/3/6/36020b38743d0b382bf3f86dd66cc8621cf3c44c.jpeg)  
 ![1713788242176](https://root-forum.cern.ch/uploads/default/original/3X/8/9/89a9634c6c0d2a55b3295e89548490092b4d8fc2.jpeg)  
 ![1713788261044](https://root-forum.cern.ch/uploads/default/original/3X/6/2/62d92c404a811a61680c8eb65149b44acf2d24e7.jpeg)

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [April 22, 2024, 1:49pm UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/6 "2024-04-22T13:49:56Z")

</div>

I finally change the drift part into:

 ![1713793729115](https://root-forum.cern.ch/uploads/default/original/3X/b/3/b3630e3c9909160cf4868899ef7ff4b603e41659.png)  
But I got this error here:  
 ![b6391ba833d9aa85eeb06d70badeed6](https://root-forum.cern.ch/uploads/default/original/3X/5/5/5562c7feff488b5cf24d359ba12da19c230006e0.jpeg)

---

<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 22, 2024, 2:25pm UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/7 "2024-04-22T14:25:22Z")

</div>

Hi,  
`GetElectron` is not really meaningful for `TrackTrim` (all electrons in a cluster are supposed to be at the same location, xc, yc, zc).  
You can change the inner for loop to

```auto
for (int k = 0; k < nc; ++k) {
  drift.DriftElectron(xc, yc, zc, tc);
}

```

By the way, the format of the `GetCluster` function that you are using is still supported, but I would like to phase it out. Instead of the while loop you can do:

```auto
for (const auto& cluster : track.GetClusters()) {
  for (int k = 0; k < cluster.n; ++k) {
    drift.DriftElectron(cluster.x, cluster.y, cluster.z, cluster.t);
  }
}

```

Finally, with `DriftLineRKF` you will always get the same drift line for a given starting point (there are no fluctuations in the drift path).  
So, an even more efficient way would be something like this:

```auto
for (const auto& cluster : track.GetClusters()) {
  drift.SetElectronSignalScalingFactor(cluster.n);
  drift.DriftElectron(cluster.x, cluster.y, cluster.z, cluster.t);
}

```

See also this example:

> **[Examples/Srim/trimsignal.C · master · garfield / garfieldpp · GitLab](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/Srim/trimsignal.C?ref_type=heads)**
>
> http://garfieldpp.web.cern.ch/garfieldpp/

---

<div class="post-metadata">

**Author:** ![Migu](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@Migu](https://root-forum.cern.ch/u/Migu)\
**Post date:** [April 24, 2024, 12:39am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/8 "2024-04-24T00:39:09Z")

</div>

Thanks a lot.

---

<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 8, 2024, 12:39am UTC](https://root-forum.cern.ch/t/simulate-alpha-particle-incidence-to-induce-and-output-electrical-signals-but-with-no-valid-medium-at-initial-position/59085/9 "2024-05-08T00:39:59Z")

</div>

Closed on May 8, 2024, 12:39am UTC

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