36 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
37 double& ey,
double& ez,
double& v,
Medium*& medium,
40 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
41 double& ey,
double& ez,
Medium*& medium,
int& status);
44 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
45 double& by,
double& bz,
int& status);
48 void WeightingField(
const double x,
const double y,
const double z,
49 double& wx,
double& wy,
double& wz,
50 const std::string& label);
53 const std::string& label);
56 bool GetMedium(
const double x,
const double y,
const double z,
65 bool SetArea(
const double xmin,
const double ymin,
const double zmin,
66 const double xmax,
const double ymax,
const double zmax);
68 bool GetArea(
double& xmin,
double& ymin,
double& zmin,
double& xmax,
69 double& ymax,
double& zmax);
71 bool IsInArea(
const double x,
const double y,
const double z);
87 const unsigned int nsteps);
90 unsigned int& nsteps)
const {
105 m_nAvgDelayedSignal = navg;
109 void SetSignal(
const std::string& label,
const unsigned int bin,
110 const double signal);
112 double GetSignal(
const std::string& label,
const unsigned int bin);
116 double GetIonSignal(
const std::string& label,
const unsigned int bin);
128 const std::vector<double>& values);
136 m_cacheTransferFunction = on;
154 void AddNoise(
const bool total =
true,
const bool electron =
false,
155 const bool ion =
false);
163 void AddWhiteNoise(
const double enc,
const bool poisson =
true,
164 const double q0 = 1.);
175 return m_thresholdCrossings.size();
188 void AddSignal(
const double q,
const double t0,
const double t1,
189 const double x0,
const double y0,
const double z0,
190 const double x1,
const double y1,
const double z1,
191 const bool integrateWeightingField,
192 const bool useWeightingPotential =
false);
194 void AddSignal(
const double q,
const std::vector<double>& ts,
195 const std::vector<std::array<double, 3> >& xs,
196 const std::vector<std::array<double, 3> >& vs,
197 const std::vector<double>& ns,
const int navg);
200 const double z0,
const double x1,
const double y1,
205 bool IsWireCrossed(
const double x0,
const double y0,
const double z0,
206 const double x1,
const double y1,
const double z1,
207 double& xc,
double& yc,
double& zc,
208 const bool centre,
double& rc);
209 bool IsInTrapRadius(
const double q0,
const double x0,
const double y0,
210 const double z0,
double& xw,
double& yw,
double& rw);
213 std::string m_className =
"Sensor";
216 std::vector<ComponentBase*> m_components;
222 std::vector<double> signal;
223 std::vector<double> electronsignal;
224 std::vector<double> ionsignal;
225 std::vector<double> delayedElectronSignal;
226 std::vector<double> delayedIonSignal;
230 std::vector<Electrode> m_electrodes;
233 unsigned int m_nTimeBins = 200;
234 double m_tStart = 0.;
235 double m_tStep = 10.;
236 unsigned int m_nEvents = 0;
237 bool m_delayedSignal =
false;
238 std::vector<double> m_delayedSignalTimes;
239 unsigned int m_nAvgDelayedSignal = 0;
242 double (*m_fTransfer)(
double t) =
nullptr;
243 Shaper* m_shaper =
nullptr;
244 std::vector<std::pair<double, double> > m_fTransferTab;
245 bool m_cacheTransferFunction =
true;
247 double m_fTransferSq = -1.;
249 std::vector<double> m_fTransferFFT;
251 bool m_integrated =
false;
254 double (*m_fNoise)(
double t) =
nullptr;
256 std::vector<std::pair<double, bool> > m_thresholdCrossings;
257 double m_thresholdLevel = 0.;
260 bool m_hasUserArea =
false;
261 double m_xMinUser = 0., m_yMinUser = 0., m_zMinUser = 0.;
262 double m_xMaxUser = 0., m_yMaxUser = 0., m_zMaxUser = 0.;
265 bool m_debug =
false;
268 bool GetBoundingBox(
double& xmin,
double& ymin,
double& zmin,
double& xmax,
269 double& ymax,
double& zmax);
271 void FillSignal(Electrode& electrode,
const double q,
272 const std::vector<double>& ts,
273 const std::vector<double>& is,
const int navg,
274 const bool delayed =
false);
275 void FillBin(Electrode& electrode,
const unsigned int bin,
276 const double signal,
const bool electron,
const bool delayed) {
277 electrode.signal[bin] += signal;
279 electrode.electronsignal[bin] += signal;
280 if (delayed) electrode.delayedElectronSignal[bin] += signal;
282 electrode.ionsignal[bin] += signal;
283 if (delayed) electrode.delayedIonSignal[bin] += signal;
287 double TransferFunctionSq();
288 double InterpolateTransferFunctionTable(
const double t)
const;
289 bool ConvoluteSignalFFT();
290 void FFT(std::vector<double>& data,
const bool inverse,
const int nn);
Abstract base class for components.
Abstract base class for media.
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
Get the magnetic field at (x, y, z).
bool IsIntegrated() const
Return whether the signal has been integrated/convoluted.
double GetElectronSignal(const std::string &label, const unsigned int bin)
Retrieve the electron signal for a given electrode and time bin.
bool GetVoltageRange(double &vmin, double &vmax)
Return the voltage range.
void AddWhiteNoise(const double enc, const bool poisson=true, const double q0=1.)
void SetDelayedSignalTimes(const std::vector< double > &ts)
Set the points in time at which to evaluate the delayed weighting field.
void SetTimeWindow(const double tstart, const double tstep, const unsigned int nsteps)
bool IntegrateSignal()
Replace the current signal curve by its integral.
void SetSignal(const std::string &label, const unsigned int bin, const double signal)
Set/override the signal in a given time bin explicitly.
void EnableDelayedSignal(const bool on=true)
Compute the component of the signal due to the delayed weighting field.
double GetDelayedIonSignal(const std::string &label, const unsigned int bin)
Retrieve the delayed ion/hole signal for a given electrode and time bin.
bool IsInTrapRadius(const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
bool DelayAndSubtractFraction(const double td, const double f)
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
Get the weighting field at (x, y, z).
double GetTransferFunction(const double t)
Evaluate the transfer function at a given time.
void GetTimeWindow(double &tstart, double &tstep, unsigned int &nsteps) const
Retrieve the time window and binning.
unsigned int GetNumberOfElectrodes() const
Get the number of electrodes attached to the sensor.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&medium, int &status)
Get the drift field and potential at (x, y, z).
bool SetArea()
Set the user area to the default.
double GetSignal(const std::string &label, const unsigned int bin)
Retrieve the total signal for a given electrode and time bin.
void SetNoiseFunction(double(*f)(double t))
Set the function to be used for evaluating the noise component.
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
void AddElectrode(ComponentBase *comp, const std::string &label)
Add an electrode.
double GetInducedCharge(const std::string &label)
void AddNoise(const bool total=true, const bool electron=false, const bool ion=false)
Add noise to the induced signal.
double WeightingPotential(const double x, const double y, const double z, const std::string &label)
Get the weighting potential at (x, y, z).
bool ComputeThresholdCrossings(const double thr, const std::string &label, int &n)
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Get the medium at (x, y, z).
void Clear()
Remove all components, electrodes and reset the sensor.
void AddSignal(const double q, const double t0, const double t1, const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const bool integrateWeightingField, const bool useWeightingPotential=false)
Add the signal from a charge-carrier step.
bool ConvoluteSignal(const bool fft=false)
Convolute the induced current with the transfer function.
void SetTransferFunction(double(*f)(double t))
Set the function to be used for evaluating the transfer function.
bool GetThresholdCrossing(const unsigned int i, double &time, double &level, bool &rise) const
void AddComponent(ComponentBase *comp)
Add a component.
unsigned int GetNumberOfThresholdCrossings() const
Sensor()=default
Constructor.
double GetDelayedElectronSignal(const std::string &label, const unsigned int bin)
Retrieve the delayed electron signal for a given electrode and time bin.
void EnableTransferFunctionCache(const bool on=true)
bool IsWireCrossed(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc, const bool centre, double &rc)
void ClearSignal()
Reset signals and induced charges of all electrodes.
void AddInducedCharge(const double q, const double x0, const double y0, const double z0, const double x1, const double y1, const double z1)
Add the induced charge from a charge carrier drift between two points.
unsigned int GetNumberOfComponents() const
Get the number of components attached to the sensor.
double GetIonSignal(const std::string &label, const unsigned int bin)
Retrieve the ion or hole signal for a given electrode and time bin.
void EnableDebugging(const bool on=true)
Switch debugging messages on/off.
void SetDelayedSignalAveragingOrder(const unsigned int navg)
void NewSignal()
Start a new event, when computing the average signal over multiple events.
bool GetArea(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Return the current user area.
ComponentBase * GetComponent(const unsigned int i)
Retrieve the pointer to a given component.
Class for signal processing.