158 <<
"fBatch: " <<
fBatch << std::endl
161 <<
"fShowLogo: " <<
fShowLogo << std::endl
162 <<
"fSortRaw: " <<
fSortRaw << std::endl
164 <<
"fIsOnline: " <<
fIsOnline << std::endl
165 <<
"fStartGui: " <<
fStartGui << std::endl
168 <<
"fDebug: " <<
fDebug << std::endl
169 <<
"fLogFile: " <<
fLogFile << std::endl
189 <<
"fTreeName: " <<
fTreeName << std::endl
196 <<
"fHelp: " <<
fHelp << std::endl
215 std::string default_calfile = gEnv->GetValue(
"GRSI.CalFile",
"");
216 if(default_calfile.length() != 0u) {
223 std::string default_valfile = gEnv->GetValue(
"GRSI.ValFile",
"");
224 if(default_valfile.length() != 0u) {
236 size_t lastSlash = program.rfind(
'/');
237 if(lastSlash != std::string::npos) {
238 program.erase(0, lastSlash + 1);
242 bool useRecommendedFlags =
false;
244 std::vector<std::string> input_files;
245 std::string default_file_format;
251 parser.
default_option(&input_files,
true).description(
"Input file(s)");
252 parser.
option(
"h help ?", &
fHelp,
true).description(
"Show this help message");
257 .description(
"Build window, in ns.")
260 .description(
"Build events by timestamp w/o using CFD")
263 .description(
"Addback window, time in ns")
266 .description(
"BGO suppression window, time in ns")
269 .description(
"Minimum BGO energy for suppression")
272 .description(
"Use static window for event building")
275 .description(
"Fit waveforms using SFU algorithms")
278 .description(
"Correct cross-talk")
282 if(program ==
"grsisort") {
284 parser.
option(
"recommended", &useRecommendedFlags,
true).description(
"Use recommended flags (those in " DGREEN "dark green" GREEN ")").colour(
GREEN);
288 .description(
"Filename of output fragment hists");
290 .description(
"Filename of output analysis hists");
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");
299 .description(
"Number of events to hold when sorting by time/trigger_id")
300 .default_value(200000);
303 parser.
option(
"l no-logo", &
fShowLogo,
true).description(
"Inhibit the startup logo").default_value(
true).colour(
DGREEN);
305 .description(
"Extract wave forms to data class when available.")
306 .default_value(
false);
308 .description(
"Write debug information to output/file, e.g. enables writing of TDescantDebug at analysis stage")
309 .default_value(
false);
312 .description(
"Offset to the word count in the GRIFFIN header word, default is -1 (disabled).")
318 .description(
"Write fragment tree.")
320 parser.
option(
"bad-frags write-bad-frags bad-fragments write-bad-fragments", &
fWriteBadFrags,
true)
321 .description(
"Write fragments that failed parsing to BadFragmentTree")
324 .description(
"Write out-of-order fragments to a separate tree at the sorting stage")
325 .default_value(
false)
329 parser.
option(
"downscaling", &
fDownscaling,
true).description(
"Downscaling factor for raw events to be processed").default_value(1);
332 parser.
option(
"suppress-error suppress-errors suppress_error suppress_errors", &
fSuppressErrors,
true)
333 .description(
"Suppress error output from parsing")
336 .description(
"Reconstruct missing high bits of timestamp")
339 .description(
"Ignore missing channels completely (not written to fragment or analysis tree)")
340 .default_value(
false);
342 .description(
"Skip sorting fragments before building events (default is false)")
343 .default_value(
false);
346 .description(
"Size of fragment write queue")
347 .default_value(10000000);
349 .description(
"Size of analysis write queue")
350 .default_value(1000000);
352 parser.
option(
"column-width", &
fColumnWidth,
true).description(
"Width of one column of status").default_value(20);
354 .description(
"Number of characters to be used for status output")
358 "Seconds between each detailed status output (each a new line), non-positive numbers mean no detailed status")
360 }
else if(program ==
"grsiproof") {
363 .description(
"Max number of nodes to use when running a grsiproof session")
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");
371 .description(
"Name of tree to be proofed, default is empty, i.e. FragmentTree, AnalysisTree, and Lst2RootTree are checked");
373 .description(
"use average rate instead of current rate");
375 .description(
"use parallel unzipping of input files");
377 .description(
"set tree cache size (default = -1 = off)");
379 .description(
"use sub mergers to merge result from workers (default = -1 = off, 0 = automatic number of mergers)");
381 .description(
"enable proof stats");
382 }
else if(program ==
"grsiframe") {
385 .description(
"Maximum number of nodes to use when running a grsiframe session")
388 .description(
"Name of tree to be used, default is empty, i.e. FragmentTree, and AnalysisTree are checked");
390 .description(
"Increases verbosity of RDataFrame (also turns off the progress bar)")
391 .default_value(
false);
394 if(program ==
"grsiframe") {
397 .description(
"Maximum number of (midas, lst, rlmd, or tdr) events read")
402 for(
int i = 1; i < argc; i++) {
403 std::string filename = argv[i];
408 std::cerr <<
"ERROR: " << e.what() <<
"\n"
409 << parser << std::endl;
417 parser.
parse(argc, argv,
true);
419 std::cerr <<
"ERROR: " << e.what() <<
"\n"
420 << parser << std::endl;
432 std::cout << parser << std::endl;
443 for(
auto& file : input_files) {
458 parser.
parse(argc, argv,
false);
460 std::cerr <<
"ERROR: " << e.what() <<
"\n"
461 << parser << std::endl;
464 if(useRecommendedFlags) {
480 size_t dotPos = filename.find_last_of(
'.');
481 size_t slashPos = filename.find_last_of(
'/');
484 if(dotPos == std::string::npos || (dotPos < slashPos && slashPos != std::string::npos)) {
487 std::string ext = filename.substr(dotPos + 1);
490 bool isZipped = (ext ==
"gz") || (ext ==
"bz2") || (ext ==
"zip");
492 std::string remaining = filename.substr(0, dotPos);
493 ext = remaining.substr(remaining.find_last_of(
'.') + 1);
517 if((ext ==
"c") || (ext ==
"C") || (ext ==
"c+") || (ext ==
"C+") || (ext ==
"c++") || (ext ==
"C++")) {
520 if(ext ==
"dat" || ext ==
"cvt") {
521 if(filename.find(
"GlobalRaw") != std::string::npos) {
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++")) {
587 std::string fullFilename =
full_path(filename);
589 if(lib.
GetSymbol(
"MakeFragmentHistograms") !=
nullptr) {
593 if(lib.
GetSymbol(
"MakeAnalysisHistograms") !=
nullptr) {
597 if(lib.
GetSymbol(
"CreateParser") !=
nullptr && lib.
GetSymbol(
"DestroyParser") !=
nullptr &&
602 if(lib.
GetSymbol(
"CreateHelper") !=
nullptr && lib.
GetSymbol(
"DestroyHelper") !=
nullptr) {
607 std::cerr << fullFilename <<
" did not contain MakeFragmentHistograms or MakeAnalysisHistograms or CreateParser and others or CreateHelper and DestroyHelper" << std::endl;
632 default: std::cout <<
"\tDiscarding unknown file: " << filename << std::endl;
return false;
641 TDirectory* oldDir = gDirectory;
643 if(file ==
nullptr) {
644 file = gDirectory->GetFile();
647 std::string oldoption = std::string(file->GetOption());
648 if(oldoption ==
"READ") {
649 file->ReOpen(
"UPDATE");
652 std::cout <<
"No file opened to write TGRSIOptions to." << std::endl;
655 Get()->Write(
"GRSIOptions", TObject::kOverwrite);
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");
681 TDirectory* oldDir = gDirectory;
682 if(file !=
nullptr) {
686 if(gDirectory->GetFile() ==
nullptr) {
687 std::cout <<
"File does not exist" << std::endl;
692 file = gDirectory->GetFile();
694 TList* list = file->GetListOfKeys();
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)) {
std::string full_path(const std::string &path)
@ COMPILED_SHARED_LIBRARY
void parse(int argc, char **argv, bool firstPass)
ArgParseConfigT< T > & option(const std::string flag, T *output_location, bool firstPass)
void parse_file(std::string &filename)
ArgParseConfigT< std::vector< T > > & default_option(std::vector< T > *output_location, bool firstPass)
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)
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)