StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
res_laser.C
1 // $Id: res_laser.C,v 1.6 2009/10/14 15:58:43 jcs Exp $
2 //
3 // $Log: res_laser.C,v $
4 // Revision 1.6 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.5 2008/05/15 21:00:06 jcs
9 // change histogram limits
10 // add improved comments
11 //
12 // Revision 1.4 2008/04/23 20:28:56 jcs
13 // clean up code
14 //
15 // Revision 1.2 2006/03/15 15:14:06 jcs
16 // add lines for listing CVS update info
17 //
18 
19 // plots the rms width of the residual distribution in radius and in phi vs. change in gas composition delta Ar
20 // from the *_res.log files produced by lasertest.C macro
21 // to use create the res.log file with the following 2 commands
22 // touch res.log
23 // cat *_res.log >> res.log
24 
25 
26 #include "Gtypes.h"
27 #include "iostream.h"
28 
29 float calc_min(float b1,float b2)
30 {
31  return -b1/(2*b2);
32 }
33 
34 void res_laser()
35 {
36  TCanvas *c1 = new TCanvas("c1","ps",200,10,700,500);
37  TStyle *plain = new TStyle("Plain","Plain Style (no colors/fill areas)");
38  plain->SetTitleOffset(1.25);
39  plain->SetCanvasBorderMode(0);
40  plain->SetPadBorderMode(0);
41  plain->SetPadColor(0);
42  plain->SetCanvasColor(0);
43  plain->SetTitleColor(0);
44  plain->SetStatColor(0);
45  plain->SetPalette(1);
46  plain->SetOptStat(0000000);
47  plain->SetOptFit(00000000);
48 
49  TH2F *hr = new TH2F("hr","",10,-0.5,0.5,10,0.0,0.1);
50  hr->SetTitle("#sigma_{res} vs. #Delta Argon");
51  hr->GetYaxis()->SetTitleOffset(1.2);
52  hr->GetYaxis()->SetTitle("#sigma_{res}");
53  hr->GetXaxis()->SetTitleOffset(1.2);
54  hr->GetXaxis()->SetTitle("#Delta Argon");
55  hr->SetStats(0);
56  hr->DrawCopy();
57  //
58 
59  FILE *file1=fopen ("res.log","r");
60  Int_t datab1,datab0;
61 
62  const int nhits=160;
63 
64  float resx[nhits],resy[nhits],resrad[nhits],resphi[nhits], t0[nhits], gas[nhits];
65 
66  float gas_temp, t0_temp, T, c2,rad, err, resphi_temp, resrad_temp;
67 
68  int ihits==0;
69  while(!feof(file1))
70  {
71 
72  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&resx,&c2);
73  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&resy,&c2);
74  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&resrad_temp,&c2);
75  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&resphi_temp,&c2);
76  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&rad,&err);
77  datab1 = fscanf(file1,"%f %f %f %f",&t0_temp,&gas_temp,&T,&rad);
78  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&rad,&err);
79  datab1 = fscanf(file1,"%f %f %f %f",&t0_temp,&gas_temp,&T,&rad);
80  datab1 = fscanf(file1,"%f %f %f %f %f",&t0_temp,&gas_temp,&T,&rad,&err);
81  datab1 = fscanf(file1,"%f %f %f %f",&t0_temp,&gas_temp,&T,&rad);
82 
83  //cout<<t0_temp<<endl;
84  //if (t0_temp!=0)
85  {
86  t0[ihits]=t0_temp;
87  gas[ihits]=gas_temp;
88  resphi[ihits]=resphi_temp;
89  resrad[ihits]=resrad_temp;
90  cout<<ihits<<" t0["<<ihits<<"] = "<<t0_temp<<" gas["<<ihits<<"] = "<<gas_temp<<" resphi["<<ihits<<"] = "<<resphi_temp<<" resrad["<<ihits<<"] = "<<resrad_temp<<endl;
91  ihits++;
92  }
93  }
94 
95  TF1 *g=new TF1("g","[0]+[1]*x^2",0,0.6);
96  g->SetParameters(0.01,0.001);
97  g->SetLineColor(kRed);
98 
99  TGraph *gerad = new TGraph(ihits,gas,resphi);
100  gerad->SetMarkerStyle(22);
101  gerad->SetMarkerColor(kRed);
102  gerad->SetMarkerSize(1);
103  gerad->Draw("P");
104  //gerad->Fit(g,"R");
105 
106  //cout<<"Min phi = "<<calc_min(g->GetParameter(0),g->GetParameter(1))<<endl;
107 
108  TGraph *gerad1 = new TGraph(ihits,gas,resrad);
109  gerad1->SetMarkerStyle(23);
110  gerad1->SetMarkerColor(kGreen);
111  gerad1->SetMarkerSize(1);
112  gerad1->Draw("P");
113 
114  //g->SetLineColor(kGreen);
115  //gerad1->Fit(g,"R");
116 
117  //cout<<"Min rad = "<<calc_min(g->GetParameter(0),g->GetParameter(1))<<endl;
118 
119  leg = new TLegend(0.66,0.82,0.92,0.96);
120  leg->SetTextSize(0.05);
121  leg->AddEntry(gerad,"#sigma_{res,#phi}","P");
122  leg->AddEntry(gerad1,"#sigma_{res,r}","P");
123  //leg->AddEntry(gerad2,"scope","P");
124  //leg->AddEntry(gerad1,"52.25/47.75 halffield","P");
125  //leg->AddEntry(gerad2,"53/47 halffield","P");
126  //leg->AddEntry(steppurgegasno,"purge modus fieldoff 53%/47%","l");
127  leg->SetFillColor(0);
128  leg->Draw();
129 
130  c1->Update();
131 
132 }