22 TFile*
f1 =
new TFile(
"YYYY/m_root_dir/LumTau_XXXX.root" );
24 f1->GetObject(
"event",
data );
29 TCanvas* myCanvas =
new TCanvas();
30 myCanvas->Divide( 1, 1 );
31 TPad* c1_1 =
new TPad(
"c1_1",
"c1_1", 0.01, 0.01, 0.99, 0.99 );
34 c1_1->Range( 0.425458, -114.842, 0.674993, 802.951 );
35 c1_1->SetBorderSize( 2 );
36 c1_1->SetBottomMargin( 0.125129 );
37 c1_1->SetFrameFillColor( 0 );
41 Bool_t topup =
false, is_topup =
false;
47 data->SetBranchAddress(
"topup", &topup );
48 data->SetBranchAddress(
"run", &run );
49 data->SetBranchAddress(
"time", &
time );
50 data->SetBranchAddress(
"etsT1", &etsT1 );
54 data->SetBranchAddress(
"e1", &
e1 );
55 data->SetBranchAddress(
"e2", &
e2 );
56 data->SetBranchAddress(
"etot", &
etot );
57 data->SetBranchAddress(
"phi1", &
phi1 );
58 data->SetBranchAddress(
"phi2", &
phi2 );
64 Int_t init_time = 1234567890;
67 data->GetEntry( n_first );
73 cout <<
"E_cms = " << E_cms << endl;
80 tot_time =
data->GetMaximum(
"etsT1" );
89 data->GetEntry( n_last );
95 cout <<
"\n the time of the event is wrong!";
102 Double_t dlt = 0.0, mean = 0.0, width = 0.0;
103 Double_t luminitial = 0.;
104 Double_t tau = 5000.;
109 cout <<
"\nThe runtime is abnormal!!!" << endl;
110 cout <<
"It's value is " <<
difft << endl;
111 cout <<
"Please check it carefully!" << endl;
116 TCanvas* c2 =
new TCanvas(
"c2",
" ", 700, 500 );
117 c2->SetFillColor( kWhite );
122 cout <<
"\nRuntime less than 300 " << endl;
123 cout <<
"Using default tau value " << tau << endl;
127 cout <<
"\n topup mode." << endl;
134 TH1F* dltphi1 =
new TH1F(
"dltphi1",
"dltphi", 150, -30, 30 );
135 for ( Int_t i = 0; i <
nentries; i++ )
138 bool cut = (
e1 / E_cms ) > 0.417 && (
e1 / E_cms ) < 0.55 && (
e2 / E_cms ) > 0.417 &&
145 TF1* h1 =
new TF1(
"h1",
"gaus", -6, 4 );
146 dltphi1->Fit( h1,
"R+" );
147 dlt = h1->GetParameter( 1 );
150 TF1* h2 =
new TF1(
"h2",
"gaus", 4, 30 );
151 dltphi1->Fit( h2,
"R+" );
152 mean = h2->GetParameter( 1 );
153 Double_t sigma = h2->GetParameter( 2 );
156 const Int_t nbin = 10;
157 if ( dlt < -6 || dlt > 4 || mean < 4 || mean > 30 || ( mean - dlt ) - 0.5 * width < 0 )
158 cout <<
"\nSomething wrong with cut Bhabha entries. " << endl;
162 Double_t
xtime[nbin + 1],
lum[nbin];
163 for ( Int_t i = 0; i < nbin + 1; i++ ) {
xtime[i] =
timemin + (
difft / 10. ) * i; }
167 for ( Int_t i = 0; i < nbin; i++ )
168 {
hdltphi[i] =
new TH1D(
"",
"dltphi distribution", 50, -50., 50. ); }
169 TH1D*
htime =
new TH1D(
"htime",
"time", 80, -10., 10. );
171 for ( Int_t i = 0; i < nbin; i++ )
173 for ( Int_t j = 0; j <
nentries; j++ )
176 bool lumcut = (
e1 / E_cms ) > 0.417 && (
e2 / E_cms ) > 0.417 &&
178 fabs(
dltphi - dlt ) > ( mean - dlt ) - width &&
179 fabs(
dltphi - dlt ) < ( mean - dlt ) + width &&
etot < E_cms + 0.5;
188 for ( Int_t i = 0; i < nbin; i++ )
196 for ( Int_t i = 0; i < nbin - 1 &&
lum[i] <
lum[i + 1]; i++ ) { imin = i + 1; }
197 Double_t lummax =
lum[imin];
198 Double_t xmin = x[imin];
200 for ( Int_t i = imin; i < nbin; i++ ) { lumsum +=
lum[i]; }
201 Double_t lumsum2 = lumsum * lumsum;
203 TF1*
g1 =
new TF1(
"g1",
"[0]*exp(-x/[1])", xmin, 10000. );
204 g1->SetParameters( lummax, 1.e+4 );
205 g1->SetLineColor( 2 );
206 TGraph*
gr =
new TGraph( nbin, x,
lum );
207 gr->SetLineColor( 2 );
208 gr->SetLineWidth( 2 );
209 gr->SetMarkerColor( 4 );
210 gr->SetMarkerStyle( 21 );
211 gr->SetTitle(
"BbLum" );
212 gr->GetXaxis()->SetTitle(
"Time" );
213 gr->GetYaxis()->SetTitle(
"Luminosity" );
214 gr->Fit(
"g1",
"R" );
218 luminitial =
g1->GetParameter( 0 );
219 tau =
g1->GetParameter( 1 );
223 if ( !is_topup && tau > 99999. )
225 cout <<
"\nThe result of fit is terrible. " << endl << endl;
226 cout <<
"set the tau value = 99999" << endl;
232 m_outputFile.open(
"YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app );
234 <<
" " << ( luminitial *
exp( -1.0 *
difft / ( tau ) ) )
235 <<
" " << tau << endl;
241 TString result = Form(
"tau = %6.2f", tau );
242 TText* text01 =
new TText( 0.7, 0.8, result );
244 text01->Draw(
"same" );
246 c2->GetFrame()->SetFillColor( kWhite );
247 c2->GetFrame()->SetBorderSize( 1 );
249 c2->Print(
"lum_0000XXXX.ps" );
255 cout <<
"E_cms = " << E_cms << endl;
256 cout <<
"\nruntime = " <<
difft << endl;
257 cout <<
"\ndlt = " << dlt << endl;
258 cout <<
"mean = " << mean << endl;
259 cout <<
"width = " << width << endl;
260 cout <<
"\ntau = " << tau << endl << endl;
268 TSQLServer* db = TSQLServer::Connect(
"mysql://bes3db2.ihep.ac.cn",
"guest",
"guestpass" );
273 const char* ins =
"select BER_PRB from run.RunParams where run_number = %d";
276 TSQLResult* res = db->Query( sql );
277 if ( res->GetRowCount() == 0 )
279 printf(
"Cannot find the beam energy of run %d from the database.\n", runno );
284 TSQLRow* row = res->Next();
285 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)