-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataset.cpp
More file actions
124 lines (99 loc) · 3.69 KB
/
Copy pathdataset.cpp
File metadata and controls
124 lines (99 loc) · 3.69 KB
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
#include "dataset.h"
#include <fstream>
#include <sstream>
using namespace std;
DataSet::DataSet()
{
}
void DataSet::readData()
{
ifstream file("eventFiles/events.txt");
//QFile file("/home/radek/Dropbox/OpenGL/mcEventDisplay/eventsHiggs.txt");
//file.open(QIODevice::ReadOnly);
ifstream &in = file;
//QTextStream in(&file);
vector<Particle> event;
cout << "I am here RADEK " <<file.good()<< " "<< file.is_open() << endl;
int i = 0;
while(in.good()) {
string head;
getline(in, head);
//head = in.readLine();
if(head.compare(" -------- PYTHIA Event Listing (complete event) ---------------------------------------------------------------------------------"))
continue;
//head = in.readLine();
cout << "rADEK1 " << head << endl;
getline(in, head);
cout << "rADEK2 " << head << endl;
if(head.compare(" "))
continue;
//head = in.readLine();
getline(in, head);
cout << "rADEK3 " << head << endl;
if(head.compare(" no id name status mothers daughters colours p_x p_y p_z e m "))
//no id name status mothers daughters colours p_x p_y p_z e m
continue;
//head = in.readLine();
getline(in, head);
cout << "rADEK4 " << head << endl;
if(head.compare(" scale pol xProd yProd zProd tProd tau"))
continue;
Particle p;
bool stat;
event.clear();
do {
stat = true;
//cout << "ahoj "<< in.status()<<endl;
string strTmp;
getline(in, strTmp);
stringstream sTmp(strTmp);
if(strTmp.find("Charge sum") != std::string::npos) {
stat = false; break;
}
sTmp >> p.id >> p.pdg >> p.name >> p.status
>> p.mother1 >> p.mother2 >> p.daughter1 >> p.daughter2
>> p.col >> p.acol >> p.px >> p.py >> p.pz >> p.e >> p.m;
//cout << "helenkaMother " << p.id << "isGood:"<< in.good()<< endl;
if (!in.good()) { stat = false; break; }
getline(in, strTmp);
stringstream sTmp2(strTmp);
sTmp2 >> p.scale >> p.pol >> p.xProd >> p.yProd >> p.zProd >> p.tProd >>p.tau;
//cout << "Helenka " << p.scale << " "<<p.pol <<"isGood:"<< in.good()<< endl;
getline(in, strTmp);
if (!in.good()) {
stat = false;
break;
}
if(!stat)
break;
event.push_back(p);
} while(stat);
//head = in.readLine();
getline(in, head);
//cout << head.toUtf8().constData() << endl;
//head = in.readLine();
//getline(in, head);
//cout << head.toUtf8().constData() << endl;
//head = in.readLine();
getline(in, head);
if(!head.compare(" -------- End PYTHIA Event Listing -----------------------------------------------------------------------------------------------")) {
//cout << "I am here, hura!!! " <<event.size()<< endl;
//cout <<"OK "<<in.status() <<endl;
//in.resetStatus();
trees.push_back(Tree(i, event));
cout << "I am here RADEK entry " <<i <<", ev size " << event.size() << endl;
event.clear();
++i;
//cout << endl;
}
//cout <<":"<< head.toUtf8().constData() <<":"<< endl;
//cout << endl;
//QStringList fields = line.split(",");
//model->appendRow(fields);
//if(i++ > 10000)
//exit(0);
}
cout << "I am here RADEK end " << trees.size() << endl;
//exit(0);
file.close();
}