4 |
|
#ifndef UserCode_JetFitAnalyzer_HistoFitter_h |
5 |
|
#define UserCode_JetFitAnalyzer_HistoFitter_h |
6 |
|
|
7 |
+ |
#include <TH2.h> |
8 |
+ |
#include <vector> |
9 |
+ |
#include <string> |
10 |
+ |
#include <TString.h> |
11 |
+ |
#include <TFormula.h> |
12 |
+ |
#include <TMinuit.h> |
13 |
+ |
|
14 |
|
class HistoFitter { |
15 |
|
public: |
16 |
< |
|
17 |
< |
static double fcn(int &, double *, double &, double *, int); |
16 |
> |
// the objective function that gets minimized by TMinuit |
17 |
> |
static void fcn(int&, double *, double&, double *, int); |
18 |
> |
// the correction to Gaussians drifting outside of histogram |
19 |
> |
static double outsiderCorrection(double *, double XbinSize, |
20 |
> |
double YbinSize, |
21 |
> |
double cutoffRad = 0.2); |
22 |
|
|
23 |
|
enum TroubleStage { |
24 |
|
T_NULL = 0, |
30 |
|
struct VectorHisto { |
31 |
|
std::vector< std::vector<double> > bins; |
32 |
|
double Xlo, Xhi, Ylo, Yhi; |
33 |
< |
} energy; |
33 |
> |
}; |
34 |
|
|
35 |
|
struct Trouble { |
36 |
|
TroubleStage occ; |
60 |
|
|
61 |
|
double fitFunction(double, double, double *); |
62 |
|
|
63 |
< |
TFormula *getFormula(); |
63 |
> |
TFormula *indivFormula(); |
64 |
|
void setFormula(TFormula *); |
65 |
|
void indivParameter(int, std::string&, double&, double&, double&, double&); |
66 |
|
void setIndivParameter(int, std::string, double, double, double, double); |
72 |
|
void setIndivMeanY(unsigned); |
73 |
|
virtual double chisquareSigma(double) = 0; |
74 |
|
double formulaIntegral(double, double, double, double, |
75 |
< |
double*, double, double, double*); |
76 |
< |
std::vector< std::vector< double > > subtractCurrentFit(VectorHisto); |
75 |
> |
double*, double, double); |
76 |
> |
std::vector< std::vector< double > > subtractCurrentFit(VectorHisto, |
77 |
> |
FitResults); |
78 |
|
void initParsFromModelDef(std::vector<TString> &, |
79 |
|
double *, double *, double *, double *, |
80 |
|
int, FitResults); |
81 |
|
void findInitialValues(std::vector<TString> &, |
82 |
|
double *, double *, double *, double *, |
83 |
< |
int); |
84 |
< |
double initNewN(); |
85 |
< |
double initNewMeanX(); |
86 |
< |
double initNewMeanY(); |
83 |
> |
int, FitResults, int); |
84 |
> |
double initNewN(FitResults, int); |
85 |
> |
double initNewMeanX(FitResults, int); |
86 |
> |
double initNewMeanY(FitResults, int); |
87 |
|
void initParameters(TH2 *, TMinuit *, std::vector<TString> &, |
88 |
|
double *, double *, double *, double *, |
89 |
|
int, FitResults); |
93 |
|
TFormula *theIndivFormula; // formula for individual Gaussian |
94 |
|
std::vector<std::string> indivParNames; |
95 |
|
std::vector<double> indivParStarts; |
96 |
< |
std::vector<double> indivParStartSteps; |
96 |
> |
std::vector<double> indivParStartingStepSizes; |
97 |
|
std::vector<double> indivParLowerLimit; |
98 |
|
std::vector<double> indivParUpperLimit; |
99 |
|
unsigned theIndivEnergy; |
105 |
|
|
106 |
|
int getNumberOfDegreesOfFreedom(VectorHisto, int); |
107 |
|
|
108 |
+ |
FitResults putParsInFitResults(std::vector<TString>, |
109 |
+ |
double *, double *, double *, double *); |
110 |
+ |
static VectorHisto loadTH2IntoVectorHisto(TH2*); |
111 |
+ |
Trouble minimize(TMinuit*, VectorHisto, int); |
112 |
+ |
|
113 |
+ |
int findNnewGauss(TH2 *, VectorHisto, FitResults); |
114 |
|
FitResults fit_histo(TH2 *hist, |
115 |
|
std::vector<Trouble> &t, |
116 |
|
int start_theNumberOfGaussians = 1, |
123 |
|
protected: |
124 |
|
ModelDefinition *mdef; |
125 |
|
static ModelDefinition *static_mdef; |
126 |
+ |
static VectorHisto energy; |
127 |
|
}; |
128 |
|
|
129 |
|
#endif |