-
Notifications
You must be signed in to change notification settings - Fork 0
/
code1.cpp
313 lines (300 loc) · 8.29 KB
/
code1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
void DRTileMPV(int a, float cc) {
TFile *file;
switch (a) {
case 22:
{
file = new TFile("dimple_scint3_box15_gap01_xz22mm_e200.root");
goto X;
}
case 24:
{
file = new TFile("dimple_scint3_box15_gap01_xz24mm_e200.root");
goto X;
}
case 26:
{
file = new TFile("dimple_scint3_box15_gap01_xz26mm_e200.root");
goto X;
}
case 28:
{
file = new TFile("dimple_scint3_box15_gap01_xz28mm_e200.root");
goto X;
}
case 210:
{
file = new TFile("dimple_scint3_box15_gap01_xz210mm_e200.root");
goto X;
}
case 212:
{
file = new TFile("dimple_scint3_box15_gap01_xz212mm_e200.root");
goto X;
}
case 214:
{
file = new TFile("dimple_scint3_box15_gap01_xz214mm_e200.root");
goto X;
}
case 42:
{
file = new TFile("dimple_scint3_box15_gap01_xz42mm_e200.root");
goto X;
}
case 44:
{
file = new TFile("dimple_scint3_box15_gap01_xz44mm_e200.root");
goto X;
}
case 46:
{
file = new TFile("dimple_scint3_box15_gap01_xz46mm_e200.root");
goto X;
}
case 48:
{
file = new TFile("dimple_scint3_box15_gap01_xz48mm_e200.root");
goto X;
}
case 410:
{
file = new TFile("dimple_scint3_box15_gap01_xz410mm_e200.root");
goto X;
}
case 412:
{
file = new TFile("dimple_scint3_box15_gap01_xz412mm_e200.root");
goto X;
}
case 414:
{
file = new TFile("dimple_scint3_box15_gap01_xz414mm_e200.root");
goto X;
}
case 62:
{
file = new TFile("dimple_scint3_box15_gap01_xz62mm_e200.root");
goto X;
}
case 64:
{
file = new TFile("dimple_scint3_box15_gap01_xz64mm_e200.root");
goto X;
}
case 66:
{
file = new TFile("dimple_scint3_box15_gap01_xz66mm_e200.root");
goto X;
}
case 68:
{
file = new TFile("dimple_scint3_box15_gap01_xz68mm_e200.root");
goto X;
}
case 610:
{
file = new TFile("dimple_scint3_box15_gap01_xz610mm_e200.root");
goto X;
}
case 612:
{
file = new TFile("dimple_scint3_box15_gap01_xz612mm_e200.root");
goto X;
}
case 614:
{
file = new TFile("dimple_scint3_box15_gap01_xz614mm_e200.root");
goto X;
}
case 82:
{
file = new TFile("dimple_scint3_box15_gap01_xz82mm_e200.root");
goto X;
}
case 84:
{
file = new TFile("dimple_scint3_box15_gap01_xz84mm_e200.root");
goto X;
}
case 86:
{
file = new TFile("dimple_scint3_box15_gap01_xz86mm_e200.root");
goto X;
}
case 88:
{
file = new TFile("dimple_scint3_box15_gap01_xz88mm_e200.root");
goto X;
}
case 810:
{
file = new TFile("dimple_scint3_box15_gap01_xz810mm_e200.root");
goto X;
}
case 812:
{
file = new TFile("dimple_scint3_box15_gap01_xz812mm_e200.root");
goto X;
}
case 814:
{
file = new TFile("dimple_scint3_box15_gap01_xz814mm_e200.root");
goto X;
}
case 102:
{
file = new TFile("dimple_scint3_box15_gap01_xz102mm_e200.root");
goto X;
}
case 104:
{
file = new TFile("dimple_scint3_box15_gap01_xz104mm_e200.root");
goto X;
}
case 106:
{
file = new TFile("dimple_scint3_box15_gap01_xz106mm_e200.root");
goto X;
}
case 108:
{
file = new TFile("dimple_scint3_box15_gap01_xz108mm_e200.root");
goto X;
}
case 1010:
{
file = new TFile("dimple_scint3_box15_gap01_xz1010mm_e200.root");
goto X;
}
case 1012:
{
file = new TFile("dimple_scint3_box15_gap01_xz1012mm_e200.root");
goto X;
}
case 1014:
{
file = new TFile("dimple_scint3_box15_gap01_xz1014mm_e200.root");
goto X;
}
case 122:
{
file = new TFile("dimple_scint3_box15_gap01_xz122mm_e200.root");
goto X;
}
case 124:
{
file = new TFile("dimple_scint3_box15_gap01_xz124mm_e200.root");
goto X;
}
case 126:
{
file = new TFile("dimple_scint3_box15_gap01_xz126mm_e200.root");
goto X;
}
case 128:
{
file = new TFile("dimple_scint3_box15_gap01_xz128mm_e200.root");
goto X;
}
case 1210:
{
file = new TFile("dimple_scint3_box15_gap01_xz1210mm_e200.root");
goto X;
}
case 1212:
{
file = new TFile("dimple_scint3_box15_gap01_xz1212mm_e200.root");
goto X;
}
case 1214:
{
file = new TFile("dimple_scint3_box15_gap01_xz1214mm_e200.root");
goto X;
}
case 142:
{
file = new TFile("dimple_scint3_box15_gap01_xz142mm_e200.root");
goto X;
}
case 144:
{
file = new TFile("dimple_scint3_box15_gap01_xz144mm_e200.root");
goto X;
}
case 146:
{
file = new TFile("dimple_scint3_box15_gap01_xz146mm_e200.root");
goto X;
}
case 148:
{
file = new TFile("dimple_scint3_box15_gap01_xz148mm_e200.root");
goto X;
}
case 1410:
{
file = new TFile("dimple_scint3_box15_gap01_xz1410mm_e200.root");
goto X;
}
case 1412:
{
file = new TFile("dimple_scint3_box15_gap01_xz1412mm_e200.root");
goto X;
}
case 1414:
{
file = new TFile("dimple_scint3_box15_gap01_xz1414mm_e200.root");
goto X;
}
default:
{
std::cout << "Error in \"a\" " << std::endl;
goto X;
}
}
X :
TH1F *hist;
TF1 *fitFunc1;
TF1 *fitFunc2;
TCanvas *c1 = new TCanvas("c1", "c1", 1);
printf("File open... ");
if (!file) {
printf("[FAIL]\n");
return 0;
} else printf("[OK]\n");
printf("Loading histogram... ");
hist = (TH1F *)file->Get("fCounterSipm");
if (!hist) {
printf("[FAIL]\n");
return 0;
} else printf("[OK]\n");
fitFunc1 = new TF1("fitFunc1", "gaus");
hist->GetYaxis()->SetTitle("Number of events");
hist->GetXaxis()->SetTitle("Number of photons");
hist->Fit(fitFunc1, "0");
float mean1 = fitFunc1->GetParameter(1);
float sigma1 = fitFunc1->GetParameter(2);
std::cout << "Mean1 : " << mean1 << std::endl;
std::cout << "Sigma1 : " << sigma1 << std::endl;
fitFunc2 = new TF1("fitFunc2", "gaus", mean1 - cc*sigma1, mean1 + cc*sigma1);
hist->Fit(fitFunc2, "R");
float mean2 = fitFunc2->GetParameter(1);
float sigma2 = fitFunc2->GetParameter(2);
std::cout << "Mean2 : " << mean2 << std::endl;
std::cout << "Sigma2 : " << sigma2 << std::endl;
int flag = 0;
double chi2 = 0;
chi2 = fitFunc2->GetChisquare() / fitFunc2->GetNDF();
if (chi2 > 5) flag = 1;
c1->SaveAs("pic.jpg");
// hist->Draw();
FILE *out = fopen("out.txt", "a+");
printf("File open... ");
if (!out) {
printf("[FAIL]\n");
return 0;
} else printf("[OK]\n");
fprintf(out,"%i %E %E %E %i\n", a, mean2, sigma2, chi2, flag);
// out << mean2 << " " << sigma2 << " " << chi2 << " " << flag << std::endl;
// fclose(out);
}