CbmRoot
Loading...
Searching...
No Matches
CbmRecoUnpack.cxx
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 */
11#include "CbmRecoUnpack.h"
12
13#include "CbmRecoUnpackConfig.tmpl"
14#include "CbmTimeSlice.h"
15#include "CbmTrdDigi.h"
16#include "CbmTsEventHeader.h"
17
18#include <Monitor.hpp>
19#include <System.hpp>
20
21#include <FairRootManager.h>
22#include <Logger.h>
23
24#include <RtypesCore.h>
25#include <TH1.h>
26#include <TStopwatch.h>
27
28#include <cstddef>
29#include <cstdint>
30#include <memory>
31#include <utility>
32#include <vector>
33
34
35using fles::Subsystem;
36using fles::Timeslice;
37using std::unique_ptr;
38
39
40// ----- Constructor ------------------------------------------------------
42// ----------------------------------------------------------------------------
43
44// ----- Destructor ------------------------------------------------------
46{
48 LOG(debug) << "CbmRecoUnpack::~CbmRecoUnpack!";
49};
50// ----------------------------------------------------------------------------
51
52
53// ----- Finish -----------------------------------------------------------
55{
56 LOG(info) << "CbmRecoUnpack::Finish() I do let the unpackers talk first :\n";
57
58 if (fPsdConfig) fPsdConfig->GetUnpacker()->Finish();
59 if (fMuchConfig) fMuchConfig->GetUnpacker()->Finish();
60 if (fRichConfig) fRichConfig->GetUnpacker()->Finish();
61 if (fStsConfig) fStsConfig->GetUnpacker()->Finish();
62 if (fTofConfig) fTofConfig->GetUnpacker()->Finish();
63 if (fTrd1DConfig) fTrd1DConfig->GetUnpacker()->Finish();
64 if (fTrd2DConfig) fTrd2DConfig->GetUnpacker()->Finish();
65 if (fBmonConfig) fBmonConfig->GetUnpacker()->Finish();
66
67 // Create some default performance profiling histograms and write them to a file
69 if (fPublishProfMoni) {
70 double dTotalDataSizeIn = 0.0;
71 double dTotalDataSizeOut = 0.0;
72 for (auto datait : fDataSizeMapCurrSec) {
73 dTotalDataSizeIn += datait.second.first;
74 dTotalDataSizeOut += datait.second.second;
75 }
76 for (auto datait : fDataSizeMapCurrSec) {
77 double dUnpRatio = 0 < datait.second.first ? datait.second.second / datait.second.first : 0.0;
78 double dShareIn = 0 < dTotalDataSizeIn ? datait.second.first / dTotalDataSizeIn : 0.0;
79 double dShareOut = 0 < dTotalDataSizeOut ? datait.second.second / dTotalDataSizeOut : 0.0;
80 fMonitor->QueueMetric(
81 "unpack_perf",
82 {{"host", fMoniCurrrentHostname}, {"jobid", fMoniJobId}, {"det", fNameMapPerTs[datait.first].first}},
83 {{"dataIn", datait.second.first},
84 {"dataOut", datait.second.second},
85 {"unpRatio", dUnpRatio},
86 {"shareIn", dShareIn},
87 {"shareOut", dShareOut}},
88 fPubMoniProcTime ? std::chrono::system_clock::time_point() : fMonitorSecCurrentTs);
89 }
90 }
91}
92
93// ----------------------------------------------------------------------------
94
95// ----- Initialisation ---------------------------------------------------
97{
98
99 FairRootManager* ioman = FairRootManager::Instance();
100 assert(ioman);
101
102 auto eh = FairRun::Instance()->GetEventHeader();
103 if (eh->IsA() == CbmTsEventHeader::Class())
104 fCbmTsEventHeader = static_cast<CbmTsEventHeader*>(eh);
105 else
106 LOG(fatal)
107 << "CbmRecoUnpack::Init() no CbmTsEventHeader was added to the run. Without it, we can not store the UTC of the "
108 "Timeslices correctly. Hence, this causes a fatal. Please add it in the steering macro to the Run.";
109
110 fTimeSlice = new CbmTimeSlice(0., 1.28e8 + 1.28e6); // FIXME: hardcoded TS length + overlap of mCBM 2022 becnhmark
111 ioman->Register("TimeSlice.", "DAQ", fTimeSlice, kTRUE);
112
113 // --- Psd
114 if (fPsdConfig) {
115 fPsdConfig->InitOutput();
117 fPsdConfig->SetAlgo();
118 initParContainers(fPsdConfig->GetParContainerRequest());
119 fPsdConfig->InitAlgo();
120 initPerformanceMaps(Subsystem::PSD, "PSD");
121 }
122 // --- Rich
123 if (fRichConfig) {
124 fRichConfig->InitOutput();
126 fRichConfig->SetAlgo();
127 initParContainers(fRichConfig->GetParContainerRequest());
128 fRichConfig->InitAlgo();
129 initPerformanceMaps(Subsystem::RICH, "RICH");
130 }
131
132 // --- Sts
133 if (fStsConfig) {
134 fStsConfig->InitOutput();
136 fStsConfig->SetAlgo();
137 initParContainers(fStsConfig->GetParContainerRequest());
138 fStsConfig->InitAlgo();
139 initPerformanceMaps(Subsystem::STS, "STS");
140 }
141
142 // --- Much
143 if (fMuchConfig) {
144 fMuchConfig->InitOutput();
146 fMuchConfig->SetAlgo();
147 initParContainers(fMuchConfig->GetParContainerRequest());
148 fMuchConfig->InitAlgo();
149 initPerformanceMaps(Subsystem::MUCH, "MUCH");
150 }
151
152
153 // --- Tof
154 if (fTofConfig) {
155 fTofConfig->InitOutput();
157 fTofConfig->SetAlgo();
158 fTofConfig->LoadParFileName();
159 initParContainers(fTofConfig->GetParContainerRequest());
160 fTofConfig->InitAlgo();
161 initPerformanceMaps(Subsystem::TOF, "TOF");
162 }
163 // --- Trd
164 if (fTrd1DConfig) {
165 fTrd1DConfig->InitOutput();
167 fTrd1DConfig->SetAlgo();
168 initParContainers(fTrd1DConfig->GetParContainerRequest());
169 fTrd1DConfig->InitAlgo();
170 initPerformanceMaps(Subsystem::TRD, "TRD1D");
171 }
172 // --- TRD2D
173 if (fTrd2DConfig) {
174 if (fTrd1DConfig && (fTrd2DConfig->GetOutputBranchName() == fTrd1DConfig->GetOutputBranchName())) {
175 LOG(info) << fTrd2DConfig->GetName() << "::Init() ---------------------------------";
176 fTrd2DConfig->SetOutputVec(fTrd1DConfig->GetOutputVec());
177 }
178 else {
179 fTrd2DConfig->InitOutput();
181 }
182 fTrd2DConfig->SetAlgo();
183 initParContainers(fTrd2DConfig->GetParContainerRequest());
184 fTrd2DConfig->InitAlgo();
185 initPerformanceMaps(Subsystem::TRD2D, "TRD2D");
186 }
187 // This is an ugly work around, because the TRD and TRD2D want to access the same vector and there is no
188 // function to retrieve a writeable vector<obj> from the FairRootManager, especially before the branches
189 // are created, as far as I am aware.
190 // The second option workaround is in in Init() to look for the fasp config and create a separate branch
191 // for fasp created CbmTrdDigis PR 072021
192
193 // --- Bmon
194 if (fBmonConfig) {
195 fBmonConfig->InitOutput();
197 fBmonConfig->SetAlgo();
198 fBmonConfig->LoadParFileName();
199 initParContainers(fBmonConfig->GetParContainerRequest());
200 fBmonConfig->InitAlgo();
201 initPerformanceMaps(Subsystem::BMON, "Bmon");
202 }
203
204 if (fDoPerfProfPerTs) {
206 fTimerTs = new TStopwatch();
207
208 fhCpuTimePerTs = new TH1D("hCpuTimePerTs", "CPU Processing time of TS vs TS; Ts; CPU time [ms]", 6000, 0, 6000);
209 fhRealTimePerTs = new TH1D("hRealTimePerTs", "Real Processing time of TS vs TS; Ts; Real time [ms]", 6000, 0, 6000);
210
212 new TH1D("hCpuTimePerTsHist", "CPU Histo filling time of TS vs TS; Ts; CPU time [ms]", 6000, 0, 6000);
214 new TH1D("hRealTimePerTsHist", "Real Histo filling time of TS vs TS; Ts; Real time [ms]", 6000, 0, 6000);
215
217 new TH1D("hUnpackingRatioPerTs", "ratio of tot. unp. digi size to tot. input raw size vs TS; TS; Size Ratio []",
218 6000, 0, 6000);
219 }
220
221 if (fPublishProfMoni) { //
222 fMonitor = std::make_unique<cbm::Monitor>(fUriPublishProfMoni);
223 fMoniCurrrentHostname = fles::system::current_hostname();
224 LOG(info) << "Unpack: Publishing monitoring metrics to time-series DB at " << fUriPublishProfMoni << " as "
225 << fMoniCurrrentHostname << " with job ID " << fMoniJobId;
226 }
227
228 return kTRUE;
229}
230// ----------------------------------------------------------------------------
231
232
233// ----- initPerformanceMaps ----------------------------------------------
234void CbmRecoUnpack::initPerformanceMaps(Subsystem subsystem, std::string name)
235{
236 if (fDoPerfProf) {
237 fNameMap.emplace(std::make_pair(subsystem, std::make_pair(name, 0)));
238 fTimeMap.emplace(std::make_pair(subsystem, std::make_pair(0, 0)));
239 fDataSizeMap.emplace(std::make_pair(subsystem, std::make_pair(0, 0)));
240 }
241 if (fDoPerfProfPerTs) {
242 fNameMapPerTs.emplace(std::make_pair(subsystem, std::make_pair(name, 0)));
243 fTimeMapPerTs.emplace(std::make_pair(subsystem, std::make_pair(0, 0)));
244 fDataSizeMapPerTs.emplace(std::make_pair(subsystem, std::make_pair(0, 0)));
245 if (fPublishProfMoni) { //
246 fDataSizeMapCurrSec.emplace(std::make_pair(subsystem, std::make_pair(0, 0)));
247 }
248
249 fvhInpRatioPerTs.emplace(std::make_pair(
250 subsystem,
251 new TH1D(Form("hInpRatioPerTs%s", name.c_str()),
252 Form("ratio of input data size in total input data size vs TS for %s; TS; Size Ratio []", name.c_str()),
253 6000, 0, 6000)));
254 fvhOutRatioPerTs.emplace(std::make_pair(
255 subsystem,
256 new TH1D(Form("hOutRatioPerTs%s", name.c_str()),
257 Form("ratio of unpacked digi size in total output size vs TS for %s; TS; Size Ratio []", name.c_str()),
258 6000, 0, 6000)));
259 fvhUnpRatioPerTs.emplace(std::make_pair(
260 subsystem,
261 new TH1D(Form("hUnpRatioPerTs%s", name.c_str()),
262 Form("ratio of unpacked digi size to raw data size vs TS for %s; TS; O/I Size Ratio []", name.c_str()),
263 6000, 0, 6000)));
264 }
265}
266// ----------------------------------------------------------------------------
267
268
269// ----- performanceProfiling ---------------------------------------------
271{
272 std::unique_ptr<TH1D> hProducedDigis =
273 std::unique_ptr<TH1D>(new TH1D("ProducedDigis", "ProducedDigis", fNameMap.size(), -0.5, fNameMap.size() - 0.5));
274 hProducedDigis->SetXTitle("Subsystem");
275 hProducedDigis->SetYTitle("N-Digis");
276 std::unique_ptr<TH1D> hSpeedPerf = std::unique_ptr<TH1D>(
277 new TH1D("SpeedPerformance", "SpeedPerformance", fNameMap.size() * 2, -0.5, fNameMap.size() * 2 - 0.5));
278 hSpeedPerf->SetXTitle("Subsystem");
279 hSpeedPerf->SetYTitle("Unpacking performance [#mus/Digi]");
280 std::unique_ptr<TH1D> hDataPerf = std::unique_ptr<TH1D>(
281 new TH1D("DataPerformance", "DataPerformance", fNameMap.size() * 2, -0.5, fNameMap.size() * 2 - 0.5));
282 hDataPerf->SetXTitle("Subsystem");
283 hDataPerf->SetYTitle("Data [MB]");
284 size_t iunpackerbin = 1;
285 for (auto namepair : fNameMap) {
286
287 // Speed performance
288 auto timeit = fTimeMap.find(namepair.first);
289 double cpu = 0 < namepair.second.second ? timeit->second.first / namepair.second.second : 0.0;
290 double wall = 0 < namepair.second.second ? timeit->second.second / namepair.second.second : 0.0;
291
292 // Data performance
293 auto datait = fDataSizeMap.find(namepair.first);
294 double indata = datait->second.first;
295 double outdata = datait->second.second;
296
297
298 // N-Digis
299 std::string label = namepair.second.first;
300 hProducedDigis->GetXaxis()->SetBinLabel(iunpackerbin, label.data());
301 hProducedDigis->SetBinContent(iunpackerbin, namepair.second.second);
302
303 // Cpu time
304 label = namepair.second.first;
305 label += " cpu";
306 hSpeedPerf->GetXaxis()->SetBinLabel(iunpackerbin * 2 - 1, label.data());
307 hSpeedPerf->SetBinContent(iunpackerbin * 2 - 1, cpu);
308 // Wall time
309 label = namepair.second.first;
310 label += " wall";
311 hSpeedPerf->GetXaxis()->SetBinLabel(iunpackerbin * 2, label.data());
312 hSpeedPerf->SetBinContent(iunpackerbin * 2, wall);
313
314 // In data
315 label = namepair.second.first;
316 label += " in";
317 hDataPerf->GetXaxis()->SetBinLabel(iunpackerbin * 2 - 1, label.data());
318 hDataPerf->SetBinContent(iunpackerbin * 2 - 1, indata);
319
320 // Out data
321 label = namepair.second.first;
322 label += " out";
323 hDataPerf->GetXaxis()->SetBinLabel(iunpackerbin * 2, label.data());
324 hDataPerf->SetBinContent(iunpackerbin * 2, outdata);
325
326 ++iunpackerbin;
327 }
328
330 TFile* oldFile = gFile;
331 TDirectory* oldDir = gDirectory;
332
334 TFile histofile(fOutfilename.data(), "RECREATE");
335
336 histofile.cd();
337 hProducedDigis->Write();
338 hSpeedPerf->Write();
339 hDataPerf->Write();
340
341 if (fDoPerfProfPerTs) {
342 fhCpuTimePerTs->Write();
343 fhRealTimePerTs->Write();
344 fhCpuTimePerTsHist->Write();
345 fhRealTimePerTsHist->Write();
346 for (auto detHist : fvhInpRatioPerTs) {
347 fvhInpRatioPerTs[detHist.first]->Write();
348 fvhOutRatioPerTs[detHist.first]->Write();
349 fvhUnpRatioPerTs[detHist.first]->Write();
350 }
351 fhUnpackingRatioPerTs->Write();
352 }
353
355 gFile = oldFile;
356 gDirectory = oldDir;
357
358 // histofile->Close();
359 histofile.Close();
360}
362{
364 double dTotalCpuTime = fTimerTs->CpuTime() * 1000.;
365 double dTotalRealTime = fTimerTs->RealTime() * 1000.;
366 fTimerTs->Start();
367
368 /*
369 for (auto timeit : fTimeMapPerTs) {
370 // Speed performance
371 dTotalCpuTime += timeit->second.first
372 dTotalRealTime += timeit->second.second
373 }
374 */
375
376 double dTotalDataSizeIn = 0.0;
377 double dTotalDataSizeOut = 0.0;
378
379 using sctp = std::chrono::system_clock::time_point;
380 sctp tsStart = sctp(std::chrono::seconds(static_cast<uint64_t>(fCbmTsEventHeader->GetTsStartTime() * 1e-9)));
381 if (fMonitorSecCurrentTs == sctp()) { //
382 fMonitorSecCurrentTs = tsStart;
383 }
384 else if (fPubMoniProcTime || fMonitorSecCurrentTs < tsStart) {
385 for (auto datait : fDataSizeMapCurrSec) {
386 dTotalDataSizeIn += datait.second.first;
387 dTotalDataSizeOut += datait.second.second;
388 }
389 for (auto datait : fDataSizeMapCurrSec) {
390 double dUnpRatio = 0 < datait.second.first ? datait.second.second / datait.second.first : 0.0;
391 double dShareIn = 0 < dTotalDataSizeIn ? datait.second.first / dTotalDataSizeIn : 0.0;
392 double dShareOut = 0 < dTotalDataSizeOut ? datait.second.second / dTotalDataSizeOut : 0.0;
393 fMonitor->QueueMetric(
394 "unpack_perf",
395 {{"host", fMoniCurrrentHostname}, {"jobid", fMoniJobId}, {"det", fNameMapPerTs[datait.first].first}},
396 {{"dataIn", datait.second.first},
397 {"dataOut", datait.second.second},
398 {"unpRatio", dUnpRatio},
399 {"shareIn", dShareIn},
400 {"shareOut", dShareOut}},
402 }
403 fMonitorSecCurrentTs = tsStart;
404 for (auto datait = fDataSizeMapCurrSec.begin(); datait != fDataSizeMapCurrSec.end(); ++datait) {
405 datait->second.first = 0.0;
406 datait->second.second = 0.0;
407 }
408 dTotalDataSizeIn = 0.0;
409 dTotalDataSizeOut = 0.0;
410 }
411
413 for (auto datait : fDataSizeMapPerTs) {
414 dTotalDataSizeIn += datait.second.first;
415 dTotalDataSizeOut += datait.second.second;
416
417 if (fPublishProfMoni) {
418 fDataSizeMapCurrSec[datait.first].first += datait.second.first;
419 fDataSizeMapCurrSec[datait.first].second += datait.second.second;
420 }
421 }
422 for (auto datait : fDataSizeMapPerTs) {
423 fvhInpRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.first / dTotalDataSizeIn);
424 fvhOutRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.second / dTotalDataSizeOut);
425 if (datait.second.first) { //
426 fvhUnpRatioPerTs[datait.first]->Fill(fCbmTsEventHeader->GetTsIndex(), datait.second.second / datait.second.first);
427 }
428 }
429 fhUnpackingRatioPerTs->Fill(fCbmTsEventHeader->GetTsIndex(), dTotalDataSizeOut / dTotalDataSizeIn);
430 fhCpuTimePerTs->Fill(fCbmTsEventHeader->GetTsIndex(), dTotalCpuTime);
431 fhRealTimePerTs->Fill(fCbmTsEventHeader->GetTsIndex(), dTotalRealTime);
432
433 for (auto timeit = fTimeMapPerTs.begin(); timeit != fTimeMapPerTs.end(); ++timeit) {
434 // Speed performance
435 timeit->second.first = 0.0;
436 timeit->second.second = 0.0;
437 }
438 for (auto datait = fDataSizeMapPerTs.begin(); datait != fDataSizeMapPerTs.end(); ++datait) {
439 datait->second.first = 0.0;
440 datait->second.second = 0.0;
441 }
442
443 fTimerTs->Stop();
444 fhCpuTimePerTsHist->Fill(fCbmTsEventHeader->GetTsIndex(), fTimerTs->CpuTime() * 1000.);
445 fhRealTimePerTsHist->Fill(fCbmTsEventHeader->GetTsIndex(), fTimerTs->RealTime() * 1000.);
446}
447// ----------------------------------------------------------------------------
448
449// ----- Reset ------------------------------------------------------------
451{
452 // Reset the event header for a new timeslice
454 fTimeSlice->Reset(0., 1.28e8 + 1.28e6); // FIXME: hardcoded TS length + overlap of mCBM 2022 becnhmark
455
456 // Reset the unpackers for a new timeslice, e.g. clear the output vectors
457
458 // ----Much ----
459 if (fMuchConfig) fMuchConfig->Reset();
460 // ---- Psd ----
461 if (fPsdConfig) fPsdConfig->Reset();
462 // ---- Rich ----
463 if (fRichConfig) fRichConfig->Reset();
464 // ---- Sts ----
465 if (fStsConfig) fStsConfig->Reset();
466 // ---- Tof ----
467 if (fTofConfig) fTofConfig->Reset();
468 // ---- Trd ----
469 if (fTrd1DConfig) fTrd1DConfig->Reset();
470 // ---- Trd2D ----
471 if (fTrd2DConfig) fTrd2DConfig->Reset();
472 // ---- Bmon ----
473 if (fBmonConfig) fBmonConfig->Reset();
474}
475
476// ----------------------------------------------------------------------------
477
478// ----- Unpacking --------------------------------------------------------
479void CbmRecoUnpack::Unpack(unique_ptr<Timeslice> ts)
480{
481 if (fDoPerfProfPerTs) {
483 fTimerTs->Start();
484 }
485
486 // Prepare timeslice
487 const fles::Timeslice& timeslice = *ts;
488
489 fCbmTsEventHeader->SetTsIndex(ts->index());
490 fCbmTsEventHeader->SetTsStartTime(ts->start_time());
491
492 fTimeSlice->SetStartTime(ts->start_time());
493
494 uint64_t nComponents = ts->num_components();
495 if (fDoDebugPrints || 0 == ts->index() % 100) {
496 LOG(info) << "Unpack: TS index " << ts->index() << " components " << nComponents;
497 }
498
499 for (uint64_t component = 0; component < nComponents; component++) {
500
501 auto subsystem = static_cast<Subsystem>(ts->descriptor(component, 0).sys_id);
502
503 switch (subsystem) {
504 case Subsystem::MUCH: {
505 if (fMuchConfig) {
506 fCbmTsEventHeader->AddNDigisMuch(unpack(subsystem, &timeslice, component, fMuchConfig,
507 fMuchConfig->GetOptOutAVec(), fMuchConfig->GetOptOutBVec()));
508 }
509 break;
510 }
511
512 case Subsystem::PSD: {
513 if (fPsdConfig) {
514 fCbmTsEventHeader->AddNDigisPsd(unpack(subsystem, &timeslice, component, fPsdConfig,
515 fPsdConfig->GetOptOutAVec(), fPsdConfig->GetOptOutBVec()));
516 }
517 break;
518 }
519 case Subsystem::RICH: {
520 if (fRichConfig) {
521 fCbmTsEventHeader->AddNDigisRich(unpack(subsystem, &timeslice, component, fRichConfig,
522 fRichConfig->GetOptOutAVec(), fRichConfig->GetOptOutBVec()));
523 }
524 break;
525 }
526 case Subsystem::STS: {
527 if (fStsConfig) {
528 fCbmTsEventHeader->AddNDigisSts(unpack(subsystem, &timeslice, component, fStsConfig,
529 fStsConfig->GetOptOutAVec(), fStsConfig->GetOptOutBVec()));
530 }
531 break;
532 }
533 case Subsystem::TOF: {
534 if (fTofConfig) {
535 fCbmTsEventHeader->AddNDigisTof(unpack(subsystem, &timeslice, component, fTofConfig,
536 fTofConfig->GetOptOutAVec(), fTofConfig->GetOptOutBVec()));
537 }
538 break;
539 }
540 case Subsystem::TRD: {
541 if (fTrd1DConfig) {
542 fCbmTsEventHeader->AddNDigisTrd1D(unpack(subsystem, &timeslice, component, fTrd1DConfig,
543 fTrd1DConfig->GetOptOutAVec(), fTrd1DConfig->GetOptOutBVec()));
544 }
545 break;
546 }
547 case Subsystem::TRD2D: {
548 if (fTrd2DConfig) {
549 fCbmTsEventHeader->AddNDigisTrd2D(unpack(subsystem, &timeslice, component, fTrd2DConfig,
550 fTrd2DConfig->GetOptOutAVec(), fTrd2DConfig->GetOptOutBVec()));
551 }
552 break;
553 }
554 case Subsystem::BMON: {
555 if (fBmonConfig) {
556 fCbmTsEventHeader->AddNDigisBmon(unpack(subsystem, &timeslice, component, fBmonConfig,
557 fBmonConfig->GetOptOutAVec(), fBmonConfig->GetOptOutBVec()));
558 }
559 break;
560 }
561 default: {
562 if (fDoDebugPrints)
563 LOG(error) << "Unpack: Unknown subsystem " << fles::to_string(subsystem) << " for component " << component;
564 break;
565 }
566 }
567 }
568
571 if (fMuchConfig && fMuchConfig->GetOutputVec()) {
572 timesort(fMuchConfig->GetOutputVec());
573 }
574 if (fPsdConfig && fPsdConfig->GetOutputVec()) {
575 timesort(fPsdConfig->GetOutputVec());
576 }
577 if (fRichConfig && fRichConfig->GetOutputVec()) {
578 timesort(fRichConfig->GetOutputVec());
579 }
580 if (fStsConfig && fStsConfig->GetOutputVec()) {
581 timesort(fStsConfig->GetOutputVec());
582 }
583 if (fTofConfig && fTofConfig->GetOutputVec()) {
584 timesort(fTofConfig->GetOutputVec());
585 }
586 if (fTrd1DConfig && fTrd1DConfig->GetOutputVec()) {
587 timesort(fTrd1DConfig->GetOutputVec());
588 }
589 if (fTrd2DConfig && fTrd2DConfig->GetOutputVec()) {
590 timesort(fTrd2DConfig->GetOutputVec());
591 }
592 if (fBmonConfig && fBmonConfig->GetOutputVec()) {
593 timesort(fBmonConfig->GetOutputVec());
594 }
595
597 if (fMuchConfig && fMuchConfig->GetOptOutAVec()) {
598 timesort(fMuchConfig->GetOptOutAVec());
599 }
600 if (fPsdConfig && fPsdConfig->GetOptOutAVec()) {
601 timesort(fPsdConfig->GetOptOutAVec());
602 }
603 if (fRichConfig && fRichConfig->GetOptOutAVec()) {
604 timesort(fRichConfig->GetOptOutAVec());
605 }
606 if (fStsConfig && fStsConfig->GetOptOutAVec()) {
607 timesort(fStsConfig->GetOptOutAVec());
608 }
609 if (fTofConfig && fTofConfig->GetOptOutAVec()) {
610 timesort(fTofConfig->GetOptOutAVec());
611 }
612 if (fTrd1DConfig && fTrd1DConfig->GetOptOutAVec()) {
613 timesort(fTrd1DConfig->GetOptOutAVec());
614 }
615 if (fTrd2DConfig && fTrd2DConfig->GetOptOutAVec()) {
616 timesort(fTrd2DConfig->GetOptOutAVec());
617 }
618 if (fBmonConfig && fBmonConfig->GetOptOutAVec()) {
619 timesort(fBmonConfig->GetOptOutAVec());
620 }
621 }
622
623 if (fBmonConfig && fBmonConfig->GetMonitor()) { //
624 fBmonConfig->GetMonitor()->FinalizeTsBmonMicroSpillHistos();
625 }
626
627 if (fDoPerfProfPerTs) {
628 fTimerTs->Stop();
630 }
631}
632// ----------------------------------------------------------------------------
633
634
ClassImp(CbmConverterManager)
Main steering class for unpacking in cbmroot.
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.
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.
std::string fUriPublishProfMoni
URI (type:hostname:port:db_name) for optional connection to monitoring DB.
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.
std::string fMoniJobId
std::string fMoniCurrrentHostname
The application's monitoring object.
std::map< Subsystem, std::pair< double, double > > fDataSizeMap
Map to store the in and out data amount, key = Subsystem.
TH1 * fhRealTimePerTsHist
Plotting time per TS.
TH1 * fhCpuTimePerTsHist
Processing time per TS.
std::map< Subsystem, std::pair< double, double > > fDataSizeMapCurrSec
void Reset()
Clear the output vectors as preparation of the next timeslice. Called via FairSource::Reset()
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.
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::map< Subsystem, TH1 * > fvhOutRatioPerTs
ratio of system data in total input size vs TS in run
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).
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.
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.
bool fDoDebugPrints
Flag if extended debug output is to be printed or not.
std::map< Subsystem, std::pair< double, double > > fTimeMapPerTs
Map to store the cpu and wall time for a single TS, key = Subsystem.
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
std::shared_ptr< CbmMuchUnpackConfig > fMuchConfig
Current time slice.
std::shared_ptr< CbmTrdUnpackConfig > fTrd1DConfig
Configuration of the Trd unpacker. Provides the configured algorithm.
bool fDoPerfProfPerTs
Flag if performance profiling per TS should be activated or not.
void performanceProfilingPerTs()
Run the performance profiling for a single TS based on the fTimeMapPerTs and fDataSizeMapPerTs member...
TStopwatch * fTimerTs
std::chrono::system_clock::time_point fMonitorSecCurrentTs
std::shared_ptr< CbmRichUnpackConfig > fRichConfig
Configuration of the Rich unpacker. Provides the configured algorithm.
void RegisterOutputs(FairRootManager *ioman, std::shared_ptr< TConfig > config)
Bool_t Init()
Initialisation.
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.
size_t unpack(const Subsystem subsystem, const fles::Timeslice *ts, std::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::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()
bool fDoPerfProf
Flag if performance profiling should be activated or not.
Bookkeeping of time-slice content.
void SetStartTime(double time)
Set start time.
void Reset()
Reset the time slice.
void AddNDigisTof(uint64_t value)
Add a number of digis from this Ts.
void AddNDigisMuch(uint64_t value)
Add a number of digis from this Ts.
uint64_t GetTsStartTime() const
void AddNDigisTrd1D(uint64_t value)
Add a number of digis from this Ts.
void AddNDigisBmon(uint64_t value)
Add a number of digis from this Ts.
void AddNDigisPsd(uint64_t value)
Add a number of digis from this Ts.
void AddNDigisSts(uint64_t value)
Add a number of digis from this Ts.
void Reset()
Resets counters and variables for a new Timeslice, e.g. the NDigis counter are set back to 0.
void AddNDigisRich(uint64_t value)
Add a number of digis from this Ts.
void SetTsStartTime(uint64_t value)
Set the Ts Start Time.
uint64_t GetTsIndex() const
void AddNDigisTrd2D(uint64_t value)
Add a number of digis from this Ts.
void SetTsIndex(uint64_t value)
Set the Ts Start Time.
std::chrono::time_point< std::chrono::system_clock > sctp