10 #include "../GausStepFitter.h" 11 #include "../gausTF1.h" 27 using std::ostringstream;
28 using std::istringstream;
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());
91 int main(
int narg,
const char* argc[]) {
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);
int main(int narg, const char *argc[])
TF1 * gausTF1(double heightIn, double meanIn, double sigmaIn, std::string fname)
std::vector< double > DoubleVector
void err(const char *fmt,...)
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
int test_GausStepFitter(double satfrac)
QTextStream & endl(QTextStream &s)