-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
146 lines (131 loc) · 4.67 KB
/
main.cpp
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <iostream>
#include <TApplication.h>
#include <TStopwatch.h>
#include <TString.h>
#include <TObjString.h>
#include <TList.h>
#include <TSystemDirectory.h>
#include "dataprocess.h"
int main(int argc, char **argv)
{
TStopwatch time;
time.Start();
bool bCol = true;
bool bRow = true;
bool bToA = true;
bool bToT = true;
bool bTrig = true;
bool bTrigTime = true;
bool bTrigToA = true;
bool bProcTree = true;
bool bCsv = false;
bool bCentroid = true;
int gapPix = 1;
float gapTime = 1.0;
bool bNoTrigWindow = true;
float timeWindow = 0;
float timeStart = 0;
bool bSingleFile = true;
int c;
bool bash = false;
bool combine = false;
TString dirname = ".";
TString filename = "";
TString process = "procAll";
UInt_t maxEntries = 0;
while( ( c = getopt (argc, argv, ":bcd:f:p:e:") ) != -1 )
{
switch(c)
{
case 'b':
bash = true;
break;
case 'c':
bCsv = true;
break;
case 'd':
if (optarg){ dirname = (TString) optarg; combine = true; break;}
else {std::cout << "Missing dir name" << std::endl;}
case 'f':
if(optarg){ filename = (TString) optarg; break;}
else {std::cout << "Missing file name" << std::endl;}
case 'p':
if(optarg){ process = (TString) optarg; break;}
else {std::cout << "Missing process type" << std::endl;}
case 'e':
if(optarg){ maxEntries = (UInt_t) std::atoll(optarg); break;}
else {std::cout << "Define max entries " << std::endl;}
case '?':
std::cout << "Received unknown argument " << c << std::endl;
default :
std::cout << "Exiting code. Usage: " << std::endl;
std::cout << "-b executes in bash" << std::endl;
std::cout << "-c creates csv output" << std::endl;
std::cout << "-d [] name of folder in which to combine (do not use -f)" << std::endl;
std::cout << "-f [] name of file to process (do not use -d)" << std::endl;
std::cout << "-p [] procAll/procDat/procRoot" << std::endl;
std::cout << "-e [] max number of entries" << std::endl;
return -1;
break;
}
}
if (bash)
{
DataProcess* processor = new DataProcess();
if (process.Contains("procRoot"))
processor->setProcess(ProcType::procRoot);
else if (process.Contains("procDat"))
processor->setProcess(ProcType::procDat);
else
processor->setProcess(ProcType::procAll);
processor->setNEntries(maxEntries);
processor->setOptions(bCol, bRow, bToT, bToA, bTrig, bTrigTime, bTrigToA, bProcTree, bCsv, bCentroid, gapPix, gapTime, bNoTrigWindow, timeWindow, timeStart, bSingleFile);
if (combine)
{
TObjString inputNames[256];
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;
inputNames[inputNumber++].SetString(dirname+"/"+fname);
}
}
}
processor->setName(inputNames, inputNumber);
if (process.Contains("procRoot"))
processor->setCorrection(CorrType::corrUse, inputNames[0].GetString() + "_LTcorr.csv");
else
processor->setCorrection(CorrType::corrNew, inputNames[0].GetString() + "_LTcorr.csv");
}
else
{
std::cout << filename << " " << " at " << dirname << std::endl;
processor->setName(filename);
if (process.Contains("procRoot"))
processor->setCorrection(CorrType::corrUse, filename + "_LTcorr.csv");
else
processor->setCorrection(CorrType::corrNew, filename + "_LTcorr.csv");
}
processor->process();
}
// else
// {
// TApplication theApp("App",&argc,argv);
//
// new DrGUI(); // qt written app
// theApp.Run();
// }
time.Stop();
time.Print();
return 0;
}