GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIOptions.cxx
Go to the documentation of this file.
1#include "TGRSIOptions.h"
2
3#include <algorithm>
4#include <cctype>
5#include <iostream>
6
7#include "TEnv.h"
8#include "TKey.h"
9#include "TSystem.h"
10
11#include "Globals.h"
12#include "FullPath.h"
13#include "ArgParser.h"
14#include "DynamicLibrary.h"
15#include "TGRSIUtilities.h"
16#include "GRootCommands.h"
17
21
22TGRSIOptions* TGRSIOptions::Get(int argc, char** argv)
23{
24 // The Getter for the singleton TGRSIOptions. This makes it
25 // so there is only ever one instance of the options during
26 // a session and it can be accessed from anywhere during that
27 // session.
28 if(fGRSIOptions == nullptr) {
29 fGRSIOptions = new TGRSIOptions(argc, argv);
30 }
31 return fGRSIOptions;
32}
33
34TGRSIOptions::TGRSIOptions(int argc, char** argv)
35{
36 /// Ctor used when interpreter is initialized
37 Load(argc, argv);
38}
39
40void TGRSIOptions::Clear(Option_t*)
41{
42 /// Clears all of the variables in the TGRSIOptions
43 fInputFiles.clear();
44 fInputRootFiles.clear();
45 fInputCalFiles.clear();
46 fInputOdbFiles.clear();
47 fExternalRunInfo.clear();
48 fMacroFiles.clear();
50
51 fInputCutFiles.clear();
52 fInputValFiles.clear();
53 fInputWinFiles.clear();
54 fInputRing = "";
55
61
65
66 fOptionsFile.clear();
67
68 fLogFile = "grsisort.log";
69
70 fCloseAfterSort = false;
71 fLogErrors = false;
72 fUseMidFileOdb = false;
73
74 fMakeAnalysisTree = false;
75 fUseRnTuple = false;
76 fReadingMaterial = false;
77 fIgnoreFileOdb = false;
78 fIgnoreOdbChannels = false;
79 fDownscaling = 1;
80
81 fIgnoreScaler = false;
82 fIgnoreEpics = false;
83 fWriteFragmentTree = false;
84 fWriteBadFrags = false;
85 fWriteDiagnostics = false;
86 fWordOffset = -1;
87
88 fBatch = false;
89
90 fShowedVersion = false;
91 fShowLogo = false;
92 fSortRaw = true;
93 fExtractWaves = false;
94 fIsOnline = false;
95 fStartGui = false;
96 fMakeHistos = false;
97 fSortMultiple = false;
98 fDebug = false;
99
102
103 fNumberOfEvents = 0;
104
105 fIgnoreMissingChannel = false;
106 fSkipInputSort = false;
107
108 fSeparateOutOfOrder = false;
109
110 fShouldExit = false;
111
112 fColumnWidth = 20;
113 fStatusWidth = 120;
114 fStatusInterval = 10;
115 fLongFileDescription = false;
116
119
120 // Proof only
121 fMaxWorkers = -1;
122 fSelectorOnly = false;
123 fTreeName.clear();
125 fParallelUnzip = false;
126 fCacheSize = -1;
127 fSubmergers = -1;
128 fProofStats = false;
129
130 fHelp = false;
131
132 fParserLibrary.clear();
133}
134
135void TGRSIOptions::Print(Option_t*) const
136{
137 /// Print the current status of TGRSIOptions, includes all names, lists and flags
138 std::cout << "fCloseAfterSort: " << fCloseAfterSort << std::endl
139 << "fLogErrors: " << fLogErrors << std::endl
140 << "fUseMidFileOdb: " << fUseMidFileOdb << std::endl
141 << "fSuppressErrors: " << fSuppressErrors << std::endl
142 << "fReconstructTimeStamp: " << fReconstructTimeStamp << std::endl
143 << std::endl
144 << "fMakeAnalysisTree: " << fMakeAnalysisTree << std::endl
145 << "fUseRnTuple: " << fUseRnTuple << std::endl
146 << "fReadingMaterial;: " << fReadingMaterial << std::endl
147 << "fIgnoreFileOdb: " << fIgnoreFileOdb << std::endl
148 << "fIgnoreOdbChannels: " << fIgnoreOdbChannels << std::endl
149 << "fDownscaling: " << fDownscaling << std::endl
150 << std::endl
151 << "fIgnoreScaler: " << fIgnoreScaler << std::endl
152 << "fIgnoreEpics: " << fIgnoreEpics << std::endl
153 << "fWriteFragmentTree: " << fWriteFragmentTree << std::endl
154 << "fWriteBadFrags: " << fWriteBadFrags << std::endl
155 << "fWriteDiagnostics: " << fWriteDiagnostics << std::endl
156 << "fWordOffset: " << fWordOffset << std::endl
157 << std::endl
158 << "fBatch: " << fBatch << std::endl
159 << std::endl
160 << "fShowedVersion: " << fShowedVersion << std::endl
161 << "fShowLogo: " << fShowLogo << std::endl
162 << "fSortRaw: " << fSortRaw << std::endl
163 << "fExtractWaves;: " << fExtractWaves << std::endl
164 << "fIsOnline: " << fIsOnline << std::endl
165 << "fStartGui: " << fStartGui << std::endl
166 << "fMakeHistos: " << fMakeHistos << std::endl
167 << "fSortMultiple: " << fSortMultiple << std::endl
168 << "fDebug: " << fDebug << std::endl
169 << "fLogFile: " << fLogFile << std::endl
170 << std::endl
171 << "fFragmentWriteQueueSize: " << fFragmentWriteQueueSize << std::endl
172 << "fAnalysisWriteQueueSize: " << fAnalysisWriteQueueSize << std::endl
173 << std::endl
174 << "fIgnoreMissingChannel: " << fIgnoreMissingChannel << std::endl
175 << "fSkipInputSort: " << fSkipInputSort << std::endl
176 << "fSortDepth: " << fSortDepth << std::endl
177 << std::endl
178 << "fSeparateOutOfOrder: " << fSeparateOutOfOrder << std::endl
179 << std::endl
180 << "fShouldExit: " << fShouldExit << std::endl
181 << std::endl
182 << "fColumnWidth: " << fColumnWidth << std::endl
183 << "fStatusWidth: " << fStatusWidth << std::endl
184 << "fStatusInterval: " << fStatusInterval << std::endl
185 << "fLongFileDescription: " << fLongFileDescription << std::endl
186 << std::endl
187 << "fMaxWorkers: " << fMaxWorkers << std::endl
188 << "fSelectorOnly: " << fSelectorOnly << std::endl
189 << "fTreeName: " << fTreeName << std::endl
190 << "fAverageRateEstimation: " << fAverageRateEstimation << std::endl
191 << "fParallelUnzip: " << fParallelUnzip << std::endl
192 << "fCacheSize: " << fCacheSize << std::endl
193 << "fSubmergers: " << fSubmergers << std::endl
194 << "fProofStats: " << fProofStats << std::endl
195 << std::endl
196 << "fHelp: " << fHelp << std::endl
197 << std::endl
198 << "fParserLibrary: " << fParserLibrary << std::endl;
199
201}
202
203void TGRSIOptions::Load(int argc, char** argv)
204{
205 /// This checks all of the options provided to GRSISort. This also loads in some
206 /// libraries in order to do on the fly histogramming.
207 Clear();
208 fFragmentHistogramLib = gEnv->GetValue("GRSI.FragmentHistLib", "");
209 fAnalysisHistogramLib = gEnv->GetValue("GRSI.AnalysisHistLib", "");
210
211 fParserLibrary = gEnv->GetValue("GRSI.ParserLibrary", "");
212
213 // Load default TChannels, if specified.
214 {
215 std::string default_calfile = gEnv->GetValue("GRSI.CalFile", "");
216 if(default_calfile.length() != 0u) {
217 fInputCalFiles.push_back(default_calfile);
218 }
219 }
220
221 // Load default GValues, if specified.
222 {
223 std::string default_valfile = gEnv->GetValue("GRSI.ValFile", "");
224 if(default_valfile.length() != 0u) {
225 fInputValFiles.push_back(default_valfile);
226 }
227 }
228
229 // Get name of the program calling this function (removing any path from the name)
230 std::string program;
231 if(argc > 0) {
232 program = argv[0];
233 } else {
234 program = "unknown";
235 }
236 size_t lastSlash = program.rfind('/');
237 if(lastSlash != std::string::npos) {
238 program.erase(0, lastSlash + 1);
239 }
240
241 ArgParser parser;
242 bool useRecommendedFlags = false;
243
244 std::vector<std::string> input_files;
245 std::string default_file_format;
246
247 // parser.option() will initialize boolean values to false.
248
249 // general options
250 // these options are all to be set directly on the first parsing pass, so we set the firstPass flag to true
251 parser.default_option(&input_files, true).description("Input file(s)");
252 parser.option("h help ?", &fHelp, true).description("Show this help message");
253 parser.option("v version", &fShowedVersion, true).description("Show the version of GRSISort");
254
255 // analysis options, these options are to be parsed on the second pass, so firstPass is set to false
256 parser.option("build-window", &fAnalysisOptions->fBuildWindow, false)
257 .description("Build window, in ns.")
258 .colour(DCYAN);
259 parser.option("build-events-by-timestamp", &fAnalysisOptions->fBuildEventsByTimeStamp, false)
260 .description("Build events by timestamp w/o using CFD")
261 .colour(DCYAN);
262 parser.option("addback-window", &fAnalysisOptions->fAddbackWindow, false)
263 .description("Addback window, time in ns")
264 .colour(DCYAN);
265 parser.option("suppression-window", &fAnalysisOptions->fSuppressionWindow, false)
266 .description("BGO suppression window, time in ns")
267 .colour(DCYAN);
268 parser.option("suppression-energy", &fAnalysisOptions->fSuppressionEnergy, false)
269 .description("Minimum BGO energy for suppression")
270 .colour(DCYAN);
271 parser.option("static-window", &fAnalysisOptions->fStaticWindow, false)
272 .description("Use static window for event building")
273 .colour(DCYAN);
274 parser.option("waveform-fitting", &fAnalysisOptions->fWaveformFitting, false)
275 .description("Fit waveforms using SFU algorithms")
276 .colour(DCYAN);
277 parser.option("is-correcting-cross-talk", &fAnalysisOptions->fIsCorrectingCrossTalk, false)
278 .description("Correct cross-talk")
279 .colour(DCYAN);
280
281 // program specific options
282 if(program == "grsisort") {
283 // grsisort only options
284 parser.option("recommended", &useRecommendedFlags, true).description("Use recommended flags (those in " DGREEN "dark green" GREEN ")").colour(GREEN);
285 parser.option("output-fragment-tree", &fOutputFragmentFile, true).description("Filename of output fragment tree");
286 parser.option("output-analysis-tree", &fOutputAnalysisFile, true).description("Filename of output analysis tree");
287 parser.option("output-fragment-hists", &fOutputFragmentHistogramFile, true)
288 .description("Filename of output fragment hists");
289 parser.option("output-analysis-hists", &fOutputAnalysisHistogramFile, true)
290 .description("Filename of output analysis hists");
291
292 parser.option("a", &fMakeAnalysisTree, true).description("Make the analysis tree").colour(DGREEN);
293 parser.option("use-rntuple", &fUseRnTuple, true).description("Use experimental RNTuple instead of TTree");
294 parser.option("H histos", &fMakeHistos, true).description("Attempt to run events through MakeHisto lib");
295 parser.option("g start-gui", &fStartGui, true).description("Start the gui at program start");
296 parser.option("b batch", &fBatch, true).description("Run in batch mode");
297
298 parser.option("sort-depth", &fSortDepth, true)
299 .description("Number of events to hold when sorting by time/trigger_id")
300 .default_value(200000);
301
302 parser.option("q quit", &fCloseAfterSort, true).description("Quit after completing the sort").colour(DGREEN);
303 parser.option("l no-logo", &fShowLogo, true).description("Inhibit the startup logo").default_value(true).colour(DGREEN);
304 parser.option("w extract-waves", &fExtractWaves, true)
305 .description("Extract wave forms to data class when available.")
306 .default_value(false);
307 parser.option("d debug", &fDebug, true)
308 .description("Write debug information to output/file, e.g. enables writing of TDescantDebug at analysis stage")
309 .default_value(false);
310 parser.option("write-diagnostics", &fWriteDiagnostics, true).description("Write Parsing/SortingDiagnostics to root-file").colour(DGREEN);
311 parser.option("word-count-offset", &fWordOffset, true)
312 .description("Offset to the word count in the GRIFFIN header word, default is -1 (disabled).")
313 .default_value(-1)
314 .colour(DGREEN);
315 parser.option("log-errors", &fLogErrors, true);
316 parser.option("reading-material", &fReadingMaterial, true);
317 parser.option("write-fragment-tree write-frag-tree", &fWriteFragmentTree, true)
318 .description("Write fragment tree.")
319 .colour(DGREEN);
320 parser.option("bad-frags write-bad-frags bad-fragments write-bad-fragments", &fWriteBadFrags, true)
321 .description("Write fragments that failed parsing to BadFragmentTree")
322 .colour(DGREEN);
323 parser.option("separate-out-of-order", &fSeparateOutOfOrder, true)
324 .description("Write out-of-order fragments to a separate tree at the sorting stage")
325 .default_value(false)
326 .colour(DGREEN);
327 parser.option("ignore-odb", &fIgnoreFileOdb, true);
328 parser.option("ignore-odb-channels", &fIgnoreOdbChannels, true);
329 parser.option("downscaling", &fDownscaling, true).description("Downscaling factor for raw events to be processed").default_value(1);
330 parser.option("ignore-epics", &fIgnoreEpics, true);
331 parser.option("ignore-scaler", &fIgnoreScaler, true);
332 parser.option("suppress-error suppress-errors suppress_error suppress_errors", &fSuppressErrors, true)
333 .description("Suppress error output from parsing")
334 .colour(DGREEN);
335 parser.option("reconstruct-timestamp reconstruct-time-stamp", &fReconstructTimeStamp, true)
336 .description("Reconstruct missing high bits of timestamp")
337 .colour(DGREEN);
338 parser.option("ignore-missing-channel", &fIgnoreMissingChannel, true)
339 .description("Ignore missing channels completely (not written to fragment or analysis tree)")
340 .default_value(false);
341 parser.option("skip-input-sort", &fSkipInputSort, true)
342 .description("Skip sorting fragments before building events (default is false)")
343 .default_value(false);
344
345 parser.option("fragment-size", &fFragmentWriteQueueSize, true)
346 .description("Size of fragment write queue")
347 .default_value(10000000);
348 parser.option("analysis-size", &fAnalysisWriteQueueSize, true)
349 .description("Size of analysis write queue")
350 .default_value(1000000);
351
352 parser.option("column-width", &fColumnWidth, true).description("Width of one column of status").default_value(20);
353 parser.option("status-width", &fStatusWidth, true)
354 .description("Number of characters to be used for status output")
355 .default_value(120);
356 parser.option("status-interval", &fStatusInterval, true)
357 .description(
358 "Seconds between each detailed status output (each a new line), non-positive numbers mean no detailed status")
359 .default_value(10);
360 } else if(program == "grsiproof") {
361 // Proof only parser options
362 parser.option("max-workers", &fMaxWorkers, true)
363 .description("Max number of nodes to use when running a grsiproof session")
364 .default_value(-1);
365
366 parser.option("selector-only", &fSelectorOnly, true)
367 .description("Turns off PROOF to run a selector on the main thread");
368 parser.option("log-file", &fLogFile, true).description("File logs from grsiproof are written to");
369
370 parser.option("tree-name", &fTreeName, true)
371 .description("Name of tree to be proofed, default is empty, i.e. FragmentTree, AnalysisTree, and Lst2RootTree are checked");
372 parser.option("average-rate", &fAverageRateEstimation, true)
373 .description("use average rate instead of current rate");
374 parser.option("parallel-unzip", &fParallelUnzip, true)
375 .description("use parallel unzipping of input files");
376 parser.option("cache-size", &fCacheSize, true)
377 .description("set tree cache size (default = -1 = off)");
378 parser.option("sub-mergers", &fSubmergers, true)
379 .description("use sub mergers to merge result from workers (default = -1 = off, 0 = automatic number of mergers)");
380 parser.option("proof-stats", &fProofStats, true)
381 .description("enable proof stats");
382 } else if(program == "grsiframe") {
383 // grsiframe only parser options
384 parser.option("max-workers", &fMaxWorkers, true)
385 .description("Maximum number of nodes to use when running a grsiframe session")
386 .default_value(1);
387 parser.option("tree-name", &fTreeName, true)
388 .description("Name of tree to be used, default is empty, i.e. FragmentTree, and AnalysisTree are checked");
389 parser.option("d debug", &fDebug, true)
390 .description("Increases verbosity of RDataFrame (also turns off the progress bar)")
391 .default_value(false);
392 }
393
394 if(program == "grsiframe") {
395 // grsisort or grsiproof options
396 parser.option("max-events", &fNumberOfEvents, true)
397 .description("Maximum number of (midas, lst, rlmd, or tdr) events read")
398 .default_value(0);
399 }
400
401 // look for any arguments ending with .info, pass to parser.
402 for(int i = 1; i < argc; i++) {
403 std::string filename = argv[i];
405 try {
406 parser.parse_file(filename);
407 } catch(ParseError& e) {
408 std::cerr << "ERROR: " << e.what() << "\n"
409 << parser << std::endl;
410 throw;
411 }
412 }
413 }
414
415 // Look at the command line.
416 try {
417 parser.parse(argc, argv, true);
418 } catch(ParseError& e) {
419 std::cerr << "ERROR: " << e.what() << "\n"
420 << parser << std::endl;
421 throw;
422 }
423
424 // Print version if requested
425 if(fShowedVersion) {
426 Version();
427 fShouldExit = true;
428 }
429
430 // print help if required
431 if(fHelp) {
432 std::cout << parser << std::endl;
433 fShouldExit = true;
434 }
435
436 if(fOutputFragmentHistogramFile.length() > 0 && fOutputFragmentHistogramFile != "none") {
437 fMakeHistos = true;
438 }
439 if(fOutputAnalysisHistogramFile.length() > 0 && fOutputAnalysisHistogramFile != "none") {
440 fMakeHistos = true;
441 }
442
443 for(auto& file : input_files) {
444 FileAutoDetect(file);
445 }
446
447 // load any additional parser library
448 if(!fParserLibrary.empty()) {
449 gSystem->Load(fParserLibrary.c_str());
450 }
451
452 // read analysis options from input file(s)
453 for(const std::string& file : fInputRootFiles) {
455 }
456 // parse analysis options from command line options
457 try {
458 parser.parse(argc, argv, false);
459 } catch(ParseError& e) {
460 std::cerr << "ERROR: " << e.what() << "\n"
461 << parser << std::endl;
462 throw;
463 }
464 if(useRecommendedFlags) {
465 fMakeAnalysisTree = true;
466 fShowLogo = false;
467 fCloseAfterSort = true;
468 fWriteDiagnostics = true;
469 fWriteFragmentTree = true;
470 fWriteBadFrags = true;
471 fSeparateOutOfOrder = true;
472 fSuppressErrors = true;
474 fWordOffset = -1;
475 }
476}
477
478kFileType TGRSIOptions::DetermineFileType(const std::string& filename)
479{
480 size_t dotPos = filename.find_last_of('.');
481 size_t slashPos = filename.find_last_of('/');
482 // if we didn't find a . (or if it was before the last /) we don't have any extension
483 // => so it's a TDR file
484 if(dotPos == std::string::npos || (dotPos < slashPos && slashPos != std::string::npos)) {
485 return kFileType::TDR_FILE;
486 }
487 std::string ext = filename.substr(dotPos + 1);
488
489 // check if this is a zipped file and if so get the extension before the zip-extension
490 bool isZipped = (ext == "gz") || (ext == "bz2") || (ext == "zip");
491 if(isZipped) {
492 std::string remaining = filename.substr(0, dotPos);
493 ext = remaining.substr(remaining.find_last_of('.') + 1);
494 }
495
496 if(ext == "mid") {
498 }
499 if(ext == "lst") {
500 return kFileType::LST_FILE;
501 }
502 if(ext == "rlmd") {
504 }
505 if(ext == "evt") {
506 return kFileType::NSCL_EVT;
507 }
508 if(ext == "cal") {
510 }
511 if(ext == "root") {
513 }
514 if((ext == "cxx")) {
516 }
517 if((ext == "c") || (ext == "C") || (ext == "c+") || (ext == "C+") || (ext == "c++") || (ext == "C++")) {
519 }
520 if(ext == "dat" || ext == "cvt") {
521 if(filename.find("GlobalRaw") != std::string::npos) {
523 }
525 }
526 if(ext == "hist") {
528 }
529 if(ext == "so") {
531 }
532 if(ext == "info") {
534 }
535 if(ext == "val") {
536 return kFileType::GVALUE;
537 }
538 if(ext == "par") {
540 }
541 if(ext == "win") {
543 }
544 if(ext == "cuts") {
546 }
547 if(ext == "xml") {
548 return kFileType::XML_FILE;
549 }
550
551 // strip possible parenthese with arguments for the script from the extension
552 size_t openingPos = ext.find_first_of('(');
553 if(openingPos != std::string::npos) {
554 ext = ext.substr(0, openingPos);
555 if((ext == "c") || (ext == "C") || (ext == "c+") || (ext == "C+") || (ext == "c++") || (ext == "C++")) {
557 }
558 }
560}
561
562bool TGRSIOptions::FileAutoDetect(const std::string& filename)
563{
564 /// Detects the type of file provided on the command line. This uses the extension to determine
565 /// the type of the file. Once the type is determined, the file is sent to the appropriate list
566 /// in TGRSIOptions. This is also smart enough to dynamically link histogramming libraries.
567 switch(DetermineFileType(filename)) {
574 case kFileType::MIDAS_FILE: fInputFiles.push_back(filename); return true;
575
576 case kFileType::ROOT_DATA: fInputRootFiles.push_back(filename); return true;
577
578 case kFileType::ROOT_MACRO: fMacroFiles.push_back(filename); return true;
579
580 case kFileType::CALIBRATED: fInputCalFiles.push_back(filename); return true;
581
582 case kFileType::DATAFRAME: fDataFrameLibrary = full_path(filename); return true;
583
585 bool used = false;
586 // need absolute path not relative path in case the current working directory is not in LD_LIBRARY_PATH
587 std::string fullFilename = full_path(filename);
588 DynamicLibrary lib(fullFilename);
589 if(lib.GetSymbol("MakeFragmentHistograms") != nullptr) {
590 fFragmentHistogramLib = fullFilename;
591 used = true;
592 }
593 if(lib.GetSymbol("MakeAnalysisHistograms") != nullptr) {
594 fAnalysisHistogramLib = fullFilename;
595 used = true;
596 }
597 if(lib.GetSymbol("CreateParser") != nullptr && lib.GetSymbol("DestroyParser") != nullptr &&
598 lib.GetSymbol("CreateFile") != nullptr && lib.GetSymbol("DestroyFile") != nullptr) {
599 fParserLibrary = fullFilename;
600 used = true;
601 }
602 if(lib.GetSymbol("CreateHelper") != nullptr && lib.GetSymbol("DestroyHelper") != nullptr) {
603 fDataFrameLibrary = fullFilename;
604 used = true;
605 }
606 if(!used) {
607 std::cerr << fullFilename << " did not contain MakeFragmentHistograms or MakeAnalysisHistograms or CreateParser and others or CreateHelper and DestroyHelper" << std::endl;
608 }
609 return used;
610 }
611
612 case kFileType::GVALUE: fInputValFiles.push_back(filename); return true;
613
615 // if we haven't read any user setting create new ones and read the file, otherwise just read the file
616 if(fUserSettings == nullptr) {
617 fUserSettings = new TUserSettings(filename);
618 } else {
619 fUserSettings->ReadSettings(filename);
620 }
621 return true;
622
623 case kFileType::PRESETWINDOW: fInputWinFiles.push_back(filename); return true;
624
625 case kFileType::CUTS_FILE: fInputCutFiles.push_back(filename); return true;
626
627 case kFileType::CONFIG_FILE: return false;
628
629 case kFileType::XML_FILE: fInputOdbFiles.push_back(filename); return true;
630
632 default: std::cout << "\tDiscarding unknown file: " << filename << std::endl; return false;
633 }
634}
635
637{
638 /// Writes options information to the tree
639 // Maintain old gDirectory info
640 bool success = true;
641 TDirectory* oldDir = gDirectory;
642
643 if(file == nullptr) {
644 file = gDirectory->GetFile();
645 }
646 file->cd();
647 std::string oldoption = std::string(file->GetOption());
648 if(oldoption == "READ") {
649 file->ReOpen("UPDATE");
650 }
651 if(!gDirectory) { // we don't compare to nullptr here, as ROOT >= 6.24.00 uses the TDirectoryAtomicAdapter structure with a bool() operator
652 std::cout << "No file opened to write TGRSIOptions to." << std::endl;
653 success = false;
654 } else {
655 Get()->Write("GRSIOptions", TObject::kOverwrite);
657 if(!fUserSettings->empty()) { fUserSettings->Write("UserSettings", TObject::kOverwrite); }
658 }
659
660 std::cout << "Writing TGRSIOptions to " << gDirectory->GetFile()->GetName() << std::endl;
661 if(oldoption == "READ") {
662 std::cout << " Returning " << gDirectory->GetFile()->GetName() << " to \"" << oldoption << "\" mode." << std::endl;
663 file->ReOpen("READ");
664 }
665 oldDir->cd(); // Go back to original gDirectory
666
667 return success;
668}
669
671{
672 // Sets the TGRSIOptions to the info passes as tmp.
673 if((fGRSIOptions != nullptr) && (tmp != fGRSIOptions)) {
674 delete fGRSIOptions;
675 }
676 fGRSIOptions = tmp;
677}
678
679Bool_t TGRSIOptions::ReadFromFile(TFile* file)
680{
681 TDirectory* oldDir = gDirectory;
682 if(file != nullptr) {
683 file->cd();
684 }
685
686 if(gDirectory->GetFile() == nullptr) {
687 std::cout << "File does not exist" << std::endl;
688 oldDir->cd();
689 return false;
690 }
691
692 file = gDirectory->GetFile();
693
694 TList* list = file->GetListOfKeys();
695 TIter iter(list);
696 std::cout << "Reading options from file: " << CYAN << file->GetName() << RESET_COLOR << std::endl;
697 while(TKey* key = static_cast<TKey*>(iter.Next())) {
698 if((key == nullptr) || (strcmp(key->GetClassName(), "TGRSIOptions") != 0)) {
699 continue;
700 }
701
702 TGRSIOptions::SetOptions(static_cast<TGRSIOptions*>(key->ReadObj()));
703 oldDir->cd();
704 return true;
705 }
706 oldDir->cd();
707
708 return false;
709}
std::string full_path(const std::string &path)
Definition FullPath.cxx:9
void Version()
#define DGREEN
Definition Globals.h:17
#define DCYAN
Definition Globals.h:21
#define GREEN
Definition Globals.h:8
#define CYAN
Definition Globals.h:12
#define RESET_COLOR
Definition Globals.h:5
kFileType
Definition TGRSITypes.h:9
@ COMPILED_SHARED_LIBRARY
@ UNKNOWN_FILETYPE
void parse(int argc, char **argv, bool firstPass)
Definition ArgParser.h:333
ArgParseConfigT< T > & option(const std::string flag, T *output_location, bool firstPass)
Definition ArgParser.h:412
void parse_file(std::string &filename)
Definition ArgParser.h:365
ArgParseConfigT< std::vector< T > > & default_option(std::vector< T > *output_location, bool firstPass)
Definition ArgParser.h:420
Loads a Shared Object library.
void * GetSymbol(const char *symbol)
Extracts a symbol from the shared library.
bool fIsCorrectingCrossTalk
True if we are correcting for cross-talk in GRIFFIN at analysis-level.
bool WriteToFile(const std::string &file)
double fSuppressionEnergy
Minimum energy used to suppress Ge-Events. (default = 0 keV)
int64_t fBuildWindow
if building with a window(GRIFFIN) this is the size of the window. (default = 2us (2000))
void Print(Option_t *opt="") const override
double fSuppressionWindow
Time used to suppress Ge-Events. (default = 300 ns (300))
void Clear(Option_t *opt="") override
bool fBuildEventsByTimeStamp
use time stamps instead of time (including CFD) to build events
double fAddbackWindow
Time used to build Addback-Ge-Events for TIGRESS/GRIFFIN. (default = 300 ns (300))
bool fWaveformFitting
If true, waveform fitting with SFU algorithm will be performed.
void ReadFromFile(const std::string &file)
bool fStaticWindow
Flag to use static window (default moving)
bool fIgnoreScaler
Flag to ignore scalers in GRIFFIN.
std::string fTreeName
Name of tree to be analyzed (default is empty, i.e. FragmentTree, AnalysisTree, and Lst2RootTree are ...
bool fWriteDiagnostics
Flag to write diagnostics.
void Load(int argc, char **argv)
bool fReadingMaterial
Flag to show reading material (–reading-material)
bool fShouldExit
Flag to exit sorting.
std::vector< std::string > fInputFiles
A list of the input files.
bool fWriteBadFrags
Flag to write bad fragments.
std::vector< std::string > fInputValFiles
A list of the input GValue files.
bool fSeparateOutOfOrder
Flag to build out of order into seperate event tree.
static kFileType DetermineFileType(const std::string &filename)
bool fCloseAfterSort
Flag to close after sorting (-q)
static TGRSIOptions * Get(int argc=0, char **argv=nullptr)
Do not use!
bool fIgnoreFileOdb
Flag to ignore midas file odb.
std::vector< std::string > fInputCutFiles
A list of input cut files.
std::string fInputRing
The name of hte input ring.
bool fSortRaw
Flag to sort raw file.
bool fProofStats
enable proof stats
static TAnalysisOptions * fAnalysisOptions
contains all options for analysis
unsigned int fStatusInterval
Time between status updates.
size_t fAnalysisWriteQueueSize
Size of the analysis write Q.
bool fMakeAnalysisTree
Flag to make analysis tree (-a)
size_t fStatusWidth
Size of total verbose status.
bool fSelectorOnly
Flag to turn PROOF off in grsiproof.
std::vector< std::string > fInputCalFiles
A list of the input cal files.
std::string fOutputFragmentFile
The name of the fragment file to write to.
std::string fAnalysisHistogramLib
The name of the script for histogramming events.
int fWordOffset
Offset for word count in GRIFFIN header (default 1)
static TGRSIOptions * fGRSIOptions
int fCacheSize
set tree cache size, default is -1 (off)
std::string fFragmentHistogramLib
The name of the script for histogramming fragments.
int fMaxWorkers
Max workers used in grsiproof.
int fDownscaling
Downscaling factor for raw events to be processed.
bool fExtractWaves
Flag to keep waveforms (suppress with –no-waveforms)
bool fIgnoreMissingChannel
Flag to completely ignore missing channels.
std::vector< std::string > fOptionsFile
A list of the input .info files.
std::string fOutputFilteredFile
bool fLogErrors
Flag to log errors (–log-errors)
bool fSuppressErrors
Flag to suppress errors (–suppress-errors)
bool fSkipInputSort
Flag to sort on time or triggers.
int fSubmergers
set number of sub-mergers (0 = automatic), default is -1 (off)
bool fStartGui
Flag to start GUI (-g)
std::string fDataFrameLibrary
library (or .cxx file) for dataframe processing (used with grsiframe)
static void SetOptions(TGRSIOptions *tmp)
TGRSIOptions()=default
int fSortDepth
Size of Q that stores fragments to be built into events.
static bool WriteToFile(TFile *file=nullptr)
bool fReconstructTimeStamp
Flag to reconstruct missing high bits of time stamps (–reconstruct-timestamp)
std::string fOutputAnalysisFile
The name of the analysis file to write to.
void Clear(Option_t *opt="") override
bool fHelp
help requested?
static Bool_t ReadFromFile(TFile *file=nullptr)
std::string fOutputAnalysisHistogramFile
The name of the analysis histogram file.
size_t fNumberOfEvents
Number of events, fragments, etc. to process (0 - all)
bool fIgnoreEpics
Flag to ignore epics.
std::string fLogFile
The name of the output log file.
bool fBatch
Flag to use batch mode (-b)
size_t fColumnWidth
Size of verbose columns.
bool fIsOnline
Flag to sort online data.
std::vector< std::string > fInputWinFiles
A list of the input window files.
bool fSortMultiple
Flag to sort multiple files.
bool fIgnoreOdbChannels
Flag to ignore channels from midas file odb (but do use EPICS from ODB)
std::string fCompiledFilterFile
size_t fFragmentWriteQueueSize
Size of the Fragment write Q.
bool fMakeHistos
Flag to make histograms (-H)
void Print(Option_t *opt="") const override
bool fDebug
Flag for debug mode.
bool fParallelUnzip
enable use of parallel unzipping
bool fShowedVersion
Flag to show version.
bool fAverageRateEstimation
enable average rate estimation
std::string fParserLibrary
location of shared object library for data parser and files
bool fUseRnTuple
Flag to use experimental TRNTuple instead of TTree.
std::vector< std::string > fInputRootFiles
A list of the input root files.
bool fShowLogo
Flag to show logo (suppress with -l)
bool fLongFileDescription
bool fWriteFragmentTree
Flag to write fragment tree.
std::vector< std::string > fMacroFiles
A list of the input macro (.C) files.
bool FileAutoDetect(const std::string &filename)
bool fUseMidFileOdb
Flag to read odb from midas.
static TUserSettings * fUserSettings
contains user settings read from text-file
std::vector< std::string > fExternalRunInfo
A list of the input run info files.
std::vector< std::string > fInputOdbFiles
A list of the input odb files.
std::string fOutputFragmentHistogramFile
The name of the fragment histogram file.
void Clear(Option_t *="") override
bool ReadSettings(const std::string &settingsFile)