TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
libtpcbfm
bf_srtm.c
Go to the documentation of this file.
1
4
/*****************************************************************************/
5
#include "tpcclibConfig.h"
6
/*****************************************************************************/
7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <math.h>
10
#include <time.h>
11
#include <string.h>
12
/*****************************************************************************/
13
#include "
tpcextensions.h
"
14
#include "
tpctac.h
"
15
#include "
tpccm.h
"
16
/*****************************************************************************/
17
#include "
tpcbfm.h
"
18
/*****************************************************************************/
19
20
/*****************************************************************************/
26
int
bfmSRTM
(
28
double
*t,
32
double
*cri,
34
const
int
n,
36
const
int
bfNr,
38
const
double
t3min,
40
const
double
t3max,
42
TAC
*bf,
44
TPCSTATUS
*status
45
) {
46
int
verbose=0;
if
(status!=NULL) verbose=status->
verbose
;
47
if
(verbose>0) printf(
"%s(t, cri, %d, %d, %g, %g, bf)\n"
, __func__, n, bfNr, t3min, t3max);
48
if
(t==NULL || cri==NULL || bf==NULL) {
49
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_FAIL
);
50
return
TPCERROR_FAIL
;
51
}
52
if
(n<2 || bfNr<1) {
53
if
(verbose>1) printf(
"invalid sample or BF number\n"
);
54
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_TOO_FEW
);
55
return
TPCERROR_TOO_FEW
;
56
}
57
if
(t3min<1.0E-10 || t3min>=t3max) {
// range cannot be computed otherwise
58
if
(verbose>1) printf(
"invalid theta3 range\n"
);
59
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_INVALID_VALUE
);
60
return
TPCERROR_INVALID_VALUE
;
61
}
62
63
int
ret;
64
65
/* Allocate memory for basis functions */
66
if
(verbose>1) printf(
"allocating memory for basis functions\n"
);
67
tacFree
(bf);
68
ret=
tacAllocate
(bf, n, bfNr);
69
if
(ret!=
TPCERROR_OK
) {
70
statusSet
(status, __func__, __FILE__, __LINE__, ret);
71
return
ret;
72
}
73
/* Copy and set information fields */
74
bf->
tacNr
=bfNr; bf->
sampleNr
=n;
75
bf->
format
=
TAC_FORMAT_TSV_UK
;
76
bf->
isframe
=0;
77
for
(
int
bi=0; bi<bf->
tacNr
; bi++) sprintf(bf->
c
[bi].
name
,
"B%5.5d"
, bi+1);
78
for
(
int
fi=0; fi<bf->
sampleNr
; fi++) bf->
x
[fi]=t[fi];
79
/* Compute theta3 values to size fields */
80
{
81
if
(verbose>1) printf(
"computing theta3 values\n"
);
82
double
a, b, c;
83
a=log10(t3min); b=log10(t3max); c=(b-a)/(
double
)(bfNr-1);
84
for
(
int
bi=0; bi<bf->
tacNr
; bi++) {
85
bf->
c
[bi].
size
=pow(10.0, (
double
)bi*c+a);
86
}
87
}
88
if
(verbose>2) {
89
printf(
"bf_t3_range := %g - %g\n"
, bf->
c
[0].
size
, bf->
c
[bf->
tacNr
-1].
size
);
90
printf(
"bf_t3_gaps := %g - %g\n"
, bf->
c
[1].
size
-bf->
c
[0].
size
,
91
bf->
c
[bf->
tacNr
-1].
size
-bf->
c
[bf->
tacNr
-2].
size
);
92
}
93
94
/* Calculate the basis functions */
95
if
(verbose>1) printf(
"computing basis functions\n"
);
96
ret=0;
97
for
(
int
bi=0; bi<bf->
tacNr
&& !ret; bi++) {
98
if
(verbose>99) printf(
" theta3=%g\n"
, bf->
c
[bi].
size
);
99
ret=
simC1_i
(t, cri, n, 1.0, bf->
c
[bi].
size
, bf->
c
[bi].
y
);
100
}
101
if
(ret) {
102
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_INVALID_VALUE
);
103
return
TPCERROR_INVALID_VALUE
;
104
}
105
106
statusSet
(status, __func__, __FILE__, __LINE__,
TPCERROR_OK
);
107
return
(
TPCERROR_OK
);
108
}
109
/*****************************************************************************/
110
111
/*****************************************************************************/
bfmSRTM
int bfmSRTM(double *t, double *cri, const int n, const int bfNr, const double t3min, const double t3max, TAC *bf, TPCSTATUS *status)
Definition
bf_srtm.c:26
simC1_i
int simC1_i(double *t, double *cai, const int nr, const double k1, const double k2, double *ct)
Definition
sim1cm.c:164
statusSet
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition
statusmsg.c:142
TACC::name
char name[MAX_TACNAME_LEN+1]
Definition
tpctac.h:81
TACC::y
double * y
Definition
tpctac.h:75
TACC::size
double size
Definition
tpctac.h:71
TAC
Definition
tpctac.h:87
TAC::x
double * x
Definition
tpctac.h:97
TAC::format
tacformat format
Definition
tpctac.h:93
TAC::sampleNr
int sampleNr
Definition
tpctac.h:89
TAC::isframe
int isframe
Definition
tpctac.h:95
TAC::c
TACC * c
Definition
tpctac.h:117
TAC::tacNr
int tacNr
Definition
tpctac.h:91
TPCSTATUS
Definition
tpcextensions.h:241
TPCSTATUS::verbose
int verbose
Verbose level, used by statusPrint() etc.
Definition
tpcextensions.h:242
tacFree
void tacFree(TAC *tac)
Definition
tac.c:106
tacAllocate
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
Definition
tac.c:130
tpcbfm.h
Header file for libtpcbfm.
tpccm.h
Header file for libtpccm.
tpcextensions.h
Header file for library libtpcextensions.
TPCERROR_INVALID_VALUE
@ TPCERROR_INVALID_VALUE
Invalid value.
Definition
tpcextensions.h:220
TPCERROR_FAIL
@ TPCERROR_FAIL
General error.
Definition
tpcextensions.h:192
TPCERROR_OK
@ TPCERROR_OK
No error.
Definition
tpcextensions.h:191
TPCERROR_TOO_FEW
@ TPCERROR_TOO_FEW
File contains too few samples.
Definition
tpcextensions.h:208
tpctac.h
Header file for library libtpctac.
TAC_FORMAT_TSV_UK
@ TAC_FORMAT_TSV_UK
UK TSV (point as decimal separator).
Definition
tpctac.h:37
Generated on
for TPCCLIB by
1.17.0