StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
laser_2d_pos.C
1 // $Id: laser_2d_pos.C,v 1.5 2010/04/27 20:48:29 jcs Exp $
2 //
3 // $Log: laser_2d_pos.C,v $
4 // Revision 1.5 2010/04/27 20:48:29 jcs
5 // Prithwish's changes to automatically name and save the 2d plots in both ps and png format
6 //
7 // Revision 1.4 2009/10/14 15:58:43 jcs
8 // change and add macros so that in addition to varying t0 and the gas compostion,
9 // the gas temperature can be varied
10 //
11 // Revision 1.3 2006/08/02 11:04:55 jcs
12 // measured laser position in histogram titles now depend on ftpc and lsec
13 //
14 // Revision 1.2 2006/03/15 15:14:06 jcs
15 // add lines for listing CVS update info
16 //
17 
18 //======================================================================
19 //
20 // laser_2d_pos reads the file produced in StFtpcLaserCalib::MakePs()
21 // and draws the reconstructed position histograms
22 //
23 // Inputs to macro:
24 // ftpc - 1 Ftpc West
25 // 2 Ftpc East
26 // lsec - laser sector
27 // a - select value(s) to be histogrammed
28 // a Laser I - straight track at lpos1
29 // b Laser II - straight track at lpos2
30 // c Laser III - straight track at lpos3
31 // d all 3 straight lasers
32 // opt - set Draw Options
33 // (see ftp://root.cern.ch/root/doc/chapter3.pdf, pages 5-6)
34 //
35 //======================================================================
36 
37 void laser_2d_pos(int ftpc, int lsec,TString a,char *opt)
38 {
39 
40 // FTPC WEST
41  if (ftpc == 1 ) {
42  if (lsec == 1) {
43  // Ftpc West lsec 1 (raft #4)
44  const Float_t lpos1=11.88;
45  const Float_t lpos2=19.55;
46  const Float_t lpos3=28.56;
47  TH2F *hr1 = new TH2F("hr1","Laser I(west,lsec 1): nominal (11.88cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
48  TH2F *hr2 = new TH2F("hr2","Laser II(west,lsec 1): nominal (19.55cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
49  TH2F *hr3 = new TH2F("hr3","Laser III(west,lsec 1): nominal (28.56cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
50  cout<<"Initialized for ftpc = "<<ftpc<<"(west) lsec = "<<lsec<<endl;
51  }
52  else if (lsec == 2) {
53  // Ftpc West lsec 2 (raft #8)
54  const Float_t lpos1=11.68;
55  const Float_t lpos2=19.45;
56  const Float_t lpos3=28.51;
57  TH2F *hr1 = new TH2F("hr1","Laser I(west,lsec 2): nominal (11.68cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
58  TH2F *hr2 = new TH2F("hr2","Laser II(west,lsec 2): nominal (19.45cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
59  TH2F *hr3 = new TH2F("hr3","Laser III(west,lsec 2): nominal (28.51cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
60  cout<<"Initialized for ftpc = "<<ftpc<<"(west) lsec = "<<lsec<<endl;
61  }
62  else if (lsec == 3) {
63  // Ftpc West lsec 3 (raft #11)
64  const Float_t lpos1=11.78;
65  const Float_t lpos2=19.35;
66  const Float_t lpos3=28.41;
67  TH2F *hr1 = new TH2F("hr1","Laser I(west,lsec 3): nominal (11.78cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
68  TH2F *hr2 = new TH2F("hr2","Laser II(west,lsec 3): nominal (19.35cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
69  TH2F *hr3 = new TH2F("hr3","Laser III(west,lsec 3): nominal (28.41cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
70  cout<<"Initialized for ftpc = "<<ftpc<<"(west) lsec = "<<lsec<<endl;
71  }
72  else {
73  cout<<"Invalid lsec for ftpc = "<<ftpc<<"(west) lsec = "<<lsec<<endl;
74  exit(1);
75  }
76  }
77 
78 // FTPC EAST
79  if (ftpc == 2 ) {
80  if (lsec == 1) {
81  // Ftpc East lsec 1 (raft #4)
82  const Float_t lpos1=11.75;
83  const Float_t lpos2=19.44;
84  const Float_t lpos3=28.41;
85  TH2F *hr1 = new TH2F("hr1","Laser I(east,lsec 1): nominal (11.75cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
86  TH2F *hr2 = new TH2F("hr2","Laser II(east,lsec 1): nominal (19.44cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
87  TH2F *hr3 = new TH2F("hr3","Laser III(east,lsec 1): nominal (28.41cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
88  cout<<"Initialized for ftpc = "<<ftpc<<"(east) lsec = "<<lsec<<endl;
89  }
90  else if (lsec == 2) {
91  // Ftpc East lsec 2 (raft #8)
92  const Float_t lpos1=11.85;
93  const Float_t lpos2=19.44;
94  const Float_t lpos3=28.41;
95  TH2F *hr1 = new TH2F("hr1","Laser I(east,lsec 2): nominal (11.85cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
96  TH2F *hr2 = new TH2F("hr2","Laser II(east,lsec 2): nominal (19.44cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
97  TH2F *hr3 = new TH2F("hr3","Laser III(east,lsec 2): nominal (28.41cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
98  cout<<"Initialized for ftpc = "<<ftpc<<"(east) lsec = "<<lsec<<endl;
99  }
100  else if (lsec == 3) {
101  // Ftpc East lsec 3 (raft #11)
102  const Float_t lpos1=11.86;
103  const Float_t lpos2=19.45;
104  const Float_t lpos3=28.31;
105  TH2F *hr1 = new TH2F("hr1","Laser I(east,lsec 3): nominal (11.86cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
106  TH2F *hr2 = new TH2F("hr2","Laser II(east,lsec 3): nominal (19.45cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
107  TH2F *hr3 = new TH2F("hr3","Laser III(east,lsec 3): nominal (28.31cm) - reconstructed position",12,-0.55,0.65,12,-0.45,0.75);
108  cout<<"Initialized for ftpc = "<<ftpc<<"(east) lsec = "<<lsec<<endl;
109  }
110  else {
111  cout<<"Invalid lsec for ftpc = "<<ftpc<<"(east) lsec = "<<lsec<<endl;
112  exit(2);
113  }
114  }
115 
116  TCanvas *c1 = new TCanvas("c1","ps",200,10,700,500);
117 
118  gStyle->SetPalette(1);
119  gStyle->SetOptStat(0);
120  gStyle->SetOptFit(0);
121 /*
122  gStyle->SetCanvasBorderMode(0);
123  gStyle->SetPadBorderMode(0);
124  gStyle->SetPadColor(0);
125  gStyle->SetCanvasColor(0);
126  gStyle->SetTitleColor(0);
127  gStyle->SetStatColor(0);
128 */
129 
130  TH2F *hr0 = new TH2F("hr","",12,-0.55,0.65,12,-0.45,0.75);
131  hr0->GetYaxis()->SetTitle("#Delta Ar [%]");
132  hr0->GetXaxis()->SetTitle("#Delta t_{0}");
133  hr1->GetYaxis()->SetTitle("#Delta Ar [%]");
134  hr1->GetXaxis()->SetTitle("#Delta t_{0}");
135  hr2->GetYaxis()->SetTitle("#Delta Ar [%]");
136  hr2->GetXaxis()->SetTitle("#Delta t_{0}");
137  hr3->GetYaxis()->SetTitle("#Delta Ar [%]");
138  hr3->GetXaxis()->SetTitle("#Delta t_{0}");
139  //
140 
141  FILE *file1=fopen ("res.log","r");
142 
143  Int_t datab1;
144 
145 
146 
147  float resx,resy,resrad,resphi, t0, gas, T, c2,rad1,rad11, rad2, rad21, rad3, rad31, err;
148 
149 
150  while(!feof(file1))
151  {
152  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resx,&c2);
153  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resy,&c2);
154  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resrad,&c2);
155  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&resphi,&c2);
156  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad1,&err);
157  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad11);
158  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad2,&err);
159  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad21);
160  datab1 = fscanf(file1,"%f %f %f %f %f",&t0,&gas,&T,&rad3,&err);
161  datab1 = fscanf(file1,"%f %f %f %f",&t0,&gas,&T,&rad31);
162  if (feof(file1)) break;
163 
164  if (a=='a')
165  {
166  hr0->Fill(t0,gas,lpos1-rad1);
167  }
168  else if (a=='b')
169  {
170  hr0->Fill(t0,gas,lpos2-rad2);
171  }
172  else if (a=='c')
173  {
174  hr0->Fill(t0,gas,lpos3-rad3);
175  }
176  else if (a=='d')
177  {
178  hr1->Fill(t0,gas,lpos1-rad1);
179  hr2->Fill(t0,gas,lpos2-rad2);
180  hr3->Fill(t0,gas,lpos3-rad3);
181  }
182  else
183  {cout<<"Function not available !"<<endl;break;}
184  }
185  if (a=='d')
186  {
187  c1->Divide(2,2);
188  c1->cd(1);
189  hr1->DrawCopy(opt);
190  c1->cd(2);
191  hr2->DrawCopy(opt);
192  c1->cd(3);
193  hr3->DrawCopy(opt);
194  }
195  else
196  hr0->DrawCopy(opt);
197 
198  //float minx,miny;
199  //cout<<hr1->GetMinimumBin()<<endl;;
200  //cout<<minx<<" "<<miny<<endl;
201  c1->Update();
202  if (fclose(file1) != 0)
203  cout<<"Error closing input file"<<endl;
204 
205  if(ftpc==1 && lsec==1)c1->SaveAs("w_lsec1_2d_Del_g-Del_t0.png");
206  if(ftpc==1 && lsec==1)c1->SaveAs("w_lsec1_2d_Del_g-Del_t0.ps");
207  if(ftpc==1 && lsec==2)c1->SaveAs("w_lsec2_2d_Del_g-Del_t0.png");
208  if(ftpc==1 && lsec==2)c1->SaveAs("w_lsec2_2d_Del_g-Del_t0.ps");
209  if(ftpc==1 && lsec==3)c1->SaveAs("w_lsec3_2d_Del_g-Del_t0.png");
210  if(ftpc==1 && lsec==3)c1->SaveAs("w_lsec3_2d_Del_g-Del_t0.ps");
211  if(ftpc==2 && lsec==1)c1->SaveAs("e_lsec1_2d_Del_g-Del_t0.png");
212  if(ftpc==2 && lsec==1)c1->SaveAs("e_lsec1_2d_Del_g-Del_t0.ps");
213  if(ftpc==2 && lsec==2)c1->SaveAs("e_lsec2_2d_Del_g-Del_t0.png");
214  if(ftpc==2 && lsec==2)c1->SaveAs("e_lsec2_2d_Del_g-Del_t0.ps");
215  if(ftpc==2 && lsec==3)c1->SaveAs("e_lsec3_2d_Del_g-Del_t0.png");
216  if(ftpc==2 && lsec==3)c1->SaveAs("e_lsec3_2d_Del_g-Del_t0.ps");
217 }