54 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
55 double& ey,
double& ez,
double& v,
Medium*& medium,
58 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
59 double& ey,
double& ez,
Medium*& medium,
int& status);
62 void MagneticField(
const double x,
const double y,
const double z,
double& bx,
63 double& by,
double& bz,
int& status);
67 double& wx,
double& wy,
double& wz,
68 const std::string& label);
71 const std::string& label);
75 const double z,
const double t,
76 const std::string& label);
87 bool SetArea(
const double xmin,
const double ymin,
const double zmin,
88 const double xmax,
const double ymax,
const double zmax);
90 bool GetArea(
double& xmin,
double& ymin,
double& zmin,
double& xmax,
91 double& ymax,
double& zmax);
93 bool IsInArea(
const double x,
const double y,
const double z);
96 bool IsInside(
const double x,
const double y,
const double z);
112 const unsigned int nsteps);
115 unsigned int& nsteps)
const {
134 void SetSignal(
const std::string& label,
const unsigned int bin,
135 const double signal);
137 void SetSignal(
const std::string& label,
const std::vector<double>& ts,
138 const std::vector<double>& is);
140 double GetSignal(
const std::string& label,
const unsigned int bin);
142 double GetSignal(
const std::string& label,
const unsigned int bin,
154 const unsigned int bin);
164 const std::vector<double>& values);
199 void AddNoise(
const bool total =
true,
const bool electron =
false,
200 const bool ion =
false);
210 const bool poisson =
true,
const double q0 = 1.);
213 const double q0 = 1.);
240 const double q,
const std::vector<double>& ts,
241 const std::vector<std::array<double, 3> >& xs);
245 const double q,
const std::vector<double>& ts,
246 const std::vector<std::array<double, 3> >& xs,
247 const std::vector<double>& qs);
251 const std::vector<std::array<double, 3> >& xs,
252 const bool integrateWeightingField);
257 const std::vector<std::array<double, 3> >& xs,
258 const std::vector<std::array<double, 3> >& vs,
259 const std::vector<double>& ns,
const int navg);
263 const std::string optTotal =
"t",
264 const std::string optPrompt =
"",
265 const std::string optDelayed =
"");
267 void ExportSignal(
const std::string& label,
const std::string& filename,
268 const bool chargeCariers =
false)
const;
272 const double z0,
const double x1,
const double y1,
277 bool CrossedWire(
const double x0,
const double y0,
const double z0,
278 const double x1,
const double y1,
const double z1,
279 double& xc,
double& yc,
double& zc,
const bool centre,
283 const double z0,
double& xw,
double& yw,
double& rw);
287 const double x1,
const double y1,
const double z1,
288 double& xc,
double& yc,
double& zc);
293 const double x1,
const double y1,
const double z1,
294 const double xp,
const double yp,
const double zp,
295 const unsigned int nI,
const int isign = 0);
305 void TransferGPUElectrodeSignals(SensorGPU*& sensor_gpu);
367 double& ymax,
double& zmax);
370 const std::vector<double>& ts,
const std::vector<double>& is,
371 const int navg,
const bool delayed =
false);
373 const double signal,
const bool electron,
const bool delayed) {
374 std::lock_guard<std::mutex> guard(
m_mutex);
375 electrode.
signal[bin] += signal;
391 const unsigned int nn);
396 void FFT(std::vector<double>& data,
const bool inverse,
const int nn);
Abstract base class for components.
Abstract base class for components.
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).
double TransferFunctionSq()
void EnableMagneticField(const unsigned int i, const bool on)
Activate/deactivate use of the magnetic field of a given component.
double GetElectronSignal(const std::string &label, const unsigned int bin)
Retrieve the electron signal for a given electrode and time bin.
void PlotSignal(const std::string &label, TPad *pad, const std::string optTotal="t", const std::string optPrompt="", const std::string optDelayed="")
Plot the induced signal.
bool ConvoluteSignal(const std::string &label, const bool fft=false)
Convolute the induced current on a given electrode with the transfer function.
std::vector< std::tuple< Component *, bool, bool > > m_components
Components.
void FillBin(Electrode &electrode, const unsigned int bin, const double signal, const bool electron, const bool delayed)
Medium * GetMedium(const double x, const double y, const double z)
Get the medium at (x, y, z).
bool GetVoltageRange(double &vmin, double &vmax)
Return the voltage range.
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
double GetTotalInducedCharge(const std::string &label)
void AddWhiteNoise(const double enc, const bool poisson=true, const double q0=1.)
Add white noise to the induced signals on all electrodes.
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)
Set the time window and binning for the signal calculation.
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.
std::vector< double > m_delayedSignalTimes
bool DelayAndSubtractFraction(const double td, const double f)
Delay the signal and subtract an attenuated copy (modelling a constant fraction discriminator).
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).
Sensor(Component *comp)
Constructor from a single component.
void AddSignalWeightingField(const double q, const std::vector< double > &ts, const std::vector< std::array< double, 3 > > &xs, const std::vector< std::array< double, 3 > > &vs, const std::vector< double > &ns, const int navg)
Calculate the signal from a drift line using the weighting field method, given the drift velocities a...
double GetTransferFunction(const double t)
Evaluate the transfer function at a given time.
bool ConvoluteSignalFFT()
void EnableComponent(const unsigned int i, const bool on)
Activate/deactivate a given component.
double InterpolateTransferFunctionTable(const double t) const
bool CrossedWire(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)
Determine whether a line between two points crosses a wire, calls Component::CrossedWire.
bool SetArea(const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
Set the user area explicitly.
void SetTransferFunction(const std::vector< double > ×, const std::vector< double > &values)
Set the points to be used for interpolating the transfer function.
void FillSignal(Electrode &electrode, const double q, const std::vector< double > &ts, const std::vector< double > &is, const int navg, const bool delayed=false)
double(* m_fNoise)(double t)
void GetTimeWindow(double &tstart, double &tstep, unsigned int &nsteps) const
Retrieve the time window and binning.
void AddElectrode(Component *comp, const std::string &label)
Add an electrode.
bool IntegrateSignal(const std::string &label)
Replace the signal on a given electrode by its integral.
void AddComponent(Component *comp)
Add a component.
void SetTransferFunction(std::function< double(double)>)
Set the function to be used for evaluating the transfer function.
void PrintTransferFunction()
Print some information about the presently set transfer function.
double DelayedWeightingPotential(const double x, const double y, const double z, const double t, const std::string &label)
Get the delayed weighting potential at (x, y, z).
void ConvoluteSignalFFT(Electrode &electrode, const std::vector< double > &tab, const unsigned int nn)
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).
void AddSignalWeightingPotential(const double q, const std::vector< double > &ts, const std::vector< std::array< double, 3 > > &xs, const std::vector< double > &qs)
Calculate the signal from an avalanche using the weighting potential method.
double GetSignal(const std::string &label, const unsigned int bin)
Retrieve the total signal for a given electrode and time bin.
size_t GetNumberOfComponents() const
Get the number of components attached to the sensor.
bool m_cacheTransferFunction
std::function< double(double)> m_fTransfer
void ConvoluteSignal(Electrode &electrode, const std::vector< double > &tab)
void SetNoiseFunction(double(*f)(double t))
Set the function to be used for evaluating the noise component.
void AddSignalWeightingField(const double q, const std::vector< double > &ts, const std::vector< std::array< double, 3 > > &xs, const bool integrateWeightingField)
Calculate the signal from a drift line using the weighting field method.
void IntegrateSignal(Electrode &electrode)
double GetPromptSignal(const std::string &label, const unsigned int bin)
Retrieve the prompt signal for a given electrode and time bin.
bool IntegrateSignals()
Replace the signals on all electrodes curve by their integrals.
bool HasMagneticField() const
Does the sensor have a non-zero magnetic field?
bool ConvoluteSignals(const bool fft=false)
Convolute all induced currents with the transfer function.
std::vector< Electrode > m_electrodes
Electrodes.
bool IsInArea(const double x, const double y, const double z)
Check if a point is inside the user area.
bool CrossedPlane(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc)
Determine whether a line between two points crosses a plane, calls Component::CrossedPlane.
std::vector< std::pair< double, double > > m_fTransferTab
double GetInducedCharge(const std::string &label)
Calculated using the weighting potentials at the start and end points.
void AddNoise(const bool total=true, const bool electron=false, const bool ion=false)
Add noise to the induced signal.
double GetSignal(const std::string &label, const unsigned int bin, const int comp)
Retrieve the electron signal for a given electrode and time bin.
void AddSignalWeightingPotential(const double q, const std::vector< double > &ts, const std::vector< std::array< double, 3 > > &xs)
Calculate the signal from a drift line using the weighting potential method.
void MakeTransferFunctionTable(std::vector< double > &tab)
size_t GetNumberOfElectrodes() const
Get the number of electrodes attached to the sensor.
unsigned int m_nAvgDelayedSignal
double IntegrateFluxLine(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const double xp, const double yp, const double zp, const unsigned int nI, const int isign=0)
Integrate the electric field flux through a line from (x0,y0,z0) to (x1,y1,z1) along a direction (xp,...
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&medium, int &status)
Get the drift field at (x, y, z).
double WeightingPotential(const double x, const double y, const double z, const std::string &label)
Get the weighting potential at (x, y, z).
Component * GetComponent(const unsigned int i)
Retrieve the pointer to a given component.
void AddWhiteNoise(const std::string &label, const double enc, const bool poisson=true, const double q0=1.)
Add white noise to the induced signal, given a desired output ENC.
bool ComputeThresholdCrossings(const double thr, const std::string &label, int &n)
Determine the threshold crossings of the current signal curve.
void Clear()
Remove all components, electrodes and reset the sensor.
bool SetArea(const bool verbose=false)
Set the user area to the default.
void SetSignal(const std::string &label, const std::vector< double > &ts, const std::vector< double > &is)
Set/override the signal.
~Sensor()=default
Destructor.
bool GetThresholdCrossing(const unsigned int i, double &time, double &level, bool &rise) const
Retrieve the time and type of a given threshold crossing (after having called ComputeThresholdCrossin...
size_t GetNumberOfThresholdCrossings() const
Get the number of threshold crossings (after having called ComputeThresholdCrossings).
void ClearElectrodes()
Remove all electrodes.
bool IsInside(const double x, const double y, const double z)
Check if a point is inside an active medium and inside the user area.
Sensor()=default
Default constructor.
std::vector< std::pair< double, bool > > m_thresholdCrossings
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)
Cache integral and FFT of the transfer function instead of recomputing it at every call (default: on)...
double CreateGPUTransferObject(SensorGPU *&sensor_gpu)
Create and initialise GPU Transfer class.
void SetTransferFunction(Shaper &shaper)
Set the transfer function using a Shaper object.
void ClearSignal()
Reset signals and induced charges of all electrodes.
double GetDelayedSignal(const std::string &label, const unsigned int bin)
Retrieve the delayed signal for a given electrode and time bin.
void ExportSignal(const std::string &label, const std::string &filename, const bool chargeCariers=false) const
Exporting induced signal to a csv file.
std::vector< double > m_fTransferFFT
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.
void PlotTransferFunction()
Plot the presently set transfer function.
void FFT(std::vector< double > &data, const bool inverse, const int nn)
bool InTrapRadius(const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
Determine whether a point is in the trap radius of a wire.
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)
Set the number of points to be used when averaging the delayed signal vector over a time bin (default...
bool ConvoluteSignalFFT(const std::string &label)
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.
bool IsIntegrated(const std::string &label) const
Return whether the signal has been integrated/convoluted.
Class for signal processing.
std::vector< double > delayedSignal
std::vector< double > delayedElectronSignal
std::vector< double > electronSignal
std::vector< double > signal
std::vector< double > delayedIonSignal
std::vector< double > ionSignal