3 static int runnum, yearday, png, pdf;
5 static const int NCRATE=14;
6 static const char* CRATE[NCRATE]={
"L1",
"BC1",
"MXQ",
"MIX",
"BCW",
"BCE",
"FEQ",
7 "BBC",
"BBQ",
"FMS",
"QT1",
"QT2",
"QT3",
"QT4"};
8 static const int color[NCRATE]= {kGreen+2,kBlue,kRed,kBlue,kBlue,kBlue,kOrange-3,
9 kBlue,kRed,kBlue,kMagenta,kMagenta,kMagenta,kMagenta};
14 static float MAX=65536*3.0;
16 void makeqaplot(
int run=0,
float max=MAX,
int plt=0,
float min=0){
21 c1 =
new TCanvas(
"c1",
"RCC Counter",50,0,1200,900);
22 gStyle->SetPalette(1);
23 gStyle->SetStatW(0.4);
24 gStyle->SetStatH(0.3);
25 gStyle->SetTitleH(0.2);
28 if(run==0) {sprintf(fname,
"rccqa.root");}
29 else {sprintf(fname,
"%d/rccqa.%d.root",yearday,run);}
31 cout <<
"Opening "<<fname<<endl;
32 file=
new TFile(fname,
"old");
35 gStyle->SetOptStat(111110);
36 gStyle->SetOptTitle(1);
40 for(
int i=0; i<NCRATE; i++){
41 c1->cd(i+1)->SetLogy();
42 h=(TH1F*)file->Get(CRATE[i]);
43 mMean[i]=h->GetMean();
45 mMax[i]=h->GetXaxis()->GetBinCenter(h->FindLastBinAbove(0.0,1));
46 if(mMax[i]>=65536) {h->SetFillColor(kRed);}
47 else {h->SetFillColor(kBlue);}
50 h->GetXaxis()->SetRangeUser(0, max);
53 cout << Form(
"%3s Mean=%9.1f RMS=%9.1f MaxDiff=%9.1f",CRATE[i],mMean[i],mRms[i],mMax[i])<<endl;
57 sprintf(fname,
"%d.diff.png",runnum);
60 sprintf(fname,
"%d/%d.diff.png",yearday,runnum);
62 sprintf(fname,
"%d/%d.diff.zoom.png",yearday,runnum);
68 if(run==0) {sprintf(fname,
"rcc.txt");}
69 else {sprintf(fname,
"%d/rcc.%d.txt",yearday,run);}
70 printf(
"Writing %s\n",fname);
71 FILE* txfile = fopen(fname,
"w");
73 printf(
"Could not open file\n");
75 for(
int i=0; i<NCRATE; i++){
76 fprintf(txfile,
"%12.1f %12.1f %12.1f\n",
77 mMean[i],mRms[i],mMax[i]);
86 gStyle->SetTitleH(0.05);
87 gStyle->SetOptStat(0);
88 TTree* t=(TTree*)file->Get(
"RCC");
91 unsigned int DIFF[NCRATE];
92 t->SetBranchAddress(
"evt",&EVT);
93 t->SetBranchAddress(
"tcu",&TCU);
94 t->SetBranchAddress(
"diff",&DIFF);
95 int n = t->GetEntries();
96 unsigned long long one=1;
97 unsigned long long tmin=one<<32;
98 unsigned long long tmax=0;
99 unsigned long long dmin=one<<32;
100 unsigned long long dmax=0;
103 for(
int i=0; i<NCRATE; i++){
104 g[i] =
new TGraph(1);
105 g[i]->SetLineColor(color[i]);
107 printf(
"Found %d entries in Tree\n",n);
108 for(
int i=0; i<n; i++){
111 if(tmin>TCU) tmin=TCU;
112 if(tmax<TCU) tmax=TCU;
113 for(
int j=0; j<NCRATE; j++){
114 long long diff=DIFF[j];
116 if(diff>2147483647) diff=diff-4294967296;
118 if(j==6) printf(
"Crate=%2d TCU=%10d tmin=%10d DIFF=%10u diff=%10d diff2=%10d %f\n",
119 j,TCU,tmin,DIFF[j],diff,diff2,(
double)diff2);
121 g[j]->SetPoint(i,
double(TCU),
double(diff2));
122 if(dmin>diff) dmin=diff;
123 if(dmax<diff) dmax=diff;
127 printf(
"Tmin=%f Tmax=%f Dmin=%f Dmax=%f\n",tmin,tmax,dmin,max);
128 TH2F* frame=
new TH2F(
"diff",
"RCC-TCU [xing]",1,
129 float(tmin),
float(tmax),1,min,max);
131 for(
int i=0; i<NCRATE; i++){
134 TLine *l =
new TLine(tmin, 65536.0 , tmax, 65536.0);
137 tt=
new TText(0.7,0.03,
"TCU counter [xing]"); tt->SetNDC(); tt->SetTextSize(0.03); tt->Draw();
138 tt=
new TText(0.7,0.38,
"Memory Overwrite above"); tt->SetNDC(); tt->SetTextSize(0.02); tt->Draw();
139 float x=0.15, y=0.87, dy=0.025;
140 for(
int i=0; i<NCRATE; i++){
141 tt=
new TText(x,y,CRATE[i]); tt->SetNDC(); tt->SetTextSize(0.025); tt->SetTextColor(color[i]); tt->Draw();
145 sprintf(fname,
"%d.tdiff.png",runnum);
148 sprintf(fname,
"%d/%d.tdiff.png",yearday,runnum);
150 sprintf(fname,
"%d/%d.tdiff.%d.png",yearday,runnum,max);
156 if(plt==0 || plt==3){
158 gStyle->SetTitleH(0.05);
159 gStyle->SetOptStat(0);
160 TTree* t=(TTree*)file->Get(
"RCC");
163 sprintf(fname,
"%d.rate.png",runnum);
165 sprintf(fname,
"%d/%d.rate.png",yearday,runnum);