9 float x[]={.00, .10, .20, .35, .50, .75, 1.0,
10 .00,-.10,-.20,-.35,-.50,-.75,-1.0,.00,
13 float y[]={0,0,0,0,0,0,0,
15 .00, .10, .20, .35, .50, .75, 1.0,
16 .00,-.10,-.20,-.35,-.50,-.75,-1.0,.00};
17 int timediff[]={00,35,35,37,36,37,37,41,35,35,37,35,37,37,42,
18 31,35,36,36,35,37,38,41,35,35,35,36,37,37,42};
19 float Nblue=11349.49/107;
20 float Nyellow=10274.33/107;
30 float x[]={.00, .15, .30, .45, .60, .75, .90,
31 .00,-.15,-.30,-.45,-.60,-.75,-.90,.00,
34 float y[]={0,0,0,0,0,0,0,
36 .00, .15, .30, .45, .60, .75, .90,
37 .00,-.15,-.30,-.45,-.60,-.75,-.90,.00};
38 int timediff[]={00,36,37,36,36,36,36,41,36,36,36,36,36,36,41,
39 31,36,35,36,36,36,36,41,37,36,36,36,36,36,41};
40 float Nblue=10505.05/106;
41 float Nyellow=10039.98/106;
46 #endif // end of setup switch between runs
48 int integration_width=30;
49 float *x_longname ,*y_longname ;
52 float frequency=9.383/120.0;
54 Double_t gaus_stepping(Double_t *v, Double_t *par)
56 Double_t skfNN=par[0]/1e7*frequency*kbb;
65 Double_t background=par[3];
71 printf(
"Requested step out of bounds, for drawing. This shouldn't be possible.\n");
77 if (dx*dx>1.1 || dy*dy>1.1)
79 printf(
"v[0]=%f,step=%d ==> dx=%f, dy=%f\n",v[0],step,dx,dy);
80 printf(
"Array out of bounds. Checking arrays:\n");
82 printf(
"step=%d x=%1.2f y=%1.2f\n",i,x [i],y [i]);
86 if (dx*dx>(x[x_end]*x[x_end]*.95) || dy*dy>(x[x_end]*x[x_end]*.95))
87 return use_background*background*integration_width;
89 if ((sx2*sy2)<0.00000001)
91 printf(
"gaus_Step with: 0=%f,1=%f,2=%f\n",skfNN,sx2,sy2);
96 Double_t sL= skfNN/(2*TMath::Pi()*sqrt(sx2*sy2));
98 Double_t val=sL*exp(-dx*dx/(2*sx2))*exp(-dy*dy/(2*sy2));
105 return (val+background)*integration_width;
110 void janNicePlot(TH1F * hin){
125 sprintf(txt,
"BHT3 yield for R%d; vernier scan i-th step",runID);
127 hin->SetMaximum(yMax);
128 hin->SetMarkerStyle(8);
129 hin->SetMarkerColor(kBlue);
131 sprintf(txt,
"vernierR%dbht3_1gaus",runID);
132 c2=
new TCanvas(txt,txt,450,600);
135 TPad *cU,*cD; splitPadY(0.4,&cU,&cD);
139 gStyle->SetOptStat(0);
140 gStyle->SetOptFit(11111);
142 TF1 *ff=hin->GetFunction(
"steppy"); assert(ff);
143 float nb=hin->GetNbinsX();
145 TH1F *hdif=(TH1F*) hin->Clone();
147 sprintf(txt,
"yield residua; step index; data-fit");
150 float par0=ff->GetParameter(0);
151 float erPar0=ff->GetParError(0);
152 float relEr=erPar0/par0;
153 printf(
"par0=%f +/- %f , relEr=%f\n",par0,erPar0,relEr);
155 for(
int k=1;k<=nb;k++) {
156 float x=hin->GetBinCenter(k);
157 float y=hin->GetBinContent(k);
158 float ey=hin->GetBinError(k);
159 float fy=ff->Eval(x);
161 float totEr=sqrt(ey*ey+eFit*eFit);
163 hdif->SetBinContent(k,y-fy);
164 hdif->SetBinError(k,totEr);
168 hdif->SetMaximum(yMax/10.);
169 hdif->SetMinimum(-yMax/10.);
170 ln=
new TLine(0,0,30,0); ln->SetLineStyle(2);ln->Draw();ln->SetLineColor(kBlack);
175 void splitPadY(
float y, TPad **cU, TPad **cD) {
176 (*cU) =
new TPad(
"padD",
"apdD",0,y+0.005,1.0,1.);
178 (*cD) =
new TPad(
"padU",
"apdU",0.0,0.,1.,y);
189 void makeVernierScanFitFromHist(
char * infile=
"temp.hist.root")
191 if(jan==1) infile=
"10097097.bht3.hist.root";
192 if(jan==2) infile=
"10103044.bht3.hist.root";
194 TFile *f=
new TFile(infile);
195 TH1F* times=(TH1F*)(f->Get(
"time"));
202 timestamp[0]=timediff[0];
203 for (
int i=1;i<30;i++)
204 timestamp[i]=timediff[i]+timestamp[i-1];
208 TH1F *stamps=
new TH1F(
"timestamps",
"timestamps",max_time,0,max_time);
219 TH1F *hOffset=
new TH1F(
"offset",
"summed differential across big steps as a function of proposed offset;offset;dHz/dt",600,0,600);
220 for (
int i=4;i+timestamp[28]<max_time;i++)
223 temp_value-=times->GetBinContent(i+timestamp[6]-2);
224 temp_value-=times->GetBinContent(i+timestamp[6]-1);
225 temp_value+=times->GetBinContent(i+timestamp[6]+1);
226 temp_value+=times->GetBinContent(i+timestamp[6]+2);
228 temp_value-=times->GetBinContent(i+timestamp[13]-2);
229 temp_value-=times->GetBinContent(i+timestamp[13]-1);
230 temp_value+=times->GetBinContent(i+timestamp[13]+1);
231 temp_value+=times->GetBinContent(i+timestamp[13]+2);
233 temp_value-=times->GetBinContent(i+timestamp[21]-2);
234 temp_value-=times->GetBinContent(i+timestamp[21]-1);
235 temp_value+=times->GetBinContent(i+timestamp[21]+1);
236 temp_value+=times->GetBinContent(i+timestamp[21]+2);
238 temp_value-=times->GetBinContent(i+timestamp[28]-2);
239 temp_value-=times->GetBinContent(i+timestamp[28]-1);
240 temp_value+=times->GetBinContent(i+timestamp[28]+1);
241 temp_value+=times->GetBinContent(i+timestamp[28]+2);
242 hOffset->Fill(i,temp_value);
243 if (temp_value>best_value)
245 best_value=temp_value;
250 printf(
"Best offset is %d\n",best_offset);
259 end_offset=16-integration_width/2;
260 start_offset=end_offset+integration_width;
262 for (
int i=0;i<30;i++)
269 for (
int j=best_offset+timestamp[i]-start_offset;
270 j<(best_offset+timestamp[i]-end_offset);j++)
271 counts[i]+=times->GetBinContent(j);
274 TH1F *idealized=
new TH1F(
"idealized",
"counts vs step;step;counts",30,0,30);
278 for (
int i=0;i<30;i++)
281 idealized->Fill(i,counts[i]);
282 idealized->GetYaxis()->SetRangeUser(0,1600);
290 float err_counts[30];
291 for (
int i=0;i<30;i++)
292 err_counts[i]=sqrt(counts[i]);
295 for (
int i=0;i<30;i++)
313 TF1 *func=
new TF1(
"steppy",gaus_stepping,0.1,29.9,4);
314 func->SetParameters(2,0.25,0.25,.05);
316 func->SetParNames(
"sigma (nb)",
"#sigma_{X}^{2} (mm^{2})",
"#sigma_{Y}^{2^} (mm^{2})",
"background (Hz)");
318 func->SetParLimits(1,0.01,10);
319 func->SetParLimits(2,0.01,10);
323 idealized->Fit(
"steppy");
330 idealized->Draw(
"e");
333 janNicePlot(idealized);
338 Double_t b[]={4.997,.1733,-0.068,.1323,.1323};
339 TF1 *copyfunc=
new TF1(
"copy",gaus_stepping,0.1,29.9,4);
340 copyfunc->SetParameters(b);
341 copyfunc->Draw(
"SAME");
343 for (
int w=0;w<30;w+=1)
346 printf(
"bin=%f counts=%f, func=%f\n",w,gaus_stepping(a,b),func->Eval(w*1.0));