-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakeCSVfromPlainROOTfile.C
51 lines (44 loc) · 1.17 KB
/
makeCSVfromPlainROOTfile.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
#include"TString.h"
#include"TChain.h"
#include"TTree.h"
#include"TFile.h"
#include"TH1F.h"
#include"TTreeFormula.h"
#include <iostream>
#include <fstream>
void
doCSV (TString inputFile)
{
TFile *filein = new TFile (inputFile);
TTree *tree = (TTree*) filein->Get("rootTupleTree/tree");
cout << "tree:" << tree << endl;
Double_t L1_HTT240, run, lumi;
tree->GetEntry(0);
tree->SetBranchAddress ("L1_HTT240", &L1_HTT240);
tree->SetBranchAddress ("run", &run);
tree->SetBranchAddress ("lumi", &lumi);
cout << "2" << endl;
int entries = tree->GetEntries ();
if (entries <= 0) {
cout << "No entries in file " << inputFile << endl;
throw 1;
}
TTree *newTree = tree->CloneTree (0);
vector < pair < int, int >>goodRunLumi;
int oldLumi = -1;
for (int i = 0; i < tree->GetEntries (); i++) {
tree->GetEntry (i);
if (L1_HTT240 && lumi != oldLumi)
goodRunLumi.push_back (pair < int, int >(run, lumi));
oldLumi = lumi;
}
ofstream myfile;
myfile.open ("lowLumi.csv");
for(const auto & pair: goodRunLumi) myfile << pair.first<< ","<<pair.second<< endl;
myfile.close();
}
void
makeCSV ()
{
doCSV ("../ntupleTrigger/L1HTTSkim.root");
}