# The questions about the induced current

**URL:** <https://root-forum.cern.ch/t/the-questions-about-the-induced-current/48314>\
**Category:** Garfield++\
**Created:** [January 9, 2022, 1:20pm UTC](https://root-forum.cern.ch/t/the-questions-about-the-induced-current/48314 "2022-01-09T13:20:10Z")\
**Posts on this page:** 1\
**Showing post:** 26

<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 17, 2022, 2:49am UTC](https://root-forum.cern.ch/t/the-questions-about-the-induced-current/48314/26 "2022-01-17T02:49:33Z")

</div>

Hi,  
Thanks a lot for your reply  
Yep, I know that the DriftHole should be deleted, because it is used for the silicon. I have modified the code, but the results still notice killed, so I just simulate the drift line first and then to the induced current signal. The drift line result don’t show the killed but the empty plot like below

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/b/1/b1a80c016c7b7e8844f04ef4d3a172e98769f031.png)  
And that’s my code:

```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"
#include "Garfield/ViewField.hh"
#include "Garfield/TrackHeed.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", "mm");
  fm.PrintRange();
  fm.PrintMaterials();
 // fm.SetWeightingField("weight.lis", "readout");
  double x0, y0, z0, x1, y1, z1;
  fm.GetBoundingBox(x0, y0, z0, x1, y1, z1);

  ViewField fieldView;
  constexpr bool plotField = true;
  if (plotField) {
    fieldView.SetComponent(&fm);
    // Set the normal vector of the viewing plane.
    fieldView.SetPlane(0, 0, -1, 0, 0, 0.5 * (z0 + z1));
    fieldView.PlotContour();
    //fieldView.PlotFieldLines(xf, yf, zf, true, true, kOrange-3); 
  }

  // Define the medium.
  MediumMagboltz gas;
  gas.LoadGasFile("He-740Torr.gas");
  fm.SetMedium(0, &gas);

  Sensor sensor;
  sensor.AddComponent(&fm);
  sensor.AddElectrode(&fm, "readout");
  sensor.SetTimeWindow(0., 1000., 100);
  sensor.GetSignal("readout",1000);

  // Read the TRIM output file. 
  TrackTrim tr;
  const std::string filename = "EXYZ-He.txt";
  // Import the first 100 ions.
  if (!tr.ReadFile(filename, 500)) {
    std::cerr << "Reading TRIM EXYZ file failed.\n";
    return 1;
  }
  tr.SetWorkFunction(42);
  tr.SetFanoFactor(0.17);
  // 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);
  }
  driftView.SetArea(-1.67e-1, 0.172, -0.67e-1, 0.2);
  driftView.Plot(true);

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

  app.Run();
  return 0;
}

```

---

_[View the full topic](https://root-forum.cern.ch/t/the-questions-about-the-induced-current/48314)._
