Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
171 lines (156 loc) · 5.72 KB
/
Copy pathmain.cpp
File metadata and controls
171 lines (156 loc) · 5.72 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include <unistd.h>
#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;
bool bForwardTrigger = true;
float timeWindow = 0;
float timeStart = 0;
bool bSingleFile = true;
int c;
bool bash = false;
bool combine = false;
TString dirout = "";
TString dirname = ".";
TString filename = "";
TString process = "procAll";
UInt_t maxEntries = 0;
while( ( c = getopt (argc, argv, ":hbcto:d:f:p:e:") ) != -1 )
{
switch(c)
{
case 'b':
bash = true;
break;
case 'c':
bCsv = true;
break;
case 't':
bForwardTrigger = false;
break;
case 'o':
if (optarg){ dirout = (TString) optarg; break;}
else {std::cout << "Missing dir output" << std::endl;}
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;
case 'h':
;
default :
std::cout << "The script is used following way: " << std::endl;
std::cout << "-b executes in bash" << std::endl;
std::cout << "-c creates csv output" << std::endl;
std::cout << "-t backward trigger" << std::endl;
std::cout << "-o name of folder where to generate 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, bForwardTrigger, bNoTrigWindow, timeWindow, timeStart, bSingleFile);
if (!dirout.EndsWith("/")) dirout+= "/";
processor->setOutputPath(dirout);
TString tmpname;
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") || fname.EndsWith(".tpx3")))
{
if (inputNumber == 0) tmpname = fname;
std::cout << fname << " " << inputNumber << " at " << dirname << std::endl;
inputNames[inputNumber++].SetString(dirname+"/"+fname);
}
}
}
Int_t dotPos = tmpname.Last('.');
tmpname.Replace(dotPos, 200, "_LTcorr.csv");
processor->setName(inputNames, inputNumber);
if (process.Contains("procRoot"))
processor->setCorrection(CorrType::corrUse, dirout + tmpname);
else
processor->setCorrection(CorrType::corrNew, dirout + tmpname);
}
else
{
std::cout << filename << " " << " at " << dirname << std::endl;
tmpname = filename;
if (dirname == ".") {
Int_t slashPos = tmpname.Last('/');
Int_t dotPos = tmpname.Last('.');
tmpname.Replace(dotPos, 200, "_LTcorr.csv");
tmpname.Remove(0, slashPos + 1);
}
processor->setName(filename);
if (process.Contains("procRoot"))
processor->setCorrection(CorrType::corrUse, dirout + tmpname);
else
processor->setCorrection(CorrType::corrNew, dirout + tmpname);
}
processor->process();
}
// else
// {
// TApplication theApp("App",&argc,argv);
//
// new DrGUI(); // qt written app
// theApp.Run();
// }
time.Stop();
time.Print();
return 0;
}