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);
42 Double_t time = 0.0,dltphi = 0.0,costht1 = 0.0,costht2 = 0.0,e1 = 0.0,e2 = 0.0,etot = 0.0,phi1 = 0.0,phi2 = 0.0;
45 data->SetBranchAddress(
"topup", &topup);
46 data->SetBranchAddress(
"run",&run);
47 data->SetBranchAddress(
"time",&time);
48 data->SetBranchAddress(
"dltphi",&dltphi);
49 data->SetBranchAddress(
"costht1",&costht1);
50 data->SetBranchAddress(
"costht2",&costht2);
51 data->SetBranchAddress(
"e1",&e1);
52 data->SetBranchAddress(
"e2",&e2);
53 data->SetBranchAddress(
"etot",&etot);
54 data->SetBranchAddress(
"phi1",&phi1);
55 data->SetBranchAddress(
"phi2",&phi2);
60 cout <<
"E_cms = " << E_cms << endl;
62 nentries = (Int_t)data->GetEntries();
64 Double_t timemin = 0.0,timemax = 0.0;
67 data->GetEntry((nentries - 1));
69 Double_t difft = timemax-timemin;
71 Double_t dlt = 0.0,mean = 0.0,width = 0.0;
72 Double_t luminitial = 0.;
76 cout <<
"\nRuntime less than 300 " << endl;
84 TH1F *dltphi1 =
new TH1F(
"dltphi1",
"dltphi",150,-30,30);
85 for (Int_t i = 0;i<nentries;i++)
88 bool cut = (e1/E_cms)>0.417&&(e1/E_cms)<0.491&&(e2/E_cms)>0.417&&(e2/E_cms)<0.491
89 &&fabs(costht1)<0.8&&fabs(costht2)<0.8
93 dltphi1->Fill(dltphi);
98 TF1* h1=
new TF1(
"h1",
"gaus",-6,4);
99 dltphi1->Fit(h1,
"R+");
100 dlt = h1->GetParameter(1);
103 TF1* h2=
new TF1(
"h2",
"gaus",4,30);
104 dltphi1->Fit(h2,
"R+");
105 mean = h2->GetParameter(1);
106 Double_t
sigma = h2->GetParameter(2);
109 if (dlt<-6||dlt>4||mean<4||mean>30||(mean-dlt)-0.5*width<0)
110 cout <<
"\nSomething wrong with cut Bhabha entries. " << endl;
114 Double_t xtime[11],lum[10];
115 for(Int_t i=0;i<11;i++)
117 xtime[i]=timemin+(difft/10.)*i;
123 for(Int_t i=0;i<10;i++)
125 hdltphi[i] =
new TH1D(
"",
"dltphi distribution",50,-50.,50.);
127 TH1 *htime =
new TH1D(
"htime",
"time", 80, -10., 10.);
129 for(Int_t i=0;i<10;i++)
131 for(Int_t j=0;j<nentries;j++)
134 bool lumcut = (e1/E_cms)>0.417&&(e2/E_cms)>0.417&&fabs(costht1)<0.8&&
135 fabs(costht2)<0.8&&fabs(dltphi-dlt)>(mean-dlt)-width&&
136 fabs(dltphi-dlt)<(mean-dlt)+width&&etot<E_cms+0.5;
137 if(lumcut&&time>xtime[i]&&time<xtime[i+1])
139 hdltphi[i]->Fill(dltphi);
147 for(Int_t i=0;i<10;i++)
149 nevt[i] = hdltphi[i]->GetEntries();
150 x[i]=xtime[i+1]-xtime[0];
155 TCanvas *c2 =
new TCanvas(
"c2",
" ",700,500);
156 c2->SetFillColor(kWhite);
160 for(Int_t i=0;lum[i]<lum[i+1];i++)
164 Double_t lummax = lum[imin];
165 Double_t xmin =
x[imin];
167 for(Int_t i=imin;i<10;i++)
171 Double_t lumsum2 = lumsum*lumsum;
174 TF1 *g1 =
new TF1(
"g1",
"[0]*exp(-x/[1])",xmin,10000.);
175 g1->SetParameters(lummax,1e+4.);
177 TGraph* gr =
new TGraph(n,
x,lum);
180 gr->SetMarkerColor(4);
181 gr->SetMarkerStyle(21);
182 gr->SetTitle(
"BbLum");
183 gr->GetXaxis()->SetTitle(
"Time");
184 gr->GetYaxis()->SetTitle(
"Luminosity");
189 luminitial = g1->GetParameter(0);
190 tau = g1->GetParameter(1);
195 if (!topup && tau>99999.)
197 cout <<
"\nThe result of fit is terrible. " << endl << endl;
198 cout <<
"set the tau value = 99999" << endl;
204 cout <<
"\nThe runtime is minus." << endl << endl;
209 std::ofstream m_outputFile;
210 m_outputFile.open(
"YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app);
211 m_outputFile<< runno <<
" "<<difft<<
" "<<luminitial<<
" "<<(luminitial *
exp(- 1.0 * difft / (tau)))<<
" "<< tau <<endl;
212 m_outputFile.close();
217 TString result = Form(
"tau = %6.2f",tau);
218 TText* text01 =
new TText(0.7,0.8,result);
220 text01->Draw(
"same");
222 c2->GetFrame()->SetFillColor(kWhite);
223 c2->GetFrame()->SetBorderSize(1);
225 c2->Print(
"lum_0000XXXX.ps");
231 cout <<
"E_cms = " << E_cms << endl;
232 cout <<
"\nruntime = " << difft << endl;
233 cout <<
"\ndlt = " << dlt << endl;
234 cout <<
"mean = " << mean << endl;
235 cout <<
"width = " << width << endl;
236 cout <<
"\ntau = " << tau << endl << endl;
247 TSQLServer *db = TSQLServer::Connect(
"mysql://bes3db2.ihep.ac.cn",
"guest",
"guestpass");
252 const char *ins =
"select BER_PRB from run.RunParams where run_number = %d";
255 TSQLResult *res = db->Query(sql);
256 if (res->GetRowCount() == 0) {
257 printf(
"Cannot find the beam energy of run %d from the database.\n", runno);
262 TSQLRow *row = res->Next();
263 TString sbe = row->GetField(0);
EvtComplex exp(const EvtComplex &c)
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)
Double_t BeamEnergyOnline(Int_t)
void tau_mode(int flag=0)