1 void resid(
int run=0,
int plt=1,
int quad=-1,
int png=0,
int ba=1,
int disc=0){
2 static const int kFgtNumDiscs=6;
3 static const int kFgtNumQuads=4;
4 static const int NAXIS=4;
6 TH1F *hist[kFgtNumDiscs][kFgtNumQuads][NAXIS];
7 TH2F *hist2[kFgtNumDiscs][kFgtNumQuads][NAXIS*2];
9 TCanvas *c1 =
new TCanvas(
"c1",
"trk",700,800);
10 gStyle->SetLabelSize(0.04,
"xy");
11 gStyle->SetPalette(1);
12 gStyle->SetStatW(0.4);
15 char fname[3][150]={
"alignment.root",
"alignment_before.root",
"alignment_after.root"};
17 sprintf(fname[0],
"%d/alignment_%d.root",yearday,run);
18 sprintf(fname[1],
"%d/alignment_before_%d.root",yearday,run);
19 sprintf(fname[2],
"%d/alignment_after_%d.root",yearday,run);
22 const char* caxis[NAXIS]={
"dx",
"dy",
"dr",
"dphi"};
23 const char* caxis2[NAXIS*2]={
"dx.vs.x",
"dx.vs.y",
"dy.vs.x",
"dy.vs.y",
24 "dr.vs.r",
"dr.vs.phi",
"dphi.vs.r",
"dphi.vs.phi"};
25 const float max[NAXIS]={0.1,0.1,0.1,0.02};
26 const char* cquad[kFgtNumQuads]={
"A",
"B",
"C",
"D"};
27 const int color[kFgtNumDiscs]={1,2,8,4,6,9};
29 cout <<
"Opening "<<fname[ba]<<endl;
30 TFile* file=
new TFile(fname[ba],
"");
32 for(
int idisc=0; idisc<kFgtNumDiscs; idisc++){
33 for(
int iquad=0; iquad<kFgtNumQuads; iquad++){
34 for(
int axis=0; axis<NAXIS; axis++){
36 sprintf(c,
"%1d%1s-%s",idisc+1,cquad[iquad],caxis[axis]);
37 hist[idisc][iquad][axis]=(TH1F*) file->Get(c);
39 for(
int axis=0; axis<NAXIS*2; axis++){
41 sprintf(c,
"%1d%1s-%s",idisc+1,cquad[iquad],caxis2[axis]);
42 hist2[idisc][iquad][axis]=(TH2F*) file->Get(c);
47 char cc[100], cpdf[100];
48 sprintf(cpdf,
"%d/resid1d.%d.pdf",yearday,run);
49 if(png==2) {sprintf(cc,
"%s[",cpdf); c1->Print(cc,
"pdf");}
51 int quad1=quad, quad2=quad;
52 if(quad==-1) {quad1=0; quad2=kFgtNumQuads-1;}
54 for(
int q=quad1; q<=quad2; q++){
58 for(
int axis=0; axis<NAXIS; axis++){
60 double xmin, xmax, ymax=0.0;
61 for(
int idisc=0; idisc<kFgtNumDiscs; idisc++){
63 TH1F *h=hist[idisc][q][axis];
64 if(!h || (disc>0 && disc!=idisc+1) )
continue;
65 xmin=h->GetXaxis()->GetXmin();
66 xmax=h->GetXaxis()->GetXmax();
67 double m=h->GetMaximum();
72 sprintf(c,
"frame%1s-%s",cquad[q],caxis[axis]);
73 TH2F *frame =
new TH2F(c,
"",1,xmin,xmax,1,0.0,ymax*1.2); frame->SetStats(0);
75 for(
int idisc=0; idisc<kFgtNumDiscs; idisc++){
76 TH1F *h=hist[idisc][q][axis];
77 if(!h || (disc>0 && disc!=idisc+1))
continue;
78 if(disc>0) h->SetStats(1111111);
79 h->SetLineColor(color[idisc]); h->Draw(
"SAME");
81 if(h->GetEntries()>10){
83 TF1 *g = h->GetFunction(
"gaus");
84 g->SetLineColor(color[idisc]); g->Draw(
"same");
88 if(axis==3) {sprintf(c,
"%1d%s sig=%6.4f",idisc+1,cquad[q],s);}
89 else {sprintf(c,
"%1d%s sig=%6.3f",idisc+1,cquad[q],s);}
91 if(disc>0 || (disc==0 && idisc<3)) { t1 =
new TText(xmin*0.9,ymax*(1.1-0.1*idisc),c); }
92 else { t1 =
new TText(xmax*0.2,ymax*(1.1-0.1*(idisc-3)),c); }
93 t1->SetTextSize(0.05); t1->SetTextColor(color[idisc]); t1->Draw();
95 TText *t2 =
new TText(xmax*0.9,-ymax*0.10,caxis[axis]);
96 t2->SetTextSize(0.05); t2->Draw();
101 sprintf(cpng,
"%d/resid1d,%d.%d.png",yearday,run,q);
103 }
else if(png==2) {c1->Print(cpdf,
"pdf");}
106 if(plt==2 || plt==0){
109 if(disc==0){ disc1=1; disc2=6; }
110 for(
int d=disc1; d<disc2; d++){
113 for(
int axis=0; axis<2*NAXIS; axis++){
115 TH2F *h2=hist2[d-1][q][axis];
122 sprintf(cpng,
"%d/resid2d.%d.d%d.q%d.png",yearday,run,d,q);
124 }
else if(png==2) {c1->Print(cpdf,
"pdf");}
128 if(png==2) {sprintf(cc,
"%s]",cpdf); c1->Print(cc,
"pdf");}