Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • le.koch/cbmroot
  • patrick.pfistner_AT_kit.edu/cbmroot
  • lena.rossel_AT_stud.uni-frankfurt.de/cbmroot
  • i.deppner/cbmroot
  • fweig/cbmroot
  • karpushkin_AT_inr.ru/cbmroot
  • v.akishina/cbmroot
  • rishat.sultanov_AT_cern.ch/cbmroot
  • l_fabe01_AT_uni-muenster.de/cbmroot
  • pwg-c2f/cbmroot
  • j.decuveland/cbmroot
  • a.toia/cbmroot
  • i.vassiliev/cbmroot
  • n.herrmann/cbmroot
  • o.lubynets/cbmroot
  • se.gorbunov/cbmroot
  • cornelius.riesen_AT_physik.uni-giessen.de/cbmroot
  • zhangqn17_AT_mails.tsinghua.edu.cn/cbmroot
  • bartosz.sobol/cbmroot
  • ajit.kumar/cbmroot
  • computing/cbmroot
  • a.agarwal_AT_vecc.gov.in/cbmroot
  • osingh/cbmroot
  • wielanek_AT_if.pw.edu.pl/cbmroot
  • malgorzata.karabowicz.stud_AT_pw.edu.pl/cbmroot
  • m.shiroya/cbmroot
  • s.roy/cbmroot
  • p.-a.loizeau/cbmroot
  • a.weber/cbmroot
  • ma.beyer/cbmroot
  • d.klein/cbmroot
  • d.smith/cbmroot
  • mvdsoft/cbmroot
  • d.spicker/cbmroot
  • y.h.leung/cbmroot
  • m.deveaux/cbmroot
  • mkunold/cbmroot
  • h.darwish/cbmroot
  • f_fido01_AT_uni-muenster.de/cbmroot
  • g.kozlov/cbmroot
  • d.emschermann/cbmroot
  • evgeny.lavrik/cbmroot
  • v.friese/cbmroot
  • f.uhlig/cbmroot
  • ebechtel_AT_ikf.uni-frankfurt.de/cbmroot
  • a.senger/cbmroot
  • praisig/cbmroot
  • s.lebedev/cbmroot
  • redelbach_AT_compeng.uni-frankfurt.de/cbmroot
  • p.subramani/cbmroot
  • a_meye37_AT_uni-muenster.de/cbmroot
  • om/cbmroot
  • o.golosov/cbmroot
  • l.chlad/cbmroot
  • a.bercuci/cbmroot
  • d.ramirez/cbmroot
  • v.singhal/cbmroot
  • h.schiller/cbmroot
  • apuntke/cbmroot
  • f.zorn/cbmroot
  • rubio_AT_physi.uni-heidelberg.de/cbmroot
  • p.chudoba/cbmroot
  • apuntke/mcbmroot
  • r.karabowicz/cbmroot
64 results
Show changes
Showing
with 4001 additions and 88 deletions
/* Copyright (C) 2020 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceMcbmEventBuilderWin.h"
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()("FillHistos", bpo::value<bool>()->default_value(true),
"Fill histograms and send them to histo server if true");
options.add_options()("IgnTsOver", bpo::value<bool>()->default_value(false), "Ignore TS overlap if true");
options.add_options()("EvtOverMode", bpo::value<std::string>()->default_value("NoOverlap"),
"Set the event overlap mode, use string matching an EOverlapMode ");
options.add_options()("RefDet", bpo::value<std::string>()->default_value("kBmon"),
"Set the reference (seed) detector, use string matching an ECbmModuleId ");
options.add_options()("AddDet", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Add a detector for digis selection, use string matching an ECbmModuleId ");
options.add_options()("DelDet", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Remove a detector for digis selection, use string matching an "
"ECbmModuleId ");
options.add_options()("SetTrigWin", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Set trigger window for selected detector, use string matching "
"ECbmModuleId,dWinBeg,dWinEnd e.g. kSts,-10.5,100.0");
options.add_options()("SetTrigMinNb", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Set minimum number of digis for selected detector, use string matching "
"ECbmModuleId,uMinNb e.g. kTof,10");
options.add_options()("TsNameIn", bpo::value<std::string>()->default_value("unpts_0"),
"MQ channel name for unpacked TS data");
options.add_options()("EvtNameOut", bpo::value<std::string>()->default_value("events"),
"MQ channel name for built events");
options.add_options()("ChNameIn", bpo::value<std::string>()->default_value("histogram-in"),
"MQ channel name for histos");
options.add_options()("ChNameHistCfg", bpo::value<std::string>()->default_value("histo-conf"),
"MQ channel name for histos config");
options.add_options()("ChNameCanvCfg", bpo::value<std::string>()->default_value("canvas-conf"),
"MQ channel name for canvases config");
options.add_options()("PubFreqTs", bpo::value<uint32_t>()->default_value(100), "Histo publishing frequency in TS");
options.add_options()("PubTimeMin", bpo::value<double_t>()->default_value(1.0),
"Minimal time between two publishing");
options.add_options()("PubTimeMax", bpo::value<double_t>()->default_value(10.0),
"Maximal time between two publishing");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmEventBuilderWin(); }
/* Copyright (C) 2020 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceMcbmMonitorPulser.h"
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()("DebugMoni", bpo::value<bool>()->default_value(false), "Debug Monitor Mode");
options.add_options()("HistEvoSz", bpo::value<uint32_t>()->default_value(1800),
"Size of evolution histos in seconds");
options.add_options()("PulsTotMin", bpo::value<uint32_t>()->default_value(185), "Minimal TOT for pulser cut");
options.add_options()("PulsTotMax", bpo::value<uint32_t>()->default_value(195), "Maximal TOT for pulser cut");
options.add_options()("PubFreqTs", bpo::value<uint32_t>()->default_value(100), "Histo publishing frequency in TS");
options.add_options()("PubTimeMin", bpo::value<double_t>()->default_value(1.0),
"Minimal time between two publishing");
options.add_options()("PubTimeMax", bpo::value<double_t>()->default_value(10.0),
"Maximal time between two publishing");
options.add_options()("TsNameIn", bpo::value<std::string>()->default_value("unpts_0"), "MQ channel name for TS data");
options.add_options()("ChNameIn", bpo::value<std::string>()->default_value("histogram-in"),
"MQ channel name for histos");
options.add_options()("ChNameHistCfg", bpo::value<std::string>()->default_value("histo-conf"),
"MQ channel name for histos config");
options.add_options()("ChNameCanvCfg", bpo::value<std::string>()->default_value("canvas-conf"),
"MQ channel name for canvases config");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmMonitorPulser(); }
/* Copyright (C) 2020 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceMcbmUnpack.h"
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()("IgnOverMs", bpo::value<bool>()->default_value(true), "Ignore overlap MS if true");
options.add_options()("SetTimeOffs", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Set time offset in ns for selected detector, use string matching "
"ECbmModuleId,dOffs e.g. kTof,-35.2");
options.add_options()("TsNameIn", bpo::value<std::string>()->default_value("fullts"),
"MQ channel name for raw TS data");
options.add_options()("TsNameOut", bpo::value<std::string>()->default_value("unpts_0"),
"MQ channel name for unpacked TS data");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmUnpack(); }
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceUnpack.h"
#include <iomanip>
#include <string>
#include "runFairMQDevice.h"
namespace bpo = boost::program_options;
using namespace std;
void addCustomOptions(bpo::options_description& options)
{
options.add_options()("Setup", bpo::value<std::string>()->default_value("mcbm_beam_2021_07_surveyed"),
"Name/tag of the geomatry setup");
options.add_options()("RunId", bpo::value<uint32_t>()->default_value(1588), "Run ID");
options.add_options()("UnpBmon", bpo::value<bool>()->default_value(false), "Enable Bmon unpacking if true");
options.add_options()("UnpSts", bpo::value<bool>()->default_value(true), "Enable STS unpacking if true");
options.add_options()("UnpMuch", bpo::value<bool>()->default_value(false), "Enable MUCH unpacking if true");
options.add_options()("UnpTrd1d", bpo::value<bool>()->default_value(true), "Enable TRD 1D unpacking if true");
options.add_options()("UnpTrd2d", bpo::value<bool>()->default_value(true), "Enable TRD 2D unpacking if true");
options.add_options()("UnpTof", bpo::value<bool>()->default_value(true), "Enable TOF unpacking if true");
options.add_options()("UnpRich", bpo::value<bool>()->default_value(true), "Enable RICH unpacking if true");
options.add_options()("UnpPsd", bpo::value<bool>()->default_value(true), "Enable PSD unpacking if true");
options.add_options()("IgnOverMs", bpo::value<bool>()->default_value(true), "Ignore overlap MS if true");
options.add_options()("FullTimeSort", bpo::value<bool>()->default_value(true),
"Full time sorting per detector before sending output array");
options.add_options()("SetTimeOffs", bpo::value<std::vector<std::string>>()->multitoken()->composing(),
"Set time offset in ns for selected detector, use string matching "
"ECbmModuleId,dOffs e.g. kTof,-35.2");
options.add_options()("TsNameIn", bpo::value<std::string>()->default_value("ts-request"),
"MQ channel name for raw TS data");
options.add_options()("TsNameOut", bpo::value<std::string>()->default_value("unpts_0"),
"MQ channel name for unpacked TS data");
options.add_options()("PubFreqTs", bpo::value<uint32_t>()->default_value(0), "Histo publishing frequency in TS");
options.add_options()("PubTimeMin", bpo::value<double_t>()->default_value(1.0),
"Minimal time between two publishing");
options.add_options()("PubTimeMax", bpo::value<double_t>()->default_value(10.0),
"Maximal time between two publishing");
options.add_options()("ChNameIn", bpo::value<std::string>()->default_value("histogram-in"),
"MQ channel name for histos");
}
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpack(); }
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 2 ]; then
_nbbranch=$1
_run_id=$2
((_pubfreqts = $_nbbranch*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 5 ]; then
_filename=""
_dirname=""
_hostname=$5
if [ $# -ge 6 ]; then
_pubfreqts=$6
if [ $# -ge 7 ]; then
_pubminsec=$7
if [ $# -ge 8 ]; then
_pubmaxsec=$8
fi
fi
fi
elif [ $# -ge 3 ]; then
_filename=$3
_hostname=""
if [ $# -eq 4 ]; then
_dirname=$4
else
_dirname=""
fi
else
echo 'Missing parameters or wrong number of parameters.'
echo 'Possible usages are:'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> <full filename pattern list>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> <filename pattern> <folder_path>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
return -1
fi
else
echo 'Missing parameters. At least the number of branches and the trigger set are required'
echo 'Possible usages are:'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> <full filename pattern list>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> <filename pattern> <folder_path>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startBmonMoni2022.sh <Nb // branches> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
return -1
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2022/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchPar.par # Valid from 2163
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriPar.par
_parfileBmon=@VMCWORKDIR@/macro/beamtime/mcbm2022/mBmonCriPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2021/mRichPar_70.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2021/mPsdPar.par
_setup_name=mcbm_beam_2022_03_22_iron
if [ $_run_id -ge 2060 ]; then
if [ $_run_id -le 2065 ]; then
_setup_name=mcbm_beam_2022_03_09_carbon
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto26032022.par # Valid for runs 2060-2162
elif [ $_run_id -le 2160 ]; then # Potentially wrong setup between 2065 and 2150 but not official runs
_setup_name=mcbm_beam_2022_03_22_iron
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto26032022.par # Valid for runs 2060-2162
elif [ $_run_id -le 2310 ]; then # Potentially wrong setup between 2160 and 2176 but not official runs
_setup_name=mcbm_beam_2022_03_28_uranium
fi
fi
_ratelog=0 # hides ZMQ messages rates and bandwidth
#_ratelog=1 # display ZMQ messages rates and bandwidth
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
# Compute limits of TOF selection/trigger window
_TofL=$_TofMean
_TofH=$_TofMean
(( _TofL -= _TofWin))
(( _TofH += _TofWin))
echo Tof window $_TofL - $_TofH
LIST_OF_PIDS=""
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbbranch ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="RepReqTsSampler"
SAMPLER+=" --control static"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 30"
#SAMPLER+=" --max-timeslices 100"
#SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --max-timeslices -1"
#SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --fles-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 10"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --PubFreqTs $_pubfreqts"
SAMPLER+=" --PubTimeMin $_pubminsec"
SAMPLER+=" --PubTimeMax $_pubmaxsec"
SAMPLER+=" --channel-config name=ts-request,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11555,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007,rateLogging=$_ratelog"
SAMPLER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
# xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &> $SAMPLER_LOG &
echo $SAMPLER
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileBmon;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
#PARAMETERSERVER+=" --libs-to-load=CbmStsBase;CbmMuchBase;CbmTrdBase;CbmTofBase;CbmRichBase" # doesn't work due to runtime problem
PARAMETERSERVER+=" --setup $_setup_name"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
# xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &> $PARAMSRV_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
HISTSERVER="MqHistoServer"
HISTSERVER+=" --control static"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8091"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
# xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &> $HISTSRV_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
sleep 1
_iBranch=0
while (( _iBranch < _nbbranch )); do
(( _yOffset=200*_iBranch ))
(( _iBranch += 1 ))
(( _iPort = 11680 + _iBranch ))
UNPACKER="BmonMonitor"
UNPACKER+=" --control static"
UNPACKER+=" --id unp$_iBranch"
#UNPACKER+=" --severity error"
UNPACKER+=" --severity info"
#UNPACKER+=" --severity debug"
UNPACKER+=" --Setup $_setup_name"
UNPACKER+=" --RunId $_run_id"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --UnpBmon true"
UNPACKER+=" --SetTimeOffs kT0,0"
UNPACKER+=" --PubFreqTs $_pubfreqts"
UNPACKER+=" --PubTimeMin $_pubminsec"
UNPACKER+=" --PubTimeMax $_pubmaxsec"
UNPACKER+=" --TsNameOut unpts$_iBranch"
UNPACKER+=" --channel-config name=ts-request,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11555,rateLogging=$_ratelog"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iBranch,type=push,method=bind,transport=zeromq,sndBufSize=2,address=tcp://127.0.0.1:$_iPort,rateLogging=$_ratelog"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
UNPACKER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iBranch"
UNPACKER_LOG+="_$LOGFILETAG"
# xterm -l -lf $UNPACKER_LOG -geometry 132x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &> $UNPACKER_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
done
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
PID_LOG="pids_$LOGFILETAG"
echo $LIST_OF_PIDS &> $PID_LOG
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 1 ]; then
_nbmoni=$1
((_pubfreqts = $_nbmoni*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 4 ]; then
_filename=""
_dirname=""
_hostname=$4
if [ $# -ge 5 ]; then
_pubfreqts=$5
if [ $# -ge 6 ]; then
_pubminsec=$6
if [ $# -ge 7 ]; then
_pubmaxsec=$7
fi
fi
fi
elif [ $# -ge 2 ]; then
_filename=$2
_hostname=""
if [ $# -eq 3 ]; then
_dirname=$3
else
_dirname=""
fi
else
echo 'Starting connection to local stream'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
fi
else
echo 'Starting connection to local stream with 1 monitor process'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
_nbmoni=1
_pubfreqts=100
_pubminsec=1.0
_pubmaxsec=10.0
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2021/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2021/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2021/mTofCriPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2021/mRichPar_70.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2021/mPsdPar.par
_setup_name=mcbm_beam_2021_07_surveyed
_run_id=1588
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbmoni ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="RepReqTsSampler"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 100"
SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --fles-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 1000"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --PubFreqTs $_pubfreqts"
SAMPLER+=" --PubTimeMin $_pubminsec"
SAMPLER+=" --PubTimeMax $_pubmaxsec"
SAMPLER+=" --channel-config name=ts-request,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11555"
SAMPLER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007"
SAMPLER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
echo $SAMPLER
_iMoni=0
while (( _iMoni < _nbmoni )); do
(( _yOffset=200*_iMoni ))
(( _iMoni += 1 ))
(( _iPort = 11680 + _iMoni ))
UNPACKER="MqUnpack"
UNPACKER+=" --id unp$_iMoni"
UNPACKER+=" --severity info"
#UNPACKER+=" --severity debug"
UNPACKER+=" --Setup $_setup_name"
UNPACKER+=" --RunId $_run_id"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --SetTimeOffs kSTS,-2221"
UNPACKER+=" --SetTimeOffs kMUCH,-885"
UNPACKER+=" --SetTimeOffs kTRD,0"
UNPACKER+=" --SetTimeOffs kTRD2D,-1800"
UNPACKER+=" --SetTimeOffs kTOF,-1220"
UNPACKER+=" --SetTimeOffs kRICH,254800"
UNPACKER+=" --SetTimeOffs kPSD,0"
UNPACKER+=" --PubFreqTs $_pubfreqts"
UNPACKER+=" --PubTimeMin $_pubminsec"
UNPACKER+=" --PubTimeMax $_pubmaxsec"
UNPACKER+=" --TsNameOut unpts$_iMoni"
UNPACKER+=" --channel-config name=ts-request,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11555"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
UNPACKER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iMoni"
UNPACKER_LOG+="_$LOGFILETAG"
xterm -l -lf $UNPACKER_LOG -geometry 132x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
EVTBUILDER="BuildDigiEvents"
EVTBUILDER+=" --id build$_iMoni"
EVTBUILDER+=" --severity info"
#EVTBUILDER+=" --severity debug"
EVTBUILDER+=" --PubFreqTs $_pubfreqts"
EVTBUILDER+=" --PubTimeMin $_pubminsec"
EVTBUILDER+=" --PubTimeMax $_pubmaxsec"
EVTBUILDER+=" --FillHistos true"
EVTBUILDER+=" --IgnTsOver false"
EVTBUILDER+=" --EvtOverMode AllowOverlap"
EVTBUILDER+=" --RefDet kTof"
EVTBUILDER+=" --DelDet kT0"
EVTBUILDER+=" --DelDet kMuch"
EVTBUILDER+=" --SetTrigWin kSts,-100,100"
EVTBUILDER+=" --SetTrigWin kTrd,-250,250"
EVTBUILDER+=" --SetTrigWin kTof,-150,150" # To get T0 Digis (seed + close-by digis) in the event
EVTBUILDER+=" --SetTrigWin kRich,-100,100"
EVTBUILDER+=" --SetTrigWin kPsd,-100,100"
EVTBUILDER+=" --SetTrigMinNb kSts,0"
EVTBUILDER+=" --SetTrigMinNb kTrd,0"
EVTBUILDER+=" --SetTrigMinNb kTof,6"
EVTBUILDER+=" --SetTrigMinNb kRich,0"
EVTBUILDER+=" --SetTrigMinNb kPsd,0"
EVTBUILDER+=" --TsNameIn unpts$_iMoni"
EVTBUILDER+=" --EvtNameOut events"
EVTBUILDER+=" --channel-config name=unpts$_iMoni,type=pull,method=connect,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
EVTBUILDER+=" --channel-config name=events,type=push,method=connect,transport=zeromq,address=tcp://127.0.0.1:11556"
# EVTBUILDER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTBUILDER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
EVTBUILDER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTBUILDER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTBUILDER_LOG="build$_iMoni"
EVTBUILDER_LOG+="_$LOGFILETAG"
xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
done
EVTSINK="DigiEventSink"
EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info"
#EVTSINK+=" --severity debug"
#EVTSINK+=" --StoreFullTs 1"
EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos false"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTSINK+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG"
xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --libs-to-load=libCbmFlibMcbm2018" # doesn't work due to runtime problem
PARAMETERSERVER+=" --setup $_setup_name"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
HISTSERVER="MqHistoServer"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 3 ]; then
_nbbranch=$1
_TriggSet=$2
_run_id=$3
((_pubfreqts = $_nbbranch*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 6 ]; then
_filename=""
_dirname=""
_hostname=$6
if [ $# -ge 7 ]; then
_pubfreqts=$7
if [ $# -ge 8 ]; then
_pubminsec=$8
if [ $# -ge 9 ]; then
_pubmaxsec=$9
fi
fi
fi
elif [ $# -ge 4 ]; then
_filename=$4
_hostname=""
if [ $# -eq 5 ]; then
_dirname=$5
else
_dirname=""
fi
else
echo 'Missing parameters or wrong number of parameters.'
echo 'Possible usages are:'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> <full filename pattern list>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> <filename pattern> <folder_path>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
return -1
fi
else
echo 'Missing parameters. At least the number of branches and the trigger set are required'
echo 'Possible usages are:'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> <full filename pattern list>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> <filename pattern> <folder_path>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startBuildRawEvents2022.sh <Nb // branches> <Trigger set> <Run Id> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
return -1
fi
########################################################################################################################
# Setup file and parameter files for parameter server
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2022/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v22d_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriPar.par
_parfileBmon=@VMCWORKDIR@/macro/beamtime/mcbm2022/mBmonCriPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2021/mRichPar_70.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2021/mPsdPar.par
_setup_name=mcbm_beam_2022_03_22_iron
# Parameter files => Update depending on run ID!!!
# --> Setup
if [ $_run_id -ge 2060 ]; then
if [ $_run_id -le 2065 ]; then
_setup_name=mcbm_beam_2022_03_09_carbon
elif [ $_run_id -le 2160 ]; then # Potentially wrong setup between 2065 and 2150 but not official runs
_setup_name=mcbm_beam_2022_03_22_iron
elif [ $_run_id -le 2310 ]; then # Potentially wrong setup between 2160 and 2176 but not official runs
_setup_name=mcbm_beam_2022_03_28_uranium
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v22g_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v22g_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v22g_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v22g_mcbm.gain.par
elif [ $_run_id -le 2397 ]; then # Potentially wrong setup between 2310 and 2350 but not official runs
_setup_name=mcbm_beam_2022_05_23_nickel
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.gain.par
elif [ $_run_id -le 2497 ]; then # Potentially wrong setup between 2397 and 2454 but not official runs
_setup_name=mcbm_beam_2022_06_16_gold
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v22h_mcbm.gain.par
fi
fi
# --> mMUCH
if [ $_run_id -ge 2060 ]; then
if [ $_run_id -le 2162 ]; then
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto26032022.par # Valid for runs 2060-2162
elif [ $_run_id -le 2291 ]; then
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto03042022.par # Valid for runs 2163-2291
elif [ $_run_id -le 2315 ]; then
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto10042022.par # Valid for runs 2292-2315
elif [ $_run_id -le 2366 ]; then
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto23052022.par # Valid for runs 2316-2366
elif [ $_run_id -le 2397 ]; then
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchParUpto26052022.par # Valid for runs 2060-2162
else
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2022/mMuchPar.par # Valid for runs 2398 and higher until further notice
fi
fi
# --> mTOF
if [ $_run_id -ge 2060 ]; then
if [ $_run_id -le 2065 ]; then
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriParCarbon.par # Valid for runs 2060-2065
elif [ $_run_id -le 2160 ]; then # Potentially wrong setup between 2065 and 2150 but not official runs
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriParIron.par # Valid for runs 2150-2160
elif [ $_run_id -le 2310 ]; then # Potentially wrong setup between 2160 and 2176 but not official runs
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriParUranium.par # Valid for runs 2176-2310
elif [ $_run_id -le 2497 ]; then # Potentially wrong setup between 2310 and 2335 but not official runs
# Nickel runs: 2335 - 2397
# Gold runs: 2400 - 2497
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriParNickel.par # Valid for runs 2335-2497
else
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriPar.par # Up to TOF team to tune for testing
fi
fi
########################################################################################################################
_ratelog=0 # hides ZMQ messages rates and bandwidth
#_ratelog=1 # display ZMQ messages rates and bandwidth
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
# Apply sets of settings for different triggers
case $_TriggSet in
0) # default, any Tof hit
_TofMean=20
_TofWin=100
_TofMin=1
_T0Min=0
_StsMin=0
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
1) # default, Tof - T0 concidences (pulser)
_TofMean=20
_TofWin=200
_TofMin=2
_TofMinLay=1
_T0Min=1
_StsMin=0
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
2) # Tof standalone track trigger (cosmic)
_TofMean=20
_TofWin=50
_TofMin=8
_TofMinLay=4
_T0Min=0
_StsMin=0
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
3) # Tof track trigger with T0
_TofMean=20
_TofWin=50
_TofMin=8
_TofMinLay=4
_T0Min=1
_StsMin=0
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
4) # mCbm track trigger Tof, T0 & STS
_TofMean=20
_TofWin=50
_TofMin=8
_TofMinLay=4
_T0Min=1
_StsMin=2
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
5) # mCbm lambda trigger
_TofMean=20
_TofWin=40
_TofMin=16
_TofMinLay=8 # PAL 07/04/2022: Not sure here if it should be 4 or 8 (2 tracks in same det. stack excluded?)
_T0Min=1
_StsMin=8
_StsMinLay=0
_MuchMin=0
_Trd1dMin=0
_Trd2dMin=0
_RichMin=0
;;
6) # One hit per detector system w/ big acceptance = mCbm full track trigger
_TofMean=20
_TofWin=50
_TofMin=8
_TofMinLay=4
_T0Min=1
_StsMin=4
_StsMinLay=0
_MuchMin=2
_Trd1dMin=2
_Trd2dMin=0
_RichMin=0
esac
echo Using MQ trigger par set: $_TriggSet
# Compute limits of TOF selection/trigger window
_TofL=$_TofMean
_TofH=$_TofMean
(( _TofL -= _TofWin))
(( _TofH += _TofWin))
echo Tof window $_TofL - $_TofH
LIST_OF_PIDS=""
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbbranch ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="RepReqTsSampler"
SAMPLER+=" --control static"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 30"
#SAMPLER+=" --max-timeslices 100"
#SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --max-timeslices -1"
#SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --fles-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 10"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --PubFreqTs $_pubfreqts"
SAMPLER+=" --PubTimeMin $_pubminsec"
SAMPLER+=" --PubTimeMax $_pubmaxsec"
SAMPLER+=" --channel-config name=ts-request,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11555,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006,rateLogging=$_ratelog"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007,rateLogging=$_ratelog"
SAMPLER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
# xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &> $SAMPLER_LOG &
echo $SAMPLER
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --control static"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileBmon;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
#PARAMETERSERVER+=" --libs-to-load=CbmStsBase;CbmMuchBase;CbmTrdBase;CbmTofBase;CbmRichBase" # doesn't work due to runtime problem
PARAMETERSERVER+=" --setup $_setup_name"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
# xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &> $PARAMSRV_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
HISTSERVER="MqHistoServer"
HISTSERVER+=" --control static"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
# xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &> $HISTSRV_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
sleep 1
_iBranch=0
while (( _iBranch < _nbbranch )); do
(( _yOffset=200*_iBranch ))
(( _iBranch += 1 ))
(( _iPort = 11680 + _iBranch ))
UNPACKER="MqUnpack"
UNPACKER+=" --control static"
UNPACKER+=" --id unp$_iBranch"
#UNPACKER+=" --severity error"
UNPACKER+=" --severity info"
#UNPACKER+=" --severity debug"
UNPACKER+=" --Setup $_setup_name"
UNPACKER+=" --RunId $_run_id"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --UnpBmon true"
UNPACKER+=" --UnpMuch true"
UNPACKER+=" --UnpPsd false"
UNPACKER+=" --SetTimeOffs kT0,0"
UNPACKER+=" --SetTimeOffs kSTS,-980"
UNPACKER+=" --SetTimeOffs kMUCH,-980"
UNPACKER+=" --SetTimeOffs kTRD,1300"
UNPACKER+=" --SetTimeOffs kTRD2D,-510"
UNPACKER+=" --SetTimeOffs kTOF,40"
UNPACKER+=" --SetTimeOffs kRICH,130"
UNPACKER+=" --PubFreqTs $_pubfreqts"
UNPACKER+=" --PubTimeMin $_pubminsec"
UNPACKER+=" --PubTimeMax $_pubmaxsec"
UNPACKER+=" --TsNameOut unpts$_iBranch"
UNPACKER+=" --channel-config name=ts-request,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11555,rateLogging=$_ratelog"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iBranch,type=push,method=bind,transport=zeromq,sndBufSize=2,address=tcp://127.0.0.1:$_iPort,rateLogging=$_ratelog"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
UNPACKER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iBranch"
UNPACKER_LOG+="_$LOGFILETAG"
# xterm -l -lf $UNPACKER_LOG -geometry 132x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &> $UNPACKER_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
EVTBUILDER="BuildDigiEvents"
EVTBUILDER+=" --control static"
EVTBUILDER+=" --id build$_iBranch"
EVTBUILDER+=" --severity info"
#EVTBUILDER+=" --severity debug"
EVTBUILDER+=" --PubFreqTs $_pubfreqts"
EVTBUILDER+=" --PubTimeMin $_pubminsec"
EVTBUILDER+=" --PubTimeMax $_pubmaxsec"
EVTBUILDER+=" --FillHistos true"
# EVTBUILDER+=" --FillHistos false"
EVTBUILDER+=" --IgnTsOver false"
EVTBUILDER+=" --EvtOverMode AllowOverlap"
EVTBUILDER+=" --RefDet kTof"
EVTBUILDER+=" --AddDet kT0"
EVTBUILDER+=" --AddDet kMuch"
EVTBUILDER+=" --DelDet kPsd"
EVTBUILDER+=" --SetTrigWin kT0,-100,100"
EVTBUILDER+=" --SetTrigWin kSts,-60,60"
EVTBUILDER+=" --SetTrigWin kMuch,-400,400"
EVTBUILDER+=" --SetTrigWin kTrd,-300,300"
EVTBUILDER+=" --SetTrigWin kTrd2D,-300,300"
EVTBUILDER+=" --SetTrigWin kTof,$_TofL,$_TofH"
EVTBUILDER+=" --SetTrigWin kRich,-60,60"
EVTBUILDER+=" --SetTrigMinNb kT0,$_T0Min"
EVTBUILDER+=" --SetTrigMinNb kSts,$_StsMin"
EVTBUILDER+=" --SetTrigMinNb kMuch,0"
EVTBUILDER+=" --SetTrigMinNb kTrd,0"
EVTBUILDER+=" --SetTrigMinNb kTrd2D,0"
EVTBUILDER+=" --SetTrigMinNb kTof,$_TofMin"
EVTBUILDER+=" --SetTrigMinNb kRich,0"
EVTBUILDER+=" --SetTrigMinLayersNb kTof,$_TofMinLay"
EVTBUILDER+=" --SetTrigMinLayersNb kSts,$_StsMinLay"
EVTBUILDER+=" --TsNameIn unpts$_iBranch"
EVTBUILDER+=" --EvtNameOut events"
EVTBUILDER+=" --channel-config name=unpts$_iBranch,type=pull,method=connect,transport=zeromq,rcvBufSize=2,address=tcp://127.0.0.1:$_iPort,rateLogging=$_ratelog"
EVTBUILDER+=" --channel-config name=events,type=push,method=connect,transport=zeromq,sndBufSize=2,address=tcp://127.0.0.1:11556,rateLogging=$_ratelog"
# EVTBUILDER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTBUILDER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
EVTBUILDER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
EVTBUILDER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTBUILDER_LOG="build$_iBranch"
EVTBUILDER_LOG+="_$LOGFILETAG"
# xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
nohup @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &> $EVTBUILDER_LOG &
VALGRIND_EVT="valgrind -v --error-limit=no --suppressions=$ROOTSYS/etc/root/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_evt_log.txt"
VALGHEAP_EVT="valgrind --tool=massif --massif-out-file=valgrind_evt_massif.out"
# nohup $VALGRIND_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &> $EVTBUILDER_LOG &
# nohup $VALGHEAP_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &> $EVTBUILDER_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
done
EVTSINK="DigiEventSink"
EVTSINK+=" --control static"
EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info"
#EVTSINK+=" --severity debug"
#EVTSINK+=" --StoreFullTs 1"
#EVTSINK+=" --BypassConsecutiveTs 1"
EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos true"
#EVTSINK+=" --BypassConsecutiveTs true"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,rcvBufSize=$_nbbranch,address=tcp://127.0.0.1:11556,rateLogging=$_ratelog"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006,rateLogging=$_ratelog"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007,rateLogging=$_ratelog"
EVTSINK+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666,rateLogging=$_ratelog"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG"
# xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
nohup @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &> $EVTSINK_LOG &
LIST_OF_PIDS+=$!
LIST_OF_PIDS+=" "
PID_LOG="pids_$LOGFILETAG"
echo $LIST_OF_PIDS &> $PID_LOG
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 1 ]; then
_nbmoni=$1
((_pubfreqts = $_nbmoni*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 4 ]; then
_filename=""
_dirname=""
_hostname=$4
if [ $# -ge 5 ]; then
_pubfreqts=$5
if [ $# -ge 6 ]; then
_pubminsec=$6
if [ $# -ge 7 ]; then
_pubmaxsec=$7
fi
fi
fi
elif [ $# -ge 2 ]; then
_filename=$2
_hostname=""
if [ $# -eq 3 ]; then
_dirname=$3
else
_dirname=""
fi
else
echo 'Starting connection to local stream'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
fi
else
echo 'Starting connection to local stream with 1 monitor process'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
_nbmoni=1
_pubfreqts=100
_pubminsec=1.0
_pubmaxsec=10.0
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2021/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2021/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/macro/beamtime/mcbm2022/trd_v21b_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v21b_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2022/mTofCriPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2021/mRichPar_70.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2021/mPsdPar.par
_setup_name=mcbm_beam_2021_07_surveyed
_run_id=1660
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbmoni ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="RepReqTsSampler"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 100"
#SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --fles-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 1000"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --PubFreqTs $_pubfreqts"
SAMPLER+=" --PubTimeMin $_pubminsec"
SAMPLER+=" --PubTimeMax $_pubmaxsec"
SAMPLER+=" --channel-config name=ts-request,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11555"
SAMPLER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007"
SAMPLER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
echo $SAMPLER
_iMoni=0
while (( _iMoni < _nbmoni )); do
(( _yOffset=200*_iMoni ))
(( _iMoni += 1 ))
(( _iPort = 11680 + _iMoni ))
UNPACKER="MqUnpack"
UNPACKER+=" --id unp$_iMoni"
#UNPACKER+=" --severity error"
UNPACKER+=" --severity info"
#UNPACKER+=" --severity debug"
UNPACKER+=" --Setup $_setup_name"
UNPACKER+=" --RunId $_run_id"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --SetTimeOffs kSTS,-2221"
UNPACKER+=" --SetTimeOffs kMUCH,-885"
UNPACKER+=" --SetTimeOffs kTRD,0"
UNPACKER+=" --SetTimeOffs kTRD2D,-1800"
UNPACKER+=" --SetTimeOffs kTOF,-1220"
UNPACKER+=" --SetTimeOffs kRICH,254800"
UNPACKER+=" --SetTimeOffs kPSD,0"
UNPACKER+=" --PubFreqTs $_pubfreqts"
UNPACKER+=" --PubTimeMin $_pubminsec"
UNPACKER+=" --PubTimeMax $_pubmaxsec"
UNPACKER+=" --TsNameOut unpts$_iMoni"
UNPACKER+=" --channel-config name=ts-request,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11555"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
UNPACKER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iMoni"
UNPACKER_LOG+="_$LOGFILETAG"
xterm -l -lf $UNPACKER_LOG -geometry 132x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
EVTBUILDER="BuildDigiEvents"
EVTBUILDER+=" --id build$_iMoni"
EVTBUILDER+=" --severity info"
#EVTBUILDER+=" --severity debug"
EVTBUILDER+=" --PubFreqTs $_pubfreqts"
EVTBUILDER+=" --PubTimeMin $_pubminsec"
EVTBUILDER+=" --PubTimeMax $_pubmaxsec"
EVTBUILDER+=" --FillHistos true"
EVTBUILDER+=" --IgnTsOver false"
EVTBUILDER+=" --EvtOverMode AllowOverlap"
EVTBUILDER+=" --RefDet kTof"
EVTBUILDER+=" --DelDet kT0"
EVTBUILDER+=" --DelDet kMuch"
EVTBUILDER+=" --SetTrigWin kSts,-100,100"
EVTBUILDER+=" --SetTrigWin kTrd,-250,250"
EVTBUILDER+=" --SetTrigWin kTof,-150,150" # To get T0 Digis (seed + close-by digis) in the event
EVTBUILDER+=" --SetTrigWin kRich,-100,100"
EVTBUILDER+=" --SetTrigWin kPsd,-100,100"
EVTBUILDER+=" --SetTrigMinNb kSts,0"
EVTBUILDER+=" --SetTrigMinNb kTrd,0"
EVTBUILDER+=" --SetTrigMinNb kTof,6"
EVTBUILDER+=" --SetTrigMinNb kRich,0"
EVTBUILDER+=" --SetTrigMinNb kPsd,0"
EVTBUILDER+=" --TsNameIn unpts$_iMoni"
EVTBUILDER+=" --EvtNameOut events"
EVTBUILDER+=" --channel-config name=unpts$_iMoni,type=pull,method=connect,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
EVTBUILDER+=" --channel-config name=events,type=push,method=connect,transport=zeromq,address=tcp://127.0.0.1:11556"
# EVTBUILDER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTBUILDER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
EVTBUILDER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTBUILDER+=" --transport zeromq"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTBUILDER_LOG="build$_iMoni"
EVTBUILDER_LOG+="_$LOGFILETAG"
xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
done
EVTSINK="DigiEventSink"
EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info"
#EVTSINK+=" --severity debug"
#EVTSINK+=" --StoreFullTs 1"
EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos false"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTSINK+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG"
xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --libs-to-load=libCbmFlibMcbm2018" # doesn't work due to runtime problem
PARAMETERSERVER+=" --setup $_setup_name"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
HISTSERVER="MqHistoServer"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 1 ]; then
_nbmoni=$1
((_pubfreqts = $_nbmoni*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 4 ]; then
_filename=""
_dirname=""
_hostname=$4
if [ $# -ge 5 ]; then
_pubfreqts=$5
if [ $# -ge 6 ]; then
_pubminsec=$6
if [ $# -ge 7 ]; then
_pubmaxsec=$7
fi
fi
fi
elif [ $# -ge 2 ]; then
_filename=$2
_hostname=""
if [ $# -eq 3 ]; then
_dirname=$3
else
_dirname=""
fi
else
echo 'Starting connection to local stream'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
fi
else
echo 'Starting connection to local stream with 1 monitor process'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
_nbmoni=1
_pubfreqts=100
_pubminsec=1.0
_pubmaxsec=10.0
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2020/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2020/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2020/mTofPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2020/mRichPar.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2020/mPsdPar.par
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbmoni ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="MultiTsaSampler"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 100"
SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --flib-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 1000"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --channel-config name=fullts,type=push,method=bind,address=tcp://127.0.0.1:11555"
#SAMPLER+=" --channel-config name=fullts,type=push,method=bind,address=tcp://127.0.0.1:11555,sndBufSize=$_singBuffSz,rcvBuffSize=$_paraBuffSz"
#SAMPLER+=" --transport shmem"
SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
echo $SAMPLER
_iMoni=0
while (( _iMoni < _nbmoni )); do
(( _yOffset=200*_iMoni ))
(( _iMoni += 1 ))
(( _iPort = 11680 + _iMoni ))
UNPACKER="McbmUnpack"
UNPACKER+=" --id unp$_iMoni"
UNPACKER+=" --severity info"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --SetTimeOffs kSTS,-985"
UNPACKER+=" --SetTimeOffs kMUCH,-885"
UNPACKER+=" --SetTimeOffs kTRD,-25"
UNPACKER+=" --SetTimeOffs kTOF,25"
UNPACKER+=" --SetTimeOffs kRICH,-310"
UNPACKER+=" --SetTimeOffs kPSD,-240"
UNPACKER+=" --TsNameOut unpts$_iMoni"
UNPACKER+=" --channel-config name=fullts,type=pull,method=connect,address=tcp://127.0.0.1:11555"
#UNPACKER+=" --transport shmem"
UNPACKER+=" --transport zeromq"
#UNPACKER+=" --transport nanomsg"
# UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
# UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort,sndBufSize=$_paraBuffSz,rcvBuffSize=$_paraBuffSz"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
#UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
#UNPACKER+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
#UNPACKER+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iMoni"
UNPACKER_LOG+="_$LOGFILETAG"
VALGRIND_UNP="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_unp_log.txt"
VALGHEAP_UNP="valgrind -v --tool=massif --massif-out-file=valgrind_unp_massif.out"
xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
# xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e $VALGRIND_UNP @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
# xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e $VALGHEAP_UNP @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
EVTBUILDER="BuildRawEvents"
EVTBUILDER+=" --id build$_iMoni"
EVTBUILDER+=" --severity info"
EVTBUILDER+=" --PubFreqTs $_pubfreqts"
EVTBUILDER+=" --PubTimeMin $_pubminsec"
EVTBUILDER+=" --PubTimeMax $_pubmaxsec"
EVTBUILDER+=" --FillHistos true"
EVTBUILDER+=" --IgnTsOver false"
EVTBUILDER+=" --EvtOverMode NoOverlap"
EVTBUILDER+=" --SetTrigWin kT0,-1,10" # To get T0 Digis (seed + close-by digis) in the event
EVTBUILDER+=" --SetTrigWin kSts,-50,100"
EVTBUILDER+=" --SetTrigWin kMuch,-150,50"
EVTBUILDER+=" --SetTrigWin kTrd,-250,100"
EVTBUILDER+=" --SetTrigWin kTof,-150,10"
EVTBUILDER+=" --SetTrigWin kRich,-150,20"
EVTBUILDER+=" --SetTrigWin kPsd,-50,10"
EVTBUILDER+=" --SetTrigMinNb kT0,1"
EVTBUILDER+=" --SetTrigMinNb kSts,0"
EVTBUILDER+=" --SetTrigMinNb kMuch,0"
EVTBUILDER+=" --SetTrigMinNb kTrd,0"
EVTBUILDER+=" --SetTrigMinNb kTof,10"
EVTBUILDER+=" --SetTrigMinNb kRich,0"
EVTBUILDER+=" --SetTrigMinNb kPsd,0"
EVTBUILDER+=" --TsNameIn unpts$_iMoni"
EVTBUILDER+=" --EvtNameOut events"
EVTBUILDER+=" --channel-config name=unpts$_iMoni,type=pull,method=connect,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
#EVTBUILDER+=" --transport shmem"
EVTBUILDER+=" --transport zeromq"
#EVTBUILDER+=" --transport nanomsg"
EVTBUILDER+=" --channel-config name=events,type=push,method=connect,transport=zeromq,address=tcp://127.0.0.1:11556"
# EVTBUILDER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTBUILDER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
EVTBUILDER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTBUILDER+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
EVTBUILDER+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTBUILDER_LOG="build$_iMoni"
EVTBUILDER_LOG+="_$LOGFILETAG"
VALGRIND_EVT="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_evt_log.txt"
VALGHEAP_EVT="valgrind --tool=massif --massif-out-file=valgrind_evt_massif.out"
xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
# xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e $VALGRIND_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
# xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e $VALGHEAP_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
done
EVTSINK="McbmEventSink"
EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info"
EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos false"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556"
#EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556,sndBufSize=$_paraBuffSz,rcvBuffSize=$_unpBufSz"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTSINK+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTSINK+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
EVTSINK+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG"
VALGRIND_SINK="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_sink_log.txt"
VALGHEAP_SINK="valgrind -v --tool=massif --massif-out-file=valgrind_sink_massif.out"
VALGCPU_SINK="valgrind -v --tool=callgrind"
xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGRIND_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGHEAP_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGCPU_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
#PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --libs-to-load=libCbmFlibMcbm2018" # doesn't work due to runtime problem
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
HISTSERVER="MqHistoServer"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 1 ]; then
_nbmoni=$1
((_pubfreqts = $_nbmoni*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 4 ]; then
_filename=""
_dirname=""
_hostname=$4
if [ $# -ge 5 ]; then
_pubfreqts=$5
if [ $# -ge 6 ]; then
_pubminsec=$6
if [ $# -ge 7 ]; then
_pubmaxsec=$7
fi
fi
fi
elif [ $# -ge 2 ]; then
_filename=$2
_hostname=""
if [ $# -eq 3 ]; then
_dirname=$3
else
_dirname=""
fi
else
echo 'Starting connection to local stream'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
fi
else
echo 'Starting connection to local stream with 1 monitor process'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
_nbmoni=1
_pubfreqts=100
_pubminsec=1.0
_pubmaxsec=10.0
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2020/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2020/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2020/mTofPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2020/mRichPar.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2020/mPsdPar.par
LOGFILETAG=`hostname`
LOGFILETAG+="_"
LOGFILETAG+=`date +%Y_%m_%d_%H_%M_%S`
LOGFILETAG+=".log"
(( _paraBuffSz=100 ))
(( _singBuffSz=_paraBuffSz*_nbmoni ))
echo "Buffer size for parallel devices $_paraBuffSz"
echo "Buffer size for singleton devices $_singBuffSz"
SAMPLER="MultiTsaSampler"
SAMPLER+=" --id sampler1"
#SAMPLER+=" --max-timeslices 0"
#SAMPLER+=" --max-timeslices 10"
#SAMPLER+=" --max-timeslices 100"
SAMPLER+=" --max-timeslices 300"
#SAMPLER+=" --max-timeslices 1000"
SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --flib-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 1000"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --ChNameMissTs missedts"
SAMPLER+=" --ChNameCmds commands"
SAMPLER+=" --channel-config name=fullts,type=push,method=bind,address=tcp://127.0.0.1:11555"
#SAMPLER+=" --channel-config name=fullts,type=push,method=bind,address=tcp://127.0.0.1:11555,sndBufSize=$_singBuffSz,rcvBuffSize=$_paraBuffSz"
#SAMPLER+=" --transport shmem"
SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
SAMPLER+=" --channel-config name=missedts,type=pub,method=bind,address=tcp://127.0.0.1:11006"
SAMPLER+=" --channel-config name=commands,type=pub,method=bind,address=tcp://127.0.0.1:11007"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
SAMPLER_LOG="sampler1_$LOGFILETAG"
xterm -l -lf $SAMPLER_LOG -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
echo $SAMPLER
_iMoni=0
while (( _iMoni < _nbmoni )); do
(( _yOffset=200*_iMoni ))
(( _iMoni += 1 ))
(( _iPort = 11680 + _iMoni ))
UNPACKER="McbmUnpack"
UNPACKER+=" --id unp$_iMoni"
UNPACKER+=" --severity info"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --SetTimeOffs kSTS,-985"
UNPACKER+=" --SetTimeOffs kMUCH,-885"
UNPACKER+=" --SetTimeOffs kTRD,-25"
UNPACKER+=" --SetTimeOffs kTOF,25"
UNPACKER+=" --SetTimeOffs kRICH,-310"
UNPACKER+=" --SetTimeOffs kPSD,-240"
UNPACKER+=" --TsNameOut unpts$_iMoni"
UNPACKER+=" --channel-config name=fullts,type=pull,method=connect,address=tcp://127.0.0.1:11555"
#UNPACKER+=" --transport shmem"
UNPACKER+=" --transport zeromq"
#UNPACKER+=" --transport nanomsg"
# UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
# UNPACKER+=" --channel-config name=unpts$_iMoni,type=push,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort,sndBufSize=$_paraBuffSz,rcvBuffSize=$_paraBuffSz"
# UNPACKER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
#UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
#UNPACKER+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
#UNPACKER+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
UNPACKER_LOG="unp$_iMoni"
UNPACKER_LOG+="_$LOGFILETAG"
VALGRIND_UNP="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_unp_log.txt"
VALGHEAP_UNP="valgrind -v --tool=massif --massif-out-file=valgrind_unp_massif.out"
xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
# xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e $VALGRIND_UNP @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
# xterm -l -lf $UNPACKER_LOG -geometry 80x23+400+$_yOffset -hold -e $VALGHEAP_UNP @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
EVTBUILDER="McbmEventBuilderWin"
EVTBUILDER+=" --id build$_iMoni"
EVTBUILDER+=" --severity info"
EVTBUILDER+=" --PubFreqTs $_pubfreqts"
EVTBUILDER+=" --PubTimeMin $_pubminsec"
EVTBUILDER+=" --PubTimeMax $_pubmaxsec"
EVTBUILDER+=" --FillHistos true"
EVTBUILDER+=" --IgnTsOver false"
EVTBUILDER+=" --EvtOverMode NoOverlap"
EVTBUILDER+=" --SetTrigWin kT0,-1,10" # To get T0 Digis (seed + close-by digis) in the event
EVTBUILDER+=" --SetTrigWin kSts,-50,100"
EVTBUILDER+=" --SetTrigWin kMuch,-150,50"
EVTBUILDER+=" --SetTrigWin kTrd,-250,100"
EVTBUILDER+=" --SetTrigWin kTof,-150,10"
EVTBUILDER+=" --SetTrigWin kRich,-150,20"
EVTBUILDER+=" --SetTrigWin kPsd,-50,10"
EVTBUILDER+=" --SetTrigMinNb kT0,1"
EVTBUILDER+=" --SetTrigMinNb kSts,0"
EVTBUILDER+=" --SetTrigMinNb kMuch,0"
EVTBUILDER+=" --SetTrigMinNb kTrd,0"
EVTBUILDER+=" --SetTrigMinNb kTof,10"
EVTBUILDER+=" --SetTrigMinNb kRich,0"
EVTBUILDER+=" --SetTrigMinNb kPsd,0"
EVTBUILDER+=" --TsNameIn unpts$_iMoni"
EVTBUILDER+=" --EvtNameOut events"
EVTBUILDER+=" --channel-config name=unpts$_iMoni,type=pull,method=connect,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
#EVTBUILDER+=" --transport shmem"
EVTBUILDER+=" --transport zeromq"
#EVTBUILDER+=" --transport nanomsg"
EVTBUILDER+=" --channel-config name=events,type=push,method=connect,transport=zeromq,address=tcp://127.0.0.1:11556"
# EVTBUILDER+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTBUILDER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
EVTBUILDER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTBUILDER+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
EVTBUILDER+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTBUILDER_LOG="build$_iMoni"
EVTBUILDER_LOG+="_$LOGFILETAG"
VALGRIND_EVT="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_evt_log.txt"
VALGHEAP_EVT="valgrind --tool=massif --massif-out-file=valgrind_evt_massif.out"
xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
# xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e $VALGRIND_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
# xterm -l -lf $EVTBUILDER_LOG -geometry 80x23+800+$_yOffset -hold -e $VALGHEAP_EVT @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTBUILDER &
done
EVTSINK="McbmEventSink"
EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info"
EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos false"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556"
#EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11556,sndBufSize=$_paraBuffSz,rcvBuffSize=$_unpBufSz"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTSINK+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
EVTSINK+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
EVTSINK+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG"
VALGRIND_SINK="valgrind -v --error-limit=no --suppressions=$ROOTSYS/share/root/etc/valgrind-root.supp --leak-check=full --show-reachable=yes --log-file=valgrind_sink_log.txt"
VALGHEAP_SINK="valgrind -v --tool=massif --massif-out-file=valgrind_sink_massif.out"
VALGCPU_SINK="valgrind -v --tool=callgrind"
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGRIND_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
#xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGHEAP_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
xterm -l -lf $EVTSINK_LOG -geometry 80x23+1200+0 -hold -e $VALGCPU_SINK @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$EVTSINK &
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
#PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --libs-to-load=libCbmFlibMcbm2018" # doesn't work due to runtime problem
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
PARAMSRV_LOG="parmq_$LOGFILETAG"
xterm -l -lf $PARAMSRV_LOG -geometry 80x23+1600+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
HISTSERVER="MqHistoServer"
HISTSERVER+=" --id server1"
HISTSERVER+=" --severity info"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
HISTSRV_LOG="server1_$LOGFILETAG"
xterm -l -lf $HISTSRV_LOG -geometry 80x23+2000+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
#!/bin/bash
if [ -e @SIMPATH@/bin/fairmq-shmmonitor ]; then
@SIMPATH@/bin/fairmq-shmmonitor --cleanup
fi
if [ $# -ge 1 ]; then
_nbmoni=$1
((_pubfreqts = $_nbmoni*100 ))
_pubminsec=1.0
_pubmaxsec=10.0
if [ $# -ge 4 ]; then
_filename=""
_dirname=""
_hostname=$4
if [ $# -ge 5 ]; then
_pubfreqts=$5
if [ $# -ge 6 ]; then
_pubminsec=$6
if [ $# -ge 7 ]; then
_pubmaxsec=$7
fi
fi
fi
elif [ $# -ge 2 ]; then
_filename=$2
_hostname=""
if [ $# -eq 3 ]; then
_dirname=$3
else
_dirname=""
fi
else
echo 'Starting connection to local stream'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
fi
else
echo 'Starting connection to local stream with 1 monitor process'
echo ' for other usages, please supply at least a filename.'
echo 'Possible usages are:'
echo 'startMQMcbmPulserMonitor2020.sh'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <full filename pattern list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> <filename pattern> <folder_path>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s>'
echo 'startMQMcbmPulserMonitor2020.sh <Nb Unp & Moni processes> "" "" <hostname(s) list> <Hist publish freq. in TS> <Min Hist pub. in s> <Max Hist pub. in s>'
_filename=""
_dirname=""
_hostname="localhost"
_nbmoni=1
_pubfreqts=100
_pubminsec=1.0
_pubmaxsec=10.0
fi
_parfileSts=@VMCWORKDIR@/macro/beamtime/mcbm2020/mStsPar.par
_parfileMuch=@VMCWORKDIR@/macro/beamtime/mcbm2020/mMuchPar.par
_parfileTrdAsic=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.asic.par
_parfileTrdDigi=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.digi.par
_parfileTrdGas=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gas.par
_parfileTrdGain=@VMCWORKDIR@/parameters/trd/trd_v18q_mcbm.gain.par
_parfileTof=@VMCWORKDIR@/macro/beamtime/mcbm2020/mTofPar.par
_parfileRich=@VMCWORKDIR@/macro/beamtime/mcbm2020/mRichPar.par
_parfilePsd=@VMCWORKDIR@/macro/beamtime/mcbm2020/mPsdPar.par
SAMPLER="MultiTsaSampler"
SAMPLER+=" --id sampler1"
SAMPLER+=" --max-timeslices 0"
SAMPLER+=" --severity info"
#SAMPLER+=" --flib-port 10"
if [ "$_hostname" != "" ]; then
SAMPLER+=" --flib-host $_hostname"
elif [ "$_filename" != "" ]; then
SAMPLER+=" --filename $_filename"
if [ "$_dirname" != "" ]; then
SAMPLER+=" --dirname $_dirname"
fi
fi
SAMPLER+=" --high-water-mark 1000"
SAMPLER+=" --no-split-ts 1"
SAMPLER+=" --channel-config name=fullts,type=push,method=bind,address=tcp://127.0.0.1:11555"
#SAMPLER+=" --transport shmem"
SAMPLER+=" --transport zeromq"
#SAMPLER+=" --transport nanomsg"
xterm -l -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/source/$SAMPLER &
_iMoni=0
while (( _iMoni < _nbmoni )); do
(( _yOffset=200*_iMoni ))
(( _iMoni += 1 ))
(( _iPort = 11680 + _iMoni ))
UNPACKER="McbmUnpack"
UNPACKER+=" --id unp$_iMoni"
UNPACKER+=" --severity info"
UNPACKER+=" --IgnOverMs 1"
UNPACKER+=" --TsNameOut unpts$_iMoni"
UNPACKER+=" --channel-config name=fullts,type=pull,method=connect,address=tcp://127.0.0.1:11555"
#UNPACKER+=" --transport shmem"
UNPACKER+=" --transport zeromq"
#UNPACKER+=" --transport nanomsg"
# UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005"
UNPACKER+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
UNPACKER+=" --channel-config name=unpts$_iMoni,type=pub,method=bind,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
#UNPACKER+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
#UNPACKER+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
#UNPACKER+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
xterm -l -geometry 80x23+400+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$UNPACKER &
MONITOR="McbmMonitorPulser"
MONITOR+=" --id mon$_iMoni"
MONITOR+=" --severity info"
MONITOR+=" --PubFreqTs $_pubfreqts"
MONITOR+=" --PubTimeMin $_pubminsec"
MONITOR+=" --PubTimeMax $_pubmaxsec"
MONITOR+=" --TsNameIn unpts$_iMoni"
MONITOR+=" --channel-config name=unpts$_iMoni,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:$_iPort"
#MONITOR+=" --transport shmem"
MONITOR+=" --transport zeromq"
#MONITOR+=" --transport nanomsg"
MONITOR+=" --channel-config name=parameters,type=req,method=connect,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
MONITOR+=" --channel-config name=histogram-in,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11666"
MONITOR+=" --channel-config name=histo-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
MONITOR+=" --channel-config name=canvas-conf,type=pub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
xterm -l -geometry 80x23+800+$_yOffset -hold -e @CMAKE_BINARY_DIR@/bin/MQ/mcbm/$MONITOR &
done
PARAMETERSERVER="parmq-server"
PARAMETERSERVER+=" --id parmq-server"
PARAMETERSERVER+=" --severity info"
PARAMETERSERVER+=" --channel-name parameters"
#PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005"
PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,transport=zeromq,address=tcp://127.0.0.1:11005,rateLogging=0"
PARAMETERSERVER+=" --first-input-name $_parfileSts;$_parfileMuch;$_parfileTrdAsic;$_parfileTrdDigi;$_parfileTrdGas;$_parfileTrdGain;$_parfileTof;$_parfileRich;$_parfilePsd"
PARAMETERSERVER+=" --first-input-type ASCII"
PARAMETERSERVER+=" --libs-to-load=libCbmFlibMcbm2018" # doesn't work due to runtime problem
xterm -geometry 80x23+1200+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/parmq/$PARAMETERSERVER &
HISTSERVER="MqHistoServer"
HISTSERVER+=" --id server1"
HISTSERVER+=" --histport 8081"
HISTSERVER+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
HISTSERVER+=" --channel-config name=histo-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11667,rateLogging=0"
HISTSERVER+=" --channel-config name=canvas-conf,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11668,rateLogging=0"
xterm -geometry 80x23+1400+0 -hold -e @CMAKE_BINARY_DIR@/bin/MQ/histogramServer/$HISTSERVER &
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerMonitor.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerMonitor.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerT0Monitor2020.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerT0Monitor2020.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerBmonMonitor2020.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerBmonMonitor2020.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerTofMonitor2020.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerTofMonitor2020.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerBmonMonitor2021.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerBmonMonitor2021.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerTofMonitor2021.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerTofMonitor2021.sh)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerPsdMonitor2021.sh.in ${CMAKE_BINARY_DIR}/bin/MQ/topologies/startMQSamplerPsdMonitor2021.sh)
set(INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/MQ/base
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/monitor
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/parameter
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/dataformat
${CBMROOT_SOURCE_DIR}/fles/mcbm2018/commonMQ
${CBMROOT_SOURCE_DIR}/fles/flestools
${CBMDATA_DIR}
${CBMDATA_DIR}/tof
${CBMDATA_DIR}/raw
${CBMBASE_DIR}
)
Set(SYSTEM_INCLUDE_DIRECTORIES
${SYSTEM_INCLUDE_DIRECTORIES}
${ZeroMQ_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${FAIRROOT_INCLUDE_DIR}
${FAIRMQ_INCLUDE_DIR}
${FAIRMQ_INCLUDE_DIR}/options
${IPC_INCLUDE_DIRECTORY}
${CBMROOT_SOURCE_DIR}/external/cppzmq
)
include_directories(${INCLUDE_DIRECTORIES})
include_directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
set(LINK_DIRECTORIES
${ROOT_LIBRARY_DIR}
${FAIRROOT_LIBRARY_DIR}
${FAIRMQ_LIBRARY_DIR}
${Boost_LIBRARY_DIRS}
)
link_directories(${LINK_DIRECTORIES})
${CMAKE_CURRENT_SOURCE_DIR}
)
# Set the install path within the build directory
set(EXECUTABLE_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}/MQ/monitor")
# Set the install path within the installation directory
set(BIN_DESTINATION bin/MQ/monitor)
Set(BOOST_LIBS
${Boost_SYSTEM_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_LOG_LIBRARY}
)
If(UNIX AND NOT APPLE)
List(APPEND BOOST_LIBS pthread)
EndIf()
set(FAIR_LIBS
FairMQ
)
set(PUBLIC_DEPS
CbmMQBase
ROOT::Core
)
If(FAIRLOGGER_FOUND)
set(FAIR_LIBS
${FAIR_LIBS}
FairLogger
)
EndIf()
set(PRIVATE_DEPS
CbmFlibFlesTools
CbmFlibMcbm2018
FairRoot::ParBase
Boost::serialization
Boost::program_options
ROOT::Gpad
ROOT::Hist
ROOT::RIO
)
set(EXE_NAME T0MonitorMcbm2018)
set(SRCS CbmDeviceMonitorT0.cxx runMonitorT0.cxx)
set(INTERFACE_DEPS
FairMQ::FairMQ
external::fles_ipc
)
set(DEPENDENCIES
${DEPENDENCIES}
${FAIR_LIBS}
${BOOST_LIBS}
fles_ipc
CbmFlibMcbm2018
CbmFlibFlesTools
CbmBase
CbmData
Core
RIO
Net
Hist
RHTTP
)
#GENERATE_LIBRARY()
GENERATE_EXECUTABLE()
set(EXE_NAME BmonMonitorMcbm2018)
set(SRCS CbmDeviceMonitorBmon.cxx runMonitorBmon.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME TofMonitorMcbm2018)
set(SRCS CbmDeviceMonitorTof.cxx runMonitorTof.cxx)
set(DEPENDENCIES
${DEPENDENCIES}
${FAIR_LIBS}
${BOOST_LIBS}
fles_ipc
CbmFlibMcbm2018
CbmFlibFlesTools
CbmBase
CbmData
Core
RIO
Net
Hist
RHTTP
)
#GENERATE_LIBRARY()
GENERATE_EXECUTABLE()
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME BmonMonitorReqMcbm)
set(SRCS CbmDeviceMonitorReqBmon.cxx runMonitorReqBmon.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME TofMonitorReqMcbm)
set(SRCS CbmDeviceMonitorReqTof.cxx runMonitorReqTof.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
set(EXE_NAME PsdMonitorMcbm2018)
set(SRCS CbmDeviceMonitorPsd.cxx runMonitorPsd.cxx)
set(PUBLIC_DEPENDENCIES ${PUBLIC_DEPS})
set(PRIVATE_DEPENDENCIES ${PRIVATE_DEPS})
set(INTERFACE_DEPENDENCIES ${INTERFACE_DEPS})
generate_cbm_executable()
# Install scripts and input file
if(EXISTS ${VMCWORKDIR}/input/tofget4_hd2018.tsa)
install(FILES ${VMCWORKDIR}/input/tofget4_hd2018.tsa
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cbmroot/input
)
endif()
# Set the correct variables for the installation
set(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/cbmroot)
set(MY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CURRENT_SOURCE_DIR ${VMCWORKDIR}/input)
set(TMPDIR "${CMAKE_BINARY_DIR}")
set(CMAKE_BINARY_DIR ${CMAKE_INSTALL_PREFIX})
# Configure file for installation directory
configure_file(${MY_SOURCE_DIR}/startMQSamplerMonitor.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerMonitor.sh)
configure_file(${MY_SOURCE_DIR}/startMQSamplerBmonMonitor2020.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerBmonMonitor2020.sh)
configure_file(${MY_SOURCE_DIR}/startMQSamplerTofMonitor2020.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2020.sh)
configure_file(${MY_SOURCE_DIR}/startMQSamplerBmonMonitor2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerBmonMonitor2021.sh)
configure_file(${MY_SOURCE_DIR}/startMQSamplerTofMonitor2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2021.sh)
configure_file(${MY_SOURCE_DIR}/startMQSamplerPsdMonitor2021.sh.in ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerPsdMonitor2021.sh)
install(PROGRAMS ${TMPDIR}/bin/MQ/topologies/install/startMQSamplerMonitor.sh
${TMPDIR}/bin/MQ/topologies/install/startMQSamplerBmonMonitor2020.sh
${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2020.sh
${TMPDIR}/bin/MQ/topologies/install/startMQSamplerBmonMonitor2021.sh
${TMPDIR}/bin/MQ/topologies/install/startMQSamplerTofMonitor2021.sh
${TMPDIR}/bin/MQ/topologies/install/startMQSamplerPsdMonitor2021.sh
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/MQ/topologies
)
/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */
/**
* CbmDeviceMonitorBmon.cxx
*
* @since 2019-03-26
* @author F. Uhlig
*/
#include "CbmDeviceMonitorBmon.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMcbm2018MonitorAlgoBmon.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include "BoostSerializer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
#include "RootSerializer.h"
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
CbmDeviceMonitorBmon::CbmDeviceMonitorBmon()
: fbIgnoreOverlapMs {false}
, fsChannelNameDataInput {"t0component"}
, fsChannelNameHistosInput {"histogram-in"}
, fuHistoryHistoSize {3600}
, fuMinTotPulser {185}
, fuMaxTotPulser {195}
, fuOffSpillCountLimit {25}
, fuOffSpillCountLimitNonPulser {10}
, fdSpillCheckInterval {0.0128}
, fvuChanMap {0, 1, 2, 3, 4, 5, 6, 7}
, fuPublishFreqTs {100}
, fdMinPublishTime {0.5}
, fdMaxPublishTime {5.0}
, fsAllowedChannels {fsChannelNameDataInput}
, fParCList {nullptr}
, fulNumMessages {0}
, fulTsCounter {0}
, fLastPublishTime {std::chrono::system_clock::now()}
, fMonitorAlgo {new CbmMcbm2018MonitorAlgoBmon()}
, fArrayHisto {}
, fvpsHistosFolder {}
, fvpsCanvasConfig {}
{
}
void CbmDeviceMonitorBmon::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmMqStarHistoServer.";
fbIgnoreOverlapMs = fConfig->GetValue<bool>("IgnOverMs");
fuHistoryHistoSize = fConfig->GetValue<uint32_t>("HistEvoSz");
fuMinTotPulser = fConfig->GetValue<uint32_t>("PulsTotMin");
fuMaxTotPulser = fConfig->GetValue<uint32_t>("PulsTotMax");
fuOffSpillCountLimit = fConfig->GetValue<uint32_t>("SpillThr");
fuOffSpillCountLimitNonPulser = fConfig->GetValue<uint32_t>("SpillThrNonPuls");
fdSpillCheckInterval = fConfig->GetValue<double>("SpillCheckInt");
std::string sChanMap = fConfig->GetValue<std::string>("ChanMap");
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
fsAllowedChannels[0] = fsChannelNameDataInput;
UInt_t uChanIdx = 0;
size_t charPosDel = sChanMap.find(',');
while (uChanIdx < fvuChanMap.size() && std::string::npos != charPosDel) {
LOG(info) << sChanMap.substr(0, charPosDel);
fvuChanMap[uChanIdx] = std::stoul(sChanMap.substr(0, charPosDel));
LOG(info) << fvuChanMap[uChanIdx];
sChanMap = sChanMap.substr(charPosDel + 1);
LOG(info) << sChanMap;
uChanIdx++;
charPosDel = sChanMap.find(',');
} // while( uChanIdx < fvuChanMap.size() && std::string::npos != charPosDel )
if (uChanIdx < fvuChanMap.size()) {
LOG(info) << sChanMap;
fvuChanMap[uChanIdx] = std::stoul(sChanMap);
LOG(info) << fvuChanMap[uChanIdx];
} // if( uChanIdx < fvuChanMap.size() )
LOG(info) << "Histograms publication frequency in TS: " << fuPublishFreqTs;
LOG(info) << "Histograms publication min. interval in s: " << fdMinPublishTime;
LOG(info) << "Histograms publication max. interval in s: " << fdMaxPublishTime;
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (std::string::npos != entry.first.find(fsChannelNameDataInput)) {
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceMonitorBmon::HandleData);
} // if( entry.first.find( "ts" )
} // for( auto const &entry : fChannels )
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
bool CbmDeviceMonitorBmon::IsChannelNameAllowed(std::string channelName)
{
for (auto const& entry : fsAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fsAllowedChannels.begin(), fsAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fsAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
} // if (pos1!=std::string::npos)
} // for(auto const &entry : fsAllowedChannels)
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
bool CbmDeviceMonitorBmon::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceMonitorBmon.";
fParCList = fMonitorAlgo->GetParList();
for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string paramName {tempObj->GetName()};
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
// Her must come the proper Runid
std::string message = paramName + ",111";
LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
FairParGenericSet* newObj = nullptr;
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
newObj = static_cast<FairParGenericSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from the server:";
newObj->print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
} // if (rep->GetSize() != 0)
} // if (Receive(rep, "parameters") >= 0)
} // if (Send(req, "parameters") > 0)
fParCList->AddAt(newObj, iparC);
delete tempObj;
} // for ( int iparC = 0; iparC < fParCList->GetEntries(); iparC++ )
/// Need to add accessors for all options
fMonitorAlgo->SetIgnoreOverlapMs(fbIgnoreOverlapMs);
fMonitorAlgo->SetMonitorMode(kTRUE);
fMonitorAlgo->SetHistoryHistoSize(fuHistoryHistoSize);
fMonitorAlgo->SetPulserTotLimits(fuMinTotPulser, fuMaxTotPulser);
fMonitorAlgo->SetSpillThreshold(fuOffSpillCountLimit);
fMonitorAlgo->SetSpillThresholdNonPulser(fuOffSpillCountLimitNonPulser);
fMonitorAlgo->SetSpillCheckInterval(fdSpillCheckInterval);
fMonitorAlgo->SetChannelMap(fvuChanMap[0], fvuChanMap[1], fvuChanMap[2], fvuChanMap[3], fvuChanMap[4], fvuChanMap[5],
fvuChanMap[6], fvuChanMap[7]);
// fMonitorAlgo->AddMsComponentToList(0, 0x90);
Bool_t initOK = fMonitorAlgo->InitContainers();
return initOK;
}
bool CbmDeviceMonitorBmon::InitHistograms()
{
/// Histos creation and obtain pointer on them
/// Trigger histo creation on all associated algos
bool initOK = fMonitorAlgo->CreateHistograms();
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = fMonitorAlgo->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fMonitorAlgo->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceMonitorBmon::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
if (0 == fulNumMessages) {
try {
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
} // if( 0 == fulNumMessages)
if (0 == fulNumMessages) InitHistograms();
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
/// Create an empty TS and fill it with the incoming message
fles::StorableTimeslice component {0};
inputArchive >> component;
/// Process the Timeslice
DoUnpack(component, 0);
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
if (!fbConfigSent) {
// Send the configuration only once per run!
fbConfigSent = SendHistoConfAndData();
} // if( !fbConfigSent )
else
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
return true;
}
bool CbmDeviceMonitorBmon::SendHistoConfAndData()
{
/// Prepare multiparts message and header
std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size());
FairMQMessagePtr messageHeader(NewMessage());
// Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader);
BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader);
FairMQParts partsOut;
partsOut.AddPart(std::move(messageHeader));
for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) {
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]);
partsOut.AddPart(std::move(messageHist));
} // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto)
for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) {
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]);
partsOut.AddPart(std::move(messageCan));
} // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv)
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr msgHistos(NewMessage());
// Serialize<RootSerializer>(*msgHistos, &fArrayHisto);
RootSerializer().Serialize(*msgHistos, &fArrayHisto);
partsOut.AddPart(std::move(msgHistos));
/// Send the multi-parts message to the common histogram messages queue
if (Send(partsOut, fsChannelNameHistosInput) < 0) {
LOG(error) << "CbmDeviceMonitorBmon::SendHistoConfAndData => Problem sending data";
return false;
} // if( Send( partsOut, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
bool CbmDeviceMonitorBmon::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceMonitorBmon::~CbmDeviceMonitorBmon() {}
Bool_t CbmDeviceMonitorBmon::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
fulTsCounter++;
if (kFALSE == fbComponentsAddedToList) {
for (uint32_t uCompIdx = 0; uCompIdx < ts.num_components(); ++uCompIdx) {
if (kusSysId == ts.descriptor(uCompIdx, 0).sys_id) {
fMonitorAlgo->AddMsComponentToList(uCompIdx, kusSysId);
} // if( kusSysId == ts.descriptor( uCompIdx, 0 ).sys_id )
} // for( uint32_t uComp = 0; uComp < ts.num_components(); ++uComp )
fbComponentsAddedToList = kTRUE;
} // if( kFALSE == fbComponentsAddedToList )
if (kFALSE == fMonitorAlgo->ProcessTs(ts)) {
LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fMonitorAlgo->ProcessTs( ts ) )
/// Clear the digis vector in case it was filled
fMonitorAlgo->ClearVector();
if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << " time slices";
return kTRUE;
}
void CbmDeviceMonitorBmon::Finish() {}
/* Copyright (C) 2019-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */
/**
* CbmDeviceMonitorBmon.h
*
* @since 2019-03-26
* @author F. Uhlig
*/
#ifndef CBMDEVICEMONITORBmon_H_
#define CBMDEVICEMONITORBmon_H_
#include "CbmMqTMessage.h"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "Rtypes.h"
#include "TObjArray.h"
#include <chrono>
#include <map>
#include <vector>
class TList;
class CbmMcbm2018MonitorAlgoBmon;
class CbmDeviceMonitorBmon : public FairMQDevice {
public:
CbmDeviceMonitorBmon();
virtual ~CbmDeviceMonitorBmon();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
private:
/// Constants
static const uint16_t kusSysId = 0x90;
/// Control flags
Bool_t fbIgnoreOverlapMs; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Bool_t fbComponentsAddedToList = kFALSE;
/// User settings parameters
std::string fsChannelNameDataInput;
std::string fsChannelNameHistosInput;
uint32_t fuHistoryHistoSize;
uint32_t fuMinTotPulser;
uint32_t fuMaxTotPulser;
uint32_t fuOffSpillCountLimit;
uint32_t fuOffSpillCountLimitNonPulser;
double fdSpillCheckInterval;
std::vector<uint32_t> fvuChanMap;
uint32_t fuPublishFreqTs;
double_t fdMinPublishTime;
double_t fdMaxPublishTime;
/// List of MQ channels names
std::vector<std::string> fsAllowedChannels;
/// Parameters management
TList* fParCList;
/// Statistics & first TS rejection
uint64_t fulNumMessages;
uint64_t fulTsCounter;
std::chrono::system_clock::time_point fLastPublishTime;
/// Processing algo
CbmMcbm2018MonitorAlgoBmon* fMonitorAlgo;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto;
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder;
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig;
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
bool IsChannelNameAllowed(std::string channelName);
bool InitContainers();
bool InitHistograms();
bool DoUnpack(const fles::Timeslice& ts, size_t component);
void Finish();
bool SendHistoConfAndData();
bool SendHistograms();
};
#endif /* CBMDEVICEMONITORBmon_H_ */
/* Copyright (C) 2021 Institute for Nuclear Research, Moscow
SPDX-License-Identifier: GPL-3.0-only
Authors: Nikolay Karpushkin [committer] */
/**
* CbmDeviceMonitorPsd.cxx
*
* @since 2021-02-17
* @author N. Karpushkin
* @comment based on CbmDeviceMonitorBmon by F. Uhlig
*/
#include "CbmDeviceMonitorPsd.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMQDefs.h"
#include "CbmMcbm2018MonitorAlgoPsd.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include "BoostSerializer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
#include "RootSerializer.h"
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
CbmDeviceMonitorPsd::CbmDeviceMonitorPsd()
: fbIgnoreOverlapMs {false}
, fsChannelNameDataInput {"psdcomponent"}
, fsChannelNameHistosInput {"histogram-in"}
, fsChannelNameHistosConfig {"histo-conf"}
, fsChannelNameCanvasConfig {"canvas-conf"}
, fuPublishFreqTs {100}
, fdMinPublishTime {0.5}
, fdMaxPublishTime {5.0}
, fuHistoryHistoSize {3600}
, fviHistoChargeArgs(3, 0)
, fviHistoAmplArgs(3, 0)
, fviHistoZLArgs(3, 0)
, fsAllowedChannels {fsChannelNameDataInput}
, fParCList {nullptr}
, fulNumMessages {0}
, fulTsCounter {0}
, fLastPublishTime {std::chrono::system_clock::now()}
, fMonitorAlgo {new CbmMcbm2018MonitorAlgoPsd()}
, fArrayHisto {}
, fvpsHistosFolder {}
, fvpsCanvasConfig {}
{
}
void CbmDeviceMonitorPsd::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmMqStarHistoServer.";
fbIgnoreOverlapMs = fConfig->GetValue<bool>("IgnOverMs");
fbMonitorMode = fConfig->GetValue<bool>("MonitorMode");
fbMonitorChanMode = fConfig->GetValue<bool>("MonitorChanMode");
fbMonitorWfmMode = fConfig->GetValue<bool>("MonitorWfmMode");
fbMonitorFitMode = fConfig->GetValue<bool>("MonitorFitMode");
fuHistoryHistoSize = fConfig->GetValue<uint32_t>("HistEvoSz");
fviHistoChargeArgs = fConfig->GetValue<std::vector<int>>("HistChrgArgs");
fviHistoAmplArgs = fConfig->GetValue<std::vector<int>>("HistAmplArgs");
fviHistoZLArgs = fConfig->GetValue<std::vector<int>>("HistZlArgs");
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
fsChannelNameHistosConfig = fConfig->GetValue<std::string>("ChNameHistCfg");
fsChannelNameCanvasConfig = fConfig->GetValue<std::string>("ChNameCanvCfg");
fsAllowedChannels[0] = fsChannelNameDataInput;
LOG(info) << "Histograms publication frequency in TS: " << fuPublishFreqTs;
LOG(info) << "Histograms publication min. interval in s: " << fdMinPublishTime;
LOG(info) << "Histograms publication max. interval in s: " << fdMaxPublishTime;
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
//logger::SetLogLevel("INFO");
int noChannel = fChannels.size();
LOG(info) << "Number of defined channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (std::string::npos != entry.first.find(fsChannelNameDataInput)) {
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
OnData(entry.first, &CbmDeviceMonitorPsd::HandleData);
} // if( entry.first.find( "ts" )
} // for( auto const &entry : fChannels )
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
// Wrapper defined in CbmMQDefs.h to support different FairMQ versions
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
}
bool CbmDeviceMonitorPsd::IsChannelNameAllowed(std::string channelName)
{
for (auto const& entry : fsAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fsAllowedChannels.begin(), fsAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fsAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx;
return true;
} // if (pos1!=std::string::npos)
} // for(auto const &entry : fsAllowedChannels)
LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names.";
LOG(error) << "Stop device.";
return false;
}
Bool_t CbmDeviceMonitorPsd::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceMonitorPsd.";
fParCList = fMonitorAlgo->GetParList();
for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string paramName {tempObj->GetName()};
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
// Her must come the proper Runid
std::string message = paramName + ",111";
LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
FairParGenericSet* newObj = nullptr;
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
newObj = static_cast<FairParGenericSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from the server:";
newObj->print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
} // if (rep->GetSize() != 0)
} // if (Receive(rep, "parameters") >= 0)
} // if (Send(req, "parameters") > 0)
fParCList->AddAt(newObj, iparC);
delete tempObj;
} // for ( int iparC = 0; iparC < fParCList->GetEntries(); iparC++ )
/// Need to add accessors for all options
fMonitorAlgo->SetIgnoreOverlapMs(fbIgnoreOverlapMs);
fMonitorAlgo->SetMonitorMode(fbMonitorMode);
fMonitorAlgo->SetMonitorChanMode(fbMonitorChanMode);
fMonitorAlgo->SetMonitorWfmMode(fbMonitorWfmMode);
fMonitorAlgo->SetMonitorFitMode(fbMonitorFitMode);
fMonitorAlgo->SetHistoryHistoSize(fuHistoryHistoSize);
fMonitorAlgo->SetChargeHistoArgs(fviHistoChargeArgs);
fMonitorAlgo->SetAmplHistoArgs(fviHistoAmplArgs);
fMonitorAlgo->SetZLHistoArgs(fviHistoZLArgs);
//fMonitorAlgo->AddMsComponentToList(0, 0x80);
Bool_t initOK = fMonitorAlgo->InitContainers();
// Bool_t initOK = fMonitorAlgo->ReInitContainers();
/// Histos creation and obtain pointer on them
/// Trigger histo creation on all associated algos
initOK &= fMonitorAlgo->CreateHistograms();
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = fMonitorAlgo->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fMonitorAlgo->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, psHistoConfig);
/// Send message to the common histogram config messages queue
if (Send(messageHist, fsChannelNameHistosConfig) < 0) {
LOG(error) << "Problem sending histo config";
return false;
} // if( Send( messageHist, fsChannelNameHistosConfig ) < 0 )
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, psCanvConfig);
/// Send message to the common canvas config messages queue
if (Send(messageCan, fsChannelNameCanvasConfig) < 0) {
LOG(error) << "Problem sending canvas config";
return false;
} // if( Send( messageCan, fsChannelNameCanvasConfig ) < 0 )
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
bool CbmDeviceMonitorPsd::HandleData(FairMQMessagePtr& msg, int /*index*/)
{
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
/// Create an empty TS and fill it with the incoming message
fles::StorableTimeslice component {0};
inputArchive >> component;
/// Process the Timeslice
DoUnpack(component, 0);
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
return true;
}
bool CbmDeviceMonitorPsd::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceMonitorPsd::~CbmDeviceMonitorPsd() {}
Bool_t CbmDeviceMonitorPsd::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
if (kFALSE == fbComponentsAddedToList) {
for (uint32_t uCompIdx = 0; uCompIdx < ts.num_components(); ++uCompIdx) {
if (kusSysId == ts.descriptor(uCompIdx, 0).sys_id) {
fMonitorAlgo->AddMsComponentToList(uCompIdx, kusSysId);
} // if( kusSysId == ts.descriptor( uCompIdx, 0 ).sys_id )
} // for( uint32_t uComp = 0; uComp < ts.num_components(); ++uComp )
fbComponentsAddedToList = kTRUE;
} // if( kFALSE == fbComponentsAddedToList )
if (kFALSE == fMonitorAlgo->ProcessTs(ts)) {
LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fMonitorAlgo->ProcessTs( ts ) )
/// Clear the digis vector in case it was filled
fMonitorAlgo->ClearVector();
if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << "TS";
fulTsCounter++;
return kTRUE;
}
void CbmDeviceMonitorPsd::Finish() {}
/* Copyright (C) 2021 Institute for Nuclear Research, Moscow
SPDX-License-Identifier: GPL-3.0-only
Authors: Nikolay Karpushkin [committer] */
/**
* CbmDeviceMonitorPsd.h
*
* @since 2021-02-17
* @author N. Karpushkin
* @comment based on CbmDeviceMonitorBmon by F. Uhlig
*/
#ifndef CBMDEVICEMONITORPSD_H_
#define CBMDEVICEMONITORPSD_H_
#include "CbmMqTMessage.h"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "Rtypes.h"
#include "TObjArray.h"
#include <chrono>
#include <map>
#include <vector>
class TList;
class CbmMcbm2018MonitorAlgoPsd;
class CbmDeviceMonitorPsd : public FairMQDevice {
public:
CbmDeviceMonitorPsd();
virtual ~CbmDeviceMonitorPsd();
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
private:
/// Constants
static const uint16_t kusSysId = 0x80;
Bool_t fbComponentsAddedToList = kFALSE;
/// Control flags
Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
Bool_t fbIgnoreOverlapMs; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Bool_t fbMonitorChanMode; //! Switch ON the filling channelwise histograms
Bool_t fbMonitorWfmMode; //! Switch ON the filling waveforms histograms
Bool_t fbMonitorFitMode; //! Switch ON the filling waveform fitting histograms
// Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
/// User settings parameters
std::string fsChannelNameDataInput;
std::string fsChannelNameHistosInput;
std::string fsChannelNameHistosConfig;
std::string fsChannelNameCanvasConfig;
uint32_t fuPublishFreqTs;
double_t fdMinPublishTime;
double_t fdMaxPublishTime;
UInt_t fuHistoryHistoSize;
std::vector<Int_t> fviHistoChargeArgs; /** Charge histogram arguments in adc counts **/
std::vector<Int_t> fviHistoAmplArgs; /** Amplitude histogram arguments in adc counts **/
std::vector<Int_t> fviHistoZLArgs; /** ZeroLevel histogram arguments in adc counts **/
/// List of MQ channels names
std::vector<std::string> fsAllowedChannels;
/// Parameters management
TList* fParCList;
/// Statistics & first TS rejection
uint64_t fulNumMessages;
uint64_t fulTsCounter;
std::chrono::system_clock::time_point fLastPublishTime;
/// Processing algo
CbmMcbm2018MonitorAlgoPsd* fMonitorAlgo;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto;
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder;
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig;
bool IsChannelNameAllowed(std::string channelName);
Bool_t InitContainers();
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
void Finish();
bool SendHistograms();
};
#endif /* CBMDEVICEMONITORPSD_H_ */
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceMonitorReqBmon.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMcbm2018MonitorAlgoBmon.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include "BoostSerializer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
#include "RootSerializer.h"
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
CbmDeviceMonitorReqBmon::CbmDeviceMonitorReqBmon() : fMonitorAlgo {new CbmMcbm2018MonitorAlgoBmon()} {}
void CbmDeviceMonitorReqBmon::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmMqStarHistoServer.";
fbIgnoreOverlapMs = fConfig->GetValue<bool>("IgnOverMs");
fuHistoryHistoSize = fConfig->GetValue<uint32_t>("HistEvoSz");
fuMinTotPulser = fConfig->GetValue<uint32_t>("PulsTotMin");
fuMaxTotPulser = fConfig->GetValue<uint32_t>("PulsTotMax");
fuOffSpillCountLimit = fConfig->GetValue<uint32_t>("SpillThr");
fuOffSpillCountLimitNonPulser = fConfig->GetValue<uint32_t>("SpillThrNonPuls");
fdSpillCheckInterval = fConfig->GetValue<double>("SpillCheckInt");
std::string sChanMap = fConfig->GetValue<std::string>("ChanMap");
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsTsBlockName = fConfig->GetValue<std::string>("TsBlockName");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
UInt_t uChanIdx = 0;
size_t charPosDel = sChanMap.find(',');
while (uChanIdx < fvuChanMap.size() && std::string::npos != charPosDel) {
fvuChanMap[uChanIdx] = std::stoul(sChanMap.substr(0, charPosDel));
sChanMap = sChanMap.substr(charPosDel + 1);
uChanIdx++;
charPosDel = sChanMap.find(',');
} // while( uChanIdx < fvuChanMap.size() && std::string::npos != charPosDel )
if (uChanIdx < fvuChanMap.size()) {
fvuChanMap[uChanIdx] = std::stoul(sChanMap);
} // if( uChanIdx < fvuChanMap.size() )
LOG(info) << "Histograms publication frequency in TS: " << fuPublishFreqTs;
LOG(info) << "Histograms publication min. interval in s: " << fdMinPublishTime;
LOG(info) << "Histograms publication max. interval in s: " << fdMaxPublishTime;
if ("" == fsTsBlockName) {
//
LOG(info) << "Requesting TS using the SysId: 0x" << std::hex << static_cast<int>(kusSysId) << std::dec;
}
else {
//
LOG(info) << "Requesting TS using the following block name: " << fsTsBlockName;
}
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
bool CbmDeviceMonitorReqBmon::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceMonitorReqBmon.";
fParCList = fMonitorAlgo->GetParList();
for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string paramName {tempObj->GetName()};
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
// Her must come the proper Runid
std::string message = paramName + ",111";
LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
FairParGenericSet* newObj = nullptr;
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
newObj = static_cast<FairParGenericSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from the server:";
newObj->print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
} // if (rep->GetSize() != 0)
} // if (Receive(rep, "parameters") >= 0)
} // if (Send(req, "parameters") > 0)
fParCList->AddAt(newObj, iparC);
delete tempObj;
} // for ( int iparC = 0; iparC < fParCList->GetEntries(); iparC++ )
/// Need to add accessors for all options
fMonitorAlgo->SetIgnoreOverlapMs(fbIgnoreOverlapMs);
fMonitorAlgo->SetMonitorMode(kTRUE);
fMonitorAlgo->SetHistoryHistoSize(fuHistoryHistoSize);
fMonitorAlgo->SetPulserTotLimits(fuMinTotPulser, fuMaxTotPulser);
fMonitorAlgo->SetSpillThreshold(fuOffSpillCountLimit);
fMonitorAlgo->SetSpillThresholdNonPulser(fuOffSpillCountLimitNonPulser);
fMonitorAlgo->SetSpillCheckInterval(fdSpillCheckInterval);
fMonitorAlgo->SetChannelMap(fvuChanMap[0], fvuChanMap[1], fvuChanMap[2], fvuChanMap[3], fvuChanMap[4], fvuChanMap[5],
fvuChanMap[6], fvuChanMap[7]);
// fMonitorAlgo->AddMsComponentToList(0, 0x90);
Bool_t initOK = fMonitorAlgo->InitContainers();
return initOK;
}
bool CbmDeviceMonitorReqBmon::InitHistograms()
{
/// Histos creation and obtain pointer on them
/// Trigger histo creation on all associated algos
bool initOK = fMonitorAlgo->CreateHistograms();
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = fMonitorAlgo->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fMonitorAlgo->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
bool CbmDeviceMonitorReqBmon::ConditionalRun()
{
/// First request a new TS (full or single system components or multi-syst components block)
std::string message = fsTsBlockName;
if ("" == message) message = std::to_string(kusSysId);
LOG(debug) << "Requesting new TS by sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
if (Send(req, fsChannelNameDataInput) <= 0) {
LOG(error) << "Failed to send the request! message was " << message;
return false;
} // if (Send(req, fsChannelNameDataInput) <= 0)
else if (Receive(rep, fsChannelNameDataInput) < 0) {
LOG(error) << "Failed to receive a reply to the request! message was " << message;
return false;
} // else if (Receive(rep, fsChannelNameDataInput) < 0)
else if (rep->GetSize() == 0) {
LOG(error) << "Received empty reply. Something went wrong with the timeslice generation! message was " << message;
return false;
} // else if (rep->GetSize() == 0)
/// Message received, do Algo related Initialization steps if needed
if (0 == fulNumMessages) {
try {
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
} // if( 0 == fulNumMessages)
if (0 == fulNumMessages) InitHistograms();
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with size " << rep->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
std::string msgStr(static_cast<char*>(rep->GetData()), rep->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
/// Create an empty TS and fill it with the incoming message
fles::StorableTimeslice component {0};
inputArchive >> component;
/// Process the Timeslice
DoUnpack(component, 0);
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
if (!fbConfigSent) {
// Send the configuration only once per run!
fbConfigSent = SendHistoConfAndData();
} // if( !fbConfigSent )
else
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
return true;
}
bool CbmDeviceMonitorReqBmon::SendHistoConfAndData()
{
/// Prepare multiparts message and header
std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size());
FairMQMessagePtr messageHeader(NewMessage());
// Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader);
BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader);
FairMQParts partsOut;
partsOut.AddPart(std::move(messageHeader));
for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) {
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]);
partsOut.AddPart(std::move(messageHist));
} // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto)
for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) {
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]);
partsOut.AddPart(std::move(messageCan));
} // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv)
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr msgHistos(NewMessage());
// Serialize<RootSerializer>(*msgHistos, &fArrayHisto);
RootSerializer().Serialize(*msgHistos, &fArrayHisto);
partsOut.AddPart(std::move(msgHistos));
/// Send the multi-parts message to the common histogram messages queue
if (Send(partsOut, fsChannelNameHistosInput) < 0) {
LOG(error) << "CbmDeviceMonitorReqBmon::SendHistoConfAndData => Problem sending data";
return false;
} // if( Send( partsOut, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
bool CbmDeviceMonitorReqBmon::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceMonitorReqBmon::~CbmDeviceMonitorReqBmon() {}
Bool_t CbmDeviceMonitorReqBmon::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
fulTsCounter++;
if (kFALSE == fbComponentsAddedToList) {
for (uint32_t uCompIdx = 0; uCompIdx < ts.num_components(); ++uCompIdx) {
if (kusSysId == ts.descriptor(uCompIdx, 0).sys_id) {
fMonitorAlgo->AddMsComponentToList(uCompIdx, kusSysId);
} // if( kusSysId == ts.descriptor( uCompIdx, 0 ).sys_id )
} // for( uint32_t uComp = 0; uComp < ts.num_components(); ++uComp )
fbComponentsAddedToList = kTRUE;
} // if( kFALSE == fbComponentsAddedToList )
if (kFALSE == fMonitorAlgo->ProcessTs(ts)) {
LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fMonitorAlgo->ProcessTs( ts ) )
/// Clear the digis vector in case it was filled
fMonitorAlgo->ClearVector();
if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << " time slices";
return kTRUE;
}
void CbmDeviceMonitorReqBmon::Finish() {}
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifndef CBMDEVICEMONITORREQBmon_H_
#define CBMDEVICEMONITORREQBmon_H_
#include "CbmMqTMessage.h"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "Rtypes.h"
#include "TObjArray.h"
#include <chrono>
#include <map>
#include <vector>
class TList;
class CbmMcbm2018MonitorAlgoBmon;
class CbmDeviceMonitorReqBmon : public FairMQDevice {
public:
CbmDeviceMonitorReqBmon();
virtual ~CbmDeviceMonitorReqBmon();
protected:
virtual void InitTask();
virtual bool ConditionalRun();
private:
/// Constants
static const uint16_t kusSysId = 0x90;
/// Control flags
Bool_t fbIgnoreOverlapMs = kFALSE; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Bool_t fbComponentsAddedToList = kFALSE;
/// User settings parameters
std::string fsChannelNameDataInput = "ts-request";
std::string fsTsBlockName = "t0block";
std::string fsChannelNameHistosInput = "histogram-in";
uint32_t fuHistoryHistoSize = 3600;
uint32_t fuMinTotPulser = 185;
uint32_t fuMaxTotPulser = 195;
uint32_t fuOffSpillCountLimit = 25;
uint32_t fuOffSpillCountLimitNonPulser = 10;
double fdSpillCheckInterval = 0.0128;
std::vector<uint32_t> fvuChanMap = {0, 1, 2, 3, 4, 5, 6, 7};
uint32_t fuPublishFreqTs = 100;
double_t fdMinPublishTime = 0.5;
double_t fdMaxPublishTime = 5.0;
/// Parameters management
TList* fParCList = nullptr;
/// Statistics & first TS rejection
uint64_t fulNumMessages = 0;
uint64_t fulTsCounter = 0;
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
/// Processing algo
CbmMcbm2018MonitorAlgoBmon* fMonitorAlgo;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto = {};
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
bool InitContainers();
bool InitHistograms();
bool DoUnpack(const fles::Timeslice& ts, size_t component);
void Finish();
bool SendHistoConfAndData();
bool SendHistograms();
};
#endif /* CBMDEVICEMONITORREQBmon_H_ */
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#include "CbmDeviceMonitorReqTof.h"
#include "CbmFlesCanvasTools.h"
#include "CbmMQDefs.h"
#include "CbmMcbm2018MonitorAlgoTof.h"
#include "StorableTimeslice.hpp"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairParGenericSet.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TList.h"
#include "TNamed.h"
#include "BoostSerializer.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/utility.hpp>
#include <array>
#include <iomanip>
#include <stdexcept>
#include <string>
#include "RootSerializer.h"
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
using namespace std;
CbmDeviceMonitorReqTof::CbmDeviceMonitorReqTof() : fMonitorAlgo {new CbmMcbm2018MonitorAlgoTof()} {}
void CbmDeviceMonitorReqTof::InitTask()
try {
/// Read options from executable
LOG(info) << "Init options for CbmMqStarHistoServer.";
fbIgnoreOverlapMs = fConfig->GetValue<bool>("IgnOverMs");
fbDebugMonitorMode = fConfig->GetValue<bool>("DebugMoni");
fbIgnoreCriticalErrors = fConfig->GetValue<bool>("IgnCritErr");
fuHistoryHistoSize = fConfig->GetValue<uint32_t>("HistEvoSz");
fuMinTotPulser = fConfig->GetValue<uint32_t>("PulsTotMin");
fuMaxTotPulser = fConfig->GetValue<uint32_t>("PulsTotMax");
fiGdpbIndex = fConfig->GetValue<int32_t>("GdpbIdx");
fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs");
fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin");
fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax");
fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn");
fsTsBlockName = fConfig->GetValue<std::string>("TsBlockName");
fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn");
LOG(info) << "Histograms publication frequency in TS: " << fuPublishFreqTs;
LOG(info) << "Histograms publication min. interval in s: " << fdMinPublishTime;
LOG(info) << "Histograms publication max. interval in s: " << fdMaxPublishTime;
/// Set the Monitor Algo in Absolute time scale
fMonitorAlgo->UseAbsoluteTime();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
// Wrapper defined in CbmMQDefs.h to support different FairMQ versions
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
}
Bool_t CbmDeviceMonitorReqTof::InitContainers()
{
LOG(info) << "Init parameter containers for CbmDeviceMonitorReqTof.";
fParCList = fMonitorAlgo->GetParList();
for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) {
FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
fParCList->Remove(tempObj);
std::string paramName {tempObj->GetName()};
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
// Should only be used for small data because of the cost of an additional copy
// Here must come the proper Runid
std::string message = paramName + ",111";
LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
FairParGenericSet* newObj = nullptr;
if (Send(req, "parameters") > 0) {
if (Receive(rep, "parameters") >= 0) {
if (rep->GetSize() != 0) {
CbmMqTMessage tmsg(rep->GetData(), rep->GetSize());
newObj = static_cast<FairParGenericSet*>(tmsg.ReadObject(tmsg.GetClass()));
LOG(info) << "Received unpack parameter from the server:";
newObj->print();
}
else {
LOG(error) << "Received empty reply. Parameter not available";
} // if (rep->GetSize() != 0)
} // if (Receive(rep, "parameters") >= 0)
} // if (Send(req, "parameters") > 0)
fParCList->AddAt(newObj, iparC);
delete tempObj;
} // for ( int iparC = 0; iparC < fParCList->GetEntries(); iparC++ )
/// Need to add accessors for all options
fMonitorAlgo->SetIgnoreOverlapMs(fbIgnoreOverlapMs);
fMonitorAlgo->SetDebugMonitorMode(fbDebugMonitorMode);
fMonitorAlgo->SetIgnoreCriticalErrors(fbIgnoreCriticalErrors);
fMonitorAlgo->SetHistoryHistoSize(fuHistoryHistoSize);
fMonitorAlgo->SetPulserTotLimits(fuMinTotPulser, fuMaxTotPulser);
fMonitorAlgo->SetGdpbIndex(fiGdpbIndex);
Bool_t initOK = fMonitorAlgo->InitContainers();
return initOK;
}
bool CbmDeviceMonitorReqTof::InitHistograms()
{
/// Histos creation and obtain pointer on them
/// Trigger histo creation on all associated algos
bool initOK = fMonitorAlgo->CreateHistograms();
/// Obtain vector of pointers on each histo from the algo (+ optionally desired folder)
std::vector<std::pair<TNamed*, std::string>> vHistos = fMonitorAlgo->GetHistoVector();
/// Obtain vector of pointers on each canvas from the algo (+ optionally desired folder)
std::vector<std::pair<TCanvas*, std::string>> vCanvases = fMonitorAlgo->GetCanvasVector();
/// Add pointers to each histo in the histo array
/// Create histo config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Histo name, Folder >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto) {
// LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName()
// << " in " << vHistos[ uHisto ].second.data()
// ;
fArrayHisto.Add(vHistos[uHisto].first);
std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second);
fvpsHistosFolder.push_back(psHistoConfig);
LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data();
} // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto )
/// Create canvas config vector
/// ===> Use an std::vector< std::pair< std::string, std::string > > with < Canvas name, config >
/// and send it through a separate channel using the BoostSerializer
for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) {
// LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName()
// << " in " << vCanvases[ uCanv ].second.data();
std::string sCanvName = (vCanvases[uCanv].first)->GetName();
std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first);
std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf);
fvpsCanvasConfig.push_back(psCanvConfig);
LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data();
} // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv )
return initOK;
}
bool CbmDeviceMonitorReqTof::ConditionalRun()
{
/// First request a new TS (full or single system components or multi-syst components block)
std::string message = fsTsBlockName;
if ("" == message) message = std::to_string(kusSysIdTof);
LOG(debug) << "Requesting new TS by sending message: " << message;
FairMQMessagePtr req(NewSimpleMessage(message));
FairMQMessagePtr rep(NewMessage());
if (Send(req, fsChannelNameDataInput) <= 0) {
LOG(error) << "Failed to send the request! message was " << message;
return false;
} // if (Send(req, fsChannelNameDataInput) <= 0)
else if (Receive(rep, fsChannelNameDataInput) < 0) {
LOG(error) << "Failed to receive a reply to the request! message was " << message;
return false;
} // else if (Receive(rep, fsChannelNameDataInput) < 0)
else if (rep->GetSize() == 0) {
LOG(error) << "Received empty reply. Something went wrong with the timeslice generation! message was " << message;
return false;
} // else if (rep->GetSize() == 0)
/// Message received, do Algo related Initialization steps if needed
if (0 == fulNumMessages) {
try {
InitContainers();
}
catch (InitTaskError& e) {
LOG(error) << e.what();
ChangeState(fair::mq::Transition::ErrorFound);
}
} // if( 0 == fulNumMessages)
if (0 == fulNumMessages) InitHistograms();
/// Process received message
fulNumMessages++;
LOG(debug) << "Received message number " << fulNumMessages << " with size " << rep->GetSize();
if (0 == fulNumMessages % 10000) LOG(info) << "Received " << fulNumMessages << " messages";
std::string msgStr(static_cast<char*>(rep->GetData()), rep->GetSize());
std::istringstream iss(msgStr);
boost::archive::binary_iarchive inputArchive(iss);
/// Create an empty TS and fill it with the incoming message
fles::StorableTimeslice component {0};
inputArchive >> component;
/// Process the Timeslice
DoUnpack(component, 0);
/// Send histograms each 100 time slices. Should be each ~1s
/// Use also runtime checker to trigger sending after M s if
/// processing too slow or delay sending if processing too fast
std::chrono::system_clock::time_point currentTime = std::chrono::system_clock::now();
std::chrono::duration<double_t> elapsedSeconds = currentTime - fLastPublishTime;
if ((fdMaxPublishTime < elapsedSeconds.count())
|| (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) {
if (!fbConfigSent) {
// Send the configuration only once per run!
fbConfigSent = SendHistoConfAndData();
} // if( !fbConfigSent )
else
SendHistograms();
fLastPublishTime = std::chrono::system_clock::now();
} // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) )
return true;
}
bool CbmDeviceMonitorReqTof::SendHistoConfAndData()
{
/// Prepare multiparts message and header
std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size());
FairMQMessagePtr messageHeader(NewMessage());
// Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader);
BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader);
FairMQParts partsOut;
partsOut.AddPart(std::move(messageHeader));
for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) {
/// Serialize the vector of histo config into a single MQ message
FairMQMessagePtr messageHist(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]);
partsOut.AddPart(std::move(messageHist));
} // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto)
for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) {
/// Serialize the vector of canvas config into a single MQ message
FairMQMessagePtr messageCan(NewMessage());
// Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]);
BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]);
partsOut.AddPart(std::move(messageCan));
} // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv)
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr msgHistos(NewMessage());
// Serialize<RootSerializer>(*msgHistos, &fArrayHisto);
RootSerializer().Serialize(*msgHistos, &fArrayHisto);
partsOut.AddPart(std::move(msgHistos));
/// Send the multi-parts message to the common histogram messages queue
if (Send(partsOut, fsChannelNameHistosInput) < 0) {
LOG(error) << "CbmDeviceMonitorReqTof::SendHistoConfAndData => Problem sending data";
return false;
} // if( Send( partsOut, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
bool CbmDeviceMonitorReqTof::SendHistograms()
{
/// Serialize the array of histos into a single MQ message
FairMQMessagePtr message(NewMessage());
// Serialize<RootSerializer>(*message, &fArrayHisto);
RootSerializer().Serialize(*message, &fArrayHisto);
/// Send message to the common histogram messages queue
if (Send(message, fsChannelNameHistosInput) < 0) {
LOG(error) << "Problem sending data";
return false;
} // if( Send( message, fsChannelNameHistosInput ) < 0 )
/// Reset the histograms after sending them (but do not reset the time)
fMonitorAlgo->ResetHistograms(kFALSE);
return true;
}
CbmDeviceMonitorReqTof::~CbmDeviceMonitorReqTof() {}
Bool_t CbmDeviceMonitorReqTof::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
fulTsCounter++;
if (kFALSE == fbComponentsAddedToList) {
for (uint32_t uCompIdx = 0; uCompIdx < ts.num_components(); ++uCompIdx) {
if (kusSysIdTof == ts.descriptor(uCompIdx, 0).sys_id) {
fMonitorAlgo->AddMsComponentToList(uCompIdx, kusSysIdTof);
} // if( kusSysIdTof == ts.descriptor( uCompIdx, 0 ).sys_id )
else if (kusSysIdBmon == ts.descriptor(uCompIdx, 0).sys_id) {
fMonitorAlgo->AddMsComponentToList(uCompIdx, kusSysIdBmon);
} // if( kusSysIdBmon == ts.descriptor( uCompIdx, 0 ).sys_id )
} // for( uint32_t uComp = 0; uComp < ts.num_components(); ++uComp )
fbComponentsAddedToList = kTRUE;
} // if( kFALSE == fbComponentsAddedToList )
if (kFALSE == fMonitorAlgo->ProcessTs(ts)) {
LOG(error) << "Failed processing TS " << ts.index() << " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fMonitorAlgo->ProcessTs( ts ) )
/// Clear the digis vector in case it was filled
fMonitorAlgo->ClearVector();
if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << " time slices";
return kTRUE;
}
void CbmDeviceMonitorReqTof::Finish() {}
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer] */
#ifndef CBMDEVICEMONITORREQTOF_H_
#define CBMDEVICEMONITORREQTOF_H_
#include "CbmMqTMessage.h"
#include "Timeslice.hpp"
#include "FairMQDevice.h"
#include "Rtypes.h"
#include "TObjArray.h"
#include <chrono>
#include <map>
#include <vector>
class TList;
class CbmMcbm2018MonitorAlgoTof;
class CbmDeviceMonitorReqTof : public FairMQDevice {
public:
CbmDeviceMonitorReqTof();
virtual ~CbmDeviceMonitorReqTof();
protected:
virtual void InitTask();
virtual bool ConditionalRun();
private:
/// Constants
static const uint16_t kusSysIdTof = 0x60;
static const uint16_t kusSysIdBmon = 0x90;
/// Control flags
Bool_t fbIgnoreOverlapMs = kFALSE; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Bool_t fbDebugMonitorMode = kFALSE; //! Switch ON the filling of a additional set of histograms
Bool_t fbIgnoreCriticalErrors = kTRUE; //! If ON not printout at all for critical errors
Bool_t fbComponentsAddedToList = kFALSE;
/// User settings parameters
std::string fsChannelNameDataInput = "ts-request";
std::string fsTsBlockName = "t0tofblock";
std::string fsChannelNameHistosInput = "histogram-in";
uint32_t fuHistoryHistoSize = 3600;
uint32_t fuMinTotPulser = 185;
uint32_t fuMaxTotPulser = 195;
int32_t fiGdpbIndex = -1;
uint32_t fuPublishFreqTs = 100;
double_t fdMinPublishTime = 0.5;
double_t fdMaxPublishTime = 5.0;
/// Parameters management
TList* fParCList = nullptr;
/// Statistics & first TS rejection
uint64_t fulNumMessages = 0;
uint64_t fulTsCounter = 0;
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
/// Processing algo
CbmMcbm2018MonitorAlgoTof* fMonitorAlgo;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto = {};
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
bool InitContainers();
bool InitHistograms();
Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
void Finish();
bool SendHistoConfAndData();
bool SendHistograms();
};
#endif /* CBMDEVICEMONITORREQTOF_H_ */