Class Reference for E1039 Core & Analysis Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
plot_matscan.C
Go to the documentation of this file.
1 float phimin = 10000;
2 float phimax = -10000;
3 float x0min = 100000;
4 float x0max = -100000;
5 float lamda0min = 100000;
6 float lamda0max = -100000;
7 
9  const char *datfile = "matscan.dat",
10  const double theta_req = -90,
11  TGraph* &gr,
12  TGraph* &grl
13  )
14 {
15  FILE *f = fopen(datfile,"r");
16  if (!f)
17  {
18  cout << "file " << datfile << " cannot be opened" << endl;
19  return;
20  }
21  float theta;
22  float phi;
23  float path;
24  float x0;
25  float lamda0;
26  vector<float> phivec;
27  vector<float> x0vec;
28  vector<float> lamda0vec;
29 
30  while(fscanf(f,"%f %f %f %f %f",&theta,&phi,&path,&x0,&lamda0) != EOF)
31  {
32  //cout << "theta: " << theta
33  // << ", phi: " << phi
34  // << ", path: " << path
35  // << ", x0: " << x0
36  // << ", lamda0: " << lamda0
37  // << endl;
38 
39  if(theta_req>0 && fabs(theta - theta_req)>0.0001) continue;
40 
41  if (phi > phimax)
42  {
43  phimax = phi;
44  }
45  if (phi < phimin)
46  {
47  phimin = phi;
48  }
49  if (x0 > x0max)
50  {
51  x0max = x0;
52  }
53  if (x0 < x0min)
54  {
55  x0min = x0;
56  }
57  if (lamda0 > lamda0max)
58  {
59  lamda0max = lamda0;
60  }
61  if (lamda0 < lamda0min)
62  {
63  lamda0min = lamda0;
64  }
65  phivec.push_back(phi);
66  x0vec.push_back(x0);
67  lamda0vec.push_back(lamda0);
68  }
69  float *phiarr = new float[phivec.size()];
70  float *x0arr = new float[x0vec.size()];
71  float *lamda0arr = new float[lamda0vec.size()];
72  for (int i=0; i<phivec.size(); i++)
73  {
74  phiarr[i] = phivec[i];
75  x0arr[i] = x0vec[i];
76  lamda0arr[i] = lamda0vec[i];
77  }
78 
79  //TCanvas *c = new TCanvas("c1","material scan");
80  //c->Divide(1,2);
81  //c->cd(1);
82  //TH2 *h2 = new TH2F("hx2","x0 vs phi",2,phimin-1,phimax+1,2,0,x0max+0.1*x0max);
83  //h2->SetStats(kFALSE);
84  //h2->Draw();
85  //TGraph *gr = new TGraph(phivec.size(),phiarr,x0arr);
86  //gr->SetMarkerStyle(21);
87  //gr->SetMarkerSize(0.1);
88  //gr->Draw("LP");
89  //c->cd(2);
90  //TH2 *hl2 = new TH2F("hlamda2","lamda0 vs phi",2,phimin-1,phimax+1,2,0,lamda0max+lamda0max/10.);
91  //hl2->SetStats(kFALSE);
92  //hl2->Draw();
93  //TGraph *grl = new TGraph(phivec.size(),phiarr,lamda0arr);
94  //grl->SetMarkerStyle(21);
95  //grl->SetMarkerSize(0.1);
96  //grl->Draw("LP");
97 
98  gr = new TGraph(phivec.size(),phiarr,x0arr);
99  gr->SetMarkerStyle(21);
100  gr->SetMarkerSize(0.1);
101  gr->SetLineWidth(2);
102 
103  grl = new TGraph(phivec.size(),phiarr,lamda0arr);
104  grl->SetMarkerStyle(21);
105  grl->SetMarkerSize(0.1);
106  grl->SetLineWidth(2);
107 
108  fclose(f);
109  return;
110 }
111 
113  const char* datfile = "matscan.dat"
114  ){
115 
116 #define ntheta 6
117  double thetas[ntheta] = {90, 80, 70, 60, 50, 40};
118  TGraph *gr[ntheta];
119  TGraph *grl[ntheta];
120 
121  for(int i=0;i<ntheta;i++)
122  {
123  plot_matscan_worker(datfile, thetas[i], gr[i], grl[i]);
124  }
125 
126  TCanvas *c = new TCanvas("c1","material scan");
127  c->Divide(1,2);
128  c->cd(1)->SetGrid();
129  TH2 *h2 = new TH2F("hx2","x0 vs phi",2,phimin-1,phimax+1,2,0,x0max+0.1*x0max);
130  h2->SetStats(kFALSE);
131  h2->Draw();
132  c->cd(2)->SetGrid();
133  TH2 *hl2 = new TH2F("hlamda2","lamda0 vs phi",2,phimin-1,phimax+1,2,0,lamda0max+lamda0max/10.);
134  hl2->SetStats(kFALSE);
135  hl2->Draw();
136 
137  for(int i=0;i<ntheta;i++)
138  {
139  c->cd(1);
140  gr[i]->SetLineColor(i+1);
141  gr[i]->Draw("LP");
142  c->cd(2);
143  grl[i]->SetLineColor(i+1);
144  grl[i]->Draw("LP");
145  }
146 
147 
148  return;
149 }
float phimax
Definition: plot_matscan.C:2
void plot_matscan(const char *datfile="matscan.dat")
Definition: plot_matscan.C:112
float lamda0min
Definition: plot_matscan.C:5
float x0max
Definition: plot_matscan.C:4
void plot_matscan_worker(const char *datfile="matscan.dat", const double theta_req=-90, TGraph *&gr, TGraph *&grl)
Definition: plot_matscan.C:8
#define ntheta
float x0min
Definition: plot_matscan.C:3
float phimin
Definition: matscan.C:8
float lamda0max
Definition: plot_matscan.C:6