00001
00002 reCalSmd() {
00003 float goalMipEne=1.3;
00004
00005
00006
00007 const int nSec=8; char *secL[nSec]={"03V","04U","06V","07U","09V","10U","12V","01U"}; TString tit="smd-Layer-3"; char *fncN="pol4";
00008
00009
00010
00011 TFile *fdA[nSec];
00012 TString iPath="/star/u/wissink/cal2006/";
00013
00014
00015 int j;
00016 for(j=0;j<nSec;j++) {
00017 TString fname=iPath+"smd"+secL[j]+".hist.root";
00018 fdA[j]=new TFile(fname);
00019 assert(fdA[j]->IsOpen());
00020 }
00021
00022
00023 fdG=new TFile("/star/u/wissink/cal2006/iter5-pp/R7089008.hist.root");
00024 assert(fdG->IsOpen());
00025
00026
00027
00028 h=new TH1F(tit,tit+" Average recon MIP energy from pair of strips; strip ID; MIP energy [MeV]",290,.5,290.5);
00029
00030 c=new TCanvas(tit,tit,600,400);
00031
00032 h->Draw();
00033 h->SetMinimum(0.7);
00034 h->SetMaximum(1.8);
00035 gStyle->SetOptFit(0);
00036 gStyle->SetOptStat(0);
00037
00038 lg=new TLegend(.2,.11,.35,.41);
00039
00040 TGraphErrors *grS=new TGraphErrors;
00041 grS->SetMarkerStyle(3);
00042
00043 for(j=0;j<nSec;j++) {
00044
00045 TString grN="mpvN"; grN+=secL[j];
00046 TGraphErrors *gr=(TGraphErrors *)fdA[j]->Get(grN);
00047 assert(gr);
00048 int n=gr->GetN();
00049 Double_t* eyA=gr->GetEY();
00050 Double_t* yA=gr->GetY();
00051 Double_t* xA=gr->GetX();
00052 int i;
00053 for(i=0;i<n;i++){
00054 if(fabs(yA[i]-1.3)>0.5) continue;
00055 if(fabs(eyA[i])>0.5) continue;
00056 int nS=grS->GetN();
00057 grS->SetPoint(nS,xA[i],yA[i]);
00058 grS->SetPointError(nS,0.,eyA[i]);
00059 }
00060
00061 gr->Draw("P");
00062 gr->SetMarkerStyle(24+j);
00063 lg->AddEntry(gr,secL[j],"lpe");
00064 }
00065
00066 lg->Draw();
00067
00068 c2=new TCanvas();
00069
00070 h->Draw();
00071 grS->Draw("P");
00072
00073 int col=kBlue;
00074
00075 grS->Fit(fncN);
00076 TF1* f=grS->GetFunction(fncN); assert(f);
00077 f->SetLineColor(col);
00078 f->SetLineWidth(2);
00079 f->SetRange(0.5,288.);
00080
00081 c->cd();
00082 f->Draw("same");
00083
00084
00085
00086 c3=new TCanvas();
00087 c3->Divide(3,3);
00088 for(j=0;j<nSec;j++) {
00089 TString gnN="ug"; gnN+=secL[j];
00090 TH1F * hg=( TH1F *)fdG->Get(gnN);
00091 assert(hg);
00092 c3->cd(j+1); hg->Draw();
00093 int i;
00094 int ns=hg->GetNbinsX();
00095
00096 TString ogN="gains"; ogN+=secL[j]; ogN+="smd.dat";
00097 FILE *fog=fopen(ogN.Data(),"w"); assert(fog);
00098 fprintf(fog,"# absolute gains for SMD plain %s,\n# stripName, gain[ch/GeV], erGain=dumm, correction, old gain\n",secL[j]);
00099
00100 for(i=1;i<=ns;i++) {
00101 if(i>288) break;
00102 float g1=hg->GetBinContent(i);
00103 float gc=goalMipEne/f->Eval(i);
00104 float g2=g1/gc;
00105
00106
00107 fprintf(fog,"%s%03d %8.1f 0.1 (corr= %.3f) old=%.1f \n",secL[j],i,g2,gc,g1);
00108 }
00109 fclose(fog);
00110 }
00111
00112
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 avr2() {
00125
00126
00127
00128 const int nSec=2; char *secL[nSec]={"01U","01V"}; int symA[nSec]={26,28}; TString tit="SMD-L3";
00129
00130 TFile *fdA[nSec];
00131 TString iPath="/star/u/wissink/cal2006/";
00132
00133
00134 int j;
00135 for(j=0;j<nSec;j++) {
00136 TString fname=iPath+"smd"+secL[j]+".hist.root";
00137 fdA[j]=new TFile(fname);
00138 assert(fdA[j]->IsOpen());
00139 }
00140
00141
00142
00143 h=new TH1F(tit,tit+" Average recon MIP energy from pair of strips; strip ID; MIP energy [MeV]",290,.5,290.5);
00144
00145 c=new TCanvas(tit,tit,600,400);
00146
00147
00148 h->Draw();
00149 h->SetMinimum(0.6);
00150 h->SetMaximum(1.6);
00151 gStyle->SetOptFit(0);
00152 gStyle->SetOptStat(0);
00153
00154 lg=new TLegend(.2,.15,.4,.45);
00155
00156 for(j=0;j<nSec;j++) {
00157 int col=kBlack+j+1;
00158 TString grN="mpvN"; grN+=secL[j];
00159 TGraphErrors *gr=(TGraphErrors *)fdA[j]->Get(grN);
00160 assert(gr);
00161 gr->Draw("P");
00162 gr->SetMarkerStyle(symA[j]);
00163 gr->SetLineColor(col);
00164 gr->SetMarkerColor(col);
00165
00166
00167 char *fncN="pol4";
00168 gr->Fit(fncN);
00169 TF1* f=gr->GetFunction(fncN); assert(f);
00170 f->SetLineColor(col);
00171 f->SetLineWidth(2);
00172
00173 lg->AddEntry(gr,secL[j],"lpe");
00174 }
00175
00176 lg->Draw();
00177
00178
00179
00180
00181 }