1 static int startday=082;
4 static const int NRUN=10000;
8 static const int NCRATE=14;
9 static const char* CRATE[NCRATE]={
"L1",
"BC1",
"MXQ",
"MIX",
"BCW",
"BCE",
"FEQ",
10 "BBC",
"BBQ",
"FMS",
"QT1",
"QT2",
"QT3",
"QT4"};
11 static const int color[NCRATE]= {kGreen,kBlue,kRed,kBlue,kBlue,kBlue,kRed,
12 kBlue,kRed,kBlue,kRed,kRed,kRed,kRed};
14 static const int NVAL=3;
16 static Float_t frun[NRUN];
17 static Long64_t idx[NRUN];
18 static double val[NCRATE][NVAL][NRUN];
19 static TGraph* g[NCRATE][NVAL];
25 void read(
int irun,
int runnum){
27 int yearday=runnum/1000;
28 sprintf(file,
"www/%d/rcc.%d.txt",yearday,runnum);
29 FILE* f=fopen(file,
"r");
30 if(!f) { printf(
"Failed to open %s\n",file);
return; }
34 for(
int i=0; i<NCRATE; i++){
35 float rmean,rrms,rmax;
36 fscanf(f,
"%f %f %f",&rmean,&rrms,&rmax);
37 val[i][0][irun]=rmean;
40 g[i][0]->SetPoint(ngoodrun,
double(irun),val[i][0][irun]);
41 g[i][1]->SetPoint(ngoodrun,
double(irun),val[i][1][irun]);
42 g[i][2]->SetPoint(ngoodrun,
double(irun),val[i][2][irun]);
48 void readall(
int day){
55 if(yearday!=0) {startday=yearday; endday=yearday;}
56 for(
int d=startday; d<=endday; d++){
58 char dirname[100]; sprintf(dirname,
"www/%5d/",yday);
59 TSystemDirectory dir(dirname,dirname);
60 TList *files = dir.GetListOfFiles();
65 while ((file=(TSystemFile*)next())) {
66 fname = file->GetName();
67 if (!file->IsDirectory() && fname.BeginsWith(
"rcc") && fname.EndsWith(
".txt")) {
68 sscanf(fname.Data(),
"%4s%8f%4s",tmp,&r,tmp);
77 TMath::Sort((
long)i,frun,idx,0);
78 for(
int j=0; j<nrun; j++){
79 read(j,(
int)frun[idx[j]]);
83 void plot(
int val=1,
float xmin=0.0,
float xmax=0.0,
float ymin=0.0,
float ymax=500.0){
84 if(xmax==0) xmax=nrun;
85 TH2F *frame =
new TH2F(
"frame",
"",1,xmin,xmax,1,ymin,ymax); frame->Draw();
86 for(
int i=0; i<NCRATE; i++){
91 void history(
int day=15170,
int zoom=0,
92 float xmin=0.0,
float xmax=0.0,
93 float ymin=0.0,
float ymax=65536.0,
94 float ymin2=0.0,
float ymax2=65536.0/3.0,
95 float ymin3=0.0,
float ymax3=65536.0*3.0
102 for(
int i=0; i<NCRATE; i++){
103 for(
int v=0; v<NVAL; v++){
104 g[i][v]=
new TGraph(1);
105 g[i][v]->SetMarkerStyle(20);
106 g[i][v]->SetMarkerSize(1);
107 g[i][v]->SetLineColor(color[i]);
111 gStyle->SetOptStat(0);
113 c1 =
new TCanvas(
"c1",
"History",50,0,700,720);
115 c1->cd(1); plot(0,xmin,xmax,ymin,ymax);
116 t=
new TText(0.15,0.92,
"Mean(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
117 t=
new TText(0.75,0.8,
"DSM Crates"); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(kBlue); t->Draw();
118 t=
new TText(0.75,0.7,
"QT Crates"); t->SetNDC(); t->SetTextSize(0.07); t->SetTextColor(kRed); t->Draw();
119 c1->cd(2); plot(1,xmin,xmax,ymin2,ymax2);
120 t=
new TText(0.15,0.92,
"RMS(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
121 c1->cd(3); plot(2,xmin,xmax,ymin3,ymax3);
122 t=
new TText(0.15,0.92,
"MAX(RCC-TCU)[xing]"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
123 t=
new TText(0.77,0.01,
"RunIdx"); t->SetNDC(); t->SetTextSize(0.1); t->Draw();
124 TLine *l =
new TLine(0.0, 65536.0,nrun, 65536.0); l->Draw();
126 t=
new TText(0.15,0.45,
"Memory Overwrite above"); t->SetNDC(); t->SetTextSize(0.05); t->Draw();
131 if(zoom>0) {sprintf(file,
"%d/historyz.%5d.png",day,day);}
132 else {sprintf(file,
"%d/history.%5d.png",day,day);}
134 if(zoom>0) {sprintf(file,
"historyz.png",day);}
135 else {sprintf(file,
"history.png",day);}
138 printf(
"Create %s\n",file);