...
 
Commits (3)
.PHONY: all clean
# Add C++14 standard flag if no other C++ standard was selected
ifneq (,$(findstring CXXFLAGS,-std=))
CXXFLAGS += -std=c++14
endif
all: $(TARGET)
clean:
......
......@@ -3,19 +3,28 @@ HEADERS := $(wildcard *.hh)
OBJECTS := $(patsubst %.cc,%.o,$(SOURCES))
DEPS := $(patsubst %.cc,%.d,$(SOURCES))
ROOT_CLING = rootcling
# Removed -rml lib$(MODNAME).so as a precaution, failed in fit
ROOT_CLING_FLAGS = -f $@ -noIncludePaths -inlineInputHeader -s $(TARGET) -rmf $(ROOTMAP)
ROOT_CXXFLAGS := $(shell root-config --cflags)
ROOT_GLIBS := $(shell root-config --glibs)
LIBMFILE_CFLAGS = # e.g. -I/usr/local/include
LIBMFILE_LDFLAGS = # e.g. -L /opt/lib64
MFILE_CFLAGS = # e.g. -I/usr/local/include
MFILE_LDFLAGS = # e.g. -L /opt/lib64
LIBX11_CFLAGS = # e.g. -I/opt/X11/include
LIBX11_LDFLAGS = # e.g. -L/opt/X11/lib
CFLAGS = -O2 -g -Wall -fPIC $(DEPFLAGS) $(MFILE_CFLAGS)
CXXFLAGS = $(ROOT_CXXFLAGS) $(MFILE_CFLAGS) -Wall -g -O2 -fPIC $(DEPFLAGS)
ROOT_CONFIG = root-config
ROOT_CLING = rootcling
ROOT_CLING_FLAGS = -f $@ -noIncludePaths -inlineInputHeader
ROOT_CLING_FLAGS += -s $(TARGET) -rmf $(ROOTMAP)
# Removed as a precaution, failed in fit
# ROOT_CLING_FLAGS += -rml lib$(MODNAME).so
ROOT_CXXFLAGS := $(shell $(ROOT_CONFIG) --cflags)
ROOT_LIBS := $(shell $(ROOT_CONFIG) --libs)
ROOT_GLIBS := $(shell $(ROOT_CONFIG) --glibs)
CFLAGS = -O2 -g -Wall -fPIC $(DEPFLAGS)
CXXFLAGS = $(ROOT_CXXFLAGS) -Wall -g -O2 -fPIC $(DEPFLAGS) -I../util
LDFLAGS = -shared
LDLIBS = -lstdc++ $(ROOT_GLIBS) -lX11
LDLIBS = -lstdc++
DEPFLAGS = -MT $@ -MMD -MP -MF $*.Td
POSTCOMPILE = mv -f $*.Td $*.d
......
......@@ -31,6 +31,8 @@
#include <TAxis.h>
#include "Compat.hh"
namespace HDTV {
void Calibration::SetCal(const std::vector<double> &cal) {
......@@ -155,7 +157,7 @@ double Calibration::E2Ch(double e) const {
}
void Calibration::Apply(TAxis *axis, int nbins) {
auto centers = std::make_unique<double[]>(nbins);
auto centers = Util::make_unique<double[]>(nbins);
for (int i = 0; i < nbins; i++) {
centers[i] = Ch2E(i);
......
......@@ -23,8 +23,7 @@
#include "DisplayObj.hh"
#include <algorithm>
#include <Riostream.h>
#include <iostream>
#include "DisplayStack.hh"
#include "View1D.hh"
......
......@@ -24,7 +24,6 @@
#include <utility>
#include <Riostream.h>
#include <TH1.h>
#include <TROOT.h>
......
......@@ -2,4 +2,14 @@
MODNAME = display
include ../Makefile.def
CFLAGS += $(LIBX11_CFLAGS)
CXXFLAGS += $(LIBX11_CFLAGS)
LDFLAGS += $(LIBX11_LDFLAGS)
LDLIBS += $(ROOT_GLIBS) -lX11
ROOT_CLING_FLAGS += $(LIBX11_CFLAGS)
include ../Makefile.body
......@@ -22,7 +22,6 @@
#include "Marker.hh"
#include <Riostream.h>
#include <TColor.h>
#include <TROOT.h>
......
......@@ -22,7 +22,6 @@
#include "Painter.hh"
#include <Riostream.h>
#include <TGX11.h>
#include "DisplayFunc.hh"
......
......@@ -25,8 +25,8 @@
#include <cmath>
#include <limits>
#include <iostream>
#include <Riostream.h>
#include <TGScrollBar.h>
#include <TGStatusBar.h>
......
......@@ -32,6 +32,7 @@
#include <TH1.h>
#include <TVirtualFitter.h>
#include "Compat.hh"
#include "Util.hh"
namespace HDTV {
......@@ -125,9 +126,9 @@ TF1 *EEPeak::GetPeakFunc() {
double max = fPos.Value(fFunc) + DECOMP_FUNC_WIDTH * fSigma2.Value(fFunc);
int numParams = fFunc->GetNpar();
fPeakFunc = std::make_unique<TF1>(GetFuncUniqueName("eepeak", this).c_str(),
this, &EEPeak::Eval, min, max, numParams,
"EEPeak", "Eval");
fPeakFunc = Util::make_unique<TF1>(GetFuncUniqueName("eepeak", this).c_str(),
this, &EEPeak::Eval, min, max, numParams,
"EEPeak", "Eval");
for (int i = 0; i < numParams; i++) {
fPeakFunc->SetParameter(i, fFunc->GetParameter(i));
......@@ -178,8 +179,9 @@ void EEPeak::StoreIntegral() {
double dAdGamma = A * (std::log(sigma2 * eta + B) +
gamma / (sigma2 * eta + B) * dBdGamma);
double Vt = A / (1. - gamma) * (std::pow(B + 5. * sigma1, 1. - gamma) -
std::pow(B + eta * sigma2, 1. - gamma));
double Vt = A / (1. - gamma) *
(std::pow(B + 5. * sigma1, 1. - gamma) -
std::pow(B + eta * sigma2, 1. - gamma));
double dVtdA = Vt / A;
double dVtdB = A * (std::pow(B + 5. * sigma1, -gamma) -
......@@ -219,10 +221,11 @@ void EEPeak::StoreIntegral() {
std::erf(5. * std::sqrt(std::log(2.)) * sigma1 / sigma2);
double dVrdSigma1 = 5. * std::exp(-25. * std::log(2) * (sigma1 * sigma1) /
(sigma2 * sigma2));
double dVrdSigma2 = Vr / sigma2 -
5. * std::exp(-25. * std::log(2) * (sigma1 * sigma1) /
(sigma2 * sigma2)) *
sigma1 / sigma2;
double dVrdSigma2 =
Vr / sigma2 - 5. *
std::exp(-25. * std::log(2) * (sigma1 * sigma1) /
(sigma2 * sigma2)) *
sigma1 / sigma2;
vol += Vr;
dVdSigma1 += dVrdSigma1;
......@@ -308,9 +311,9 @@ TF1 *EEFitter::GetBgFunc() {
max = fMax;
}
fBgFunc = std::make_unique<TF1>(GetFuncUniqueName("fitbg_ee", this).c_str(),
this, &EEFitter::EvalBg, min, max, fNumParams,
"EEFitter", "EvalBg");
fBgFunc = Util::make_unique<TF1>(GetFuncUniqueName("fitbg_ee", this).c_str(),
this, &EEFitter::EvalBg, min, max,
fNumParams, "EEFitter", "EvalBg");
for (int i = 0; i < fNumParams; i++) {
fBgFunc->SetParameter(i, fSumFunc->GetParameter(i));
......@@ -355,8 +358,8 @@ void EEFitter::_Fit(TH1 &hist) {
}
// Create fit function
fSumFunc = std::make_unique<TF1>("f", this, &EEFitter::Eval, fMin, fMax,
fNumParams, "EEFitter", "Eval");
fSumFunc = Util::make_unique<TF1>("f", this, &EEFitter::Eval, fMin, fMax,
fNumParams, "EEFitter", "Eval");
// Init fit parameters
// Note: this may set parameters several times, but that should not matter
......@@ -448,9 +451,9 @@ void EEFitter::_Restore(double ChiSquare) {
// Internal worker function to restore the fit
// Create fit function
fSumFunc = std::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&EEFitter::Eval, fMin, fMax, fNumParams,
"EEFitter", "Eval");
fSumFunc = Util::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&EEFitter::Eval, fMin, fMax, fNumParams,
"EEFitter", "Eval");
for (auto &peak : fPeaks) {
peak.SetSumFunc(fSumFunc.get());
......
......@@ -2,4 +2,7 @@
MODNAME = fit
include ../Makefile.def
LDLIBS += $(ROOT_LIBS)
include ../Makefile.body
......@@ -31,6 +31,7 @@
#include <TH1.h>
#include <TVirtualFitter.h>
#include "Compat.hh"
#include "Util.hh"
namespace HDTV {
......@@ -49,10 +50,10 @@ PolyBg::PolyBg(const PolyBg &src)
//! Copy constructor
if (src.fFunc != nullptr) {
fFunc = std::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, src.fFunc->GetXmin(),
src.fFunc->GetXmax(), fBgDeg + 1, "PolyBg",
"_Eval");
fFunc = Util::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, src.fFunc->GetXmin(),
src.fFunc->GetXmax(), fBgDeg + 1, "PolyBg",
"_Eval");
for (int i = 0; i <= fBgDeg; i++) {
fFunc->SetParameter(i, src.fFunc->GetParameter(i));
......@@ -74,10 +75,10 @@ PolyBg &PolyBg::operator=(const PolyBg &src) {
fChisquare = src.fChisquare;
fCovar = src.fCovar;
fFunc = std::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, src.fFunc->GetXmin(),
src.fFunc->GetXmax(), fBgDeg + 1, "PolyBg",
"_Eval");
fFunc = Util::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, src.fFunc->GetXmin(),
src.fFunc->GetXmax(), fBgDeg + 1, "PolyBg",
"_Eval");
for (int i = 0; i <= fBgDeg; i++) {
fFunc->SetParameter(i, src.fFunc->GetParameter(i));
......@@ -125,9 +126,9 @@ void PolyBg::Fit(TH1 &hist) {
}
// Copy parameters to new function
fFunc = std::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, GetMin(), GetMax(), fBgDeg + 1,
"PolyBg", "_Eval");
fFunc = Util::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, GetMin(), GetMax(), fBgDeg + 1,
"PolyBg", "_Eval");
for (int i = 0; i <= fBgDeg; i++) {
fFunc->SetParameter(i, fitFunc.GetParameter(i));
......@@ -148,9 +149,9 @@ bool PolyBg::Restore(const TArrayD &values, const TArrayD &errors,
}
// Copy parameters to new function
fFunc = std::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, GetMin(), GetMax(), fBgDeg + 1,
"PolyBg", "_Eval");
fFunc = Util::make_unique<TF1>(GetFuncUniqueName("b", this).c_str(), this,
&PolyBg::_Eval, GetMin(), GetMax(), fBgDeg + 1,
"PolyBg", "_Eval");
for (int i = 0; i <= fBgDeg; i++) {
fFunc->SetParameter(i, values[i]);
......
......@@ -27,11 +27,11 @@
#include <algorithm>
#include <numeric>
#include <Riostream.h>
#include <TError.h>
#include <TF1.h>
#include <TH1.h>
#include "Compat.hh"
#include "Util.hh"
namespace HDTV {
......@@ -122,9 +122,10 @@ TF1 *TheuerkaufPeak::GetPeakFunc() {
double max = fPos.Value(fFunc) + DECOMP_FUNC_WIDTH * fSigma.Value(fFunc);
int numParams = fFunc->GetNpar();
fPeakFunc = std::make_unique<TF1>(GetFuncUniqueName("peak", this).c_str(),
this, &TheuerkaufPeak::EvalNoStep, min, max,
numParams, "TheuerkaufPeak", "EvalNoStep");
fPeakFunc =
Util::make_unique<TF1>(GetFuncUniqueName("peak", this).c_str(), this,
&TheuerkaufPeak::EvalNoStep, min, max, numParams,
"TheuerkaufPeak", "EvalNoStep");
for (int i = 0; i < numParams; i++) {
fPeakFunc->SetParameter(i, fFunc->GetParameter(i));
......@@ -284,9 +285,9 @@ TF1 *TheuerkaufFitter::GetBgFunc() {
max = fMax;
}
fBgFunc = std::make_unique<TF1>(GetFuncUniqueName("fitbg", this).c_str(),
this, &TheuerkaufFitter::EvalBg, min, max,
fNumParams, "TheuerkaufFitter", "EvalBg");
fBgFunc = Util::make_unique<TF1>(GetFuncUniqueName("fitbg", this).c_str(),
this, &TheuerkaufFitter::EvalBg, min, max,
fNumParams, "TheuerkaufFitter", "EvalBg");
for (int i = 0; i < fNumParams; i++) {
fBgFunc->SetParameter(i, fSumFunc->GetParameter(i));
......@@ -330,9 +331,9 @@ void TheuerkaufFitter::_Fit(TH1 &hist) {
}
// Create fit function
fSumFunc = std::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&TheuerkaufFitter::Eval, fMin, fMax,
fNumParams, "TheuerkaufFitter", "Eval");
fSumFunc = Util::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&TheuerkaufFitter::Eval, fMin, fMax,
fNumParams, "TheuerkaufFitter", "Eval");
PeakVector_t::const_iterator citer;
......@@ -599,9 +600,9 @@ bool TheuerkaufFitter::Restore(const TArrayD &bgPolValues,
//! Internal worker function to restore the fit
void TheuerkaufFitter::_Restore(double ChiSquare) {
// Create fit function
fSumFunc = std::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&TheuerkaufFitter::Eval, fMin, fMax,
fNumParams, "TheuerkaufFitter", "Eval");
fSumFunc = Util::make_unique<TF1>(GetFuncUniqueName("f", this).c_str(), this,
&TheuerkaufFitter::Eval, fMin, fMax,
fNumParams, "TheuerkaufFitter", "Eval");
for (auto &peak : fPeaks) {
peak.SetSumFunc(fSumFunc.get());
......
......@@ -3,8 +3,15 @@ MODNAME := mfile-root
include ../Makefile.def
LDFLAGS += $(MFILE_LDFLAGS)
LDLIBS += -lmfile
CFLAGS += $(LIBMFILE_CFLAGS)
CXXFLAGS += $(LIBMFILE_CFLAGS)
LDFLAGS += $(MFILE_LDFLAGS)
LDLIBS += $(ROOT_LIBS)
LDLIBS += -lmfile
ROOT_CLING_FLAGS += $(LIBMFILE_CFLAGS)
MATOP_SOURCES := $(wildcard matop/*.c)
MATOP_OBJECTS := $(patsubst %.c,%.o,$(MATOP_SOURCES))
......
#ifndef HDTV_ROOTEXT_UTIL_COMPAT_HH
#define HDTV_ROOTEXT_UTIL_COMPAT_HH
#include <memory>
#include <type_traits>
namespace HDTV {
namespace Util {
#if __cplusplus >= 201402L
using std::make_unique;
#else
namespace detail {
template <typename T> struct MakeUniq {
using single_object = std::unique_ptr<T>;
};
template <typename T> struct MakeUniq<T[]> {
using array = std::unique_ptr<T[]>;
};
template <typename T, size_t N> struct MakeUniq<T[N]> {
struct invalid_type {};
};
} // namespace detail
// make_unique for single objects
template <typename T, typename... Args>
inline typename detail::MakeUniq<T>::single_object
make_unique(Args &&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
// make_unique for arrays of unknown bound
template <typename T, typename... Args>
inline typename detail::MakeUniq<T>::array
make_unique(size_t n) {
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[n]);
}
// disable make_unique for arrays of known bounds
template <typename T, typename... Args>
inline typename detail::MakeUniq<T>::invalid_type
make_unique(Args &&... args) = delete;
#endif /* __cplusplus */
} // namespace Util
} // namespace HDTV
#endif /* HDTV_ROOTEXT_UTIL_COMPAT_HH */