Evaluation of fit.
1879 {
1880 using namespace std;
1881 using namespace JPP;
1882
1884
1885
1887
1890
1891
1892
1893
1894 const struct M_t {
1896 {
1897 R = value.model.
getIndex(&JK40Parameters_t::R);
1898 p1 = value.model.
getIndex(&JK40Parameters_t::p1);
1899 p2 = value.model.
getIndex(&JK40Parameters_t::p2);
1900 p3 = value.model.
getIndex(&JK40Parameters_t::p3);
1901 p4 = value.model.
getIndex(&JK40Parameters_t::p4);
1902 cc = value.model.
getIndex(&JK40Parameters_t::cc);
1903 bc = value.model.
getIndex(&JK40Parameters_t::bc);
1904 }
1905
1906 int R;
1908 int p2;
1909 int p3;
1910 int p4;
1911 int cc;
1912 int bc;
1913
1915
1916
1917
1918
1919 const struct T_t :
public std::array<int, NUMBER_OF_RINGS> {
1921 {
1924 }
1925
1926 int N = value.model.
getN();
1927
1929 if (value.transmittance[i].isFree()) { (*this)[i] = N; ++N; }
1930 }
1931 }
1933
1934
1935
1936
1937 struct i_t {
1938 i_t() :
1943 {}
1944
1945 int QE;
1946 int TTS;
1947 int t0;
1948 int bg;
1949 };
1950
1951 const struct I_t :
public std::array<i_t, NUMBER_OF_PMTS> {
1953 {
1954 int N = value.model.
getN() + value.transmittance.
getN();
1955
1956 for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
1957 if (value.parameters[i].QE .isFree()) { (*this)[i].QE = N; ++N; }
1958 if (value.parameters[i].TTS.isFree()) { (*this)[i].TTS = N; ++N; }
1959 if (value.parameters[i].t0 .isFree()) { (*this)[i].t0 = N; ++N; }
1960 if (value.parameters[i].bg .isFree()) { (*this)[i].bg = N; ++N; }
1961 }
1962 }
1963
1965
1966
1968 double operator[](const int index) const
1969 {
1970 for (const_iterator i = this->begin(); i != this->end(); ++i) {
1971 if (i->first == index) {
1972 return i->second;
1973 }
1974 }
1975
1977 }
1978 };
1979
1981
1982#define PUSH_BACK(i,v) if (i != INVALID_INDEX) { buffer.push_back({i, v}); }
1983
1984
1985 size_t number_of_errors = 0;
1986
1987 for (data_type::const_iterator ix =
data.begin(); ix !=
data.end(); ++ix) {
1988
1990
1993
1995
1997
2002
2003 for (
const rate_type& iy : ix->second) {
2004
2005 const double R2 = bell.getValue (iy.
dt_ns);
2007
2008 const double R = real.bc + real.
background + T1 *
R1 * (real.cc + R2);
2011
2013
2014 buffer.clear();
2015
2023
2026 }
2027
2036
2038
2039 DEBUG(
"PMT pair(" << setw(2) <<
pair.first <<
"," << setw(2) <<
pair.second <<
") " <<
FIXED(7,3) << iy.
dt_ns <<
" [ns]" << endl);
2040
2041 const double PRECISION = 1.0e-5;
2042
2043#define MAKE_TEST(i,v) if (i != INVALID_INDEX) { \
2044 \
2045 const bool status = fabs(buffer[i] - v) <= PRECISION; \
2046 \
2047 DEBUG((status ? GREEN : RED) \
2048 << setw(20) << left << #i << right << ' ' \
2049 << setw(3) << i << ' ' \
2050 << FIXED(12,5) << buffer[i] << ' ' \
2051 << FIXED(12,5) << v << ' ' \
2052 << (!status ? "***" : "") \
2053 << RESET << endl); \
2054 \
2055 if (!status) { \
2056 number_of_errors += 1; \
2057 } \
2058 }
2059
2061 {
2063 {
2065
2066 this->model.R .relax();
2067 this->model.p1.relax();
2068 this->model.p2.relax();
2069 this->model.p3.relax();
2070 this->model.p4.relax();
2071 this->model.cc.relax();
2072 this->model.bc.relax();
2073
2074 for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
2075 parameters[i].QE .relax();
2076 parameters[i].TTS.relax();
2077 parameters[i].t0 .relax();
2078 parameters[i].bg .relax();
2079 }
2080
2081 return *this;
2082 }
2083
2085 {
2087 }
2088 };
2089
2090 const double DX = 1.0e-8;
2092
2093
2094
2096 {
2098 };
2099
2107
2114 }
2117 }
2120
2121 cout << endl;
2122 }
2123
2124 for (buffer_type::const_iterator row = buffer.begin(); row != buffer.end(); ++row) {
2125
2126 Y[row->first] += row->second;
2127
2128 V[row->first][row->first] += row->second * row->second;
2129
2130 for (buffer_type::const_iterator col = buffer.begin(); col != row; ++col) {
2131 V[row->first][col->first] += row->second * col->second;
2132 V[col->first][row->first] =
V[row->first][col->first];
2133 }
2134 }
2135 }
2136 }
2137 }
2138
2139#undef PUSH_BACK
2140
2142
2143 STATUS(
"Test finished with " << number_of_errors <<
" errors." << endl);
2144
2145 exit(number_of_errors == 0 ? 0 : 1);
2146 }
2147 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
double getDerivative() const
Get derivative of value.
Interface to read input and write output for TObject tests.
Exception for accessing a value in a collection that is outside of its range.
static const int INVALID_INDEX
invalid index
static double BELL_SHAPE
Bell shape.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
Model for fit to acoustics data.
size_t getN() const
Get number of fit parameters.
size_t getIndex(int id, double JString::*p) const
Get index of fit parameter for given string.
Fit parameters for two-fold coincidence rate due to K40.
const JK40Parameters_t & getGradient(const double ct) const
Get gradient.
double getValue(const double ct) const
Get K40 coincidence rate as a function of cosine angle between PMT axes.
Auxiliary data structure for derived quantities of a given PMT pair.
int getIndex() const
Get index of PMT used for fixed time offset.
const real_type & getReal(const pair_type &pair) const
Get derived quantities.
Auxiliary data structure to handle transmittance of glass sphere due to sedimentation.
double getValue(const double ct, const ring_pair pair) const
Get weighed contribution of water and glass.
const JTransmittance_t & getGradient(const double ct, const ring_pair pair) const
Get gradient.
double error
error of rate [Hz/ns]
double value
value of rate [Hz/ns]
JMatrixND & reset()
Set matrix to the null matrix.