00001 /* 00002 * Copyright (C) 2008-2012, Daniel Kollar and Kevin Kroeninger. 00003 * All rights reserved. 00004 * 00005 * For the licensing terms see doc/COPYING. 00006 */ 00007 00008 // --------------------------------------------------------- 00009 00010 #include <TH1D.h> 00011 00012 #include "BCLog.h" 00013 #include "BCH1D.h" 00014 00015 #include "BCSummaryPriorModel.h" 00016 00017 // --------------------------------------------------------- 00018 BCSummaryPriorModel::BCSummaryPriorModel() 00019 : BCModel() 00020 , fTestModel(0) 00021 { 00022 } 00023 00024 // --------------------------------------------------------- 00025 BCSummaryPriorModel::BCSummaryPriorModel(const char * name) 00026 : BCModel(name) 00027 , fTestModel(0) 00028 { 00029 } 00030 00031 // --------------------------------------------------------- 00032 BCSummaryPriorModel::~BCSummaryPriorModel() 00033 {} 00034 00035 // --------------------------------------------------------- 00036 void BCSummaryPriorModel::SetModel(BCModel * model) 00037 { 00038 fTestModel = model; 00039 00040 // copy parameters 00041 int npar = fTestModel->GetNParameters(); 00042 for (int i = 0; i < npar; ++i) { 00043 BCParameter * par = fTestModel->GetParameter(i); 00044 AddParameter(par); 00045 } 00046 00047 // set default histogram binning to the one of the original model 00048 for (int i = 0; i < npar; ++i) { 00049 // this construct has to go here, because otherwise there is a 00050 // warning from BCEngineMCMC:: MCMCGetH1Marginalized 00051 if (fTestModel->GetBestFitParameters().size() > 0){ 00052 BCH1D* hist = fTestModel->GetMarginalized( fTestModel->GetParameter(i) ); 00053 if (hist) { 00054 int nbins = hist->GetHistogram()->GetNbinsX(); 00055 SetNbins( (fTestModel->GetParameter(i)->GetName()).c_str(), nbins); 00056 } 00057 } 00058 } 00059 00060 // set default MCMC setup to the one of the original model 00061 MCMCSetNChains( fTestModel->MCMCGetNChains() ); 00062 MCMCSetNLag( fTestModel->MCMCGetNLag() ); 00063 MCMCSetNIterationsMax( fTestModel->MCMCGetNIterationsMax() ); 00064 MCMCSetNIterationsRun( fTestModel->MCMCGetNIterationsRun() ); 00065 MCMCSetNIterationsPreRunMin( fTestModel->MCMCGetNIterationsPreRunMin() ); 00066 MCMCSetNIterationsUpdate( fTestModel->MCMCGetNIterationsUpdate() ); 00067 MCMCSetNIterationsUpdateMax( fTestModel->MCMCGetNIterationsUpdateMax() ); 00068 MCMCSetRValueCriterion( fTestModel->MCMCGetRValueCriterion() ); 00069 MCMCSetRValueParametersCriterion( fTestModel->MCMCGetRValueParametersCriterion() ); 00070 00071 } 00072 00073 // --------------------------------------------------------- 00074 double BCSummaryPriorModel::LogLikelihood(const std::vector<double> & parameters) 00075 { 00076 return fTestModel->LogAPrioriProbability(parameters); 00077 } 00078 00079 // --------------------------------------------------------- 00080 double BCSummaryPriorModel::LogAPrioriProbability(const std::vector<double> & /*parameters*/) 00081 { 00082 return 0; 00083 } 00084 00085 // --------------------------------------------------------- 00086