1 |
dnisson |
1.3 |
#ifndef UserCode_JetFitAnalyzer_JetFitAnalyzer_h
|
2 |
|
|
#define UserCode_JetFitAnalyzer_JetFitAnalyzer_h
|
3 |
|
|
|
4 |
dnisson |
1.1 |
// system include files
|
5 |
|
|
#include <memory>
|
6 |
|
|
|
7 |
|
|
// user include files
|
8 |
|
|
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
9 |
|
|
#include "FWCore/Framework/interface/EDAnalyzer.h"
|
10 |
|
|
|
11 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
12 |
|
|
#include "FWCore/Framework/interface/MakerMacros.h"
|
13 |
|
|
|
14 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
15 |
|
|
|
16 |
|
|
#include "UserCode/JetFitAnalyzer/interface/jetfit.h"
|
17 |
|
|
|
18 |
|
|
#include "TH2.h"
|
19 |
|
|
|
20 |
dnisson |
1.3 |
#include <string>
|
21 |
|
|
#include <vector>
|
22 |
|
|
|
23 |
|
|
#include <TFormula.h>
|
24 |
|
|
#include <TString.h>
|
25 |
|
|
#include <TMinuit.h>
|
26 |
|
|
#include <TH2.h>
|
27 |
|
|
|
28 |
dnisson |
1.1 |
class JetFitAnalyzer : public edm::EDAnalyzer {
|
29 |
|
|
public:
|
30 |
|
|
explicit JetFitAnalyzer(const edm::ParameterSet&);
|
31 |
|
|
~JetFitAnalyzer();
|
32 |
dnisson |
1.3 |
|
33 |
|
|
|
34 |
|
|
enum TroubleStage {
|
35 |
|
|
T_NULL = 0,
|
36 |
|
|
T_SIMPLEX,
|
37 |
|
|
T_MIGRAD,
|
38 |
|
|
T_MINOS
|
39 |
|
|
};
|
40 |
|
|
|
41 |
|
|
struct VectorHisto {
|
42 |
|
|
vector< vector<double> > bins;
|
43 |
|
|
double Xlo, Xhi, Ylo, Yhi;
|
44 |
|
|
} energy;
|
45 |
|
|
|
46 |
|
|
struct Trouble {
|
47 |
|
|
TroubleStage occ;
|
48 |
|
|
int istat;
|
49 |
|
|
};
|
50 |
|
|
|
51 |
|
|
struct FitResults {
|
52 |
|
|
TH2 *rebinnedHisto;
|
53 |
|
|
std::vector< double > chisquare;
|
54 |
|
|
std::vector< std::vector<TString> > pars;
|
55 |
|
|
std::vector< std::vector<double> > pval;
|
56 |
|
|
std::vector< std::vector<double> > perr;
|
57 |
|
|
std::vector< std::vector<double> > plo;
|
58 |
|
|
std::vector< std::vector<double> > phi;
|
59 |
|
|
};
|
60 |
|
|
|
61 |
|
|
class ModelDefinition {
|
62 |
|
|
public:
|
63 |
|
|
int numberOfGaussians();
|
64 |
|
|
void setNumberOfGaussians(int);
|
65 |
|
|
|
66 |
|
|
double fitFunction(double, double, double *);
|
67 |
|
|
|
68 |
|
|
TFormula *getFormula();
|
69 |
|
|
void setFormula(TFormula *);
|
70 |
|
|
void indivParameter(int, std::string&, double&, double&, double&, double&);
|
71 |
|
|
void setIndivParameter(int, std::string, double, double, double, double);
|
72 |
|
|
void get_special_par(int, int, double&, double&, double&, double&);
|
73 |
|
|
void set_special_par(int, int, double, double, double, double);
|
74 |
|
|
unsigned get_n_special_par_sets();
|
75 |
|
|
int get_indiv_max_E();
|
76 |
|
|
void set_indiv_max_E(int);
|
77 |
|
|
int get_indiv_max_x();
|
78 |
|
|
void set_indiv_max_x(int);
|
79 |
|
|
int get_indiv_max_y();
|
80 |
|
|
void set_indiv_max_y(int);
|
81 |
|
|
virtual double chisquare_error(double) = 0;
|
82 |
|
|
double formula_int(double, double, double, double,
|
83 |
|
|
double*, double, double, double*);
|
84 |
|
|
void par_init(TH2 *, TMinuit *, std::vector<TString> &,
|
85 |
|
|
double *, double *, double *, double *,
|
86 |
|
|
int, FitResults);
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
private:
|
90 |
|
|
TFormula *indiv_formula; // formula for individual Gaussian
|
91 |
|
|
std::vector<std::string> indiv_par_names;
|
92 |
|
|
std::vector<double> indiv_par_starts;
|
93 |
|
|
std::vector<double> indiv_par_start_steps;
|
94 |
|
|
std::vector<double> indiv_par_lo;
|
95 |
|
|
std::vector<double> indiv_par_hi;
|
96 |
|
|
std::vector< std::vector<double> > special_par_starts;
|
97 |
|
|
std::vector< std::vector<double> > special_par_start_steps;
|
98 |
|
|
std::vector< std::vector<double> > special_par_lo;
|
99 |
|
|
std::vector< std::vector<double> > special_par_hi;
|
100 |
|
|
int indiv_max_E;
|
101 |
|
|
int indiv_max_x;
|
102 |
|
|
int indiv_max_y;
|
103 |
|
|
int theNumberOfGaussians;
|
104 |
|
|
};
|
105 |
|
|
|
106 |
|
|
FitResults fit_histo(TH2 *hist, std::vector<Trouble> &t,
|
107 |
|
|
void (*cc_minuit)(TMinuit *, TH2 *, int) = 0,
|
108 |
|
|
int start_ngauss = 0,
|
109 |
|
|
int rebinX = 1, int rebinY = 1,
|
110 |
|
|
double P_cutoff_val = 0.5);
|
111 |
|
|
|
112 |
|
|
ModelDefinition& curr_ModelDefinition();
|
113 |
|
|
void set_ModelDefinition(ModelDefinition *_mdef);
|
114 |
|
|
|
115 |
|
|
bool get_ignorezero();
|
116 |
|
|
void set_ignorezero(bool);
|
117 |
|
|
|
118 |
|
|
double fit_fcn_TF2(double *, double *);
|
119 |
dnisson |
1.1 |
|
120 |
|
|
protected:
|
121 |
|
|
virtual void beginJob(const edm::EventSetup&);
|
122 |
|
|
virtual void analyze(const edm::Event&, const edm::EventSetup&);
|
123 |
|
|
virtual void endJob();
|
124 |
|
|
virtual TH2D * make_histo(const edm::Event&, const edm::EventSetup&) = 0;
|
125 |
|
|
virtual jetfit::model_def& make_model_def(const edm::Event&,
|
126 |
|
|
const edm::EventSetup&,
|
127 |
|
|
TH2 *hist) = 0;
|
128 |
|
|
virtual void analyze_results(jetfit::results, std::vector<jetfit::trouble>,
|
129 |
|
|
TH2 *) = 0;
|
130 |
|
|
void set_user_minuit(void (*_user_minuit)(TMinuit *, TH2 *, int) ) {
|
131 |
|
|
user_minuit = _user_minuit;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
private:
|
135 |
|
|
// ----------member data ---------------------------
|
136 |
|
|
bool ignorezero_;
|
137 |
|
|
int rebinX_;
|
138 |
|
|
int rebinY_;
|
139 |
|
|
double P_cutoff_val_;
|
140 |
|
|
void (*user_minuit)(TMinuit *, TH2 *, int);
|
141 |
|
|
};
|
142 |
|
|
|
143 |
|
|
//
|
144 |
|
|
// constants, enums and typedefs
|
145 |
|
|
//
|
146 |
|
|
|
147 |
|
|
//
|
148 |
|
|
// static data member definitions
|
149 |
|
|
//
|
150 |
dnisson |
1.3 |
|
151 |
|
|
#endif
|