//*CMZ : 2.00/11 08/08/98 22.48.25 by Rene Brun
//*CMZ : 2.00/09 23/06/98 17.59.18 by Rene Brun
//*CMZ : 1.03/09 16/03/98 08.22.34 by Fons Rademakers
//*-- Author : Rene Brun 28/11/96
//*KEEP,CopyRight,T=C.
/*************************************************************************
* Copyright(c) 1995-1999, The ROOT System, All rights reserved. *
* Authors: Rene Brun, Fons Rademakers. *
* For list of contributors see $ROOTSYS/AA_CREDITS. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation for non-commercial purposes is hereby granted without *
* fee, provided that the above copyright notice appears in all copies *
* and that both the copyright notice and this permission notice appear *
* in the supporting documentation. The authors make no claims about the *
* suitability of this software for any purpose. It is provided "as is" *
* without express or implied warranty. *
*************************************************************************/
//*KEND.
//*KEEP,TROOT.
#include "TROOT.h"
//*KEEP,TFitPanelGraph,T=C++.
#include "TFitPanelGraph.h"
//*KEEP,TGroupButton,T=C++.
#include "TGroupButton.h"
//*KEEP,TSlider,T=C++.
#include "TSlider.h"
//*KEEP,TText.
#include "TText.h"
//*KEEP,TGraph.
#include "TGraph.h"
//*KEEP,TF1.
#include "TF1.h"
//*KEND.
#include <stdio.h>
ClassImp(TFitPanelGraph)
//______________________________________________________________________________
//
// A TFitPanelGraph is a TFitPanel specialized to control graph fits.
// With the mouse, the user can control:
// - the type of function to be fitted
// - the various fit options
// - the drawing options
// When the FIT button is executed, the selected histogram is fitted
// with the current parameters.
// The options are documented in TGraph::Fit.
//
/*
*/
//
//
//______________________________________________________________________________
TFitPanelGraph::TFitPanelGraph() : TFitPanel()
{
//*-*-*-*-*-*-*-*-*-*-*-*FitPanelGraph default constructor*-*-*-*-*-*-*-*-*-*-*
//*-* ============================
}
//_____________________________________________________________________________
TFitPanelGraph::TFitPanelGraph(const Text_t *name, const Text_t *title, UInt_t ww, UInt_t wh)
: TFitPanel(name, title,ww,wh)
{
//*-*-*-*-*-*-*-*-*-*-*-*FitPanelGraph constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//*-* ========================
}
//______________________________________________________________________________
TFitPanelGraph::~TFitPanelGraph()
{
//*-*-*-*-*-*-*-*-*-*-*FitPanelGraph default destructor*-*-*-*-*-*-*-*-*-*-*-*
//*-* ===============================
}
//______________________________________________________________________________
void TFitPanelGraph::Apply(const Text_t *action)
{
//*-*-*-*-*-*-*-*-*-*Collect all options and fit histogram*-*-*-*-*-*-*
//*-* =====================================
if (!fRefPad) return;
fRefPad->cd();
SetCursor(kWatch);
if (!strcmp(action,"Defaults")) {
SetDefaults();
return;
}
// take into account slider to set the function range;
TObject *obj;
TGroupButton *button;
TIter next(fPrimitives);
while ((obj = next())) {
if (obj->InheritsFrom(TGroupButton::Class())) {
button = (TGroupButton*)obj;
if (button->GetBorderMode() < 0) button->ExecuteAction();
}
}
TGraph *gr = (TGraph*)fObjectFit;
Int_t npoints = gr->GetN();
Float_t *gx = gr->GetX();
TF1 *f1 = (TF1*)gROOT->GetFunction((char*)fFunction.Data());
if (!f1) return;
Float_t xgrmin = gx[0];
Float_t xgrmax = gx[0];
for (Int_t i=0;i<npoints;i++) {
if (gx[i] < xgrmin) xgrmin = gx[i];
if (gx[i] > xgrmax) xgrmax = gx[i];
}
Float_t smin = fSlider->GetMinimum();
Float_t smax = fSlider->GetMaximum();
Float_t xpmin = fRefPad->GetUxmin();
Float_t xpmax = fRefPad->GetUxmax();
Float_t xmin = xpmin + (xpmax-xpmin)*smin;
Float_t xmax = xpmin + (xpmax-xpmin)*smax;
if (smin <= 0) xmin = xgrmin;
if (smax >= 1) xmax = xgrmax;
f1->SetRange(xmin,xmax);
gr->Fit((char*)fFunction.Data(), (char*)fOption.Data(), (char*)fSame.Data());
fOption = "r";
fFunction = "gaus";
fSame = "";
fRefPad->Modified();
fRefPad->Update();
}
//______________________________________________________________________________
void TFitPanelGraph::SavePrimitive(ofstream &, Option_t *)
{
//*-*-*-*-*-*-*-*-*-*-*Save this fitpanelgraph in a macro*-*-*-*-*-*-*
//*-* ==================================
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.