-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckindex.C
52 lines (44 loc) · 1.24 KB
/
checkindex.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
#include <iostream>
#include <fstream>
#include <TTree.h>
#include <TTreeIndex.h>
#include <TFile.h>
#include <TString.h>
#include <cstring>
#include "utils.h"
#include "ramrecord.C"
void checkindex(const char *file = "ramexample.root")
{
auto f = TFile::Open(file);
auto t = RAMRecord::GetTree(f);
RAMRecord *r = 0;
t->SetBranchAddress("RAMRecord.", &r);
// Check for TTreeIndex in TTree, same file and external file (in that order)
auto i = t->GetTreeIndex();
if (i) {
std::cout << "Index present in TTree" << std::endl;
} else {
std::string indexfile = file;
indexfile.append(".rai");
std::FILE *fp = std::fopen(indexfile.c_str(), "r");
if (fp) {
auto f2 = TFile::Open(indexfile.c_str());
i = (TTreeIndex *)f2->Get("INDEX");
if (i) {
std::cout << "HOLA" << std::endl;
std::cout << "Index present in separate TFile" << std::endl;
}
delete fp;
delete f2;
}
}
if (i) {
std::cout << "Majorname is " << i->GetMajorName() << std::endl;
std::cout << "Minorname is " << i->GetMinorName() << std::endl;
} else {
std::cout << "Index Missing" << std::endl;
}
delete i;
delete t;
delete f;
}