1 scanBXoff(
char* Rrun =
"R10103027") {
2 gStyle->SetPalette(1,0);
3 gStyle->SetOptStat(11);
5 char *tit[]={
"mubX7",
"bX48"};
11 TString fname=
"../dataB4.31/"; fname+=Rrun; fname+=
".wana.hist.root";
13 TFile *fd=
new TFile(fname);
16 printf(
"scanBXoff %s not exits \n",fname.Data());
24 TFile *fd2=
new TFile(
"../dataB4.31/R10103027.wana.hist.root");
26 hI =(TH1F*) fd->Get(
"mubX7v"); assert(hI);
29 TH1F *hI2=(TH1F*)hI->Clone();
32 hI2->SetFillColor(kYellow);
33 hI2->SetLineColor(kWhite);
35 TCanvas *c1=
new TCanvas(Rrun,Rrun,800,700);
44 TH1F *hc =
new TH1F(
"ch-"+tt,
"CHi2 dostribution vs. bXing offset for:"+tt,120,-0.5,119.5);
46 TH1F *hd=(TH1F*) fd->Get(tt);
49 printf(
"%s file exist but %s is missing\n",fname.Data(),tt.Data());
54 c1->cd(0*nd+k+1); hd->Draw();
57 hd->SetFillColor(kBlue);
60 myRms[k]=hd->GetRMS();
61 if(myRms[k]<10)
continue;
63 TH1F *hx=(TH1F*)hd->Clone();
66 int off= scanOff(hx, hI, hc);
68 printf(
"run=%s off=%d\n",Rrun,off);
69 c1->cd(1*nd+k+1); hc->Draw(); gPad->SetLogy();
70 hc->SetFillColor(kGreen);
73 TH1F *hg=(TH1F*)hd->Clone();
79 hg->SetFillColor(kBlue);
84 printf(
"#scanBXoff %s ",Rrun);
87 printf(
"%s: rms=%f off=%d ",tit[k], myRms[k], myOff[k]);
100 void shift(TH1F *hd,TH1F *hg,
int off) {
105 int j= 1+(i+120-off)%120;
106 hg->SetBinContent(i+1, hd->GetBinContent(j));
113 int scanOff(TH1F *hx, TH1F *hp, TH1F *hc) {
117 for(off=0;off<120;off++) {
118 float chi2= getChi2(hx,hp,off);
120 if(min>chi2) { min=chi2; k=off;}
124 if(min*3.>hc->Integral()/120.)
return -2;
134 float getChi2(TH1F *hx, TH1F *hp,
int off) {
135 int nb=hx->GetNbinsX();
138 float * x=hx->GetArray();
139 float * p=hp->GetArray();
144 int j= 1+(i+off)%120;
145 float xx= (x[j] -p[i+1])/hx->GetBinError(j);
154 void setNorm(TH1F *h){
155 int nb=h->GetNbinsX();
157 float * y=h->GetArray();
163 float fac=(50*1+10*0.01 )/sum;
165 for(i=1;i<=120;i++) {
169 float err=fac*sqrt(xx);
170 h->SetBinContent(i,val);
171 h->SetBinError(i,err);
180 void draw_raw2(TFile *dirL1=0){
182 assert(dirL1->IsOpen());
184 TCanvas *c1=
new TCanvas(
"raw1",
"My raw1",450,500);
187 char *tit[]={
"bX7",
"bX48"};
194 TH1F* h1=(TH1F*) dirL1->Get(tit[k]);
196 h1->SetLineColor(kBlue);