19 TWOPID = 6.2831853071795865;
35 double ofac,
double hifac,
int *nout,
int *jmax,
double *prob,
45 double ave,
c, cc, cwtau, effm, expy, pnow, pymax, s, ss, sumc, sumcy, sums, sumsh, sumsy;
46 double swtau, var, wtau, xave, xdiff, xmax, xmin, yy;
50 std::vector<double> wi, wpi, wpr, wr;
57 wi.erase(wi.begin(), wi.end());
58 wpi.erase(wpi.begin(), wpi.end());
59 wpr.erase(wpr.begin(), wpr.end());
60 wr.erase(wr.begin(), wr.end());
67 ntmp = (int)(0.5 * ofac * hifac *
n);
72 if(
avevar(indata, &ave, &var) != 0) {
73 std::cerr <<
"LOMB: Average failed!\n";
80 for(p = indata->begin(); p != indata->end(); p++) {
81 if((*p).x > xmax) xmax = (*p).x;
82 if((*p).x < xmin) xmin = (*p).x;
86 xave = 0.5 * (xmax + xmin);
88 pnow = 1. / (xdiff * ofac);
90 for(p = indata->begin(); p != indata->end(); p++) {
93 wpr.push_back((-2. *
pow(
sin(0.5 *
arg) , 2)));
101 if((wr.end() - wr.begin()) !=
n) {
102 std::cerr <<
"LOMB: Vector range mismatch!!!\n";
106 for(i = 0; i < (*nout); i++) {
112 for(j = 0; j <
n; j++) {
117 sumc += (
c - s) * (
c + s);
120 wtau = 0.5 *
atan2(2.0 * sumsh, sumc);
128 for(j = 0, p = indata->begin() ; j < n && p != indata->
end() ; j++, p++) {
132 ss = s * cwtau -
c * swtau;
133 cc =
c * cwtau + s * swtau;
140 wr[j] = (wr[j] * wpr[j] - wi[j] * wpi[j]) + wr[j];
141 wi[j] = (wi[j] * wpr[j] + wtemp * wpi[j]) + wi[j];
145 pt.
y = 0.5 * (sumcy * sumcy / sumc + sumsy * sumsy / sums) / var;
146 if(amp) pt.
y =
sqrt(
pow((sumcy / sumc), 2.) +
pow((sumsy / sums), 2.));
153 outdata->push_back(pt);
155 pnow += 1. / (ofac * xdiff);
160 effm = 2. * (*nout) / ofac;
163 if(*prob > 0.01) *prob = 1. -
pow((1. - expy), effm);
165 wi.erase(wi.begin(), wi.end());
166 wpi.erase(wpi.begin(), wpi.end());
167 wpr.erase(wpr.begin(), wpr.end());
168 wr.erase(wr.begin(), wr.end());
197 std::cerr <<
"Only one datapoint -> no averaging....\n";
201 for(p = data->begin(); p != data->end(); p++) *ave += (*p).y;
207 for(p = data->begin(); p != data->end(); p++) {
213 *var = (*var - ep * ep /
n) / (
n - 1);
233 double expy, effm, prob;
237 expy =
exp(-1 * (*peak));
238 effm = 2. * (double)(*nout) / (*ofac);
240 if(prob > 0.01) prob = 1. -
pow((1. - expy), effm);
249 double *sdev,
double *var,
double *skew,
double *curt)
276 std::cerr <<
"To few data points for moment analysis!\n";
288 for(p = indata->begin(); p != indata->end(); p++) {
289 s += (*p).y * (*p).x;
293 *ave = s / (double)nn;
307 for(p = indata->begin(); p != indata->end(); p++) {
311 *adev = *adev + (double)
std::abs((
double)s);
314 *var += pnr * (*p).y;
317 *skew += pnr * (*p).y;
320 *curt += pnr * (*p).y;
324 *adev = *adev / (double)nn;
326 *var = (*var - ep * ep / (double)nn) / ((double)(nn - 1));
331 *skew = *skew / ((double)nn *
pow(*sdev, 3.));
332 *curt = *curt / ((double)nn *
pow(*var, 2.)) - 3.;
334 std::cerr <<
"No skew or kurtosis when zero variance in moment\n";
std::vector< LOMB_TYPE >::const_iterator CI_lt
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Tps< T > exp(const Tps< T > &x)
Exponential.
Tps< T > sin(const Tps< T > &x)
Sine.
Tps< T > sqrt(const Tps< T > &x)
Square root.
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
constexpr double c
The velocity of light in m/s.
virtual ~LOMB_class(void)
int avevar(std::vector< LOMB_TYPE > *data, double *ave, double *var)
double signi(double *peak, int *nout, double *ofac)
int moment(std::vector< LOMB_TYPE > *indata, double *ave, double *adev, double *sdev, double *var, double *skew, double *curt)
int period(std::vector< LOMB_TYPE > *indata, std::vector< LOMB_TYPE > *outdata, double ofac, double hifac, int *nout, int *jmax, double *prob, int amp)