Xephyr  0.0
ToyFitterExclusion.h
1 #ifndef TOY_FITTER
2 #define TOY_FITTER
3 
4 #include "XeLikelihoods.h"
5 #include "TGraphAsymmErrors.h"
6 #include "TGraph.h"
7 #include "XeUtils.h"
8 #include "dataHandler.h"
9 #include "TFile.h"
10 #include "TGraph.h"
11 #include "TRandom.h"
12 #include "TRint.h"
13 #include "TString.h"
14 #include "TFile.h"
15 #include "TTree.h"
16 #include "TList.h"
17 #include "TParameter.h"
18 #include "XeStat.h"
19 #include "TTree.h"
20 #include "TH2F.h"
21 #include <map>
22 #include <vector>
23 #include <stdio.h>
24 #include "plotHelpers.h"
25 
26 #include "Math/Minimizer.h"
27 #include "Math/Factory.h"
28 #include "Math/Functor.h"
29 #include "Math/BrentMinimizer1D.h"
30 
31 using namespace std;
32 
44 
45  public:
46 
49  ToyFitterExclusion(TString CollectionName);
50 
59  double computeTS(double mu) ;
60 
72  void fit(double mu, int stopAt=-999);
73 
75  void setTheLikelihood(ProfileLikelihood *like) { likeHood = like; };
76 
77 
87  TGraphAsymmErrors computeTSDistros(TString fileName, double *mu_list, int mu_size);
88 
89 
99  TGraphAsymmErrors computeTSDistros(TTree *tree, double *mu_list, int mu_size);
100 
110  void spitTheLimit(TGraphAsymmErrors *ninety_quantiles, int sopAt = -999);
111 
113  void setInputDir(TString path) { dirPath = path; };
114 
116  void setOutputDir(TString path){ OutDir = path; };
117 
118  // \brief set or unset the parameter randomization. Default true.
119  void setRandomizeMeasure(bool doOrNot) { randomizeMeasure = doOrNot ;};
120 
121  // \brief in case you want to change the tree name on the fly
122  void setTreeName(TString newName) { treeName = newName; };
123 
124  // \brief setting random seed for measured param generation
125  // TRandom likes a integer seed.
126  void setSeed(ULong_t seed) { rambo.SetSeed(seed); };
127 
128  // \brief you must set this if you want to use calibration in fit
129  void setCalibrationTreeName(TString newName) { calTreeName = newName; };
130 
131  // \brief set output file suffix, useful for conditional fit of null
132  void setOutputSuffix(TString name) { Suffix = name; } ;
133 
135  void setGeneration(int generation) { Gen = generation; };
136 
137  private:
138 
142  void for_each_tree( double (ToyFitterExclusion::*p2method)(double), TTree *outTree, double mu, int stopAt = -999);
143 
146  double limitLoop(double initial_mu);
147 
149  void saveParameters(double *params);
150 
152  void fillTrueParams( );
153 
155  void measureParameters();
156 
158  double eval_testStatMinuit( double mu );
159 
161  double getBestAsympoticGuessForMu(double one_over_sigma_squared, double mu_hat );
162 
163  void saveNames(string *names);
164 
165  ProfileLikelihood *likeHood;
166  TString dirPath;
167  TString treeName;
168  TString OutDir;
169  TGraphAsymmErrors *graph_of_quantiles;
170  TString calTreeName;
171  TString Suffix;
172  int IndexHolder;
173  int CurrentTreeIndex;
174  int Gen;
175 
176  double likelihood_uncond;
177  double likelihood_cond;
178  double true_params[50] = {0.} ;
179  double measured_params[50] = {0.};
180  double uncond_params[50] = {0.};
181  double cond_params[50] = {0.};
182  bool limit_converged;
183  double testStat_limit;
184  double testStat_at0;
185  vector<string> name_params;
186  vector<string> name_true_params;
187  TRandom3 rambo;
188  double mu_fit;
189  double mu_limit;
190  double lower_mu_limit;
191  double limit;
192  double lower_limit;
193  double testStat;
194  double q_tilde;
195  int numberOfParams;
196  bool randomizeMeasure;
197 };
198 
199 #endif
Class to handle the fitting of toy dataset for limit production.
Definition: ToyFitterExclusion.h:43
void setOutputDir(TString path)
set the path to dir in which the fits are stored otherwise is current
Definition: ToyFitterExclusion.h:116
void setTheLikelihood(ProfileLikelihood *like)
set the likelihood to fit
Definition: ToyFitterExclusion.h:75
Helper Class to send consistently formatted messages. It allows different levels of severity for the ...
Definition: XeUtils.h:22
void setInputDir(TString path)
set path to input file (only dir no file name)
Definition: ToyFitterExclusion.h:113
void setGeneration(int generation)
set the Generation, this info will be available in the generated tree (so that u can hadd them)...
Definition: ToyFitterExclusion.h:135
Definition: XeStat.h:742