CbmRoot
Loading...
Searching...
No Matches
CbmGeoNodeMap.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 CbmGeoNodeMap_h
11#define CbmGeoNodeMap_h 1
12
13#include "CbmAddress.h"
14#include "CbmDefs.h"
15#include "CbmRecoSetupUtils.h"
17
18#include <cstdint>
19#include <functional>
20#include <string>
21#include <unordered_map>
22
23namespace cbm
24{
27 class GeoNodeMap {
28 public:
31 explicit GeoNodeMap(std::unordered_map<uint32_t, std::string>&& nodeMap);
32
35 const std::string& GetNodePath(uint32_t address) const
36 {
37 auto it = fNodeMap.find(ApplyMask(address));
38 if (it != fNodeMap.end()) {
39 return it->second;
40 }
41 return fNodeMap.at(0);
42 }
43
45 const auto& GetNodeMap() const { return fNodeMap; }
46
49 algo::GeoVolume ReadGeoVolume(uint32_t address);
50
56 // TODO: extend for a generic root object
57 template<class Visitor>
58 auto GetVolumeProperties(Visitor&& visitor, ECbmModuleId moduleId) const
59 {
60 using Property_t = std::invoke_result_t<Visitor, algo::GeoVolume>;
61 std::unordered_map<uint32_t, Property_t> res;
62 for (const auto& [address, path] : fNodeMap) {
63 if (static_cast<ECbmModuleId>(CbmAddress::GetSystemId(address)) == moduleId) {
64 res[address] = std::invoke(std::forward<Visitor>(visitor), RecoSetupUtils::ReadVolume(path));
65 }
66 }
67 return res;
68 }
69
73 static uint32_t ApplyMask(uint32_t address, ECbmModuleId moduleId)
74 {
75 switch (moduleId) {
81 default: return 0;
82 }
83 }
84
87 static uint32_t ApplyMask(uint32_t address)
88 {
89 auto moduleId = static_cast<ECbmModuleId>(CbmAddress::GetSystemId(address));
90 return ApplyMask(address, moduleId);
91 }
92
93 private:
94 std::unordered_map<uint32_t, std::string> fNodeMap;
95
97 // TODO: replace with a GetDetectorId method
98 template<ECbmModuleId ModuleId>
99 static uint32_t AlignableMask()
100 {
101 if constexpr (ModuleId == ECbmModuleId::kMvd) {
102 return 0x00000fff; // MVD Sensor
103 }
104 else if constexpr (ModuleId == ECbmModuleId::kSts) {
105 return 0xffffffff; // STS Sensor
106 }
107 else if constexpr (ModuleId == ECbmModuleId::kMuch) {
108 return 0x00007fff; // MuCh Module ?
109 }
110 else if constexpr (ModuleId == ECbmModuleId::kTrd) {
111 return 0x00007fff; // TRD Module
112 }
113 else if constexpr (ModuleId == ECbmModuleId::kTof) {
114 return 0x001fffff; // TOF RPC
115 }
116 }
117 };
118
119} // namespace cbm
120
121#endif // CbmGeoNodeMap_h
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kMvd
Micro-Vertex Detector.
Definition CbmDefs.h:47
@ kTrd
Transition Radiation Detector.
Definition CbmDefs.h:51
@ kTof
Time-of-flight Detector.
Definition CbmDefs.h:52
@ kSts
Silicon Tracking System.
Definition CbmDefs.h:48
@ kMuch
Muon detection system.
Definition CbmDefs.h:50
Different utilities for the CbmOfflineRecoSetup library (source)
A class for a geometrical volume representation in the reconstruction setup.
static int32_t GetSystemId(uint32_t address)
Definition CbmAddress.h:47
auto GetVolumeProperties(Visitor &&visitor, ECbmModuleId moduleId) const
Read volume properties for a given ModuleId.
static uint32_t ApplyMask(uint32_t address, ECbmModuleId moduleId)
Applies mask.
algo::GeoVolume ReadGeoVolume(uint32_t address)
Read volume properties of the node.
const std::string & GetNodePath(uint32_t address) const
A common function to get a path of a node.
GeoNodeMap(std::unordered_map< uint32_t, std::string > &&nodeMap)
Constructor.
static uint32_t AlignableMask()
Mask for minimally alignable element.
std::unordered_map< uint32_t, std::string > fNodeMap
Map of geometrical nodes vs hardware address.
const auto & GetNodeMap() const
An accessor to the node map.
static uint32_t ApplyMask(uint32_t address)
Applies mask.
A representation of a geometrical volume of different tracking stations.
Definition GeoVolume.h:25
static algo::GeoVolume ReadVolume(const TString &path)
Creates a volume info from a geo node, provided by path.