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 parser.option("bad-frags write-bad-frags bad-fragments write-bad-fragments", &fWriteBadFrags, true)
320 .description("Write fragments that failed parsing to BadFragmentTree");
321 parser.option("separate-out-of-order", &fSeparateOutOfOrder, true)
322 .description("Write out-of-order fragments to a separate tree at the sorting stage")
323 .default_value(false)
324 .colour(DGREEN);
325 parser.option("ignore-odb", &fIgnoreFileOdb, true);
326 parser.option("ignore-odb-channels", &fIgnoreOdbChannels, true);
327 parser.option("downscaling", &fDownscaling, true).description("Downscaling factor for raw events to be processed").default_value(1);
328 parser.option("ignore-epics", &fIgnoreEpics, true);
329 parser.option("ignore-scaler", &fIgnoreScaler, true);
330 parser.option("suppress-error suppress-errors suppress_error suppress_errors", &fSuppressErrors, true)
331 .description("Suppress error output from parsing")
332 .colour(DGREEN);
333 parser.option("reconstruct-timestamp reconstruct-time-stamp", &fReconstructTimeStamp, true)
334 .description("Reconstruct missing high bits of timestamp")
335 .colour(DGREEN);
336 parser.option("ignore-missing-channel", &fIgnoreMissingChannel, true)
337 .description("Ignore missing channels completely (not written to fragment or analysis tree)")
338 .default_value(false);
339 parser.option("skip-input-sort", &fSkipInputSort, true)
340 .description("Skip sorting fragments before building events (default is false)")
341 .default_value(false);
342
343 parser.option("fragment-size", &fFragmentWriteQueueSize, true)
344 .description("Size of fragment write queue")
345 .default_value(10000000);
346 parser.option("analysis-size", &fAnalysisWriteQueueSize, true)
347 .description("Size of analysis write queue")
348 .default_value(1000000);
349
350 parser.option("column-width", &fColumnWidth, true).description("Width of one column of status").default_value(20);
351 parser.option("status-width", &fStatusWidth, true)
352 .description("Number of characters to be used for status output")
353 .default_value(120);
354 parser.option("status-interval", &fStatusInterval, true)
355 .description(
356 "Seconds between each detailed status output (each a new line), non-positive numbers mean no detailed status")
357 .default_value(10);
358 } else if(program == "grsiproof") {
359 // Proof only parser options
360 parser.option("max-workers", &fMaxWorkers, true)
361 .description("Max number of nodes to use when running a grsiproof session")
362 .default_value(-1);
363
364 parser.option("selector-only", &fSelectorOnly, true)
365 .description("Turns off PROOF to run a selector on the main thread");
366 parser.option("log-file", &fLogFile, true).description("File logs from grsiproof are written to");
367
368 parser.option("tree-name", &fTreeName, true)
369 .description("Name of tree to be proofed, default is empty, i.e. FragmentTree, AnalysisTree, and Lst2RootTree are checked");
370 parser.option("average-rate", &fAverageRateEstimation, true)
371 .description("use average rate instead of current rate");
372 parser.option("parallel-unzip", &fParallelUnzip, true)
373 .description("use parallel unzipping of input files");
374 parser.option("cache-size", &fCacheSize, true)
375 .description("set tree cache size (default = -1 = off)");
376 parser.option("sub-mergers", &fSubmergers, true)
377 .description("use sub mergers to merge result from workers (default = -1 = off, 0 = automatic number of mergers)");
378 parser.option("proof-stats", &fProofStats, true)
379 .description("enable proof stats");
380 } else if(program == "grsiframe") {
381 // grsiframe only parser options
382 parser.option("max-workers", &fMaxWorkers, true)
383 .description("Maximum number of nodes to use when running a grsiframe session")
384 .default_value(1);
385 parser.option("tree-name", &fTreeName, true)
386 .description("Name of tree to be used, default is empty, i.e. FragmentTree, and AnalysisTree are checked");
387 parser.option("d debug", &fDebug, true)
388 .description("Increases verbosity of RDataFrame (also turns off the progress bar)")
389 .default_value(false);
390 }
391
392 if(program == "grsiframe") {
393 // grsisort or grsiproof options
394 parser.option("max-events", &fNumberOfEvents, true)
395 .description("Maximum number of (midas, lst, rlmd, or tdr) events read")
396 .default_value(0);
397 }
398
399 // look for any arguments ending with .info, pass to parser.
400 for(int i = 1; i < argc; i++) {
401 std::string filename = argv[i];
403 try {
404 parser.parse_file(filename);
405 } catch(ParseError& e) {
406 std::cerr << "ERROR: " << e.what() << "\n"
407 << parser << std::endl;
408 throw;
409 }
410 }
411 }
412
413 // Look at the command line.
414 try {
415 parser.parse(argc, argv, true);
416 } catch(ParseError& e) {
417 std::cerr << "ERROR: " << e.what() << "\n"
418 << parser << std::endl;
419 throw;
420 }
421
422 // Print version if requested
423 if(fShowedVersion) {
424 Version();
425 fShouldExit = true;
426 }
427
428 // print help if required
429 if(fHelp) {
430 std::cout << parser << std::endl;
431 fShouldExit = true;
432 }
433
434 if(fOutputFragmentHistogramFile.length() > 0 && fOutputFragmentHistogramFile != "none") {
435 fMakeHistos = true;
436 }
437 if(fOutputAnalysisHistogramFile.length() > 0 && fOutputAnalysisHistogramFile != "none") {
438 fMakeHistos = true;
439 }
440
441 for(auto& file : input_files) {
442 FileAutoDetect(file);
443 }
444
445 // load any additional parser library
446 if(!fParserLibrary.empty()) {
447 gSystem->Load(fParserLibrary.c_str());
448 }
449
450 // read analysis options from input file(s)
451 for(const std::string& file : fInputRootFiles) {
453 }
454 // parse analysis options from command line options
455 try {
456 parser.parse(argc, argv, false);
457 } catch(ParseError& e) {
458 std::cerr << "ERROR: " << e.what() << "\n"
459 << parser << std::endl;
460 throw;
461 }
462 if(useRecommendedFlags) {
463 fMakeAnalysisTree = true;
464 fShowLogo = false;
465 fCloseAfterSort = true;
466 fWriteDiagnostics = true;
467 fSeparateOutOfOrder = true;
468 fSuppressErrors = true;
470 fWordOffset = -1;
471 }
472}
473
474kFileType TGRSIOptions::DetermineFileType(const std::string& filename)
475{
476 size_t dotPos = filename.find_last_of('.');
477 size_t slashPos = filename.find_last_of('/');
478 // if we didn't find a . (or if it was before the last /) we don't have any extension
479 // => so it's a TDR file
480 if(dotPos == std::string::npos || (dotPos < slashPos && slashPos != std::string::npos)) {
481 return kFileType::TDR_FILE;
482 }
483 std::string ext = filename.substr(dotPos + 1);
484
485 // check if this is a zipped file and if so get the extension before the zip-extension
486 bool isZipped = (ext == "gz") || (ext == "bz2") || (ext == "zip");
487 if(isZipped) {
488 std::string remaining = filename.substr(0, dotPos);
489 ext = remaining.substr(remaining.find_last_of('.') + 1);
490 }
491
492 if(ext == "mid") {
494 }
495 if(ext == "lst") {
496 return kFileType::LST_FILE;
497 }
498 if(ext == "rlmd") {
500 }
501 if(ext == "evt") {
502 return kFileType::NSCL_EVT;
503 }
504 if(ext == "cal") {
506 }
507 if(ext == "root") {
509 }
510 if((ext == "cxx")) {
512 }
513 if((ext == "c") || (ext == "C") || (ext == "c+") || (ext == "C+") || (ext == "c++") || (ext == "C++")) {
515 }
516 if(ext == "dat" || ext == "cvt") {
517 if(filename.find("GlobalRaw") != std::string::npos) {
519 }
521 }
522 if(ext == "hist") {
524 }
525 if(ext == "so") {
527 }
528 if(ext == "info") {
530 }
531 if(ext == "val") {
532 return kFileType::GVALUE;
533 }
534 if(ext == "par") {
536 }
537 if(ext == "win") {
539 }
540 if(ext == "cuts") {
542 }
543 if(ext == "xml") {
544 return kFileType::XML_FILE;
545 }
546
547 // strip possible parenthese with arguments for the script from the extension
548 size_t openingPos = ext.find_first_of('(');
549 if(openingPos != std::string::npos) {
550 ext = ext.substr(0, openingPos);
551 if((ext == "c") || (ext == "C") || (ext == "c+") || (ext == "C+") || (ext == "c++") || (ext == "C++")) {
553 }
554 }
556}
557
558bool TGRSIOptions::FileAutoDetect(const std::string& filename)
559{
560 /// Detects the type of file provided on the command line. This uses the extension to determine
561 /// the type of the file. Once the type is determined, the file is sent to the appropriate list
562 /// in TGRSIOptions. This is also smart enough to dynamically link histogramming libraries.
563 switch(DetermineFileType(filename)) {
570 case kFileType::MIDAS_FILE: fInputFiles.push_back(filename); return true;
571
572 case kFileType::ROOT_DATA: fInputRootFiles.push_back(filename); return true;
573
574 case kFileType::ROOT_MACRO: fMacroFiles.push_back(filename); return true;
575
576 case kFileType::CALIBRATED: fInputCalFiles.push_back(filename); return true;
577
578 case kFileType::DATAFRAME: fDataFrameLibrary = full_path(filename); return true;
579
581 bool used = false;
582 // need absolute path not relative path in case the current working directory is not in LD_LIBRARY_PATH
583 std::string fullFilename = full_path(filename);
584 DynamicLibrary lib(fullFilename);
585 if(lib.GetSymbol("MakeFragmentHistograms") != nullptr) {
586 fFragmentHistogramLib = fullFilename;
587 used = true;
588 }
589 if(lib.GetSymbol("MakeAnalysisHistograms") != nullptr) {
590 fAnalysisHistogramLib = fullFilename;
591 used = true;
592 }
593 if(lib.GetSymbol("CreateParser") != nullptr && lib.GetSymbol("DestroyParser") != nullptr &&
594 lib.GetSymbol("CreateFile") != nullptr && lib.GetSymbol("DestroyFile") != nullptr) {
595 fParserLibrary = fullFilename;
596 used = true;
597 }
598 if(lib.GetSymbol("CreateHelper") != nullptr && lib.GetSymbol("DestroyHelper") != nullptr) {
599 fDataFrameLibrary = fullFilename;
600 used = true;
601 }
602 if(!used) {
603 std::cerr << fullFilename << " did not contain MakeFragmentHistograms or MakeAnalysisHistograms or CreateParser and others or CreateHelper and DestroyHelper" << std::endl;
604 }
605 return used;
606 }
607
608 case kFileType::GVALUE: fInputValFiles.push_back(filename); return true;
609
611 // if we haven't read any user setting create new ones and read the file, otherwise just read the file
612 if(fUserSettings == nullptr) {
613 fUserSettings = new TUserSettings(filename);
614 } else {
615 fUserSettings->ReadSettings(filename);
616 }
617 return true;
618
619 case kFileType::PRESETWINDOW: fInputWinFiles.push_back(filename); return true;
620
621 case kFileType::CUTS_FILE: fInputCutFiles.push_back(filename); return true;
622
623 case kFileType::CONFIG_FILE: return false;
624
625 case kFileType::XML_FILE: fInputOdbFiles.push_back(filename); return true;
626
628 default: std::cout << "\tDiscarding unknown file: " << filename << std::endl; return false;
629 }
630}
631
633{
634 /// Writes options information to the tree
635 // Maintain old gDirectory info
636 bool success = true;
637 TDirectory* oldDir = gDirectory;
638
639 if(file == nullptr) {
640 file = gDirectory->GetFile();
641 }
642 file->cd();
643 std::string oldoption = std::string(file->GetOption());
644 if(oldoption == "READ") {
645 file->ReOpen("UPDATE");
646 }
647 if(!gDirectory) { // we don't compare to nullptr here, as ROOT >= 6.24.00 uses the TDirectoryAtomicAdapter structure with a bool() operator
648 std::cout << "No file opened to write TGRSIOptions to." << std::endl;
649 success = false;
650 } else {
651 Get()->Write("GRSIOptions", TObject::kOverwrite);
653 if(!fUserSettings->empty()) { fUserSettings->Write("UserSettings", TObject::kOverwrite); }
654 }
655
656 std::cout << "Writing TGRSIOptions to " << gDirectory->GetFile()->GetName() << std::endl;
657 if(oldoption == "READ") {
658 std::cout << " Returning " << gDirectory->GetFile()->GetName() << " to \"" << oldoption << "\" mode." << std::endl;
659 file->ReOpen("READ");
660 }
661 oldDir->cd(); // Go back to original gDirectory
662
663 return success;
664}
665
667{
668 // Sets the TGRSIOptions to the info passes as tmp.
669 if((fGRSIOptions != nullptr) && (tmp != fGRSIOptions)) {
670 delete fGRSIOptions;
671 }
672 fGRSIOptions = tmp;
673}
674
675Bool_t TGRSIOptions::ReadFromFile(TFile* file)
676{
677 TDirectory* oldDir = gDirectory;
678 if(file != nullptr) {
679 file->cd();
680 }
681
682 if(gDirectory->GetFile() == nullptr) {
683 std::cout << "File does not exist" << std::endl;
684 oldDir->cd();
685 return false;
686 }
687
688 file = gDirectory->GetFile();
689
690 TList* list = file->GetListOfKeys();
691 TIter iter(list);
692 std::cout << "Reading options from file: " << CYAN << file->GetName() << RESET_COLOR << std::endl;
693 while(TKey* key = static_cast<TKey*>(iter.Next())) {
694 if((key == nullptr) || (strcmp(key->GetClassName(), "TGRSIOptions") != 0)) {
695 continue;
696 }
697
698 TGRSIOptions::SetOptions(static_cast<TGRSIOptions*>(key->ReadObj()));
699 oldDir->cd();
700 return true;
701 }
702 oldDir->cd();
703
704 return false;
705}
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)