00001 #include "RootFitStrategy.h"
00002 #include <TH1.h>
00003 #include <TF1.h>
00004 #include <TGraphErrors.h>
00005
00006 using namespace Sct;
00007 namespace SctFitter{
00008 RootFitStrategy::RootFitStrategy(string opt) throw()
00009 : FitStrategy(opt), name("RootFitStrategy") {}
00010
00011 RootFitStrategy::~RootFitStrategy() throw() {}
00012
00013 void RootFitStrategy::fitTH1(const TH1& hist, TF1& fit) const throw(LogicError, MathsError) {
00015 TH1& theHist = const_cast<TH1&> (hist);
00016 theHist.Fit(&fit, getOptions().c_str());
00017 }
00018
00019 void RootFitStrategy::fitTGraph(const TGraph& graph, TF1& fit) const throw(LogicError, MathsError) {
00021 TGraph& theGraph = const_cast<TGraph&> (graph);
00022 theGraph.Fit(&fit, getOptions().c_str());
00023 }
00024
00025 void RootFitStrategy::fitTGraphErrors(const TGraphErrors& graph, TF1& fit) const throw(LogicError, MathsError) {
00027 TGraphErrors& theGraph = const_cast<TGraphErrors&> (graph);
00028 theGraph.Fit(&fit, getOptions().c_str());
00029 }
00030
00031 const string& RootFitStrategy::getName() const throw() {
00032 return name;
00033 }
00034
00035 bool RootFitStrategy::inMap=FitStrategyFactory::instance().addToMap("RootFitStrategy", *new RootFitStrategy("") );
00036
00037 }