# How to get drift time in garfield++

**URL:** <https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809>\
**Category:** Garfield++\
**Created:** [September 13, 2021, 8:31am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809 "2021-09-13T08:31:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![lyp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lyp](https://root-forum.cern.ch/u/lyp)\
**Post date:** [September 13, 2021, 8:31am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/1 "2021-09-13T08:31:39Z")

</div>

Excuse me sir, I am a freshman in garfield++ and I am researching the relevance between the dirft time of electron and the particle source distance in MDT.

I have read the example DriftTube ,it tells about relationship between time and singal. Now I want to know the dirft time(time of the fastest electron reach sensor) of each track, how could i modify the source code?

---

<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:** [September 13, 2021, 9:24am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/2 "2021-09-13T09:24:12Z")

</div>

Hi,  
after calculating a drift line using `DriftLineRKF::DriftElectron` you can retrieve the arrival time using the function `GetEndPoint`. To determine the arrival time of the first electron that reaches the wire, you could do something along these lines:

```auto
for (unsigned int j = 0; j < nTracks; ++j) {
  track.NewTrack(x0, y0, 0, 0, 0, 1, 0);
  double xc = 0., yc = 0., zc = 0., tc = 0., ec = 0., extra = 0.;
  int nc = 0;
  double tmin = std::numeric_limits<double>::max();
  while (track.GetCluster(xc, yc, zc, tc, nc, ec, extra)) {
    for (int k = 0; k < nc; ++k) {
      double xe = 0., ye = 0., ze = 0., te = 0., ee = 0.;
      double dx = 0., dy = 0., dz = 0.;
      track.GetElectron(k, xe, ye, ze, te, ee, dx, dy, dz);
      drift.DriftElectron(xe, ye, ze, te);
      double xf = 0., yf = 0., zf = 0., tf = 0.;
      int stat = 0;
      drift.GetEndPoint(xf, yf, zf, tf, stat);
      tmin = std::min(tmin, tf);
    }
  }
  std::cout << "First electron arrives at " << tmin << " ns.\n";
}
```

---

<div class="post-metadata">

**Author:** ![lyp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lyp](https://root-forum.cern.ch/u/lyp)\
**Post date:** [September 14, 2021, 5:52am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/4 "2021-09-14T05:52:25Z")

</div>

OK,I think I got it.  
Sir ,there is another question. The example give a figure about signal and time. Is there any way to get the data of a specified point(for example I want to know the time when signal come to 10% of the climax)  
Appreciate for your anwser sir!

---

<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:** [September 14, 2021, 6:15am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/5 "2021-09-14T06:15:54Z")

</div>

You’re right, you can use `GetDriftTime` and `GetEndPoint` to get the arrival time, they return the same number.

You can retrieve the signal in a given time bin using the function  
`double GetSignal(const std::string& label, const unsigned int bin);`  
of the `Sensor` class, where `label` is the identifier of the electrode (in the drift tube example: “s”), and bin is the bin number (the number of bins and the spacing is set earlier when you call `SetTimeWindow`).

---

<div class="post-metadata">

**Author:** ![lyp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lyp](https://root-forum.cern.ch/u/lyp)\
**Post date:** [September 15, 2021, 7:26am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/6 "2021-09-15T07:26:25Z")

</div>

Sir, what is the unit of signal? I saw the figure write signal[fc], what is fc??

---

<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:** [September 15, 2021, 7:42am UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/7 "2021-09-15T07:42:15Z")

</div>

femto Coulomb

---

<div class="post-metadata">

**Author:** ![lyp](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecc23a/32.png) [@lyp](https://root-forum.cern.ch/u/lyp)\
**Post date:** [September 24, 2021, 12:30pm UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/9 "2021-09-24T12:30:27Z")

</div>

Thank you again!

---

<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:** [October 8, 2021, 12:31pm UTC](https://root-forum.cern.ch/t/how-to-get-drift-time-in-garfield/46809/10 "2021-10-08T12:31:22Z")

</div>

Closed on October 8, 2021, 12:31pm UTC

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