StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
saveSignalCharAPV.C
1 
2 void saveSignalCharAPV(Char_t* signalFile="signalShapes.root")
3 {
4  TFile f(signalFile);
5  Char_t buffer[100];
6  Char_t quadName[10];
7  Char_t layerName[10];
8 
9  /*CANVAS LIST
10  c0-c1: numFSig
11  c2-c4: maxTb
12  c5-c6: maxAdc
13  c7-c9: firstHigh
14  */
15 
16  cout << "So many APV plots... please be patient." << endl;
17 
18  sprintf(buffer,"Canvas_mean&max_maxTb_APVbin");
19  TCanvas c2(buffer,buffer,10,10,1600,800);
20  c2.Divide(2,2);
21 
22  sprintf(buffer,"Canvas_mean&max_firsthigh_APVbin");
23  TCanvas c7(buffer,buffer,10,10,1600,800);
24  c7.Divide(2,2);
25 
26  const Int_t n = 240;
27  Double_t meanmaxTblayerP[n] = {0};
28  Double_t meanmaxTblayerR[n] = {0};
29  Double_t meanmaxTblayerRerr[n] = {0};
30  Double_t meanmaxTblayerPerr[n] = {0};
31  Double_t maxmaxTblayerP[n] = {0};
32  Double_t maxmaxTblayerR[n] = {0};
33  Double_t meanmaxfhlayerP[n] = {0};
34  Double_t meanmaxfhlayerR[n] = {0};
35  Double_t meanmaxfhlayerRerr[n] = {0};
36  Double_t meanmaxfhlayerPerr[n] = {0};
37  Double_t maxmaxfhlayerP[n] = {0};
38  Double_t maxmaxfhlayerR[n] = {0};
39  Double_t nbinAPV[n] = {0};
40  Double_t nbinAPVerr[n] = {0};
41 
42  for(Int_t ibin=0;ibin<n;ibin++)
43  {
44  nbinAPV[ibin]=(Double_t*)ibin;
45  }
46 
47  for(int iD=1;iD<7;iD++)
48  {
49  for(int iL=0;iL<2;iL++)
50  {
51  if(iL==0)
52  sprintf(layerName,"P");
53  else
54  sprintf(layerName,"R");
55 
56  sprintf(buffer,"Canvas0_Disc_%id_QuadAandB_Layer%s",iD,layerName);
57  TCanvas c0(buffer,buffer,10,10,3000,2000);
58  c0.Divide(5,4);
59 
60  sprintf(buffer,"Canvas3_Disc_%id_QuadAandB_Layer%s",iD,layerName);
61  TCanvas c3(buffer,buffer,10,10,3000,2000);
62  c3.Divide(5,4);
63 
64  sprintf(buffer,"Canvas5_Disc_%id_QuadAandB_Layer%s",iD,layerName);
65  TCanvas c5(buffer,buffer,10,10,3000,2000);
66  c5.Divide(5,4);
67 
68  sprintf(buffer,"Canvas8_Disc_%id_QuadAandB_Layer%s",iD,layerName);
69  TCanvas c8(buffer,buffer,10,10,3000,2000);
70  c8.Divide(5,4);
71 
72  for(int binAPVi=0;binAPVi<20;binAPVi++)
73  {
74  int truAPV = -1;
75  int iQ = -1;
76  if((binAPVi>= 0) && (binAPVi<= 9)){
77  iQ=0;
78  sprintf(quadName,"A");}
79  if((binAPVi>=10) && (binAPVi<=19)){
80  iQ=1;
81  sprintf(quadName,"B");}
82  if((iD-1==0) || ((iD-1)%2==1)){
83  if((binAPVi>= 0) && (binAPVi<= 4)) truAPV = binAPVi;
84  if((binAPVi>= 5) && (binAPVi<= 9)) truAPV = binAPVi+12;
85  if((binAPVi>=10) && (binAPVi<=14)) truAPV = binAPVi+2;
86  if((binAPVi>=15) && (binAPVi<=19)) truAPV = binAPVi-10;
87  }
88  else{
89  if((binAPVi>= 0) && (binAPVi<= 4)) truAPV = binAPVi+12;
90  if((binAPVi>= 5) && (binAPVi<= 9)) truAPV = binAPVi;
91  if((binAPVi>=10) && (binAPVi<=14)) truAPV = binAPVi-10;
92  if((binAPVi>=15) && (binAPVi<=19)) truAPV = binAPVi+2;
93  }
94 
95  //this is a brute-force way to map the truAPV to the rdo, arm, grp number, just for more labels
96  //it is ugly looking and not optimal but it works. (until the mapping changes..)
97  int rdo = -1;
98  int arm = -1;
99  int grp = -1;
100  if(truAPV>= 0 && truAPV<= 9) grp = 0;
101  if(truAPV>=12 && truAPV<=21) grp = 1;
102  if(iD==1){
103  arm = 0;
104  if(iQ==0) rdo = 1;
105  if(iQ==1){
106  if(truAPV > 10) rdo = 1;
107  if(truAPV < 10) rdo = 2;
108  }
109  if(iQ==3){
110  if(truAPV > 10) rdo = 2;
111  if(truAPV < 10) rdo = 1;
112  }
113  if(iQ==2) rdo = 2;
114  }
115  if(iD==2){
116  arm = 1;
117  if(truAPV>=5 && truAPV<=9) rdo = 2;
118  else rdo = 1;
119  }
120  if(iD==3){
121  if(truAPV>=12 && truAPV<=16) {
122  rdo = 2;
123  arm = 1;
124  }
125  else {
126  rdo = 1;
127  arm = 2;
128  }
129  }
130  if(iD==4){
131  if(truAPV>=5 && truAPV<=9){
132  rdo = 1;
133  arm = 3;
134  }
135  else{
136  rdo = 2;
137  arm = 2;
138  }
139  }
140  if(iD==5){
141  arm = 3;
142  if(truAPV>=12 && truAPV<=16) rdo = 1;
143  else rdo = 2;
144  }
145  if(iD==6){
146  arm = 4;
147  if(truAPV>=5 && truAPV<=9) rdo = 2;
148  else rdo = 1;
149  }
150 
151  c0.cd(binAPVi+1);
152  sprintf(buffer,"APVnumFSigCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
153  TH1D* h=(TH1D*)f.Get(buffer);
154  sprintf(buffer,"APVnumFSigCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
155  if(h!=0)
156  {
157  h->SetTitle(buffer);
158  h->SetName(buffer);
159  h->SetFillColor(1);
160  h->Draw();
161  }
162 
163  c3.cd(binAPVi+1);
164  sprintf(buffer,"APVmaxTbCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
165  //cout <<"loading " << buffer <<endl;
166  // TCanvas c2;
167  TH1D* h=(TH1D*)f.Get(buffer);
168  sprintf(buffer,"APVmaxTbCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
169  if(h!=0)
170  {
171  Double_t meanval = h->GetMean(1);
172  Double_t meanvalerr = h->GetRMS(1);
173  Double_t maxbinnum = h->GetMaximumBin();
174  //cout << "iD, quad, apv, maxbinnum: " << iD << ", " << quadName << ", " << truAPV << ", " << maxbinnum << endl;
175  if(iL==0){
176  meanmaxTblayerP[(iD-1)*40+binAPVi] = meanval;
177  meanmaxTblayerPerr[(iD-1)*40+binAPVi] = meanvalerr;
178  maxmaxTblayerP[(iD-1)*40+binAPVi] = maxbinnum-1;
179  }
180  if(iL==1){
181  meanmaxTblayerR[(iD-1)*40+binAPVi] = meanval;
182  meanmaxTblayerRerr[(iD-1)*40+binAPVi] = meanvalerr;
183  maxmaxTblayerR[(iD-1)*40+binAPVi] = maxbinnum-1;
184  }
185  h->SetTitle(buffer);
186  h->SetName(buffer);
187  h->SetFillColor(1);
188  h->Draw();
189  }
190  c5.cd(binAPVi+1);
191  sprintf(buffer,"APVmaxAdcCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
192  TH1D* h=(TH1D*)f.Get(buffer);
193  sprintf(buffer,"APVmaxAdcCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
194  if(h!=0)
195  {
196  h->SetTitle(buffer);
197  h->SetName(buffer);
198  h->SetFillColor(1);
199  h->Draw();
200  }
201 
202  c8.cd(binAPVi+1);
203  sprintf(buffer,"APVnumFirstHighCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
204  TH1D* h=(TH1D*)f.Get(buffer);
205  sprintf(buffer,"maxFirstHighCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
206  if(h!=0)
207  {
208  Double_t meanval = h->GetMean(1);
209  Double_t meanvalerr = h->GetRMS(1);
210  Double_t maxbinnum = h->GetMaximumBin();
211  if(iL==0){
212  meanmaxfhlayerP[(iD-1)*40+binAPVi] = meanval;
213  meanmaxfhlayerPerr[(iD-1)*40+binAPVi] = meanvalerr;
214  maxmaxfhlayerP[(iD-1)*40+binAPVi] = maxbinnum-1;
215  }
216  if(iL==1){
217  meanmaxfhlayerR[(iD-1)*40+binAPVi] = meanval;
218  meanmaxfhlayerRerr[(iD-1)*40+binAPVi] = meanvalerr;
219  maxmaxfhlayerR[(iD-1)*40+binAPVi] = maxbinnum-1;
220  }
221  h->SetTitle(buffer);
222  h->SetName(buffer);
223  h->SetFillColor(1);
224  h->Draw();
225  }
226 
227 
228  }
229  sprintf(buffer,"APVnumFSigCloseInfoForDisk%d_QuadAandB_layer%s.png",iD,layerName);
230  c0.SaveAs(buffer);
231 
232  sprintf(buffer,"APVmaxTbCloseInfoForDisk%d_QuadAandB_layer%s.png",iD,layerName);
233  c3.SaveAs(buffer);
234 
235  sprintf(buffer,"APVmaxAdcCloseInfoForDisk%d_QuadAandB_layer%s.png",iD,layerName);
236  c5.SaveAs(buffer);
237 
238  sprintf(buffer,"APVmaxFirstHighCloseInfoForDisk%d_QuadAandB_layer%s.png",iD,layerName);
239  c8.SaveAs(buffer);
240 
241  if(iD>1) continue;
242 
243  sprintf(buffer,"Canvas1_Disc_%id_QuadCandD_Layer%s",iD,layerName);
244  TCanvas c1(buffer,buffer,10,10,3000,2000);
245  c1.Divide(5,4);
246 
247  sprintf(buffer,"Canvas4_Disc_%id_QuadCandD_Layer%s",iD,layerName);
248  TCanvas c4(buffer,buffer,10,10,3000,2000);
249  c4.Divide(5,4);
250 
251  sprintf(buffer,"Canvas6_Disc_%id_QuadCandD_Layer%s",iD,layerName);
252  TCanvas c6(buffer,buffer,10,10,3000,2000);
253  c6.Divide(5,4);
254 
255  sprintf(buffer,"Canvas9_Disc_%id_QuadCandD_Layer%s",iD,layerName);
256  TCanvas c9(buffer,buffer,10,10,3000,2000);
257  c9.Divide(5,4);
258 
259 
260  for(int binAPVi=20;binAPVi<40;binAPVi++)
261  {
262  int truAPV = -1;
263  int iQ = -1;
264  if((binAPVi>=20) && (binAPVi<=29)){
265  iQ=2;
266  sprintf(quadName,"C");}
267  if((binAPVi>=30) && (binAPVi<=39)){
268  iQ=3;
269  sprintf(quadName,"D");}
270  if((iD>1) && (iQ>1)) continue;
271  if((iD-1==0) || ((iD-1)%2==1)){
272  if((binAPVi>=20) && (binAPVi<=24)) truAPV = binAPVi-20;
273  if((binAPVi>=25) && (binAPVi<=29)) truAPV = binAPVi-8;
274  if((binAPVi>=30) && (binAPVi<=34)) truAPV = binAPVi-18;
275  if((binAPVi>=35) && (binAPVi<=39)) truAPV = binAPVi-30;
276  }
277  else{
278  if((binAPVi>=20) && (binAPVi<=24)) truAPV = binAPVi-8;
279  if((binAPVi>=25) && (binAPVi<=29)) truAPV = binAPVi-20;
280  if((binAPVi>=30) && (binAPVi<=34)) truAPV = binAPVi-26;
281  if((binAPVi>=35) && (binAPVi<=39)) truAPV = binAPVi-18;
282  }
283  int rdo = -1;
284  int arm = -1;
285  int grp = -1;
286  if(truAPV>= 0 && truAPV<= 9) grp = 0;
287  if(truAPV>=12 && truAPV<=21) grp = 1;
288  if(iD==1){
289  arm = 0;
290  if(iQ==0) rdo = 1;
291  if(iQ==1){
292  if(truAPV > 10) rdo = 1;
293  if(truAPV < 10) rdo = 2;
294  }
295  if(iQ==3){
296  if(truAPV > 10) rdo = 2;
297  if(truAPV < 10) rdo = 1;
298  }
299  if(iQ==2) rdo = 2;
300  }
301  if(iD==2){
302  arm = 1;
303  if(truAPV>=5 && truAPV<=9) rdo = 2;
304  else rdo = 1;
305  }
306  if(iD==3){
307  if(truAPV>=12 && truAPV<=16) {
308  rdo = 2;
309  arm = 1;
310  }
311  else {
312  rdo = 1;
313  arm = 2;
314  }
315  }
316  if(iD==4){
317  if(truAPV>=5 && truAPV<=9){
318  rdo = 1;
319  arm = 3;
320  }
321  else{
322  rdo = 2;
323  arm = 2;
324  }
325  }
326  if(iD==5){
327  arm = 3;
328  if(truAPV>=12 && truAPV<=16) rdo = 1;
329  else rdo = 2;
330  }
331  if(iD==6){
332  arm = 4;
333  if(truAPV>=5 && truAPV<=9) rdo = 2;
334  else rdo = 1;
335  }
336 
337  c1.cd(binAPVi-19);
338  sprintf(buffer,"APVnumFSigCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
339 
340  TH1D* h=(TH1D*)f.Get(buffer);
341  sprintf(buffer,"APVnumFSigCloseCluster%s_d%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
342  if(h!=0)
343  {
344  h->SetTitle(buffer);
345  h->SetName(buffer);
346  h->SetFillColor(1);
347  h->Draw();
348  }
349 
350  c4.cd(binAPVi-19);
351  sprintf(buffer,"APVmaxTbCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
352 
353  TH1D* h=(TH1D*)f.Get(buffer);
354  sprintf(buffer,"APVmaxTbCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
355  if(h!=0)
356  {
357  Double_t meanval = h->GetMean(1);
358  Double_t meanvalerr = h->GetRMS(1);
359  if(iL==0){
360  meanmaxTblayerP[(iD-1)*40+binAPVi] = meanval;
361  meanmaxTblayerPerr[(iD-1)*40+binAPVi] = meanvalerr;
362  }
363  if(iL==1){
364  meanmaxTblayerR[(iD-1)*40+binAPVi] = meanval;
365  meanmaxTblayerRerr[(iD-1)*40+binAPVi] = meanvalerr;
366  }
367  h->SetTitle(buffer);
368  h->SetName(buffer);
369  h->SetFillColor(1);
370  h->Draw();
371  }
372 
373  c6.cd(binAPVi-19);
374  sprintf(buffer,"APVmaxAdcCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
375 
376  TH1D* h=(TH1D*)f.Get(buffer);
377  sprintf(buffer,"APVmaxAdcCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
378  if(h!=0)
379  {
380  h->SetTitle(buffer);
381  h->SetName(buffer);
382  h->SetFillColor(1);
383  h->Draw();
384  }
385 
386  c9.cd(binAPVi-19);
387  sprintf(buffer,"APVnumFirstHighCloseCluster%s_disc%d_quad%d_apvBIN%d",layerName,iD,iQ,binAPVi);
388 
389  TH1D* h=(TH1D*)f.Get(buffer);
390  sprintf(buffer,"maxFirstHighCloseCluster%sd%dq%s_rdo%darm%dgrp%dapv%d",layerName,iD,quadName,rdo,arm,grp,truAPV);
391  if(h!=0)
392  {
393  Double_t meanval = h->GetMean(1);
394  Double_t meanvalerr = h->GetRMS(1);
395  if(iL==0){
396  meanmaxfhlayerP[(iD-1)*40+binAPVi] = meanval;
397  meanmaxfhlayerPerr[(iD-1)*40+binAPVi] = meanvalerr;
398  }
399  if(iL==1){
400  meanmaxfhlayerR[(iD-1)*40+binAPVi] = meanval;
401  meanmaxfhlayerRerr[(iD-1)*40+binAPVi] = meanvalerr;
402  }
403  h->SetTitle(buffer);
404  h->SetName(buffer);
405  h->SetFillColor(1);
406  h->Draw();
407  }
408 
409 
410  }
411 
412  sprintf(buffer,"APVnumFSigCloseInfoForDisk%d_QuadCandD_layer%s.png",iD,layerName);
413  c1.SaveAs(buffer);
414 
415  sprintf(buffer,"APVmaxTbCloseInfoForDisk%d_QuadCandD_layer%s.png",iD,layerName);
416  c4.SaveAs(buffer);
417 
418  sprintf(buffer,"APVmaxAdcCloseInfoForDisk%d_QuadCandD_layer%s.png",iD,layerName);
419  c6.SaveAs(buffer);
420 
421  sprintf(buffer,"APVmaxFirstHighCloseInfoForDisk%d_QuadCandD_layer%s.png",iD,layerName);
422  c9.SaveAs(buffer);
423 
424  }
425  }
426  c2.cd(1);
427  TGraphErrors *gr1 = new TGraphErrors(n,nbinAPV,meanmaxTblayerP,nbinAPVerr,meanmaxTblayerPerr);
428  gr1->SetTitle("Layer P mean maxTb per APV");
429  gr1->SetMinimum(0);
430  gr1->SetMaximum(7);
431  gr1->SetMarkerColor(1);
432  gr1->SetMarkerSize(.4);
433  gr1->SetMarkerStyle(21);
434  gr1->Draw("AP");
435  c2.cd(2);
436  TGraphErrors *gr2 = new TGraphErrors(n,nbinAPV,meanmaxTblayerR,nbinAPVerr,meanmaxTblayerRerr);
437  gr2->SetTitle("Layer R mean maxTb per APV");
438  gr2->SetMinimum(0);
439  gr2->SetMaximum(7);
440  gr2->SetMarkerColor(1);
441  gr2->SetMarkerSize(.4);
442  gr2->SetMarkerStyle(21);
443  gr2->Draw("AP");
444  c2.cd(3);
445  TGraph *gr3 = new TGraph(n,nbinAPV,maxmaxTblayerP);
446  gr3->SetTitle("Layer P max maxTb per APV");
447  gr3->SetMinimum(0);
448  gr3->SetMaximum(7);
449  gr3->SetMarkerColor(1);
450  gr3->SetMarkerSize(.4);
451  gr3->SetMarkerStyle(21);
452  gr3->Draw("AP");
453  c2.cd(4);
454  TGraph *gr4 = new TGraph(n,nbinAPV,maxmaxTblayerR);
455  gr4->SetTitle("Layer R max maxTb per APV");
456  gr4->SetMinimum(0);
457  gr4->SetMaximum(7);
458  gr4->SetMarkerColor(1);
459  gr4->SetMarkerSize(.4);
460  gr4->SetMarkerStyle(21);
461  gr4->Draw("AP");
462  c2.Update();
463  c2.SaveAs("APVmeanmaxTb.png");
464 
465  c7.cd(1);
466  TGraphErrors *gr5 = new TGraphErrors(n,nbinAPV,meanmaxfhlayerP,nbinAPVerr,meanmaxfhlayerPerr);
467  gr5->SetTitle("Layer P mean maxFirstHigh per APV");
468  gr5->SetMinimum(0);
469  gr5->SetMaximum(7);
470  gr5->SetMarkerColor(1);
471  gr5->SetMarkerSize(.4);
472  gr5->SetMarkerStyle(21);
473  gr5->Draw("AP");
474  c7.cd(2);
475  TGraphErrors *gr6 = new TGraphErrors(n,nbinAPV,meanmaxfhlayerR,nbinAPVerr,meanmaxfhlayerRerr);
476  gr6->SetTitle("Layer R mean maxFirstHigh per APV");
477  gr6->SetMinimum(0);
478  gr6->SetMaximum(7);
479  gr6->SetMarkerColor(1);
480  gr6->SetMarkerSize(.4);
481  gr6->SetMarkerStyle(21);
482  gr6->Draw("AP");
483  c7.cd(3);
484  TGraph *gr7 = new TGraph(n,nbinAPV,maxmaxfhlayerP);
485  gr7->SetTitle("Layer P max maxFirstHigh per APV");
486  gr7->SetMinimum(0);
487  gr7->SetMaximum(7);
488  gr7->SetMarkerColor(1);
489  gr7->SetMarkerSize(.4);
490  gr7->SetMarkerStyle(21);
491  gr7->Draw("AP");
492  c7.cd(4);
493  TGraph *gr8 = new TGraph(n,nbinAPV,maxmaxfhlayerR);
494  gr8->SetTitle("Layer R max maxFirstHigh per APV");
495  gr8->SetMinimum(0);
496  gr8->SetMaximum(7);
497  gr8->SetMarkerColor(1);
498  gr8->SetMarkerSize(.4);
499  gr8->SetMarkerStyle(21);
500  gr8->Draw("AP");
501  c7.Update();
502  c7.SaveAs("APVmeanmaxFirstHigh.png");
503 
504 }