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