CbmRoot
Loading...
Searching...
No Matches
tof/RecoSetupUnit.h
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#ifndef ALGO_TOF_RecoSetupUnit_h
11#define ALGO_TOF_RecoSetupUnit_h 1
12
13#include "CbmDefs.h"
14#include "CbmTofAddress.h"
16
17#include <boost/serialization/access.hpp>
18#include <boost/serialization/export.hpp>
19
20#include <utility>
21#include <vector>
22
23namespace cbm::algo::tof
24{
25 // TODO: probably can be re-used for defining the tof-related info TOF hit-finder (then, int -> tof::Module)
29 public:
32 struct SmTypeInfo {
33 uint32_t offset{0};
34 uint16_t nSm{0};
35 uint16_t nRpc{0};
36
37 private:
38 friend boost::serialization::access;
39 template<class Archive>
40 void serialize(Archive& ar, const unsigned int /*version*/)
41 {
42 ar& offset;
43 ar& nSm;
44 ar& nRpc;
45 }
46 };
47
49 TrkStationIdMap() = default;
50
54 TrkStationIdMap(std::vector<SmTypeInfo>&& smTypeRpcMap, std::vector<int>&& trkStationIdMap);
55
57 void Clear()
58 {
59 fSmTypeRpcMap.clear();
60 fTrkStationIdMap.clear();
61 }
62
64 bool IsEmpty() const { return fSmTypeRpcMap.empty() && fTrkStationIdMap.empty(); }
65
67 uint16_t GetNofSmTypes() const { return fSmTypeRpcMap.size(); }
68
71 uint16_t GetNofRpc(uint16_t iSmType) const { return fSmTypeRpcMap[iSmType].nRpc; }
72
75 uint16_t GetNofSm(uint16_t iSmType) const { return fSmTypeRpcMap[iSmType].nSm; }
76
78 const auto& GetSmTypeRpcMap() const { return fSmTypeRpcMap; }
79
81 const auto& GetTrkStationIdMap() const { return fTrkStationIdMap; }
82
87 int GetTrackingStationIndex(uint16_t iSmType, uint16_t iSm, uint16_t iRpc) const
88 {
89 if (iSmType < GetNofSmTypes() && iSm < GetNofSm(iSmType) && iRpc < GetNofRpc(iSmType)) {
90 const auto& smt = fSmTypeRpcMap[iSmType];
91 return fTrkStationIdMap[smt.offset + iSm * smt.nRpc + iRpc];
92 }
93 return -1;
94 }
95
96 private:
97 std::vector<SmTypeInfo> fSmTypeRpcMap{};
98 std::vector<int> fTrkStationIdMap{};
99
100 friend boost::serialization::access;
101 template<class Archive>
102 void serialize(Archive& ar, const unsigned int /*version*/)
103 {
104 ar& fSmTypeRpcMap;
106 }
107 };
108
111 class RecoSetupUnit : public TrackingSetupIfs<RecoSetupUnit> {
112 friend class TrackingSetupIfs<RecoSetupUnit>;
113
114 public:
116 RecoSetupUnit() = default;
117
121 RecoSetupUnit(std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>>&& stationVolumes,
122 TrkStationIdMap&& trkStationIdMap);
123
125 static constexpr std::string_view GetDetectorName() { return "TOF"; }
126
128 static constexpr ECbmModuleId GetModuleId() { return ECbmModuleId::kTof; }
129
132
133 private:
137 int ImplGetTrackingStationId(uint32_t address) const;
138
141 bool ImplIsTimeInfoProvided(int /*stationId*/) const { return true; }
142
146 bool IsInitialized() const;
147
150 template<class Archive>
151 void serialize(Archive& ar, const unsigned int /*version*/)
152 {
153 ar& boost::serialization::base_object<TrackingSetupIfs<RecoSetupUnit>>(*this);
155 }
156
158 };
159
160 //* Inline methods
161 inline int RecoSetupUnit::ImplGetTrackingStationId(uint32_t address) const
162 {
163 int iSmType = CbmTofAddress::GetSmType(address);
164 int iSm = CbmTofAddress::GetSmId(address);
165 int iRpc = CbmTofAddress::GetRpcId(address);
166 return fTrkStationIdMap.GetTrackingStationIndex(iSmType, iSm, iRpc);
167 }
168
169
170} // namespace cbm::algo::tof
171
172
173#endif // ALGO_STS_RecoSetupUnit_h
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kTof
Time-of-flight Detector.
Definition CbmDefs.h:52
Base class for the detector interface for reconstruction algorithms.
static int32_t GetSmId(uint32_t address)
static int32_t GetRpcId(uint32_t address)
static int32_t GetSmType(uint32_t address)
static constexpr std::string_view GetDetectorName()
Name of the detector.
static constexpr ECbmModuleId GetModuleId()
Module ID.
void serialize(Archive &ar, const unsigned int)
const TrkStationIdMap & GetTrkStationIdMap() const
A constant accessor to the TrkStationIdMap.
bool IsInitialized() const
Validates initialization of the instance.
int ImplGetTrackingStationId(uint32_t address) const
Returns tracking station index by the TOF address.
RecoSetupUnit()=default
Default constructor (note: needed for serialization)
bool ImplIsTimeInfoProvided(int) const
Returns a flag, if time information is provided by the detector.
friend class boost::serialization::access
Serialization rule.
TrkStationIdMap fTrkStationIdMap
A map of tracking station indexing.
A mapper for TOF tracking stations.
void serialize(Archive &ar, const unsigned int)
const auto & GetTrkStationIdMap() const
A constant accessor to the tracking station ID container.
uint16_t GetNofSm(uint16_t iSmType) const
Gets number of SMs for a given SM type.
uint16_t GetNofSmTypes() const
Gets number of supermodule types.
void Clear()
Clears the contents.
int GetTrackingStationIndex(uint16_t iSmType, uint16_t iSm, uint16_t iRpc) const
Gets tracking station index for a given SM type, SM and RPC.
std::vector< SmTypeInfo > fSmTypeRpcMap
Information on the RPC indexing within differnt SM types.
std::vector< int > fTrkStationIdMap
Index of tracking station vs. RPC.
bool IsEmpty() const
Checks, if the container is empty.
const auto & GetSmTypeRpcMap() const
A constant accessor to the SmType RPC map.
TrkStationIdMap()=default
Default constructor (for serialization)
uint16_t GetNofRpc(uint16_t iSmType) const
Gets number of RPCs for a given SM type.
Information on RPC offsets for each SM type.
uint16_t nRpc
Number of RPCs for a given SM type.
uint32_t offset
An index of first RPC for a given SM type.
uint16_t nSm
Number of supermodules for a given SM type.
void serialize(Archive &ar, const unsigned int)