Evaluation of fit.
1496 {
1497 using namespace std;
1498 using namespace JPP;
1499
1501
1502
1504
1507
1508
1509
1510
1511 const struct M_t {
1513 {
1514 R =
model.getIndex(&JK40Parameters_t::R);
1515 p1 =
model.getIndex(&JK40Parameters_t::p1);
1516 p2 =
model.getIndex(&JK40Parameters_t::p2);
1517 p3 =
model.getIndex(&JK40Parameters_t::p3);
1518 p4 =
model.getIndex(&JK40Parameters_t::p4);
1519 cc =
model.getIndex(&JK40Parameters_t::cc);
1520 bc =
model.getIndex(&JK40Parameters_t::bc);
1521 }
1522
1523 int R;
1525 int p2;
1526 int p3;
1527 int p4;
1528 int cc;
1529 int bc;
1530
1532
1533
1534
1535
1536 struct i_t {
1537 i_t() :
1542 {}
1543
1544 int QE;
1545 int TTS;
1546 int t0;
1547 int bg;
1548 };
1549
1550 const struct I_t :
public std::array<i_t, NUMBER_OF_PMTS> {
1552 {
1553 int N = value.JK40Parameters::getN();
1554
1555 for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
1556 if (value.parameters[i].QE .isFree()) { (*this)[i].QE = N; ++N; }
1557 if (value.parameters[i].TTS.isFree()) { (*this)[i].TTS = N; ++N; }
1558 if (value.parameters[i].t0 .isFree()) { (*this)[i].t0 = N; ++N; }
1559 if (value.parameters[i].bg .isFree()) { (*this)[i].bg = N; ++N; }
1560 }
1561 }
1562
1564
1565
1566
1568 double operator[](const int index) const
1569 {
1570 for (const_iterator i = this->begin(); i != this->end(); ++i) {
1571 if (i->first == index) {
1572 return i->second;
1573 }
1574 }
1575
1577 }
1578 };
1579
1581
1582#define PUSH_BACK(i,v) if (i != INVALID_INDEX) { buffer.push_back({i, v}); }
1583
1584
1585 size_t number_of_errors = 0;
1586
1587 for (data_type::const_iterator ix =
data.begin(); ix !=
data.end(); ++ix) {
1588
1590
1593
1595
1597
1600
1601 for (
const rate_type& iy : ix->second) {
1602
1603 const double R2 = bell.getValue (iy.
dt_ns);
1605
1606 const double R = real.bc + real.
background +
R1 * (real.cc + R2);
1609
1611
1612 buffer.clear();
1613
1621
1630
1632
1633 DEBUG(
"PMT pair(" << setw(2) <<
pair.first <<
"," << setw(2) <<
pair.second <<
") " <<
FIXED(7,3) << iy.
dt_ns <<
" [ns]" << endl);
1634
1635 const double PRECISION = 1.0e-5;
1636
1637#define MAKE_TEST(i,v) if (i != INVALID_INDEX) { \
1638 \
1639 const bool status = fabs(buffer[i] - v) <= PRECISION; \
1640 \
1641 DEBUG((status ? GREEN : RED) \
1642 << setw(20) << left << #i << right << ' ' \
1643 << setw(3) << i << ' ' \
1644 << FIXED(12,5) << buffer[i] << ' ' \
1645 << FIXED(12,5) << v << ' ' \
1646 << (!status ? "***" : "") \
1647 << RESET << endl); \
1648 \
1649 if (!status) { \
1650 number_of_errors += 1; \
1651 } \
1652 }
1653
1655 {
1657 {
1659
1660 R .relax();
1662 p2.relax();
1663 p3.relax();
1664 p4.relax();
1665 cc.relax();
1666 bc.relax();
1667
1668 for (int i = 0; i != NUMBER_OF_PMTS; ++i) {
1669 parameters[i].QE .relax();
1670 parameters[i].TTS.relax();
1671 parameters[i].t0 .relax();
1672 parameters[i].bg .relax();
1673 }
1674
1675 return *this;
1676 }
1677
1679 {
1681 }
1682 };
1683
1684 const double DX = 1.0e-8;
1686
1687
1688
1690 {
1692 };
1693
1701
1708 }
1711 }
1714
1715 cout << endl;
1716 }
1717
1718 for (buffer_type::const_iterator row = buffer.begin(); row != buffer.end(); ++row) {
1719
1720 Y[row->first] += row->second;
1721
1722 V[row->first][row->first] += row->second * row->second;
1723
1724 for (buffer_type::const_iterator col = buffer.begin(); col != row; ++col) {
1725 V[row->first][col->first] += row->second * col->second;
1726 V[col->first][row->first] =
V[row->first][col->first];
1727 }
1728 }
1729 }
1730 }
1731 }
1732
1733#undef PUSH_BACK
1734
1736
1737 STATUS(
"Test finished with " << number_of_errors <<
" errors." << endl);
1738
1739 exit(number_of_errors == 0 ? 0 : 1);
1740 }
1741 }
#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.
Fit parameters for two-fold coincidence rate due to K40.
const JK40Parameters_t & getGradient(const double ct) const
Get gradient.
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.
double getValue(const pair_type &pair, const double dt_ns) const
Get K40 coincidence rate.
double error
error of rate [Hz/ns]
double value
value of rate [Hz/ns]
JMatrixND & reset()
Set matrix to the null matrix.