29 Name myname =
"GausRmsFitter::fit: ";
30 if ( ph->GetEntries() == 0 ) {
31 if (
m_LogLevel >= 2 ) cout <<
"Histogram has no entries." <<
endl;
37 double sigma = ph->GetRMS();
38 double height = ph->GetMaximum();
39 int nbin = ph->GetXaxis()->GetNbins();
40 int ibin1Start = ph->GetXaxis()->GetFirst();
41 int ibin2Start = ph->GetXaxis()->GetLast();
42 double x1 = ph->GetXaxis()->GetBinLowEdge(ibin1Start);
43 double x2 = ph->GetXaxis()->GetBinUpEdge(ibin2Start);
49 cout << myname <<
"Start loop with mean, sigma: " << mean <<
", " << sigmaOld <<
endl;
51 const Index maxtry = 100;
53 int ibin1 = ibin1Start;
54 int ibin2 = ibin2Start;
55 for ( ; itry<maxtry; ++itry ) {
58 ibin1 = ph->GetXaxis()->FindFixBin(x1);
59 if ( ibin1 == 0 ) ibin1 = 1;
60 x1 = ph->GetXaxis()->GetBinLowEdge(ibin1);
62 ibin2 = ph->GetXaxis()->FindFixBin(x2);
63 if ( ibin2 == nbin+1 ) ibin2 = nbin;
64 x2 = ph->GetXaxis()->GetBinUpEdge(ibin2);
65 ph->GetXaxis()->SetRange(ibin1, ibin2);
69 cout << myname <<
setw(5) << itry <<
": (" << x1 <<
", " << x2 <<
"): " 70 << mean <<
", " << sigma <<
endl;
72 if ( sigma < 1.001*sigmaOld ) {
77 ph->GetXaxis()->SetRange(ibin1Start, ibin2Start);
78 if ( itry >= 100 ) cout << myname <<
"WARNING: too many iterations." <<
endl;
88 sigma = ph->GetXaxis()->GetBinWidth(1)/sqrt(12.0);
89 if (
m_LogLevel >= 1 ) cout << myname <<
"Reset sigma = 0 --> " << sigma <<
endl;
92 pffix->FixParameter(1, mean);
93 pffix->FixParameter(2, sigma);
94 pffix->SetRange(x1, x2);
98 if (
m_LogLevel >= 1 ) cout << myname <<
" status " << fstat <<
endl;
104 ph->GetListOfFunctions()->Clear();
ChannelGroupService::Name Name
int quietHistFit(TH1 *ph, std::string fname, std::string fopt)
TF1 * gausTF1(double heightIn, double meanIn, double sigmaIn, std::string fname)
Q_EXPORT QTSManip setw(int w)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
QTextStream & endl(QTextStream &s)