# Signal question

**URL:** <https://root-forum.cern.ch/t/signal-question/63443>\
**Category:** Garfield++\
**Created:** [April 24, 2025, 3:18am UTC](https://root-forum.cern.ch/t/signal-question/63443 "2025-04-24T03:18:00Z")\
**Posts on this page:** 17\
**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 24, 2025, 3:18am UTC](https://root-forum.cern.ch/t/signal-question/63443/1 "2025-04-24T03:18:00Z")

</div>

I simulated the current signal of a proportional counter tube at a working voltage of 1100V, and the results are as follows:

 ![4.23](https://root-forum.cern.ch/uploads/default/original/3X/d/b/db269d85f35d5216fc251951136c68322efbdb66.png)  
The signal has two peaks generated by ions and electrons, respectively. The peak value of ions is close to that of electrons. I’m not sure if this is correct?

---

<div class="post-metadata">

**Author:** ![lbreitwi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lbreitwi/32/21330_2.png) [@lbreitwi](https://root-forum.cern.ch/u/lbreitwi)\
**Post date:** [April 24, 2025, 7:26am UTC](https://root-forum.cern.ch/t/signal-question/63443/2 "2025-04-24T07:26:00Z")

</div>

@hschindl could you please take a look at this question?

---

<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 24, 2025, 8:17am UTC](https://root-forum.cern.ch/t/signal-question/63443/3 "2025-04-24T08:17:44Z")

</div>

Hi @Migu, the signal looks “unusual” to me, but I cannot say much more without knowing in a bit more detail what your configuration looks like and how you simulated the signal. Could you provide a **minimal** working example?

---

<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, 2025, 12:35pm UTC](https://root-forum.cern.ch/t/signal-question/63443/4 "2025-04-24T12:35:06Z")

</div>

Thanks for the reply! Here is the working example.  
[IonMobility\_Ar+\_Ar.txt](https://root-forum.cern.ch/uploads/short-url/YkWM8IfKm8adv1bZedorLsesd4.txt) (807 Bytes)  
[Li\_in\_Ar\_CO2\_gas.txt](https://root-forum.cern.ch/uploads/short-url/j52CEX9tfiB9vKlZur5Mq5Cbs72.txt) (5.5 KB)  
[signalv3.1.C](https://root-forum.cern.ch/uploads/short-url/oJ4xr5ng6Dj7Qt4mmYhvuUvjRfD.C) (21.9 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:** [April 25, 2025, 5:02am UTC](https://root-forum.cern.ch/t/signal-question/63443/5 "2025-04-25T05:02:51Z")

</div>

Thanks! What I had in mind though was a _ **minimal** _ working example: [How to create a Minimal, Reproducible Example - Help Center - Stack Overflow](https://stackoverflow.com/help/minimal-reproducible-example)  
Can you try to trim your program such that contains only what is essential to reproduce the issue at hand?

---

<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 25, 2025, 10:38am UTC](https://root-forum.cern.ch/t/signal-question/63443/6 "2025-04-25T10:38:28Z")

</div>

Oh sorry！  
I used` TrackSrim` with SRIM-generated files to simulate the initial ionization process of incident particles.

```auto
TrackSrim tr;
  tr.SetSensor(&sensor); 
  const std::string file = "Li_in_Ar_CO2_gas.txt";   
  tr.SetKineticEnergy(0.84e6);    
  tr.SetWorkFunction(27.7);       
  tr.SetFanoFactor(0.172);      
  const double za = ratioofAr * (18. / 39.948) +ratioofCO2 * (22. / 44.0095); // Set A and Z of the gas (not sure what's the correct mixing law).
  tr.SetAtomicMassNumbers(22. / za, 22);
  tr.EnableTransverseStraggling(false);
  tr.EnableLongitudinalStraggling(false);

```

I used `AvalancheMicroscopic` to drift the electrons and sequentially corrected the initial ionization positions in each cluster.

```auto
const bool notnewtrack= !tr.NewTrack(projectilex, projectiley, projectilez, projectileT, projectiledx, projectiledy, projectiledz);    
    if (notnewtrack) {
      std::cerr << "Generating clusters failed; skipping this particle's track.\n";
      continue;
    }
    unsigned int netot = 0;
    std::vector<std::array<double,7>> informationofclusters;
    while (true) {                          
      int ne = 0;
      double xc, yc, zc, tc, ec, ekin;
      const bool done = tr.GetCluster(xc, yc, zc, tc, ne, ec, ekin);  
      if(done) {                                                                 
      informationofclusters.push_back({xc, yc, zc, tc, ne, ec,ekin});          
      netot += ne;        
      }   
      if (!done) {
        break;                    
      }
    }
    double MLi=6.9405*1.66053886e-27;     
    double Mev=1.602176565e-13;              
    for(int i=0;i<informationofclusters.size()-1;++i){
      double speedofprojectile=sqrt(2*informationofclusters[i+1][6]*Mev/MLi)/1.e7;    
      double distanceofclusters=sqrt(pow(informationofclusters[i+1][0]-informationofclusters[i][0],2) \
                                    +pow(informationofclusters[i+1][1]-informationofclusters[i][1],2) \
                                    +pow(informationofclusters[i+1][2]-informationofclusters[i][2],2));  
      double duation=distanceofclusters/speedofprojectile;                  
      informationofclusters[i+1][3]=informationofclusters[i][3]+duation;     
    }

```

Then, I conducted an avalanche of electrons in each cluster and also calculated the ions.

```auto
for(int j=0; j<informationofclusters.size( ); ++j){  
        double avalancheelectrons=0;
        double avalancheions=0;   
        AvalancheMicroscopic driftelectron;
        driftelectron.SetSensor(&sensor);
        driftelectron.EnableSignalCalculation();      
        driftelectron.EnablePlotting(&driftView);  
        
        AvalancheMC driftion;           
        driftion.SetSensor(&sensor);    
        driftion.SetDistanceSteps(2.e-4);   
        driftion.EnableSignalCalculation();    

        AvalancheMC driftprimaryion;           
        driftprimaryion.SetSensor(&sensor);     
        driftprimaryion.SetDistanceSteps(2.e-4);        
        driftprimaryion.EnableSignalCalculation();    

        for (int k = 0; k <informationofclusters[j][4]; ++k) {           
          driftelectron.AvalancheElectron(informationofclusters[j][0], informationofclusters[j][1], \
                                          informationofclusters[j][2], informationofclusters[j][3], 0.00001, 0., 0., 0.); 
        }
        int np=0;
        np=driftelectron.GetNumberOfElectronEndpoints();  
        for(int m=0; m<np; ++m){                         
          double xestart, yestart, zestart, testart, eestart;
          double xeend, yeend, zeend, teend, eeend;
          int status;
          driftelectron.GetElectronEndpoint(m, xestart, yestart, zestart, testart, eestart, xeend, yeend, zeend, teend, eeend, status);
          driftion.SetIonSignalScalingFactor(informationofclusters[j][4]);
          driftion.DriftIon(xestart, yestart, zestart, testart);
        } 
        driftprimaryion.SetIonSignalScalingFactor(informationofclusters[j][4]);
        driftprimaryion.DriftIon(informationofclusters[j][0], informationofclusters[j][1], \
                                 informationofclusters[j][2], informationofclusters[j][3]);       

      }

```

---

<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 26, 2025, 1:52pm UTC](https://root-forum.cern.ch/t/signal-question/63443/7 "2025-04-26T13:52:05Z")

</div>

Hi,  
thanks for the explanations; I don’t know if it’s sufficient to explain the signal shape, but it looks like you are simulating (some of) the ions twice. When looping over the electron drift lines and simulating an ion drift line from the starting point of each electron trajectory, you already include the “primary” ions, you don’t need to simulate them explicitly again.

I’ve attached a trimmed down and slightly modified version of your code. I didn’t manage to reproduce the signal shape you observed though…  
[mre.C](https://root-forum.cern.ch/uploads/short-url/jCcWFamMAmFSXwq7lM6PFeM7qL3.C) (3.2 KB)

---

<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 26, 2025, 2:13pm UTC](https://root-forum.cern.ch/t/signal-question/63443/8 "2025-04-26T14:13:02Z")

</div>

Thank you so much for the reply. I will adjust my code based on the example you provided and compare the signal results. But i am so sorry that maybe i will reply after two days.

---

<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 28, 2025, 6:02am UTC](https://root-forum.cern.ch/t/signal-question/63443/9 "2025-04-28T06:02:37Z")

</div>

Hi！I encountered the following problem while running `‘mre.c’`:

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/1/e/1ef5cf37e71fc53abaf1689b8ca5a107a3b6280f.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 28, 2025, 3:13pm UTC](https://root-forum.cern.ch/t/signal-question/63443/10 "2025-04-28T15:13:03Z")

</div>

Please update to the latest version of the master branch; or copy the ion mobility file to your local directory; or set the full path to the ion mobility file.

---

<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:** [May 7, 2025, 9:06am UTC](https://root-forum.cern.ch/t/signal-question/63443/11 "2025-05-07T09:06:51Z")

</div>

Hi !  
Running ‘mre.c’ requires more than eight hours. Is there any method of enhancing the program’s calculation speed?

---

<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 7, 2025, 6:56pm UTC](https://root-forum.cern.ch/t/signal-question/63443/12 "2025-05-07T18:56:31Z")

</div>

Hi,  
indeed, you have quite a lot of primary electrons on the track, and simulating avalanches on a microscopic level for each of them will be quite time consuming. Have you considered using `DriftLineRKF` instead?

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [May 7, 2025, 9:53pm UTC](https://root-forum.cern.ch/t/signal-question/63443/13 "2025-05-07T21:53:17Z")

</div>

Hello,

I’ve attached a faster version of the simulation. It uses AvalancheMC instead of AvalancheMicroscopic (I also left the DriftLineRKF version commented out) and OpenMP. You’ll probably have to tweak the step size to get the desired results. You’ll also have to generate a .gas file for the desired mixture, I didn’t have one so I used 80/20 instead of 85/15.

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

[CMakeLists.txt](https://root-forum.cern.ch/uploads/short-url/am1N4u4JeZf3LEp7qNI54AChHKS.txt) (336 Bytes)

[mre.C](https://root-forum.cern.ch/uploads/short-url/f4jbxshXXD6u3Rt3NDXWmo2A0wY.C) (3.3 KB)

Sincerely,  
Gabriel

---

<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:** [May 9, 2025, 4:15am UTC](https://root-forum.cern.ch/t/signal-question/63443/14 "2025-05-09T04:15:06Z")

</div>

Hi，  
Thank you very much for offering the revised version. I attempted to run your code and allocated 64 processors to my virtual machine. However, I’ve been stuck on the first cluster for 20 minutes and have yet to proceed to the second cluster for calculations.

 ![1746764002770](https://root-forum.cern.ch/uploads/default/original/3X/d/9/d9b796b3c3ddba11b59652422a9a03484291de27.png)  
Could you tell me how long your program has been running calculations for?

---

<div class="post-metadata">

**Author:** ![gabrielribcesario](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gabrielribcesario/32/38927_2.png) [@gabrielribcesario](https://root-forum.cern.ch/u/gabrielribcesario)\
**Post date:** [May 9, 2025, 12:22pm UTC](https://root-forum.cern.ch/t/signal-question/63443/15 "2025-05-09T12:22:00Z")

</div>

Hello,

That’s strange. I’ve attached the output of my last run of the unaltered version of the code, i.e. AvalancheMC with step size of 0.01[cm]. I just ran it on my side with a i9-10900k (36 logic processors). If the environment variable `OMP_NUM_THREADS` is set to 64 then the loop should be using the 64 logic processors available on your virtual machine, and if it is not set the loop defaults to the maximum number anyways. The easiest way to check this by running the command `echo $OMP_NUM_THREADS`. The second easiest way is checking if CPU usage peaks for each logic processor you’ve allocated.

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

It could also be that you got an unlucky sequence with the RNG that caused the drift line calculation time of one of the electrons to skyrocket, impeding the calculation of the next cluster of electrons.

Some other important info as well:

ROOT version: 6.32.12  
Garfield++ version (commit SHA): d34fbdf7  
Platform: Ubuntu-22.04 (WSL)

---

<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:** [May 9, 2025, 1:23pm UTC](https://root-forum.cern.ch/t/signal-question/63443/16 "2025-05-09T13:23:45Z")

</div>

Hello！  
Thank you for your reply! I will try to find out what happened.

---

<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 23, 2025, 1:24pm UTC](https://root-forum.cern.ch/t/signal-question/63443/17 "2025-05-23T13:24:45Z")

</div>

Closed on May 23, 2025, 1:24pm UTC

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