-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroupCoincidences.cpp
More file actions
62 lines (45 loc) · 1.7 KB
/
Copy pathgroupCoincidences.cpp
File metadata and controls
62 lines (45 loc) · 1.7 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
#include <iostream>
#include <TFile.h>
#include "include/utils.h"
#include "include/eventSelection.h"
// Globals
bool g_verbose;
TString g_treeName;
std::vector<TString> g_fullPaths;
void processSingleRootFile(const size_t idx) {
std::cout << "Processing: " << g_fullPaths[idx] << std::endl;
TFile* file = getTFile(g_fullPaths[idx], "UPDATE", g_verbose);
TTree* tree = getTTree(file, g_treeName, g_verbose);
if (!checkIfLeafExists(tree, "trueness")) {
std::cerr << "Error: trueness leaf missing." << std::endl;
std::exit(1);
}
if (!checkIfLeafExists(tree, "group")) {
Int_t groupID, groupEventID1, groupEventID2;
TBranch* b0 = tree->Branch("groupID", &groupID, "groupID/I");
TBranch* b1 = tree->Branch("groupEventID1", &groupEventID1, "groupEventID1/I");
TBranch* b2 = tree->Branch("groupEventID2", &groupEventID2, "groupEventID2/I");
coincidenceGrouping(tree, groupID, b0, groupEventID1, b1, groupEventID2, b2, g_verbose);
std::cout << "Writing: " << g_fullPaths[idx] << std::endl;
file->cd();
tree->Write("", TObject::kWriteDelete);
file->Close();
}
}
int main(int argc, char* argv[]) {
// Check for the required input
if (argc < 2) {
printf("Error: no path provided.\n");
return 1;
}
const char *path = argv[1];
//printf("Path: %s\n", path);
// Set globals
g_verbose = false;
// g_treeName = "MergedCoincidences";
g_treeName = "Coincidences";
g_fullPaths = getListOfRootFilePaths(path, g_verbose);
// runSequentially(g_fullPaths.size(), processSingleFile);
runInSeparateProcesses(g_fullPaths.size(), processSingleRootFile, 128);
return 0;
}