ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/JetFitAnalyzer/interface/HistoFitter.h
(Generate patch)

Comparing UserCode/JetFitAnalyzer/interface/HistoFitter.h (file contents):
Revision 1.2 by dnisson, Thu Nov 26 21:06:02 2009 UTC vs.
Revision 1.9 by dnisson, Thu Mar 4 18:49:03 2010 UTC

# Line 1 | Line 1
1   // Original Author: David Nisson
2 < // A histogram fitter
2 > // Fits a two-dimensional model in eta and phi consisting of summed
3 > // Gaussians to a histogram, supplied in the function fit_histo.
4 > // This histogram can be of mass, energy, or momentum.
5  
6   #ifndef UserCode_JetFitAnalyzer_HistoFitter_h
7   #define UserCode_JetFitAnalyzer_HistoFitter_h
8  
9 + #include <TH2.h>
10 + #include <vector>
11 + #include <string>
12 + #include <TString.h>
13 + #include <TFormula.h>
14 + #include <TMinuit.h>
15 +
16   class HistoFitter {
17   public:
18 +  // the objective function that gets minimized by TMinuit
19 +  static void fcn(int&, double *, double&, double *, int);
20 +  // the correction to Gaussians drifting outside of histogram
21 +  static double outsiderCorrection(double *, double XbinSize,
22 +                                   double YbinSize,
23 +                                   double cutoffRad = 0.2);
24  
25 <  static double fcn(int &, double *, double &, double *, int);
11 <
25 >  // place where fitting trouble happened
26    enum TroubleStage {
27      T_NULL = 0,
28      T_SIMPLEX,
# Line 16 | Line 30 | public:
30      T_MINOS
31    };
32  
33 +  // the histogram class used internally by HistoFitter
34    struct VectorHisto {
35      std::vector< std::vector<double> > bins;
36      double Xlo, Xhi, Ylo, Yhi;
37 <  } energy;
37 >  };
38  
39 +  // information about fitting trouble
40    struct Trouble {
41      TroubleStage occ;
42      int istat;
43    };
44  
45 +  // structure that stores the fit results
46    struct FitResults {
47      TH2 *rebinnedHisto;
48      std::vector< double > chisquare;
# Line 49 | Line 66 | public:
66  
67      double fitFunction(double, double, double *);
68  
69 <    TFormula *getFormula();
69 >    TFormula *indivFormula();
70      void setFormula(TFormula *);
71      void indivParameter(int, std::string&, double&, double&, double&, double&);
72      void setIndivParameter(int, std::string, double, double, double, double);
# Line 59 | Line 76 | public:
76      void setIndivMeanX(unsigned);
77      unsigned indivMeanY();
78      void setIndivMeanY(unsigned);
79 <    virtual double chisquareSigma(double) = 0;
79 >    virtual double chisquareSigma(double, double) = 0;
80      double formulaIntegral(double, double, double, double,
81 <                       double*, double, double, double*);
82 <    std::vector< std::vector< double > > subtractCurrentFit(VectorHisto);
81 >                       double*, double, double);
82 >    std::vector< std::vector< double > > subtractCurrentFit(VectorHisto,
83 >                                                            FitResults);
84      void initParsFromModelDef(std::vector<TString> &,
85                                double *, double *, double *, double *,
86                                int, FitResults);
87      void findInitialValues(std::vector<TString> &,
88                             double *, double *, double *, double *,
89 <                           int);
90 <    double initNewN();
91 <    double initNewMeanX();
92 <    double initNewMeanY();
89 >                           int, FitResults, int);
90 >    double initNewN(FitResults, int);
91 >    double initNewMeanX(FitResults, int);
92 >    double initNewMeanY(FitResults, int);
93      void initParameters(TH2 *, TMinuit *, std::vector<TString> &,
94                    double *, double *, double *, double *,
95                    int, FitResults);
# Line 81 | Line 99 | public:
99      TFormula *theIndivFormula; // formula for individual Gaussian
100      std::vector<std::string> indivParNames;
101      std::vector<double> indivParStarts;
102 <    std::vector<double> indivParStartSteps;
102 >    std::vector<double> indivParStartingStepSizes;
103      std::vector<double> indivParLowerLimit;
104      std::vector<double> indivParUpperLimit;
105      unsigned theIndivEnergy;
# Line 93 | Line 111 | public:
111  
112    int getNumberOfDegreesOfFreedom(VectorHisto, int);
113  
114 +  FitResults putParsInFitResults(std::vector<TString>,
115 +                                 double *, double *, double *, double *,
116 +                                 FitResults&);
117 +  static VectorHisto loadTH2IntoVectorHisto(TH2*);
118 +  Trouble minimize(TMinuit*, VectorHisto, int);
119 +
120 +  int findNnewGauss(TH2 *, VectorHisto, FitResults);
121    FitResults fit_histo(TH2 *hist,
122                          std::vector<Trouble> &t,
123                      int start_theNumberOfGaussians = 1,
# Line 103 | Line 128 | public:
128  
129    double fitFunction_TF2(double *, double *);
130   protected:
106  ModelDefinition *mdef;
131    static ModelDefinition *static_mdef;
132 +  static VectorHisto energy;
133   };
134  
135   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines