00001 #ifndef __MCMC_H__
00002 #define __MCMC_H__
00003 
00004 #include <vector>
00005 #include <cmath>
00006 #include <cuda.h>
00007 #include <hemi/hemi.h>
00008 #include "signals.h"
00009 #include "nll_kernels.h"
00010 
00011 #ifdef __CUDACC__
00012 #include <curand_kernel.h>
00013 #endif
00014 
00015 #ifndef __HEMI_ARRAY_H__
00016 #define __HEMI_ARRAY_H__
00017 #include <hemi/array.h>
00018 #endif
00019 
00020 class TNtuple;
00021 
00029 class MCMC {
00030   public:
00037     MCMC(const std::vector<Signal>& signals, TNtuple* data);
00038 
00044      ~MCMC();
00045 
00054     TNtuple* operator()(unsigned nsteps, float burnin_fraction,
00055                         unsigned sync_interval=1000);
00056 
00067     hemi::Array<float>* build_lut(const std::vector<Signal>& signals,
00068                                         TNtuple* data);
00069 
00070   protected:
00090     void nll(const float* v, double* nll,
00091              double* event_partial_sums,
00092              double* event_total_sum);
00093 
00094   private:
00095     unsigned nsignals;  
00096     unsigned nevents;  
00097     unsigned nnllblocks;  
00098     unsigned nllblocksize;  
00099     unsigned nnllthreads;  
00100     unsigned nreducethreads; 
00101     unsigned blocksize;  
00102     unsigned nblocks;  
00103     std::string varlist;  
00104     hemi::Array<float>* expectations;  
00105     hemi::Array<float>* constraints;  
00106     hemi::Array<float>* lut;  
00107     hemi::Array<RNGState>* rngs;  
00108 };
00109 
00110 #endif  // __MCMC_H__
00111