CbmRoot
Loading...
Searching...
No Matches
DigiData.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
4#include "DigiData.h"
5
6using namespace cbm::algo;
7
8// Ctor / Dtor defined in .cxx file so we can use forward declarations for digi types in the header
9
11
13
15 : fSts(ToPODVector(storable.fSts.fDigis))
16 , fMuch(ToPODVector(storable.fMuch.fDigis))
17 , fTof(ToPODVector(storable.fTof.fDigis))
18 , fBmon(ToPODVector(storable.fBmon.fDigis))
19 , fTrd(ToPODVector(storable.fTrd.fDigis))
20 , fTrd2d(ToPODVector(storable.fTrd2d.fDigis))
21 , fRich(ToPODVector(storable.fRich.fDigis))
22 , fPsd(ToPODVector(storable.fPsd.fDigis))
23 , fFsd(ToPODVector(storable.fFsd.fDigis))
24{
25}
26
27size_t DigiData::Size(ECbmModuleId system) const
28{
29 switch (system) {
30 case ECbmModuleId::kSts: return fSts.size();
31 case ECbmModuleId::kMuch: return fMuch.size();
32 case ECbmModuleId::kTof: return fTof.size();
33 case ECbmModuleId::kBmon: return fBmon.size();
34 case ECbmModuleId::kTrd: return fTrd.size();
35 case ECbmModuleId::kTrd2d: return fTrd2d.size();
36 case ECbmModuleId::kRich: return fRich.size();
37 case ECbmModuleId::kPsd: return fPsd.size();
38 case ECbmModuleId::kFsd: return fFsd.size();
39 default: throw std::runtime_error("DigiData: Invalid system Id " + ::ToString(system));
40 }
41}
42
43size_t DigiData::TotalSize() const
44{
45 return fSts.size() + fMuch.size() + fTof.size() + fBmon.size() + fTrd.size() + fTrd2d.size() + fRich.size()
46 + fPsd.size() + fFsd.size();
47}
48
50{
51 return sizeof(CbmStsDigi) * fSts.size() + sizeof(CbmMuchDigi) * fMuch.size() + sizeof(CbmTofDigi) * fTof.size()
52 + sizeof(CbmBmonDigi) * fBmon.size() + sizeof(CbmTrdDigi) * fTrd.size() + sizeof(CbmTrdDigi) * fTrd2d.size()
53 + sizeof(CbmRichDigi) * fRich.size() + sizeof(CbmPsdDigi) * fPsd.size() + sizeof(CbmFsdDigi) * fFsd.size();
54}
55
57{
58 return CbmDigiData{
59 .fBmon =
60 {
61 .fDigis = ToStdVector(fBmon),
62 },
63 .fSts =
64 {
65 .fDigis = ToStdVector(fSts),
66 },
67 .fMuch =
68 {
69 .fDigis = ToStdVector(fMuch),
70 },
71 .fRich =
72 {
73 .fDigis = ToStdVector(fRich),
74 },
75 .fTrd =
76 {
77 .fDigis = ToStdVector(fTrd),
78 },
79 .fTrd2d =
80 {
81 .fDigis = ToStdVector(fTrd2d),
82 },
83 .fTof =
84 {
85 .fDigis = ToStdVector(fTof),
86 },
87 .fPsd =
88 {
89 .fDigis = ToStdVector(fPsd),
90 },
91 .fFsd =
92 {
93 .fDigis = ToStdVector(fFsd),
94 },
95 };
96}
97
98std::vector<DigiEvent> DigiEvent::FromCbmDigiEvents(const std::vector<CbmDigiEvent>& events)
99{
100 std::vector<DigiEvent> result;
101 result.reserve(events.size());
102 for (const auto& event : events) {
103 result.emplace_back(event);
104 }
105 return result;
106}
107
108std::vector<CbmDigiEvent> DigiEvent::ToCbmDigiEvents(const std::vector<DigiEvent>& events)
109{
110 std::vector<CbmDigiEvent> result;
111 result.reserve(events.size());
112 for (const auto& event : events) {
113 result.emplace_back(event.ToStorable());
114 }
115 return result;
116}
117
119 : DigiData(storable.fData)
120 , fNumber(storable.fNumber)
121 , fTime(storable.fTime)
122{
123}
124
126{
127 return CbmDigiEvent{
128 .fData = DigiData::ToStorable(),
129 .fNumber = fNumber,
130 .fTime = fTime,
131 };
132}
ECbmModuleId
Definition CbmDefs.h:39
@ kTrd
Transition Radiation Detector.
@ kTof
Time-of-flight Detector.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kTrd2d
TRD-FASP Detector (FIXME)
@ kMuch
Muon detection system.
@ kFsd
Forward spectator detector.
@ kRich
Ring-Imaging Cherenkov Detector.
Data class for a signal in the t-zero detector.
Definition CbmBmonDigi.h:30
Collection of digis from all detector systems.
Definition CbmDigiData.h:32
Collection of digis from all detector systems within one event.
Data class for FSD digital information.
Definition CbmFsdDigi.h:36
Data class for PSD digital information.
Definition CbmPsdDigi.h:36
Data class for a single-channel message in the STS.
Definition CbmStsDigi.h:40
Data class for expanded digital TOF information.
Definition CbmTofDigi.h:47
std::vector< T > ToStdVector(const PODVector< T > &vec)
Definition PODVector.h:20
PODVector< T > ToPODVector(const std::vector< T > &vec)
Definition PODVector.h:26
Collection of digis from all detector systems.
Definition DigiData.h:31
PODVector< CbmRichDigi > fRich
Unpacked RICH digis.
Definition DigiData.h:38
PODVector< CbmTrdDigi > fTrd
Unpacked TRD digis.
Definition DigiData.h:36
PODVector< CbmStsDigi > fSts
Unpacked STS digis.
Definition DigiData.h:32
PODVector< CbmTrdDigi > fTrd2d
Unpacked TRD2D digis.
Definition DigiData.h:37
PODVector< CbmFsdDigi > fFsd
Unpacked FSD digis.
Definition DigiData.h:40
PODVector< CbmTofDigi > fTof
Unpacked TOF digis.
Definition DigiData.h:34
size_t TotalSize() const
Get the total number of digis across all subsystems.
Definition DigiData.cxx:43
CbmDigiData ToStorable() const
Convert to CbmDigiData for file storage.
Definition DigiData.cxx:56
PODVector< CbmPsdDigi > fPsd
Unpacked PSD digis.
Definition DigiData.h:39
PODVector< CbmMuchDigi > fMuch
Unpacked MUCH digis.
Definition DigiData.h:33
PODVector< CbmBmonDigi > fBmon
Unpacked Bmon digis.
Definition DigiData.h:35
size_t Size(ECbmModuleId system) const
Get the number of digis for a given subsystem.
Definition DigiData.cxx:27
size_t TotalSizeBytes() const
Get the total number of bytes used by all digis.
Definition DigiData.cxx:49
double fTime
Event trigger time [ns].
Definition DigiData.h:82
static std::vector< CbmDigiEvent > ToCbmDigiEvents(const std::vector< DigiEvent > &events)
Definition DigiData.cxx:108
static std::vector< DigiEvent > FromCbmDigiEvents(const std::vector< CbmDigiEvent > &events)
Definition DigiData.cxx:98
uint64_t fNumber
Event identifier.
Definition DigiData.h:81
CbmDigiEvent ToStorable() const
Convert to CbmDigiEvent for file storage.
Definition DigiData.cxx:125