BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnRun9HalfDM.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 BmnRun9HalfDM class declaration
9 Run9 full-granularity representation, single half of each station only
10*/
11
12#ifndef BMNRUN9HALFDM_H
13#define BMNRUN9HALFDM_H
14
15#include "BmnRun9DM.h"
16
17#include <TString.h>
18#include <numeric>
19
20/*
21 * Common base for the fine-grained half-assembly models: same every-module
22 * scheme as BmnRun9DM, but only one half of every station is alignable
23 * (55 elements, plus the target if the model has one). Top elements carry
24 * the first half of module numbers, bottom elements the second half. Derived
25 * classes pick the kept half via KeepBottomHalf().
26 *
27 * The last GEM station, a single module crossing y = 0, has no halves.
28 * BmnRun9DM leaves it out (a zero in GEM_MODULES), so every station of this
29 * model has two halves.
30 *
31 * Hierarchical parametrization
32 * ----------------------------
33 * The half of a station is a rigid mechanical unit, so the model declares one
34 * composite node per station half on top of the element-level nodes. The
35 * nodes carry the names BmnRun9DM gives the same station halves (STAnnU,
36 * STAnnL), so config files address them the same way in both models.
37 * Pivots are left to the default (centre of gravity of the owned elements,
38 * i.e. the beam axis at their mean z).
39 */
40
42{
43 protected:
44 // selects which half of every station is alignable
45 virtual Bool_t KeepBottomHalf() const noexcept = 0;
46
47 // the bottom half starts where the station's own module count says it does
48 virtual Int_t FirstModule(Int_t station) const noexcept override
49 {
50 return MOD_NUM_START + (KeepBottomHalf() ? StationModules(station) / 2 : 0);
51 }
52 virtual Int_t StationAlignables(Int_t station) const noexcept override
53 {
54 // method also works for the single-module station,
55 // it is a safety feature for the future code changes
56 if (!StationModules(station))
57 return 0;
58 return std::max(1, BmnRun9DM::StationAlignables(station) / 2);
59 }
60
61 public:
63
64 // CAUTION: the base check goes first. The halves test below knows nothing
65 // of the stations left out, and keeps a single-module one in the bottom model.
66 virtual Bool_t IgnoreHit(Int_t CbmDetectorID) const noexcept override
67 {
68 if (BmnRun9DM::IgnoreHit(CbmDetectorID))
69 return kTRUE;
70 const Int_t module{((CbmDetectorID >> 4) & 0xFFF) - MOD_NUM_START},
71 station{((CbmDetectorID >> 16) & 0xFF) - STA_NUM_START}, half{StationModules(station) / 2};
72 if (0 == half) // single-module station kept whole by both halves
73 return kFALSE; // ignoring it is up to BmnRun9DM::IgnoreHit()
74 return KeepBottomHalf() ? module < half : module >= half;
75 }
76 virtual Bool_t IgnoresSome() const noexcept override { return kTRUE; }
77
78 virtual std::vector<Composite> Composites() const override
79 {
80 // NextID() walks the stations in order and never revisits one, so the
81 // elements of a station half occupy a contiguous index range
82 std::vector<Composite> nodes;
83 nodes.reserve(LastStation() - FirstStation() + 1);
84 for (Int_t station = FirstStation(), leaf = 0; station <= LastStation(); station++) {
85 if (0 == StationAlignables(station))
86 continue; // ignore 'empty' stations
87 Composite node;
88 node.name = Form(KeepBottomHalf() ? "STA%02dL" : "STA%02dU", station + STA_NUM_START);
89 node.leaves.resize(StationAlignables(station));
90 std::iota(node.leaves.begin(), node.leaves.end(), leaf);
91 leaf += node.leaves.size();
92 nodes.push_back(std::move(node));
93 }
94 return nodes;
95 }
96};
97
98#endif // BMNRUN9HALFDM_H
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
char * Form(const char *fmt,...)
BmnRun9DM(Bool_t withTarget=kTRUE)
Definition BmnRun9DM.h:240
static constexpr const Int_t MOD_NUM_START
Definition BmnRun9DM.h:70
static constexpr const Int_t STA_NUM_START
Definition BmnRun9DM.h:69
virtual Int_t FirstStation() const noexcept
Definition BmnRun9DM.h:100
virtual Bool_t IgnoreHit(Int_t CbmDetectorID) const noexcept override
Definition BmnRun9DM.h:188
Int_t StationModules(Int_t station) const noexcept
Definition BmnRun9DM.h:83
virtual Int_t LastStation() const noexcept
Definition BmnRun9DM.h:101
virtual Int_t StationAlignables(Int_t station) const noexcept
Definition BmnRun9DM.h:94
BmnRun9DM(Bool_t withTarget=kTRUE)
Definition BmnRun9DM.h:240
virtual Bool_t IgnoreHit(Int_t CbmDetectorID) const noexcept override
virtual std::vector< Composite > Composites() const override
virtual Int_t FirstModule(Int_t station) const noexcept override
virtual Bool_t KeepBottomHalf() const noexcept=0
virtual Int_t StationAlignables(Int_t station) const noexcept override
virtual Bool_t IgnoresSome() const noexcept override