StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doBtow_ttime.C
1 ttime() {
2  TString path="/star/institutions/iucf/balewski/2008-L2-tmp/day333/";
3 
4  int runL[]={113,115,116,117,118,120,121,122,123,124,125};
5  TString jay[]={"01","02","03","04","05","06","07","08","09","10","11","12"};
6  TString kay[]={"a","b","c","d","e","f","g","h","i","j"};
7  TString ell[]={"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40"};
8  TString craten[]={"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","a","b","c","d","e","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e"};
9  TString crate1[]={"0","0","0","0","0","0","0","0","0","1","1","1","1","1","1","1","1","1","1","2","2","2","2","2","2","2","2","2","2","3"};
10  TString crate2[]={"1","2","3","4","5","6","7","8","9","0","1","2","3","4","5","6","7","8","9","0","1","2","3","4","5","6","7","8","9","0"};
11 
12 
13  c=new TCanvas();
14  c->Divide(6,5);
15 
16 
17 
18  Float_t es[11],ese[11];
19  Float_t ws[11],wse[11];
20  Float_t td[11];
21  Float_t csum[30][11];
22  Float_t mean;
23  Int_t iiii=0;
24  Int_t jc;
25  Float_t gg,sum;
26 
27  e1= new TF1("e1","expo",60,200);
28  w1= new TF1("w1","expo",60,200);
29 
30  TString htitle,title,crate,icrate;
31  int i,j,k,l,ic,icc,iccc;
32  for(i=0;i<11;i++) {
33  cout<<" i = "<<i<<endl;
34  TString fname=path+"run8333";
35  fname+=runL[i];
36  fname+=".l2ped.hist.root";
37  fd1=new TFile(fname); assert(fd1->IsOpen());
38 
39  if(i==0) east0 = new TH1D("east0","east0",500,0,500);
40  if(i==1) east1 = new TH1D("east1","east1",500,0,500);
41  if(i==2) east2 = new TH1D("east2","east2",500,0,500);
42  if(i==3) east3 = new TH1D("east3","east3",500,0,500);
43  if(i==4) east4 = new TH1D("east4","east4",500,0,500);
44  if(i==5) east5 = new TH1D("east5","east5",500,0,500);
45  if(i==6) east6 = new TH1D("east6","east6",500,0,500);
46  if(i==7) east7 = new TH1D("east7","east7",500,0,500);
47  if(i==8) east8 = new TH1D("east8","east8",500,0,500);
48  if(i==9) east9 = new TH1D("east9","east9",500,0,500);
49  if(i==10) east10 = new TH1D("east10","east10",500,0,500);
50 
51 
52  if(i==0) west0 = new TH1D("west0","west0",500,0,500);
53  if(i==1) west1 = new TH1D("west1","west1",500,0,500);
54  if(i==2) west2 = new TH1D("west2","west2",500,0,500);
55  if(i==3) west3 = new TH1D("west3","west3",500,0,500);
56  if(i==4) west4 = new TH1D("west4","west4",500,0,500);
57  if(i==5) west5 = new TH1D("west5","west5",500,0,500);
58  if(i==6) west6 = new TH1D("west6","west6",500,0,500);
59  if(i==7) west7 = new TH1D("west7","west7",500,0,500);
60  if(i==8) west8 = new TH1D("west8","west8",500,0,500);
61  if(i==9) west9 = new TH1D("west9","west9",500,0,500);
62  if(i==10) west10 = new TH1D("west10","west10",500,0,500);
63 
64 
65  for(j=0;j<12;j++){
66  for(k=0;k<10;k++){
67  for(l=0;l<40;l++){
68  // if(l!=11&&l!=12&&l!=27&&l!=28)continue;
69  htitle="a"+jay[j]+"t"+kay[k]+ell[l];
70  h1=(TH1F*)fd1->Get(htitle); assert(h1);
71  title= h1->GetTitle();
72  crate =title[19]+title[20];
73  for(icc=0;icc<30;icc++){
74 
75  if(crate1[icc] == title[19] && crate2[icc] == title[20]){
76  iccc=icc;
77  iiii+=1;
78  h1->SetAxisRange(10.,1000.);
79  mean = h1->GetMean();
80  sum = h1->Integral();
81  if(mean<15)continue;
82  if(mean>60)continue;
83  if(sum<100)continue;
84 
85  if(icc>14&&j==8)continue;
86 
87  h1->SetAxisRange(mean+50.,mean+100.);
88  sum=2400.*(h1->Integral())/sum;
89  if(sum>1.5)cout<<"crate = "<<icc<<"j k l"<<j<<" "<<k<<" "<<l<<endl;
90  if(sum>1.5)continue;
91 
92  h1->SetAxisRange(mean+60.,mean+300.);
93  sum=h1->Integral();
94  csum[iccc][i] += sum;
95 
96 
97  if(iccc<15 && i==0){
98  for(jc=0;jc<300;jc++){
99  gg =h1->GetBinContent(mean+jc+1);
100  east0->Fill(20+jc,gg);
101  }
102  }
103  if(iccc<15 && i==1){
104  for(jc=0;jc<300;jc++){
105  gg =h1->GetBinContent(mean+jc+1);
106  east1->Fill(20+jc,gg);
107  }
108  }
109  if(iccc<15 && i==2){
110  for(jc=0;jc<300;jc++){
111  gg =h1->GetBinContent(mean+jc+1);
112  east2->Fill(20+jc,gg);
113  }
114  }
115  if(iccc<15 && i==3){
116  for(jc=0;jc<300;jc++){
117  gg =h1->GetBinContent(mean+jc+1);
118  east3->Fill(20+jc,gg);
119  }
120  }
121  if(iccc<15 && i==4){
122  for(jc=0;jc<300;jc++){
123  gg =h1->GetBinContent(mean+jc+1);
124  east4->Fill(20+jc,gg);
125  }
126  }
127 
128  if(iccc<15 && i==5){
129  for(jc=0;jc<300;jc++){
130  gg =h1->GetBinContent(mean+jc+1);
131  east5->Fill(20+jc,gg);
132  }
133  }
134  if(iccc<15 && i==6){
135  for(jc=0;jc<300;jc++){
136  gg =h1->GetBinContent(mean+jc+1);
137  east6->Fill(20+jc,gg);
138  }
139  }
140  if(iccc<15 && i==7){
141  for(jc=0;jc<300;jc++){
142  gg =h1->GetBinContent(mean+jc+1);
143  east7->Fill(20+jc,gg);
144  }
145  }
146  if(iccc<15 && i==8){
147  for(jc=0;jc<300;jc++){
148  gg =h1->GetBinContent(mean+jc+1);
149  east8->Fill(20+jc,gg);
150  }
151  }
152  if(iccc<15 && i==9){
153  for(jc=0;jc<300;jc++){
154  gg =h1->GetBinContent(mean+jc+1);
155  east9->Fill(20+jc,gg);
156  }
157  }
158 
159  if(iccc<15 && i==10){
160  for(jc=0;jc<300;jc++){
161  gg =h1->GetBinContent(mean+jc+1);
162  east10->Fill(20+jc,gg);
163  }
164  }
165 
166  if(iccc>14 && i==0){
167  for(jc=0;jc<300;jc++){
168  gg =h1->GetBinContent(mean+jc+1);
169  west0->Fill(20+jc,gg);
170  }
171  }
172  if(iccc>14 && i==1){
173  for(jc=0;jc<300;jc++){
174  gg =h1->GetBinContent(mean+jc+1);
175  west1->Fill(20+jc,gg);
176  }
177  }
178  if(iccc>14 && i==2){
179  for(jc=0;jc<300;jc++){
180  gg =h1->GetBinContent(mean+jc+1);
181  west2->Fill(20+jc,gg);
182  }
183  }
184  if(iccc>14 && i==3){
185  for(jc=0;jc<300;jc++){
186  gg =h1->GetBinContent(mean+jc+1);
187  west3->Fill(20+jc,gg);
188  }
189  }
190  if(iccc>14 && i==4){
191  for(jc=0;jc<300;jc++){
192  gg =h1->GetBinContent(mean+jc+1);
193  west4->Fill(20+jc,gg);
194  }
195  }
196  if(iccc>14 && i==5){
197  for(jc=0;jc<300;jc++){
198  gg =h1->GetBinContent(mean+jc+1);
199  west5->Fill(20+jc,gg);
200  }
201  }
202 
203  if(iccc>14 && i==6){
204  for(jc=0;jc<300;jc++){
205  gg =h1->GetBinContent(mean+jc+1);
206  west6->Fill(20+jc,gg);
207  }
208  }
209  if(iccc>14 && i==7){
210  for(jc=0;jc<300;jc++){
211  gg =h1->GetBinContent(mean+jc+1);
212  west7->Fill(20+jc,gg);
213  }
214  }
215  if(iccc>14 && i==8){
216  for(jc=0;jc<300;jc++){
217  gg =h1->GetBinContent(mean+jc+1);
218  west8->Fill(20+jc,gg);
219  }
220  }
221  if(iccc>14 && i==9){
222  for(jc=0;jc<300;jc++){
223  gg =h1->GetBinContent(mean+jc+1);
224  west9->Fill(20+jc,gg);
225  }
226  }
227 
228  if(iccc>14 && i==10){
229  for(jc=0;jc<300;jc++){
230  gg =h1->GetBinContent(mean+jc+1);
231  west10->Fill(20+jc,gg);
232  }
233  }
234 
235 
236 
237 
238  }
239  }
240  }
241  }
242  }
243 
244 
245  if(i==0)east0->Fit("e1","RO");
246  if(i==1)east1->Fit("e1","RO");
247  if(i==2)east2->Fit("e1","RO");
248  if(i==3)east3->Fit("e1","RO");
249  if(i==4)east4->Fit("e1","RO");
250  if(i==5)east5->Fit("e1","RO");
251  if(i==6)east6->Fit("e1","RO");
252  if(i==7)east7->Fit("e1","RO");
253  if(i==8)east8->Fit("e1","RO");
254  if(i==9)east9->Fit("e1","RO");
255  if(i==10)east10->Fit("e1","RO");
256 
257  if(i==0)west0->Fit("w1","RO");
258  if(i==1)west1->Fit("w1","RO");
259  if(i==2)west2->Fit("w1","RO");
260  if(i==3)west3->Fit("w1","RO");
261  if(i==4)west4->Fit("w1","RO");
262  if(i==5)west5->Fit("w1","RO");
263  if(i==6)west6->Fit("w1","RO");
264  if(i==7)west7->Fit("w1","RO");
265  if(i==8)west8->Fit("w1","RO");
266  if(i==9)west9->Fit("w1","RO");
267  if(i==10)west10->Fit("w1","RO");
268 
269 
270  td[i]=12 + 5.*i;
271 
272  ese[i]=0.;
273 
274  es[i]=e1->GetParameter(1);
275  if(es[i]!=0.){
276  es[i]=-1./es[i];
277  ese[i]=es[i]**2*(e1->GetParError(1));
278  }
279  ese[i]=0.;
280 
281  ws[i]=w1->GetParameter(1);
282  if(ws[i]!=0.){
283  ws[i]=-1./ws[i];
284  wse[i]=ws[i]**2*(w1->GetParError(1));
285  }
286 
287  cout<<es[i]<<" "<<ws[i]<<endl;
288  }
289 
290 
291 
292  c1->SetLogy();
293 
294  Float_t wp[7],ep[7],xp[7];
295 
296  gStyle->SetOptStat(0);
297 
298  c2 = new TCanvas("c2","Gain vs Delay", 200, 10, 700, 500);
299  // TH2F *hr = new TH2F("hr","East Crates Gain vs Delay: Day 333",1,10,70,1,0,25);
300  // hr->SetYTitle("Gain");
301  // hr->SetXTitle("Delay (ns)");
302  // hr->Draw();
303 
304  graph1 = new TGraphErrors(11,td,es,0,ese);
305 
306  graph1->SetTitle("East Crates: Gain vs TCD Phase");
307  graph1->GetXaxis()->SetTitle("TCD Phase (ns)");
308  graph1->GetYaxis()->SetTitle("Average Gain");
309 
310  graph1->SetMarkerStyle(21);
311  graph1->SetMarkerSize(1.0);
312  graph1->SetMarkerColor(1);
313  graph1->Draw("AP");
314 
315  for(j=0;j<7;j++){
316  xp[j]=td[j+2];
317  wp[j]=es[j+2];
318  ep[j]=ese[j+2];
319  }
320 
321  graph1a = new TGraphErrors(6,xp,wp,0,ep);
322  graph1a->SetMarkerStyle(21);
323  graph1a->SetMarkerSize(1.0);
324  graph1a->SetMarkerColor(2);
325  graph1a->Draw("SP");
326 
327  graph1a->Fit("gaus");
328 
329  gStyle->SetOptStat(0);
330 
331 
332  c3 = new TCanvas("c3","Gain vs Delay", 200, 10, 700, 500);
333 
334 
335  graph2 = new TGraphErrors(11,td,ws,0,wse);
336 
337  graph2->SetTitle("West Crates: Gain vs TCD Phase");
338  graph2->GetXaxis()->SetTitle("TCD Phase (ns)");
339  graph2->GetYaxis()->SetTitle("Average Gain");
340 
341  graph2->SetMarkerStyle(21);
342  graph2->SetMarkerSize(1.0);
343  graph2->SetMarkerColor(1);
344  graph2->Draw("AP");
345 
346  for(j=0;j<7;j++){
347  xp[j]=td[j+2];
348  wp[j]=ws[j+2];
349  ep[j]=wse[j+2];
350  }
351 
352  graph2a = new TGraphErrors(6,xp,wp,0,ep);
353  graph2a->SetMarkerStyle(21);
354  graph2a->SetMarkerSize(1.0);
355  graph2a->SetMarkerColor(2);
356  graph2a->Draw("SP");
357 
358  graph2a->Fit("gaus");
359 
360  ofstream out;
361  out.open("timing.tex");
362 
363  Int_t is,iz,icc;
364  for(is=0;is<11;is++){
365  for(icc=0;icc<30;icc++){
366  iz=icc+1;
367  out<<is<<" "<<iz<<" "<<csum[icc][is]<<endl;
368  }
369  }
370 
371  ofstream out1;
372  out1.open("timing0.tex");
373 
374  Int_t i;
375  for(i=0;i<11;i++){
376  out1<<i<<" "<<es[i]<<" "<<ese[i]<<" "<<ws[i]<<" "<<wse[i]<<endl;
377  }
378 
379  cout<<"finished writing output"<<endl;
380 
381 }
382  // if(i>4) continue;
383  // c->cd(1+i); h1->Draw(); gPad->SetLogy(); h1->SetAxisRange(40.,100.);
384