From 3818eb16704a78ace1a836e482d0d4e268d77af0 Mon Sep 17 00:00:00 2001 From: kyjung Date: Thu, 11 Sep 2025 18:19:12 -0400 Subject: [PATCH 1/8] Updated ICARUS startOM for spack evn --- installations/sbn-fd/startOMProdSpack.sh | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 installations/sbn-fd/startOMProdSpack.sh diff --git a/installations/sbn-fd/startOMProdSpack.sh b/installations/sbn-fd/startOMProdSpack.sh new file mode 100755 index 0000000..438b830 --- /dev/null +++ b/installations/sbn-fd/startOMProdSpack.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# 18 March 2020 -- copied from commited version... +# Change name of terminal, suggested by Antoni +printf '\033]2;Online Monitoring\a' + +#defaults +my_env="sbn-fd" +my_devdir=$1 +my_redishost=icarus-db02.fnal.gov +my_swdir=/daq/software + +my_daqarea=${HOME}/DQM_SPACK_DevAreas + +fcl_file=$my_daqarea/$my_devdir/sbndqm/installations/sbn-fd/$2 +my_dispatcherfcl=" -f $fcl_file " + +printf "Environment:\n" +printf "\tenv=$my_env\n" +printf "\tdevdir=$my_devdir\n" +printf "\tdispatcherfcl=$fcl_file\n" +printf "\tredishost=$my_redishost\n\n" + +echo "Activating Spack environment..." +source /daq/software/spack_packages/spack/v1.0.1.sbnd/setup-env.sh +export SPACK_DISABLE_LOCAL_CONFIG=true +cd $my_daqarea/$my_devdir +spack env activate --prompt --dir . + +echo "$(spack find --format '{name}@{version} {variants.s} {variants.cxxstd} /{hash:7}' sbndqm-suite)" +echo "$(spack find --format '{name}@{version} {variants.cxxstd} /{hash:7}' sbndqm)" +echo "$(spack find --format '{name}@{version} {variants.cxxstd} /{hash:7}' sbndaq-online)" +echo "$(spack find --format '{name}@{version} {variants.cxxstd} /{hash:7}' icaruscode)" + +echo "Loaded Spack enviroment!" + +if [[ ! -d $my_daqarea/$my_devdir/python_virtualenv ]]; then + python3 -m venv $my_daqarea/$my_devdir/python_virtualenv + source $my_daqarea/$my_devdir/python_virtualenv/bin/activate + python3 -m pip install --upgrade pip + python3 -m pip install -r $my_daqarea/$my_devdir/sbndqm/sbndqm/AliveMonitor/requirements.txt + python3 -m pip list -v +else + source $my_daqarea/$my_devdir/python_virtualenv/bin/activate +fi + +export PYTHONPATH="$(spack location -i py-fhicl-py)/lib:$PYTHONPATH" + +FCL_DIR="$(dirname "$fcl_file")" +export FHICL_FILE_PATH="$FCL_DIR:$my_daqarea/$my_devdir:$FHICL_FILE_PATH" + +#cleanup +killall -9 lar +ipcrm -M 0x40471454 + +python $my_daqarea/$my_devdir/sbndqm/sbndqm/AliveMonitor/alive_monitor.py -s "$my_redishost" -k DAQConsumer \ +-c "python $my_daqarea/$my_devdir/sbndqm/sbndqm/DAQConsumer/daq_consumer.py $my_dispatcherfcl -l /daq/log/DAQConsumerOM/ -lo" From fd2c11cb739d898c52344adadc2d34d0be805ac8 Mon Sep 17 00:00:00 2001 From: kyjung Date: Thu, 11 Sep 2025 18:19:36 -0400 Subject: [PATCH 2/8] Baseline subtraction flag is added --- installations/sbn-fd/ICARUS_OnlineMonitor.fcl | 3 +++ installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl | 3 +++ installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl | 3 +++ installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl | 3 +++ 4 files changed, 12 insertions(+) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor.fcl index 90e473c..341271d 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor.fcl @@ -53,6 +53,9 @@ analysis_config: { // Change tick period to be 0.4 for ICARUS tick_period: 0.4 + + // Baseline is already subtracted in daqROI + is_baseline_subtracted: true } END_PROLOG diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl index 5e66745..f42081b 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl @@ -53,6 +53,9 @@ analysis_config: { // Change tick period to be 0.4 for ICARUS tick_period: 0.4 + + // Baseline is already subtracted in daqROI + is_baseline_subtracted: true } END_PROLOG diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl index ac8ff5d..a3ab456 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl @@ -53,6 +53,9 @@ analysis_config: { // Change tick period to be 0.4 for ICARUS tick_period: 0.4 + + // Baseline is already subtracted in daqROI + is_baseline_subtracted: true } END_PROLOG diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl index 72db8c5..b21d266 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl @@ -53,6 +53,9 @@ analysis_config: { // Change tick period to be 0.4 for ICARUS tick_period: 0.4 + + // Baseline is already subtracted in daqROI + is_baseline_subtracted: true } END_PROLOG From 06b922eaded1ced5d1179b4b9c04ecff75519036 Mon Sep 17 00:00:00 2001 From: kyjung Date: Thu, 11 Sep 2025 18:21:24 -0400 Subject: [PATCH 3/8] Add baseline subtraction flag --- sbndqm/dqmAnalysis/TPC/Analysis.cc | 20 ++++++++++++++------ sbndqm/dqmAnalysis/TPC/Analysis.hh | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/sbndqm/dqmAnalysis/TPC/Analysis.cc b/sbndqm/dqmAnalysis/TPC/Analysis.cc index fe0ee61..f3c885b 100644 --- a/sbndqm/dqmAnalysis/TPC/Analysis.cc +++ b/sbndqm/dqmAnalysis/TPC/Analysis.cc @@ -90,6 +90,9 @@ Analysis::AnalysisConfig::AnalysisConfig(const fhicl::ParameterSet ¶m) { // whether to use plane data in peakfinding use_planes = param.get("use_planes", false); + //set true if input waveform is subtracted + is_baseline_subtracted = param.get("is_baseline_subtracted", false); + // method to calculate baseline: // 0 == assume baseline is 0 // 1 == assume baseline is in digits.GetPedestal() @@ -329,6 +332,11 @@ void Analysis::ProcessChannel(const raw::RawDigit &digits) { _timing.EndTime(&_timing.baseline_calc); } + float baseline_local = _per_channel_data[channel].baseline; + if (_config.is_baseline_subtracted) { + baseline_local = 0; + } + if (_config.timing) { _timing.StartTime(); } @@ -355,11 +363,11 @@ void Analysis::ProcessChannel(const raw::RawDigit &digits) { threshold = _config.threshold; } else if (_config.threshold_calc == 1) { - auto thresholds = Threshold(adc_vec, _per_channel_data[channel].baseline, _config.threshold_sigma, _config.verbose); + auto thresholds = Threshold(adc_vec, baseline_local, _config.threshold_sigma, _config.verbose); threshold = thresholds.Val(); } else if (_config.threshold_calc == 2) { - NoiseSample temp({{0, (unsigned)digits.NADC()-1}}, _per_channel_data[channel].baseline); + NoiseSample temp({{0, (unsigned)digits.NADC()-1}}, baseline_local); float raw_rms = temp.RMS(adc_vec); threshold = raw_rms * _config.threshold_sigma; } @@ -368,7 +376,7 @@ void Analysis::ProcessChannel(const raw::RawDigit &digits) { float n_sigma = _config.threshold_sigma; if (_config.use_planes && _channel_info.PlaneType(channel) == PeakFinder::collection) n_sigma = n_sigma * 1.5; - threshold = _thresholds[channel].Threshold(adc_vec, _per_channel_data[channel].baseline, n_sigma); + threshold = _thresholds[channel].Threshold(adc_vec, baseline_local, n_sigma); } if (_config.timing) { _timing.EndTime(&_timing.calc_threshold); @@ -384,7 +392,7 @@ void Analysis::ProcessChannel(const raw::RawDigit &digits) { if (_config.find_signal) { PeakFinder::plane_type plane = (_config.use_planes) ? _channel_info.PlaneType(channel) : PeakFinder::unspecified; - PeakFinder peaks(adc_vec, _per_channel_data[channel].baseline, threshold, + PeakFinder peaks(adc_vec, baseline_local, threshold, _config.n_smoothing_samples, _config.n_above_threshold, plane); _per_channel_data[channel].peaks.assign(peaks.Peaks()->begin(), peaks.Peaks()->end()); } @@ -399,11 +407,11 @@ void Analysis::ProcessChannel(const raw::RawDigit &digits) { // get noise samples if (_config.noise_range_sampling == 0) { // use first n_noise_samples - _noise_samples[channel] = NoiseSample( { { 0, _config.n_noise_samples -1 } }, _per_channel_data[channel].baseline); + _noise_samples[channel] = NoiseSample( { { 0, _config.n_noise_samples -1 } }, baseline_local); } else { // or use peak finding - _noise_samples[channel] = NoiseSample(_per_channel_data[channel].peaks, _per_channel_data[channel].baseline, digits.NADC()); + _noise_samples[channel] = NoiseSample(_per_channel_data[channel].peaks, baseline_local, digits.NADC()); } // Refine baseline values by taking the mean over the background range diff --git a/sbndqm/dqmAnalysis/TPC/Analysis.hh b/sbndqm/dqmAnalysis/TPC/Analysis.hh index 6ecd8b5..2716fd1 100644 --- a/sbndqm/dqmAnalysis/TPC/Analysis.hh +++ b/sbndqm/dqmAnalysis/TPC/Analysis.hh @@ -114,6 +114,7 @@ public: bool fill_waveforms; bool reduce_data; bool timing; + bool is_baseline_subtracted; AnalysisConfig(const fhicl::ParameterSet ¶m); AnalysisConfig() {} From 3759ebf1bfbfed3b828aacecfa2c24705c19280f Mon Sep 17 00:00:00 2001 From: Kiyoung Jung <87654299+kyjung123@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:16:29 -0400 Subject: [PATCH 4/8] Update output path --- installations/sbn-fd/ICARUS_OnlineMonitor.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor.fcl index 341271d..acc1768 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor.fcl @@ -147,7 +147,7 @@ source: #decoder output outputs.decodedout:{ module_type: RootOutput - fileName: "/data/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" + fileName: "/daq/scratch/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" dataTier: "raw" compressionLevel: 3 SelectEvents: [pscale_OnMonFiles] From a7804f0502c75c67de5a64e7598f1345a13890c1 Mon Sep 17 00:00:00 2001 From: Kiyoung Jung <87654299+kyjung123@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:17:02 -0400 Subject: [PATCH 5/8] Update output path --- installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl index f42081b..bf001b2 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCEast.fcl @@ -147,7 +147,7 @@ source: #decoder output outputs.decodedout:{ module_type: RootOutput - fileName: "/data/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" + fileName: "/daq/scratch/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" dataTier: "raw" compressionLevel: 3 SelectEvents: [pscale_OnMonFiles] From cf6ffd7490e148f5a757c0d8c490baed0be5cba0 Mon Sep 17 00:00:00 2001 From: Kiyoung Jung <87654299+kyjung123@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:17:24 -0400 Subject: [PATCH 6/8] Update output path --- installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl index a3ab456..599ab97 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCOnly.fcl @@ -147,7 +147,7 @@ source: #decoder output outputs.decodedout:{ module_type: RootOutput - fileName: "/data/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" + fileName: "/daq/scratch/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" dataTier: "raw" compressionLevel: 3 SelectEvents: [pscale_OnMonFiles] From b9ec07d304a0d354d844b4dfb069a0fe1b0f754f Mon Sep 17 00:00:00 2001 From: Kiyoung Jung <87654299+kyjung123@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:17:49 -0400 Subject: [PATCH 7/8] Update output path --- installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl index b21d266..ffcb74f 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_TPCWest.fcl @@ -147,7 +147,7 @@ source: #decoder output outputs.decodedout:{ module_type: RootOutput - fileName: "/data/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" + fileName: "/daq/scratch/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" dataTier: "raw" compressionLevel: 3 SelectEvents: [pscale_OnMonFiles] From aed1f190c1f4084ecb41db81951c5e6ca11c30aa Mon Sep 17 00:00:00 2001 From: Kiyoung Jung <87654299+kyjung123@users.noreply.github.com> Date: Sun, 5 Oct 2025 23:18:50 -0400 Subject: [PATCH 8/8] Update output path --- installations/sbn-fd/ICARUS_OnlineMonitor_PMTOnly.fcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installations/sbn-fd/ICARUS_OnlineMonitor_PMTOnly.fcl b/installations/sbn-fd/ICARUS_OnlineMonitor_PMTOnly.fcl index 8bca97b..6aa2ede 100644 --- a/installations/sbn-fd/ICARUS_OnlineMonitor_PMTOnly.fcl +++ b/installations/sbn-fd/ICARUS_OnlineMonitor_PMTOnly.fcl @@ -84,7 +84,7 @@ source: #decoder output outputs.decodedout:{ module_type: RootOutput - fileName: "/data/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" + fileName: "/daq/scratch/onmon_files/onmon_output_%r_%s_%tc_%#-decoded.root" dataTier: "raw" compressionLevel: 3 SelectEvents: [pscale_OnMonFiles]