-
Notifications
You must be signed in to change notification settings - Fork 2
/
DRGUI.C
613 lines (493 loc) · 22.6 KB
/
DRGUI.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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
//==================================
// Author: IRAKLI CHAKABERIA =====
// Coauthor: PETER SVIHRA =====
// Date: 2017-02-14 =====
//==================================
#include <TGButton.h>
#include <TGButtonGroup.h>
#include <TGLabel.h>
#include <TGNumberEntry.h>
#include <TG3DLine.h>
#include <TApplication.h>
#include <TSysEvtHandler.h>
#include "TGTextEdit.h"
#include "TGText.h"
#include "TGDimension.h"
#include "TObjString.h"
#include <deque>
#include "dataprocess.h"
const char * fileTypes[] = {
"data files", "*.dat",
"SoPhy files", "*.tpx3",
"ROOT files", "*.root",
0, 0
};
const char * fileTypesCorr[] = {
"lookup table", "*.csv",
0, 0
};
class TextMargin : public TGHorizontalFrame {
protected:
TGNumberEntry * fEntry;
TGLabel * label;
public:
TextMargin(const TGWindow *p, const char *name, TGNumberFormat::EStyle style = TGNumberFormat::kNESInteger) : TGHorizontalFrame(p)
{
fEntry = new TGNumberEntry(this, 0, 6, -1, style);
AddFrame(fEntry, new TGLayoutHints(kLHintsLeft));
label = new TGLabel(this, name);
AddFrame(label, new TGLayoutHints(kLHintsLeft, 10));
}
TGTextEntry * GetEntry() const { return fEntry->GetNumberEntry(); }
void SetEntry(int entry) { fEntry->SetNumber(entry); }
void SetEnabled(bool state) {
// fEntry->SetState(!state);
if (label->IsDisabled()) { label->Enable(); fEntry->SetState(kTRUE); }
else { label->Disable(); fEntry->SetState(kFALSE); }
}
// ClassDef(TextMargin, 0);
};
class DRGui : public TGMainFrame {
protected:
TGTextButton * fButton;
TGTextButton * sButton;
TGTextButton * bButton;
TGTextButton * cButton;
TGTextEdit * rootFile;
TGTextEdit * corrFile;
TSignalHandler * sigHandler;
public:
bool bnHits;
bool bCol;
bool bRow;
bool bToA;
bool bToT;
bool bTrig;
bool bTrigTime;
bool bTrigToA;
bool bCentroid;
bool bProcTree;
bool bCsv;
CorrType ctCorrection;
TString stCorrection;
TGRadioButton * off;
TGRadioButton * create;
ProcType ptProcess;
bool bCombineInput;
int inputNumber;
bool bSingleFile;
bool bNoTrigWindow;
float timeWindow;
float timeStart;
int linesPerFile;
int m_gapPix;
double m_gapTime;
DRGui();
void ProcessNames();
void RunReducer();
void StopReducer();
void ApplyCutsHits(char *);
void ApplyCutsWindow(char *);
void ApplyCutsStart(char *);
void ApplyCutsLines(char *);
void ApplyCutsCentroidPixel(char * val);
void ApplyCutsCentroidTime(char * val);
void SelectOff(Bool_t);
void SelectUse(Bool_t);
void SelectNew(Bool_t);
void SelectCol(Bool_t);
void SelectRow(Bool_t);
void SelectToA(Bool_t);
void SelectToT(Bool_t);
void SelectTrig(Bool_t);
void SelectTrigTime(Bool_t);
void SelectTrigToA(Bool_t);
void SelectData(Bool_t);
void SelectRoot(Bool_t);
void SelectAll(Bool_t);
void SelectProcTree(Bool_t);
void SelectCsv(Bool_t);
void SelectSingleFile(Bool_t);
void SelectNoTrigWindow(Bool_t);
void SelectCent(Bool_t);
void SelectCombined(Bool_t);
void Browse();
void BrowseCorr();
// ClassDef(DRGui, 0);
private:
TString m_infoMsg;
TObjString m_inputNames[32];
};
void DRGUI() {
//
// Initialize library
// gROOT->ProcessLine(".L dataprocess.cpp+");
new DRGui();
}
DRGui::DRGui() : TGMainFrame(gClient->GetRoot(), 10, 20, kHorizontalFrame) {
SetCleanup(kDeepCleanup);
// All variables are selected by default
bCol = true;
bRow = true;
bToA = true;
bToT = true;
bTrig = true;
bTrigTime = true;
bTrigToA = true;
bProcTree = false;
bCsv = true;
bNoTrigWindow = false;
bSingleFile = false;
bCombineInput = false;
bCentroid = false;
inputNumber = 0;
ctCorrection = corrOff;
ptProcess = procAll;
linesPerFile = 100000;
timeWindow = 40;
timeStart = 0;
m_gapPix = 0;
m_gapTime = 1.0;
m_infoMsg = "Select File";
// Controls on right
TGVerticalFrame * controls = new TGVerticalFrame(this);
AddFrame(controls, new TGLayoutHints(kLHintsRight | kLHintsNormal | kLHintsExpandY, 5, 5, 5, 5));
// VARIABLE and PROCESSES ON LEFT
TGVerticalFrame * variables = new TGVerticalFrame(this);
AddFrame(variables, new TGLayoutHints(kLHintsLeft | kLHintsNormal | kLHintsExpandY, 5, 5, 5, 5));
// Separator
TGVertical3DLine *separator = new TGVertical3DLine(this);
AddFrame(separator, new TGLayoutHints(kLHintsRight | kLHintsExpandY));
TGVertical3DLine *separator1 = new TGVertical3DLine(this);
AddFrame(separator1, new TGLayoutHints(kLHintsExpandY));
// Contents
TGVerticalFrame * contents = new TGVerticalFrame(this);
AddFrame(contents, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
// The button for test
fButton = new TGTextButton(contents, "&RUN THE DATA REDUCER");
// fButton->Resize(200, 200);
// fButton->ChangeOptions(fButton->GetOptions() | kFixedSize);
fButton->SetToolTipText("Run the reducer macro", 200);
fButton->Connect("Pressed()", "DRGui", this, "RunReducer()");
// STOPPING EXECUTION
sButton = new TGTextButton(contents, "&STOP THE DATA REDUCER");
sButton->SetToolTipText("Stop the reducer macro", 200);
sButton->Connect("Pressed()", "DRGui", this, "StopReducer()");
sigHandler = new TSignalHandler(kSigInterrupt);
sigHandler->Add();
sigHandler->Connect("Notified()", "DRGui", this, "StopReducer()");
// CORRECTION USAGE
TGGroupFrame * corrGroup = new TGGroupFrame(contents, "Timewalk Correction");
corrGroup->SetTitlePos(TGGroupFrame::kCenter);
TGHButtonGroup * correction = new TGHButtonGroup(corrGroup);
off = new TGRadioButton(correction, "off");
TGRadioButton * use = new TGRadioButton(correction, "use");
create = new TGRadioButton(correction, "new");
off ->SetOn();
use ->SetOn(kFALSE);
create->SetOn(kFALSE);
correction->AddFrame(off , new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
correction->AddFrame(use , new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
correction->AddFrame(create, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
off ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectOff(Bool_t)");
use ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectUse(Bool_t)");
create ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectNew(Bool_t)");
create->SetEnabled(kFALSE);
correction->SetRadioButtonExclusive(kTRUE);
corrFile = new TGTextEdit(corrGroup, 600,60);
cButton = new TGTextButton(corrGroup, "Browse Correction File");
corrGroup->AddFrame(correction, new TGLayoutHints(kLHintsExpandX));
corrGroup->AddFrame(corrFile, new TGLayoutHints(kLHintsExpandX));
corrGroup->AddFrame(cButton, new TGLayoutHints(kLHintsExpandX));
cButton->Connect("Clicked()", "DRGui", this, "BrowseCorr()");
cButton->SetEnabled(kFALSE);
contents->AddFrame(corrGroup, new TGLayoutHints(kLHintsExpandX));
// BROWSE FILE
rootFile = new TGTextEdit(contents, 600,200, m_infoMsg);
//rootFile->SetText();
bButton = new TGTextButton(contents, "Browse Files");
contents->AddFrame(rootFile, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
contents->AddFrame(bButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 10, 10, 10, 10));
contents->AddFrame(fButton, new TGLayoutHints(kLHintsBottom| kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
contents->AddFrame(sButton, new TGLayoutHints(kLHintsBottom| kLHintsExpandX, 5, 5, 5, 5));
bButton->Connect("Clicked()", "DRGui", this, "Browse()");
// VARIABLES
TGGroupFrame * varsGroup = new TGGroupFrame(variables, "Variables");
varsGroup->SetTitlePos(TGGroupFrame::kCenter);
TGCheckButton * col = new TGCheckButton(varsGroup, "Col");
TGCheckButton * row = new TGCheckButton(varsGroup, "Row");
TGCheckButton * toa = new TGCheckButton(varsGroup, "ToA");
TGCheckButton * tot = new TGCheckButton(varsGroup, "ToT");
TGCheckButton * trig = new TGCheckButton(varsGroup, "Trigger ID");
TGCheckButton * trigTime= new TGCheckButton(varsGroup, "Trigger Time");
TGCheckButton * trigToA = new TGCheckButton(varsGroup, "ToA-Trigger");
col->SetOn();
row->SetOn();
toa->SetOn();
tot->SetOn();
trig->SetOn();
trigTime->SetOn();
trigToA->SetOn();
varsGroup->AddFrame(col, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(row, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(toa, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(tot, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(trig, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(trigTime,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
varsGroup->AddFrame(trigToA, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
col ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectCol(Bool_t)");
row ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectRow(Bool_t)");
toa ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectToA(Bool_t)");
tot ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectToT(Bool_t)");
trig ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectTrig(Bool_t)");
trigTime->Connect("Toggled(Bool_t)", "DRGui", this, "SelectTrigTime(Bool_t)");
trigToA ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectTrigToA(Bool_t)");
variables->AddFrame(varsGroup, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// PROCESSES
TGVButtonGroup * procGroup = new TGVButtonGroup(variables, "Process");
procGroup->SetTitlePos(TGGroupFrame::kCenter);
TGRadioButton * all = new TGRadioButton(procGroup, "all");
TGRadioButton * data = new TGRadioButton(procGroup, "data");
TGRadioButton * root = new TGRadioButton(procGroup, "root");
TGCheckButton * procTree = new TGCheckButton(procGroup, "procTree");
TGCheckButton * csv = new TGCheckButton(procGroup, "csv");
all ->SetOn();
data->SetOn(kFALSE);
root->SetOn(kFALSE);
procTree->SetOn(kFALSE);
csv->SetOn(kTRUE);
procGroup->AddFrame(procTree,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
procGroup->AddFrame(all, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
procGroup->AddFrame(data, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
procGroup->AddFrame(root, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
all ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectAll(Bool_t)");
data ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectData(Bool_t)");
root ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectRoot(Bool_t)");
procTree->Connect("Toggled(Bool_t)", "DRGui", this, "SelectProcTree(Bool_t");
csv ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectCsv(Bool_t");
procGroup->SetRadioButtonExclusive(kTRUE);
variables->AddFrame(procGroup, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// CUTS
TGGroupFrame * cuts = new TGGroupFrame(controls, "Cuts");
cuts->SetTitlePos(TGGroupFrame::kCenter);
TextMargin * timeW = new TextMargin(cuts, "Time Window Size (micro s)", TGNumberFormat::kNESRealOne);
timeW->SetEntry(timeWindow);
TextMargin * timeS = new TextMargin(cuts, "Time Window Start (micro s)", TGNumberFormat::kNESRealOne);
timeS->SetEntry(timeStart);
TGCheckButton * noTrigWindow = new TGCheckButton(cuts, "All Data");
cuts->AddFrame(timeS, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
cuts->AddFrame(timeW, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
cuts->AddFrame(noTrigWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
noTrigWindow->Connect("Toggled(Bool_t)", "TextMargin", timeS, "SetEnabled(Bool_t)");
noTrigWindow->Connect("Toggled(Bool_t)", "TextMargin", timeW, "SetEnabled(Bool_t)");
noTrigWindow->Connect("Toggled(Bool_t)", "DRGui", this, "SelectNoTrigWindow(Bool_t)");
timeW->GetEntry()->Connect("TextChanged(char*)", "DRGui", this, "ApplyCutsWindow(char*)");
timeS->GetEntry()->Connect("TextChanged(char*)", "DRGui", this, "ApplyCutsStart(char*)");
controls->AddFrame(cuts, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// OUTPUT CONTROL
TGGroupFrame * outControl = new TGGroupFrame(controls, "Output File");
outControl->SetTitlePos(TGGroupFrame::kCenter);
TGCheckButton * singleFile = new TGCheckButton(outControl, "Single File");
TextMargin * nLines = new TextMargin(outControl, "Lines per File");
outControl->AddFrame(singleFile, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
outControl->AddFrame(nLines, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
nLines->SetEntry(linesPerFile);
nLines->GetEntry()->Connect("TextChanged(char*)", "DRGui", this, "ApplyCutsLines(char*)");
singleFile->Connect("Toggled(Bool_t)", "TextMargin", nLines, "SetEnabled(Bool_t)");
singleFile->Connect("Toggled(Bool_t)", "DRGui", this, "SelectSingleFile(Bool_t)");
controls->AddFrame(outControl, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// INPUT CONTROL
TGVButtonGroup * combGroup = new TGVButtonGroup(controls, "Input File");
combGroup->SetTitlePos(TGGroupFrame::kCenter);
TGCheckButton * combIn = new TGCheckButton(combGroup, "Combine .dat files");
combIn->SetOn(bCombineInput);
combGroup->AddFrame(combIn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
combIn->Connect("Toggled(Bool_t)", "DRGui", this, "SelectCombined(Bool_t)");
controls->AddFrame(combGroup, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// CENTROID CONTROL
TGGroupFrame * centControl = new TGGroupFrame(controls, "Centroiding");
centControl->SetTitlePos(TGGroupFrame::kCenter);
TGCheckButton * cent = new TGCheckButton(centControl, "Centroid");
TextMargin * gapPix = new TextMargin(centControl, "Allowed pix gap", TGNumberFormat::kNESInteger);
TextMargin * gapTime = new TextMargin(centControl, "Time Window (micro s)", TGNumberFormat::kNESRealTwo);
centControl->AddFrame(cent, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
centControl->AddFrame(gapPix, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
centControl->AddFrame(gapTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
gapPix ->SetEntry(m_gapPix);
gapPix ->SetEnabled(kTRUE);
gapTime->SetEntry(m_gapTime);
gapTime ->SetEnabled(kTRUE);
gapPix ->GetEntry()->Connect("TextChanged(char*)", "DRGui", this, "ApplyCutsCentroidPixel(char*)");
gapTime->GetEntry()->Connect("TextChanged(char*)", "DRGui", this, "ApplyCutsCentroidTime(char*)");
cent ->Connect("Toggled(Bool_t)", "TextMargin", gapPix, "SetEnabled(Bool_t)");
cent ->Connect("Toggled(Bool_t)", "TextMargin", gapTime, "SetEnabled(Bool_t)");
cent ->Connect("Toggled(Bool_t)", "DRGui", this, "SelectCent(Bool_t)");
controls->AddFrame(centControl, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
// QUIT
TGTextButton *quit = new TGTextButton(controls, "Quit");
controls->AddFrame(quit, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 0, 5));
quit->Connect("Pressed()", "TApplication", gApplication, "Terminate()");
Connect("CloseWindow()", "TApplication", gApplication, "Terminate()");
DontCallClose();
MapSubwindows();
Resize();
SetWMSizeHints(GetDefaultWidth(), GetDefaultHeight(), 1000, 1000, 0 ,0);
SetWindowName("RRGui");
MapRaised();
}
void DRGui::ApplyCutsWindow(char * val){ timeWindow = abs(atof(val)); }
void DRGui::ApplyCutsStart(char * val) { timeStart = abs(atof(val)); }
void DRGui::ApplyCutsLines(char * val) { linesPerFile = abs(atoi(val)); }
void DRGui::ApplyCutsCentroidPixel(char * val) { m_gapPix = abs(atoi(val)); }
void DRGui::ApplyCutsCentroidTime (char * val) { m_gapTime = abs(atof(val)); }
void DRGui::SelectCol(Bool_t check) { bCol = check; }
void DRGui::SelectRow(Bool_t check) { bRow = check; }
void DRGui::SelectToA(Bool_t check) { bToA = check; }
void DRGui::SelectToT(Bool_t check) { bToT = check; }
void DRGui::SelectTrig(Bool_t check) { bTrig = check; }
void DRGui::SelectTrigTime(Bool_t check) { bTrigTime = check; }
void DRGui::SelectTrigToA(Bool_t check) { bTrigToA = check; }
void DRGui::SelectCent(Bool_t check) { bCentroid = check; if (!check) {off->SetOn(kTRUE); create->SetOn(kFALSE);} create->SetEnabled(check);}
void DRGui::SelectAll(Bool_t check) { if (check) ptProcess = procAll; }
void DRGui::SelectData(Bool_t check) { if (check) ptProcess = procDat; }
void DRGui::SelectRoot(Bool_t check) { if (check) ptProcess = procRoot; }
void DRGui::SelectProcTree(Bool_t check){ bProcTree = check; }
void DRGui::SelectCsv(Bool_t check){ bCsv = check; }
void DRGui::SelectOff(Bool_t check) { if (check) ctCorrection = corrOff; corrFile->Clear(); cButton->SetEnabled(!check); }
void DRGui::SelectUse(Bool_t check) { if (check) ctCorrection = corrUse; corrFile->Clear(); cButton->SetEnabled(check); }
void DRGui::SelectNew(Bool_t check) { if (check) ctCorrection = corrNew; corrFile->Clear(); cButton->SetEnabled(!check); }
void DRGui::SelectCombined(Bool_t check) { if (check) bCombineInput = check; }
void DRGui::SelectSingleFile(Bool_t check) { bSingleFile = check; }
void DRGui::SelectNoTrigWindow(Bool_t check) { bNoTrigWindow = check; }
void DRGui::BrowseCorr()
{
static TString dir(".");
TGFileInfo fileInfo;
fileInfo.SetMultipleSelection(kFALSE);
fileInfo.fFileTypes = fileTypesCorr;
fileInfo.fIniDir = StrDup(dir);
//
// browsing dialog - multiple files or one file only
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fileInfo);
if (fileInfo.fMultipleSelection && fileInfo.fFileNamesList)
{
corrFile->Clear();
TObjString *el;
TIter next(fileInfo.fFileNamesList);
while ((el = (TObjString *) next()))
{
corrFile->AddLine(el->GetString());
}
}
else if (fileInfo.fFilename)
{
corrFile->Clear();
corrFile->AddLine(fileInfo.fFilename);
}
corrFile->NextChar();
corrFile->DelChar();
dir = fileInfo.fIniDir;
}
void DRGui::Browse()
{
static TString dir(".");
TGFileInfo fileInfo;
fileInfo.SetMultipleSelection(kTRUE);
fileInfo.fFileTypes = fileTypes;
fileInfo.fIniDir = StrDup(dir);
//
// browsing dialog - multiple files or one file only
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fileInfo);
if (fileInfo.fMultipleSelection && fileInfo.fFileNamesList)
{
rootFile->Clear();
TObjString *el;
TIter next(fileInfo.fFileNamesList);
while ((el = (TObjString *) next()))
{
rootFile->AddLine(el->GetString());
}
}
else if (fileInfo.fFilename)
{
rootFile->Clear();
rootFile->AddLine(fileInfo.fFilename);
}
rootFile->NextChar();
rootFile->DelChar();
dir = fileInfo.fIniDir;
}
void DRGui::RunReducer()
{
ProcessNames();
TString tmpString;
TStopwatch time;
time.Start();
DataProcess* processor = new DataProcess();
processor->setCorrection(ctCorrection, stCorrection);
if (bCombineInput)
{
processor->setName(m_inputNames, inputNumber);
processor->setProcess(ptProcess);
processor->setOptions(bCol, bRow, bToT, bToA, bTrig, bTrigTime, bTrigToA, bProcTree, bCsv, bCentroid, m_gapPix, m_gapTime, bNoTrigWindow, timeWindow, timeStart, bSingleFile, linesPerFile);
processor->process();
}
else
{
for (int i = 0; i < inputNumber; i++)
{
tmpString = m_inputNames[i].GetString();
if (tmpString.EndsWith(".root"))
{
processor->setProcess(procRoot);
}
else if (tmpString.EndsWith(".dat") || tmpString.EndsWith(".tpx3"))
{
processor->setProcess(ptProcess);
}
processor->setName(tmpString);
processor->setOptions(bCol, bRow, bToT, bToA, bTrig, bTrigTime, bTrigToA, bProcTree, bCsv, bCentroid, m_gapPix, m_gapTime, bNoTrigWindow, timeWindow, timeStart, bSingleFile, linesPerFile);
processor->process();
}
}
time.Stop();
std::cout << std::endl;
std::cout << "###################################" << std::endl;
std::cout << "Total Runtime of the code: " << std::endl;
time.Print();
}
void DRGui::ProcessNames()
{
TString fileName = "";
TGText* inputFileNames = new TGText(rootFile->GetText());
TGText* correctionFileNames = new TGText(corrFile->GetText());
TGLongPosition pos = TGLongPosition(0,0);
Int_t lineNumber = 0;
Int_t lineLength = 0;
inputNumber = 0;
stCorrection = correctionFileNames->GetLine(pos,correctionFileNames->GetLineLength(0));
while( (lineLength = inputFileNames->GetLineLength(lineNumber)) != -1)
{
pos = TGLongPosition(0,lineNumber++);
fileName = inputFileNames->GetLine(pos,lineLength);
if (fileName.EndsWith(".root") || fileName.EndsWith(".dat") || fileName.EndsWith(".tpx3"))
{
cout << fileName << " " << inputNumber << endl;
m_inputNames[inputNumber++].SetString(fileName);
}
else
{
cout << " ========================================== " << endl;
cout << " ======== INVALID ENTRY FILE NAME ========= " << endl;
cout << fileName << endl;
cout << " ========================================== " << endl;
}
}
}
void DRGui::StopReducer()
{
cout << "===============================================" << endl;
cout << "======== REDUCER SUCCESSFULLY STOPPED =========" << endl;
cout << "===============================================" << endl;
gSystem->ExitLoop();
}