CbmRoot
Loading...
Searching...
No Matches
trd/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_TRD_RecoSetupUnit_h
11#define ALGO_TRD_RecoSetupUnit_h 1
12
13#include "CbmDefs.h"
14#include "CbmTrdAddress.h"
16
17#include <boost/serialization/access.hpp>
18#include <boost/serialization/array.hpp>
19#include <boost/serialization/export.hpp>
20#include <boost/serialization/utility.hpp>
21
22#include <array>
23#include <utility>
24#include <vector>
25
26namespace cbm::algo::trd
27{
28 class RecoSetupUnit : public TrackingSetupIfs<RecoSetupUnit> {
29 friend class TrackingSetupIfs<RecoSetupUnit>;
30
31 public:
32 // TODO: move this structure in the HitfindSetupIfs
35 struct ModuleInfo {
36 int32_t orientation;
37 int32_t type;
38
40 ModuleInfo() = default;
41
45 ModuleInfo(int32_t orientation_, int32_t type_) : orientation(orientation_), type(type_) {}
46
47 private:
50 template<typename Archive>
51 void serialize(Archive& ar, const unsigned int /*version*/)
52 {
53 ar& orientation;
54 ar& type;
55 }
56 };
57
62 using ModuleInfoMap_t = std::pair<std::vector<ModuleInfo>, uint32_t>;
63
65 RecoSetupUnit() = default;
66
70 RecoSetupUnit(std::pair<std::vector<GeoVolume>, std::vector<GeoVolume>>&& stationVolumes,
71 ModuleInfoMap_t&& moduleTypeMap);
72
74 static constexpr std::string_view GetDetectorName() { return "TRD"; }
75
77 static constexpr ECbmModuleId GetModuleId() { return ECbmModuleId::kTrd; }
78
79 private:
83 ModuleInfo GetModuleInfo(uint32_t address) const;
84
88 template<class HitType>
89 HitRange ImplGetHitRange(const HitType& hit) const;
90
94 int ImplGetTrackingStationId(uint32_t address) const;
95
98 bool ImplIsTimeInfoProvided(int /*stationId*/) const { return true; }
99
103 bool IsInitialized() const;
104
106 template<class Archive>
108 void serialize(Archive& ar, const unsigned int /*version*/)
109 {
110 ar& boost::serialization::base_object<TrackingSetupIfs<RecoSetupUnit>>(*this);
111 ar& fvModuleInfoMap;
112 }
113
115 };
116
117 //* Inline method implementations
118
119 // -------------------------------------------------------------------------------------------------------------------
120 //
122 {
123 // NOTE: an assumption, that the layer is the tracking station for TRD!
124 auto iLayer = CbmTrdAddress::GetLayerId(address);
125 auto iModule = CbmTrdAddress::GetModuleId(address);
126 return fvModuleInfoMap.first[fvModuleInfoMap.second * iLayer + iModule];
127 }
128
129 // -------------------------------------------------------------------------------------------------------------------
130 //
131 template<class HitType>
133 {
134 HitRange res = TrackingSetupIfs<RecoSetupUnit>::ImplGetHitRange(hit); // default hit ranges
135 const auto moduleInfo = GetModuleInfo(hit.GetAddress());
136 // NOTE: for now take the information on the TRD Pad type from the hit, but it should be retrieved from the
137 // moduleInfo as soon, as the digitization parameters of TRD are brought to the next version.
138 if (hit.GetClassType() == 0) {
139 if (!hit.IsRowCross()) {
140 if (1 == moduleInfo.orientation || 3 == moduleInfo.orientation) {
141 res.y = sqrt(3.) * hit.GetDy();
142 }
143 else {
144 res.x = sqrt(3.) * hit.GetDx();
145 }
146 }
147 }
148 else {
149 // NOTE/FIXME/TODO: the values below come from the legacy tracking interface class. They should be improved
150 if (0 == moduleInfo.orientation || 2 == moduleInfo.orientation) {
151 res.x = 1.7;
152 res.y = 3.5;
153 res.t = 200.;
154 }
155 else {
156 res.x = 3.5;
157 res.y = 1.7;
158 res.t = 200.;
159 }
160 }
161 return res;
162 }
163
164 // -------------------------------------------------------------------------------------------------------------------
165 //
166 inline int RecoSetupUnit::ImplGetTrackingStationId(uint32_t address) const
167 {
168 return CbmTrdAddress::GetLayerId(address);
169 }
170} // namespace cbm::algo::trd
171
172
173#endif // ALGO_STS_RecoSetupUnit_h
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kTrd
Transition Radiation Detector.
Definition CbmDefs.h:51
HitType
Definition CbmHit.h:25
Helper class to convert unique channel ID back and forth.
friend fvec sqrt(const fvec &a)
Base class for the detector interface for reconstruction algorithms.
static uint32_t GetModuleId(uint32_t address)
Return module ID from address.
static uint32_t GetLayerId(uint32_t address)
Return layer ID from address.
HitRange ImplGetHitRange(const HitType &hit) const
Returns default hit range factor.
static constexpr ECbmModuleId GetModuleId()
Module ID.
std::pair< std::vector< ModuleInfo >, uint32_t > ModuleInfoMap_t
A map of TRD module info vs.
ModuleInfo GetModuleInfo(uint32_t address) const
Returns a TRD module type by its address.
void serialize(Archive &ar, const unsigned int)
Serialization rule.
HitRange ImplGetHitRange(const HitType &hit) const
Returns default hit range.
static constexpr std::string_view GetDetectorName()
Name of the detector.
bool ImplIsTimeInfoProvided(int) const
Returns a flag, if time information is provided by the detector.
RecoSetupUnit()=default
Default constructor (note: needed for serialization)
ModuleInfoMap_t fvModuleInfoMap
map of TRD module types vs [layerId x moduleId]
bool IsInitialized() const
Validates initialization of the concrete class.
int ImplGetTrackingStationId(uint32_t address) const
Returns tracking station index by the TRD address.
friend class boost::serialization::access
A structure to keep the ranges of the hit x, y and time measurements.
double t
range for a time measurement [ns]
double y
range for an y-measurement [cm]
double x
range for an x-measurement [cm]
Different characteristics of TRD module.
ModuleInfo(int32_t orientation_, int32_t type_)
Constructor from parameters.
void serialize(Archive &ar, const unsigned int)
int32_t type
-1: undefined, 0: Trd1D, 1: Trd2D
ModuleInfo()=default
Default constructor.
friend class boost::serialization::access
Serialization rule.
int32_t orientation
0, 2: uniform y-coordinate, 1, 3: uniform x-coordinate (for TRD1D)