22 TFile *
f1 =
new TFile(
"YYYY/m_root_dir/LumTau_XXXX.root");
28 TCanvas *myCanvas =
new TCanvas();
29 myCanvas->Divide(1,1);
30 TPad *c1_1 =
new TPad(
"c1_1",
"c1_1",0.01,0.01,0.99,0.99);
33 c1_1->Range(0.425458,-114.842,0.674993,802.951);
34 c1_1->SetBorderSize(2);
35 c1_1->SetBottomMargin(0.125129);
36 c1_1->SetFrameFillColor(0);
40 Bool_t topup =
false, is_topup =
false;
45 data->SetBranchAddress(
"topup", &topup);
46 data->SetBranchAddress(
"run",&run);
47 data->SetBranchAddress(
"time",&
time);
48 data->SetBranchAddress(
"etsT1",&etsT1);
52 data->SetBranchAddress(
"e1",&
e1);
53 data->SetBranchAddress(
"e2",&
e2);
54 data->SetBranchAddress(
"etot",&
etot);
55 data->SetBranchAddress(
"phi1",&
phi1);
56 data->SetBranchAddress(
"phi2",&
phi2);
62 Int_t init_time = 1234567890;
65 data->GetEntry(n_first);
71 cout <<
"E_cms = " << E_cms << endl;
75 Int_t tot_time =
data->GetMaximum(
"etsT1");
85 data->GetEntry(n_last);
90 cout <<
"\n the time of the event is wrong!";
97 Double_t dlt = 0.0,mean = 0.0,width = 0.0;
98 Double_t luminitial = 0.;
103 cout <<
"\nThe runtime is abnormal!!!" << endl;
104 cout <<
"It's value is " <<
difft << endl;
105 cout <<
"Please check it carefully!" << endl;
110 cout <<
"\nRuntime less than 300 " << endl;
111 cout <<
"Using default tau value " << tau << endl;
114 cout <<
"\n topup mode." << endl;
121 TH1F *dltphi1 =
new TH1F(
"dltphi1",
"dltphi",150,-30,30);
125 bool cut = (
e1/E_cms)>0.417&&(
e1/E_cms)<0.491&&(
e2/E_cms)>0.417&&(
e2/E_cms)<0.491
135 TF1* h1=
new TF1(
"h1",
"gaus",-6,4);
136 dltphi1->Fit(h1,
"R+");
137 dlt = h1->GetParameter(1);
140 TF1* h2=
new TF1(
"h2",
"gaus",4,30);
141 dltphi1->Fit(h2,
"R+");
142 mean = h2->GetParameter(1);
143 Double_t
sigma = h2->GetParameter(2);
146 if (dlt<-6||dlt>4||mean<4||mean>30||(mean-dlt)-0.5*width<0)
147 cout <<
"\nSomething wrong with cut Bhabha entries. " << endl;
152 for(Int_t i=0;i<11;i++)
160 for(Int_t i=0;i<10;i++)
162 hdltphi[i] =
new TH1D(
"",
"dltphi distribution",50,-50.,50.);
164 TH1 *
htime =
new TH1D(
"htime",
"time", 80, -10., 10.);
166 for(Int_t i=0;i<10;i++)
171 bool lumcut = (
e1/E_cms)>0.417&&(
e2/E_cms)>0.417&&fabs(
costht1)<0.8&&
173 fabs(
dltphi-dlt)<(mean-dlt)+width&&
etot<E_cms+0.5;
184 for(Int_t i=0;i<10;i++)
192 TCanvas *c2 =
new TCanvas(
"c2",
" ",700,500);
193 c2->SetFillColor(kWhite);
197 for(Int_t i=0;
lum[i]<
lum[i+1];i++)
201 Double_t lummax =
lum[imin];
202 Double_t xmin =
x[imin];
204 for(Int_t i=imin;i<10;i++)
208 Double_t lumsum2 = lumsum*lumsum;
211 TF1 *
g1 =
new TF1(
"g1",
"[0]*exp(-x/[1])",xmin,10000.);
212 g1->SetParameters(lummax,1e+4.);
214 TGraph*
gr =
new TGraph(
n,
x,
lum);
217 gr->SetMarkerColor(4);
218 gr->SetMarkerStyle(21);
219 gr->SetTitle(
"BbLum");
220 gr->GetXaxis()->SetTitle(
"Time");
221 gr->GetYaxis()->SetTitle(
"Luminosity");
226 luminitial =
g1->GetParameter(0);
227 tau =
g1->GetParameter(1);
232 if (!is_topup && tau>99999.)
234 cout <<
"\nThe result of fit is terrible. " << endl << endl;
235 cout <<
"set the tau value = 99999" << endl;
241 m_outputFile.open(
"YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app);
248 TString result = Form(
"tau = %6.2f",tau);
249 TText* text01 =
new TText(0.7,0.8,result);
251 text01->Draw(
"same");
253 c2->GetFrame()->SetFillColor(kWhite);
254 c2->GetFrame()->SetBorderSize(1);
256 c2->Print(
"lum_0000XXXX.ps");
262 cout <<
"E_cms = " << E_cms << endl;
263 cout <<
"\nruntime = " <<
difft << endl;
264 cout <<
"\ndlt = " << dlt << endl;
265 cout <<
"mean = " << mean << endl;
266 cout <<
"width = " << width << endl;
267 cout <<
"\ntau = " << tau << endl << endl;
278 TSQLServer *db = TSQLServer::Connect(
"mysql://bes3db2.ihep.ac.cn",
"guest",
"guestpass");
283 const char *ins =
"select BER_PRB from run.RunParams where run_number = %d";
286 TSQLResult *res = db->Query(sql);
287 if (res->GetRowCount() == 0) {
288 printf(
"Cannot find the beam energy of run %d from the database.\n", runno);
293 TSQLRow *row = res->Next();
294 TString sbe = row->GetField(0);
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)