1 scanBXoff(
char* Rrun =
"R6104032") {
2 gStyle->SetPalette(1,0);
3 gStyle->SetOptStat(11);
5 char *tit[]={
"bX7",
"bX48"};
11 TString fname=
"iter1/"; fname+=Rrun; fname+=
".hist.root";
13 TFile *fd=
new TFile(fname);
16 printf(
"scanBXoff %s not exits \n",fname.Data());
25 hI =(TH1F*) fd->Get(
"bXI"); assert(hI);
28 TH1F *hI2=(TH1F*)hI->Clone();
31 hI2->SetFillColor(kYellow);
32 hI2->SetLineColor(kWhite);
34 TCanvas *c1=
new TCanvas(Rrun,Rrun,800,700);
43 TH1F *hc =
new TH1F(
"ch-"+tt,
"CHi2 dostribution vs. bXing offset for:"+tt,120,-0.5,119.5);
45 TH1F *hd=(TH1F*) fd->Get(tt);
48 printf(
"%s file exist but %s is missing\n",fname.Data(),tt.Data());
53 c1->cd(0*nd+k+1); hd->Draw();
56 hd->SetFillColor(kBlue);
59 myRms[k]=hd->GetRMS();
60 if(myRms[k]<10)
continue;
62 TH1F *hx=(TH1F*)hd->Clone();
65 int off= scanOff(hx, hI, hc);
67 printf(
"run=%s off=%d\n",Rrun,off);
68 c1->cd(1*nd+k+1); hc->Draw(); gPad->SetLogy();
72 TH1F *hg=(TH1F*)hd->Clone();
78 hg->SetFillColor(kBlue);
83 printf(
"#scanBXoff %s ",Rrun);
86 printf(
"%s: rms=%f off=%d ",tit[k], myRms[k], myOff[k]);
99 void shift(TH1F *hd,TH1F *hg,
int off) {
104 int j= 1+(i+120-off)%120;
105 hg->SetBinContent(i+1, hd->GetBinContent(j));
112 int scanOff(TH1F *hx, TH1F *hp, TH1F *hc) {
116 for(off=0;off<120;off++) {
117 float chi2= getChi2(hx,hp,off);
119 if(min>chi2) { min=chi2; k=off;}
123 if(min*3.>hc->Integral()/120.)
return -2;
133 float getChi2(TH1F *hx, TH1F *hp,
int off) {
134 int nb=hx->GetNbinsX();
137 float * x=hx->GetArray();
138 float * p=hp->GetArray();
143 int j= 1+(i+off)%120;
144 float xx= (x[j] -p[i+1])/hx->GetBinError(j);
153 void setNorm(TH1F *h){
154 int nb=h->GetNbinsX();
156 float * y=h->GetArray();
162 float fac=(50*1+10*0.01 )/sum;
164 for(i=1;i<=120;i++) {
168 float err=fac*sqrt(xx);
169 h->SetBinContent(i,val);
170 h->SetBinError(i,err);
179 void draw_raw2(TFile *dirL1=0){
181 assert(dirL1->IsOpen());
183 TCanvas *c1=
new TCanvas(
"raw1",
"My raw1",450,500);
186 char *tit[]={
"bX7",
"bX48"};
193 TH1F* h1=(TH1F*) dirL1->Get(tit[k]);
195 h1->SetLineColor(kBlue);