Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-13 08:21:05

0001 
0002 #ifndef G4HepEmRunUtils_HH
0003 #define G4HepEmRunUtils_HH
0004 
0005 #include "G4HepEmMacros.hh"
0006 
0007 // Roate the direction [u,v,w] given in the scattering frame to the lab frame.
0008 // Details: scattering is described relative to the [0,0,1] direction (i.e. scattering
0009 // frame). Therefore, after the new direction is computed relative to this [0,0,1]
0010 // original direction, the real original direction [u1,u2,u3] in the lab frame
0011 // needs to be accounted and the final new direction, i.e. in the lab frame is
0012 // computed.
0013 G4HepEmHostDevice
0014 void RotateToReferenceFrame(double &u, double &v, double &w, const double* refDir);
0015 
0016 G4HepEmHostDevice
0017 void RotateToReferenceFrame(double* dir, const double* refDir);
0018 
0019 // get spline interpolation of y(x) between (x1, x2) given y_N = y(x_N), y''N(x_N)
0020 G4HepEmHostDevice
0021 double GetSpline(double x1, double x2, double y1, double y2, double secderiv1, double secderiv2, double x);
0022 
0023 // get linear interpolation of y(x) between (x1, x2) given y_1 = y(x_N)
0024 G4HepEmHostDevice
0025 double GetLinear(double x1, double x2, double y1, double y2, double x);
0026 
0027 // get spline interpolation over a log-spaced xgrid previously prepared by
0028 // PrepareSpline (separate storrage of ydata and second deriavtive)
0029 // use the improved, robust spline interpolation that I put in G4 10.6
0030 G4HepEmHostDevice
0031 double GetSplineLog(int ndata, double* xdata, double* ydata, double* secderiv, double x, double logx, double logxmin, double invLDBin);
0032 
0033 // get spline interpolation over a log-spaced xgrid previously prepared by
0034 // PrepareSpline (compact storrage of ydata and second deriavtive in ydata)
0035 // use the improved, robust spline interpolation that I put in G4 10.6
0036 G4HepEmHostDevice
0037 double GetSplineLog(int ndata, double* xdata, double* ydata, double x, double logx, double logxmin, double invLDBin);
0038 
0039 // get spline interpolation over a log-spaced xgrid previously prepared by
0040 // PrepareSpline (compact storrage of xdata, ydata and second deriavtive in data)
0041 // use the improved, robust spline interpolation that I put in G4 10.6
0042 G4HepEmHostDevice
0043 double GetSplineLog(int ndata, double* data, double x, double logx, double logxmin, double invLDBin);
0044 
0045 
0046 // get spline interpolation over any xgrid: idx = i such  xdata[i] <= x < xdata[i+1]
0047 // and x >= xdata[0] and x<xdata[ndata-1]
0048 // PrepareSpline (separate storrage of ydata and second deriavtive)
0049 // use the improved, robust spline interpolation that I put in G4 10.6
0050 G4HepEmHostDevice
0051 double GetSpline(double* xdata, double* ydata, double* secderiv, double x, int idx, int step=1);
0052 
0053 // get spline interpolation if it was prepared with compact storrage of ydata
0054 // and second deriavtive in ydata
0055 // use the improved, robust spline interpolation that I put in G4 10.6
0056 G4HepEmHostDevice
0057 double GetSpline(double* xdata, double* ydata, double x, int idx);
0058 
0059 // get spline interpolation if it was prepared with compact storrage of xdata,
0060 // ydata and second deriavtive in data
0061 G4HepEmHostDevice
0062 double GetSpline(double* data, double x, int idx);
0063 
0064 
0065 // get linear interpolation over a log-spaced xgrid previously prepared by
0066 // PrepareSpline; compact storrage of xdata, ydata in data with a single `y`
0067 // at each `x` (x_i,y_i, x_i+1,y_i+1,...)
0068 G4HepEmHostDevice
0069 double GetLinearLog(int ndata, double* data, double x, double logx, double logxmin, double invLDBin);
0070 
0071 // same as above but having 2 `y` data now at each `x` (x_i,y1_i,y2_i, x_i+1,y_i+1,y2_i+1,,...)
0072 // `iwhich=1` interpolates `y1` while `iwhich=2` `y2`
0073 G4HepEmHostDevice
0074 double GetLinearLog2(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, int iwhich);
0075 // same as above but interpolate sthe 2 data at once
0076 G4HepEmHostDevice
0077 void GetLinearLog2(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, double res[2]);
0078 
0079 /*
0080 // same as GetLinearLog2 but general for N `y` data at each `x` with `shift=N+1`
0081 // - the special case above with `N=2`: `shift=N+1=3` and this the same as the above
0082 // - the special case having `N=1`: `shift=1+1=2` and with `which=1` this the same as the above GetLinearLog
0083 G4HepEmHostDevice
0084 double GetLinearLogN(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, int iwhich, int shift);
0085 */
0086 
0087 // get spline interpolation over a log-spaced xgrid previously prepared by
0088 // PrepareSpline; compact storrage of xdata, ydata in data with 4 `y` values
0089 // and their second derivatives at each `x` (x_i, y1_i,y1_i'',y2_i,y2_i'',y3_i,y3_i'',y4_i,y4_i'', x_i+1...)
0090 // `iwhich=1` interpolates `y1`; `iwhich=2` `y2`, `iwhich=3` `y3`, `iwhich=4` `y4`
0091 G4HepEmHostDevice
0092 double GetSplineLog4(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, int iwhich);
0093 //same as above but interpolates all the 4 data at once
0094 G4HepEmHostDevice
0095 void GetSplineLog4(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, double res[4]);
0096 
0097 /*
0098 // same as GetSplineLog4 but general for N `y` data and their second derivatives at each `x`
0099 // - the special case above with `N=4`: `shift=2xN +1=9` and this the same as the above
0100 // - the special case having `N=1`: `shift=2xN +1=3` and with `which=1` this the same as the above GetSplineLog with the single `double* data` array
0101 G4HepEmHostDevice
0102 double GetSplineLogN(int ndata, double* data, double x, double logx, double logxmin, double invLDBin, int iwhich, int shift);
0103 */
0104 
0105 
0106 
0107 
0108 // finds the lower index of the x-bin in an ordered, increasing x-grid such
0109 // that x[i] <= x < x[i+1]
0110 G4HepEmHostDevice
0111 int    FindLowerBinIndex(double* xdata, int num, double x, int step=1);
0112 
0113 
0114 #endif // G4HepEmRunUtils_HH