-
Notifications
You must be signed in to change notification settings - Fork 2
/
fastEntanglement.C
44 lines (37 loc) · 1.32 KB
/
fastEntanglement.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
#include <TString.h>
#include <TObjString.h>
#include <TList.h>
#include <TSystemDirectory.h>
#include "entangled.h"
#define MAX_ENTRIES 0
void fastEntanglement(TString dirname, TString treeType = "rawtree", int nthreads = 2)
{
if (dirname.EndsWith("/"))
dirname.Replace(dirname.Last('/'),200,"");
TObjString m_inputNames[32];
int inputNumber = 0;
TSystemDirectory dir(dirname, dirname);
TList *files = dir.GetListOfFiles();
if (files)
{
TSystemFile *file;
TString fname;
TIter next(files);
while ((file=(TSystemFile*)next()))
{ fname = file->GetName();
if (!file->IsDirectory() && fname.EndsWith(".root") && !fname.Contains("processed"))
{
std::cout << fname << " " << inputNumber << " at " << dirname << std::endl;
m_inputNames[inputNumber++].SetString(dirname+"/"+fname);
// Entangled* processor = new Entangled(dirname + "/" + fname, treeType, MAX_ENTRIES);
}
}
}
auto multicoreProcess = [m_inputNames, treeType](int number)
{
Entangled* processor = new Entangled(m_inputNames[number].GetString(), treeType, MAX_ENTRIES);
return 0;
};
ROOT::TProcessExecutor workers(nthreads);
workers.Map(multicoreProcess, ROOT::TSeqI(inputNumber));
}