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