Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fitparm_summary.C
Go to the documentation of this file.
1 const Int_t nfiles=8;
2 TCanvas *c[nfiles];
3 Double_t rho_error (Float_t *y1, Float_t *y1_err, Float_t *y2, Float_t *y2_err) {
4  // compute the uncertainty in measurement of the magnitude given the uncertainties in the Real and Imaginary parts.
5  // Note that this assumes uncorrelated uncertainties, which is probably not a good approximation.
6  // The full error matrix is needed to compute the uncertainties properly.
7  Double_t error=0;
8  return error;
9 }
10 Double_t phi_error (Float_t *y1, Float_t *y2) {
11  // compute the uncertainty in measurement of the phase angle given the uncertainties in the Real and Imaginary parts.
12  // Note that this assumes uncorrelated uncertainties, which is probably not a good approximation.
13  // The full error matrix is needed to compute the uncertainties properly.
14  Double_t error=0;
15  return error;
16 }
17 Int_t read_parms (Int_t j, TString filename, Float_t *yparms, Float_t *yparms_err ) {
18 
19  vector <TString> sdme;
20  vector <double> parms;
21  vector <double> parms_err;
22 
23 
24  TString infile = filename+".fit2"; // file with parameters
25 
26  cout << "Opening parameters file: " << infile.Data() << endl;
27 
28  // now read and print fitted values
29  ifstream parameters;
30  parameters.open (infile.Data());
31  if (!parameters) {
32  cout << "ERROR: Failed to open data file= " << infile.Data() << endl;
33  return 1; // failed to open data file
34  }
35 
36  TString CanvasName = filename;
37  // cout << "j=" << j << " CanvasName=" << CanvasName << endl;
38  c[j] = new TCanvas(CanvasName,CanvasName,200,10,1000,700);
39 
40  TString line;
41  while (line.ReadLine(parameters)){
42 
43  TObjArray *tokens = line.Tokenize("\t");
44  Int_t ntokens = tokens->GetEntries();
45 
46  // cout << " ntokens=" << ntokens << " line=" << line.Data() << endl;
47  Int_t jmax=ntokens/3;
48  for (Int_t j=0; j<jmax; j++){
49  sdme.push_back( (((TObjString*)tokens->At(3*j))->GetString()) );
50  parms.push_back( (((TObjString*)tokens->At(3*j+1))->GetString()).Atof() );
51  parms_err.push_back( (((TObjString*)tokens->At(3*j+2))->GetString()).Atof());
52  }
53 
54  } // end loop over lines
55 
56  TString title = filename;
57  TLatex *t1 = new TLatex(0.2,0.85,title);
58  t1->SetNDC();
59  t1->SetTextSize(0.04);
60  t1->Draw();
61 
62  for (Int_t j=0; j<sdme.size()-2; j++) { // -2 to eliminate Sigma and P
63  cout << sdme[j] << "=" << parms[j] << " err=" << parms_err[j] << endl;
64 
65  TString sdmename;
66  sdmename = sdme[j];
67  title.Form("%s = \t%.3f #pm %.3f\n",sdmename.Data(),parms[j],parms_err[j]);
68  // cout << "title=" << title << endl;
69  TLatex *t1 = new TLatex(0.2,0.75 - 0.05*j,title);
70  t1->SetNDC();
71  t1->SetTextSize(0.04);
72  t1->Draw();
73  }
74 
75 
76  // cout << " parms.size()=" << parms.size() << endl;
77  for (jj=0; jj<parms.size()-2; jj++) {
78  yparms[jj] = parms[jj];
79  yparms_err[jj] = parms_err[jj];
80  }
81 
82 
83  parameters.close();
84 
85  return 0;
86 
87 }
88 
89 
91 {
92 // File: fitparm_summary.C
93  // Read text files with fitted parameters, plot and compare
94 //
95 
96  gStyle->SetPalette(1,0);
97  gStyle->SetOptStat(111111);
98  gStyle->SetOptFit(111111);
99  gStyle->SetPadRightMargin(0.15);
100  gStyle->SetPadLeftMargin(0.15);
101  gStyle->SetPadBottomMargin(0.15);
102 
103  vector <TString> filenames;
104  Float_t g1V00_re[nfiles];
105  Float_t g1V00_im[nfiles];
106  Float_t g1V11_re[nfiles];
107  Float_t g1V11_im[nfiles];
108  Float_t g1V10_re[nfiles];
109  Float_t g1V10_im[nfiles];
110  Float_t g1V1m1_re[nfiles];
111  Float_t g1V1m1_im[nfiles];
112  Float_t g1V00_re_err[nfiles];
113  Float_t g1V00_im_err[nfiles];
114  Float_t g1V11_re_err[nfiles];
115  Float_t g1V11_im_err[nfiles];
116  Float_t g1V10_re_err[nfiles];
117  Float_t g1V10_im_err[nfiles];
118  Float_t g1V1m1_re_err[nfiles];
119  Float_t g1V1m1_im_err[nfiles];
120  Float_t xparms[nfiles]={1,2,3,4,5,6,7,8};
121  Float_t xparms_err[nfiles]={0.01,0.01,0.01,0.01,0.01,0.01,0.01,0.01};
122  Float_t g1V00_rho[nfiles];
123  Float_t g1V00_phi[nfiles];
124  Float_t g1V11_rho[nfiles];
125  Float_t g1V11_phi[nfiles];
126  Float_t g1V10_rho[nfiles];
127  Float_t g1V10_phi[nfiles];
128  Float_t g1V1m1_rho[nfiles];
129  Float_t g1V1m1_phi[nfiles];
130 
131  Float_t g1V00_rho_err[nfiles];
132  Float_t g1V00_phi_err[nfiles];
133  Float_t g1V11_rho_err[nfiles];
134  Float_t g1V11_phi_err[nfiles];
135  Float_t g1V10_rho_err[nfiles];
136  Float_t g1V10_phi_err[nfiles];
137  Float_t g1V1m1_rho_err[nfiles];
138  Float_t g1V1m1_phi_err[nfiles];
139 
140 
141  const Int_t nparms=8;
142  Float_t yparms[nparms];
143  Float_t yparms_err[nparms];
144 
145  TGraphErrors *gr_g1V00_re;
146  TGraphErrors *gr_g1V00_im;
147  TGraphErrors *gr_g1V11_re;
148  TGraphErrors *gr_g1V11_im;
149  TGraphErrors *gr_g1V10_re;
150  TGraphErrors *gr_g1V10_im;
151  TGraphErrors *gr_g1V1m1_re;
152  TGraphErrors *gr_g1V1m1_im;
153 
154  TGraphErrors *gr_g1V00_rho;
155  TGraphErrors *gr_g1V00_phi;
156  TGraphErrors *gr_g1V11_rho;
157  TGraphErrors *gr_g1V11_phi;
158  TGraphErrors *gr_g1V10_rho;
159  TGraphErrors *gr_g1V10_phi;
160  TGraphErrors *gr_g1V1m1_rho;
161  TGraphErrors *gr_g1V1m1_phi;
162 
163  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_NOTAG_W_1000000");
164  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_NOTAG_File_1000000");
165  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG_W_1000000");
166  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG_File_1000000");
167  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG10_W_1000000");
168  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG10_File_1000000");
169  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG40_W_1000000");
170  filenames.push_back("twopi_primakoff_DSelect_sw1pw1000_TAG40_File_1000000");
171 
172 
173  for (j=0; j<filenames.size(); j++) {
174  read_parms(j, filenames[j], yparms, yparms_err);
175  cout << " yparms=" << yparms[0] << " " << yparms[1] << " " << yparms[2] << " " << yparms[3] << " " << yparms[4] << " " << yparms[5] << " " << yparms[6] << " " << yparms[7] << endl;
176  g1V00_re[j] = yparms[0];
177  g1V00_im[j] = yparms[1];
178  g1V11_re[j] = yparms[2];
179  g1V11_im[j] = yparms[3];
180  g1V10_re[j] = yparms[4];
181  g1V10_im[j] = yparms[5];
182  g1V1m1_re[j] = yparms[6];
183  g1V1m1_im[j] = yparms[7];
184  g1V00_re_err[j] = yparms_err[0];
185  g1V00_im_err[j] = yparms_err[1];
186  g1V11_re_err[j] = yparms_err[2];
187  g1V11_im_err[j] = yparms_err[3];
188  g1V10_re_err[j] = yparms_err[4];
189  g1V10_im_err[j] = yparms_err[5];
190  g1V1m1_re_err[j] = yparms_err[6];
191  g1V1m1_im_err[j] = yparms_err[7];
192 
193 
194  g1V00_rho[j] = sqrt(yparms[0]*yparms[0]+yparms[1]*yparms[1]);
195  g1V00_phi[j] = atan2(yparms[1],yparms[0])*180./3.14159;
196  g1V11_rho[j] = sqrt(yparms[2]*yparms[2]+yparms[3]*yparms[3]);
197  g1V11_phi[j] = atan2(yparms[3],yparms[2])*180./3.14159;
198  g1V10_rho[j] = sqrt(yparms[4]*yparms[4]+yparms[5]*yparms[5]);
199  g1V10_phi[j] = atan2(yparms[5],yparms[4])*180./3.14159;
200  g1V1m1_rho[j] = sqrt(yparms[6]*yparms[6]+yparms[7]*yparms[7]);
201  g1V1m1_phi[j] = atan2(yparms[7],yparms[6])*180./3.14159;
202  }
203 
204 
205  gr_g1V00_re = new TGraphErrors(nfiles,xparms,g1V00_re,xparms_err,g1V00_re_err);
206  gr_g1V00_im = new TGraphErrors(nfiles,xparms,g1V00_im,xparms_err,g1V00_im_err);
207  gr_g1V11_re = new TGraphErrors(nfiles,xparms,g1V11_re,xparms_err,g1V11_re_err);
208  gr_g1V11_im = new TGraphErrors(nfiles,xparms,g1V11_im,xparms_err,g1V11_im_err);
209  gr_g1V10_re = new TGraphErrors(nfiles,xparms,g1V10_re,xparms_err,g1V10_re_err);
210  gr_g1V10_im = new TGraphErrors(nfiles,xparms,g1V10_im,xparms_err,g1V10_im_err);
211  gr_g1V1m1_re = new TGraphErrors(nfiles,xparms,g1V1m1_re,xparms_err,g1V1m1_re_err);
212  gr_g1V1m1_im = new TGraphErrors(nfiles,xparms,g1V1m1_im,xparms_err,g1V1m1_im_err);
213 
214  gr_g1V00_rho = new TGraphErrors(nfiles,xparms,g1V00_rho,xparms_err,g1V00_rho_err);
215  gr_g1V00_phi = new TGraphErrors(nfiles,xparms,g1V00_phi,xparms_err,g1V00_phi_err);
216  gr_g1V11_rho = new TGraphErrors(nfiles,xparms,g1V11_rho,xparms_err,g1V11_rho_err);
217  gr_g1V11_phi = new TGraphErrors(nfiles,xparms,g1V11_phi,xparms_err,g1V11_phi_err);
218  gr_g1V10_rho = new TGraphErrors(nfiles,xparms,g1V10_rho,xparms_err,g1V10_rho_err);
219  gr_g1V10_phi = new TGraphErrors(nfiles,xparms,g1V10_phi,xparms_err,g1V10_phi_err);
220  gr_g1V1m1_rho = new TGraphErrors(nfiles,xparms,g1V1m1_rho,xparms_err,g1V1m1_rho_err);
221  gr_g1V1m1_phi = new TGraphErrors(nfiles,xparms,g1V1m1_phi,xparms_err,g1V1m1_phi_err);
222 
223  c0 = new TCanvas("c0","c0",200,10,1000,700);
224  c0->Divide(3,3);
225  c0->cd(1);
226  gr_g1V00_re->SetTitle("g1V00_re");
227  gr_g1V00_re->GetXaxis()->SetTitleSize(0.05);
228  gr_g1V00_re->GetYaxis()->SetTitleSize(0.05);
229  gr_g1V00_re->GetXaxis()->SetTitle("Measurement");
230  gr_g1V00_re->SetMarkerStyle(20);
231  gr_g1V00_re->SetMarkerColor(4);
232  gr_g1V00_re->Draw("p");
233  gr_g1V00_re->Draw();
234 
235  c0->cd(2);
236  gr_g1V00_im->SetTitle("g1V00_im");
237  gr_g1V00_im->GetXaxis()->SetTitleSize(0.05);
238  gr_g1V00_im->GetYaxis()->SetTitleSize(0.05);
239  gr_g1V00_im->GetXaxis()->SetTitle("Measurement");
240  gr_g1V00_im->SetMarkerStyle(20);
241  gr_g1V00_im->SetMarkerColor(4);
242  gr_g1V00_im->Draw("p");
243  gr_g1V00_im->Draw();
244 
245  c0->cd(3);
246  gr_g1V11_re->SetTitle("g1V11_re");
247  gr_g1V11_re->GetXaxis()->SetTitleSize(0.05);
248  gr_g1V11_re->GetYaxis()->SetTitleSize(0.05);
249  gr_g1V11_re->GetXaxis()->SetTitle("Measurement");
250  gr_g1V11_re->SetMarkerStyle(20);
251  gr_g1V11_re->SetMarkerColor(4);
252  gr_g1V11_re->Draw("p");
253  gr_g1V11_re->Draw();
254 
255  c0->cd(4);
256  gr_g1V11_im->SetTitle("g1V11_im");
257  gr_g1V11_im->GetXaxis()->SetTitleSize(0.05);
258  gr_g1V11_im->GetYaxis()->SetTitleSize(0.05);
259  gr_g1V11_im->GetXaxis()->SetTitle("Measurement");
260  gr_g1V11_im->SetMarkerStyle(20);
261  gr_g1V11_im->SetMarkerColor(4);
262  gr_g1V11_im->Draw("p");
263  gr_g1V11_im->Draw();
264 
265  c0->cd(5);
266  gr_g1V10_re->SetTitle("g1V10_re");
267  gr_g1V10_re->GetXaxis()->SetTitleSize(0.05);
268  gr_g1V10_re->GetYaxis()->SetTitleSize(0.05);
269  gr_g1V10_re->GetXaxis()->SetTitle("Measurement");
270  gr_g1V10_re->SetMarkerStyle(20);
271  gr_g1V10_re->SetMarkerColor(4);
272  gr_g1V10_re->Draw("p");
273  gr_g1V10_re->Draw();
274 
275  c0->cd(6);
276  gr_g1V10_im->SetTitle("g1V10_im");
277  gr_g1V10_im->GetXaxis()->SetTitleSize(0.05);
278  gr_g1V10_im->GetYaxis()->SetTitleSize(0.05);
279  gr_g1V10_im->GetXaxis()->SetTitle("Measurement");
280  gr_g1V10_im->SetMarkerStyle(20);
281  gr_g1V10_im->SetMarkerColor(4);
282  gr_g1V10_im->Draw("p");
283  gr_g1V10_im->Draw();
284 
285  c0->cd(7);
286  gr_g1V1m1_re->SetTitle("g1V1m1_re");
287  gr_g1V1m1_re->GetXaxis()->SetTitleSize(0.05);
288  gr_g1V1m1_re->GetYaxis()->SetTitleSize(0.05);
289  gr_g1V1m1_re->GetXaxis()->SetTitle("Measurement");
290  gr_g1V1m1_re->SetMarkerStyle(20);
291  gr_g1V1m1_re->SetMarkerColor(4);
292  gr_g1V1m1_re->Draw("p");
293  gr_g1V1m1_re->Draw();
294 
295  c0->cd(8);
296  gr_g1V1m1_im->SetTitle("g1V1m1_im");
297  gr_g1V1m1_im->GetXaxis()->SetTitleSize(0.05);
298  gr_g1V1m1_im->GetYaxis()->SetTitleSize(0.05);
299  gr_g1V1m1_im->GetXaxis()->SetTitle("Measurement");
300  gr_g1V1m1_im->SetMarkerStyle(20);
301  gr_g1V1m1_im->SetMarkerColor(4);
302  gr_g1V1m1_im->Draw("p");
303  gr_g1V1m1_im->Draw();
304 
305  c1 = new TCanvas("c1","c1",200,10,1000,700);
306  c1->Divide(3,3);
307  c1->cd(1);
308  gr_g1V00_rho->SetTitle("g1V00_rho");
309  gr_g1V00_rho->GetXaxis()->SetTitleSize(0.05);
310  gr_g1V00_rho->GetYaxis()->SetTitleSize(0.05);
311  gr_g1V00_rho->GetXaxis()->SetTitle("Measurement");
312  gr_g1V00_rho->SetMarkerStyle(20);
313  gr_g1V00_rho->SetMarkerColor(4);
314  gr_g1V00_rho->Draw("p");
315  gr_g1V00_rho->Draw();
316 
317  c1->cd(2);
318  gr_g1V00_phi->SetTitle("g1V00_phi");
319  gr_g1V00_phi->GetXaxis()->SetTitleSize(0.05);
320  gr_g1V00_phi->GetYaxis()->SetTitleSize(0.05);
321  gr_g1V00_phi->GetXaxis()->SetTitle("Measurement");
322  gr_g1V00_phi->SetMarkerStyle(20);
323  gr_g1V00_phi->SetMarkerColor(4);
324  gr_g1V00_phi->Draw("p");
325  gr_g1V00_phi->Draw();
326 
327  c1->cd(3);
328  gr_g1V11_rho->SetTitle("g1V11_rho");
329  gr_g1V11_rho->GetXaxis()->SetTitleSize(0.05);
330  gr_g1V11_rho->GetYaxis()->SetTitleSize(0.05);
331  gr_g1V11_rho->GetXaxis()->SetTitle("Measurement");
332  gr_g1V11_rho->SetMarkerStyle(20);
333  gr_g1V11_rho->SetMarkerColor(4);
334  gr_g1V11_rho->Draw("p");
335  gr_g1V11_rho->Draw();
336 
337  c1->cd(4);
338  gr_g1V11_phi->SetTitle("g1V11_phi");
339  gr_g1V11_phi->GetXaxis()->SetTitleSize(0.05);
340  gr_g1V11_phi->GetYaxis()->SetTitleSize(0.05);
341  gr_g1V11_phi->GetXaxis()->SetTitle("Measurement");
342  gr_g1V11_phi->SetMarkerStyle(20);
343  gr_g1V11_phi->SetMarkerColor(4);
344  gr_g1V11_phi->Draw("p");
345  gr_g1V11_phi->Draw();
346 
347  c1->cd(5);
348  gr_g1V10_rho->SetTitle("g1V10_rho");
349  gr_g1V10_rho->GetXaxis()->SetTitleSize(0.05);
350  gr_g1V10_rho->GetYaxis()->SetTitleSize(0.05);
351  gr_g1V10_rho->GetXaxis()->SetTitle("Measurement");
352  gr_g1V10_rho->SetMarkerStyle(20);
353  gr_g1V10_rho->SetMarkerColor(4);
354  gr_g1V10_rho->Draw("p");
355  gr_g1V10_rho->Draw();
356 
357  c1->cd(6);
358  gr_g1V10_phi->SetTitle("g1V10_phi");
359  gr_g1V10_phi->GetXaxis()->SetTitleSize(0.05);
360  gr_g1V10_phi->GetYaxis()->SetTitleSize(0.05);
361  gr_g1V10_phi->GetXaxis()->SetTitle("Measurement");
362  gr_g1V10_phi->SetMarkerStyle(20);
363  gr_g1V10_phi->SetMarkerColor(4);
364  gr_g1V10_phi->Draw("p");
365  gr_g1V10_phi->Draw();
366 
367  c1->cd(7);
368  gr_g1V1m1_rho->SetTitle("g1V1m1_rho");
369  gr_g1V1m1_rho->GetXaxis()->SetTitleSize(0.05);
370  gr_g1V1m1_rho->GetYaxis()->SetTitleSize(0.05);
371  gr_g1V1m1_rho->GetXaxis()->SetTitle("Measurement");
372  gr_g1V1m1_rho->SetMarkerStyle(20);
373  gr_g1V1m1_rho->SetMarkerColor(4);
374  gr_g1V1m1_rho->Draw("p");
375  gr_g1V1m1_rho->Draw();
376 
377  c1->cd(8);
378  gr_g1V1m1_phi->SetTitle("g1V1m1_phi");
379  gr_g1V1m1_phi->GetXaxis()->SetTitleSize(0.05);
380  gr_g1V1m1_phi->GetYaxis()->SetTitleSize(0.05);
381  gr_g1V1m1_phi->GetXaxis()->SetTitle("Measurement");
382  gr_g1V1m1_phi->SetMarkerStyle(20);
383  gr_g1V1m1_phi->SetMarkerColor(4);
384  gr_g1V1m1_phi->Draw("p");
385  gr_g1V1m1_phi->Draw();
386 
387  c[0]->SaveAs("fitparm_summary.pdf(");
388  for (j=1; j<nfiles; j++) {
389  c[j]->SaveAs("fitparm_summary.pdf");
390  }
391  c0->SaveAs("fitparm_summary.pdf");
392  c1->SaveAs("fitparm_summary.pdf)");
393 }
Double_t rho_error(Float_t *y1, Float_t *y1_err, Float_t *y2, Float_t *y2_err)
const Int_t nfiles
Double_t c0[2][NMODULES]
Definition: tw_corr.C:67
Double_t phi_error(Float_t *y1, Float_t *y2)
#define c
TString filename
TFile * infile
Definition: tw_corr.C:45
Double_t c1[2][NMODULES]
Definition: tw_corr.C:68
TLatex * t1
double sqrt(double)
Int_t read_parms(Int_t j, TString filename, Float_t *yparms, Float_t *yparms_err)
void fitparm_summary()
vector< string > filenames