00001 #ifndef __BCTEMPLATEENSEMBLETEST__H 00002 #define __BCTEMPLATEENSEMBLETEST__H 00003 00004 /*! 00005 * \class BCTemplateEnsembleTest 00006 * This class can be used for ensemble tests using the StackTool. The 00007 * fitting can be done with Minuit or with Markov Chains. 00008 * 00009 * \brief A class for doing ensemble tests. 00010 * \author Andrea Knue 00011 * \author Daniel Kollar 00012 * \author Kevin Kroeninger 00013 * \date 10.04.2010 00014 */ 00015 00016 /* 00017 * Copyright (C) 2008, 2009, 2010, Daniel Kollar and Kevin Kroeninger. 00018 * All rights reserved. 00019 * 00020 * For the licensing terms see doc/COPYING. 00021 */ 00022 00023 // -------------------------------------------------------------------------------------------- 00024 00025 #include <vector> 00026 #include <TH1D.h> 00027 00028 class TFile; 00029 class TTree; 00030 class TRandom3; 00031 00032 class BCTemplateFitter; 00033 00034 // -------------------------------------------------------------------------------------------- 00035 00036 class BCTemplateEnsembleTest 00037 { 00038 public: 00039 00040 /** 00041 * The constructor. 00042 */ 00043 BCTemplateEnsembleTest(); 00044 00045 /** 00046 * The destructor. 00047 */ 00048 ~BCTemplateEnsembleTest(); 00049 00050 /** 00051 * Set the template used to generate the ensembles. 00052 */ 00053 int SetEnsembleTemplate(TH1D hist); 00054 00055 /** 00056 * Set the BCTemplateFitter used to analyze the ensembles. 00057 */ 00058 void SetTemplateFitter(BCTemplateFitter * model) 00059 { fTemplateFitter = model; }; 00060 00061 /** 00062 * Set the parameters used for generating ensembles using the 00063 * current template fitter model. 00064 */ 00065 void SetTemplateParameters(std::vector<double> parameters) 00066 { fTemplateParameters = parameters; }; 00067 00068 /** 00069 * A function to perform an ensemble test for each data set in the 00070 * container. 00071 * @param tree: A tree from which the parameters are taken, e.g., 00072 * the poesterior 00073 */ 00074 int PerformEnsembleTest(TTree* tree = 0); 00075 00076 /** 00077 * A function to define the number of events per ensemble. 00078 */ 00079 void SetEnsembleExpectation(double expectation) 00080 { fEnsembleExpectation = expectation; }; 00081 00082 /** 00083 * A function to define the number of ensembles per data set. 00084 */ 00085 void SetNEnsembles(int n) 00086 { fNEnsembles = n; }; 00087 00088 /** 00089 * A function to set the MCMC flag. 00090 */ 00091 void SetFlagMCMC(bool flag) 00092 { fFlagMCMC = flag; } 00093 00094 /** 00095 * Write tree to file 00096 */ 00097 int Write(const char * filename); 00098 00099 /** 00100 * Prepare tree. 00101 */ 00102 int PrepareTree(); 00103 00104 /** 00105 * Print pulls 00106 */ 00107 void PrintPulls(const char* filename); 00108 00109 private: 00110 00111 /** 00112 * Create a new ensemble. 00113 * @return A histogram with the new ensemble. 00114 */ 00115 TH1D * BuildEnsemble(); 00116 00117 protected: 00118 00119 /** 00120 * The template used for the generation of ensembles. 00121 */ 00122 TH1D fEnsembleTemplate; 00123 00124 /** 00125 * The stack model used to analyze the ensembles. 00126 */ 00127 BCTemplateFitter * fTemplateFitter; 00128 00129 /** 00130 * Output file. 00131 */ 00132 TFile * fFile; 00133 00134 /** 00135 * Output tree. 00136 */ 00137 TTree * fTree; 00138 00139 /** 00140 * The parameters used to generate ensembles 00141 */ 00142 std::vector<double> fTemplateParameters; 00143 00144 /** 00145 * A counter for the number of ensembles. 00146 */ 00147 int fEnsembleCounter; 00148 00149 /** 00150 * Exepectation value 00151 */ 00152 double fEnsembleExpectation; 00153 00154 /** 00155 * Number of ensembles per data set. 00156 */ 00157 int fNEnsembles; 00158 00159 /** 00160 * A flag to turn the Markov Chains on. 00161 */ 00162 bool fFlagMCMC; 00163 00164 /** 00165 * The random number generator. 00166 */ 00167 TRandom3 * fRandom; 00168 00169 /** 00170 * Tree variable: parameter values 00171 */ 00172 std::vector<double> fOutParValue; 00173 00174 /** 00175 * Tree variable: global mode 00176 */ 00177 std::vector<double> fOutParModeGlobal; 00178 00179 /** 00180 * Tree variable: positive uncertainty on global mode 00181 */ 00182 std::vector<double> fOutParErrorUpGlobal; 00183 00184 /** 00185 * Tree variable: negative uncertainty on global mode 00186 */ 00187 std::vector<double> fOutParErrorDownGlobal; 00188 00189 /** 00190 * Tree variable: global mode 00191 */ 00192 std::vector<double> fOutParPullGlobal; 00193 00194 /** 00195 * Tree variable: marginalized mode 00196 */ 00197 std::vector<double> fOutParModeMarg; 00198 00199 /** 00200 * Tree variable: median 00201 */ 00202 std::vector<double> fOutParMedianMarg; 00203 00204 /** 00205 * Tree variable: mean 00206 */ 00207 std::vector<double> fOutParMeanMarg; 00208 00209 /** 00210 * Tree variable: rms 00211 */ 00212 std::vector<double> fOutParRMSMarg; 00213 00214 /** 00215 * Tree variable: 16% quantile 00216 */ 00217 std::vector<double> fOutParErrorUpMarg; 00218 00219 /** 00220 * Tree variable: 84% quantile 00221 */ 00222 std::vector<double> fOutParErrorDownMarg; 00223 00224 /** 00225 * Tree variable: global mode 00226 */ 00227 std::vector<double> fOutParPullMarg; 00228 00229 /** 00230 * Tree variable: 5% quantile 00231 */ 00232 std::vector<double> fOutParQuantile5Marg; 00233 00234 /** 00235 * Tree variable: 10% quantile 00236 */ 00237 std::vector<double> fOutParQuantile10Marg; 00238 00239 /** 00240 * Tree variable: 90% quantile 00241 */ 00242 std::vector<double> fOutParQuantile90Marg; 00243 00244 /** 00245 * Tree variable: 95% quantile 00246 */ 00247 std::vector<double> fOutParQuantile95Marg; 00248 00249 /** 00250 * Tree variable: marginalized mode (ratio) 00251 */ 00252 std::vector<double> fOutRatioModeMarg; 00253 00254 /** 00255 * Tree variable: median (ratio) 00256 */ 00257 std::vector<double> fOutRatioMedianMarg; 00258 00259 /** 00260 * Tree variable: mean (ratio) 00261 */ 00262 std::vector<double> fOutRatioMeanMarg; 00263 00264 /** 00265 * Tree variable: rms (ratio) 00266 */ 00267 std::vector<double> fOutRatioRMSMarg; 00268 00269 /** 00270 * Tree variable: 16% quantile (ratio) 00271 */ 00272 std::vector<double> fOutRatioErrorUpMarg; 00273 00274 /** 00275 * Tree variable: 84% quantile (ratio) 00276 */ 00277 std::vector<double> fOutRatioErrorDownMarg; 00278 00279 /** 00280 * Tree variable: 5% quantile (ratio) 00281 */ 00282 std::vector<double> fOutRatioQuantile5Marg; 00283 00284 /** 00285 * Tree variable: 10% quantile (ratio) 00286 */ 00287 std::vector<double> fOutRatioQuantile10Marg; 00288 00289 /** 00290 * Tree variable: 90% quantile (ratio) 00291 */ 00292 std::vector<double> fOutRatioQuantile90Marg; 00293 00294 /** 00295 * Tree variable: 95% quantile (ratio) 00296 */ 00297 std::vector<double> fOutRatioQuantile95Marg; 00298 00299 /** 00300 * Tree variable: chi2 calculated with global best fit parameters 00301 */ 00302 double fOutChi2Global; 00303 00304 /** 00305 * Tree variable: chi2 calculated with marginalized best fit 00306 * parameters 00307 */ 00308 double fOutChi2Marg; 00309 00310 /** 00311 * Tree variable: ndf 00312 */ 00313 int fOutNDF; 00314 00315 /** 00316 * Tree variable: chi2-probability calculated with global best fit 00317 * parameters 00318 */ 00319 double fOutChi2ProbGlobal; 00320 00321 /** 00322 * Tree variable: chi2-probability calculated with marginalized 00323 * best fit parameters 00324 */ 00325 double fOutChi2ProbMarg; 00326 00327 /** 00328 * Tree variable: KL probability 00329 */ 00330 double fOutKSProb; 00331 00332 /** 00333 * Tree variable: p-value 00334 */ 00335 double fOutPValue; 00336 00337 /** 00338 * Tree variable: number of events in the data 00339 */ 00340 int fOutNEvents; 00341 }; 00342 00343 #endif