17{
18
19 gROOT->Reset();
20
21
22 TFile *
f1 =
new TFile(
"YYYY/m_root_dir/LumTau_XXXX.root");
24
26 {
27
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);
31 c1_1->Draw();
32 c1_1->cd();
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);
37 }
38
39
40 Bool_t topup = false, is_topup = false;
41 Int_t run = 0;
44
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);
57
59
60 Int_t runno = 0;
62 Int_t init_time = 1234567890;
63 Int_t n_first = 0;
64 do {
65 data->GetEntry(n_first);
66
67 n_first += 1;
69 runno = run;
71 cout << "E_cms = " << E_cms << endl;
72 is_topup = topup;
74
75 Int_t tot_time =
data->GetMaximum(
"etsT1");
77 if ( tot_time > 0 )
78 {
80 } else {
82
83
84 do {
85 data->GetEntry(n_last);
86 n_last -= 1;
90 cout << "\n the time of the event is wrong!";
92 return;
93 }
95 }
96
97 Double_t dlt = 0.0,mean = 0.0,width = 0.0;
98 Double_t luminitial = 0.;
99 Double_t tau = 5000.;
100
102 {
103 cout << "\nThe runtime is abnormal!!!" << endl;
104 cout <<
"It's value is " <<
difft << endl;
105 cout << "Please check it carefully!" << endl;
106 return;
107 }
108
110 cout << "\nRuntime less than 300 " << endl;
111 cout << "Using default tau value " << tau << endl;
112 }
113 else if (is_topup) {
114 cout << "\n topup mode." << endl;
115 luminitial = 2000;
116 tau = 99999999;
117 }
118 else
119 {
120
121 TH1F *dltphi1 = new TH1F("dltphi1","dltphi",150,-30,30);
123 {
125 bool cut = (
e1/E_cms)>0.417&&(
e1/E_cms)<0.491&&(
e2/E_cms)>0.417&&(
e2/E_cms)<0.491
129 {
131 }
132 }
133
134
135 TF1* h1=new TF1("h1","gaus",-6,4);
136 dltphi1->Fit(h1,"R+");
137 dlt = h1->GetParameter(1);
138
139
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);
145
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;
148 else
149 {
150
152 for(Int_t i=0;i<11;i++)
153 {
155 }
156
157
158
160 for(Int_t i=0;i<10;i++)
161 {
162 hdltphi[i] =
new TH1D(
"",
"dltphi distribution",50,-50.,50.);
163 }
164 TH1 *
htime =
new TH1D(
"htime",
"time", 80, -10., 10.);
165
166 for(Int_t i=0;i<10;i++)
167 {
169 {
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;
175 {
177 }
178 }
179 }
180
181
184 for(Int_t i=0;i<10;i++)
185 {
189 }
190
191
192 TCanvas *c2 = new TCanvas("c2"," ",700,500);
193 c2->SetFillColor(kWhite);
194 c2->SetGrid();
195
196 Int_t imin;
197 for(Int_t i=0;
lum[i]<
lum[i+1];i++)
198 {
199 imin = i+1;
200 }
201 Double_t lummax =
lum[imin];
202 Double_t xmin =
x[imin];
203 Double_t lumsum;
204 for(Int_t i=imin;i<10;i++)
205 {
207 }
208 Double_t lumsum2 = lumsum*lumsum;
209
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");
224
225
226 luminitial =
g1->GetParameter(0);
227 tau =
g1->GetParameter(1);
228 }
229 }
230
231
232 if (!is_topup && tau>99999.)
233 {
234 cout << "\nThe result of fit is terrible. " << endl << endl;
235 cout << "set the tau value = 99999" << endl;
236 tau = 99999;
237 }
238
239
241 m_outputFile.open(
"YYYY/m_txt_dir/LumTau_XXXX.txt", ios_base::app);
244
246 {
247
248 TString result = Form("tau = %6.2f",tau);
249 TText* text01 = new TText(0.7,0.8,result);
250 text01->SetNDC();
251 text01->Draw("same");
252 c2->Update();
253 c2->GetFrame()->SetFillColor(kWhite);
254 c2->GetFrame()->SetBorderSize(1);
255 c2->Modified();
256 c2->Print("lum_0000XXXX.ps");
257 }
258
260 {
261
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;
268 }
269}
std::ofstream m_outputFile
EvtComplex exp(const EvtComplex &c)
Double_t BeamEnergyOnline(Int_t)