ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/JetFitAnalyzer/interface/HistoFitter.h
Revision: 1.1
Committed: Thu Nov 26 06:34:43 2009 UTC (15 years, 5 months ago) by dnisson
Content type: text/plain
Branch: MAIN
Log Message:
Split off fitter (header file).

File Contents

# User Rev Content
1 dnisson 1.1 // Original Author: David Nisson
2     // A histogram fitter
3    
4     #ifndef UserCode_JetFitAnalyzer_HistoFitter_h
5     #define UserCode_JetFitAnalyzer_HistoFitter_h
6    
7     class HistoFitter {
8     public:
9    
10     enum TroubleStage {
11     T_NULL = 0,
12     T_SIMPLEX,
13     T_MIGRAD,
14     T_MINOS
15     };
16    
17     struct VectorHisto {
18     vector< vector<double> > bins;
19     double Xlo, Xhi, Ylo, Yhi;
20     } energy;
21    
22     struct Trouble {
23     TroubleStage occ;
24     int istat;
25     };
26    
27     struct FitResults {
28     TH2 *rebinnedHisto;
29     std::vector< double > chisquare;
30     std::vector< std::vector<TString> > pars;
31     std::vector< std::vector<double> > pval;
32     std::vector< std::vector<double> > perr;
33     std::vector< std::vector<double> > plo;
34     std::vector< std::vector<double> > phi;
35     };
36    
37     class ModelDefinition {
38     public:
39     int numberOfGaussians();
40     void setNumberOfGaussians(int);
41     int maxNumberOfGaussians() {
42     return theMaxNumberOfGaussians;
43     }
44     void setMaxNumberOfGaussians(int newNumberOfGaussians) {
45     theMaxNumberOfGaussians = newNumberOfGaussians;
46     }
47    
48     double fitFunction(double, double, double *);
49    
50     TFormula *getFormula();
51     void setFormula(TFormula *);
52     void indivParameter(int, std::string&, double&, double&, double&, double&);
53     void setIndivParameter(int, std::string, double, double, double, double);
54     int indivEnergy();
55     void setIndivEnergy(int);
56     int indivMeanX();
57     void setIndivMeanX(int);
58     int indivMeanY();
59     void setIndivMeanY(int);
60     virtual double chisquareSigma(double) = 0;
61     double formulaIntegral(double, double, double, double,
62     double*, double, double, double*);
63     std::vector< std::vector< double > > subtractCurrentFit(VectorHisto);
64     void initParsFromModelDef(std::vector<TString> &,
65     double *, double *, double *, double *,
66     int, FitResults);
67     void findInitialValues(std::vector<TString> &,
68     double *, double *, double *, double *,
69     int);
70     double initNewN();
71     double initNewMeanX();
72     double initNewMeanY();
73     void initParameters(TH2 *, TMinuit *, std::vector<TString> &,
74     double *, double *, double *, double *,
75     int, FitResults);
76    
77    
78     private:
79     TFormula *theIndivFormula; // formula for individual Gaussian
80     std::vector<std::string> indivParNames;
81     std::vector<double> indivParStarts;
82     std::vector<double> indivParStartSteps;
83     std::vector<double> indivParLowerLimit;
84     lo;
85     std::vector<double> indivParUpperLimit;
86     int theIndivEnergy;
87     int theIndivMeanX;
88     int theIndivMeanY;
89     int theNumberOfGaussians;
90     int theMaxNumberOfGaussians;
91     };
92    
93     FitResults fit_histo(TH2 *hist, std::vector<Trouble> &t,
94     void (*cc_minuit)(TMinuit *, TH2 *, int) = 0,
95     int start_theNumberOfGaussians = 0,
96     int rebinX = 1, int rebinY = 1,
97     double P_cutoff_val = 0.5);
98    
99     ModelDefinition& curr_ModelDefinition();
100     void set_ModelDefinition(ModelDefinition *_mdef);
101    
102     bool get_ignorezero();
103     void set_ignorezero(bool);
104    
105     double fit_fcn_TF2(double *, double *);
106     // }
107     }
108    
109     #endif