# A bug that will cause ComponentTcad delayed signal to be NaN

**URL:** <https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367>\
**Category:** Garfield++\
**Created:** [October 29, 2025, 1:24pm UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367 "2025-10-29T13:24:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Leong](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/john_leong/32/35495_2.png) [@John\_Leong](https://root-forum.cern.ch/u/John_Leong)\
**Post date:** [October 29, 2025, 1:24pm UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367/1 "2025-10-29T13:24:56Z")

</div>

Problem locates at function “Garfield::Sensor::AddSignalWeightingField()” in file “Source/Garfield/Sensor.cc”. The for loop start from Line 738 calculates all delayed signal in each electrode. At Line 735, dt may be 0, because the last two elements in vector xs and vector ts may be exactly the same in some case. This will cause calcuated scale is NaN, thus the signal is NaN.

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

Why there’re two **identical** element in the vector? I checked where these 2 vectors come from, it turns out that the function is called in Line 571, function “Garfield::AvalancheMC::DriftLine” , file “Source/Garfield/AvalancheMC.cc”. The “path” parameter stores paritlce 4D information.

![image](https://root-forum.cern.ch/uploads/default/original/3X/9/e/9e05c7aba174fffaffceb49ed645d8a4243aa991.png)

After checking carefully, I think the “Garfield::AvalancheMC::Terminate” function will cause an unexpected dupulication of a boundary point. The following picture shows Line 494 to Line 504 in function “Garfield::AvalancheMC::DriftLine”. **If x0 lies at sensor boundary, or very close to, then Terminate function will assign x1=x0 and emplace\_back.**

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/6/b/6b97f266359732354759f1a6e6d3d8b2f0c61a29.png)

Here is the reason. If x0 is close enough to the boundary, then x1 will always be outside, thus status == -5 or xm will not in area, then x1 will not be assigned the value of xm. Therefore, x1 will remain the value of x0 and t1 remain the value of t0, emplace\_back a exactly same point to the path.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/c/0/c02655255b310779b97f0d9e8622eb75f5626e52.png)

---

<div class="post-metadata">

**Author:** ![devajith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/devajith/32/37165_2.png) [@devajith](https://root-forum.cern.ch/u/devajith)\
**Post date:** [October 29, 2025, 1:37pm UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367/2 "2025-10-29T13:37:07Z")

</div>

Hi @John_Leong,  
Adding @hschindl, who might be able to help you.

Cheers,  
Dev

---

<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:** [October 29, 2025, 2:33pm UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367/3 "2025-10-29T14:33:10Z")

</div>

Hi,  
thanks a lot for reporting and debugging this issue! @djjansse is looking into it…

---

<div class="post-metadata">

**Author:** ![djjansse](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/d/8baadc/32.png) [@djjansse](https://root-forum.cern.ch/u/djjansse)\
**Post date:** [November 8, 2025, 9:36am UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367/4 "2025-11-08T09:36:33Z")

</div>

Dear @John_Leong,

Thank you for sharing this observation. We pushed a fix to the main branch [[!557](https://gitlab.cern.ch/garfield/garfieldpp/-/merge_requests/557)] which should addresses this issue.

Kind regards,

Djunes

---

<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:** [November 22, 2025, 9:36am UTC](https://root-forum.cern.ch/t/a-bug-that-will-cause-componenttcad-delayed-signal-to-be-nan/64367/5 "2025-11-22T09:36:50Z")

</div>

Closed on November 22, 2025, 9:36am UTC

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