156 <<
"fBatch: " <<
fBatch << std::endl
159 <<
"fShowLogo: " <<
fShowLogo << std::endl
160 <<
"fSortRaw: " <<
fSortRaw << std::endl
162 <<
"fIsOnline: " <<
fIsOnline << std::endl
163 <<
"fStartGui: " <<
fStartGui << std::endl
166 <<
"fDebug: " <<
fDebug << std::endl
167 <<
"fLogFile: " <<
fLogFile << std::endl
187 <<
"fTreeName: " <<
fTreeName << std::endl
194 <<
"fHelp: " <<
fHelp << std::endl
213 std::string default_calfile = gEnv->GetValue(
"GRSI.CalFile",
"");
214 if(!default_calfile.empty()) {
221 std::string default_valfile = gEnv->GetValue(
"GRSI.ValFile",
"");
222 if(!default_valfile.empty()) {
234 size_t lastSlash = program.rfind(
'/');
235 if(lastSlash != std::string::npos) {
236 program.erase(0, lastSlash + 1);
240 bool useRecommendedFlags =
false;
242 std::vector<std::string> input_files;
243 std::string default_file_format;
249 parser.
default_option(&input_files,
true).description(
"Input file(s)");
250 parser.
option(
"h help ?", &
fHelp,
true).description(
"Show this help message");
255 .description(
"Build window, in ns.")
258 .description(
"Build events by timestamp w/o using CFD")
261 .description(
"Addback window, time in ns")
264 .description(
"BGO suppression window, time in ns")
267 .description(
"Minimum BGO energy for suppression")
270 .description(
"Use static window for event building")
273 .description(
"Fit waveforms using SFU algorithms")
276 .description(
"Correct cross-talk")
280 if(program ==
"grsisort") {
282 parser.
option(
"recommended", &useRecommendedFlags,
true).description(
"Use recommended flags (those in " DGREEN "dark green" GREEN ")").colour(
GREEN);
286 .description(
"Filename of output fragment hists");
288 .description(
"Filename of output analysis hists");
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");
297 .description(
"Number of events to hold when sorting by time/trigger_id")
298 .default_value(200000);
301 parser.
option(
"l no-logo", &
fShowLogo,
true).description(
"Inhibit the startup logo").default_value(
true).colour(
DGREEN);
303 .description(
"Extract wave forms to data class when available.")
304 .default_value(
false);
306 .description(
"Write debug information to output/file, e.g. enables writing of TDescantDebug at analysis stage")
307 .default_value(
false);
310 .description(
"Offset to the word count in the GRIFFIN header word, default is -1 (disabled).")
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");
320 .description(
"Write out-of-order fragments to a separate tree at the sorting stage")
321 .default_value(
false)
325 parser.
option(
"downscaling", &
fDownscaling,
true).description(
"Downscaling factor for raw events to be processed").default_value(1);
328 parser.
option(
"suppress-error suppress-errors suppress_error suppress_errors", &
fSuppressErrors,
true)
329 .description(
"Suppress error output from parsing")
332 .description(
"Reconstruct missing high bits of timestamp")
335 .description(
"Ignore missing channels completely (not written to fragment or analysis tree)")
336 .default_value(
false);
338 .description(
"Skip sorting fragments before building events (default is false)")
339 .default_value(
false);
342 .description(
"Size of fragment write queue")
343 .default_value(10000000);
345 .description(
"Size of analysis write queue")
346 .default_value(1000000);
348 parser.
option(
"column-width", &
fColumnWidth,
true).description(
"Width of one column of status").default_value(20);
350 .description(
"Number of characters to be used for status output")
354 "Seconds between each detailed status output (each a new line), non-positive numbers mean no detailed status")
356 }
else if(program ==
"grsiproof") {
359 .description(
"Max number of nodes to use when running a grsiproof session")
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");
367 .description(
"Name of tree to be proofed, default is empty, i.e. FragmentTree, AnalysisTree, and Lst2RootTree are checked");
369 .description(
"use average rate instead of current rate");
371 .description(
"use parallel unzipping of input files");
373 .description(
"set tree cache size (default = -1 = off)");
375 .description(
"use sub mergers to merge result from workers (default = -1 = off, 0 = automatic number of mergers)");
377 .description(
"enable proof stats");
378 }
else if(program ==
"grsiframe") {
381 .description(
"Maximum number of nodes to use when running a grsiframe session")
384 .description(
"Name of tree to be used, default is empty, i.e. FragmentTree, and AnalysisTree are checked");
386 .description(
"Increases verbosity of RDataFrame (also turns off the progress bar)")
387 .default_value(
false);
390 if(program ==
"grsiframe") {
393 .description(
"Maximum number of events read")
398 for(
int i = 1; i < argc; i++) {
399 std::string filename = argv[i];
404 std::cerr <<
"ERROR: " << e.what() <<
"\n"
405 << parser << std::endl;
413 parser.
parse(argc, argv,
true);
415 std::cerr <<
"ERROR: " << e.what() <<
"\n"
416 << parser << std::endl;
428 std::cout << parser << std::endl;
439 for(
auto& file : input_files) {
454 parser.
parse(argc, argv,
false);
456 std::cerr <<
"ERROR: " << e.what() <<
"\n"
457 << parser << std::endl;
460 if(useRecommendedFlags) {
474 size_t dotPos = filename.find_last_of(
'.');
475 size_t slashPos = filename.find_last_of(
'/');
478 if(dotPos == std::string::npos || (dotPos < slashPos && slashPos != std::string::npos)) {
481 std::string ext = filename.substr(dotPos + 1);
484 bool isZipped = (ext ==
"gz") || (ext ==
"bz2") || (ext ==
"zip");
486 std::string remaining = filename.substr(0, dotPos);
487 ext = remaining.substr(remaining.find_last_of(
'.') + 1);
511 if((ext ==
"c") || (ext ==
"C") || (ext ==
"c+") || (ext ==
"C+") || (ext ==
"c++") || (ext ==
"C++")) {
514 if(ext ==
"dat" || ext ==
"cvt") {
515 if(filename.find(
"GlobalRaw") != std::string::npos) {
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++")) {
581 std::string fullFilename =
full_path(filename);
583 if(lib.
GetSymbol(
"MakeFragmentHistograms") !=
nullptr) {
587 if(lib.
GetSymbol(
"MakeAnalysisHistograms") !=
nullptr) {
591 if(lib.
GetSymbol(
"CreateParser") !=
nullptr && lib.
GetSymbol(
"DestroyParser") !=
nullptr &&
596 if(lib.
GetSymbol(
"CreateHelper") !=
nullptr && lib.
GetSymbol(
"DestroyHelper") !=
nullptr) {
601 std::cerr << fullFilename <<
" did not contain MakeFragmentHistograms or MakeAnalysisHistograms or CreateParser and others or CreateHelper and DestroyHelper" << std::endl;
626 default: std::cout <<
"\tDiscarding unknown file: " << filename << std::endl;
return false;
635 TDirectory* oldDir = gDirectory;
637 if(file ==
nullptr) {
638 file = gDirectory->GetFile();
641 std::string oldoption = std::string(file->GetOption());
642 if(oldoption ==
"READ") {
643 file->ReOpen(
"UPDATE");
646 std::cout <<
"No file opened to write TGRSIOptions to." << std::endl;
649 Get()->Write(
"GRSIOptions", TObject::kOverwrite);
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");
675 TDirectory* oldDir = gDirectory;
676 if(file !=
nullptr) {
680 if(gDirectory->GetFile() ==
nullptr) {
681 std::cout <<
"File does not exist" << std::endl;
686 file = gDirectory->GetFile();
688 TList* list = file->GetListOfKeys();
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)) {
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)