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 <TH1D.h> 00026 00027 class TFile; 00028 class TTree; 00029 class TRandom3; 00030 00031 class BCTemplateFitter; 00032 00033 // -------------------------------------------------------------------------------------------- 00034 00035 class BCTemplateEnsembleTest 00036 { 00037 public: 00038 00039 /** 00040 * The constructor. 00041 */ 00042 BCTemplateEnsembleTest(); 00043 00044 /** 00045 * The destructor. 00046 */ 00047 ~BCTemplateEnsembleTest(); 00048 00049 /** 00050 * Set the template used to generate the ensembles. 00051 */ 00052 int SetEnsembleTemplate(TH1D hist); 00053 00054 /** 00055 * Set the BCTemplateFitter used to analyze the ensembles. 00056 */ 00057 void SetTemplateFitter(BCTemplateFitter * model) 00058 { fTemplateFitter = model; } 00059 00060 /** 00061 * A function to perform an ensemble test for each data set in the container. 00062 */ 00063 int PerformEnsembleTest(); 00064 00065 /** 00066 * A function to define the number of events per ensemble. 00067 */ 00068 void SetEnsembleExpectation(double expectation) 00069 { fEnsembleExpectation = expectation; } 00070 00071 /** 00072 * A function to define the number of ensembles per data set. 00073 */ 00074 void SetNEnsembles(int n) 00075 { fNEnsembles = n; } 00076 00077 /** 00078 * A function to set the MCMC flag. 00079 */ 00080 void SetFlagMCMC(bool flag) 00081 { fFlagMCMC = false; } // debugKK 00082 00083 /** 00084 * Write tree to file 00085 */ 00086 int Write(const char * filename); 00087 00088 /** 00089 * Prepare tree. 00090 */ 00091 int PrepareTree(); 00092 00093 private: 00094 00095 /** 00096 * Create a new ensemble. 00097 * @return A histogram with the new ensemble. 00098 */ 00099 TH1D * BuildEnsemble(); 00100 00101 protected: 00102 00103 /** 00104 * The template used for the generation of ensembles. 00105 */ 00106 TH1D fEnsembleTemplate; 00107 00108 /** 00109 * The stack model used to analyze the ensembles. 00110 */ 00111 BCTemplateFitter * fTemplateFitter; 00112 00113 /** 00114 * Output file. 00115 */ 00116 TFile * fFile; 00117 00118 /** 00119 * Output tree. 00120 */ 00121 TTree * fTree; 00122 00123 /** 00124 * A counter for the number of ensembles. 00125 */ 00126 int fEnsembleCounter; 00127 00128 /** 00129 * Exepectation value 00130 */ 00131 double fEnsembleExpectation; 00132 00133 /** 00134 * Number of ensembles per data set. 00135 */ 00136 int fNEnsembles; 00137 00138 /** 00139 * A flag to turn the Markov Chains on. 00140 */ 00141 bool fFlagMCMC; 00142 00143 /** 00144 * The random number generator. 00145 */ 00146 TRandom3 * fRandom; 00147 00148 /** 00149 * Tree variable: global mode 00150 */ 00151 std::vector<double> fOutParModeGlobal; 00152 00153 /** 00154 * Tree variable: positive uncertainty on global mode 00155 */ 00156 std::vector<double> fOutParErrorUpGlobal; 00157 00158 /** 00159 * Tree variable: negative uncertainty on global mode 00160 */ 00161 std::vector<double> fOutParErrorDownGlobal; 00162 00163 /** 00164 * Tree variable: marginalized mode 00165 */ 00166 std::vector<double> fOutParModeMarg; 00167 00168 /** 00169 * Tree variable: median 00170 */ 00171 std::vector<double> fOutParMedianMarg; 00172 00173 /** 00174 * Tree variable: mean 00175 */ 00176 std::vector<double> fOutParMeanMarg; 00177 00178 /** 00179 * Tree variable: rms 00180 */ 00181 std::vector<double> fOutParRMSMarg; 00182 00183 /** 00184 * Tree variable: 16% quantile 00185 */ 00186 std::vector<double> fOutParErrorUpMarg; 00187 00188 /** 00189 * Tree variable: 84% quantile 00190 */ 00191 std::vector<double> fOutParErrorDownMarg; 00192 00193 /** 00194 * Tree variable: 5% quantile 00195 */ 00196 std::vector<double> fOutParQuantile5Marg; 00197 00198 /** 00199 * Tree variable: 10% quantile 00200 */ 00201 std::vector<double> fOutParQuantile10Marg; 00202 00203 /** 00204 * Tree variable: 90% quantile 00205 */ 00206 std::vector<double> fOutParQuantile90Marg; 00207 00208 /** 00209 * Tree variable: 95% quantile 00210 */ 00211 std::vector<double> fOutParQuantile95Marg; 00212 00213 /** 00214 * Tree variable: marginalized mode (ratio) 00215 */ 00216 std::vector<double> fOutRatioModeMarg; 00217 00218 /** 00219 * Tree variable: median (ratio) 00220 */ 00221 std::vector<double> fOutRatioMedianMarg; 00222 00223 /** 00224 * Tree variable: mean (ratio) 00225 */ 00226 std::vector<double> fOutRatioMeanMarg; 00227 00228 /** 00229 * Tree variable: rms (ratio) 00230 */ 00231 std::vector<double> fOutRatioRMSMarg; 00232 00233 /** 00234 * Tree variable: 16% quantile (ratio) 00235 */ 00236 std::vector<double> fOutRatioErrorUpMarg; 00237 00238 /** 00239 * Tree variable: 84% quantile (ratio) 00240 */ 00241 std::vector<double> fOutRatioErrorDownMarg; 00242 00243 /** 00244 * Tree variable: 5% quantile (ratio) 00245 */ 00246 std::vector<double> fOutRatioQuantile5Marg; 00247 00248 /** 00249 * Tree variable: 10% quantile (ratio) 00250 */ 00251 std::vector<double> fOutRatioQuantile10Marg; 00252 00253 /** 00254 * Tree variable: 90% quantile (ratio) 00255 */ 00256 std::vector<double> fOutRatioQuantile90Marg; 00257 00258 /** 00259 * Tree variable: 95% quantile (ratio) 00260 */ 00261 std::vector<double> fOutRatioQuantile95Marg; 00262 00263 /** 00264 * Tree variable: chi2 00265 */ 00266 double fOutChi2; 00267 00268 /** 00269 * Tree variable: ndf 00270 */ 00271 int fOutNDF; 00272 00273 /** 00274 * Tree variable: chi2-probability 00275 */ 00276 double fOutChi2Prob; 00277 00278 /** 00279 * Tree variable: KL probability 00280 */ 00281 double fOutKSProb; 00282 00283 /** 00284 * Tree variable: p-value 00285 */ 00286 double fOutPValue; 00287 00288 /** 00289 * Tree variable: number of events in the data 00290 */ 00291 int fOutNEvents; 00292 }; 00293 00294 #endif