#ifdef COMPILED_ROOT #include #include #include "TH1.h" #include "TCanvas.h" #include "TFile.h" #include "TF1.h" #include "TROOT.h" #include "TApplication.h" extern void InitGui(); VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; #endif Double_t expExp(Double_t* a, Double_t* aa); #ifdef COMPILED_ROOT TROOT root("doFit","doFit",initfuncs); Int_t main(int argc, char** argv) { TApplication theApp("App",&argc,argv); #endif #ifndef COMPILED_ROOT Int_t allFits(void) { #endif Double_t p1,p2,p3; TF1* f1 = new TF1("expExp",expExp,0,1,4); f1->SetParameters(17,0.01,5,2000); f1->SetParNames("1st slope","2nd Amp","2nd slope","scale fac"); char histname[100]; TH1F* h[55]; Int_t i,j; Int_t k; FILE* fout = fopen("alldet_fits.dat","w"); TFile* fin = new TFile("alldet_hists.root"); fin->cd(); f1->SetParameters(17,0.01,5,2000); f1->SetParNames("1st slope","2nd Amp","2nd slope","scale fac"); TCanvas* c1 = new TCanvas("c1","c1",1); for(i=0 ; i<11 ; i++) { for(j=0 ; j<5 ; j++ ) { sprintf(histname,"en%2d rad%2d elastic",i+4,j+1); h[i*5+j] = (TH1F*)fin->Get(histname); h[i*5+j]->Fit("expExp","RI"); p1 = f1->GetParameter(0); p2 = f1->GetParameter(1); p3 = f1->GetParameter(2); printf("%3d %3d %f %f %f\n",i+4,j+1,p1,p2,p3); fprintf(fout,"%3d %3d %f %f %f\n",i+4,j+1,p1,p2,p3); } } fclose(fout); return 1; } Double_t expExp(Double_t* x, Double_t* par) { Double_t expPart1 = exp(par[0]*(x[0]-1)); Double_t expPart2 = exp(par[2]*(x[0]-1)); return (par[3]* (expPart1 + par[1]*expPart2)); }