StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
laser_2d_opt.C
1 // $Id: laser_2d_opt.C,v 1.4 2009/10/14 15:58:43 jcs Exp $
2 //
3 // $Log: laser_2d_opt.C,v $
4 // Revision 1.4 2009/10/14 15:58:43 jcs
5 // change and add macros so that in addition to varying t0 and the gas compostion,
6 // the gas temperature can be varied
7 //
8 // Revision 1.3 2008/05/15 20:58:34 jcs
9 // removed debug print out statement
10 //
11 // Revision 1.2 2006/03/15 15:14:06 jcs
12 // add lines for listing CVS update info
13 //
14 
15 //======================================================================
16 //
17 // laser_2d_opt reads the file produced in StFtpcLaserCalib::MakePs()
18 // and draws the histograms for the residuals
19 //
20 // Inputs to macro:
21 // a - select value(s) to be histogrammed
22 // x resx
23 // y resy
24 // r resrad
25 // p resphi
26 // c c2
27 // e rad3-28.56
28 // a resx, resy, resrad, resphi
29 // opt - set Draw Options
30 // (see ftp://root.cern.ch/root/doc/chapter3.pdf, pages 5-6)
31 //
32 //======================================================================
33 
34 void laser_2d_opt(TString a,char *opt)
35 {
36 cout<<"a = "<<a<<" opt "<<opt<<endl;
37  TCanvas *c1 = new TCanvas("c1","ps",200,10,700,500);
38  gStyle->SetPalette(1);
39  gStyle->SetOptStat(0);
40  gStyle->SetOptFit(0);
41 
42  TH2F *hr = new TH2F("hr","",12,-0.55,0.65,12,-0.45,0.75); // binning !?????
43  hr->GetYaxis()->SetTitle("#Delta Ar [%]");
44  hr->GetXaxis()->SetTitle("#Delta t_{0}");
45  TH2F *hr2 = new TH2F("hr2","Residual x",12,-0.55,0.65,12,-0.45,0.75); // binning !?????
46  hr2->GetYaxis()->SetTitle("#Delta Ar [%]");
47  hr2->GetXaxis()->SetTitle("#Delta t_{0}");
48  TH2F *hr3 = new TH2F("hr3","Residual y",12,-0.55,0.65,12,-0.45,0.75); // binning !?????
49  hr3->GetYaxis()->SetTitle("#Delta Ar [%]");
50  hr3->GetXaxis()->SetTitle("#Delta t_{0}");
51  TH2F *hr4 = new TH2F("hr4","Residual radius",12,-0.55,0.65,12,-0.45,0.75); // binning !?????
52  hr4->GetYaxis()->SetTitle("#Delta Ar [%]");
53  hr4->GetXaxis()->SetTitle("#Delta t_{0}");
54  TH2F *hr5 = new TH2F("hr5","Residual phi",12,-0.55,0.65,12,-0.45,0.75); // binning !?????
55  hr5->GetYaxis()->SetTitle("#Delta Ar [%]");
56  hr4->GetXaxis()->SetTitle("#Delta t_{0}");
57 
58  //hr->DrawCopy();
59  //
60 
61 
62  //FILE *file1=fopen ("5006004_inclined_s_laser1_b0.log","r");
63 
64  FILE *file1=fopen ("res.log","r");
65 
66  Int_t datab1;
67 
68  float resx,resy,resrad,resphi, t0, gas, T, c2,rad1,rad11, rad2, rad21, rad3, rad31, err;
69 
70  while(!feof(file1))
71  {
72  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resx,&c2);
73  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resy,&c2);
74  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resrad,&c2);
75  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resphi,&c2);
76  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad1,&err);
77  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad11);
78  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad2,&err);
79  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad21);
80  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad3,&err);
81  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad31);
82  if (feof(file1)) break;
83 
84  if (a=='x')
85  {
86  hr->Fill(t0,gas,resx);
87  }
88 /*
89  {
90  if (resx<0.01)
91  {
92  hr->Fill(t0,gas,resx);
93  }
94  else
95  {
96  hr->Fill(t0,gas,0.0);
97  }
98  }
99 */
100  else if (a=='y')
101  hr->Fill(t0,gas,resy);
102  else if (a=='r')
103  hr->Fill(t0,gas,resrad);
104  else if (a=='p')
105  hr->Fill(t0,gas,resphi);
106  else if (a=='c')
107  hr->Fill(t0,gas,(float) c2);
108  else if (a=='e')
109  hr->Fill(t0,gas,rad3-28.56);
110  //else if (a=='a' && !(gas==0 && t0==0))
111  else if (a=='a')
112  {
113  hr2->Fill(t0,gas,resx);
114  hr3->Fill(t0,gas,resy);
115  hr4->Fill(t0,gas,resrad);
116  hr5->Fill(t0,gas,resphi);
117  }
118  else
119  {cout<<"Funktion nicht vorhanden !"<<endl;break;}
120  }
121 
122  if (a=='a')
123  {
124  c1->Divide(2,2);
125  c1->cd(1);
126  hr2->DrawCopy(opt);
127  c1->cd(2);
128  hr3->DrawCopy(opt);
129  c1->cd(3);
130  hr4->DrawCopy(opt);
131  c1->cd(4);
132  hr5->DrawCopy(opt);
133  }
134  else
135  hr->DrawCopy(opt);
136  //float minx,miny;
137  //cout<<hr->GetMinimumBin()<<endl;;
138  //cout<<minx<<" "<<miny<<endl;
139  c1->Update();
140  if (fclose(file1) != 0)
141  cout<<"Datei nicht geschlossen !"<<endl;
142 }