CbmRoot
Loading...
Searching...
No Matches
CbmRecoUnpack.h
Go to the documentation of this file.
1/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer], Pierre-Alain Loizeau, Pascal Raisig */
4
10
11
12#ifndef CBMRECOUNPACK_H
13#define CBMRECOUNPACK_H 1
14
15#include "AccDataSis18.h"
16#include "CbmBmonUnpackConfig.h"
17#include "CbmMuchUnpackConfig.h"
18#include "CbmPsdUnpackConfig.h"
19#include "CbmRichUnpackConfig.h"
20#include "CbmStsUnpackConfig.h"
21#include "CbmTofUnpackConfig.h"
22#include "CbmTrdUnpackConfig.h"
24#include "CbmTsEventHeader.h"
25
26#include <MicrosliceDescriptor.hpp>
27#include <Timeslice.hpp>
28
29#include <FairParAsciiFileIo.h>
30#include <FairRootManager.h>
31
32#include <RtypesCore.h>
33#include <THnSparse.h>
34#include <TObject.h>
35
36#include <chrono>
37#include <cstddef>
38#include <cstdint>
39#include <ctime>
40#include <memory>
41#include <type_traits> // this is std::lib used for template is_member_function_pointer
42#include <utility>
43#include <vector>
44
45class CbmTimeSlice;
46class TH1;
47class TStopwatch;
48namespace cbm
49{
50 class Monitor;
51}
52
60class CbmRecoUnpack : public TObject {
61
62 public:
65
66
69
71 CbmRecoUnpack(const CbmRecoUnpack&) = delete;
72
75
77 void Finish();
78
80 Bool_t Init();
81
83 void Reset();
84
90 void SetDebugPrintout(bool value = true) { fDoDebugPrints = value; }
91
97 void SetDoPerfProfiling(bool value = true) { fDoPerfProf = value; }
98
104 void SetDoPerfProfilingPerTs(bool value = true)
105 {
106 if (value) fDoPerfProf = value;
107 fDoPerfProfPerTs = value;
108 }
109
115 void SetPublishProfMoni(bool value = true, std::string sUriMonitor = "", bool useProcTime = false,
116 std::string sJobId = "local")
117 {
118 if (value) {
119 fDoPerfProf = value;
120 fDoPerfProfPerTs = value;
121 }
122 fPublishProfMoni = value;
123 if ("" != sUriMonitor) { //
124 fUriPublishProfMoni = sUriMonitor;
125 }
126 fPubMoniProcTime = useProcTime;
127 fMoniJobId = sJobId;
128 }
129
135 void SetOutputFilename(std::string value)
136 {
137 if (!value.empty()) fOutfilename = value;
138 }
139
145 void SetTimeSorting(bool bIn = true) { bOutputFullTimeSorting = bIn; }
146
158 void AddSpillFilter(std::string sAccEvtTimingFileIn, double_t dWinStart = -1000.0, double_t dWinStop = 4500.0,
159 int32_t iSpillStartDelay = 28400, uint64_t ulTsDurationNs = 128000000, bool bMoniFindPeak = false)
160 {
161 bSpillFilter = true;
162 sAccEvtTimingFile = sAccEvtTimingFileIn;
163 dSpillFilterWinStart = dWinStart;
164 dSpillFilterWinStop = dWinStop;
165 iSpillFilterStartDelay = iSpillStartDelay;
166 ulSpillFilterTsDurationNs = ulTsDurationNs;
168 bSpillFilterMoniFindPeak = bMoniFindPeak;
169 }
170
176 void SetMonitoringOnly(bool bIn = true) { bMonitoringOnly = bIn; }
177
179 void SetUnpackConfig(std::shared_ptr<CbmMuchUnpackConfig> config) { fMuchConfig = config; }
180
182 void SetUnpackConfig(std::shared_ptr<CbmPsdUnpackConfig> config) { fPsdConfig = config; }
183
185 void SetUnpackConfig(std::shared_ptr<CbmRichUnpackConfig> config) { fRichConfig = config; }
186
188 void SetUnpackConfig(std::shared_ptr<CbmStsUnpackConfig> config) { fStsConfig = config; }
189
190 // /** @brief Set the Tof Unpack Config @param config */
191 void SetUnpackConfig(std::shared_ptr<CbmTofUnpackConfig> config) { fTofConfig = config; }
192
194 void SetUnpackConfig(std::shared_ptr<CbmTrdUnpackConfig> config) { fTrd1DConfig = config; }
195
197 void SetUnpackConfig(std::shared_ptr<CbmTrdUnpackFaspConfig> config) { fTrd2DConfig = config; }
198
200 void SetUnpackConfig(std::shared_ptr<CbmBmonUnpackConfig> config) { fBmonConfig = config; }
201
203 void Unpack(std::unique_ptr<fles::Timeslice> ts);
204
205 private:
206 using Subsystem = fles::Subsystem;
207
209 bool fDoDebugPrints = false;
210
212 bool fDoPerfProf = false;
213
215 bool fDoPerfProfPerTs = false;
216
218 bool fPublishProfMoni = false;
219
221 std::string fUriPublishProfMoni = "influx1:localhost:8086:monitoring_tests";
222
224 bool fPubMoniProcTime = true;
225
227 std::map<Subsystem, std::pair<std::string, size_t>> fNameMap = {};
228
230 std::map<Subsystem, std::pair<double, double>> fTimeMap = {};
231
233 std::map<Subsystem, std::pair<double, double>> fDataSizeMap = {};
234
236 std::map<Subsystem, std::pair<std::string, size_t>> fNameMapPerTs = {};
237
239 std::map<Subsystem, std::pair<double, double>> fTimeMapPerTs = {};
240
242 std::map<Subsystem, std::pair<double, double>> fDataSizeMapPerTs = {};
243
244 TH1* hProducedDigis = nullptr;
245 TH1* hSpeedPerf = nullptr;
246 TH1* hDataPerf = nullptr;
247 TStopwatch* fTimerTs = nullptr;
248 TH1* fhCpuTimePerTs = nullptr;
249 TH1* fhRealTimePerTs = nullptr;
250 TH1* fhCpuTimePerTsHist = nullptr;
251 TH1* fhRealTimePerTsHist = nullptr;
252 std::map<Subsystem, TH1*> fvhInpRatioPerTs = {};
253 std::map<Subsystem, TH1*> fvhOutRatioPerTs = {};
254 std::map<Subsystem, TH1*> fvhUnpRatioPerTs = {};
255 TH1* fhUnpackingRatioPerTs = nullptr;
256
257 std::unique_ptr<cbm::Monitor> fMonitor;
258 std::string fMoniCurrrentHostname = "";
259 std::string fMoniJobId = "";
260 std::chrono::system_clock::time_point fMonitorSecCurrentTs = std::chrono::system_clock::time_point();
261 std::map<Subsystem, std::pair<double, double>> fDataSizeMapCurrSec = {};
262
264 void WriteHistograms();
265
268
271
278 void initPerformanceMaps(Subsystem subsystem, std::string name);
279
280
281 template<class TConfig>
282 void RegisterOutputs(FairRootManager* ioman, std::shared_ptr<TConfig> config)
283 {
284 /*
285 * FIXME: Compiling but leading to a segfault at runtime
286 auto pOutVect = config->GetOutputVec();
287 if (pOutVect) {
288 ioman->RegisterAny(config->GetOutputBranchName().data(), pOutVect, kTRUE);
289 LOG(info) << "CbmRecoUnpack::RegisterOutputs() " << config->GetOutputBranchName() << " at " << pOutVect;
290 }
291
292 auto pOutVectOptA = config->GetOptOutAVec();
293 if (pOutVectOptA) {
294 ioman->RegisterAny(config->GetOutputBranchNameOptA().data(), pOutVectOptA, kTRUE);
295 LOG(info) << "CbmRecoUnpack::RegisterOutputs() " << config->GetOutputBranchNameOptA() << " at " << pOutVectOptA;
296 }
297
298 auto pOutVectOptB = config->GetOptOutBVec();
299 if (pOutVectOptB) {
300 ioman->RegisterAny(config->GetOutputBranchNameOptB().data(), pOutVectOptB, kTRUE);
301 LOG(info) << "CbmRecoUnpack::RegisterOutputs() " << config->GetOutputBranchNameOptB() << " at " << pOutVectOptB;
302 }
303*/
305 config->RegisterOutput(ioman);
306 }
307
313 virtual Bool_t initParContainers(std::vector<std::pair<std::string, std::shared_ptr<FairParGenericSet>>>* reqparvec)
314 {
315 LOG(debug) << GetName() << "::Init - initParContainers";
316 if (!reqparvec) {
317 LOG(info) << GetName() << "::Init - initParContainers - empty requirements vector no parameters initialized.";
318 return kTRUE;
319 }
320
321 // Now get the actual ascii files and init the containers with the asciiIo
322 for (auto& pair : *reqparvec) {
323 auto filepath = pair.first;
324 auto parset = pair.second;
325 FairParAsciiFileIo asciiInput;
326 if (!filepath.empty()) {
327 if (asciiInput.open(filepath.data())) {
328 parset->init(&asciiInput);
329 }
330 }
331 }
332 return kTRUE;
333 }
334
336 template<typename TVecobj>
337 typename std::enable_if<std::is_same<TVecobj, std::nullptr_t>::value == true, void>::type
338 timesort(std::vector<TVecobj>* /*vec = nullptr*/)
339 {
340 LOG(debug) << "CbmRecoUnpack::timesort() got an object that has no member function GetTime(). Hence, we can and "
341 "will not timesort it!";
342 }
343
344 template<typename TVecobj>
345 typename std::enable_if<!std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
346 timesort(std::vector<TVecobj>* /*vec = nullptr*/)
347 {
348 LOG(debug) << "CbmRecoUnpack::timesort() " << TVecobj::Class_Name()
349 << "is an object that has no member function GetTime(). Hence, we can and "
350 "will not timesort it!";
351 }
352
353 template<typename TVecobj>
354 typename std::enable_if<std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
355 timesort(std::vector<TVecobj>* vec = nullptr)
356 {
357 if (vec == nullptr) return;
358 std::sort(vec->begin(), vec->end(),
359 [](const TVecobj& a, const TVecobj& b) -> bool { return a.GetTime() < b.GetTime(); });
360 }
361
362
376 template<class TConfig, class TOptOutA = std::nullptr_t, class TOptOutB = std::nullptr_t>
377 size_t unpack(const Subsystem subsystem, const fles::Timeslice* ts, uint16_t icomp, TConfig config,
378 std::vector<TOptOutA>* optouttargetvecA = nullptr, std::vector<TOptOutB>* optouttargetvecB = nullptr)
379 {
380
381 auto wallstarttime = std::chrono::high_resolution_clock::now();
382 std::clock_t cpustarttime = std::clock();
383
384 auto algo = config->GetUnpacker();
385 std::vector<TOptOutA> optoutAvec = {};
386 std::vector<TOptOutB> optoutBvec = {};
387 if (optouttargetvecA) {
388 algo->SetOptOutAVec(&optoutAvec);
389 }
390 if (optouttargetvecB) {
391 algo->SetOptOutBVec(&optoutBvec);
392 }
393
394 // Set the start time of the current TS for this algorithm
395 algo->SetTsStartTime(ts->start_time());
396
397 // Run the actual unpacking
398 auto digivec = algo->Unpack(ts, icomp);
399
400 // Check if we want to write the output to somewhere (in pure online monitoring mode for example this can/would/should be skipped)
401 if (!bMonitoringOnly) {
402 if (config->GetOutputVec()) {
403 // Lets do some time-sorting if we are not doing it later
404 if (!bOutputFullTimeSorting) timesort(&digivec);
405
406 // Transfer the data from the timeslice vector to the target branch vector
407 // Digis/default output retrieved as offered by the algorithm
408 for (auto digi : digivec)
409 config->GetOutputVec()->emplace_back(digi);
410 }
411 if (optouttargetvecA) {
412 // Lets do some timesorting
413 if (!bOutputFullTimeSorting) timesort(&optoutAvec);
414 // Transfer the data from the timeslice vector to the target branch vector
415 for (auto optoutA : optoutAvec)
416 optouttargetvecA->emplace_back(optoutA);
417 }
418 if (optouttargetvecB) {
419 // Second opt output is not time sorted to allow non GetTime data container.
420 // Lets do some timesorting
421 timesort(&optoutAvec);
422 // Transfer the data from the timeslice vector to the target branch vector
423 for (auto optoutB : optoutBvec)
424 optouttargetvecB->emplace_back(optoutB);
425 }
426 }
427
428 std::clock_t cpuendtime = std::clock();
429 auto wallendtime = std::chrono::high_resolution_clock::now();
430
431 // Cpu time in [mus]
432 auto cputime = 1e6 * (cpuendtime - cpustarttime) / CLOCKS_PER_SEC;
433 algo->AddCpuTime(cputime);
434 // Real time in [mus]
435 auto walltime = std::chrono::duration<double, std::micro>(wallendtime - wallstarttime).count();
436 algo->AddWallTime(walltime);
437
438
439 // Check some numbers from this timeslice
440 size_t nDigis = digivec.size();
441 LOG(debug) << "Component " << icomp << " connected to config " << config->GetName() << " n-Digis " << nDigis
442 << " processed in walltime(cputime) = " << walltime << "(" << cputime << cputime << ") micro s"
443 << "this timeslice.";
444
445 if (fDoPerfProf) {
446 auto timeit = fTimeMap.find(subsystem);
447 timeit->second.first += cputime;
448 timeit->second.second += walltime;
449
450 auto datait = fDataSizeMap.find(subsystem);
451 datait->second.first += ts->size_component(icomp) / 1.0e6;
452 datait->second.second += nDigis * algo->GetOutputObjSize() / 1.0e6;
453
454 fNameMap.find(subsystem)->second.second += nDigis;
455 }
456
457 if (fDoPerfProfPerTs) {
458 auto timeit = fTimeMapPerTs.find(subsystem);
459 timeit->second.first += cputime;
460 timeit->second.second += walltime;
461
462 auto datait = fDataSizeMapPerTs.find(subsystem);
463 datait->second.first += ts->size_component(icomp) / 1.0e6;
464 datait->second.second += nDigis * algo->GetOutputObjSize() / 1.0e6;
465
466 fNameMapPerTs.find(subsystem)->second.second += nDigis;
467 }
468
469 return nDigis;
470 }
471 // ----------------------------------------------------------------------------
472
475
477 std::shared_ptr<CbmMuchUnpackConfig> fMuchConfig = nullptr;
478
480 std::shared_ptr<CbmPsdUnpackConfig> fPsdConfig = nullptr;
481
483 std::shared_ptr<CbmRichUnpackConfig> fRichConfig = nullptr;
484
486 std::shared_ptr<CbmStsUnpackConfig> fStsConfig = nullptr;
487
489 std::shared_ptr<CbmTofUnpackConfig> fTofConfig = nullptr;
490
492 std::shared_ptr<CbmTrdUnpackConfig> fTrd1DConfig = nullptr;
493
495 std::shared_ptr<CbmTrdUnpackFaspConfig> fTrd2DConfig = nullptr;
496
498 std::shared_ptr<CbmBmonUnpackConfig> fBmonConfig = nullptr;
499
505
507 std::string fOutfilename = "CbmRecoUnpack.perf.root";
508
511
513 bool bMonitoringOnly = false;
514
516 bool bSpillFilter = false;
517
519 std::string sAccEvtTimingFile = "";
520
522 double_t dSpillFilterWinStart = 0.0;
523
525 double_t dSpillFilterWinStop = 0.0;
526
529
531 uint64_t ulSpillFilterTsDurationNs = 128000000;
532
536
538 std::vector<AccTimingEvent> vAccEvtsSpillStart = {};
539
541 std::vector<AccTimingEvent> vAccEvtsSpillEnd = {};
542
544 std::vector<AccTimingEvent>::iterator itSpillStart = vAccEvtsSpillStart.end();
545
547 std::vector<AccTimingEvent>::iterator itSpillStop = vAccEvtsSpillEnd.end();
548
550 uint32_t uSpillIndex = 0;
551
553 TH1* fhDigiSpillStartDist = nullptr;
554 TH1* fhDigiSpillStopDist = nullptr;
555 TH2* fhDigiSpillFilterStart = nullptr;
556 TH2* fhDigiSpillFilterStop = nullptr;
557 std::map<Subsystem, TH1*> fhDigiSpillStartDistPerDet = {};
558 std::map<Subsystem, TH1*> fhDigiSpillStopDistPerDet = {};
559 std::map<Subsystem, TH2*> fhDigiSpillFilterStartPerDet = {};
560 std::map<Subsystem, TH2*> fhDigiSpillFilterStopPerDet = {};
561
567 void InitSpillFilter();
568
575 void initSpillFilterMonitoring(Subsystem subsystem, std::string name);
576
578 template<typename TVecobj>
579 typename std::enable_if<std::is_same<TVecobj, std::nullptr_t>::value == true, void>::type
580 SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector<TVecobj>* /*vec = nullptr*/)
581 {
582 LOG(debug) << "CbmRecoUnpack::SpillFilter() got an object that has no member function GetTime(). Hence, we can and "
583 "will not filter it!";
584 }
585
586 template<typename TVecobj>
587 typename std::enable_if<!std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
588 SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector<TVecobj>* /*vec = nullptr*/)
589 {
590 LOG(debug) << "CbmRecoUnpack::SpillFilter() " << TVecobj::Class_Name()
591 << "is an object that has no member function GetTime(). Hence, we can and "
592 "will not filter it!";
593 }
594
595 template<typename TVecobj>
596 typename std::enable_if<std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
597 SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector<TVecobj>* vec = nullptr)
598 {
599 size_t originalSize = vec->size();
600
601 ulTsStartNs -= iSpillFilterStartDelay;
602 uint64_t ulTsStopNs = ulTsStartNs + ulSpillFilterTsDurationNs;
603 bool bStartInTs = false;
604 double_t dStartTimeInTs = 0.0;
605 if (ulTsStartNs <= itSpillStart->GetTime() && itSpillStart->GetTime() <= ulTsStopNs) {
606 bStartInTs = true;
607 dStartTimeInTs = itSpillStart->GetTime() - ulTsStartNs;
608 }
609 bool bStopInTs = false;
610 double_t dStopTimeInTs = 0.0;
611 if (ulTsStartNs <= itSpillStop->GetTime() && itSpillStop->GetTime() <= ulTsStopNs) {
612 bStopInTs = true;
613 dStopTimeInTs = itSpillStop->GetTime() - ulTsStartNs;
614 }
615 if (bStartInTs || bStopInTs) {
616 auto itWinStart = vec->begin();
617 auto itWinStop = vec->end();
618 bool bFoundStart = false;
619 bool bFoundStop = false;
620 for (auto itDigi = vec->begin(); itDigi != vec->end(); ++itDigi) {
621 double_t dTimeToStart = itDigi->GetTime() - dStartTimeInTs;
622 double_t dTimeToStop = itDigi->GetTime() - dStopTimeInTs;
623
624 if (!bFoundStart && dSpillFilterWinStart <= dTimeToStart) {
625 itWinStart = itDigi;
626 bFoundStart = true;
627 }
628 if (!bFoundStop && dSpillFilterWinStop < dTimeToStart) {
629 itWinStop = itDigi;
630 bFoundStop = true;
631 }
632
633 fhDigiSpillStartDist->Fill(dTimeToStart);
634 fhDigiSpillStopDist->Fill(dTimeToStop);
635 fhDigiSpillStartDistPerDet[subsystem]->Fill(dTimeToStart);
636 fhDigiSpillStopDistPerDet[subsystem]->Fill(dTimeToStop);
637 if (dSpillFilterWinStart <= dTimeToStart && dTimeToStart <= dSpillFilterWinStop) {
638 fhDigiSpillFilterStart->Fill(dTimeToStart, uSpillIndex);
639 fhDigiSpillFilterStartPerDet[subsystem]->Fill(dTimeToStart, uSpillIndex);
640 }
641 if (dSpillFilterWinStart <= dTimeToStop && dTimeToStop <= dSpillFilterWinStop) {
642 fhDigiSpillFilterStop->Fill(dTimeToStop, uSpillIndex);
643 fhDigiSpillFilterStopPerDet[subsystem]->Fill(dTimeToStop, uSpillIndex);
644 }
645
646 if (!bSpillFilterMoniFindPeak && dSpillFilterWinStop < dTimeToStart && dSpillFilterWinStop < dTimeToStop) {
647 // Stop once both SpillStart and SpillStop passed, except if long range monitoring enabled
648 break;
649 }
650 }
653 if (bFoundStop) {
654 vec->erase(itWinStop, vec->end());
655 }
656
659 if (bFoundStart) {
660 vec->erase(vec->begin(), itWinStart);
661 }
662 }
663 else {
664 vec->clear();
665 }
666
667 LOG(debug2) << "Filtered " << fles::to_string(subsystem) << " digi vector from " << originalSize << " to "
668 << vec->size();
669 }
670
672};
673
674
675#endif
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
Configuration class for an unpacker algorithm.
bool Bool_t
void SetOutputFilename(std::string value)
Set the performance profiling Output Filename.
virtual Bool_t initParContainers(std::vector< std::pair< std::string, std::shared_ptr< FairParGenericSet > > > *reqparvec)
Initialise the parameter containers requested by the algorithm.
void Finish()
Actions at the end of the run.
void SetUnpackConfig(std::shared_ptr< CbmTofUnpackConfig > config)
Set the Tof Unpack Config.
void SetUnpackConfig(std::shared_ptr< CbmPsdUnpackConfig > config)
Set the Psd Unpack Config.
std::unique_ptr< cbm::Monitor > fMonitor
ratio of total unpacked size to input size vs TS in run
CbmTimeSlice * fTimeSlice
CbmTimeslice object, mostly redundant with the TsEventHeader, needed by L1 to switch timeslice mode.
double_t dSpillFilterWinStart
Start of time window for digi filtering relative to spill start event.
TH1 * fhDigiSpillStartDist
Monitoring histograms for the spill digi filter.
std::string fUriPublishProfMoni
URI (type:hostname:port:db_name) for optional connection to monitoring DB.
TH2 * fhDigiSpillFilterStop
Digi time relative to spill start.
std::map< Subsystem, TH2 * > fhDigiSpillFilterStartPerDet
Digi time relative to spill stop, per detector.
CbmRecoUnpack()
Constructor.
std::map< Subsystem, TH1 * > fvhUnpRatioPerTs
ratio of system digi size in total output size vs TS in run
bool fPublishProfMoni
Flag if performance profiling data should be published to monitoring DB.
size_t unpack(const Subsystem subsystem, 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::string fMoniJobId
double_t dSpillFilterWinStop
End of time window for digi filtering relative to spill start event.
std::string fMoniCurrrentHostname
The application's monitoring object.
void SetTimeSorting(bool bIn=true)
Enable/disable a full time sorting. If off, time sorting happens per link/FLIM source.
void WriteHistograms()
Open special output file and save eventual performance monitoring histograms into it.
std::enable_if<!std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector< TVecobj > *)
std::map< Subsystem, std::pair< double, double > > fDataSizeMap
Map to store the in and out data amount, key = Subsystem.
std::string sAccEvtTimingFile
Full path to a text file containing the raw Accelerator Event timings.
TH1 * fhRealTimePerTsHist
Plotting time per TS.
std::enable_if<!std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type timesort(std::vector< TVecobj > *)
void SetMonitoringOnly(bool bIn=true)
Enable/disable the data output. If On, data unpacked and monitored but neither sorted nor written to ...
TH1 * fhCpuTimePerTsHist
Processing time per TS.
std::map< Subsystem, std::pair< double, double > > fDataSizeMapCurrSec
void SetUnpackConfig(std::shared_ptr< CbmTrdUnpackFaspConfig > config)
Set the Trd2D Unpack Config.
void Reset()
Clear the output vectors as preparation of the next timeslice. Called via FairSource::Reset()
std::map< Subsystem, TH2 * > fhDigiSpillFilterStopPerDet
Digi time relative to spill start, per detector.
std::string fOutfilename
Name of the performance profiling output file.
std::shared_ptr< CbmStsUnpackConfig > fStsConfig
Configuration of the Sts unpacker. Provides the configured algorithm.
bool bOutputFullTimeSorting
Flag to Enable/disable a full time sorting. If off, time sorting happens per link/FLIM source.
void SetUnpackConfig(std::shared_ptr< CbmRichUnpackConfig > config)
Set the Rich Unpack Config.
std::map< Subsystem, std::pair< std::string, size_t > > fNameMapPerTs
Map to store a name for the unpackers and the processed amount of digis for a single TS,...
std::shared_ptr< CbmBmonUnpackConfig > fBmonConfig
Configuration of the Bmon unpacker. Provides the configured algorithm.
CbmTsEventHeader * fCbmTsEventHeader
Pointer to the Timeslice start time used to write it to the output tree.
std::vector< AccTimingEvent >::iterator itSpillStart
Current spill start Event.
std::map< Subsystem, TH1 * > fvhOutRatioPerTs
ratio of system data in total input size vs TS in run
void initSpillFilterMonitoring(Subsystem subsystem, std::string name)
Init the Spill filter monitoring histograms for a given system.
void InitSpillFilter()
Digi time relative to spill stop, per detector.
std::shared_ptr< CbmTrdUnpackFaspConfig > fTrd2DConfig
Configuration of the Trd unpacker. Provides the configured algorithm.
bool fPubMoniProcTime
Flag if perf data should be published to moni DB using data time (false) or processing time (true).
TH1 * fhDigiSpillStopDist
Digi time relative to spill start.
std::map< Subsystem, std::pair< double, double > > fTimeMap
Map to store the cpu and wall time, key = Subsystem.
fles::Subsystem Subsystem
bool bMonitoringOnly
Flag to Enable/disable the output completely.
void SetDebugPrintout(bool value=true)
Set the Debug Printout Flag.
ClassDef(CbmRecoUnpack, 4)
std::map< Subsystem, TH1 * > fhDigiSpillStartDistPerDet
Digi time relative to spill stop.
std::map< Subsystem, TH1 * > fvhInpRatioPerTs
Plotting time per TS.
void initPerformanceMaps(Subsystem subsystem, std::string name)
Init the performance profiling maps for a given unpacker.
std::shared_ptr< CbmTofUnpackConfig > fTofConfig
Configuration of the Tof unpacker. Provides the configured algorithm.
~CbmRecoUnpack()
Destructor.
std::map< Subsystem, std::pair< double, double > > fDataSizeMapPerTs
Map to store the in and out data amount for a single TS, key = Subsystem.
void performanceProfiling()
Run the performance profiling based on the fTimeMap and fDataSizeMap members.
uint32_t uSpillIndex
Index of the current spill in current run.
std::enable_if< std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector< TVecobj > *vec=nullptr)
bool fDoDebugPrints
Flag if extended debug output is to be printed or not.
std::vector< AccTimingEvent > vAccEvtsSpillStart
Storage of spill start accelerator events (Either KickerStart or ExtractionStartSlow)
std::map< Subsystem, std::pair< double, double > > fTimeMapPerTs
Map to store the cpu and wall time for a single TS, key = Subsystem.
void SetUnpackConfig(std::shared_ptr< CbmBmonUnpackConfig > config)
Set the Bmon Unpack Config.
bool bSpillFilterMoniFindPeak
Flag to Enable/disable monitoring histos with long range for digi filtering relative to spill start e...
TH2 * fhDigiSpillFilterStart
Digi time relative to spill stop.
int32_t iSpillFilterStartDelay
Delay of the real start of the spill relative to Spill Start Event (negative if Event is late one)
TH1 * fhRealTimePerTs
Processing time per TS.
void Unpack(std::unique_ptr< fles::Timeslice > ts)
Trigger the unpacking procedure.
TH1 * fhUnpackingRatioPerTs
ratio of selected digi vs TS in run
CbmRecoUnpack & operator=(const CbmRecoUnpack &)=delete
Assignment operator - not implemented.
std::shared_ptr< CbmMuchUnpackConfig > fMuchConfig
Current time slice.
void SetUnpackConfig(std::shared_ptr< CbmStsUnpackConfig > config)
Set the Sts Unpack Config.
std::shared_ptr< CbmTrdUnpackConfig > fTrd1DConfig
Configuration of the Trd unpacker. Provides the configured algorithm.
CbmRecoUnpack(const CbmRecoUnpack &)=delete
Copy constructor - not implemented.
bool fDoPerfProfPerTs
Flag if performance profiling per TS should be activated or not.
void SetDoPerfProfiling(bool value=true)
(De)Activate the performance profiling based on histograms
void SetUnpackConfig(std::shared_ptr< CbmMuchUnpackConfig > config)
Set the Much Unpack Config.
std::map< Subsystem, TH1 * > fhDigiSpillStopDistPerDet
Digi time relative to spill start, per detector.
void performanceProfilingPerTs()
Run the performance profiling for a single TS based on the fTimeMapPerTs and fDataSizeMapPerTs member...
bool bSpillFilter
Flag to Enable/disable digi filtering relative to spill start event.
std::enable_if< std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type timesort(std::vector< TVecobj > *vec=nullptr)
TStopwatch * fTimerTs
std::chrono::system_clock::time_point fMonitorSecCurrentTs
uint64_t ulSpillFilterTsDurationNs
Duration of TS in nanoseconds (mCBM default = 128 ms = 128 000 000 ns)
std::shared_ptr< CbmRichUnpackConfig > fRichConfig
Configuration of the Rich unpacker. Provides the configured algorithm.
void SetDoPerfProfilingPerTs(bool value=true)
(De)Activate the performance profiling based on histograms for each TS
void SetPublishProfMoni(bool value=true, std::string sUriMonitor="", bool useProcTime=false, std::string sJobId="local")
(De)Activate the publication of performance profiling data to monitoring DB
void RegisterOutputs(FairRootManager *ioman, std::shared_ptr< TConfig > config)
Bool_t Init()
Initialisation.
std::vector< AccTimingEvent >::iterator itSpillStop
Current spill stop Event.
std::map< Subsystem, std::pair< std::string, size_t > > fNameMap
Map to store a name for the unpackers and the processed amount of digis, key = Subsystem.
std::shared_ptr< CbmPsdUnpackConfig > fPsdConfig
Configuration of the Psd unpacker. Provides the configured algorithm.
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()
void AddSpillFilter(std::string sAccEvtTimingFileIn, double_t dWinStart=-1000.0, double_t dWinStop=4500.0, int32_t iSpillStartDelay=28400, uint64_t ulTsDurationNs=128000000, bool bMoniFindPeak=false)
Enable filtering of the digis using a user define window around the spill start. Requires a full time...
void SetUnpackConfig(std::shared_ptr< CbmTrdUnpackConfig > config)
Set the Trd Unpack Config.
std::enable_if< std::is_same< TVecobj, std::nullptr_t >::value==true, void >::type SpillFilter(uint64_t ulTsStartNs, const Subsystem subsystem, std::vector< TVecobj > *)
Filter a vector timewise relative to spill start. Vector type has to provide GetTime()
bool fDoPerfProf
Flag if performance profiling should be activated or not.
std::vector< AccTimingEvent > vAccEvtsSpillEnd
Storage of spill end accelerator events (ExtractionEnd or ExtractionSlowStop)
Bookkeeping of time-slice content.