Analysis-Utilities
26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Toggle main menu visibility
Loading...
Searching...
No Matches
RooLowExpTail.cu
Go to the documentation of this file.
1
#include "
RooFitPhotopeakKernels.hpp
"
2
3
#include <cuda_runtime.h>
4
5
#ifndef M_PI
6
#define M_PI 3.14159265358979323846
7
#endif
8
9
namespace
{
10
11
// exp(a)*erfc(b) without intermediate overflow; see ExpErfc in
12
// src/RooFitPhotopeakPdfs.cpp for the derivation. In the tail a and b share the
13
// sign of y and b >= a/sqrt(2), so when exp(a) would overflow erfc(b)
14
// underflows and the product tends to 0.
15
__device__
double
ExpErfc(
double
a,
double
b) {
16
if
(a <= 700.0)
17
return
exp(a) * erfc(b);
18
double
t = 1.0 / (b * b);
19
double
erfcx = (1.0 / (b * sqrt(
M_PI
))) *
20
(1.0 - 0.5 * t + 0.75 * t * t - 1.875 * t * t * t);
21
return
exp(a - b * b) * erfcx;
22
}
23
24
__global__
void
RooLowExpTailKernel(
double
*output,
const
double
*x_vals,
25
double
mu,
double
inv_tau,
26
double
inv_sqrt2_sigma,
size_t
n) {
27
size_t
i = blockIdx.x * blockDim.x + threadIdx.x;
28
if
(i < n) {
29
double
y = x_vals[i] - mu;
30
double
v = ExpErfc(y * inv_tau, y * inv_sqrt2_sigma);
31
output[i] = v > 1e-300 ? v : 1e-300;
32
}
33
}
34
35
}
// namespace
36
37
void
RooLowExpTail_launchKernel
(
double
*output,
const
double
*x_vals,
double
mu,
38
double
inv_tau,
double
inv_sqrt2_sigma,
39
size_t
n) {
40
const
int
threads = 256;
41
const
int
blocks = (n + threads - 1) / threads;
42
RooLowExpTailKernel<<<blocks, threads>>>(output, x_vals, mu, inv_tau,
43
inv_sqrt2_sigma, n);
44
}
RooFitPhotopeakKernels.hpp
Host-callable launch wrappers for the photopeak PDF CUDA kernels.
M_PI
#define M_PI
Definition
RooHighExpTail.cu:6
RooLowExpTail_launchKernel
void RooLowExpTail_launchKernel(double *output, const double *x_vals, double mu, double inv_tau, double inv_sqrt2_sigma, size_t n)
Launch the low-energy exponential tail kernel.
Definition
RooLowExpTail.cu:37
gpu
RooLowExpTail.cu
Generated by
1.17.0