CbmRoot
Loading...
Searching...
No Matches
CbmTaskUnpack.h
Go to the documentation of this file.
1/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
5
6#ifndef CBMTASKUNPACK_H
7#define CBMTASKUNPACK_H 1
8
9#include "CbmDefs.h"
10#include "CbmDigiTimeslice.h"
11
12// Hide the Monitor class from ROOT to not confuse it
13#if !defined(__CLING__) && !defined(__ROOTCLING__)
14#include "Monitor.hpp"
15#else
16namespace cbm
17{
18 class Monitor;
19}
20#endif
21
22#include "AlgoTraits.h"
23#include "EventBuilder.h"
24#include "ParFiles.h"
25#include "bmon/Unpack.h"
26#include "much/Unpack.h"
27#include "rich/Unpack.h"
28#include "sts/Unpack.h"
29#include "tof/Unpack.h"
30#include "trd/Unpack.h"
31#include "trd2d/Unpack.h"
32
33#include <FairTask.h>
34
35#include <boost/filesystem.hpp>
36
37#include <sstream>
38#include <vector>
39
40class CbmDigiManager;
41class CbmSourceTs;
42class CbmTimeSlice;
44class FairRootManager;
45
46namespace fs = boost::filesystem;
47
59class CbmTaskUnpack : public FairTask {
60
61 public:
62 struct Config {
63 bool dumpSetup = false;
64 };
65
66 struct Monitor {
67 size_t numCompUsed = 0;
68 size_t numMs = 0;
69 size_t numBytes = 0;
70 size_t numDigis = 0;
71 };
72
75
76
78 CbmTaskUnpack(fs::path paramsDir, uint32_t runId);
79
80
82 CbmTaskUnpack(const CbmTaskUnpack&) = delete;
83
84
86 virtual ~CbmTaskUnpack();
87
88
90 virtual void Exec(Option_t* opt);
91
92
94 virtual void Finish();
95
96
99
100
102 void SetMonitor(cbm::Monitor* monitor) { fMonitor = monitor; }
103
104
106 void SetOutputModeCbmrootLike(bool flag = true) { fCbmrootFormatOutput = flag; }
107
108
109 private: // methods
111 virtual InitStatus Init();
112
113 private: // members
115 cbm::Monitor* fMonitor = nullptr;
116 std::string fHostname;
117
118 /* Unpacker algorithms */
119 std::unique_ptr<cbm::algo::bmon::Unpack> fBmonUnpack;
120 std::unique_ptr<cbm::algo::much::Unpack> fMuchUnpack;
121 std::unique_ptr<cbm::algo::rich::Unpack> fRichUnpack;
122 std::unique_ptr<cbm::algo::sts::Unpack> fStsUnpack;
123 std::unique_ptr<cbm::algo::tof::Unpack> fTofUnpack;
124 std::unique_ptr<cbm::algo::trd::Unpack> fTrdUnpack;
125 std::unique_ptr<cbm::algo::trd2d::Unpack> fTrd2dUnpack;
126
127 size_t fNumTs = 0;
128 size_t fNumMs = 0;
129 size_t fNumBytes = 0;
130 size_t fNumDigis = 0;
131 double fTime = 0.;
133
142 std::vector<CbmBmonDigi>* fBmonDigis = nullptr;
143 std::vector<CbmStsDigi>* fStsDigis = nullptr;
144 std::vector<CbmMuchDigi>* fMuchDigis = nullptr;
145 std::vector<CbmTrdDigi>* fTrdDigis = nullptr;
146 std::vector<CbmTofDigi>* fTofDigis = nullptr;
147 std::vector<CbmRichDigi>* fRichDigis = nullptr;
148
149 template<class Unpacker>
150 auto RunUnpacker(const std::unique_ptr<Unpacker>& unpacker, const fles::Timeslice& ts, Monitor& monitor)
152
153 template<typename TVecobj>
154 Bool_t RegisterVector(FairRootManager* ioman, std::vector<TVecobj>*& vec);
155
156 template<typename TVecobj>
157 typename std::enable_if<std::is_member_function_pointer<decltype(&TVecobj::GetTime)>::value, void>::type
158 Timesort(std::vector<TVecobj>* vec = nullptr)
159 {
160 if (vec == nullptr) return;
161 std::sort(vec->begin(), vec->end(),
162 [](const TVecobj& a, const TVecobj& b) -> bool { return a.GetTime() < b.GetTime(); });
163 }
164
166};
167
168#endif /* CBMTASKUNPACK_H */
Type traits for online algorithms.
This file contains the definition of the ParFiles class.
CbmDigiManager.
Collection of digis from all detector systems within one timeslice.
Source class for reading from archived time slice data.
Definition CbmSourceTs.h:26
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::string fHostname
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...
ClassDef(CbmTaskUnpack, 4)
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.
cbm::Monitor * fMonitor
std::unique_ptr< cbm::algo::rich::Unpack > fRichUnpack
virtual void Finish()
Finish timeslice.
void SetOutputModeCbmrootLike(bool flag=true)
Set the output file in "as if cbmroot digi file" mode (default is "as if rra")
std::vector< CbmRichDigi > * fRichDigis
CbmSourceTs * fSource
std::unique_ptr< cbm::algo::bmon::Unpack > fBmonUnpack
std::unique_ptr< cbm::algo::tof::Unpack > fTofUnpack
std::vector< CbmTrdDigi > * fTrdDigis
void SetMonitor(cbm::Monitor *monitor)
Set the monitor object.
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)
CbmTaskUnpack & operator=(const CbmTaskUnpack &)=delete
Assignment operator (disabled)
CbmDigiTimeslice * fDigiTimeslice
Output data if writing root files "as if rra".
std::unique_ptr< cbm::algo::much::Unpack > fMuchUnpack
CbmTaskUnpack(const CbmTaskUnpack &)=delete
Copy constructor (disabled)
Bookkeeping of time-slice content.
typename std::tuple_element< 0, ResultOf_t< Algo > >::type Output_t
Type alias for the output type produced by an algorithm.
Definition AlgoTraits.h:53