00001 #ifndef __BCMODELOUTPUT__H 00002 #define __BCMODELOUTPUT__H 00003 00004 /*! 00005 * \class BCModelOutput 00006 * \brief A class for creating an (ROOT) output file. 00007 * \author Daniel Kollar 00008 * \author Kevin Kröninger 00009 * \version 1.0 00010 * \date 08.2008 00011 * \detail This class defines an output interface for the analysis. It 00012 * creates a ROOT file which can contain summary information, 00013 * histograms and Markov chains. 00014 */ 00015 00016 /* 00017 * Copyright (C) 2008-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 00027 // BAT classes 00028 class BCModel; 00029 00030 // ROOT classes 00031 class TTree; 00032 class TFile; 00033 class TObject; 00034 00035 const int MAXNPARAMETERS = 20; 00036 00037 // --------------------------------------------------------- 00038 00039 class BCModelOutput 00040 { 00041 public: 00042 00043 /** \name Constructors and destructors */ 00044 /* @{ */ 00045 00046 /** 00047 * The default constructor. */ 00048 BCModelOutput(); 00049 00050 /** 00051 * A constructor. 00052 * @param model The model to which this output class is assigned. 00053 * @param filename Name of the output file. */ 00054 BCModelOutput(BCModel * model, const char * filenname); 00055 00056 /** 00057 * The default copy constructor. */ 00058 BCModelOutput(const BCModelOutput & modeloutput); 00059 00060 /** 00061 * The default destructor. */ 00062 virtual ~BCModelOutput(); 00063 00064 /* @} */ 00065 00066 /** \name Assignment operators */ 00067 /* @{ */ 00068 00069 /** 00070 * The defaut assignment operator */ 00071 BCModelOutput & operator = (const BCModelOutput & modeloutput); 00072 00073 /* @} */ 00074 00075 /** \name Getters */ 00076 /* @{ */ 00077 00078 /** 00079 * Returns the output TTree tree. 00080 * @return The pointer to the output TTree */ 00081 TTree * GetAnalysisTree() 00082 { return fAnalysisTree; }; 00083 00084 /** 00085 * Returns the output TFile. 00086 * @return The pointer to the output TFile */ 00087 TFile * GetFile() 00088 { return fOutputFile; }; 00089 00090 /* @} */ 00091 00092 /** \name Setters */ 00093 /* @{ */ 00094 00095 /** 00096 * Assign a BCModel to this output class. 00097 * @param model A pointer to the BCModel */ 00098 void SetModel(BCModel * model); 00099 00100 00101 /** 00102 * Sets the output filename. 00103 * @param filename The filename */ 00104 void SetFile(const char * filename); 00105 00106 /* @} */ 00107 00108 /** \name Member functions (miscellaneous methods) */ 00109 /* @{ */ 00110 00111 /** 00112 * Flag for writing Markov chain to file 00113 * @param flag Writes (true) or does not write (false) the Markov chain */ 00114 void WriteMarkovChain(bool flag = true); 00115 00116 /** 00117 * Fill the output TTree with the current information. */ 00118 void FillAnalysisTree(); 00119 00120 /** 00121 * Writes the marginalized histograms to the TFile. */ 00122 void WriteMarginalizedDistributions(); 00123 00124 /** 00125 * Writes the error band histogram into the TFile. */ 00126 void WriteErrorBand(); 00127 00128 /** 00129 * Writes any object derived from TObject to TFile. */ 00130 void Write(TObject * o); 00131 00132 /** 00133 * Closes the TFile. */ 00134 void Close(); 00135 00136 /* @} */ 00137 00138 private: 00139 00140 /** 00141 * Initialize the variables */ 00142 void Init(); 00143 00144 /* 00145 * Copies this BCModelOutput into another one */ 00146 void Copy(BCModelOutput & modeloutput) const; 00147 00148 /** 00149 * Initialize the output TTree. */ 00150 void InitializeAnalysisTree(); 00151 00152 /** 00153 * Initialize SA TTree. */ 00154 void InitializeSATree(); 00155 00156 /** 00157 * Pointer to the TTree containing the summary output information. */ 00158 TTree * fAnalysisTree; 00159 00160 /* 00161 * The trees containing the Markov chains. The length of the vector 00162 * is fMCMCNChains. */ 00163 std::vector<TTree *> fMarkovChainTrees; 00164 00165 /* 00166 * The tree for the simulated annealing. */ 00167 TTree * fTreeSA; 00168 00169 /** 00170 * The output filename */ 00171 char * fFileName; 00172 00173 /** 00174 * Pointer to the output TFile. */ 00175 TFile * fOutputFile; 00176 00177 /** 00178 * Pointer to the model this output class is assigned to */ 00179 BCModel * fModel; 00180 00181 /** 00182 * The analysis tree variables */ 00183 int fIndex; 00184 unsigned int fNParameters; 00185 double fProbability_apriori; 00186 double fProbability_aposteriori; 00187 double fMode_global[MAXNPARAMETERS]; 00188 double fMode_marginalized[MAXNPARAMETERS]; 00189 double fMean_marginalized[MAXNPARAMETERS]; 00190 double fMedian_marginalized[MAXNPARAMETERS]; 00191 double fQuantile_05[MAXNPARAMETERS]; 00192 double fQuantile_10[MAXNPARAMETERS]; 00193 double fQuantile_16[MAXNPARAMETERS]; 00194 double fQuantile_84[MAXNPARAMETERS]; 00195 double fQuantile_90[MAXNPARAMETERS]; 00196 double fQuantile_95[MAXNPARAMETERS]; 00197 00198 }; 00199 00200 // --------------------------------------------------------- 00201 00202 #endif