1#ifndef G_DRIFTLINE_RKF_H
2#define G_DRIFTLINE_RKF_H
48 void RejectKinks(
const bool on =
true) { m_rejectKinks = on; }
68 bool DriftElectron(
const double x0,
const double y0,
const double z0,
71 bool DriftHole(
const double x0,
const double y0,
const double z0,
74 bool DriftIon(
const double x0,
const double y0,
const double z0,
78 bool DriftPositron(
const double x0,
const double y0,
const double z0,
88 void GetEndPoint(
double& x,
double& y,
double& z,
double& t,
int& st)
const;
99 double GetGain(
const double eps = 1.e-4);
101 double GetLoss(
const double eps = 1.e-4);
111 bool FieldLine(
const double xi,
const double yi,
const double zi,
112 std::vector<std::array<float, 3> >& xl,
113 const bool electron =
true);
119 std::string m_className =
"DriftLineRKF";
122 Sensor* m_sensor =
nullptr;
124 enum class Particle { Electron = 0, Ion, Hole, Positron, NegativeIon };
126 Particle m_particle = Particle::Electron;
129 double m_maxStepSize = 0.;
131 double m_accuracy = 1.e-8;
133 bool m_rejectKinks =
true;
135 bool m_useStepSizeLimit =
false;
138 ViewDrift* m_view =
nullptr;
141 std::vector<std::array<double, 3> > m_x;
143 std::vector<double> m_t;
148 bool m_doSignal =
true;
150 unsigned int m_navg = 2;
153 double m_scaleE = 1.;
155 double m_scaleH = 1.;
157 double m_scaleI = 1.;
160 bool m_doAvalanche =
true;
161 enum class GainFluctuations { None = 0, Polya };
163 GainFluctuations m_gainFluctuations = GainFluctuations::None;
170 bool m_doIonTail =
false;
172 double m_nE = 0., m_nI = 0.;
174 bool m_debug =
false;
177 bool DriftLine(
const double x0,
const double y0,
const double z0,
178 const double t0,
const Particle particle,
179 std::vector<double>& ts,
180 std::vector<std::array<double, 3> >& xs,
int& status);
181 bool Avalanche(
const Particle particle,
182 const std::vector<std::array<double, 3> >& xs,
183 std::vector<double>& ne, std::vector<double>& ni,
185 bool AddIonTail(
const std::vector<double>& te,
186 const std::vector<std::array<double, 3> >& xe,
187 const std::vector<double>& ni,
const double scale);
189 int GetField(
const std::array<double, 3>& x,
190 double& ex,
double& ey,
double& ez,
191 double& bx,
double& by,
double& bz,
192 Medium*& medium)
const;
194 bool GetVelocity(
const std::array<double, 3>& x,
const Particle particle,
195 std::array<double, 3>& v,
int& status)
const;
196 bool GetVelocity(
const double ex,
const double ey,
const double ez,
197 const double bx,
const double by,
const double bz,
198 Medium* medium,
const Particle particle,
199 std::array<double, 3>& v)
const;
200 bool GetDiffusion(
const double ex,
const double ey,
const double ez,
201 const double bx,
const double by,
const double bz,
202 Medium* medium,
const Particle particle,
203 double& dl,
double& dt)
const;
204 bool GetAlpha(
const double ex,
const double ey,
const double ez,
205 const double bx,
const double by,
const double bz,
206 Medium* medium,
const Particle particle,
double& alpha)
const;
207 bool GetEta(
const double ex,
const double ey,
const double ez,
208 const double bx,
const double by,
const double bz,
209 Medium* medium,
const Particle particle,
double& eta)
const;
212 bool Terminate(
const std::array<double, 3>& xx0,
213 const std::array<double, 3>& xx1,
214 const Particle particle,
215 std::vector<double>& ts,
216 std::vector<std::array<double, 3> >& xs);
219 bool DriftToWire(
const double xw,
const double yw,
const double rw,
220 const Particle particle,
221 std::vector<double>& ts,
222 std::vector<std::array<double, 3> >& xs,
int& stat);
225 double IntegrateDiffusion(
const std::array<double, 3>& xi,
226 const std::array<double, 3>& xe,
227 const Particle particle,
const double tol);
229 double IntegrateAlpha(
const std::array<double, 3>& xi,
230 const std::array<double, 3>& xe,
231 const Particle particle,
const double tol);
233 double IntegrateEta(
const std::array<double, 3>& xi,
234 const std::array<double, 3>& xe,
235 const Particle particle,
const double tol);
238 void ComputeSignal(
const Particle particle,
const double scale,
239 const std::vector<double>& ts,
240 const std::vector<std::array<double, 3> >& xs,
241 const std::vector<double>& ne)
const;
244 void Terminate(
const std::array<double, 3>& xx0,
245 const std::array<double, 3>& xx1,
246 std::vector<std::array<float, 3> >& xs);
void SetIonSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by ions.
void SetSignalAveragingOrder(const unsigned int navg)
void EnableSignalCalculation(const bool on=true)
Switch on/off calculation of induced currents (default: enabled).
void DisablePlotting()
Switch off drift line plotting.
bool DriftNegativeIon(const double x0, const double y0, const double z0, const double t0)
double GetLoss(const double eps=1.e-4)
Compute the attachment loss factor for the current drift line.
bool DriftHole(const double x0, const double y0, const double z0, const double t0)
Simulate the drift line of a hole with a given starting point.
bool DriftIon(const double x0, const double y0, const double z0, const double t0)
Simulate the drift line of an ion with a given starting point.
void SetSensor(Sensor *s)
Set the sensor.
void UnsetMaximumStepSize()
Do not apply an upper limit to the step size that is allowed.
void SetIntegrationAccuracy(const double eps)
Set the accuracy of the Runge Kutta Fehlberg drift line integration.
unsigned int GetNumberOfDriftLinePoints() const
Get the number of points of the most recent drift line.
bool DriftElectron(const double x0, const double y0, const double z0, const double t0)
Simulate the drift line of an electron with a given starting point.
void SetGainFluctuationsPolya(const double theta, const double mean=-1.)
double GetGain(const double eps=1.e-4)
Compute the multiplication factor for the current drift line.
void SetGainFluctuationsFixed(const double gain=-1.)
Do not randomize the avalanche size.
void RejectKinks(const bool on=true)
bool DriftPositron(const double x0, const double y0, const double z0, const double t0)
void GetDriftLinePoint(const unsigned int i, double &x, double &y, double &z, double &t) const
Get the coordinates and time of a point along the most recent drift line.
~DriftLineRKF()
Destructor.
void PrintDriftLine() const
Print the trajectory of the most recent drift line.
void EnablePlotting(ViewDrift *view)
Switch on drift line plotting.
DriftLineRKF()
Constructor.
double GetDriftTime() const
double GetArrivalTimeSpread(const double eps=1.e-4)
void GetAvalancheSize(double &ne, double &ni) const
void GetEndPoint(double &x, double &y, double &z, double &t, int &st) const
Get the end point and status flag of the most recent drift line.
bool FieldLine(const double xi, const double yi, const double zi, std::vector< std::array< float, 3 > > &xl, const bool electron=true)
void SetHoleSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by holes.
void EnableAvalanche(const bool on=true)
Enable/disable simulation electron multiplication (default: on).
void SetMaximumStepSize(const double ms)
Set the maximum step size that is allowed. By default, there is no limit.
void EnableIonTail(const bool on=true)
Enable/disable simulation of the ion tail (default: off).
void SetElectronSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by electrons.
Visualize drift lines and tracks.