Jpp 21.0.0-rc.1-88-g0130508c4
the software that should make you happy
Loading...
Searching...
No Matches
JPMTAnalogueSignalProcessor.hh
Go to the documentation of this file.
1#ifndef __JDETECTOR__JPMTANALOGUESIGNALPROCESSOR__
2#define __JDETECTOR__JPMTANALOGUESIGNALPROCESSOR__
3
4#include <istream>
5#include <cmath>
6#include <limits>
7
8#include "TRandom3.h"
9
10#include "JLang/JException.hh"
16
17/**
18 * \file
19 *
20 * PMT analogue signal processor.
21 * \author mdejong & bjjung & evancampenhout
22 */
23namespace JDETECTOR {
24
26
27
28 /**
29 * PMT analogue signal processor.
30 *
31 * This class provides for an implementation of the JDETECTOR::JPMTSignalProcessorInterface
32 * using a specific model for the analogue pulse of the PMT.\n
33 * In this, the leading edge of the analogue pulse from the PMT is assumed to be a Gaussian and the tail an exponential.\n
34 * The width of the Gaussian is referred to as the rise time and
35 * the inverse slope of the exponential to the decay time.\n
36 * The two functions are matched at a point where the values and first derivatives are identical.\n
37 *
38 * Note that the decay time is related to the rise time via the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.
39 *
40 * The charge distribution is assumed to be a Gaussian which is centered at the specified gain
41 * and truncated by the specified threshold.
42 *
43 * The transit times are generated according the specified spread as follows.
44 * - If the specified transit-time spread (TTS) is negative,
45 * the transit times are generated according to measurements (see method JDETECTOR::getTransitTime).\n
46 * In this, the negated integral value of the TTS corresponds to the option
47 * which in turn corresponds to the detector identifier of the measurements.
48 * - If the specified TTS is positive,
49 * the transit times are generated according a Gaussian with a sigma equals to the given TTS.
50 * - If the TTS is zero, the transit times are generated without any spread.
51 */
54 public JPMTParameters
55 {
56 /**
57 * Threshold domain specifiers
58 */
60 BELOW_THRESHOLD = -1, //!< below threshold
61 THRESHOLDBAND = 0, //!< inside threshold band
62 ABOVE_THRESHOLD = 2 //!< above threshold
63 };
64
65
66 /**
67 * Constructor.
68 *
69 * \param parameters PMT parameters
70 */
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 }
81
82
83 /**
84 * Configure internal parameters.
85 *
86 * This method provides the implementations for
87 * - matching of the leading edge of the analogue pulse (Gaussian) and the tail (exponential); and
88 * - determination of number of photo-electrons above which the time-over-threshold
89 * linearly depends on the number of photo-electrons (apart from saturation).
90 *
91 * Note that this method will throw an error if the value of the rise time (i.e.\ width of the Gaussian)
92 * is too large with respect to the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.
93 */
94 void configure()
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 }
168
169
170 /**
171 * Get decay time.
172 *
173 * \return decay time [ns]
174 */
175 double getDecayTime() const
176 {
177 return decayTime_ns;
178 }
179
180
181 /**
182 * Get time at transition point from Gaussian to exponential.
183 *
184 * \return time [ns]
185 */
186 double getT1() const
187 {
188 return t1;
189 }
190
191
192 /**
193 * Get amplitude at transition point from Gaussian to exponential.
194 *
195 * \return amplitude [npe]
196 */
197 double getY1() const
198 {
199 return y1;
200 }
201
202
203 /**
204 * Get transition point from a model-dependent to linear relation between time-over-threshold and number of photo-electrons.
205 *
206 * \return number of photo-electrons [npe]
207 */
209 {
210 return x1;
211 }
212
213
214 /**
215 * Get amplitude at given time for a one photo-electron pulse.
216 *
217 * \param t1_ns time [ns]
218 * \return amplitude [npe]
219 */
220 double getAmplitude(const double t1_ns) const
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 }
235
236
237 /**
238 * Get time to pass from threshold to top of analogue pulse.\n
239 * In this, the leading edge of the analogue pulse is assumed to be Gaussian.
240 *
241 * \param npe number of photo-electrons
242 * \param th threshold [npe]
243 * \return time [ns]
244 */
245 double getRiseTime(const double npe, const double th) const
246 {
247 return riseTime_ns * sqrt(2.0*log(npe/th)); // Gaussian
248 }
249
250
251 /**
252 * Get time to pass from top of analogue pulse to threshold.\n
253 * In this, the trailing edge of the analogue pulse is assumed to be exponential.
254 *
255 * \param npe number of photo-electrons
256 * \param th threshold [npe]
257 * \return time [ns]
258 */
259 double getDecayTime(const double npe, const double th) const
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 }
266
267
268 /**
269 * Get maximal rise time for given threshold.
270 *
271 * Note that the rise time is entirely constrained by the specification JDETECTOR::TIME_OVER_THRESHOLD_NS.
272 *
273 * \param th threshold [npe]
274 * \return rise time [ns]
275 */
276 static double getMaximalRiseTime(const double th)
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 }
283
284
285 /**
286 * Get time-over-threshold with saturation.
287 *
288 * \param tot_ns time-over-threshold without saturation
289 * \return time-over-threshold with saturation
290 */
291 double applySaturation(const double tot_ns) const
292 {
293 return saturation / sqrt(tot_ns*tot_ns + saturation*saturation) * tot_ns;
294 }
295
296
297 /**
298 * Get time-over-threshold without saturation.
299 *
300 * \param tot_ns time-over-threshold with saturation
301 * \return time-over-threshold without saturation
302 */
303 double removeSaturation(const double tot_ns) const
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 }
310
311
312 /**
313 * Get derivative of saturation factor.
314 *
315 * \param tot_ns time-over-threshold without saturation
316 * \return derivative of saturation factor
317 */
318 double getDerivativeOfSaturation(const double tot_ns) const
319 {
320 return saturation * saturation * saturation / ((saturation*saturation + tot_ns*tot_ns) * sqrt(saturation*saturation + tot_ns*tot_ns));
321 }
322
323
324 /**
325 * Get gain spread for given number of photo-electrons.
326 *
327 * \return gain spread
328 */
329 double getGainSpread() const
330 {
331 return sqrt(gain) * gainSpread;
332 }
333
334
335 /**
336 * Get gain spread for given number of photo-electrons.
337 *
338 * \param NPE number of photo-electrons
339 * \return gain spread
340 */
341 double getGainSpread(int NPE) const
342 {
343 return sqrt((double) NPE) * getGainSpread();
344 }
345
346
347 /**
348 * Get gain of underamplified pulses.
349 *
350 * \return gain of underamplified pulses
351 */
353 {
354 return gain * gainSpread * gainSpread;
355 }
356
357
358 /**
359 * Get gain of underamplified pulses.
360 *
361 * \param NPE number of photo-electrons
362 * \return gain of underamplified pulses
363 */
364 double getUnderamplifiedGain(int NPE) const
365 {
366 return ((double) NPE) * getUnderamplifiedGain();
367 }
368
369
370 /**
371 * Get gain spread of underamplified pulses.
372 *
373 * \return gain spread of underamplified pulses
374 */
376 {
377 return sqrt(gain) * gainSpread * gainSpread;
378 }
379
380
381 /**
382 * Get gain spread of underamplified pulses.
383 *
384 * \param NPE number of photo-electrons
385 * \return gain spread of underamplified pulses
386 */
387 double getUnderamplifiedGainSpread(int NPE) const
388 {
389 return sqrt((double) NPE) * getUnderamplifiedGainSpread();
390 }
391
392
393 /**
394 * Set PMT parameters.
395 *
396 * \param parameters PMT parameters
397 */
398 void setPMTParameters(const JPMTParameters& parameters)
399 {
400 static_cast<JPMTParameters&>(*this).setPMTParameters(parameters);
401
402 configure();
403 }
404
405
406 /**
407 * Read PMT signal from input.
408 *
409 * \param in input stream
410 * \param object PMT signal
411 * \return input stream
412 */
413 friend std::istream& operator>>(std::istream& in, JPMTAnalogueSignalProcessor& object)
414 {
415 in >> static_cast<JPMTParameters&>(object);
416
417 object.configure();
418
419 return in;
420 }
421
422
423 /**
424 * Get threshold domain.
425 *
426 * \param npe number of photo-electrons
427 * \return threshold domain
428 */
429 JThresholdDomain getThresholdDomain(const double npe) const
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 }
444
445
446 /**
447 * Apply relative QE.
448 *
449 * \return true if accepted; false if rejected
450 */
451 virtual bool applyQE() const override
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 }
460
461
462 /**
463 * Get randomised time according transit-time distribution.
464 *
465 * \param t_ns time [ns]
466 * \return time [ns]
467 */
468 virtual double getRandomTime(const double t_ns) const override
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 }
477
478
479 /**
480 * Compare arrival times of photo-electrons.
481 * This implementation uses the internal rise time as two photo-electron resolution.
482 *
483 * Two (or more) photo-electrons are merged if they are comparable.
484 *
485 * \param first first photo-electron
486 * \param second second photo-electron
487 * \return true if arrival times of photo-electrons are within two photo-electron resolution; else false
488 */
489 virtual bool compare(const JPhotoElectron& first, const JPhotoElectron& second) const override
490 {
491 return second.t_ns < first.t_ns + riseTime_ns;
492 }
493
494
495 /**
496 * Get randomised charge according to gain and gain spread.
497 *
498 * \param NPE number of photo-electrons
499 * \return number of photo-electrons
500 */
501 virtual double getRandomCharge(const int NPE) const override
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 }
564
565
566 /**
567 * Get probability density for given charge.
568 * The normalisation is from (threshold-thresholdband) to infinity.
569 *
570 * \param npe observed number of photo-electrons
571 * \param NPE true number of photo-electrons
572 * \return probability [npe^-1]
573 */
574 virtual double getChargeProbability(const double npe, const int NPE) const override
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 }
657
658 /**
659 * Get probability density for given charge.
660 * The normalisation is from a configurable threshold to infinity.
661 *
662 * \param npe observed number of photo-electrons
663 * \param NPE true number of photo-electrons
664 * \param normTh normalisation threshold
665 * \return probability [npe^-1]
666 */
667 double getChargeProbability(const double npe, const int NPE, const double normTh) const
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 }
755
756
757 /**
758 * Get integral of probability.
759 * The normalisation is from (threshold-thresholdband) to infinity.
760 *
761 * \param xmin minimum number of photo-electrons
762 * \param xmax maximum number of photo-electrons
763 * \param NPE true number of photo-electrons
764 * \return probability
765 */
766 double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE) const
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 }
860
861
862 /**
863 * Get integral of probability.
864 * The normalisation is from a configurable threshold to infinity.
865 *
866 * \param xmin minimum number of photo-electrons
867 * \param xmax maximum number of photo-electrons
868 * \param NPE true number of photo-electrons
869 * \param normTh normalisation threshold
870 * \return probability
871 */
872 double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE, const double normTh) const
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 }
969
970
971 /**
972 * Get integral of probability.
973 * The maximum number of photo-electrons is infinity.
974 * The normalisation is from (threshold-thresholdband) to infinity.
975 *
976 * \param xmin minimum number of photo-electrons
977 * \param NPE true number of photo-electrons
978 * \return probability
979 */
980 double getIntegralOfChargeProbability(const double xmin, const int NPE) const
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 }
1069
1070
1071 /**
1072 * Get integral of probability in specific threshold domain.
1073 * The normalisation is from (threshold-thresholdband) to infinity.
1074 *
1075 * \param domain threshold domain
1076 * \param NPE true number of photo-electrons
1077 * \return probability
1078 */
1079 double getIntegralOfChargeProbability(const JThresholdDomain domain, const int NPE) const
1080 {
1081 switch (domain) {
1082
1083 case ABOVE_THRESHOLD:
1085
1086 case THRESHOLDBAND:
1088
1089 default:
1090 return 0.0;
1091 }
1092 }
1093
1094
1095 /**
1096 * Apply threshold.
1097 *
1098 * \param npe number of photo-electrons
1099 * \return true if pass; else false
1100 */
1101 virtual bool applyThreshold(const double npe) const override
1102 {
1103 return getThresholdDomain(npe) > BELOW_THRESHOLD;
1104 }
1105
1106
1107 /**
1108 * Get time to reach threshold.
1109 *
1110 * Note that the rise time is defined to be zero for a one photo-electron signal.
1111 *
1112 * \param npe number of photo-electrons
1113 * \return time [ns]
1114 */
1115 virtual double getRiseTime(const double npe) const override
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 }
1138
1139
1140 /**
1141 * Get time-over-threshold (ToT).
1142 *
1143 * \param npe number of photo-electrons
1144 * \return ToT [ns]
1145 */
1146 virtual double getTimeOverThreshold(const double npe) const override
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 }
1185
1186
1187 /**
1188 * Get derivative of number of photo-electrons to time-over-threshold.
1189 *
1190 * \param npe number of photo-electrons
1191 * \return dnpe/dToT [ns^-1]
1192 */
1193 virtual double getDerivative(const double npe) const override
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
1219 return y / getDerivativeOfSaturation(removeSaturation(tot_ns));
1220
1221 } else {
1222
1223 return 0.0;
1224 }
1225 }
1226
1227 default:
1228 return 0.0;
1229 }
1230 }
1231
1232
1233 /**
1234 * Probability that a hit survives the simulation of the PMT.
1235 * The survival probability takes into account the number of photo-electrons, the analogue signal of the PMT and the threshold of the discriminator.
1236 *
1237 * \param NPE number of photo-electrons
1238 * \return probability
1239 */
1240 virtual double getSurvivalProbability(const int NPE) const override
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 }
1271
1272
1273 /**
1274 * Probability that a hit survives the threshold of the PMT.
1275 *
1276 * \param NPE number of photo-electrons
1277 * \return probability
1278 */
1279 virtual double getThresholdProbability(const int NPE) const override
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 }
1358
1359
1360 /**
1361 * Get number of photo-electrons.
1362 *
1363 * \param tot_ns time-over-threshold with saturation [ns]
1364 * \return number of photo-electrons
1365 */
1366 virtual double getNPE(const double tot_ns) const override
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 }
1394
1395
1396 /**
1397 * Get probability of having a pulse with specific time-over-threshold
1398 *
1399 * \param tot_ns time-over-threshold with saturation [ns]
1400 * \param NPE true number of photo-electrons
1401 * \return probability [ns^-1]
1402 */
1403 double getTimeOverThresholdProbability(const double tot_ns, const int NPE) const
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 }
1423
1424
1425 /**
1426 * Get cumulative probability of time-over-threshold distribution
1427 *
1428 * \param Tmin minimum time-over-threshold (with saturation) [ns]
1429 * \param Tmax maximum time-over-threshold (with saturation) [ns]
1430 * \param NPE true number of photo-electrons
1431 * \return probability [ns^-1]
1432 */
1433 double getIntegralOfTimeOverThresholdProbability(const double Tmin, const double Tmax, const int NPE) const
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 }
1449
1450
1451 /**
1452 * Get lower threshold for rise time evaluation.
1453 *
1454 * \return threshold [npe]
1455 */
1456 static double getTH0()
1457 {
1458 return 0.1;
1459 }
1460
1461
1462 /**
1463 * Get upper threshold for rise time evaluation.
1464 *
1465 * \return threshold [npe]
1466 */
1467 static double getTH1()
1468 {
1469 return 0.9;
1470 }
1471
1472 protected:
1473
1474 double decayTime_ns; //!< decay time [ns]
1475 double t1; //!< time at match point [ns]
1476 double y1; //!< amplitude at match point [npe]
1477 /**
1478 * Transition point from a logarithmic to a linear relation
1479 * between time-over-threshold and number of photo-electrons.\n
1480 * Measurements by B. Schermer and R. Bruijn at Nikhef.
1481 */
1482 double x1;
1483
1484 private:
1485
1486 /**
1487 * Gauss function normalised to a configurable domain.
1488 *
1489 * \param x x
1490 * \param x0 central value
1491 * \param sigma sigma
1492 * \param normXmin normalisation lower limit
1493 * \param normXmax normalisation upper limit
1494 * \return probability
1495 */
1496 double getNormalisedGauss(const double x, const double x0, const double sigma, const double normXmin, const double normXmax) const
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 }
1503
1504
1505 /**
1506 * Integral of Gauss function normalised to a configurable domain.
1507 *
1508 * \param xmin integral lower limit
1509 * \param xmax integral upper limit
1510 * \param x0 central value
1511 * \param sigma sigma
1512 * \param normXmin normalisation lower limit
1513 * \param normXmax normalisation upper limit
1514 * \return probability
1515 */
1516 double getIntegralOfNormalisedGauss(const double xmin, const double xmax, const double x0, const double sigma, const double normXmin, const double normXmax) const
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 }
1524 };
1525
1526
1527 /**
1528 * Get charge probability convoluted with a Poisson distribution.
1529 *
1530 * \param pmt PMT signal processor
1531 * \param npe measured number of photo-electrons
1532 * \param NPE expected number of photo-electrons
1533 * \param precision precision
1534 * \return probability
1535 */
1537 const double npe,
1538 const double NPE,
1539 const double precision = 1.0e-4)
1540 {
1541 int i = (int) (NPE - 5.0 * sqrt(NPE));
1542
1543 if (i < 1) {
1544 i = 1;
1545 }
1546
1547 double p = NPE * exp(-NPE) / (double) 1;
1548
1549 for (int __i = 1; __i != i; ++__i) {
1550 p *= NPE / __i;
1551 }
1552
1553 double P = 0.0;
1554
1555 for (double p0 = 0.0; (p >= p0 || p > precision); ++i, p0 = p, p *= NPE / (double) i) {
1556 P += pmt.getChargeProbability(npe, i) * p;
1557 }
1558
1559 return P;
1560 }
1561
1562
1563 /**
1564 * Get time-over-threshold probability convoluted with a Poisson distribution.
1565 *
1566 * \param pmt PMT signal processor
1567 * \param tot_ns time-over-threshold [ns]
1568 * \param NPE expected number of photo-electrons
1569 * \param precision precision
1570 * \return probability
1571 */
1573 const double tot_ns,
1574 const double NPE,
1575 const double precision = 1.0e-4)
1576 {
1577 int i = (int) (NPE - 5.0 * sqrt(NPE) - 0.5);
1578 int M = (int) (NPE + 5.0 * sqrt(NPE) + 0.5);
1579
1580 if (i < 1) { i = 1; }
1581 if (M < i) { M = i; }
1582
1583 double p = NPE * exp(-NPE) / (double) 1;
1584
1585 for (int __i = 1; __i != i; ++__i) {
1586 p *= NPE / __i;
1587 }
1588
1589 double P = 0.0;
1590
1591 for (double p0 = 0.0; (p >= p0 || p > precision) && i != M; ++i, p0 = p, p *= NPE / (double) i) {
1592 P += pmt.getTimeOverThresholdProbability(tot_ns, i) * p;
1593 }
1594
1595 return P;
1596 }
1597}
1598
1599#endif
Time calibration (including definition of sign of time offset).
Exceptions.
#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 &parameters)
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]
virtual double getChargeProbability(const double npe, const int NPE) const
Get probability density for given charge.
Exception for accessing a value in a collection that is outside of its range.
file Auxiliary data structures and methods for detector calibration.
Definition JAnchor.hh:12
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 getChargeProbability(const JPMTSignalProcessorInterface &pmt, const double npe, const double NPE, const double precision=1.0e-4)
Get charge probability convoluted with a Poisson distribution.
double getTimeOverThresholdProbability(const JPMTAnalogueSignalProcessor &pmt, const double tot_ns, const double NPE, const double precision=1.0e-4)
Get time-over-threshold probability convoluted with a Poisson distribution.
double Gauss(const double x, const double sigma)
Normalised Gauss function.
double binomial(const size_t n, const size_t k)
Binomial function.
double getUnderamplifiedGain() const
Get gain of underamplified pulses.
double getIntegralOfChargeProbability(const double xmin, const double xmax, const int NPE, const double normTh) const
Get integral of probability.
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 getUnderamplifiedGainSpread(int NPE) const
Get gain spread of underamplified pulses.
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.
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 getUnderamplifiedGainSpread() const
Get gain spread of underamplified pulses.
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 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.
double getChargeProbability(const double npe, const int NPE, const double normTh) const
Get probability density for given charge.
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 &parameters=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 getIntegralOfChargeProbability(const double xmin, const int NPE) const
Get integral of probability.
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...
void setPMTParameters(const JPMTParameters &parameters)
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).
double getGainSpread() const
Get gain spread for given number of photo-electrons.
virtual double getDerivative(const double npe) const override
Get derivative of number of photo-electrons to time-over-threshold.
double getUnderamplifiedGain(int NPE) const
Get gain of underamplified pulses.
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.
Data structure for single photo-electron.