23 #include "TMultiGraph.h"
29 void checkMCMC(TTree* tree,
unsigned int ndim,
unsigned int burnin=0,
unsigned int step=100){
36 vector<TGraph*> graphs(ndim);
37 unsigned int nentries=tree->GetEntriesFast();
38 TMultiGraph* mgraph=
new TMultiGraph();
40 for(
unsigned int ip=0;ip<ndim;++ip){
45 graphs[ip]=
new TGraph((nentries-burnin)/step);
46 mgraph->Add(graphs[ip]);
49 tree->SetBranchAddress(
"dL",&Grad);
50 tree->SetBranchAddress(
"X",&X);
55 for(
unsigned int i=burnin;
i<nentries;
i+=step){
57 for(
unsigned int j=burnin; j<=
i; ++j){
59 for(
unsigned int ip=0;ip<ndim;++ip){
63 for(
unsigned int ip=0;ip<ndim;++ip){
64 Xmean[ip]/=(double)(
i-burnin+1);
67 for(
unsigned int j=burnin; j<=
i; ++j){
70 for(
unsigned int ip=0;ip<ndim;++ip){
71 double diff=X[ip]-Xmean[ip];
74 Var3[ip]+=diff*diff*diff*Grad[ip];
79 double Rmax=-10000000;
81 unsigned int Imin, Imax;
85 for(
unsigned int ip=0;ip<ndim;++ip){
86 if(Var2[ip]==0)
continue;
87 double R=Var3[ip]/(3*Var2[ip]);
88 graphs[ip]->SetPoint(
i-burnin,
i-burnin,R);
89 if(R<Rmin){Rmin=R;Imin=ip;}
90 if(R>Rmax){Rmax=R;Imax=ip;}
99 cout <<
"Rmin("<<Imin<<
")="<<Rmin
100 <<
" ... Rmean="<<Rmean
101 <<
" ... Rmax("<<Imax<<
")="<<Rmax<<endl;