1#ifndef G_DRIFTLINE_RKF_H
2#define G_DRIFTLINE_RKF_H
83 const bool quiet =
false);
92 const double t,
const size_t w = 1);
94 bool DriftHole(
const double x,
const double y,
const double z,
95 const double t,
const size_t w = 1);
97 bool DriftIon(
const double x,
const double y,
const double z,
98 const double t,
const size_t w = 1);
102 const double t,
const size_t w = 1);
106 const double t,
const size_t w = 1);
111 void GetEndPoint(
double& x,
double& y,
double& z,
double& t,
int& st)
const;
122 double GetGain(
const double eps = 1.e-4)
const;
124 double GetLoss(
const double eps = 1.e-4)
const;
127 return m_t.empty() ? 0. :
m_t.back() -
m_t.front();
147 bool FieldLine(
const double xi,
const double yi,
const double zi,
148 std::vector<std::array<float, 3> >& xl,
149 const bool electron =
true)
const;
176 std::vector<std::array<double, 3> >
m_x;
224 bool DriftLine(
const std::array<double, 3>& x0,
const double t0,
225 const Particle particle, std::vector<double>& ts,
226 std::vector<std::array<double, 3> >& xs,
int& status)
const;
230 const std::vector<std::array<double, 3> >& xs,
231 std::vector<double>& ne, std::vector<double>& ni,
232 std::vector<double>& nn,
double& scale)
const;
236 const std::vector<std::array<double, 3> >& xe,
237 const std::vector<double>& ni,
const double scale)
const;
241 const std::vector<std::array<double, 3> >& xe,
242 const std::vector<double>& nn,
243 const double scale)
const;
245 int GetField(
const std::array<double, 3>& x,
double& ex,
double& ey,
246 double& ez,
double& bx,
double& by,
double& bz,
247 Medium*& medium)
const;
250 const Particle particle,
int& status)
const;
252 double& dl,
double& dt)
const;
260 const std::array<double, 3>& xx1,
const Particle particle,
261 std::vector<double>& ts,
262 std::vector<std::array<double, 3> >& xs)
const;
265 bool DriftToWire(
const double xw,
const double yw,
const double rw,
266 const Particle particle, std::vector<double>& ts,
267 std::vector<std::array<double, 3> >& xs,
int& stat)
const;
270 const Particle particle,
const double eps)
const;
273 const Particle particle,
const double eps)
const;
276 const Particle particle,
const double eps)
const;
279 const std::array<double, 3>& xe,
280 const Particle particle,
const double tol)
const;
283 const std::array<double, 3>& xe,
284 const Particle particle,
const double tol)
const;
287 const std::array<double, 3>& xe,
const Particle particle,
288 const double tol)
const;
292 const std::vector<double>& ts,
293 const std::vector<std::array<double, 3> >& xs,
294 const std::vector<double>& ne)
const;
298 const std::array<double, 3>& xx1,
299 std::vector<std::array<float, 3> >& xs)
const;
double ComputeSigma(const std::vector< std::array< double, 3 > > &x, const Particle particle, const double eps) const
double GetEta(const std::array< double, 3 > &x, const Particle particle) const
void EnableVelocityMap(const bool on=true)
Retrieve the drift velocity from the component.
bool FieldLine(const double xi, const double yi, const double zi, std::vector< std::array< float, 3 > > &xl, const bool electron=true) const
Compute an electric field line.
double GetAlpha(const std::array< double, 3 > &x, const Particle particle) const
void EnableDebugging(const bool on=true)
Switch debugging messages on/off (default: off).
void SetIonSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by ions.
void SetSignalAveragingOrder(const unsigned int navg)
Set the number of points to be used when averaging the delayed signal vector over a time bin in the S...
void EnableSignalCalculation(const bool on=true)
Switch calculation of induced currents on or off (default: enabled).
void SetMaximumStepSize()
Try to set an upper limit to the allowable step size based on the feature size of the sensor.
bool DriftIon(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an ion with a given starting point.
void SetGainFluctuationsPolya(const double theta, const double mean=-1., const bool quiet=false)
Sample the avalanche size from a Polya distribution with shape parameter theta.
void DisablePlotting()
Switch off drift line plotting.
bool Avalanche(const Particle particle, const std::vector< std::array< double, 3 > > &xs, std::vector< double > &ne, std::vector< double > &ni, std::vector< double > &nn, double &scale) const
double IntegrateAlpha(const std::array< double, 3 > &xi, const std::array< double, 3 > &xe, const Particle particle, const double tol) const
bool DriftToWire(const double xw, const double yw, const double rw, const Particle particle, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs, int &stat) const
double ComputeLoss(const std::vector< std::array< double, 3 > > &x, const Particle particle, const double eps) const
bool AddIonTail(const std::vector< double > &te, const std::vector< std::array< double, 3 > > &xe, const std::vector< double > &ni, const double scale) const
double IntegrateDiffusion(const std::array< double, 3 > &xi, const std::array< double, 3 > &xe, const Particle particle, const double tol) const
double GetPathLength() const
Get the cumulative path length.
double GetArrivalTimeSpread(const double eps=1.e-4) const
Compute the sigma of the arrival time distribution for the current drift line by integrating the long...
void UseWeightingPotential(const bool on=true)
Use the weighting potential (as opposed to the weighting field) for calculating the induced signal.
void EnableNegativeIonTail(const bool on=true)
Enable/disable simulation of the negative ion tail (default: off).
bool DriftElectron(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an electron with a given starting point.
bool m_useWeightingPotential
void SetSensor(Sensor *s)
Set the sensor.
void GetDriftLinePoint(const size_t i, double &x, double &y, double &z, double &t) const
Get the coordinates and time of a point along the most recent drift line.
void UnsetMaximumStepSize()
Do not apply an upper limit to the allowable step size.
void SetIntegrationAccuracy(const double eps)
Set the accuracy of the Runge Kutta Fehlberg drift line integration.
std::vector< std::array< double, 3 > > m_x
double ComputeGain(const std::vector< std::array< double, 3 > > &x, const Particle particle, const double eps) const
void SetGainFluctuationsFixed(const double gain=-1.)
Do not randomize the avalanche size.
static double Charge(const Particle particle)
bool AddNegativeIonTail(const std::vector< double > &te, const std::vector< std::array< double, 3 > > &xe, const std::vector< double > &nn, const double scale) const
void RejectKinks(const bool on=true)
Request (or not) the drift line calculation to be aborted if the drift line makes a bend sharper than...
bool Terminate(const std::array< double, 3 > &xx0, const std::array< double, 3 > &xx1, const Particle particle, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs) const
bool DriftNegativeIon(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an ion with a given starting point, assuming that it has negative charge.
bool DriftPositron(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of an electron with a given starting point, assuming that it has positive cha...
~DriftLineRKF()
Destructor.
GainFluctuations m_gainFluctuations
void PrintDriftLine() const
Print the trajectory of the most recent drift line.
double IntegrateEta(const std::array< double, 3 > &xi, const std::array< double, 3 > &xe, const Particle particle, const double tol) const
void EnablePlotting(ViewDrift *view)
Switch on drift line plotting.
double GetVar(const std::array< double, 3 > &x, const Particle particle) const
double GetGain(const double eps=1.e-4) const
Compute the multiplication factor for the current drift line.
void Terminate(const std::array< double, 3 > &xx0, const std::array< double, 3 > &xx1, std::vector< std::array< float, 3 > > &xs) const
DriftLineRKF()
Default constructor.
double GetDriftTime() const
Get the cumulative drift time.
DriftLineRKF(Sensor *sensor)
Constructor.
double GetLoss(const double eps=1.e-4) const
Compute the attachment loss factor for the current drift line.
void EnableTownsendMap(const bool on=true)
Retrieve the Townsend coefficient from the component.
bool DriftLine(const std::array< double, 3 > &x0, const double t0, const Particle particle, std::vector< double > &ts, std::vector< std::array< double, 3 > > &xs, int &status) const
void GetAvalancheSize(double &ne, double &ni) const
Return the number of electrons and ions in the avalanche.
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.
int GetField(const std::array< double, 3 > &x, double &ex, double &ey, double &ez, double &bx, double &by, double &bz, Medium *&medium) const
std::array< double, 3 > GetVelocity(const std::array< double, 3 > &x, const Particle particle, int &status) const
bool GetDiffusion(const std::array< double, 3 > &x, const Particle particle, double &dl, double &dt) const
void ComputeSignal(const Particle particle, const double scale, const std::vector< double > &ts, const std::vector< std::array< double, 3 > > &xs, const std::vector< double > &ne) const
size_t GetNumberOfDriftLinePoints() const
Get the number of points of the most recent drift line.
std::vector< double > m_t
std::pair< double, double > GetAvalancheSize() const
Return the number of electrons and ions in the avalanche.
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 (explicitly) the maximum step size that is allowed.
void EnableIonTail(const bool on=true)
Enable/disable simulation of the ion tail (default: on).
void SetElectronSignalScalingFactor(const double scale)
Set multiplication factor for the signal induced by electrons.
bool DriftHole(const double x, const double y, const double z, const double t, const size_t w=1)
Simulate the drift line of a hole with a given starting point.
Visualize drift lines and tracks.