StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
plot.C
1 TCanvas *c1;
2 static TFile* file;
3 static int runnum, yearday, png, pdf;
4 
5 static const int NBS=68, NJP=6;
6 static const char* BSname[68]={
7  "ST_A","ST_B","ST_BC","ST_C","ST_CD","ST_D",
8  "SM_DD",
9  "SB_D","SB_CD","SB_C","SB_BC","SB_B","SB_A",
10  "NB_A","NB_B","NB_BC","NB_C","NB_CD","NB_D",
11  "NM_DD",
12  "NT_D","NT_CD","NT_C","NT_BC","NT_B","NT_A",
13  "ST_E","ST_EF","ST_F","ST_G","ST_GH","ST_H","ST_HI","ST_I","ST_IJ","ST_J",
14  "SM_JJ",
15  "SB_J","SB_IJ","SB_I","SB_HI","SB_H","SB_GH","SB_G","SB_F","SB_EF","SB_E",
16  "NB_E","NB_EF","NB_F","NB_G","NB_GH","NB_H","NB_HI","NB_I","NB_IJ","NB_J",
17  "NM_JJ",
18  "NT_J","NT_IJ","NT_I","NT_HI","NT_H","NT_GH","NT_G","NT_F","NT_EF","NT_E"};
19 static const char* JPname[6]={"STop","SMid","SBot","NBot","NMid","NTop"};
20 
21 void save(char* name){
22  char fname[100];
23  if(png){
24  if(yearday==0){
25  sprintf(fname,"%d_%s.png",runnum,name);
26  }else{
27  sprintf(fname,"%d/%d.%s.png",yearday,runnum,name);
28  }
29  c1->SaveAs(fname);
30  }
31 }
32 
33 void draw(TH1F* h[], int i, int offset){
34  int color;
35  if(offset<26) {h[i+offset]->GetXaxis()->SetRangeUser(0.0,1000.0);}
36  else {h[i+offset]->GetXaxis()->SetRangeUser(0.0,500.0);}
37  if(i<9 ) {color=i+1;}
38  else {color=i+2;}
39  h[i+offset]->SetLineColor(color);
40  h[i+offset]->SetLineWidth(2);
41  if(i==0) {h[i+offset]->Draw();}
42  else {h[i+offset]->Draw("same");}
43  TText *t=new TText(0.7,0.80-0.05*i,BSname[i+offset]); t->SetNDC(); t->SetTextSize(0.05); t->SetTextColor(color); t->Draw();
44 }
45 
46 void plot(int run=16064020, int plt=0, int log=1, int png=0){
47  runnum=run;
48  yearday=run/1000;
49 
50  c1 = new TCanvas("c1","FMSTRG",50,0,700,720);
51  //gStyle->SetLabelSize(0.1,"xy");
52  gStyle->SetPalette(1);
53  gStyle->SetStatW(0.4);
54  gStyle->SetOptStat(10);
55  gStyle->SetOptTitle(1);
56 
57  char fname[50];
58  if(run==0) {sprintf(fname,"bbcqa.root");}
59  else {sprintf(fname,"%d/fmstrg.%d.root",yearday,run);}
60  cout << "Opening "<<fname<<endl;
61  file=new TFile(fname,"old");
62 
63  if(plt==0 || plt==1) {
64  c1->Clear(); c1->Divide(1,3);
65  c1->cd(1); BS3->Draw();
66  c1->cd(2); BS2->Draw();
67  c1->cd(3); BS1->Draw();
68  if(png) save("bs");
69  }
70 
71  if(plt==0 || plt==2) {
72  c1->Clear(); c1->Divide(1,3);
73  c1->cd(1); JP2->Draw();
74  c1->cd(2); JP1->Draw();
75  c1->cd(3); JP0->Draw();
76  if(png) save("jp");
77  }
78 
79  TH1F *h[68];
80  for(int i=0; i<NBS; i++) h[i]=(TH1F*)file->Get(BSname[i]);
81 
82  if(plt==0 || plt==3) {
83  gStyle->SetOptTitle(0);
84  c1->Clear(); c1->Divide(2,2);
85  c1->cd(1)->SetLogy(log); for(int i=0; i<7; i++) draw(h,i,0);
86  c1->cd(3)->SetLogy(log); for(int i=0; i<6; i++) draw(h,i,7);
87  c1->cd(2)->SetLogy(log); for(int i=0; i<7; i++) draw(h,i,7+6);
88  c1->cd(4)->SetLogy(log); for(int i=0; i<6; i++) draw(h,i,7+6+7);
89  if(png) save("smbssum");
90  gStyle->SetOptTitle(1);
91  }
92 
93  if(plt==0 || plt==4) {
94  gStyle->SetOptTitle(0);
95  c1->Clear(); c1->Divide(2,2);
96  c1->cd(1)->SetLogy(log); for(int i=0; i<11; i++) draw(h,i,26);
97  c1->cd(3)->SetLogy(log); for(int i=0; i<10; i++) draw(h,i,26+11);
98  c1->cd(2)->SetLogy(log); for(int i=0; i<11; i++) draw(h,i,26+11+10);
99  c1->cd(4)->SetLogy(log); for(int i=0; i<10; i++) draw(h,i,26+11+10+11);
100  if(png) save("smbssum");
101  gStyle->SetOptTitle(1);
102  }
103 
104  if(plt==0 || plt==5) {
105  c1->Clear(); c1->Divide(2,3);
106  c1->cd(1)->SetLogy(log); STop->Draw();
107  c1->cd(2)->SetLogy(log); NTop->Draw();
108  c1->cd(3)->SetLogy(log); SMid->Draw();
109  c1->cd(4)->SetLogy(log); NMid->Draw();
110  c1->cd(5)->SetLogy(log); SBot->Draw();
111  c1->cd(6)->SetLogy(log); NBot->Draw();
112  if(png) save("jpsum");
113  }
114 
115 }