43 #include "Minuit2/Minuit2Minimizer.h"
45 using namespace ROOT::Minuit2;
51 int main(
int argc,
char** argv){
56 bool interactive=
false;
59 TString wavefile_name;
60 TString ofile_name=
"fitresult.root";
62 TString norm_file_name;
70 while ((c = getopt(argc, argv,
"l:u:iw:o:s:n:r:qh")) != -1)
76 low_mass = atof(optarg);
79 high_mass = atof(optarg);
89 norm_file_name = optarg;
92 wavefile_name = optarg;
102 cerr <<
"usage:" << endl;
103 cerr << progname <<
" -l # -u # [-i -h -q] [-n normfile -s start values -r rank] -w wavelist -o outfile " << endl;
104 cerr <<
" where:" << endl;
105 cerr <<
" -i: interactive minuit session" << endl;
106 cerr <<
" -l #: lower edge of bin" << endl;
107 cerr <<
" -u #: upper edge of bin" << endl;
108 cerr <<
" -w file: set wavelist file" << endl;
109 cerr <<
" -o file: set output file" << endl;
110 cerr <<
" -n file: set normalization file" << endl;
111 cerr <<
" -s file: set starting values file" <<endl;
112 cerr <<
" -r #: set rank" <<endl;
113 cerr <<
" -q: run quietly" << endl;
114 cerr <<
" -h: print help" << endl;
122 TMatrixT<double> cov(2,2);
127 TMatrixT<double> prec(2,2);
133 cout <<
"Installing parameters:" << endl;
134 unsigned int ndim=L.
NDim();
145 TFile* file=TFile::Open(
"hamMCtest.root",
"RECREATE");
146 TTree* tree=
new TTree(
"MarkovChain",
"MarkovChain");
147 tree->Branch(
"N",&ndim,
"N/I");
148 tree->Branch(
"dL",&dL,
"dL[N]/D");
149 tree->Branch(
"X",&X,
"X[N]/D");
151 TTree* tree2=
new TTree(
"Steps",
"Steps");
152 tree2->Branch(
"N",&ndim,
"N/I");
153 tree2->Branch(
"dL",&dL,
"dL[N]/D");
154 tree2->Branch(
"X",&X,
"X[N]/D");
157 for(
unsigned int i=0;
i<L.
NDim();++
i){
160 R[
i]=gRandom->Gaus(0,1);
165 unsigned int Nit=5000;
166 unsigned int Nleap=5;
174 for(
unsigned it=0;it<Nit;++it){
175 cout <<
"Iteration" << it << endl;
186 for(
unsigned int ip=0; ip<ndim;++ip){
194 for(
unsigned int ip=0; ip<ndim;++ip){
198 R[ip]=R[ip]-eps2*dL[ip];
201 unsigned int nl=Nleap;
202 for(
unsigned il=0; il<nl;++il){
203 for(
unsigned int ip=0; ip<ndim;++ip){
205 X[ip]=X[ip]+eps/m*R[ip];
212 for(
unsigned int ip=0; ip<ndim;++ip){
213 R[ip]=R[ip]-eps*dL[ip];
217 for(
unsigned int ip=0; ip<ndim;++ip){
218 R[ip]=R[ip]-eps2*dL[ip];
228 for(
unsigned int ip=0; ip<ndim;++ip){
230 R[ip]=gRandom->Gaus(0,1);
234 double plength=gRandom->Gaus(0,1);
236 for(
unsigned int ip=0; ip<ndim;++ip)R[ip]*=plength;
242 cout <<
">>>> (Hlast-H)/H = " << (Hlast-H)/H << endl;
248 if(gRandom->Uniform()<TMath::Exp(H-Hlast)){
263 cout <<
"Acceptance Rate: " << (double)Nacc/(
double)(it+1) << endl;
270 cout <<
"Acceptance Rate: " << (double)Nacc/(
double)Nit << endl;
359 int mnparm(
int,
string,
double,
double,
double,
double) {
360 cerr <<
"this is impossible" << endl;