• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

BCSummaryPriorModel.cxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008-2010, 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 <BAT/BCLog.h>
00013 #include <BAT/BCH1D.h>
00014 
00015 #include <BAT/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 double BCSummaryPriorModel::LogLikelihood(std::vector <double> parameters)
00037 {
00038    return fTestModel->LogAPrioriProbability(parameters);
00039 }
00040 
00041 // ---------------------------------------------------------
00042 double BCSummaryPriorModel::LogAPrioriProbability(std::vector <double> parameters)
00043 {
00044    return 0;
00045 }
00046 
00047 // ---------------------------------------------------------
00048 int BCSummaryPriorModel::PerformAnalysis()
00049 {
00050    // check if model is set
00051    if (!fTestModel) {
00052       BCLog::OutError("BCSummaryPriorModel::PerformAnalysis : Model not defined.");
00053       return 0;
00054    }
00055 
00056    // copy parameters
00057    int npar = fTestModel->GetNParameters();
00058    for (int i = 0; i < npar; ++i) {
00059       BCParameter* par = fTestModel->GetParameter(i);
00060       AddParameter(par);
00061    }
00062 
00063    for (int i = 0; i < npar; ++i) {
00064       int nbins = fTestModel->GetMarginalized(fTestModel->GetParameter(i))->GetHistogram()->GetNbinsX();
00065       SetNbins((fTestModel->GetParameter(i)->GetName()).c_str(), nbins);
00066    }
00067 
00068    MCMCSetNLag(10);
00069    MCMCSetNIterationsRun( fTestModel->MCMCGetNIterationsRun() );
00070    MarginalizeAll();
00071    FindModeMinuit( GetBestFitParameters() );
00072 
00073    // no error
00074    return 1;
00075 }
00076 
00077 // ---------------------------------------------------------
00078 

Generated on Mon Aug 30 2010 22:14:54 for Bayesian Analysis Toolkit by  doxygen 1.7.1