1 #ifndef __JROOT__JROOTFIT__
2 #define __JROOT__JROOTFIT__
27 namespace JPP {
using namespace JROOT; }
54 return range_type(pAxis->GetXmin(), pAxis->GetXmax());
89 return std::numeric_limits<double>::min();
99 inline double getRho(
const double z)
const
113 inline double getPsi(
const double z)
const
143 const double error) :
155 inline double getRho(
const double z)
const
169 inline double getPsi(
const double z)
const
173 return -0.5 * u /
error;
274 m_3d(
const double x,
const double y,
const double z,
const T&
v) :
327 void unpack(
const TH1& h1,
342 for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
344 const double x = h1.GetXaxis()->GetBinCenter(ix);
345 const size_t count = h1.GetBinContent(ix);
364 for (Int_t ix = 1; ix <= h1.GetXaxis()->GetNbins(); ++ix) {
366 const double x = h1.GetXaxis()->GetBinCenter(ix);
367 const double value = h1.GetBinContent(ix);
368 const double error = h1.GetBinError (ix);
370 if (
X(x) && error > 0.0) {
413 void unpack(
const TH2& h2,
431 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
432 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
434 const double x = h2.GetXaxis()->GetBinCenter(ix);
435 const double y = h2.GetYaxis()->GetBinCenter(iy);
436 const size_t count = h2.GetBinContent(ix,iy);
458 for (Int_t ix = 1; ix <= h2.GetXaxis()->GetNbins(); ++ix) {
459 for (Int_t iy = 1; iy <= h2.GetYaxis()->GetNbins(); ++iy) {
461 const double x = h2.GetXaxis()->GetBinCenter(ix);
462 const double y = h2.GetYaxis()->GetBinCenter(iy);
463 const double value = h2.GetBinContent(ix,iy);
464 const double error = h2.GetBinError (ix,iy);
466 if (
X(x) &&
Y(y) && error > 0.0) {
513 void unpack(
const TH3& h3,
534 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
535 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
536 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
538 const double x = h3.GetXaxis()->GetBinCenter(ix);
539 const double y = h3.GetYaxis()->GetBinCenter(iy);
540 const double z = h3.GetZaxis()->GetBinCenter(iz);
541 const size_t count = h3.GetBinContent(ix,iy,iz);
543 if (
X(x) &&
Y(y) &&
Z(z)) {
566 for (Int_t ix = 1; ix <= h3.GetXaxis()->GetNbins(); ++ix) {
567 for (Int_t iy = 1; iy <= h3.GetYaxis()->GetNbins(); ++iy) {
568 for (Int_t iz = 1; iz <= h3.GetZaxis()->GetNbins(); ++iz) {
570 const double x = h3.GetXaxis()->GetBinCenter(ix);
571 const double y = h3.GetYaxis()->GetBinCenter(iy);
572 const double z = h3.GetZaxis()->GetBinCenter(iz);
573 const double value = h3.GetBinContent(ix,iy,iz);
574 const double error = h3.GetBinError (ix,iy,iz);
576 if (
X(x) &&
Y(y) &&
Z(z) && error > 0.0) {
598 template<
class JF1_t>
615 template<
class JF1_t>
660 template<
class JF2_t>
681 template<
class JF2_t>
727 template<
class JF3_t>
728 JF3(
const char*
const name,
752 template<
class JF3_t>
777 return this->
getValue(x[0], x[1], x[2]);
802 std::set<size_t>(indices)
815 if (std::find(parameters.begin(), parameters.end(),
T::parameters[
i]) != parameters.end()) {
826 template<
class JFs_t>
936 template<
class JFs_t>
994 h1->GetListOfFunctions()->Add(
new JF1(
"f1",
1046 (*this)(*h2, f2,
type, ls,
X,
Y);
1048 h2->GetListOfFunctions()->Add(
new JF2(
"f2",
1107 h3->GetListOfFunctions()->Add(
new JF3(
"f3",
1142 if (ls.count(
i) == 0) {
1148 this->
npx = data.size();
1172 const double y = fs.getValue(mp.
x);
1175 result.gradient = fs.getGradient(mp.
x);
1176 result.gradient *= mp.getPsi(y);
1192 const double y = fs.getValue(mp.
x, mp.
y);
1195 result.gradient = fs.getGradient(mp.
x, mp.
y);
1196 result.gradient *= mp.getPsi(y);
1215 result.gradient = fs.getGradient(mp.
x, mp.
y, mp.
z);
1216 result.gradient *= mp.getPsi(y);
1230 template<
class JFs_t>
1245 template<
class T,
class JF1_t>
1267 template<
class T,
class JF1_t>
1289 template<
class T,
class JF2_t>
1313 template<
class T,
class JF2_t>
1337 template<
class T,
class JF3_t>
1363 template<
class T,
class JF3_t>
JF3(const char *const name, const JF3_t &f3, const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Constructor.
double getError(size_t i) const
Get error of parameter at given index.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
int getParameter(const std::string &text)
Get parameter number from text string.
data_type()
Default constructor.
Auxiliary methods for mathematics.
index_list(const std::initializer_list< double T::* > ¶meters)
Conversion constructor.
m_count(const size_t count)
Constructor.
Auxiliary data structure for list of parameters.
const JFs_t & getFunction() const
Get function.
Template definition of data structure for set of data points.
double getRho(const double z) const
Get chi2.
then usage $script< input file >[option] nPossible options count
const result_type & operator()(const TH2 &h2, const JFs_t &f2, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type())
Fit.
const result_type & operator()(const TH3 &h3, const JFs_t &f3, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Fit.
JRootfit_t()
Default constructor.
m_3d()
Default constructor.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
m_1d(const double x, const T &v)
Constructor.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
std::vector< parameter_type > parameters
fit parameters
m_count()
Default constructor.
void unpack(const TH1 &h1, const range_type &X)
const result_type & operator()(const TH1 &h1, const JFs_t &f1, const T &type, const index_list &ls=index_list(), const range_type &X=range_type())
Fit.
data_type(const TH2 &h2, const range_type &X=range_type(), const range_type &Y=range_type())
Unpack constructor.
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
JRootfit()
Default constructor.
double getPsi(const double z) const
Get derivative of chi2.
void setParameters(JF1_t *f1, const double *values)
Set values of all parameters.
double getParameter(const JF1_t &f1, const size_t i)
Get value of parameter at given index.
then set_variable PMT_FILE set_variable DAQ_FILE set_variable OUTPUT_FILE set_variable DETECTOR else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
helper(const JF2_t &f2)
Constructor.
data_type(const TH3 &h3, const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Unpack constructor.
helper(const JF1_t &f1)
Constructor.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
Wrapper data structure to build ROOT 1D function.
Auxiliary data structure for list of fixed parameters.
Base class for result of ROOT Fit.
static JRootfit Fit
Global fit object.
data_type(const TH1 &h1, const range_type &X=range_type())
Unpack constructor.
double getRho(const double z) const
Get chi2.
size_t getNumberOfFreeParameters() const
Get number of free parameters.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JF1(const char *const name, const JF1_t &f1, const range_type &X=range_type())
Constructor.
size_t getN() const
Get number of data points.
size_t getNumberOfParameters() const
Get number of parameters.
JRootfit_t< JF1_t > Fit(const TH1 &h1, const JF1_t &f1, const index_list &ls=index_list(), const range_type &X=range_type())
Global fit fuction.
const result_type & operator()(TH2 *h2, const JFs_t &f2, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type())
Fit.
data_type()
Default constructor.
const result_type & operator()(TH3 *h3, const JFs_t &f3, const T &type, const index_list &ls=index_list(), const range_type &X=range_type(), const range_type &Y=range_type(), const range_type &Z=range_type())
Fit.
m_value()
Default constructor.
then fatal The output file must have the wildcard in the name
range_type getRange(TAxis *pAxis)
Get range of given axis.
m_1d()
Default constructor.
Wrapper data structure to build ROOT 2D function.
Data point for counting measurement.
const result_type & operator()(TH1 *h1, const JFs_t &f1, const T &type, const index_list &ls=index_list(), const range_type &X=range_type())
Fit.
Fit method based on the Levenberg-Marquardt method.
const result_type & eval(const JFs_t &fs, const index_list &ls, const data_type< T > &data)
Evaluate fit.
m_2d(const double x, const double y, const T &v)
Constructor.
size_t getNumberOfFreeParameters()
struct JROOT::JRootfit::@61 fit
Auxiliary data structure for fit functions.
Auxiliary class to define a range between two values.
Wrapper data structure to build ROOT 3D function.
m_value(const double value, const double error)
Constructor.
size_t npx
number of data points
double poisson(const size_t n, const double mu)
Poisson probability density distribition.
m_2d()
Default constructor.
static double epsilon()
Minimal value for numerical computations.
data_type()
Default constructor.
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
no fit printf nominal n $STRING awk v X
int getNDF() const
Get number of degrees of freedom.
JF2(const char *const name, const JF2_t &f2, const range_type &X=range_type(), const range_type &Y=range_type())
Constructor.
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
double getValue(size_t i) const
Get value of parameter at given index.
double f3(const double x, const double y, const double z)
3D function.
double operator()(const double *x, const double *parameters)
ROOT compatible function call.
m_3d(const double x, const double y, const double z, const T &v)
Constructor.
double getChi2() const
Get chi2.
helper(const JF3_t &f3)
Constructor.
index_list()
Default constructor.
JRootfit_t< JFs_t > result_type
index_list(const std::initializer_list< size_t > &indices)
Constructor.
Data point for value with error.
JGandalf< JFs_t >::result_type result_type
double getPsi(const double z) const
Get derivative of chi2.
size_t getNumberOfParameters()
Get number of parameters.