-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfastProcess.C
96 lines (82 loc) · 2.89 KB
/
fastProcess.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <TString.h>
#include <TObjString.h>
#include <TList.h>
#include <TSystemDirectory.h>
#include "dataprocess.h"
const bool bCol = true;
const bool bRow = true;
const bool bToA = true;
const bool bToT = true;
const bool bTrig = false;
const bool bTrigTime = false;
const bool bTrigToA = true;
const bool bNoTrigWindow = true;
const bool bProcTree = true;
const bool bCentroid = true;
const int gapPix = 1;
const float gapTime = 1.0;
const float timeWindow = 60;
const float timeStart = 0;
const bool bSingleFile = true;
void fastProcess(TString dirname, bool combine=kFALSE, int nthreads = 2, bool bCsv=kFALSE)
{
if (dirname.EndsWith("/"))
dirname.Replace(dirname.Last('/'),200,"");
TObjString m_inputNames[128];
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(".dat"))
{
std::cout << fname << " " << inputNumber << " at " << dirname << std::endl;
m_inputNames[inputNumber++].SetString(dirname+"/"+fname);
}
}
}
if (combine)
{
DataProcess* processor = new DataProcess();
processor->setCorrection(CorrType::corrNew);
processor->setName(m_inputNames, inputNumber);
processor->setProcess(ProcType::procAll);
processor->setOptions(bCol, bRow, bToT, bToA, bTrig, bTrigTime, bTrigToA, bProcTree, bCsv, bCentroid, gapPix, gapTime, bNoTrigWindow, timeWindow, timeStart, bSingleFile);
processor->process();
} else
{
auto multicoreProcess = [m_inputNames, bCsv](int number)
{
DataProcess* processor = new DataProcess();
TString tmpString = m_inputNames[number].GetString();
processor->setCorrection(CorrType::corrNew, tmpString + "_LTcorr.csv");
processor->setProcess(ProcType::procAll);
processor->setName(tmpString);
processor->setOptions(bCol, bRow, bToT, bToA, bTrig, bTrigTime, bTrigToA, bProcTree, bCsv, bCentroid, gapPix, gapTime, bNoTrigWindow, timeWindow, timeStart, bSingleFile);
processor->process();
return 0;
};
ROOT::TProcessExecutor workers(nthreads);
workers.Map(multicoreProcess, ROOT::TSeqI(inputNumber));
}
}
# ifndef __CINT__ // the following code will be invisible for the interpreter
int main(int argc, char** argv)
{
if (argc == 1)
std::cout << "error with arguments" << std::endl;
else
{
TString name = argv[1]; // convert the second parameter to an integer
bool combine = kFALSE;
if (argc > 2)
combine = (bool) std::stoi(argv[2]);
fastProcess(name, combine);
}
}
# endif