1 static const int mNPREPOST=2;
2 static const int mNQ=4;
3 static const int mNL=3;
4 static const int mNS=21;
5 static const int mNID=4*3*21;
8 TH1F* mXing[mNPREPOST*2+1];
14 static TString* FILENAME;
16 static float MIP[mNID];
17 static float SIG[mNID];
20 gStyle->SetOptStat(1110);
22 gStyle->SetStatW(0.2);
23 gStyle->SetStatH(0.3);
28 pad = c->cd(1);
if(LOG) pad->SetLogy();
29 mDataSize[0]->SetFillColor(kBlue); mDataSize[0]->Draw();
30 TText *t1=
new TText(0.15,0.80,
"log10(Total NData)"); t1->SetNDC(); t1->SetTextSize(0.05); t1->Draw();
32 pad = c->cd(2);
if(LOG) pad->SetLogy();
33 mDataSize[1]->SetFillColor(kBlue); mDataSize[1]->Draw();
34 TText *t2=
new TText(0.15,0.80,
"log10(Xing=0 NData)"); t2->SetNDC(); t2->SetTextSize(0.05); t2->Draw();
37 f.ReplaceAll(
".root",
".size.png");
42 gStyle->SetOptStat(1110);
44 gStyle->SetStatW(0.2);
45 gStyle->SetStatH(0.5);
47 c->Divide(1,mNPREPOST*2+1);
48 for(
int i=0; i<mNPREPOST*2+1; i++){
49 TVirtualPad *pad = c->cd(i+1); pad->SetLogy();
51 pad->SetTopMargin(mergin); pad->SetBottomMargin(mergin);
53 mXing[i]->SetFillColor(kBlue);
55 TText *t1=
new TText(0.4,0.80,Form(
"Xing=%d",x)); t1->SetNDC(); t1->SetTextSize(0.15); t1->Draw();
58 f.ReplaceAll(
".root",
".xing.png");
63 gStyle->SetOptStat(0);
68 pad = c->cd(1);
if(LOG) pad->SetLogz();
69 mAdc2[0]->Draw(
"colz");
70 pad = c->cd(2);
if(LOG) pad->SetLogz();
71 mAdc2[1]->Draw(
"colz");
73 TText *t1=
new TText(0.55,0.02,
"SlatId=(Q-1)*3*21+(L-1)*21+S"); t1->SetNDC(); t1->SetTextSize(0.05); t1->Draw();
74 f.ReplaceAll(
".root",
".2d.png");
78 void draw(
int quad=1,
int layer=1,
int widezoom=0,
int ped=0){
79 gStyle->SetOptStat(0);
81 printf(
"Plotting Quad=%d Layer=%d wide/zoom=%d\n",quad,layer,widezoom);
84 for(
int s=1; s<=21; s++){
85 if((quad==2 || quad==4) && s>19)
break;
86 TVirtualPad *pad = c->cd(s);
88 pad->SetRightMargin(mergin); pad->SetLeftMargin(mergin);
89 pad->SetTopMargin(mergin); pad->SetBottomMargin(0.01);
90 if(LOG) pad->SetLogy();
92 int id=(quad-1)*3*21 + (layer-1)*21 + s-1;
93 TH1F* h = mAdc[id][widezoom];
95 h->SetFillColor(kBlue);
96 h->SetNdivisions(205);
103 f=
new TF1(
"ga",
"gaus", 30, 200);
105 f->SetParameters(0,100);
106 f->SetParameters(1,100);
107 f->SetParameters(2,40);
109 f->SetParameters(0,100);
110 f->SetParameters(1,70);
111 f->SetParameters(2,3);
113 int res = h->Fit(
"ga",
"0RQ");
114 mip = f->GetParameter(1);
115 sig = f->GetParameter(2);
116 printf(
"MIP=%6.3f MIPSigma=%6.3f\n",mip,sig);
119 f->SetLineColor(kRed);
125 sprintf(tit,
"Q%1dL%1dC%02d",quad,layer,s);
126 TText *t1=
new TText(0.30,0.80,tit); t1->SetNDC(); t1->SetTextSize(0.15); t1->Draw();
128 float mean=h->GetMean();
129 float rms=h->GetRMS();
130 TText *t2=
new TText(0.30,0.65,Form(
"MEAN %4.1f RMS %4.2f",mean,rms)); t2->SetNDC(); t2->SetTextSize(0.15); t2->Draw();
132 TText *t3=
new TText(0.30,0.65,Form(
"MIP %4.1f +- %4.2f",mip,sig)); t3->SetNDC(); t3->SetTextSize(0.15); t3->Draw();
136 float min=h->GetXaxis()->GetXmin();
137 float max=h->GetXaxis()->GetXmax();
138 TText *t4=
new TText(0.005,0.85,Form(
"%3.0f",min)); t4->SetNDC(); t4->SetTextSize(0.03); t4->Draw();
139 TText *t5=
new TText(0.93,0.85,Form(
"%3.0f",max)); t5->SetNDC(); t5->SetTextSize(0.03); t5->Draw();
140 TString* name =
new TString(FILENAME->Data());
142 TString ff(*FILENAME);
143 ff.ReplaceAll(
".root",Form(
".Q%1dL%1d.png",quad,layer));
144 c->SaveAs(ff.Data());
147 void readfile(
int run){
149 char file[100],name[100];
150 sprintf(file,
"%d/%d.root",year,run);
151 printf(
"Opnening %s\n",file);
152 FILENAME =
new TString(file);
153 TFile* tfile=
new TFile(file,
"old");
154 mDataSize[0]=(TH1F*)tfile->Get(
"TotalSize");
155 mDataSize[1]=(TH1F*)tfile->Get(
"DataSize");
156 for(
int i=0; i<mNPREPOST*2+1; i++){
158 sprintf(name,
"Xing=%d",x);
159 mXing[i] = (TH1F*)tfile->Get(name);
161 mAdc2[0] = (TH2F*)tfile->Get(
"Adc2");
162 mAdc2[1] = (TH2F*)tfile->Get(
"Adc2z");
163 for(
int i=0; i<mNID; i++){
164 sprintf(name,
"ADC%03d",i);
165 mAdc[i][0]=(TH1F*)tfile->Get(name);
166 sprintf(name,
"ADC%03dz",i);
167 mAdc[i][1]=(TH1F*)tfile->Get(name);
172 c =
new TCanvas(
"FPS",
"FPS",15,15,700,800);
173 gStyle->SetLabelSize(0.1,
"xy");
174 gStyle->SetPalette(1);
175 gStyle->SetStatW(0.4);
179 TString f(*FILENAME);
180 f.ReplaceAll(
".root",
".mip.txt");
181 printf(
"Creating %s\n",f.Data());
182 FILE *FP = fopen(f.Data(),
"w");
183 if(FP==NULL){ printf(
"Cannot open file\n");
return; }
184 for(
int q=1; q<=4; q++){
185 for(
int l=1; l<=3; l++){
186 for(
int s=1; s<=21; s++){
187 int id=(q-1)*3*21 + (l-1)*21 + s;
188 fprintf(FP,
"%3d %1d %1d %2d %12.4f %12.4f %12.4f %12.4f\n",
189 id,q,l,s,MIP[
id],SIG[
id]);
196 void plot(
int run=16029002,
int ped=0,
int plt=0,
int quad=0,
int layer=0,
int widezoom=-1,
int log=1){
201 if(plt==1 || plt==0) plotSize();
202 if(plt==2 || plt==0) plotXing();
203 if(plt==3 || plt==0) plot2d();
204 if(plt==4 || plt==0){
205 for(
int q=1; q<=4; q++){
206 for(
int l=1; l<=3; l++){
207 if((quad==0 && layer==0) || (quad==q && layer==l)){
208 for(
int wz=0; wz<2; wz++){
209 if(widezoom==-1 || wz==widezoom){
216 if(quad==0 && layer==0) writetxt();