12#ifndef CBMDEVICEBMONMONI_H_
13#define CBMDEVICEBMONMONI_H_
18#include "Timeslice.hpp"
20#include "FairMQDevice.h"
21#include "FairParGenericSet.h"
52 static constexpr std::uint16_t
fkFlesBmon =
static_cast<std::uint16_t
>(fles::Subsystem::BMON);
83 Bool_t InitParameters(std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>* reqparvec);
88 std::chrono::system_clock::time_point
fLastPublishTime = std::chrono::system_clock::now();
90 std::map<uint16_t, std::pair<std::string, size_t>>
fNameMap = {};
92 std::map<uint16_t, std::pair<double, double>>
fTimeMap = {};
133 std::shared_ptr<CbmTrdSpadic>
GetTrdSpadic(
bool useAvgBaseline);
136 template<
typename TVecobj>
137 typename std::enable_if<std::is_same<TVecobj, std::nullptr_t>::value ==
true,
void>::type
141 <<
"CbmDeviceBmonMonitor::timesort() got an object that has no member function GetTime(). Hence, we can and "
142 "will not timesort it!";
145 template<
typename TVecobj>
146 typename std::enable_if<!std::is_member_function_pointer<
decltype(&TVecobj::GetTime)>::value,
void>::type
149 LOG(debug) <<
"CbmDeviceBmonMonitor::timesort() " << TVecobj::Class_Name()
150 <<
"is an object that has no member function GetTime(). Hence, we can and "
151 "will not timesort it!";
154 template<
typename TVecobj>
155 typename std::enable_if<std::is_member_function_pointer<
decltype(&TVecobj::GetTime)>::value,
void>::type
158 if (vec ==
nullptr)
return;
159 std::sort(vec->begin(), vec->end(),
160 [](
const TVecobj& a,
const TVecobj& b) ->
bool { return a.GetTime() < b.GetTime(); });
176 template<
class TConfig,
class TOptOutA = std::
nullptr_t,
class TOptOutB = std::
nullptr_t>
177 size_t unpack(
const uint16_t subsysid,
const fles::Timeslice* ts, uint16_t icomp, TConfig config,
178 std::vector<TOptOutA>* optouttargetvecA =
nullptr, std::vector<TOptOutB>* optouttargetvecB =
nullptr)
181 auto wallstarttime = std::chrono::high_resolution_clock::now();
182 std::clock_t cpustarttime = std::clock();
184 auto algo = config->GetUnpacker();
185 std::vector<TOptOutA> optoutAvec = {};
186 std::vector<TOptOutB> optoutBvec = {};
187 if (optouttargetvecA) { algo->SetOptOutAVec(&optoutAvec); }
188 if (optouttargetvecB) { algo->SetOptOutBVec(&optoutBvec); }
191 algo->SetTsStartTime(ts->start_time());
194 auto digivec = algo->Unpack(ts, icomp);
197 if (config->GetOutputVec()) {
203 for (
auto digi : digivec)
204 config->GetOutputVec()->emplace_back(digi);
206 if (optouttargetvecA) {
210 for (
auto optoutA : optoutAvec)
211 optouttargetvecA->emplace_back(optoutA);
213 if (optouttargetvecB) {
218 for (
auto optoutB : optoutBvec)
219 optouttargetvecB->emplace_back(optoutB);
222 std::clock_t cpuendtime = std::clock();
223 auto wallendtime = std::chrono::high_resolution_clock::now();
226 auto cputime = 1e6 * (cpuendtime - cpustarttime) / CLOCKS_PER_SEC;
227 algo->AddCpuTime(cputime);
229 auto walltime = std::chrono::duration<double, std::micro>(wallendtime - wallstarttime).count();
230 algo->AddWallTime(walltime);
234 size_t nDigis = digivec.size();
235 LOG(debug) <<
"Component " << icomp <<
" connected to config " << config->GetName() <<
" n-Digis " << nDigis
236 <<
" processed in walltime(cputime) = " << walltime <<
"(" << cputime << cputime <<
") micro s"
237 <<
"this timeslice.";
240 auto timeit =
fTimeMap.find(subsysid);
241 timeit->second.first += cputime;
242 timeit->second.second += walltime;
245 datait->second.first += ts->size_component(icomp) / 1.0e6;
246 datait->second.second += nDigis * algo->GetOutputObjSize() / 1.0e6;
248 fNameMap.find(subsysid)->second.second += nDigis;
std::chrono::system_clock::time_point fLastPublishTime
bool fDoDebugPrints
Flag if extended debug output is to be printed or not.
virtual ~CbmDeviceBmonMonitor()
Double_t fdTsFullSizeInNs
Total size of the overlap MS in a TS, [nanoseconds].
Bool_t DoUnpack(const fles::Timeslice &ts, size_t component)
std::enable_if< std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type timesort(std::vector< TVecobj > *vec=nullptr)
Bool_t InitParameters(std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > *reqparvec)
Parameters management.
TObjArray fArrayHisto
Array of histograms to send to the histogram server.
uint32_t fuPublishFreqTs
Histograms management.
double_t fdMinPublishTime
std::string fsChannelNameHistosInput
std::shared_ptr< CbmTrdSpadic > GetTrdSpadic(bool useAvgBaseline)
Get the Trd Spadic.
CbmTsEventHeader * fCbmTsEventHeader
Pointer to the Timeslice header conatining start time and index.
bool fbOutputFullTimeSorting
Flag to Enable/disable a full time sorting. If off, time sorting happens per link/FLIM source.
std::enable_if< std::is_same< TVecobj, std::nullptr_t >::value==true, void >::type timesort(std::vector< TVecobj > *)
Sort a vector timewise vector type has to provide GetTime()
Double_t fdTsCoreSizeInNs
Size of a single MS, [nanoseconds].
std::shared_ptr< CbmBmonUnpackConfig > fBmonConfig
Configuration of the unpackers. Provides the configured algorithm.
Bool_t fbComponentsAddedToList
Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice.
bool fDoPerfProf
Flag if performance profiling should be activated or not.
size_t unpack(const uint16_t subsysid, const fles::Timeslice *ts, uint16_t icomp, TConfig config, std::vector< TOptOutA > *optouttargetvecA=nullptr, std::vector< TOptOutB > *optouttargetvecB=nullptr)
Template for the unpacking call of a given algorithm.
std::vector< std::pair< std::string, std::string > > fvpsHistosFolder
Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server.
Double_t fdTsOverSizeInNs
Total size of the core MS in a TS, [nanoseconds].
std::map< uint16_t, std::pair< std::string, size_t > > fNameMap
Map to store a name for the unpackers and the processed amount of digis, key = fkFlesId.
std::vector< std::pair< std::string, std::string > > fvpsCanvasConfig
void SetUnpackConfig(std::shared_ptr< CbmBmonUnpackConfig > config)
Set the Bmon Unpack Config.
bool SendHistoConfAndData()
bool HandleCommand(FairMQMessagePtr &, int)
std::enable_if<!std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type timesort(std::vector< TVecobj > *)
std::vector< std::string > fvsSetTimeOffs
Time offsets.
size_t fuNbCoreMsPerTs
TS MetaData storage: stable so should be moved somehow to parameters handling (not transmitted with e...
std::string fsSetupName
User settings parameters.
uint64_t fulNumMessages
Statistics & first TS rejection.
std::map< uint16_t, std::pair< double, double > > fDataSizeMap
Map to store the in and out data amount, key = fkFlesId.
static constexpr std::uint16_t fkFlesBmon
Constants.
std::string fsChannelNameDataOutput
double_t fdMaxPublishTime
std::string fsChannelNameDataInput
message queues
std::map< uint16_t, std::pair< double, double > > fTimeMap
Map to store the cpu and wall time, key = fkFlesId.
std::string fsChannelNameCommands
bool fbConfigSent
Flag indicating whether the histograms and canvases configurations were already published.
TimesliceMetaData * fTsMetaData
Total size of all MS in a TS, [nanoseconds].
bool fbUnpBmon
---> for selective unpacking
Bool_t fbIgnoreOverlapMs
Control flags.