BayesianAnalysisToolkit  0.9.3
BCSummaryPriorModel.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2013, the BAT core developer team
3  * All rights reserved.
4  *
5  * For the licensing terms see doc/COPYING.
6  * For documentation see http://mpp.mpg.de/bat
7  */
8 
9 // ---------------------------------------------------------
10 
11 #include "BCSummaryPriorModel.h"
12 
13 #include "BCH1D.h"
14 #include "BCLog.h"
15 #include "BCParameter.h"
16 
17 #include <TH1D.h>
18 
19 // ---------------------------------------------------------
21  : BCModel()
22  , fTestModel(0)
23 {
24 }
25 
26 // ---------------------------------------------------------
28  : BCModel(name)
29  , fTestModel(0)
30 {
31 }
32 
33 // ---------------------------------------------------------
35 {}
36 
37 // ---------------------------------------------------------
39 {
40  fTestModel = model;
41 
42  // copy parameters
43  int npar = fTestModel->GetNParameters();
44  for (int i = 0; i < npar; ++i) {
45  BCParameter * par = const_cast<BCParameter *>(fTestModel->GetParameter(i));
46  AddParameter(par);
47  }
48 
49  // set default histogram binning to the one of the original model
50  for (int i = 0; i < npar; ++i) {
51  // this construct has to go here, because otherwise there is a
52  // warning from BCEngineMCMC:: MCMCGetH1Marginalized
53  if (fTestModel->GetBestFitParameters().size() > 0){
55  if (hist) {
56  int nbins = hist->GetHistogram()->GetNbinsX();
57  fTestModel->GetParameter(i)->SetNbins(nbins);
58  }
59  }
60  }
61 
62  // set default MCMC setup to the one of the original model
72 
73 }
74 
75 // ---------------------------------------------------------
76 double BCSummaryPriorModel::LogLikelihood(const std::vector<double> & parameters)
77 {
78  return fTestModel->LogAPrioriProbability(parameters);
79 }
80 
81 // ---------------------------------------------------------
82 double BCSummaryPriorModel::LogAPrioriProbability(const std::vector<double> & /*parameters*/)
83 {
84  return 0;
85 }