#include "../GausStepFitter.h"
#include "../gausTF1.h"
#include "TH1F.h"
#include "TF1.h"
#include "TCanvas.h"
#include <string>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cassert>
#include <vector>
Go to the source code of this file.
int main |
( |
int |
narg, |
|
|
const char * |
argc[] |
|
) |
| |
Definition at line 91 of file test_GausStepFitter.cxx.
94 string sarg = argc[1];
96 cout <<
"Usage: " << argc[0] <<
" [F1 F2 ...]" <<
endl;
100 for (
int iarg=1; iarg<narg; ++iarg ) {
101 double satfrac = 0.0;
102 istringstream ssin(argc[iarg]);
104 satfracs.push_back(satfrac);
std::vector< double > DoubleVector
void err(const char *fmt,...)
int test_GausStepFitter(double satfrac)
QTextStream & endl(QTextStream &s)
int test_GausStepFitter |
( |
double |
satfrac | ) |
|
Definition at line 33 of file test_GausStepFitter.cxx.
34 const string myname =
"test_GausStepFitter: ";
35 cout << myname <<
"Starting test" <<
endl;
37 cout << myname <<
"NDEBUG must be off." <<
endl;
40 string line =
"-----------------------------";
43 cout << myname << line <<
endl;
44 cout << myname <<
"Test data" <<
endl;
46 ssttl <<
"Test data with frac " << satfrac <<
endl;
47 TH1* ph =
new TH1F(
"hdat", ssttl.str().c_str(), 100, 0, 100);
48 ph->SetDirectory(
nullptr);
49 TF1* pf1 =
gausTF1(1.0, 50.0, 4.0,
"f1");
50 cout << myname <<
"Created function " << pf1->GetName() <<
endl;
51 TF1* pf2 =
gausTF1(1.0, 30.0, 4.0,
"f2");
52 cout << myname <<
"Created function " << pf2->GetName() <<
endl;
54 ph->FillRandom(
"f1", npt);
55 ph->FillRandom(
"f2", satfrac*npt);
56 ph->GetListOfFunctions()->Clear();
57 cout << myname <<
" Hist mean: " << ph->GetMean() <<
endl;
58 cout << myname <<
" Hist RMS: " << ph->GetRMS() <<
endl;
62 cout << myname << line <<
endl;
64 assert( gsf.fit(ph) == 0 );
65 TF1* pffit = ph->GetFunction(
"ff");
66 if ( pffit ==
nullptr ) {
67 cout << myname <<
" Fit function not found!" <<
endl;
68 ph->GetListOfFunctions()->Print();
70 cout << myname <<
" Fit mean: " << pffit->GetParameter(
"Mean") <<
endl;
71 cout << myname <<
" Fit sigma: " << pffit->GetParameter(
"Sigma") <<
endl;
74 cout << myname << line <<
endl;
75 TCanvas* pcan =
new TCanvas;
79 ssfnam <<
"gausstep" << ncan <<
".png";
81 string fnam = ssfnam.str();
82 cout << myname <<
"Writing " << fnam <<
endl;
83 pcan->Print(fnam.c_str());
TF1 * gausTF1(double heightIn, double meanIn, double sigmaIn, std::string fname)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)