-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqrootfile.cpp
More file actions
70 lines (53 loc) · 1.41 KB
/
Copy pathqrootfile.cpp
File metadata and controls
70 lines (53 loc) · 1.41 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
#include "qrootfile.h"
#include "mainwindow.h"
#include "QStandardItemModel"
#include "TFile.h"
#include "TObject.h"
#include <map>
#include <iostream>
QROOTFile::QROOTFile(std::string flnm)
{
fFileName = flnm;
file = new TFile(fFileName.c_str());
fileMap = new std::map<std::string , TObject *>();
TList* list = file->GetListOfKeys();
TObject* tmp = NULL;
for (TIter i = list->begin(); i != list->end(); ++i) {
tmp = (*i);
if (tmp->IsFolder()) {
TDirectory* dir = file->GetDirectory(tmp->GetName());
makeMap(dir);
} else {
// std::cout << tmp->GetName() << std::endl;
(*fileMap)[std::string(tmp->GetName())] = file->Get(tmp->GetName());
}
}
std::cout << std::flush;
}
QROOTFile::~QROOTFile()
{
delete file;
delete fileMap;
}
void QROOTFile::makeMap(TDirectory *dir)
{
TList* list = dir->GetListOfKeys();
TObject* tmp = NULL;
for (TIter i = list->begin(); i != list->end(); ++i) {
tmp = (*i);
if (tmp->IsFolder()) {
TDirectory* dir2 = dir->GetDirectory(tmp->GetName());
makeMap(dir2);
} else {
(*fileMap)[std::string(tmp->GetName())] = dir->Get(tmp->GetName());
}
}
}
std::map<std::string , TObject *>* QROOTFile::getMap()
{
return fileMap;
}
TObject* QROOTFile::GetObject(std::string str)
{
return (*fileMap)[str];
}