23#include "MicrosliceDescriptor.hpp"
31#include <FairParAsciiFileIo.h>
32#include <FairParamList.h>
33#include <FairRunOnline.h>
36#include <TStopwatch.h>
53 L_(fatal) <<
"Instantiated CbmTaskUnpack() without arguments (needs path to parameters and run ID).";
59 std::string mainConfigPath = (paramsDir /
"MainConfig.yaml").string();
60 auto mainConfigNode = YAML::LoadFile(mainConfigPath);
61 auto parFiles = yaml::Read<ReadoutParFiles>(mainConfigNode[
"parFiles"][
"readout"]);
63 if (!parFiles.sts.has_value()) {
64 LOG(fatal) << fName <<
": no readout parameters for STS found, please provide the parameters in " << mainConfigPath;
67 if (!parFiles.tof.has_value()) {
68 LOG(fatal) << fName <<
": no readout parameters for TOF found, please provide the parameters in " << mainConfigPath;
71 if (!parFiles.trd.has_value()) {
72 LOG(fatal) << fName <<
": no readout parameters for TRD found, please provide the parameters in " << mainConfigPath;
75 if (!parFiles.trd2d.has_value()) {
76 LOG(fatal) << fName <<
": no readout parameters for TRD2D found, please provide the parameters in "
80 if (!parFiles.bmon.has_value()) {
81 LOG(fatal) << fName <<
": no readout parameters for BMON found, please provide the parameters in "
85 sts::ReadoutSetup stsSetup = yaml::ReadFromFile<sts::ReadoutSetup>(paramsDir / parFiles.sts->readout);
86 auto chanMask = yaml::ReadFromFile<sts::ChannelMaskSet>(paramsDir / parFiles.sts->channelMask);
87 auto walkMap = yaml::ReadFromFile<sts::WalkMap>(paramsDir / parFiles.sts->walkMap);
89 sts::Unpack::Config stsCfg{.readout = readout, .walkMap = walkMap, .bCollectAuxData =
false};
90 fStsUnpack = std::make_unique<sts::Unpack>(stsCfg);
92 tof::ReadoutSetup tofSetup = yaml::ReadFromFile<tof::ReadoutSetup>(paramsDir / parFiles.tof->readout);
94 fTofUnpack = std::make_unique<tof::Unpack>(tofCfg);
96 bmon::ReadoutSetup bmonSetup = yaml::ReadFromFile<bmon::ReadoutSetup>(paramsDir / parFiles.bmon->readout);
98 fBmonUnpack = std::make_unique<bmon::Unpack>(bmonCfg);
100 auto trdCfg = yaml::ReadFromFile<trd::ReadoutConfig>(paramsDir / parFiles.trd->readout);
101 fTrdUnpack = std::make_unique<trd::Unpack>(trdCfg);
103 trd2d::ReadoutSetup setup = yaml::ReadFromFile<trd2d::ReadoutSetup>(paramsDir / parFiles.trd2d->readout);
104 trd2d::ReadoutCalib calib = yaml::ReadFromFile<trd2d::ReadoutCalib>(paramsDir / parFiles.trd2d->fee);
106 fTrd2dUnpack = std::make_unique<trd2d::Unpack>(trd2dCfg);
109 fMuchUnpack = std::make_unique<much::Unpack>(muchCfg);
112 fRichUnpack = std::make_unique<rich::Unpack>(richCfg);
140 fles::Timeslice* timeslice =
fSource->GetTimeslice();
171 fTimeslice->SetStartTime(timeslice->start_time());
199 logOut << setw(15) << left << GetName() <<
" [";
200 logOut << fixed << setw(8) << setprecision(1) << right << timer.RealTime() * 1000. <<
" ms] ";
201 logOut <<
"TS " <<
fNumTs <<
" (index " << timeslice->index() <<
")";
202 logOut <<
", components " << monitor.
numCompUsed <<
" / " << timeslice->num_components();
203 logOut <<
", microslices " << monitor.
numMs;
204 logOut <<
", input rate " << double(monitor.
numBytes) / timer.RealTime() / 1.e6 <<
" MB/s";
205 logOut <<
", digis " << monitor.
numDigis;
206 LOG(info) << logOut.str();
208#if !defined(__CLING__) && !defined(__ROOTCLING__)
211 {{
"realtime", timer.RealTime()},
212 {
"cputime", timer.CpuTime()},
214 {
"input_rate", double(monitor.
numBytes) / timer.RealTime()},
224 fTime += timer.RealTime();
234 LOG(info) <<
"=====================================";
235 LOG(info) << GetName() <<
": Run summary";
236 LOG(info) <<
"Timeslices : " <<
fNumTs;
237 LOG(info) <<
"Microslices : " <<
fNumMs;
239 LOG(info) <<
"Av. input rate : " << fixed << setprecision(2) << rate <<
" MB/s";
240 LOG(info) <<
"Time / TS : " << fixed << setprecision(2) << timePerTs <<
" ms";
241 LOG(info) <<
"=====================================";
247template<
typename TVecobj>
250 if (ioman->GetObject(TVecobj::GetBranchName())) {
251 LOG(fatal) << GetName() <<
": Branch " << TVecobj::GetBranchName() <<
" already exists!";
255 ioman->RegisterAny(TVecobj::GetBranchName(), vec, kTRUE);
256 LOG(info) << GetName() <<
": Registered branch " << TVecobj::GetBranchName() <<
" at " << vec;
263 LOG(info) <<
"==================================================";
264 LOG(info) << GetName() <<
": Initialising...";
267 fHostname = fles::system::current_hostname();
272 LOG(error) << GetName() <<
": No valid source class registered!";
275 LOG(info) <<
"--- Found CbmSourceTs instance";
278 FairRootManager* ioman = FairRootManager::Instance();
282 if (ioman->GetObject(
"DigiTimeslice")) {
283 LOG(fatal) << GetName() <<
": Branch DigiTimeslice already exists!";
290 LOG(fatal) <<
"CbmSourceDigiTimeslice::Init() no CbmTsEventHeader was added to the run. "
291 "Without it, we can not store the UTC of the Timeslices correctly. "
292 "Hence, this causes a fatal. Please add it to the Run in the steering macro.";
297 if (ioman->GetObject(
"TimeSlice.")) {
298 LOG(fatal) <<
"Source: Branch TimeSlice. already exists!";
304 ioman->Register(
"TimeSlice.",
"DAQ",
fTimeslice, kTRUE);
313 fStsDigis =
new std::vector<CbmStsDigi>();
325 fTrdDigis =
new std::vector<CbmTrdDigi>();
331 fTofDigis =
new std::vector<CbmTofDigi>();
344 ioman->RegisterAny(
"DigiTimeslice.",
fDigiTimeslice, IsOutputBranchPersistent(
"DigiTimeslice."));
345 LOG(info) <<
"--- Registered branch DigiTimeslice.";
353template<
class Unpacker>
357 auto [digis, detmon, detaux] = (*unpacker)(timeslice);
358 monitor.numCompUsed += detmon.numComponents;
359 monitor.numMs += detmon.numMs;
360 monitor.numBytes += detmon.sizeBytesIn;
361 monitor.numDigis += digis.size();
ClassImp(CbmConverterManager)
This file contains the definition of the ParFiles class.
A structure to keep parameter files for reconstruction.
Collection of digis from all detector systems within one timeslice.
Source class for reading from archived time slice data.
Task class for associating digis to events.
Bool_t RegisterVector(FairRootManager *ioman, std::vector< TVecobj > *&vec)
virtual ~CbmTaskUnpack()
Destructor.
virtual void Exec(Option_t *opt)
Task execution.
CbmTaskUnpack()
Constructor.
bool fCbmrootFormatOutput
std::vector< CbmMuchDigi > * fMuchDigis
std::unique_ptr< cbm::algo::sts::Unpack > fStsUnpack
std::unique_ptr< cbm::algo::trd::Unpack > fTrdUnpack
std::unique_ptr< cbm::algo::trd2d::Unpack > fTrd2dUnpack
CbmTimeSlice * fTimeslice
=> Time-slice header (old version, class about to be deprecated? one should use only CbmTsEventHeader...
std::vector< CbmTofDigi > * fTofDigis
std::vector< CbmStsDigi > * fStsDigis
CbmTsEventHeader * fTsEventHeader
Time-slice event header.
std::vector< CbmBmonDigi > * fBmonDigis
=> Branch vectors of Digis
virtual InitStatus Init()
Task initialisation.
std::unique_ptr< cbm::algo::rich::Unpack > fRichUnpack
virtual void Finish()
Finish timeslice.
std::vector< CbmRichDigi > * fRichDigis
std::unique_ptr< cbm::algo::bmon::Unpack > fBmonUnpack
std::unique_ptr< cbm::algo::tof::Unpack > fTofUnpack
std::vector< CbmTrdDigi > * fTrdDigis
auto RunUnpacker(const std::unique_ptr< Unpacker > &unpacker, const fles::Timeslice &ts, Monitor &monitor) -> cbm::algo::algo_traits::Output_t< Unpacker >
std::enable_if< std::is_member_function_pointer< decltype(&TVecobj::GetTime)>::value, void >::type Timesort(std::vector< TVecobj > *vec=nullptr)
CbmDigiTimeslice * fDigiTimeslice
Output data if writing root files "as if rra".
std::unique_ptr< cbm::algo::much::Unpack > fMuchUnpack
Bookkeeping of time-slice content.
Provides the hardware-to-software address mapping for the CBM-RICH.
Provides the hardware-to-software address mapping for the CBM-STS.
typename std::tuple_element< 0, ResultOf_t< Algo > >::type Output_t
Type alias for the output type produced by an algorithm.
Collection of digis from all detector systems.
PODVector< CbmRichDigi > fRich
Unpacked RICH digis.
PODVector< CbmTrdDigi > fTrd
Unpacked TRD digis.
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
PODVector< CbmTrdDigi > fTrd2d
Unpacked TRD2D digis.
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
CbmDigiData ToStorable() const
Convert to CbmDigiData for file storage.
PODVector< CbmMuchDigi > fMuch
Unpacked MUCH digis.
PODVector< CbmBmonDigi > fBmon
Unpacked Bmon digis.
Readout setup / Hardware cabling for BMon Used to create the hardware mapping for the BMon unpacker.
Readout setup / Hardware cabling for STS Used to create the hardware mapping for the STS unpacker.
Readout setup / Hardware cabling for TOF Used to create the hardware mapping for the TOF unpacker.