Analysis-Utilities 26.9.9
C++/ROOT utilities for nuclear measurement data analysis
Loading...
Searching...
No Matches

Environment setup and binary-to-ROOT file conversion. More...

#include <InitUtils.hpp>

Static Public Member Functions

static void SetROOTPreferences (PlotSaveFormat save_format=PlotSaveFormat::kPNG, const TString &plots_dir="", const TString &root_files_dir="", Bool_t enable_mt=kTRUE)
 Configure the ROOT environment and pin all output paths.
static Bool_t ConvertWavedumpBinToROOT (const TString input_filename, const TString output_name, Bool_t corrections_enabled=kTRUE)
 Convert a WaveDump binary file (DT5742 family) to a ROOT tree.
static UShort_t ConvertCoMPASSBinToROOT (const TString input_filename, const TString output_name, UShort_t global_header_override, Bool_t skip_bad_events=kFALSE)
 Convert a CoMPASS binary file to a ROOT tree.
static std::pair< std::vector< RawHit >, UShort_t > ConvertCoMPASSBinToHits (const TString input_filename, UShort_t global_header_override=0, Bool_t skip_bad_events=kFALSE)
 Read a CoMPASS binary file into memory, with no ROOT file I/O.
static Bool_t ConvertSOLBinToROOT (const TString input_filename, const TString output_name)
 Convert a SOLARIS DAQ (SOL) binary file to a ROOT tree.
static std::pair< std::vector< SOLHit >, Long64_t > ConvertSOLBinToHits (const TString input_filename)
 Read a SOL binary file into memory as lightweight hits.

Detailed Description

Environment setup and binary-to-ROOT file conversion.

All-static. SetROOTPreferences() is the recommended single entry point for configuring the ROOT environment at the top of an analysis; the remaining methods convert acquisition-software binary files into ROOT trees or in-memory hit vectors.

Definition at line 23 of file InitUtils.hpp.

Member Function Documentation

◆ ConvertCoMPASSBinToHits()

std::pair< std::vector< RawHit >, UShort_t > InitUtils::ConvertCoMPASSBinToHits ( const TString input_filename,
UShort_t global_header_override = 0,
Bool_t skip_bad_events = kFALSE )
static

Read a CoMPASS binary file into memory, with no ROOT file I/O.

The in-memory counterpart of ConvertCoMPASSBinToROOT(), for callers that want the hits directly rather than a tree on disk.

Parameters
input_filenamePath to the CoMPASS binary file.
global_header_overrideHeader word to assume instead of reading one from the file; 0 (the default) reads it from the file.
skip_bad_eventsWhen kTRUE, records that fail validation are skipped rather than aborting.
Returns
A pair of the hits read and the global header used. On failure the vector is empty and the header is 0.

Definition at line 641 of file InitUtils.cpp.

◆ ConvertCoMPASSBinToROOT()

UShort_t InitUtils::ConvertCoMPASSBinToROOT ( const TString input_filename,
const TString output_name,
UShort_t global_header_override,
Bool_t skip_bad_events = kFALSE )
static

Convert a CoMPASS binary file to a ROOT tree.

Which branches are written is dictated by the file's global header, whose low bits flag the fields present in each record: 0x0001 energy (channel units), 0x0002 calibrated energy, 0x0004 short-gate energy, 0x0008 waveform samples.

Parameters
input_filenamePath to the CoMPASS binary file.
output_nameOutput basename, without extension. Written to <root_files_base>/<output_name>.root; the base directory is created if missing.
global_header_overrideHeader word to assume instead of reading one from the file. Pass 0 to read it from the file, which is the normal case. Use a non-zero value only for files whose two-byte header is absent or wrong — passing one also suppresses the two-byte header skip.
skip_bad_eventsWhen kTRUE, records that fail validation are skipped instead of aborting the conversion. kFALSE by default.
Returns
The global header actually used, which is non-zero on success, or 0 if the input does not exist, cannot be opened, or the conversion failed. Inspect the returned bits to learn which branches the output tree carries.

Definition at line 362 of file InitUtils.cpp.

◆ ConvertSOLBinToHits()

std::pair< std::vector< SOLHit >, Long64_t > InitUtils::ConvertSOLBinToHits ( const TString input_filename)
static

Read a SOL binary file into memory as lightweight hits.

Traces are skipped entirely — each block is reduced to its header fields — which makes this cheap enough to run over a whole run when only timing and energy are needed.

Parameters
input_filenamePath to the SOL binary file.
Returns
A pair of the hits read and the total number of blocks processed. On failure the vector is empty and the count is 0.

Definition at line 1125 of file InitUtils.cpp.

◆ ConvertSOLBinToROOT()

Bool_t InitUtils::ConvertSOLBinToROOT ( const TString input_filename,
const TString output_name )
static

Convert a SOLARIS DAQ (SOL) binary file to a ROOT tree.

Writes a Data_R tree carrying every per-block header field, plus TArrayI / TArrayC trace branches for the block formats that include traces.

Parameters
input_filenamePath to the SOL binary file.
output_nameOutput basename, without extension. Written to <root_files_base>/<output_name>.root.
Returns
kTRUE on success; kFALSE if the input is missing or cannot be opened, with the reason printed to stdout.

Definition at line 886 of file InitUtils.cpp.

◆ ConvertWavedumpBinToROOT()

Bool_t InitUtils::ConvertWavedumpBinToROOT ( const TString input_filename,
const TString output_name,
Bool_t corrections_enabled = kTRUE )
static

Convert a WaveDump binary file (DT5742 family) to a ROOT tree.

Parameters
input_filenamePath to the WaveDump binary file.
output_nameOutput basename, without extension. The file is written to <root_files_base>/<output_name>.root.
corrections_enabledWhen kTRUE (the default), applies the DT5742 timing corrections during conversion.
Returns
kTRUE on success; kFALSE if the input is missing or cannot be parsed, with the reason printed to stdout.

Definition at line 798 of file InitUtils.cpp.

◆ SetROOTPreferences()

void InitUtils::SetROOTPreferences ( PlotSaveFormat save_format = PlotSaveFormat::kPNG,
const TString & plots_dir = "",
const TString & root_files_dir = "",
Bool_t enable_mt = kTRUE )
static

Configure the ROOT environment and pin all output paths.

Applies the house plotting style, forces it over any style carried by objects read from file, and puts ROOT in batch mode so plots do not pop up. Sets the plot output base via PlottingUtils::SetPlotsBaseDir() and the ROOT file I/O base via IO::SetRootFilesBaseDir().

Parameters
save_formatFigure output format. PlotSaveFormat::kPNG by default.
plots_dirBase directory for saved figures. Pass an absolute path so output is anchored to a project root regardless of the current working directory. If empty, a warning is printed and the CWD-relative "plots" is used.
root_files_dirBase directory for ROOT file I/O. Same absolute-path advice; if empty, a warning is printed and the CWD-relative "root_files" is used.
enable_mtWhen kTRUE (the default), enables ROOT thread safety via IO::SetThreadSafe() and detaches new histograms from gDirectory with TH1::AddDirectory(kFALSE), so concurrent TFile opens on other threads cannot race on a directory's child list. Required for the parallel file processing in WaveformProcessingUtils.
Note
Mutates process-wide ROOT state: gStyle, gROOT batch mode and forced style, and — with enable_mt — histogram directory ownership. Call it once, early.
Warning
With enable_mt on, histograms are no longer owned by the current TFile. Anything you want written to disk must be Write()-ten explicitly, and every histogram you create becomes your responsibility to delete.

Definition at line 318 of file InitUtils.cpp.


The documentation for this class was generated from the following files: