1#ifndef __JDETECTOR__JPMTANALOGUESIGNALPROCESSOR__
2#define __JDETECTOR__JPMTANALOGUESIGNALPROCESSOR__
77 x1(
std::numeric_limits<double>::max())
96 static const int N = 100;
97 static const double precision = 1.0e-4;
130 const double Q = b*b - 4.0*a*c;
150 x1 = std::numeric_limits<double>::max();
155 for (
int i = 0; i != N; ++i) {
157 const double x = 0.5 * (xmin + xmax);
160 if (fabs(1.0 - u) < precision) {
170 x1 = 0.5 * (xmin + xmax);
232 return exp(-0.5*x*x);
284 if (th > 0.0 && th < 1.0)
287 THROW(
JValueOutOfRange,
"JPMTAnalogueSignalProcessor::getMaximalRiseTime(): Invalid threshold " << th);
314 return std::numeric_limits<double>::max();
358 if (zmin < th) { zmin = th; }
359 if (zmax < th) { zmax = th; }
363 const double mu = NPE *
gain;
366 const double cumulP = (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
367 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
368 const double norm = 0.5 * erfc((th - mu) / sqrt(2.0) / sigma);
370 return cumulP / norm;
380 for (
int k = 0; k <= NPE; ++k) {
382 const double mu = (NPE-k) *
gain + (k) * fs *
gain;
385 cumulP += weight * (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
386 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
387 norm += weight * (0.5 * erfc((th - mu) / sqrt(2.0) / sigma));
392 return cumulP / norm;
487 return gRandom->Rndm() <
QE;
504 return gRandom->Gaus(t_ns,
TTS_ns);
540 const double mu = NPE *
gain;
543 q = gRandom->Gaus(mu,sigma);
550 const double X = gRandom->Uniform();
555 for (; k <= NPE; ++k) {
558 if (sum_p > X) {
break; }
565 const double mu = (NPE-k) *
gain + (k) * fs *
gain;
568 q = gRandom->Gaus(mu,sigma);
594 const double mu = NPE *
gain;
610 for (
int k = 0; k <= NPE; ++k) {
612 const double mu = (NPE-k) *
gain + (k) * fs *
gain;
716 THROW(
JValueOutOfRange,
"JPMTAnalogueSignalProcessor::getTimeOverThreshold: Invalid charge " << npe);
775 }
else if (
QE < 1.0) {
779 for (
int i = 1; i <= NPE; ++i) {
781 const double p = (binomial(NPE, i) * pow(
QE, i) * pow(1.0 -
QE, NPE - i));
807 const double mu = NPE *
gain;
812 const double Ptotal = 0.5 * erfc((0.0 - mu) / (sqrt(2.0) * sigma));
815 return Pabove / Ptotal;
834 for (
int k = 0; k <= NPE; ++k) {
836 const double mu = (NPE-k) *
gain + (k) * fs *
gain;
841 Ptotal += weight * 0.5 * erfc((0.0 - mu) / (sqrt(2.0) * sigma));
853 return Pabove / Ptotal;
871 virtual double getNPE(
const double tot_ns)
const override
874 return std::numeric_limits<double>::max();
885 }
else if (tot <= TOT) {
890 const double z = (-b + sqrt(b*b - 4*a*c)) / (2*a);
912 const double npe =
getNPE(tot_ns);
917 const double RaboveTh = y * v;
919 return RthBand + RaboveTh;
936 const double IthBand = PthBand * (0.5 * erfc((Tmin -
mean_ns) / sqrt(2.0) /
sigma_ns) -
940 return IthBand + IaboveTh;
991 const double precision = 1.0e-4)
993 int i = (int) (NPE - 5.0 * sqrt(NPE) - 0.5);
994 int M = (int) (NPE + 5.0 * sqrt(NPE) + 0.5);
996 if (i < 1) { i = 1; }
997 if (M < i) { M = i; }
999 double p = NPE * exp(-NPE) / (double) 1;
1001 for (
int __i = 1; __i != i; ++__i) {
1007 for (
double p0 = 0.0; (p >= p0 || p > precision) && i != M; ++i, p0 = p, p *= NPE / (double) i) {
Time calibration (including definition of sign of time offset).
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Auxiliary methods for mathematics.
Data structure for PMT parameters.
double sigma_ns
time-over-threshold standard deviation of threshold-band hits [ns]
double QE
relative quantum efficiency
int getType() const
Get type for for time-slewing correction.
double thresholdBand
threshold-band [npe]
double gainSpread
gain spread [unit]
JPMTParameters()
Default constructor.
double riseTime_ns
rise time of analogue pulse [ns]
double TTS_ns
transition time spread [ns]
double threshold
threshold [npe]
double mean_ns
mean time-over-threshold of threshold-band hits [ns]
void setPMTParameters(const JPMTParameters ¶meters)
Set PMT parameters.
double slope
slope [ns/npe]
double PunderAmplified
probability of underamplified hit
bool slewing
time slewing of analogue signal
double saturation
saturation [ns]
PMT signal processor interface.
Exception for accessing a value in a collection that is outside of its range.
file Auxiliary data structures and methods for detector calibration.
JDETECTOR::JTransitTimeGenerator_t getTransitTime
Function object to generate transit time.
const double TIME_OVER_THRESHOLD_NS
Specification for time-over-threshold corresponding to a one photo-electron pulse.
double getTimeOverThresholdProbability(const JPMTAnalogueSignalProcessor &pmt, const double tot_ns, const double NPE, const double precision=1.0e-4)
Get time-over-threshold probability.
double Gauss(const double x, const double sigma)
Normalised Gauss function.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
PMT analogue signal processor.
double getDecayTime() const
Get decay time.
friend std::istream & operator>>(std::istream &in, JPMTAnalogueSignalProcessor &object)
Read PMT signal from input.
virtual bool applyQE() const override
Apply relative QE.
virtual bool compare(const JPhotoElectron &first, const JPhotoElectron &second) const override
Compare arrival times of photo-electrons.
static double getMaximalRiseTime(const double th)
Get maximal rise time for given threshold.
double getT1() const
Get time at transition point from Gaussian to exponential.
double getGainSpread(int NPE) const
Get gain spread for given number of photo-electrons.
double getIntegralOfChargeProbability(const JThresholdDomain domain, const int NPE) const
Get integral of probability in specific threshold domain.
double decayTime_ns
decay time [ns]
virtual double getRandomTime(const double t_ns) const override
Get randomised time according transit-time distribution.
virtual bool applyThreshold(const double npe) const override
Apply threshold.
virtual double getChargeProbability(const double npe, const int NPE) const override
Get probability density for given charge.
double y1
amplitude at match point [npe]
static double getTH1()
Get upper threshold for rise time evaluation.
virtual double getRiseTime(const double npe) const override
Get time to reach threshold.
virtual double getNPE(const double tot_ns) const override
Get number of photo-electrons.
double x1
Transition point from a logarithmic to a linear relation between time-over-threshold and number of ph...
double getTimeOverThresholdProbability(const double tot_ns, const int NPE) const
Get probability of having a pulse with specific time-over-threshold.
double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE) const
Get integral of probability.
double getIntegralOfTimeOverThresholdProbability(const double Tmin, const double Tmax, const int NPE) const
Get cumulative probability of time-over-threshold distribution.
double getY1() const
Get amplitude at transition point from Gaussian to exponential.
JThresholdDomain getThresholdDomain(const double npe) const
Get threshold domain.
virtual double getThresholdProbability(const int NPE) const override
Probability that a hit survives the threshold of the PMT.
virtual double getRandomCharge(const int NPE) const override
Get randomised charge according to gain and gain spread.
JPMTAnalogueSignalProcessor(const JPMTParameters ¶meters=JPMTParameters())
Constructor.
double getDerivativeOfSaturation(const double tot_ns) const
Get derivative of saturation factor.
double applySaturation(const double tot_ns) const
Get time-over-threshold with saturation.
double getDecayTime(const double npe, const double th) const
Get time to pass from top of analogue pulse to threshold.
double removeSaturation(const double tot_ns) const
Get time-over-threshold without saturation.
double getRiseTime(const double npe, const double th) const
Get time to pass from threshold to top of analogue pulse.
double getAmplitude(const double t1_ns) const
Get amplitude at given time for a one photo-electron pulse.
static double getTH0()
Get lower threshold for rise time evaluation.
double getStartOfLinearisation() const
Get transition point from a model-dependent to linear relation between time-over-threshold and number...
JThresholdDomain
Threshold domain specifiers.
@ ABOVE_THRESHOLD
above threshold
@ BELOW_THRESHOLD
below threshold
@ THRESHOLDBAND
inside threshold band
void setPMTParameters(const JPMTParameters ¶meters)
Set PMT parameters.
void configure()
Configure internal parameters.
virtual double getSurvivalProbability(const int NPE) const override
Probability that a hit survives the simulation of the PMT.
virtual double getTimeOverThreshold(const double npe) const override
Get time-over-threshold (ToT).
virtual double getDerivative(const double npe) const override
Get derivative of number of photo-electrons to time-over-threshold.
double t1
time at match point [ns]
Data structure for single photo-electron.