Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JDETECTOR::JPMTAnalogueSignalProcessor Struct Reference

PMT analogue signal processor. More...

#include <JPMTAnalogueSignalProcessor.hh>

Inheritance diagram for JDETECTOR::JPMTAnalogueSignalProcessor:
JDETECTOR::JPMTSignalProcessorInterface JDETECTOR::JPMTParameters

Public Types

enum  JThresholdDomain { BELOW_THRESHOLD = -1 , THRESHOLDBAND = 0 , ABOVE_THRESHOLD = 2 }
 Threshold domain specifiers. More...
 

Public Member Functions

 JPMTAnalogueSignalProcessor (const JPMTParameters &parameters=JPMTParameters())
 Constructor.
 
void configure ()
 Configure internal parameters.
 
double getDecayTime () const
 Get decay time.
 
double getT1 () const
 Get time at transition point from Gaussian to exponential.
 
double getY1 () const
 Get amplitude at transition point from Gaussian to exponential.
 
double getStartOfLinearisation () const
 Get transition point from a model-dependent to linear relation between time-over-threshold and number of photo-electrons.
 
double getAmplitude (const double t1_ns) const
 Get amplitude at given time for a one photo-electron pulse.
 
double getRiseTime (const double npe, const double th) const
 Get time to pass from threshold to top of analogue pulse.
 
double getDecayTime (const double npe, const double th) const
 Get time to pass from top of analogue pulse to threshold.
 
double applySaturation (const double tot_ns) const
 Get time-over-threshold with saturation.
 
double removeSaturation (const double tot_ns) const
 Get time-over-threshold without saturation.
 
double getDerivativeOfSaturation (const double tot_ns) const
 Get derivative of saturation factor.
 
double getGainSpread () const
 Get gain spread for given number of photo-electrons.
 
double getGainSpread (int NPE) const
 Get gain spread for given number of photo-electrons.
 
double getUnderamplifiedGain () const
 Get gain of underamplified pulses.
 
double getUnderamplifiedGain (int NPE) const
 Get gain of underamplified pulses.
 
double getUnderamplifiedGainSpread () const
 Get gain spread of underamplified pulses.
 
double getUnderamplifiedGainSpread (int NPE) const
 Get gain spread of underamplified pulses.
 
void setPMTParameters (const JPMTParameters &parameters)
 Set PMT parameters.
 
JThresholdDomain getThresholdDomain (const double npe) const
 Get threshold domain.
 
virtual bool applyQE () const override
 Apply relative QE.
 
virtual double getRandomTime (const double t_ns) const override
 Get randomised time according transit-time distribution.
 
virtual bool compare (const JPhotoElectron &first, const JPhotoElectron &second) const override
 Compare arrival times of photo-electrons.
 
virtual double getRandomCharge (const int NPE) const override
 Get randomised charge according to gain and gain spread.
 
virtual double getChargeProbability (const double npe, const int NPE) const override
 Get probability density for given charge.
 
double getChargeProbability (const double npe, const int NPE, const double normTh) const
 Get probability density for given charge.
 
double getIntegralOfChargeProbability (const double xmin, const double xmax, const int NPE) const
 Get integral of probability.
 
double getIntegralOfChargeProbability (const double xmin, const double xmax, const int NPE, const double normTh) const
 Get integral of probability.
 
double getIntegralOfChargeProbability (const double xmin, const int NPE) const
 Get integral of probability.
 
double getIntegralOfChargeProbability (const JThresholdDomain domain, const int NPE) const
 Get integral of probability in specific threshold domain.
 
virtual bool applyThreshold (const double npe) const override
 Apply threshold.
 
virtual double getRiseTime (const double npe) const override
 Get time to reach threshold.
 
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.
 
virtual double getSurvivalProbability (const int NPE) const override
 Probability that a hit survives the simulation of the PMT.
 
virtual double getThresholdProbability (const int NPE) const override
 Probability that a hit survives the threshold of the PMT.
 
virtual double getNPE (const double tot_ns) const override
 Get number of photo-electrons.
 
double getTimeOverThresholdProbability (const double tot_ns, const int NPE) const
 Get probability of having a pulse with specific time-over-threshold.
 
double getIntegralOfTimeOverThresholdProbability (const double Tmin, const double Tmax, const int NPE) const
 Get cumulative probability of time-over-threshold distribution.
 
void operator() (const JCalibration &calibration, const JPMTData< JPMTSignal > &input, JPMTData< JPMTPulse > &output) const
 Process hits.
 
virtual void merge (JPMTData< JPMTPulse > &data) const
 Merging of PMT hits.
 
const JPMTParametersgetPMTParameters () const
 Get PMT parameters.
 
bool is_valid () const
 Check validity of PMT parameters.
 
int getType () const
 Get type for for time-slewing correction.
 
JProperties getProperties (const JEquationParameters &equation=JPMTParameters::getEquationParameters())
 Get properties of this class.
 
JProperties getProperties (const JEquationParameters &equation=JPMTParameters::getEquationParameters()) const
 Get properties of this class.
 

Static Public Member Functions

static double getMaximalRiseTime (const double th)
 Get maximal rise time for given threshold.
 
static double getTH0 ()
 Get lower threshold for rise time evaluation.
 
static double getTH1 ()
 Get upper threshold for rise time evaluation.
 
static double getTmin ()
 Get two photo-electron resolution for time-over-threshold.
 
static double getQmin ()
 Get width of charge distribution.
 
static JEquationParametersgetEquationParameters ()
 Get equation parameters.
 
static void setEquationParameters (const JEquationParameters &equation)
 Set equation parameters.
 

Public Attributes

double QE
 relative quantum efficiency
 
double gain
 gain [unit]
 
double gainSpread
 gain spread [unit]
 
double riseTime_ns
 rise time of analogue pulse [ns]
 
double TTS_ns
 transition time spread [ns]
 
double threshold
 threshold [npe]
 
double PunderAmplified
 probability of underamplified hit
 
double thresholdBand
 threshold-band [npe]
 
double mean_ns
 mean time-over-threshold of threshold-band hits [ns]
 
double sigma_ns
 time-over-threshold standard deviation of threshold-band hits [ns]
 
double slope
 slope [ns/npe]
 
double saturation
 saturation [ns]
 
bool slewing
 time slewing of analogue signal
 

Protected Attributes

double decayTime_ns
 decay time [ns]
 
double t1
 time at match point [ns]
 
double y1
 amplitude at match point [npe]
 
double x1
 Transition point from a logarithmic to a linear relation between time-over-threshold and number of photo-electrons.
 

Private Member Functions

double getNormalisedGauss (const double x, const double x0, const double sigma, const double normXmin, const double normXmax) const
 Gauss function normalised to a configurable domain.
 
double getIntegralOfNormalisedGauss (const double xmin, const double xmax, const double x0, const double sigma, const double normXmin, const double normXmax) const
 Integral of Gauss function normalised to a configurable domain.
 

Friends

std::istream & operator>> (std::istream &in, JPMTAnalogueSignalProcessor &object)
 Read PMT signal from input.
 

Detailed Description

PMT analogue signal processor.

This class provides for an implementation of the JDETECTOR::JPMTSignalProcessorInterface using a specific model for the analogue pulse of the PMT.
In this, the leading edge of the analogue pulse from the PMT is assumed to be a Gaussian and the tail an exponential.
The width of the Gaussian is referred to as the rise time and the inverse slope of the exponential to the decay time.
The two functions are matched at a point where the values and first derivatives are identical.
Note that the decay time is related to the rise time via the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.

The charge distribution is assumed to be a Gaussian which is centered at the specified gain and truncated by the specified threshold.

The transit times are generated according the specified spread as follows.

  • If the specified transit-time spread (TTS) is negative, the transit times are generated according to measurements (see method JDETECTOR::getTransitTime).
    In this, the negated integral value of the TTS corresponds to the option which in turn corresponds to the detector identifier of the measurements.
  • If the specified TTS is positive, the transit times are generated according a Gaussian with a sigma equals to the given TTS.
  • If the TTS is zero, the transit times are generated without any spread.

Definition at line 52 of file JPMTAnalogueSignalProcessor.hh.

Member Enumeration Documentation

◆ JThresholdDomain

Threshold domain specifiers.

Enumerator
BELOW_THRESHOLD 

below threshold

THRESHOLDBAND 

inside threshold band

ABOVE_THRESHOLD 

above threshold

Definition at line 59 of file JPMTAnalogueSignalProcessor.hh.

59 {
60 BELOW_THRESHOLD = -1, //!< below threshold
61 THRESHOLDBAND = 0, //!< inside threshold band
62 ABOVE_THRESHOLD = 2 //!< above threshold
63 };

Constructor & Destructor Documentation

◆ JPMTAnalogueSignalProcessor()

JDETECTOR::JPMTAnalogueSignalProcessor::JPMTAnalogueSignalProcessor ( const JPMTParameters & parameters = JPMTParameters())
inline

Constructor.

Parameters
parametersPMT parameters

Definition at line 71 of file JPMTAnalogueSignalProcessor.hh.

71 :
73 JPMTParameters(parameters),
74 decayTime_ns(0.0),
75 t1(0.0),
76 y1(0.0),
77 x1(std::numeric_limits<double>::max())
78 {
79 configure();
80 }
JPMTParameters()
Default constructor.
double x1
Transition point from a logarithmic to a linear relation between time-over-threshold and number of ph...
void configure()
Configure internal parameters.

Member Function Documentation

◆ configure()

void JDETECTOR::JPMTAnalogueSignalProcessor::configure ( )
inline

Configure internal parameters.

This method provides the implementations for

  • matching of the leading edge of the analogue pulse (Gaussian) and the tail (exponential); and
  • determination of number of photo-electrons above which the time-over-threshold linearly depends on the number of photo-electrons (apart from saturation).

Note that this method will throw an error if the value of the rise time (i.e. width of the Gaussian) is too large with respect to the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.

Definition at line 94 of file JPMTAnalogueSignalProcessor.hh.

95 {
96 static const int N = 100;
97 static const double precision = 1.0e-4;
98
99 // check thresholdband
100
101 if (threshold - thresholdBand < getTH0()) {
102 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::configure(): Invalid thresholdband [npe] " << thresholdBand);
103 }
104
105 // check rise time
106
108 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::configure(): Invalid rise time [ns] " << riseTime_ns);
109 }
110
111 // check probability for under-amplified signal
112
113 if (PunderAmplified < 0.0) {
114 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::configure(): Invalid probability of under-amplification " << PunderAmplified);
115 }
116
117 // decay time
118
119 const double y = -log(threshold);
120
121 const double a = y;
122 const double b = riseTime_ns * sqrt(2.0*y) - TIME_OVER_THRESHOLD_NS;
123 const double c = 0.5*riseTime_ns*riseTime_ns;
124 const double Q = b*b - 4.0*a*c;
125
126 if (Q > 0.0)
127 decayTime_ns = (-b + sqrt(Q)) / (2.0*a);
128 else
129 decayTime_ns = -b / (2.0*a);
130
131 // fix matching of Gaussian and exponential
132
133 const double x = riseTime_ns / decayTime_ns;
134
135 t1 = riseTime_ns*x;
136 y1 = exp(-0.5*x*x);
137
138 // determine transition point to linear dependence of time-over-threshold as a function of number of photo-electrons
139
140 const double xs = saturation; // disable saturation
141
142 saturation = 1.0e50;
143
144 x1 = std::numeric_limits<double>::max(); // disable linearisation
145
146 double xmin = 1.0;
147 double xmax = 1.0 / (getDerivative(1.0) * slope);
148
149 for (int i = 0; i != N; ++i) {
150
151 const double x = 0.5 * (xmin + xmax);
152 const double u = getDerivative(x) * slope;
153
154 if (fabs(1.0 - u) < precision) {
155 break;
156 }
157
158 if (u < 1.0)
159 xmin = x;
160 else
161 xmax = x;
162 }
163
164 x1 = 0.5 * (xmin + xmax);
165
166 saturation = xs; // restore saturation
167 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
double thresholdBand
threshold-band [npe]
double riseTime_ns
rise time of analogue pulse [ns]
double threshold
threshold [npe]
double slope
slope [ns/npe]
double PunderAmplified
probability of underamplified hit
double saturation
saturation [ns]
const double TIME_OVER_THRESHOLD_NS
Specification for time-over-threshold corresponding to a one photo-electron pulse.
static double getMaximalRiseTime(const double th)
Get maximal rise time for given threshold.
static double getTH0()
Get lower threshold for rise time evaluation.
virtual double getDerivative(const double npe) const override
Get derivative of number of photo-electrons to time-over-threshold.

◆ getDecayTime() [1/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getDecayTime ( ) const
inline

Get decay time.

Returns
decay time [ns]

Definition at line 175 of file JPMTAnalogueSignalProcessor.hh.

176 {
177 return decayTime_ns;
178 }

◆ getT1()

double JDETECTOR::JPMTAnalogueSignalProcessor::getT1 ( ) const
inline

Get time at transition point from Gaussian to exponential.

Returns
time [ns]

Definition at line 186 of file JPMTAnalogueSignalProcessor.hh.

187 {
188 return t1;
189 }

◆ getY1()

double JDETECTOR::JPMTAnalogueSignalProcessor::getY1 ( ) const
inline

Get amplitude at transition point from Gaussian to exponential.

Returns
amplitude [npe]

Definition at line 197 of file JPMTAnalogueSignalProcessor.hh.

198 {
199 return y1;
200 }

◆ getStartOfLinearisation()

double JDETECTOR::JPMTAnalogueSignalProcessor::getStartOfLinearisation ( ) const
inline

Get transition point from a model-dependent to linear relation between time-over-threshold and number of photo-electrons.

Returns
number of photo-electrons [npe]

Definition at line 208 of file JPMTAnalogueSignalProcessor.hh.

209 {
210 return x1;
211 }

◆ getAmplitude()

double JDETECTOR::JPMTAnalogueSignalProcessor::getAmplitude ( const double t1_ns) const
inline

Get amplitude at given time for a one photo-electron pulse.

Parameters
t1_nstime [ns]
Returns
amplitude [npe]

Definition at line 220 of file JPMTAnalogueSignalProcessor.hh.

221 {
222 if (t1_ns < t1) {
223
224 const double x = t1_ns / riseTime_ns;
225
226 return exp(-0.5*x*x); // Gaussian
227
228 } else {
229
230 const double x = t1_ns / decayTime_ns;
231
232 return exp(-x) / y1; // exponential
233 }
234 }

◆ getRiseTime() [1/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getRiseTime ( const double npe,
const double th ) const
inline

Get time to pass from threshold to top of analogue pulse.


In this, the leading edge of the analogue pulse is assumed to be Gaussian.

Parameters
npenumber of photo-electrons
ththreshold [npe]
Returns
time [ns]

Definition at line 245 of file JPMTAnalogueSignalProcessor.hh.

246 {
247 return riseTime_ns * sqrt(2.0*log(npe/th)); // Gaussian
248 }

◆ getDecayTime() [2/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getDecayTime ( const double npe,
const double th ) const
inline

Get time to pass from top of analogue pulse to threshold.


In this, the trailing edge of the analogue pulse is assumed to be exponential.

Parameters
npenumber of photo-electrons
ththreshold [npe]
Returns
time [ns]

Definition at line 259 of file JPMTAnalogueSignalProcessor.hh.

260 {
261 if (npe*y1 > th)
262 return decayTime_ns * (log(npe/th) - log(y1)); // exponential
263 else
264 return riseTime_ns * sqrt(2.0*log(npe/th)); // Gaussian
265 }

◆ getMaximalRiseTime()

static double JDETECTOR::JPMTAnalogueSignalProcessor::getMaximalRiseTime ( const double th)
inlinestatic

Get maximal rise time for given threshold.

Note that the rise time is entirely constrained by the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.

Parameters
ththreshold [npe]
Returns
rise time [ns]

Definition at line 276 of file JPMTAnalogueSignalProcessor.hh.

277 {
278 if (th > 0.0 && th < 1.0)
279 return 0.5 * TIME_OVER_THRESHOLD_NS / sqrt(-2.0*log(th));
280 else
281 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::getMaximalRiseTime(): Invalid threshold " << th);
282 }

◆ applySaturation()

double JDETECTOR::JPMTAnalogueSignalProcessor::applySaturation ( const double tot_ns) const
inline

Get time-over-threshold with saturation.

Parameters
tot_nstime-over-threshold without saturation
Returns
time-over-threshold with saturation

Definition at line 291 of file JPMTAnalogueSignalProcessor.hh.

292 {
293 return saturation / sqrt(tot_ns*tot_ns + saturation*saturation) * tot_ns;
294 }

◆ removeSaturation()

double JDETECTOR::JPMTAnalogueSignalProcessor::removeSaturation ( const double tot_ns) const
inline

Get time-over-threshold without saturation.

Parameters
tot_nstime-over-threshold with saturation
Returns
time-over-threshold without saturation

Definition at line 303 of file JPMTAnalogueSignalProcessor.hh.

304 {
305 if (tot_ns < saturation)
306 return saturation / sqrt(saturation*saturation - tot_ns*tot_ns) * tot_ns;
307 else
308 return std::numeric_limits<double>::max();
309 }

◆ getDerivativeOfSaturation()

double JDETECTOR::JPMTAnalogueSignalProcessor::getDerivativeOfSaturation ( const double tot_ns) const
inline

Get derivative of saturation factor.

Parameters
tot_nstime-over-threshold without saturation
Returns
derivative of saturation factor

Definition at line 318 of file JPMTAnalogueSignalProcessor.hh.

319 {
320 return saturation * saturation * saturation / ((saturation*saturation + tot_ns*tot_ns) * sqrt(saturation*saturation + tot_ns*tot_ns));
321 }

◆ getGainSpread() [1/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getGainSpread ( ) const
inline

Get gain spread for given number of photo-electrons.

Returns
gain spread

Definition at line 329 of file JPMTAnalogueSignalProcessor.hh.

330 {
331 return sqrt(gain) * gainSpread;
332 }
double gainSpread
gain spread [unit]

◆ getGainSpread() [2/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getGainSpread ( int NPE) const
inline

Get gain spread for given number of photo-electrons.

Parameters
NPEnumber of photo-electrons
Returns
gain spread

Definition at line 341 of file JPMTAnalogueSignalProcessor.hh.

342 {
343 return sqrt((double) NPE) * getGainSpread();
344 }
double getGainSpread() const
Get gain spread for given number of photo-electrons.

◆ getUnderamplifiedGain() [1/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getUnderamplifiedGain ( ) const
inline

Get gain of underamplified pulses.

Returns
gain of underamplified pulses

Definition at line 352 of file JPMTAnalogueSignalProcessor.hh.

353 {
354 return gain * gainSpread * gainSpread;
355 }

◆ getUnderamplifiedGain() [2/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getUnderamplifiedGain ( int NPE) const
inline

Get gain of underamplified pulses.

Parameters
NPEnumber of photo-electrons
Returns
gain of underamplified pulses

Definition at line 364 of file JPMTAnalogueSignalProcessor.hh.

365 {
366 return ((double) NPE) * getUnderamplifiedGain();
367 }
double getUnderamplifiedGain() const
Get gain of underamplified pulses.

◆ getUnderamplifiedGainSpread() [1/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getUnderamplifiedGainSpread ( ) const
inline

Get gain spread of underamplified pulses.

Returns
gain spread of underamplified pulses

Definition at line 375 of file JPMTAnalogueSignalProcessor.hh.

376 {
377 return sqrt(gain) * gainSpread * gainSpread;
378 }

◆ getUnderamplifiedGainSpread() [2/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getUnderamplifiedGainSpread ( int NPE) const
inline

Get gain spread of underamplified pulses.

Parameters
NPEnumber of photo-electrons
Returns
gain spread of underamplified pulses

Definition at line 387 of file JPMTAnalogueSignalProcessor.hh.

388 {
389 return sqrt((double) NPE) * getUnderamplifiedGainSpread();
390 }
double getUnderamplifiedGainSpread() const
Get gain spread of underamplified pulses.

◆ setPMTParameters()

void JDETECTOR::JPMTAnalogueSignalProcessor::setPMTParameters ( const JPMTParameters & parameters)
inline

Set PMT parameters.

Parameters
parametersPMT parameters

Definition at line 398 of file JPMTAnalogueSignalProcessor.hh.

399 {
400 static_cast<JPMTParameters&>(*this).setPMTParameters(parameters);
401
402 configure();
403 }

◆ getThresholdDomain()

JThresholdDomain JDETECTOR::JPMTAnalogueSignalProcessor::getThresholdDomain ( const double npe) const
inline

Get threshold domain.

Parameters
npenumber of photo-electrons
Returns
threshold domain

Definition at line 429 of file JPMTAnalogueSignalProcessor.hh.

430 {
431 if (npe > threshold) {
432
433 return ABOVE_THRESHOLD;
434
435 } else if (npe > threshold - thresholdBand) {
436
437 return THRESHOLDBAND;
438
439 } else {
440
441 return BELOW_THRESHOLD;
442 }
443 }

◆ applyQE()

virtual bool JDETECTOR::JPMTAnalogueSignalProcessor::applyQE ( ) const
inlineoverridevirtual

Apply relative QE.

Returns
true if accepted; false if rejected

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 451 of file JPMTAnalogueSignalProcessor.hh.

452 {
453 if (QE <= 0.0)
454 return false;
455 else if (QE < 1.0)
456 return gRandom->Rndm() < QE;
457 else
458 return true;
459 }
double QE
relative quantum efficiency

◆ getRandomTime()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getRandomTime ( const double t_ns) const
inlineoverridevirtual

Get randomised time according transit-time distribution.

Parameters
t_nstime [ns]
Returns
time [ns]

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 468 of file JPMTAnalogueSignalProcessor.hh.

469 {
470 if (TTS_ns < 0.0)
471 return t_ns + getTransitTime(gRandom->Rndm(), getType());
472 else if (TTS_ns > 0.0)
473 return gRandom->Gaus(t_ns, TTS_ns);
474 else
475 return t_ns;
476 }
int getType() const
Get type for for time-slewing correction.
double TTS_ns
transition time spread [ns]
JDETECTOR::JTransitTimeGenerator_t getTransitTime
Function object to generate transit time.

◆ compare()

virtual bool JDETECTOR::JPMTAnalogueSignalProcessor::compare ( const JPhotoElectron & first,
const JPhotoElectron & second ) const
inlineoverridevirtual

Compare arrival times of photo-electrons.

This implementation uses the internal rise time as two photo-electron resolution.

Two (or more) photo-electrons are merged if they are comparable.

Parameters
firstfirst photo-electron
secondsecond photo-electron
Returns
true if arrival times of photo-electrons are within two photo-electron resolution; else false

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 489 of file JPMTAnalogueSignalProcessor.hh.

490 {
491 return second.t_ns < first.t_ns + riseTime_ns;
492 }

◆ getRandomCharge()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getRandomCharge ( const int NPE) const
inlineoverridevirtual

Get randomised charge according to gain and gain spread.

Parameters
NPEnumber of photo-electrons
Returns
number of photo-electrons

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 501 of file JPMTAnalogueSignalProcessor.hh.

502 {
503 if (NPE > 0) {
504
505 if (gainSpread > 0.0) {
506
507 double q;
508
509 do {
510
511 if (PunderAmplified <= 0.0) {
512
513 const double mu = NPE * gain;
514 const double sigma = getGainSpread(NPE);
515
516 q = gRandom->Gaus(mu,sigma);
517
518 } else if (PunderAmplified < 1.0) {
519
520 // Determine which contribution to sample from
521 // Method uses inverse transform sampling for a binomial distribution
522
523 const double X = gRandom->Uniform();
524 double sum_p = 0.0;
525 double weight = pow(1-PunderAmplified, NPE);
526 int k = 0; // k underamplified photo-electrons
527
528 for (; k <= NPE; ++k) {
529
530 sum_p += weight;
531 if (sum_p > X) { break; }
532
533 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
534 }
535
536 // Sample from chosen contribution
537 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
538 const double sigma = gainSpread * sqrt(mu);
539
540 q = gRandom->Gaus(mu,sigma);
541
542 } else {
543
544 const double mu = getUnderamplifiedGain(NPE);
545 const double sigma = getUnderamplifiedGainSpread(NPE);
546
547 q = gRandom->Gaus(mu,sigma);
548 }
549
550 } while (q < 0.0);
551
552 return q;
553
554 } else {
555
556 return NPE * gain;
557 }
558
559 } else {
560
561 return 0.0;
562 }
563 }
T pow(const T &x, const double y)
Power .
Definition JMath.hh:97

◆ getChargeProbability() [1/2]

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getChargeProbability ( const double npe,
const int NPE ) const
inlineoverridevirtual

Get probability density for given charge.

The normalisation is from (threshold-thresholdband) to infinity.

Parameters
npeobserved number of photo-electrons
NPEtrue number of photo-electrons
Returns
probability [npe^-1]

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 574 of file JPMTAnalogueSignalProcessor.hh.

575 {
576 if ((NPE > 0) && (getThresholdDomain(npe) > BELOW_THRESHOLD)) {
577
578 if (PunderAmplified <= 0.0) {
579
580 const double mu = NPE * gain;
581 const double sigma = getGainSpread(NPE);
582
583 if (sigma > 0.0) {
584
585 const double prob = JMATH::Gauss(npe, mu, sigma);
586 const double norm = 0.5 * erfc(((threshold-thresholdBand) - mu) / sqrt(2.0) / sigma);
587
588 return prob / norm;
589
590 } else if (mu >= threshold - thresholdBand) {
591
592 return 1.0;
593
594 } else {
595
596 return 0.0;
597 }
598
599 } else if (PunderAmplified < 1.0) {
600
601 double norm = 0.0;
602 double prob = 0.0;
603 double weight = pow(1-PunderAmplified, NPE);
604
605 for (int k = 0; k <= NPE; ++k) { // k underamplified photo-electrons
606
607 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
608 const double sigma = gainSpread * sqrt(mu);
609
610 if (sigma > 0.0) {
611
612 prob += weight * JMATH::Gauss(npe, mu, sigma);
613 norm += weight * (0.5 * erfc(((threshold-thresholdBand) - mu) / sqrt(2.0) / sigma));
614
615 } else if (mu >= threshold - thresholdBand) {
616
617 prob += weight;
618 norm += weight;
619
620 } else {
621
622 return 0.0;
623 }
624
625 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
626 }
627
628 return prob / norm;
629
630 } else {
631
632 const double mu = getUnderamplifiedGain(NPE);
633 const double sigma = getUnderamplifiedGainSpread(NPE);
634
635 if (sigma > 0.0) {
636
637 const double prob = JMATH::Gauss(npe, mu, sigma);
638 const double norm = 0.5 * erfc(((threshold-thresholdBand) - mu) / sqrt(2.0) / sigma);
639
640 return prob / norm;
641
642 } else if (mu >= threshold - thresholdBand) {
643
644 return 1.0;
645
646 } else {
647
648 return 0.0;
649 }
650 }
651
652 } else {
653
654 return 0.0;
655 }
656 }
double Gauss(const double x, const double sigma)
Normalised Gauss function.
JThresholdDomain getThresholdDomain(const double npe) const
Get threshold domain.

◆ getChargeProbability() [2/2]

double JDETECTOR::JPMTAnalogueSignalProcessor::getChargeProbability ( const double npe,
const int NPE,
const double normTh ) const
inline

Get probability density for given charge.

The normalisation is from a configurable threshold to infinity.

Parameters
npeobserved number of photo-electrons
NPEtrue number of photo-electrons
normThnormalisation threshold
Returns
probability [npe^-1]

Definition at line 667 of file JPMTAnalogueSignalProcessor.hh.

668 {
669 if ((NPE > 0) && (getThresholdDomain(npe) > BELOW_THRESHOLD)) {
670
671 double minCharge = normTh;
672 const double th = threshold - thresholdBand;
673
674 if (minCharge < th) {minCharge = th;}
675
676 if (PunderAmplified <= 0.0) {
677
678 const double mu = NPE * gain;
679 const double sigma = getGainSpread(NPE);
680
681 if (sigma > 0.0) {
682
683 const double prob = JMATH::Gauss(npe, mu, sigma);
684 const double norm = 0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma);
685
686 return prob / norm;
687
688 } else if (mu >= normTh) {
689
690 return 1.0;
691
692 } else {
693
694 return 0.0;
695 }
696
697 } else if (PunderAmplified < 1.0) {
698
699 double norm = 0.0;
700 double prob = 0.0;
701 double weight = pow(1-PunderAmplified, NPE);
702
703 for (int k = 0; k <= NPE; ++k) { // k underamplified photo-electrons
704
705 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
706 const double sigma = gainSpread * sqrt(mu);
707
708 if (sigma > 0.0) {
709
710 prob += weight * JMATH::Gauss(npe, mu, sigma);
711 norm += weight * (0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma));
712
713 } else if (mu >= normTh) {
714
715 prob += weight;
716 norm += weight;
717
718 } else {
719
720 return 0.0;
721 }
722
723 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
724 }
725
726 return prob / norm;
727
728 } else {
729
730 const double mu = getUnderamplifiedGain(NPE);
731 const double sigma = getUnderamplifiedGainSpread(NPE);
732
733 if (sigma > 0.0) {
734
735 const double prob = JMATH::Gauss(npe, mu, sigma);
736 const double norm = 0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma);
737
738 return prob / norm;
739
740 } else if (mu >= normTh) {
741
742 return 1.0;
743
744 } else {
745
746 return 0.0;
747 }
748 }
749
750 } else {
751
752 return 0.0;
753 }
754 }

◆ getIntegralOfChargeProbability() [1/4]

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfChargeProbability ( const double xmin,
const double xmax,
const int NPE ) const
inline

Get integral of probability.

The normalisation is from (threshold-thresholdband) to infinity.

Parameters
xminminimum number of photo-electrons
xmaxmaximum number of photo-electrons
NPEtrue number of photo-electrons
Returns
probability

Definition at line 766 of file JPMTAnalogueSignalProcessor.hh.

767 {
768 if (NPE > 0) {
769
770 double zmin = xmin;
771 double zmax = xmax;
772
773 const double th = threshold - thresholdBand;
774
775 if (zmin < th) { zmin = th; }
776 if (zmax < th) { zmax = th; }
777
778 if (PunderAmplified <= 0.0) {
779
780 const double mu = NPE * gain;
781 const double sigma = getGainSpread(NPE);
782
783 if (sigma > 0.0) {
784
785 const double cumulP = (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
786 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
787 const double norm = 0.5 * erfc((th - mu) / sqrt(2.0) / sigma);
788
789 return cumulP / norm;
790
791 } else if ((mu >= zmin) && (mu <= zmax)) {
792
793 return 1.0;
794
795 } else {
796
797 return 0.0;
798 }
799
800 } else if (PunderAmplified < 1.0) {
801
802 double cumulP = 0.0;
803 double norm = 0.0;
804 double weight = pow(1.0 - PunderAmplified, NPE);
805
806 for (int k = 0; k <= NPE; ++k) { // k underamplified photo-electrons
807
808 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
809 const double sigma = gainSpread * sqrt(mu);
810
811 if (sigma > 0.0) {
812
813 cumulP += weight * (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
814 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
815 norm += weight * (0.5 * erfc((th - mu) / sqrt(2.0) / sigma));
816
817 } else if ((mu >= zmin) && (mu <= zmax)) {
818
819 cumulP += weight;
820 norm += weight;
821
822 } else {
823
824 return 0.0;
825 }
826
827 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
828 }
829
830 return cumulP / norm;
831
832 } else {
833
834 const double mu = getUnderamplifiedGain(NPE);
835 const double sigma = getUnderamplifiedGainSpread(NPE);
836
837 if (sigma > 0.0) {
838
839 const double cumulP = (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
840 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
841 const double norm = 0.5 * erfc((th - mu) / sqrt(2.0) / sigma);
842
843 return cumulP / norm;
844
845 } else if ((mu >= zmin) && (mu <= zmax)) {
846
847 return 1.0;
848
849 } else {
850
851 return 0.0;
852 }
853 }
854
855 } else {
856
857 return 0.0;
858 }
859 }

◆ getIntegralOfChargeProbability() [2/4]

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfChargeProbability ( const double xmin,
const double xmax,
const int NPE,
const double normTh ) const
inline

Get integral of probability.

The normalisation is from a configurable threshold to infinity.

Parameters
xminminimum number of photo-electrons
xmaxmaximum number of photo-electrons
NPEtrue number of photo-electrons
normThnormalisation threshold
Returns
probability

Definition at line 872 of file JPMTAnalogueSignalProcessor.hh.

873 {
874 if (NPE > 0) {
875
876 double minCharge = normTh;
877 const double th = threshold - thresholdBand;
878
879 if (minCharge < th) {minCharge = th;}
880
881 double zmin = xmin;
882 double zmax = xmax;
883
884 if (zmin < minCharge) { zmin = minCharge; }
885 if (zmax < minCharge) { zmax = minCharge; }
886
887 if (PunderAmplified <= 0.0) {
888
889 const double mu = NPE * gain;
890 const double sigma = getGainSpread(NPE);
891
892 if (sigma > 0.0) {
893
894 const double cumulP = (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
895 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
896 const double norm = 0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma);
897
898 return cumulP / norm;
899
900 } else if ((mu >= zmin) && (mu <= zmax)) {
901
902 return 1.0;
903
904 } else {
905
906 return 0.0;
907 }
908
909 } else if (PunderAmplified < 1.0) {
910
911 double cumulP = 0.0;
912 double norm = 0.0;
913 double weight = pow(1.0 - PunderAmplified, NPE);
914
915 for (int k = 0; k <= NPE; ++k) { // k underamplified photo-electrons
916
917 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
918 const double sigma = gainSpread * sqrt(mu);
919
920 if (sigma > 0.0) {
921
922 cumulP += weight * (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
923 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
924 norm += weight * (0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma));
925
926 } else if ((mu >= zmin) && (mu <= zmax)) {
927
928 cumulP += weight;
929 norm += weight;
930
931 } else {
932
933 return 0.0;
934 }
935
936 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
937 }
938
939 return cumulP / norm;
940
941 } else {
942
943 const double mu = getUnderamplifiedGain(NPE);
944 const double sigma = getUnderamplifiedGainSpread(NPE);
945
946 if (sigma > 0.0) {
947
948 const double cumulP = (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma) -
949 0.5 * erfc((zmax - mu) / sqrt(2.0) / sigma));
950 const double norm = 0.5 * erfc((normTh - mu) / sqrt(2.0) / sigma);
951
952 return cumulP / norm;
953
954 } else if ((mu >= zmin) && (mu <= zmax)) {
955
956 return 1.0;
957
958 } else {
959
960 return 0.0;
961 }
962 }
963
964 } else {
965
966 return 0.0;
967 }
968 }

◆ getIntegralOfChargeProbability() [3/4]

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfChargeProbability ( const double xmin,
const int NPE ) const
inline

Get integral of probability.

The maximum number of photo-electrons is infinity. The normalisation is from (threshold-thresholdband) to infinity.

Parameters
xminminimum number of photo-electrons
NPEtrue number of photo-electrons
Returns
probability

Definition at line 980 of file JPMTAnalogueSignalProcessor.hh.

981 {
982 if (NPE > 0) {
983
984 double zmin = xmin;
985
986 const double th = threshold - thresholdBand;
987
988 if (zmin < th) { zmin = th; }
989
990 if (PunderAmplified <= 0.0) {
991
992 const double mu = NPE * gain;
993 const double sigma = getGainSpread(NPE);
994
995 if (sigma > 0.0) {
996
997 const double cumulP = 0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma);
998 const double norm = 0.5 * erfc((th - mu) / sqrt(2.0) / sigma);
999
1000 return cumulP / norm;
1001
1002 } else if (mu >= zmin) {
1003
1004 return 1.0;
1005
1006 } else {
1007
1008 return 0.0;
1009 }
1010
1011 } else if (PunderAmplified < 1.0) {
1012
1013 double cumulP = 0.0;
1014 double norm = 0.0;
1015 double weight = pow(1.0 - PunderAmplified, NPE);
1016
1017 for (int k = 0; k <= NPE; ++k) { // k underamplified photo-electrons
1018
1019 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
1020 const double sigma = gainSpread * sqrt(mu);
1021
1022 if (sigma > 0.0) {
1023
1024 cumulP += weight * (0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma));
1025 norm += weight * (0.5 * erfc((th - mu) / sqrt(2.0) / sigma));
1026
1027 } else if (mu >= zmin) {
1028
1029 cumulP += weight;
1030 norm += weight;
1031
1032 } else {
1033
1034 return 0.0;
1035 }
1036
1037 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
1038 }
1039
1040 return cumulP / norm;
1041
1042 } else {
1043
1044 const double mu = getUnderamplifiedGain(NPE);
1045 const double sigma = getGainSpread(NPE);
1046
1047 if (sigma > 0.0) {
1048
1049 const double cumulP = 0.5 * erfc((zmin - mu) / sqrt(2.0) / sigma);
1050 const double norm = 0.5 * erfc((th - mu) / sqrt(2.0) / sigma);
1051
1052 return cumulP / norm;
1053
1054 } else if (mu >= zmin) {
1055
1056 return 1.0;
1057
1058 } else {
1059
1060 return 0.0;
1061 }
1062 }
1063
1064 } else {
1065
1066 return 0.0;
1067 }
1068 }

◆ getIntegralOfChargeProbability() [4/4]

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfChargeProbability ( const JThresholdDomain domain,
const int NPE ) const
inline

Get integral of probability in specific threshold domain.

The normalisation is from (threshold-thresholdband) to infinity.

Parameters
domainthreshold domain
NPEtrue number of photo-electrons
Returns
probability

Definition at line 1079 of file JPMTAnalogueSignalProcessor.hh.

1080 {
1081 switch (domain) {
1082
1083 case ABOVE_THRESHOLD:
1085
1086 case THRESHOLDBAND:
1088
1089 default:
1090 return 0.0;
1091 }
1092 }
double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE) const
Get integral of probability.

◆ applyThreshold()

virtual bool JDETECTOR::JPMTAnalogueSignalProcessor::applyThreshold ( const double npe) const
inlineoverridevirtual

Apply threshold.

Parameters
npenumber of photo-electrons
Returns
true if pass; else false

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1101 of file JPMTAnalogueSignalProcessor.hh.

1102 {
1103 return getThresholdDomain(npe) > BELOW_THRESHOLD;
1104 }

◆ getRiseTime() [2/2]

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getRiseTime ( const double npe) const
inlineoverridevirtual

Get time to reach threshold.

Note that the rise time is defined to be zero for a one photo-electron signal.

Parameters
npenumber of photo-electrons
Returns
time [ns]

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1115 of file JPMTAnalogueSignalProcessor.hh.

1116 {
1117 if (slewing) {
1118
1119 switch (getThresholdDomain(npe)) {
1120
1121 case THRESHOLDBAND:
1122 return ((getRiseTime(npe, getTH0()) - getRiseTime(npe, threshold-thresholdBand)) -
1123 (getRiseTime(1.0, getTH0()) - getRiseTime(1.0, threshold-thresholdBand))) + this->mean_ns;
1124
1125 case ABOVE_THRESHOLD:
1126 return ((getRiseTime(npe, getTH0()) - getRiseTime(npe, threshold)) -
1127 (getRiseTime(1.0, getTH0()) - getRiseTime(1.0, threshold)));
1128
1129 default:
1130 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::getRiseTime: Invalid charge " << npe);
1131 }
1132
1133 } else {
1134
1135 return 0.0;
1136 }
1137 }
double mean_ns
mean time-over-threshold of threshold-band hits [ns]
bool slewing
time slewing of analogue signal
double getRiseTime(const double npe, const double th) const
Get time to pass from threshold to top of analogue pulse.

◆ getTimeOverThreshold()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getTimeOverThreshold ( const double npe) const
inlineoverridevirtual

Get time-over-threshold (ToT).

Parameters
npenumber of photo-electrons
Returns
ToT [ns]

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1146 of file JPMTAnalogueSignalProcessor.hh.

1147 {
1148 switch (getThresholdDomain(npe)) {
1149
1150 case THRESHOLDBAND: {
1151
1152 return gRandom->Gaus(mean_ns, sigma_ns);
1153 }
1154
1155 case ABOVE_THRESHOLD: {
1156
1157 double tot = 0.0;
1158
1159 if (npe*y1 <= threshold) {
1160
1161 tot += getRiseTime(npe, threshold); // Gaussian
1162 tot += getRiseTime(npe, threshold); // Gaussian
1163
1164 } else if (npe <= getStartOfLinearisation()) {
1165
1166 tot += getRiseTime (npe, threshold); // Gaussian
1167 tot += getDecayTime(npe, threshold); // exponential
1168
1169 } else {
1170
1171 tot += getRiseTime (getStartOfLinearisation(), threshold); // Gaussian
1172 tot += getDecayTime(getStartOfLinearisation(), threshold); // exponential
1173
1174 tot += slope * (npe - getStartOfLinearisation()); // linear
1175 }
1176
1177 return applySaturation(tot);
1178 }
1179
1180 default: {
1181
1182 THROW(JValueOutOfRange, "JPMTAnalogueSignalProcessor::getTimeOverThreshold: Invalid charge " << npe);
1183 }}
1184 }
double sigma_ns
time-over-threshold standard deviation of threshold-band hits [ns]
double applySaturation(const double tot_ns) const
Get time-over-threshold with saturation.
double getStartOfLinearisation() const
Get transition point from a model-dependent to linear relation between time-over-threshold and number...

◆ getDerivative()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getDerivative ( const double npe) const
inlineoverridevirtual

Get derivative of number of photo-electrons to time-over-threshold.

Parameters
npenumber of photo-electrons
Returns
dnpe/dToT [ns^-1]

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1193 of file JPMTAnalogueSignalProcessor.hh.

1194 {
1195 switch (getThresholdDomain(npe)) {
1196
1197 case ABOVE_THRESHOLD: {
1198
1199 const double tot_ns = getTimeOverThreshold(npe);
1200
1201 if (tot_ns < saturation) {
1202
1203 const double z = riseTime_ns / sqrt(2.0 * log(npe/threshold));
1204
1205 double y = 0.0;
1206
1207 if (npe*y1 > threshold) {
1208
1209 if (npe <= getStartOfLinearisation())
1210 y = npe / (z + decayTime_ns); // Gaussian + exponential
1211 else
1212 y = 1.0 / slope; // linear
1213
1214 } else {
1215
1216 y = npe / (2.0 * z); // Gaussian + Gaussian
1217 }
1218
1220
1221 } else {
1222
1223 return 0.0;
1224 }
1225 }
1226
1227 default:
1228 return 0.0;
1229 }
1230 }
double getDerivativeOfSaturation(const double tot_ns) const
Get derivative of saturation factor.
double removeSaturation(const double tot_ns) const
Get time-over-threshold without saturation.
virtual double getTimeOverThreshold(const double npe) const override
Get time-over-threshold (ToT).

◆ getSurvivalProbability()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getSurvivalProbability ( const int NPE) const
inlineoverridevirtual

Probability that a hit survives the simulation of the PMT.

The survival probability takes into account the number of photo-electrons, the analogue signal of the PMT and the threshold of the discriminator.

Parameters
NPEnumber of photo-electrons
Returns
probability

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1240 of file JPMTAnalogueSignalProcessor.hh.

1241 {
1242 if (NPE > 0) {
1243
1244 if (QE <= 0.0) {
1245
1246 return 0.0;
1247
1248 } else if (QE < 1.0) {
1249
1250 double P = 0.0;
1251
1252 for (int i = 1; i <= NPE; ++i) { // i corresponds to number of photo-electrons passing relative QE
1253
1254 const double p = JMATH::binomial(NPE, i) * pow(QE, i) * pow(1.0 - QE, NPE - i);
1255
1256 P += p * getThresholdProbability(NPE);
1257 }
1258
1259 return P;
1260
1261 } else {
1262
1263 return getThresholdProbability(NPE);
1264 }
1265
1266 } else {
1267
1268 return 0.0;
1269 }
1270 }
double binomial(const size_t n, const size_t k)
Binomial function.
virtual double getThresholdProbability(const int NPE) const override
Probability that a hit survives the threshold of the PMT.

◆ getThresholdProbability()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getThresholdProbability ( const int NPE) const
inlineoverridevirtual

Probability that a hit survives the threshold of the PMT.

Parameters
NPEnumber of photo-electrons
Returns
probability

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1279 of file JPMTAnalogueSignalProcessor.hh.

1280 {
1281 if (NPE > 0) {
1282
1283 if (PunderAmplified <= 0.0) {
1284
1285 const double mu = NPE * gain;
1286 const double sigma = getGainSpread(NPE);
1287
1288 if (sigma > 0.0) {
1289
1290 const double Ptotal = 0.5 * erfc((0.0 - mu) / (sqrt(2.0) * sigma));
1291 const double Pabove = 0.5 * erfc((threshold - thresholdBand - mu) / (sqrt(2.0) * sigma));
1292
1293 return Pabove / Ptotal;
1294
1295 } else if (mu >= threshold - thresholdBand) {
1296
1297 return 1.0;
1298
1299 } else {
1300
1301 return 0.0;
1302 }
1303
1304 } else if (PunderAmplified < 1.0) {
1305
1306 double Ptotal = 0.0;
1307 double Pabove = 0.0;
1308 double weight = pow(1.0 - PunderAmplified, NPE); // binomial weight - start with all photo-electrons nominal
1309
1310 for (int k = 0; k <= NPE; ++k) { // NPE-k nominal photo-electrons and k underamplified photo-electrons
1311
1312 const double mu = (NPE-k) * gain + (k) * getUnderamplifiedGain();
1313 const double sigma = gainSpread * sqrt(mu);
1314
1315 if (sigma > 0.0) {
1316
1317 Ptotal += weight * 0.5 * erfc((0.0 - mu) / (sqrt(2.0) * sigma));
1318 Pabove += weight * 0.5 * erfc((threshold - thresholdBand - mu) / (sqrt(2.0) * sigma));
1319
1320 } else if (mu >= threshold - thresholdBand) {
1321
1322 Ptotal += weight;
1323 Pabove += weight;
1324 }
1325
1326 weight *= ((double) (NPE-k) / ((double) (k+1))) * PunderAmplified / (1.0 - PunderAmplified);
1327 }
1328
1329 return Pabove / Ptotal;
1330
1331 } else {
1332
1333 const double mu = getUnderamplifiedGain(NPE);
1334 const double sigma = getUnderamplifiedGainSpread(NPE);
1335
1336 if (sigma > 0.0) {
1337
1338 const double Ptotal = 0.5 * erfc((0.0 - mu) / (sqrt(2.0) * sigma));
1339 const double Pabove = 0.5 * erfc((threshold - thresholdBand - mu) / (sqrt(2.0) * sigma));
1340
1341 return Pabove / Ptotal;
1342
1343 } else if (mu >= threshold - thresholdBand) {
1344
1345 return 1.0;
1346
1347 } else {
1348
1349 return 0.0;
1350 }
1351 }
1352
1353 } else {
1354
1355 return 0.0;
1356 }
1357 }

◆ getNPE()

virtual double JDETECTOR::JPMTAnalogueSignalProcessor::getNPE ( const double tot_ns) const
inlineoverridevirtual

Get number of photo-electrons.

Parameters
tot_nstime-over-threshold with saturation [ns]
Returns
number of photo-electrons

Reimplemented from JDETECTOR::JPMTSignalProcessorInterface.

Definition at line 1366 of file JPMTAnalogueSignalProcessor.hh.

1367 {
1368 if (tot_ns >= saturation) {
1369 return std::numeric_limits<double>::max();
1370 }
1371
1372 const double tot = removeSaturation(tot_ns);
1373 const double TOT = (getRiseTime (getStartOfLinearisation(), threshold) +
1375
1376 if (tot <= 2*getRiseTime(threshold/y1,threshold)) { // Gaussian + Gaussian
1377
1378 return threshold * exp(tot*tot/riseTime_ns/riseTime_ns/8.0);
1379
1380 } else if (tot <= TOT) { // Gaussian + Exponential
1381
1382 const double a = decayTime_ns;
1383 const double b = sqrt(2.0) * riseTime_ns;
1384 const double c = -(decayTime_ns*log(y1) + tot);
1385 const double z = (-b + sqrt(b*b - 4*a*c)) / (2*a);
1386
1387 return threshold * exp(z*z);
1388
1389 } else { // linear
1390
1391 return getStartOfLinearisation() + (tot - TOT) / slope;
1392 }
1393 }

◆ getTimeOverThresholdProbability()

double JDETECTOR::JPMTAnalogueSignalProcessor::getTimeOverThresholdProbability ( const double tot_ns,
const int NPE ) const
inline

Get probability of having a pulse with specific time-over-threshold.

Parameters
tot_nstime-over-threshold with saturation [ns]
NPEtrue number of photo-electrons
Returns
probability [ns^-1]

Definition at line 1403 of file JPMTAnalogueSignalProcessor.hh.

1404 {
1405 if (tot_ns < saturation) {
1406
1407 const double PaboveTh = getIntegralOfChargeProbability(threshold, NPE);
1408 const double npe = getNPE(tot_ns);
1409 const double y = getChargeProbability(npe, NPE, threshold);
1410 const double v = getDerivative(npe);
1411 const double RaboveTh = PaboveTh * y * v;
1412
1413 const double PthBand = getIntegralOfChargeProbability(THRESHOLDBAND, NPE);
1414 const double RthBand = PthBand * getNormalisedGauss(tot_ns, mean_ns, sigma_ns, 0, saturation);
1415
1416 return RaboveTh + RthBand;
1417
1418 } else {
1419
1420 return 0.0;
1421 }
1422 }
virtual double getChargeProbability(const double npe, const int NPE) const override
Get probability density for given charge.
virtual double getNPE(const double tot_ns) const override
Get number of photo-electrons.
double getNormalisedGauss(const double x, const double x0, const double sigma, const double normXmin, const double normXmax) const
Gauss function normalised to a configurable domain.

◆ getIntegralOfTimeOverThresholdProbability()

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfTimeOverThresholdProbability ( const double Tmin,
const double Tmax,
const int NPE ) const
inline

Get cumulative probability of time-over-threshold distribution.

Parameters
Tminminimum time-over-threshold (with saturation) [ns]
Tmaxmaximum time-over-threshold (with saturation) [ns]
NPEtrue number of photo-electrons
Returns
probability [ns^-1]

Definition at line 1433 of file JPMTAnalogueSignalProcessor.hh.

1434 {
1435 double Xmin = Tmin;
1436 double Xmax = Tmax;
1437
1438 if (Tmin > saturation) {Xmin = saturation;}
1439 if (Tmax > saturation) {Xmax = saturation;}
1440
1441 const double PaboveTh = getIntegralOfChargeProbability(ABOVE_THRESHOLD, NPE);
1442 const double IaboveTh = PaboveTh * getIntegralOfChargeProbability(getNPE(Xmin), getNPE(Xmax), NPE, threshold);
1443
1444 const double PthBand = getIntegralOfChargeProbability(THRESHOLDBAND, NPE);
1445 const double IthBand = PthBand * getIntegralOfNormalisedGauss(Xmin, Xmax, mean_ns, sigma_ns, 0, saturation);
1446
1447 return IaboveTh + IthBand;
1448 }
double getIntegralOfNormalisedGauss(const double xmin, const double xmax, const double x0, const double sigma, const double normXmin, const double normXmax) const
Integral of Gauss function normalised to a configurable domain.

◆ getTH0()

static double JDETECTOR::JPMTAnalogueSignalProcessor::getTH0 ( )
inlinestatic

Get lower threshold for rise time evaluation.

Returns
threshold [npe]

Definition at line 1456 of file JPMTAnalogueSignalProcessor.hh.

1457 {
1458 return 0.1;
1459 }

◆ getTH1()

static double JDETECTOR::JPMTAnalogueSignalProcessor::getTH1 ( )
inlinestatic

Get upper threshold for rise time evaluation.

Returns
threshold [npe]

Definition at line 1467 of file JPMTAnalogueSignalProcessor.hh.

1468 {
1469 return 0.9;
1470 }

◆ getNormalisedGauss()

double JDETECTOR::JPMTAnalogueSignalProcessor::getNormalisedGauss ( const double x,
const double x0,
const double sigma,
const double normXmin,
const double normXmax ) const
inlineprivate

Gauss function normalised to a configurable domain.

Parameters
xx
x0central value
sigmasigma
normXminnormalisation lower limit
normXmaxnormalisation upper limit
Returns
probability

Definition at line 1496 of file JPMTAnalogueSignalProcessor.hh.

1497 {
1498 const double prob = JMATH::Gauss(x, x0, sigma);
1499 const double norm = (0.5 * erfc((normXmin - x0) / sqrt(2.0) / sigma) -
1500 0.5 * erfc((normXmax - x0) / sqrt(2.0) / sigma));
1501 return prob / norm;
1502 }

◆ getIntegralOfNormalisedGauss()

double JDETECTOR::JPMTAnalogueSignalProcessor::getIntegralOfNormalisedGauss ( const double xmin,
const double xmax,
const double x0,
const double sigma,
const double normXmin,
const double normXmax ) const
inlineprivate

Integral of Gauss function normalised to a configurable domain.

Parameters
xminintegral lower limit
xmaxintegral upper limit
x0central value
sigmasigma
normXminnormalisation lower limit
normXmaxnormalisation upper limit
Returns
probability

Definition at line 1516 of file JPMTAnalogueSignalProcessor.hh.

1517 {
1518 const double numerator = (0.5 * erfc((xmin - x0) / sqrt(2.0) / sigma_ns) -
1519 0.5 * erfc((xmax - x0) / sqrt(2.0) / sigma_ns));
1520 const double denominator = (0.5 * erfc((normXmin - x0) / sqrt(2.0) / sigma_ns) -
1521 0.5 * erfc((normXmax - x0) / sqrt(2.0) / sigma_ns));
1522 return numerator / denominator;
1523 }

◆ operator()()

void JDETECTOR::JPMTSignalProcessorInterface::operator() ( const JCalibration & calibration,
const JPMTData< JPMTSignal > & input,
JPMTData< JPMTPulse > & output ) const
inlineinherited

Process hits.

Two (or more) photo-electrons are combined if they are comparable according method compare.
Two (or more) consecutive hits hits maybe merged (according method merge).
A PMT signal with negative number of photo-electrons is not subjected to the quantum efficiency and transit-time distribution.
This feature is used to simulate the singles rate of a PMT when the measured QE is zero.

Parameters
calibrationPMT calibration
inputPMT signals
outputPMT hits

Definition at line 91 of file JPMTSignalProcessorInterface.hh.

94 {
95 // apply transition time distribution to each photo-electron.
96
97 JPMTData<JPhotoElectron> buffer;
98
99 for (JPMTData<JPMTSignal>::const_iterator hit = input.begin(); hit != input.end(); ++hit) {
100
101 for (int i = 0; i < hit->npe; ++i) {
102 if (applyQE()) {
103 buffer.push_back(JPhotoElectron(getRandomTime(hit->t_ns)));
104 }
105 }
106
107 for (int i = 0; i > hit->npe; --i) {
108 buffer.push_back(JPhotoElectron(hit->t_ns));
109 }
110 }
111
112 if (!buffer.empty()) {
113
114 buffer.push_back(JPhotoElectron::getEndMarker());
115
116 buffer.sort();
117
118
119 // generate PMT hits from time sequence of photo-electrons.
120
121 for (JPMTData<JPhotoElectron>::const_iterator q = buffer.begin(), p = q++; q != buffer.end(); ++q) {
122
123 while (compare(*p,*q)) {
124 ++q;
125 }
126
127 const double npe = getRandomCharge(distance(p,q));
128
129 if (applyThreshold(npe)) {
130 output.push_back(JPMTPulse(putTime(p->t_ns + getRiseTime(npe), calibration), getTimeOverThreshold(npe)));
131 }
132
133 p = q;
134 }
135
136 // merge overlapping PMT hits.
137
138 merge(output);
139 }
140 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
std::vector< JElement_t >::const_iterator const_iterator
virtual bool applyQE() const
Apply relative QE.
virtual double getTimeOverThreshold(const double npe) const
Get time-over-threshold (ToT).
virtual double getRandomCharge(const int NPE) const
Get randomised charge according to gain and gain spread.
virtual bool applyThreshold(const double npe) const
Apply threshold.
virtual bool compare(const JPhotoElectron &first, const JPhotoElectron &second) const
Compare arrival times of photo-electrons.
virtual double getRiseTime(const double npe) const
Get time to reach threshold.
virtual double getRandomTime(const double t_ns) const
Get randomised time according transition time distribution.
virtual void merge(JPMTData< JPMTPulse > &data) const
Merging of PMT hits.
double putTime(const T &t1, const JCalibration &cal)
Get de-calibrated time.
static JPhotoElectron getEndMarker()
Get end marker.

◆ merge()

virtual void JDETECTOR::JPMTSignalProcessorInterface::merge ( JPMTData< JPMTPulse > & data) const
inlinevirtualinherited

Merging of PMT hits.

Hits with overlapping time-over-threshold signals should -de facto- be combined. In this, the leading edge is maintained and the time-over-threshold is set to the difference between the overall trailing and leading edges. As a result, the number of PMT hits may be reduced.

Parameters
dataPMT hits (I/O)

Definition at line 311 of file JPMTSignalProcessorInterface.hh.

312 {
313 using namespace std;
314
316
317 for (JPMTData<JPMTPulse>::iterator i = data.begin(); i != data.end(); ) {
318
319 double t1 = i->t_ns;
320 double t2 = i->t_ns + i->tot_ns;
321
322 while (++i != data.end() && i->t_ns < t2 + getTmin()) {
323 t2 = max(t2, i->t_ns + i->tot_ns);
324 }
325
326 out->t_ns = t1;
327 out->tot_ns = t2 - t1;
328
329 ++out;
330 }
331
332 data.resize(distance(data.begin(), out));
333 }
std::vector< JElement_t >::iterator iterator
static double getTmin()
Get two photo-electron resolution for time-over-threshold.

◆ getTmin()

static double JDETECTOR::JPMTSignalProcessorInterface::getTmin ( )
inlinestaticinherited

Get two photo-electron resolution for time-over-threshold.

Returns
minimal time [ns]

Definition at line 341 of file JPMTSignalProcessorInterface.hh.

342 {
343 return 1.0;
344 }

◆ getQmin()

static double JDETECTOR::JPMTSignalProcessorInterface::getQmin ( )
inlinestaticinherited

Get width of charge distribution.

Returns
width charge distribution [npe]

Definition at line 352 of file JPMTSignalProcessorInterface.hh.

353 {
354 return 1.0e-3;
355 }

◆ getPMTParameters()

const JPMTParameters & JDETECTOR::JPMTParameters::getPMTParameters ( ) const
inlineinherited

Get PMT parameters.

Returns
PMT parameters

Definition at line 112 of file JPMTParameters.hh.

113 {
114 return static_cast<const JPMTParameters&>(*this);
115 }

◆ is_valid()

bool JDETECTOR::JPMTParameters::is_valid ( ) const
inlineinherited

Check validity of PMT parameters.

Returns
true if valid; else false

Definition at line 134 of file JPMTParameters.hh.

135 {
136 if (this->QE < 0.0 ||
137 this->gain < 0.0 ||
138 this->gainSpread < 0.0 ||
139 this->threshold < 0.0 ||
140 this->thresholdBand < 0.0) {
141 return false;
142 }
143
144 return true;
145 }

◆ getType()

int JDETECTOR::JPMTParameters::getType ( ) const
inlineinherited

Get type for for time-slewing correction.

Returns
type

Definition at line 153 of file JPMTParameters.hh.

154 {
155 if (this->TTS_ns < 0.0)
156 return -lrint(this->TTS_ns);
157 else
158 return 0;
159 }

◆ getEquationParameters()

static JEquationParameters & JDETECTOR::JPMTParameters::getEquationParameters ( )
inlinestaticinherited

Get equation parameters.

Returns
equation parameters

Definition at line 209 of file JPMTParameters.hh.

210 {
211 static JEquationParameters equation("=", ",", "./", "#");
212
213 return equation;
214 }
Simple data structure to support I/O of equations (see class JLANG::JEquation).

◆ setEquationParameters()

static void JDETECTOR::JPMTParameters::setEquationParameters ( const JEquationParameters & equation)
inlinestaticinherited

Set equation parameters.

Parameters
equationequation parameters

Definition at line 222 of file JPMTParameters.hh.

223 {
224 getEquationParameters() = equation;
225 }
static JEquationParameters & getEquationParameters()
Get equation parameters.

◆ getProperties() [1/2]

JProperties JDETECTOR::JPMTParameters::getProperties ( const JEquationParameters & equation = JPMTParameters::getEquationParameters())
inlineinherited

Get properties of this class.

Parameters
equationequation parameters

Definition at line 233 of file JPMTParameters.hh.

234 {
235 return JPMTParametersHelper(*this, equation);
236 }

◆ getProperties() [2/2]

JProperties JDETECTOR::JPMTParameters::getProperties ( const JEquationParameters & equation = JPMTParameters::getEquationParameters()) const
inlineinherited

Get properties of this class.

Parameters
equationequation parameters

Definition at line 244 of file JPMTParameters.hh.

245 {
246 return JPMTParametersHelper(*this, equation);
247 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JPMTAnalogueSignalProcessor & object )
friend

Read PMT signal from input.

Parameters
ininput stream
objectPMT signal
Returns
input stream

Definition at line 413 of file JPMTAnalogueSignalProcessor.hh.

414 {
415 in >> static_cast<JPMTParameters&>(object);
416
417 object.configure();
418
419 return in;
420 }

Member Data Documentation

◆ decayTime_ns

double JDETECTOR::JPMTAnalogueSignalProcessor::decayTime_ns
protected

decay time [ns]

Definition at line 1474 of file JPMTAnalogueSignalProcessor.hh.

◆ t1

double JDETECTOR::JPMTAnalogueSignalProcessor::t1
protected

time at match point [ns]

Definition at line 1475 of file JPMTAnalogueSignalProcessor.hh.

◆ y1

double JDETECTOR::JPMTAnalogueSignalProcessor::y1
protected

amplitude at match point [npe]

Definition at line 1476 of file JPMTAnalogueSignalProcessor.hh.

◆ x1

double JDETECTOR::JPMTAnalogueSignalProcessor::x1
protected

Transition point from a logarithmic to a linear relation between time-over-threshold and number of photo-electrons.


Measurements by B. Schermer and R. Bruijn at Nikhef.

Definition at line 1482 of file JPMTAnalogueSignalProcessor.hh.

◆ QE

double JDETECTOR::JPMTParameters::QE
inherited

relative quantum efficiency

Definition at line 250 of file JPMTParameters.hh.

◆ gain

double JDETECTOR::JPMTParameters::gain
inherited

gain [unit]

Definition at line 251 of file JPMTParameters.hh.

◆ gainSpread

double JDETECTOR::JPMTParameters::gainSpread
inherited

gain spread [unit]

Definition at line 252 of file JPMTParameters.hh.

◆ riseTime_ns

double JDETECTOR::JPMTParameters::riseTime_ns
inherited

rise time of analogue pulse [ns]

Definition at line 253 of file JPMTParameters.hh.

◆ TTS_ns

double JDETECTOR::JPMTParameters::TTS_ns
inherited

transition time spread [ns]

Definition at line 254 of file JPMTParameters.hh.

◆ threshold

double JDETECTOR::JPMTParameters::threshold
inherited

threshold [npe]

Definition at line 255 of file JPMTParameters.hh.

◆ PunderAmplified

double JDETECTOR::JPMTParameters::PunderAmplified
inherited

probability of underamplified hit

Definition at line 256 of file JPMTParameters.hh.

◆ thresholdBand

double JDETECTOR::JPMTParameters::thresholdBand
inherited

threshold-band [npe]

Definition at line 257 of file JPMTParameters.hh.

◆ mean_ns

double JDETECTOR::JPMTParameters::mean_ns
inherited

mean time-over-threshold of threshold-band hits [ns]

Definition at line 258 of file JPMTParameters.hh.

◆ sigma_ns

double JDETECTOR::JPMTParameters::sigma_ns
inherited

time-over-threshold standard deviation of threshold-band hits [ns]

Definition at line 259 of file JPMTParameters.hh.

◆ slope

double JDETECTOR::JPMTParameters::slope
inherited

slope [ns/npe]

Definition at line 260 of file JPMTParameters.hh.

◆ saturation

double JDETECTOR::JPMTParameters::saturation
inherited

saturation [ns]

Definition at line 261 of file JPMTParameters.hh.

◆ slewing

bool JDETECTOR::JPMTParameters::slewing
inherited

time slewing of analogue signal

Definition at line 262 of file JPMTParameters.hh.


The documentation for this struct was generated from the following file: