- Timestamp:
- 12/12/19 13:31:01 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/spectrum.cc
r19886 r19887 46 46 const double stp = (max-min)/cnt; 47 47 48 for ( int i=0; i<=cnt; i++)48 for (size_t i=0; i<=cnt; i++) 49 49 emplace(min+i*stp); 50 50 } … … 363 363 364 364 const auto vec = bins.vec(); 365 for ( int i=1; i<vec.size()-2; i++)365 for (size_t i=1; i<vec.size()-2; i++) 366 366 query1 << " ( " << i << ", " << vec[i-1] << ", " << vec[i] << " ),\n"; 367 367 query1 << " ( " << vec.size()-2 << ", " << vec[vec.size()-2] << ", " << vec[vec.size()-1] << " )\n"; … … 376 376 // ----------------------------- ROOT Histogram ----------------------------- 377 377 378 /* 379 A bit of hackery, so just sharing for fun. 380 381 #define with(T, ...) ([&]{ T ${}; __VA_ARGS__; return $; }()) 382 383 And use it like: 384 385 MyFunction(with(Params, 386 $.Name = "Foo Bar", 387 $.Age = 18 388 )); 389 390 which expands to: 391 392 MyFunction(([&] { 393 Params ${}; 394 $.Name = "Foo Bar", $.Age = 18; 395 return $; 396 }())); 397 */ 378 398 struct Histogram 379 399 { 380 400 // A workaround to be able to set a default also in C++11 401 /* 381 402 template<typename T, T def> 382 403 struct Value … … 386 407 Value(const T &_t) : t(_t) { } 387 408 operator T() const { return t; } 388 }; 409 };*/ 389 410 390 411 string name; … … 401 422 string axisy; 402 423 string axisz; 403 Value<bool,true> stats; 424 bool stats; 425 //Value<bool,true> stats; 404 426 }; 405 427 … … 468 490 const uint32_t x = row["X"]; 469 491 const double v = row["V"]; 470 if (x> h->GetNbinsX()+1)492 if (x>uint32_t(h->GetNbinsX()+1)) 471 493 continue; 472 494 … … 474 496 { 475 497 const uint32_t y = row["Y"]; 476 if (y> h->GetNbinsY()+1)498 if (y>uint32_t(h->GetNbinsY()+1)) 477 499 continue; 478 500 … … 487 509 h->SetBinError(x, double(row["E"])); 488 510 } 489 catch (const mysqlpp::BadFieldName & e)511 catch (const mysqlpp::BadFieldName &) 490 512 { 491 513 } … … 548 570 int main(int argc, const char* argv[]) 549 571 { 550 551 572 Time start; 552 573 … … 1051 1072 1052 1073 WriteHistogram(connection, { 1053 .dir = "Zd",1054 1074 .name = "OnTime", 1055 1075 .title = "Effective on time", 1076 .dir = "Zd", 1056 1077 .binningx = binning_theta, 1078 .binningy = {}, 1057 1079 .table = "ThetaHist", 1058 1080 .x = ".theta", 1081 .y = "", 1059 1082 .v = "OnTime", 1083 .err = "", 1060 1084 .axisx = "Zenith Distance #theta [#circ]", 1061 .axisy = "Eff. on time [s]" 1062 }); 1063 1064 WriteHistogram(connection, { 1065 .dir = "Zd", 1085 .axisy = "Eff. on time [s]", 1086 .axisz = "", 1087 .stats = true 1088 }); 1089 1090 WriteHistogram(connection, { 1066 1091 .name = "CountN", 1067 1092 .title = "Simulated Zenith Distance", 1093 .dir = "Zd", 1068 1094 .binningx = binning_theta, 1095 .binningy = {}, 1069 1096 .table = "ThetaHist", 1070 1097 .x = ".theta", 1098 .y = "", 1071 1099 .v = "CountN", 1072 1100 .err = "ErrCountN", 1073 1101 .axisx = "Zenith Distance #theta [#circ]", 1074 .axisy = "Counts" 1075 }); 1076 1077 WriteHistogram(connection, { 1078 .dir = "Zd", 1102 .axisy = "Counts", 1103 .axisz = "", 1104 .stats = true 1105 }); 1106 1107 WriteHistogram(connection, { 1079 1108 .name = "ZdWeight", 1080 1109 .title = "Zenith Distance Weight", 1110 .dir = "Zd", 1081 1111 .binningx = binning_theta, 1112 .binningy = {}, 1082 1113 .table = "ThetaHist", 1083 1114 .x = ".theta", 1115 .y = "", 1084 1116 .v = "ZdWeight", 1085 1117 .err = "ErrZdWeight", 1086 1118 .axisx = "Zenith Distance #theta [#circ]", 1087 .axisy = "Weight [s]" 1119 .axisy = "Weight [s]", 1120 .axisz = "", 1121 .stats = true 1088 1122 }); 1089 1123 … … 1523 1557 .dir = "Eest/Measurement", 1524 1558 .binningx = binning_eest, 1559 .binningy = {}, 1525 1560 .table = "Spectrum", 1526 1561 .x = ".energy", 1562 .y = "", 1527 1563 .v = "Signal", 1528 1564 .err = "ErrSignal", 1529 1565 .axisx = "Energy lg(E_{est}/GeV)", 1530 .axisy = "Counts" 1566 .axisy = "Counts", 1567 .axisz = "", 1568 .stats = true 1531 1569 }); 1532 1570 … … 1536 1574 .dir = "Eest/Measurement", 1537 1575 .binningx = binning_eest, 1576 .binningy = {}, 1538 1577 .table = "Spectrum", 1539 1578 .x = ".energy", 1579 .y = "", 1540 1580 .v = "Background", 1541 1581 .err = "ErrBackground", 1542 1582 .axisx = "Energy lg(E_{est}/GeV)", 1543 .axisy = "Counts" 1583 .axisy = "Count", 1584 .axisz = "", 1585 .stats = true 1544 1586 }); 1545 1587 … … 1549 1591 .dir = "Eest/Measurement", 1550 1592 .binningx = binning_eest, 1593 .binningy = {}, 1551 1594 .table = "Spectrum", 1552 1595 .x = ".energy", 1596 .y = "", 1553 1597 .v = "Excess", 1554 1598 .err = "ErrExcess", 1555 1599 .axisx = "Energy lg(E_{est}/GeV)", 1556 .axisy = "Signal - Background (Counts)" 1600 .axisy = "Signal - Background (Counts)", 1601 .axisz = "", 1602 .stats = true 1557 1603 }); 1558 1604 … … 1562 1608 .dir = "Eest/Simulation/Weighted", 1563 1609 .binningx = binning_eest, 1610 .binningy = {}, 1564 1611 .table = "Spectrum", 1565 1612 .x = ".energy", 1613 .y = "", 1566 1614 .v = "SignalW", 1567 1615 .err = "ErrSignalW", 1568 1616 .axisx = "Energy lg(E_{est}/GeV)", 1569 .axisy = "Weighted" 1617 .axisy = "Weighted", 1618 .axisz = "", 1619 .stats = true 1570 1620 }); 1571 1621 … … 1575 1625 .dir = "Eest/Simulation/Weighted", 1576 1626 .binningx = binning_eest, 1627 .binningy = {}, 1577 1628 .table = "Spectrum", 1578 1629 .x = ".energy", 1630 .y = "", 1579 1631 .v = "BackgroundW", 1580 1632 .err = "ErrBackgroundW", 1581 1633 .axisx = "Energy lg(E_{est}/GeV)", 1582 .axisy = "Weighted" 1634 .axisy = "Weighted", 1635 .axisz = "", 1636 .stats = true 1583 1637 }); 1584 1638 … … 1588 1642 .dir = "Eest/Simulation/Weighted", 1589 1643 .binningx = binning_eest, 1644 .binningy = {}, 1590 1645 .table = "Spectrum", 1591 1646 .x = ".energy", 1647 .y = "", 1592 1648 .v = "ExcessW", 1593 1649 .err = "ErrExcessW", 1594 1650 .axisx = "Energy lg(E_{est}/GeV)", 1595 .axisy = "Signal - Background (Weighted)" 1651 .axisy = "Signal - Background (Weighted)", 1652 .axisz = "", 1653 .stats = true 1596 1654 }); 1597 1655 … … 1601 1659 .dir = "Eest/Measurement", 1602 1660 .binningx = binning_eest, 1661 .binningy = {}, 1603 1662 .table = "Spectrum", 1604 1663 .x = ".energy", 1664 .y = "", 1605 1665 .v = "Significance", 1666 .err = "", 1606 1667 .axisx = "Energy lg(E_{est}/GeV)", 1607 .axisy = "Li/Ma Significance" 1608 }); 1609 1610 WriteHistogram(connection, { 1611 .dir = "Eest", 1668 .axisy = "Li/Ma Significance", 1669 .axisz = "", 1670 .stats = true 1671 }); 1672 1673 WriteHistogram(connection, { 1612 1674 .name = "Bias", 1613 1675 .title = "Energy Bias", 1676 .dir = "Eest", 1614 1677 .binningx = binning_eest, 1678 .binningy = {}, 1615 1679 .table = "Spectrum", 1616 1680 .x = ".energy", 1681 .y = "", 1617 1682 .v = "Bias", 1618 1683 .err = "Resolution", 1619 1684 .axisx = "Energy lg(E_{sim}/GeV)", 1620 1685 .axisy = "lg(E_{est}/E_{sim})", 1686 .axisz = "", 1621 1687 .stats = false 1622 1688 }); 1623 1689 1624 1690 WriteHistogram(connection, { 1625 .dir = "Eest",1626 1691 .name = "Resolution", 1627 1692 .title = "Energy Resolution", 1693 .dir = "Eest", 1628 1694 .binningx = binning_eest, 1695 .binningy = {}, 1629 1696 .table = "Spectrum", 1630 1697 .x = ".energy", 1698 .y = "", 1631 1699 .v = "Resolution", 1700 .err = "", 1632 1701 .axisx = "Energy lg(E_{sim}/GeV)", 1633 1702 .axisy = "#sigma(lg(E_{est}/E_{sim}))", 1703 .axisz = "", 1634 1704 .stats = false 1635 1705 }); 1636 1706 1637 1707 WriteHistogram(connection, { 1638 .dir = "Eest/Efficiency",1639 1708 .name = "EfficiencyN", 1640 1709 .title = "Efficiency (Counts)", 1710 .dir = "Eest/Efficiency", 1641 1711 .binningx = binning_eest, 1712 .binningy = {}, 1642 1713 .table = "Spectrum", 1643 1714 .x = ".energy", 1715 .y = "", 1644 1716 .v = "EfficiencyN", 1645 1717 .err = "ErrEfficiencyN", 1646 1718 .axisx = "Energy lg(E_{sim}/GeV)", 1647 .axisy = "Efficiency" 1648 }); 1649 1650 WriteHistogram(connection, { 1651 .dir = "Eest/Efficiency", 1719 .axisy = "Efficiency", 1720 .axisz = "", 1721 .stats = true 1722 }); 1723 1724 WriteHistogram(connection, { 1652 1725 .name = "EfficiencyW", 1653 1726 .title = "Efficiency (Weighted)", 1727 .dir = "Eest/Efficiency", 1654 1728 .binningx = binning_eest, 1729 .binningy = {}, 1655 1730 .table = "Spectrum", 1656 1731 .x = ".energy", 1732 .y = ".", 1657 1733 .v = "EfficiencyW", 1658 1734 .err = "ErrEfficiencyW", 1659 1735 .axisx = "Energy lg(E_{sim}/GeV)", 1660 .axisy = "Efficiency" 1736 .axisy = "Efficiency", 1737 .axisz = "", 1738 .stats = true 1661 1739 }); 1662 1740 … … 1664 1742 .name = "Spectrum", 1665 1743 .title = "Differential Energy Spectrum", 1744 .dir = "", 1666 1745 .binningx = binning_eest, 1746 .binningy = {}, 1667 1747 .table = "Spectrum", 1668 1748 .x = ".energy", 1749 .y = "", 1669 1750 .v = "Flux", 1670 1751 .err = "ErrFlux", 1671 1752 .axisx = "Energy lg(E/GeV)", 1672 1753 .axisy = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]", 1754 .axisz = "", 1673 1755 .stats = false 1674 1756 }); … … 1797 1879 .dir = "Esim/Simulation/Weighted", 1798 1880 .binningx = binning_esim, 1881 .binningy = {}, 1799 1882 .table = "Threshold", 1800 1883 .x = ".energy", 1884 .y = "", 1801 1885 .v = "ThresholdW", 1802 1886 .err = "ErrThresholdW", 1803 1887 .axisx = "Energy lg(E_{sim}/GeV)", 1804 .axisy = "Weighted Counts" 1888 .axisy = "Weighted Counts", 1889 .axisz = "", 1890 .stats = true 1805 1891 }); 1806 1892 … … 1810 1896 .dir = "Esim/Simulation/Counts", 1811 1897 .binningx = binning_esim, 1898 .binningy = {}, 1812 1899 .table = "Threshold", 1813 1900 .x = ".energy", 1901 .y = "", 1814 1902 .v = "ThresholdN", 1815 1903 .err = "ErrThresholdN", 1816 1904 .axisx = "Energy lg(E_{sim}/GeV)", 1817 .axisy = "Counts" 1905 .axisy = "Counts", 1906 .axisz = "", 1907 .stats = true 1818 1908 }); 1819 1909 … … 1821 1911 .name = "SimSpectrumW", 1822 1912 .title = "Weighted Simulated Excess Spectrum", 1913 .dir = "Esim/Simulation/Weighted", 1823 1914 .binningx = binning_esim, 1824 . dir = "Esim/Simulation/Weighted",1915 .binningy = {}, 1825 1916 .table = "Threshold", 1826 1917 .x = ".energy", 1918 .y = "", 1827 1919 .v = "Flux", 1828 1920 .err = "ErrFlux", 1829 1921 .axisx = "Energy lg(E_{sim}/GeV)", 1830 .axisy = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]" 1831 }); 1832 1833 WriteHistogram(connection, { 1834 .dir = "Esim", 1922 .axisy = "dN/dE [cm^{-2} s^{-1} TeV^{-1}]", 1923 .axisz = "", 1924 .stats = true 1925 }); 1926 1927 WriteHistogram(connection, { 1835 1928 .name = "Bias", 1836 1929 .title = "Energy Bias", 1930 .dir = "Esim", 1837 1931 .binningx = binning_esim, 1932 .binningy = {}, 1838 1933 .table = "Threshold", 1839 1934 .x = ".energy", 1935 .y = "", 1840 1936 .v = "Bias", 1841 1937 .err = "Resolution", 1842 1938 .axisx = "Energy lg(E_{sim}/GeV)", 1843 1939 .axisy = "lg(E_{est}/E_{sim})", 1940 .axisz = "", 1844 1941 .stats = false 1845 1942 }); 1846 1943 1847 1944 WriteHistogram(connection, { 1848 .dir = "Esim",1849 1945 .name = "Resolution", 1850 1946 .title = "Energy Resolution", 1947 .dir = "Esim", 1851 1948 .binningx = binning_esim, 1949 .binningy = {}, 1852 1950 .table = "Threshold", 1853 1951 .x = ".energy", 1952 .y = "", 1854 1953 .v = "Resolution", 1954 .err = "", 1855 1955 .axisx = "Energy lg(E_{sim}/GeV)", 1856 1956 .axisy = "#sigma(lg(E_{est}/E_{sim}))", 1957 .axisz = "", 1857 1958 .stats = false 1858 1959 }); … … 1912 2013 .name = "MigrationN", 1913 2014 .title = "Energy Migration", 2015 .dir = "", 1914 2016 .binningx = binning_esim, 1915 2017 .binningy = binning_eest, … … 1918 2020 .y = ".energyest", 1919 2021 .v = "MigrationN", 2022 .err = "", 1920 2023 .axisx = "Energy lg(E_{sim}/GeV)", 1921 2024 .axisy = "Energy lg(E_{est}/GeV)", … … 1927 2030 .name = "MigrationW", 1928 2031 .title = "Energy Migration", 2032 .dir = "", 1929 2033 .binningx = binning_esim, 1930 2034 .binningy = binning_eest, … … 1933 2037 .y = ".energyest", 1934 2038 .v = "MigrationW", 2039 .err = "", 1935 2040 .axisx = "Energy lg(E_{sim}/GeV)", 1936 2041 .axisy = "Energy lg(E_{est}/GeV)",
Note:
See TracChangeset
for help on using the changeset viewer.