BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnRun8DM.h
Go to the documentation of this file.
1/*
2 BM@N alignment routine
3 BM@N experiment at NICA complex, JINR, 2025
4
5 Department: Math & Soft Group of HEP lab
6 Author: Igor Polev, polev@jinr.int
7
8 BmnRun8DM class declaration
9 Run8 representation of detector elements via encoding
10*/
11
12#ifndef BMNRUN8DM_H
13#define BMNRUN8DM_H
14
15#include "BmnDetectorList.h"
16#include "BmnDetectorModel.h"
17
18#include <TString.h>
19
20/*
21 * Detector elements enumeration scheme
22 *
23 * SystemID - fixed constatns defined in BmnDetectorList.h
24 * StationID - sequence across all systems starting from 0 or 1 (currently 1)
25 * ModuleID - separate sequence for each station starting from 0 or 1 (currently 1)
26 *
27 * CbmStsHit DetectorID layout:
28 *
29 * 27:24 ( 4 bit) System ID
30 * 23:16 ( 8 bit) Station number
31 * 15:4 (12 bit) Sector (module) number
32 * 3:1 ( 3 bit) Sensor number (not used, allways 0b001)
33 * 0:0 ( 1 bit) Unknown (not used, allways 0b0)
34 * --------------
35 * 28 bit in total
36 *
37 * See CbmStsHit.h and BmnToCbmHitConverter::Exec()
38 */
39
41{
42 protected:
44
45 enum
46 {
49 };
50 // Run8 configuration definition
52 SIL_STATION_CNT{4}, GEM_STATION_CNT{7}, STA_NUM_START{1}, // first station number (0 or 1)
53 MOD_NUM_START{1}, // first module number for each station (0 or 1)
54 // stations have one common index range, silicons first, then GEMs
57 SIL_MODULES[SIL_STATION_CNT]{6, 10, 14, 18}, GEM_MODULES[GEM_STATION_CNT]{8, 8, 8, 8, 8, 8, 8};
58 // In GEM stations each second module is a "hot zone".
59 // Hot zones should not be aligned independently.
60
61 // module count of the station at the given 0-based station index
62 inline Int_t StationModules(Int_t station) const noexcept
63 {
64 return station < SIL_STATION_CNT ? SIL_MODULES[station] : GEM_MODULES[station - SIL_STATION_CNT];
65 }
66 // of those, the ones aligned independently. This is the single per-station
67 // primitive Alignables() and MaxModulesInStation() are built from, so a
68 // model keeping fewer elements per station restates it here alone.
69 virtual Int_t StationAlignables(Int_t station) const noexcept
70 {
71 return station < SIL_STATION_CNT ? StationModules(station) : StationModules(station) / 2; // skip hot zones
72 }
73 // module number the station's alignable sequence starts at
74 virtual Int_t FirstModule(Int_t /*station*/) const noexcept { return MOD_NUM_START; }
75 // 0-based, inclusive index range of stations this model enumerates. A
76 // subsystem-restricted model narrows it (e.g. GEM-only starts past silicon),
77 // and Reset()/NextID()/Alignables()/Composites() all honour it.
78 virtual Int_t FirstStation() const noexcept { return 0; }
79 virtual Int_t LastStation() const noexcept { return SIL_STATION_CNT + GEM_STATION_CNT - 1; }
80
81 // detector modules enumeration: see base class
82 virtual void Reset() noexcept override
83 {
84 // must set iterator BEFORE the first module according to base class
85 // definition, stepping back over one full stride of the starting system
86 const Int_t station{FirstStation()};
88 fStation = station + STA_NUM_START;
89 fModule = FirstModule(station) - (fSystem == GEM_SYSTEM_ID ? 2 : 1);
90 }
91
92 virtual Int_t NextID() noexcept override
93 {
94 // out of range check
95 if (-1 == fSystem)
96 return -1; // EOF marker must be negative
97
98 // next module
99 const Int_t stride{fSystem == GEM_SYSTEM_ID ? 2 : 1}; // skip hot zones in GEM stations
100 fModule += stride;
101
102 // Next station check. Alignable elements times the stride is the span of
103 // module numbers the station's own sequence covers, and it is counted off
104 // that sequence's first module - so the test holds for a model keeping
105 // only a part of the station just as well as for the full one.
106 const Int_t station{fStation - STA_NUM_START};
107 if ((fModule - FirstModule(station)) / (StationAlignables(station) * stride)) {
108 fStation++;
109 // remember: stations has common enumeration across all systems
110 // currently only two systems are considered - silicon, then GEM
111
112 // EOF check
114 return fSystem = -1;
115
116 // next system check
119
120 // recomputed, not the snapshot above: FirstModule() depends on the
121 // station, and fStation has just advanced
123 }
124
125 return (fSystem << 24) | (fStation << 16) | (fModule << 4) | 0b0010;
126 // constant term 0b0010 is used to match CbmStsHit DetectorID encoding
127 }
128
129 public:
130 virtual Int_t MaxModulesInStation() const noexcept override
131 {
132 Int_t cnt{0};
133 for (Int_t i = FirstStation(); i <= LastStation(); i++)
134 if (StationAlignables(i) > cnt)
135 cnt = StationAlignables(i);
136 return cnt;
137 }
138
139 virtual Int_t Alignables() const noexcept override
140 {
141 Int_t al{0};
142 for (Int_t i = FirstStation(); i <= LastStation(); i++)
143 al += StationAlignables(i);
144 return al;
145 }
146
147 // convertion from CbmStsHit DetectorID, see the layout above
148 virtual Int_t IDfromHit(Int_t CbmDetectorID) const noexcept override
149 {
150 constexpr static const Int_t MOD_NUM_START4{MOD_NUM_START << 4}, ZERO_BIT4{0xFFFFFEF};
151
152 if (GEM_SYSTEM_ID == (CbmDetectorID >> 24))
153 // to skip GEM hot zone modules we need to erase the first bit
154 // of module number if modules are enumerated from zero
155 return ((CbmDetectorID - MOD_NUM_START4) & ZERO_BIT4) + MOD_NUM_START4;
156 else
157 return CbmDetectorID;
158 }
159
160 virtual std::string DecodeID(Int_t id) const override
161 {
162 TString system;
163 BmnDetectorList::GetSystemNameCaps(id >> 24, system);
164 return Form("%-7s st %2d mod %2d", system.Data(), (id >> 16) & 0xFF, (id >> 4) & 0xFFF);
165 }
166
167 BmnRun8DM() { fDescription = "Run8 GEM and FSD all independent parts: 76 elements"; }
168 virtual ~BmnRun8DM() override; // out-of-line vtable anchor
169};
170
171#endif // BMNRUN8DM_H
Defines unique identifiers (enum) for all BM@N detector systems.
@ kSILICON
@ kGEM
int i
Definition P4_F32vec4.h:22
int Int_t
char * Form(const char *fmt,...)
static void GetSystemNameCaps(DetectorId det, TString &name)
Get system name in capitals.
BmnDetectorModel()=default
std::string fDescription
Int_t fSystem
Definition BmnRun8DM.h:43
static constexpr const Int_t GEM_STATION_CNT
Definition BmnRun8DM.h:52
virtual void Reset() noexcept override
Definition BmnRun8DM.h:82
static constexpr const Int_t GEM_MODULES[GEM_STATION_CNT]
Definition BmnRun8DM.h:57
virtual std::string DecodeID(Int_t id) const override
Definition BmnRun8DM.h:160
virtual Int_t FirstStation() const noexcept
Definition BmnRun8DM.h:78
static constexpr const Int_t SIL_STATION_IDX[2]
Definition BmnRun8DM.h:55
virtual Int_t FirstModule(Int_t) const noexcept
Definition BmnRun8DM.h:74
virtual Int_t StationAlignables(Int_t station) const noexcept
Definition BmnRun8DM.h:69
static constexpr const Int_t MOD_NUM_START
Definition BmnRun8DM.h:53
Int_t fStation
Definition BmnRun8DM.h:43
Int_t fModule
Definition BmnRun8DM.h:43
virtual ~BmnRun8DM() override
static constexpr const Int_t STA_NUM_START
Definition BmnRun8DM.h:52
static constexpr const Int_t SIL_STATION_CNT
Definition BmnRun8DM.h:52
virtual Int_t MaxModulesInStation() const noexcept override
Definition BmnRun8DM.h:130
virtual Int_t IDfromHit(Int_t CbmDetectorID) const noexcept override
Definition BmnRun8DM.h:148
static constexpr const Int_t GEM_STATION_IDX[2]
Definition BmnRun8DM.h:56
virtual Int_t LastStation() const noexcept
Definition BmnRun8DM.h:79
virtual Int_t NextID() noexcept override
Definition BmnRun8DM.h:92
static constexpr const Int_t GEM_SYSTEM_ID
Definition BmnRun8DM.h:51
static constexpr const Int_t SIL_SYSTEM_ID
Definition BmnRun8DM.h:51
virtual Int_t Alignables() const noexcept override
Definition BmnRun8DM.h:139
Int_t StationModules(Int_t station) const noexcept
Definition BmnRun8DM.h:62
static constexpr const Int_t SIL_MODULES[SIL_STATION_CNT]
Definition BmnRun8DM.h:57
const char * Data() const