-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaaa1.c
87 lines (74 loc) · 2.05 KB
/
aaa1.c
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
void aaa1 ()
{
TF1 *fitFunc;
Int_t iter = 1;
TCanvas *c1 = new TCanvas("c1", "c1", 1);
FILE* in = fopen( "aaaaa.txt", "r" );
TH1F* hist = new TH1F("hist","hist",200,0.,1600.);
std::cout << "1File open... " << std::endl;
if (!in) {
std::cout << "[FAIL]\n" << std::endl;
return 0;
} else std::cout << "[OK]" << std::endl;
Char_t a = 0;
Int_t i = 0;
Int_t j = 0;
Bool_t flag = false;
Char_t buf[0xFF];
memset(buf, 0, 0xFF);
while( feof(in) == 0 ) {
// fscanf ( in, "%s", buf );
fgets( buf, 0xFF, in );
FILE* file = fopen( buf, "r" );
Char_t buffer[0xFF];
memset(buffer, 0, 0xFF);
for (i = 0; i < 0xFF; i++) {
if ( flag == true ) break;
buffer[i] = buf[i];
if ( ( buf[i] == 't' ) && ( buf[i-1] == 'x' ) ) flag = true;
}
flag = false;
printf("%s\n", buffer);
FILE* file = fopen( buffer, "r" );
std::cout << "2File open... " << std::endl;
if (!file) {
std::cout << "[FAIL]\n" << std::endl;
return 0;
} else std::cout << "[OK]" << std::endl;
Int_t b = 0;
Int_t c = 0;
Char_t buf1[0xFF];
memset(buf1, 0, 0xFF);
while( feof(file) == 0 ) {
fscanf ( file,"%d %d", &b, &c );
fgets( buf1, 0xFF, file );
if ( b == 4 ) hist->Fill( c );
b = c = 0;
}
hist->GetXaxis()->SetRangeUser(300, 1600);
fitFunc = new TF1("fitFunc", "gaus");
hist->Fit(fitFunc);
Float_t mean = fitFunc->GetParameter(1);
Float_t sigma = fitFunc->GetParameter(2);
//Double_t chi2 = 0;
//chi2 = fitFunc->GetChisquare() / fitFunc->GetNDF();
FILE *out = fopen("out.txt", "a+");
printf("3File open... ");
if (!out) {
printf("[FAIL]\n");
return 0;
} else printf("[OK]\n");
fprintf(out,"%E %d\n", mean, iter);
iter++;
fclose(out);
hist->Draw();
// c1->SaveAs("pic.jpg");
fclose(file);
printf("Final of iteration!!!!!\n");
// break;
}
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
fclose( in );
printf("General final!!!!!!!!!\n");
iter = 1;
}