# How to get the induced current signal

**URL:** <https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288>\
**Category:** Garfield++\
**Created:** [January 7, 2022, 8:03am UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288 "2022-01-07T08:03:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![XiCheng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@XiCheng](https://root-forum.cern.ch/u/XiCheng)\
**Post date:** [January 7, 2022, 8:03am UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/1 "2022-01-07T08:03:05Z")

</div>

I want to get the weight.lis to set weight field by componentansys123 class, and finally get the current signal, but the example notice that we should set the potential volume1 to 1V, and potential of other volumes to 0V, the potentials on top of the gas and substrate are set to 0V as well.  
Now the problem is my model only has gas area and the metal part has been deleted for simplify.  
So what should I do to get the weight.lis files

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/7/8/780d7cd6f99ea3f420e5006ccdced7b6e3a45a91.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:** [January 7, 2022, 9:49am UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/2 "2022-01-07T09:49:58Z")

</div>

It’s not necessarily a problem if there are no metal volumes in your field map. I assume you have applied fixed-voltage boundary conditions to some of the surfaces in your geometry when solving for the “drift” electric field/potential. Instead of using the “real” potentials, apply 1 V to the area that corresponds to the readout electrode and 0V to the others to get the weighting field/potential.

---

<div class="post-metadata">

**Author:** ![XiCheng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@XiCheng](https://root-forum.cern.ch/u/XiCheng)\
**Post date:** [January 7, 2022, 12:58pm UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/3 "2022-01-07T12:58:03Z")

</div>

Hi,  
Thanks a lot for your help  
your advice is really helpful and I will try to get the correct results.

---

<div class="post-metadata">

**Author:** ![XiCheng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/x/aca169/32.png) [@XiCheng](https://root-forum.cern.ch/u/XiCheng)\
**Post date:** [January 8, 2022, 3:13am UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/4 "2022-01-08T03:13:18Z")

</div>

Hi,  
I have got my induced current, however it is a little bit weird. The result is like this below

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/0/7/07ffbe22f2734c35bf7ea0fd2b850ad14cce652b.png)  
And my code is this:

```auto

#include <iostream>

#include <TApplication.h>
#include <TH1F.h>
#include <TCanvas.h>

#include "Garfield/MediumSilicon.hh"
#include "Garfield/ComponentConstant.hh"
#include "Garfield/Sensor.hh"
#include "Garfield/TrackTrim.hh"
#include "Garfield/DriftLineRKF.hh"
#include "Garfield/ViewDrift.hh"
#include "Garfield/ViewSignal.hh"
#include "Garfield/ComponentAnsys123.hh"
#include "Garfield/MediumMagboltz.hh"

using namespace Garfield;

int main(int argc, char *argv[]) {

  // Application
  TApplication app("app", &argc, argv);
 
  ComponentAnsys123 fm;
  fm.Initialise("ELIST.lis", "NLIST.lis", "MPLIST.lis", "PRNSOL.lis", "cm");
  fm.SetWeightingField("weight1.lis", "readout");
  double x0, y0, z0, x1, y1, z1;
  fm.GetBoundingBox(x0, y0, z0, x1, y1, z1);

  // Define the medium.
  MediumMagboltz gas;
  gas.LoadGasFile("Ar_90_CH4_10.gas");
  fm.SetMedium(0, &gas);

  Sensor sensor;
  sensor.AddComponent(&fm);
  sensor.AddElectrode(&fm, "readout");
  // Set the time bins for the induced current.
  const unsigned int nTimeBins = 1000;
  const double tmin = 0.;
  const double tmax = 10.;
  const double tstep = (tmax - tmin) / nTimeBins;
  sensor.SetTimeWindow(tmin, tstep, nTimeBins);
 
  // Read the TRIM output file. 
  TrackTrim tr;
  const std::string filename = "EXYZ-P10.txt";
  // Import the first 100 ions.
  if (!tr.ReadFile(filename, 100)) {
    std::cerr << "Reading TRIM EXYZ file failed.\n";
    return 1;
  }
  tr.SetWorkFunction(26);
  tr.SetFanoFactor(0.179);
  // Connect the track to a sensor.
  tr.SetSensor(&sensor);

  DriftLineRKF drift;
  drift.SetSensor(&sensor);
  drift.SetMaximumStepSize(10.e-4);

  // Plot the track and the drift lines.
  ViewDrift driftView;
  tr.EnablePlotting(&driftView);
  drift.EnablePlotting(&driftView);
  
  // Simulate an ion track.
  tr.NewTrack(-0.1, 0.204, -0.07, 0., 0., -1., 0.);
  // Loop over the clusters.
  double xc, yc, zc, tc, ec, ekin;
  int ne = 0;
  while (tr.GetCluster(xc, yc, zc, tc, ne, ec, ekin)) {
    // Simulate electron and ion drift lines starting 
    // from the cluster position. 
    // Scale the induced current by the number of electron/ion pairs 
    // in the cluster.
    drift.SetElectronSignalScalingFactor(ne);
    drift.DriftElectron(xc, yc, zc, tc);
    drift.SetHoleSignalScalingFactor(ne);
    drift.DriftHole(xc, yc, zc, tc);
  }
  driftView.SetArea(-2.e-4, 0., 2.e-4, 100.e-4);
  driftView.Plot(true);

  ViewSignal signalView;
  signalView.SetSensor(&sensor);
  signalView.PlotSignal("readout", true, true, true);

  app.Run();
  return 0;
}

```

would you please help me to see about this?

---

<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:** [January 9, 2022, 1:34pm UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/5 "2022-01-09T13:34:02Z")

</div>

See

> [@The questions about the induced current](https://root-forum.cern.ch/t/the-questions-about-the-induced-current/48314/2):
>
> As you can see from the output of the program, the import of the weighting field map failed: ComponentAnsys123::SetWeightingField: Could not open file weight1.lis for reading. The file perhaps does not exist. Make sure you copy the file to the directory from which you are running the executable.

---

<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:** [January 23, 2022, 1:34pm UTC](https://root-forum.cern.ch/t/how-to-get-the-induced-current-signal/48288/6 "2022-01-23T13:34:53Z")

</div>

Closed on January 23, 2022, 1:34pm UTC

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