StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
time.C
1 static const int NCRATE=14;
2 static const char* CRATE[NCRATE]={"L1","BC1","MXQ","MIX","BCW","BCE","FEQ",
3  "BBC","BBQ","FMS","QT1","QT2","QT3","QT4"};
4 static const int color[NCRATE]= {kGreen,kBlue,kBlue,kBlue,kBlue,kBlue,kRed,
5  kBlue,kRed,kBlue,kOrange,kRed,kGreen,kYellow};
6 
7 static const int NEVT=10000;
8 static int tcu[NEVT];
9 static int diff[NCRATE][NEVT];
10 static TGraph* g[NCRATE];
11 
12 void read(int runnum){
13  char file[100];
14  //int yearday=runnum/1000;
15  //sprintf(file,"www/%d/rcc.%d.txt",yearday,runnum);
16  sprintf(file,"%d.txt",runnum);
17  FILE* f=fopen(file,"r");
18  if(!f) { printf("Failed to open %s\n",file); return; }
19  printf("Reading %s\n",file);
20  char tmp[200];
21  //fscanf(f,"%s\n",tmp);
22  //printf("%s",tmp);
23  for(int i=0; i<NEVT; i++){
24  //for(int i=0; i<10; i++){
25  float rmean,rrms,rmax;
26  fscanf(f,"%6s %d %d %d %d %d %d\n",
27  tmp, &tcu[i],
28  &diff[2][i],&diff[10][i],&diff[11][i],&diff[12][i],&diff[13][i]);
29  printf("%6s %d %d %d %d %d %d\n",
30  tmp, tcu[i],
31  diff[2][i],diff[10][i],diff[11][i],diff[12][i],diff[13][i]);
32  for(int j=0; j<NCRATE; j++){
33  g[j]->SetPoint(i,double(tcu[i]),double(diff[j][i]));
34  }
35  }
36  fclose(f);
37 }
38 
39 void plot(double xmin=0.0, double xmax=0.0, double ymin=0.0, double ymax=500.0){
40  TH2F *frame = new TH2F("frame","",1,xmin,xmax,1,ymin,ymax); frame->Draw();
41  for(int i=0; i<NCRATE; i++){
42  g[i]->Draw("L");
43  }
44 }
45 
46 void time(int run=17084043,
47  double xmin=71225190.0, double xmax=118061728.0,
48  double ymin=0.0, double ymax=65536.0*2.5){
49  for(int i=0; i<NCRATE; i++){
50  g[i]=new TGraph(1);
51  g[i]->SetMarkerStyle(20);
52  g[i]->SetMarkerSize(1);
53  g[i]->SetLineColor(color[i]);
54  }
55  gStyle->SetOptStat(0);
56  read(run);
57 
58  c1 = new TCanvas("c1",Form("%d",run),50,0,700,720);
59  plot(xmin,xmax,ymin,ymax);
60 
61  TLine *l = new TLine(xmin, 65536.0 , xmax, 65536.0); l->Draw();
62  TText *t;
63  t=new TText(0.7,0.03,"TCU counter[xing]"); t->SetNDC(); t->SetTextSize(0.03); t->Draw();
64  t=new TText(0.05,0.95,"RCC-TCU[xing]"); t->SetNDC(); t->SetTextSize(0.03); t->Draw();
65  t=new TText(0.5,0.4,"Memory Overwrite above"); t->SetNDC(); t->SetTextSize(0.03); t->Draw();
66  t=new TText(0.2,0.8,"MXQ"); t->SetNDC(); t->SetTextSize(0.03); t->SetTextColor(color[2]); t->Draw();
67  t=new TText(0.2,0.75,"QT1"); t->SetNDC(); t->SetTextSize(0.03); t->SetTextColor(color[10]); t->Draw();
68  t=new TText(0.2,0.70,"QT2"); t->SetNDC(); t->SetTextSize(0.03); t->SetTextColor(color[11]); t->Draw();
69  t=new TText(0.2,0.65,"QT3"); t->SetNDC(); t->SetTextSize(0.03); t->SetTextColor(color[12]); t->Draw();
70  t=new TText(0.2,0.60,"QT4"); t->SetNDC(); t->SetTextSize(0.03); t->SetTextColor(color[13]); t->Draw();
71 
72  /*
73 
74  TText *t;
75  c1 = new TCanvas("c1","History",50,0,700,720);
76  c1->Divide(1,3);
77  c1->cd(1); plot(0,xmin,xmax,ymin,ymax);
78  t=new TText(0.15,0.92,"Mean(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
79  t=new TText(0.75,0.8,"DSM Crates"); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(kBlue); t->Draw();
80  t=new TText(0.75,0.7,"QT Crates"); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(kRed); t->Draw();
81  c1->cd(2); plot(1,xmin,xmax,ymin2,ymax2);
82  t=new TText(0.15,0.92,"RMS(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
83  c1->cd(3); plot(2,xmin,xmax,ymin3,ymax3);
84  t=new TText(0.15,0.92,"MAX(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
85  t=new TText(0.77,0.01,"RunIdx"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
86  TLine *l = new TLine(0.0, 65536.0,nrun, 65536.0); l->Draw();
87  if(zoom==0){
88  t=new TText(0.15,0.45,"Memory Overwrite above"); t->SetNDC(); t->SetTextSize(0.05); t->Draw();
89  }
90  c1->Update();
91  char file[100];
92  if(day%1000!=0) {
93  if(zoom>0) {sprintf(file,"%d/historyz.%5d.png",day,day);}
94  else {sprintf(file,"%d/history.%5d.png",day,day);}
95  }else{
96  if(zoom>0) {sprintf(file,"historyz.png",day);}
97  else {sprintf(file,"history.png",day);}
98  }
99  */
100 
101  char file[100];
102  sprintf(file,"rcc_time_%d.png",run);
103  c1->SaveAs(file);
104  printf("Create %s\n",file);
105 }
106