48namespace HFitInterface {
53 if (func ==
nullptr)
return false;
71 }
else if (
option.fErrors1)
79 double xlow =
range.first;
82 std::cout <<
"xlow " << xlow <<
" xhigh = " <<
xhigh << std::endl;
88 Warning(
"ROOT::Fit::FillData",
"fit range is outside histogram range, no fit data for %s",axis->
GetName());
139 if (
range.Size(0) != 0) {
141 if (
range.Size(0) > 1 ) {
142 Warning(
"ROOT::Fit::FillData",
"support only one range interval for X coordinate");
146 if (
hfit->GetDimension() > 1 &&
range.Size(1) != 0) {
148 if (
range.Size(1) > 1 )
149 Warning(
"ROOT::Fit::FillData",
"support only one range interval for Y coordinate");
152 if (
hfit->GetDimension() > 2 &&
range.Size(2) != 0) {
154 if (
range.Size(2) > 1 )
155 Warning(
"ROOT::Fit::FillData",
"support only one range interval for Z coordinate");
162 std::cout <<
"THFitInterface: ifirst = " <<
hxfirst <<
" ilast = " <<
hxlast
163 <<
" total bins " <<
n
218 if (func !=
nullptr) {
229 if (ndim ==
hdim -1) {
241 dv.AddBinUpEdge( s );
247 std::cout <<
"bin " <<
binx <<
" add point " <<
x[0] <<
" " <<
hfit->GetBinContent(
binx) << std::endl;
256 std::cout <<
"THFitInterface::FillData: Hist FitData size is " <<
dv.Size() << std::endl;
266 unsigned int n =
data.Size();
275 for (
unsigned int i = 1; i <
n; ++ i) {
277 double x = *(
data.GetPoint(i,val) );
306 static const double sqrtpi = 2.506628;
309 unsigned int n =
data.Size();
320 for (
unsigned int i = 0; i <
n; ++ i) {
322 double x = *(
data.GetPoint(i,val) );
376 std::cout <<
"Gaussian initial par values" <<
constant <<
" " << mean <<
" " <<
rms << std::endl;
388 static const double sqrtpi = 2.506628;
391 unsigned int n =
data.Size();
403 double x0 = 0,
y0 = 0;
404 for (
unsigned int i = 0; i <
n; ++i) {
406 const double *coords =
data.GetPoint(i,val);
407 double x = coords[0],
y = coords[1];
460 std::cout <<
"2D Gaussian initial par values"
484 if (
fitOpt.fErrors1 || (
ey ==
nullptr && (
eyl ==
nullptr ||
eyh ==
nullptr ) ) ) {
489 else if (
ex !=
nullptr &&
fitOpt.fCoordErrors) {
498 else if ( (
eyl !=
nullptr &&
eyh !=
nullptr) &&
fitOpt.fAsymErrors) {
516 fitOpt.fCoordErrors =
false;
536 std::cout <<
"type is " <<
type <<
" graph type is " <<
gr->
IsA()->
GetName() << std::endl;
546 double *
ez =
gr->GetEZ();
551 if (
fitOpt.fErrors1 ||
ez ==
nullptr ) {
554 else if (
ex !=
nullptr &&
ey!=
nullptr &&
fitOpt.fCoordErrors) {
565 std::cout <<
"type is " <<
type <<
" graph2D type is " <<
gr->
IsA()->
GetName() << std::endl;
593 std::cout <<
"DoFillData: graph npoints = " <<
nPoints <<
" type " <<
type << std::endl;
595 double a1,
a2; func->
GetRange(
a1,
a2); std::cout <<
"func range " <<
a1 <<
" " <<
a2 << std::endl;
603 std::vector<std::pair<double, int>>
indexRemap;
604 for (
int i = 0; i <
nPoints; ++i) {
640 std::cout <<
"Point " << i <<
" " <<
gx[i] <<
" " <<
gy[i] <<
" " <<
errorY << std::endl;
676 std::cout <<
"TGraphFitInterface::FillData Graph FitData size is " <<
dv.Size() << std::endl;
684 std::vector<double> min(dim);
685 std::vector<double> max(dim);
688 for (
int i = 0; i <
ncells; ++i ) {
727 const int dim =
h1->GetNdimensions();
728 std::vector<double> min(dim);
729 std::vector<double> max(dim);
730 std::vector<Int_t>
coord(dim);
736 if ( !
value )
continue;
750 max[
j] =
h1->GetAxis(
j)->GetBinUpEdge(
coord[
j]);
771 unsigned int const ndim =
s1->GetNdimensions();
772 std::vector<double>
xmin(ndim);
773 std::vector<double>
xmax(ndim);
774 for (
unsigned int i = 0; i < ndim; ++i ) {
786 dopt.fBinVolume =
true;
787 dopt.fNormBinVolume =
true;
796 d.GetBinDataIntegral(
dv);
820 if (
dv.Size() > 0 &&
dv.NDim() == 1 ) {
822 if (
dv.GetErrorType() !=
type ) {
823 Error(
"FillData",
"Inconsistent TGraph with previous data set- skip all graph data");
844 std::cout <<
"multi-graph list of graps: " << std::endl;
845 while ((obj =
itr())) {
846 std::cout << obj->
IsA()->GetName() << std::endl;
871 std::cout <<
"Fitting MultiGraph of type " <<
type << std::endl;
881 std::cout <<
"TGraphFitInterface::FillData MultiGraph FitData size is " <<
dv.Size() << std::endl;
898 fitOpt.fAsymErrors =
false;
903 double *
gz =
gr->GetZ();
906 if (
gr->GetEZ() ==
nullptr)
fitOpt.fErrors1 =
true;
923 for (
int i = 0; i <
nPoints; ++i) {
960 std::cout <<
"Point " << i <<
" " <<
gx[i] <<
" " <<
gy[i] <<
" " <<
errorZ << std::endl;
966 std::cout <<
"THFitInterface::FillData Graph2D FitData size is " <<
dv.Size() << std::endl;
975 Error(
"GetConfidenceIntervals",
"Invalid object used for storing confidence intervals");
986 const double *
x =
d.Coords(
ipoint);
const Bool_t kIterBackward
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
class describing the range in the coordinates it supports multiple range in a coordinate.
class containing the result of the fit and all the related information (fitted parameter values,...
SparseData class representing the data of a THNSparse histogram The data needs to be converted to a B...
const_iterator begin() const
const_iterator end() const
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
static void RejectPoint(Bool_t reject=kTRUE)
Static function to set the global flag to reject points the fgRejectPoint global flag is tested by al...
virtual void GetRange(Double_t *xmin, Double_t *xmax) const
Return range of a generic N-D function.
virtual void SetParLimits(Int_t ipar, Double_t parmin, Double_t parmax)
Set lower and upper limits for parameter ipar.
static Bool_t RejectedPoint()
See TF1::RejectPoint above.
virtual void SetParameters(const Double_t *params)
virtual void SetParameter(Int_t param, Double_t value)
virtual Bool_t IsInside(const Double_t *x) const
return kTRUE if the point is inside the function range
virtual Int_t GetNdim() const
Graphics object made of three arrays X, Y and Z with the same number of points each.
A TGraphErrors is a TGraph with error bars.
Double_t GetErrorY(Int_t bin) const override
It returns the error along Y at point i.
Double_t * GetEX() const override
Double_t GetErrorX(Int_t bin) const override
It returns the error along X at point i.
Double_t * GetEY() const override
Double_t GetErrorXhigh(Int_t bin) const override
It returns the error along X at point i.
Double_t GetErrorYlow(Int_t bin) const override
It returns the error along Y at point i.
Double_t GetErrorYhigh(Int_t bin) const override
It returns the error along Y at point i.
TClass * IsA() const override
Double_t GetErrorXlow(Int_t bin) const override
It returns the error along X at point i.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual Double_t * GetEYlow() const
virtual Double_t * GetEYhigh() const
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t GetDimension() const
virtual void GetBinXYZ(Int_t binglobal, Int_t &binx, Int_t &biny, Int_t &binz) const
Return binx, biny, binz corresponding to the global bin number globalbin see TH1::GetBin function abo...
virtual Int_t GetNcells() const
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return bin lower edge for 1D histogram.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Multidimensional histogram base.
A TMultiGraph is a collection of TGraph (or derived) objects.
TList * GetListOfGraphs() const
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual TClass * IsA() const
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
void ExamineRange(const TAxis *axis, std::pair< double, double > range, int &hxfirst, int &hxlast)
bool AdjustError(const DataOptions &option, double &error, double value=1)
bool IsPointOutOfRange(const TF1 *func, const double *x)
void Init2DGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for 2D gaussian function given the fit data Set the sigma limits for zero t...
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.
void InitExpo(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for an exponential function given the fit data Set the constant and slope a...
void InitGaus(const ROOT::Fit::BinData &data, TF1 *f1)
compute initial parameter for gaussian function given the fit data Set the sigma limits for zero top ...
void DoFillData(BinData &dv, const TGraph *gr, BinData::ErrorType type, TF1 *func)
BinData::ErrorType GetDataType(const TGraph *gr, DataOptions &fitOpt)
bool GetConfidenceIntervals(const TH1 *h1, const ROOT::Fit::FitResult &r, TGraphErrors *gr, double cl=0.95)
compute confidence intervals at level cl for a fitted histogram h1 in a TGraphErrors gr
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
DataOptions : simple structure holding the options on how the data are filled.