-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
141 lines (110 loc) · 5.29 KB
/
main.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
#include "header.h"
auto c1 = new TCanvas("c1", "Histogram", 1280, 1080);
TH2* h1 = new TH2F("h1", "Histogram (W,Q^{2})_2d", 9600, 0.0, 40.0, 3200, 0.0, 40.0);
TH1F* h3 = new TH1F("h3", "Histogram W", 9600, 0.0, 40.0);
TH1F* h4 = new TH1F("h4", "Histogram Q^{2}", 3200, 0.0, 40.0);
TH2* h5 = new TH2F("h5", "Histogram (#phi,cos(#theta^{*}))", 180, 0, 2*M_PI, 100, -1 , 1);
int main(int argc, char* argv[])
{
auto start = std::chrono::high_resolution_clock::now();
auto finish_ = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_ = (finish_ - start);
int counter_(500), inter(1), counter_events(0), limit(0);
input_check(argc, argv);
if(seed_ == 0){seed_ = time(NULL);}
srand(seed_);
if(rad_corr){counter_ = 5; inter = 3;}
std::ofstream File;
std::string PATH;
int id_dot = path.find_last_of('.');
if(truncate_out)
{
for(int counter = 0; counter < ceil(double(N)/10000.0); counter++)
{
limit = (counter == ceil(double(N)/10000.0) - 1) ? N - counter*10000 : 10000;
for(int k = 0; k < limit; k += inter)
{
generate_particle(k);
}
PATH = path;
PATH.insert(id_dot,std::to_string(counter));
File.open(PATH,std::fstream::in | std::fstream::out | std::fstream::app);
for(auto i:LUND_OUTPUT)
{
for(auto j:i)
{
File << j << "\t";
}
File << std::endl;
}
finish_ = std::chrono::high_resolution_clock::now();
elapsed_ = double(ceil(double(N)/10000.0) - 1 - counter)*(finish_ - start)/double(counter);
std::cout << "Stand by ..." << ceil(counter*10000.0/(ceil(double(N)/10000.0) - 1))/100.0 << "% Time remaining: " << floor(elapsed_.count()/3600) << " h " << floor((elapsed_.count() - 3600*floor(elapsed_.count()/3600))/60) << " min " << elapsed_.count() - 60*floor(elapsed_.count()/60) << " s \r" << std::flush;
File.close(); LUND_OUTPUT.clear();
}
}else
{
for(int k = 0; k < N; k += inter)
{
generate_particle(k);
if(k % counter_ == 0)
{
finish_ = std::chrono::high_resolution_clock::now();
elapsed_ = double(N - k)*(finish_ - start)/double(k);
if(!method) std::cout << "Acceptance Rate: " << floor(10000*(double(Accepted_Number)/double(Total_Number)))/100 << "%\tStand by ..." << k*100/N << "% Time remaining: " << floor(elapsed_.count()/3600) << " h " << floor((elapsed_.count() - 3600*floor(elapsed_.count()/3600))/60) << " min " << elapsed_.count() - 60*floor(elapsed_.count()/60) << " s \r" << std::flush;
else std::cout << "Stand by ..." << k*100/N << "% Time remaining: " << floor(elapsed_.count()/3600) << " h " << floor((elapsed_.count() - 3600*floor(elapsed_.count()/3600))/60) << " min " << elapsed_.count() - 60*floor(elapsed_.count()/60) << " s \r" << std::flush;
}
}
File.open(path,std::fstream::in | std::fstream::out | std::fstream::app);
for(int i = 0; i < LUND_OUTPUT.size(); i++)
{
for(auto j:LUND_OUTPUT[i])
{
File << j << "\t";
}
File << std::endl;
if(i % counter_ == 0) std::cout << "Recording LUND ... " << ceil((i+1)*10000.0/LUND_OUTPUT.size())/100.0 << "% \r" << std::flush;
}
File.close();
}
std::cout << "Recording complete " << std::endl;
if(histogram)
{
c1 -> Divide(2 , 2);
h1->GetYaxis()->SetTitle("Q^{2}, GeV^{2}");
h1->GetYaxis()->SetTitleOffset(1.3);
h1->GetYaxis()->CenterTitle(true);
h1->GetXaxis()->SetTitle("W, GeV");
h1->GetXaxis()->CenterTitle(true);
c1->cd(1);
c1->cd(1)->SetLogz();
h1->SetAxisRange(W_min-0.1, W_max+0.1, "X");
h1->SetAxisRange(Q2_min-0.5, Q2_max+0.5, "Y");
h1->Draw("COL");
c1->cd(2);
c1->cd(2)->SetLogz();
h5->GetYaxis()->SetTitle("cos(#theta^{*})");
h5->GetYaxis()->SetTitleOffset(1.3);
h5->GetYaxis()->CenterTitle(true);
h5->GetXaxis()->SetTitle("#phi");
h5->GetXaxis()->CenterTitle(true);
h5->Draw("COL");
h3->GetXaxis()->SetTitle("W, GeV");
h3->GetXaxis()->CenterTitle(true);
c1->cd(3);
h3->SetAxisRange(W_min-0.1, W_max+0.1);
h3->Draw();
h4->GetXaxis()->SetTitle("Q^{2}, GeV^{2}");
h4->GetXaxis()->CenterTitle(true);
c1->cd(4);
h4->SetAxisRange(Q2_min-0.5, Q2_max+0.5);
c1->cd(4)->SetLogy();
h4->Draw();
c1 -> Print("Histogram.jpeg");
}
auto finish = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish - start;
std::cout << "Elapsed time: " << floor(elapsed.count()/3600) << " h " << floor((elapsed.count() - 3600*floor(elapsed.count()/3600))/60) << " min " << elapsed.count() - 60*floor(elapsed.count()/60) << " s\n";
data.clear(); data_interp.clear(); values_rad.clear(), LUND_OUTPUT.clear();
return 0;
}