This repository has been archived by the owner on Jan 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LayeredView.C
92 lines (81 loc) · 2.69 KB
/
LayeredView.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
88
89
90
91
92
#include <iostream>
#include <fstream>
#include <dirent.h>
#include <regex>
//namespace {
std::regex isLayered("\\b([0-9]+)layered.csv",std::regex::ECMAScript);
std::regex element("\\b([0-9]+),([0-9]+),([0-9]+)\\s*",std::regex::ECMAScript);
//}
constexpr int TOTAL_TICKTIME = 25;
constexpr int CRASHED_EPNS = 11;
struct TimeFrameLossTickTimeEPNRatio {
//std::vector< std::pair< std::vector<int> , std::vector<int>>> data;
int data[TOTAL_TICKTIME / 5][CRASHED_EPNS];
private:
void loadFile(const std::string& filename){
std::smatch res;
std::regex_search(filename,res,isLayered);
int ticktime = std::stoi(res[1]);
std::cout << "Ticktime " << ticktime << "\n";
std::fstream filereader(filename);
if(filereader.good()){
std::string line;
while(!filereader.eof()){
getline(filereader, line);
if(std::regex_search(line, res, element)) {
//std::cout << res[1] <<":" << res[2] << "\n";
data[(ticktime / 5) - 1][std::stoi(res[1])] = std::stoi(res[2]);
}
}
}
filereader.close();
}
public:
TimeFrameLossTickTimeEPNRatio(){
DIR *dir;
struct dirent *ent = nullptr;
if ((dir = opendir ("./")) != nullptr) {
while ((ent = readdir (dir)) != nullptr) {
if(std::regex_match(ent->d_name, isLayered)){
loadFile(ent->d_name);
//printf ("%s\n", ent->d_name);
}
}
}
}
};
void showTable(const TimeFrameLossTickTimeEPNRatio tf){
std::cout << "EPNs\t\t|";
for (int i = 0; i < CRASHED_EPNS; i++){
std::cout << i << " | ";
}
std::cout << "\n";
for(int i = 0; i < TOTAL_TICKTIME / 5; i++) {
std::cout << "ticktime\t| " << 5 + (i * 5) << " | ";
for (int j = 0; j < CRASHED_EPNS; j++){
std::cout << tf.data[i][j] << " | ";
}
std::cout << "\n";
}
}
TCanvas* Topology (){
TimeFrameLossTickTimeEPNRatio ratio;
showTable(ratio);
TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
Double_t x, y, z, P = 6.;
Int_t np = 200;
TGraph2D *dt = new TGraph2D();
dt->SetTitle("Graph TF loss EPN/Ticktime ratio; ticktime; amount crashed epns; TF loss");
Int_t index = 0;
for(int x = 0; x < TOTAL_TICKTIME / 5; x++) {
for (int y = 0; y < CRASHED_EPNS; y++){
dt->SetPoint(index, x,y,(1000 - ratio.data[x][y]));
index++;
}
}
gStyle->SetPalette(1);
dt->Draw("surf1");
//dt->SetMarkerStyle(20);
//dt->Draw("pcol");
return c;
}