20#include <FairRuntimeDb.h>
22#include <TGeoManager.h>
23#include <TGeoPhysicalNode.h>
29template<ECbmModuleId ModuleId>
30using Tag = std::integral_constant<ECbmModuleId, ModuleId>;
37 std::unordered_map<uint32_t, std::string> res;
39 for (
auto [address, pSensor] : mvdSensorMap) {
40 res[address] = pSensor->GetNodeName().Data();
50 std::unordered_map<uint32_t, std::string> res;
52 for (
int iSensor = 0; iSensor < pSetup->GetNofSensors(); ++iSensor) {
53 const auto* pSensor = pSetup->GetSensor(iSensor);
55 const auto* pNode = pSensor->GetNode();
57 std::string path = pNode->GetName();
58 if (path.compare(0, 4,
"cave") == 0) {
61 uint32_t address = pSensor->GetAddress();
72 std::unordered_map<uint32_t, std::string> res;
76 std::regex rpcPattern{
"module_(\\d+)_(\\d+)/gas_box_(\\d+)/counter_(\\d+)"};
78 for (
const auto& rpcPath : vRpcPaths) {
80 std::string line{rpcPath.Data()};
81 if (std::regex_search(line, match, rpcPattern)) {
82 int smTypeId{std::stoi(match[1])};
83 int smId{std::stoi(match[2])};
84 int rpcId{std::stoi(match[4])};
86 res[address] = std::string(rpcPath.Data());
98 std::unordered_map<uint32_t, std::string> res;
102 std::regex rpcPattern{
"layer(\\d+)_(\\d+)/module(\\d+)_(\\d+)"};
104 for (
const auto& rpcPath : vRpcPaths) {
106 std::string line{rpcPath.Data()};
107 if (std::regex_search(line, match, rpcPattern)) {
108 int layerId{std::stoi(match[1])};
109 int moduleId{std::stoi(match[3])};
111 res[address] = std::string(rpcPath.Data());
122 std::unordered_map<uint32_t, std::string> collectedNodes;
125 auto AddNodes = [&](
auto aTag) ->
void {
126 constexpr ECbmModuleId ModuleId =
decltype(aTag)::value;
128 LOG(info) <<
"GeoNodeMapBuilder: building node map for " << ModuleId;
141catch (
const std::exception& err) {
142 LOG(fatal) <<
"cbm::GeoNodeMapBuilder: failed building the map. Reason: " << err.what();
143 __builtin_unreachable();
ECbmModuleId
Enumerator for module Identifiers.
A multi-purpose class to access the geometrical information stored in a TGeoManager (source)
std::integral_constant< ECbmModuleId, ModuleId > Tag
A builder for the cbm::GeoNodeMap class (source)
Helper class to convert unique channel ID back and forth.
std::map< uint32_t, CbmMvdSensor * > & GetSensorMap()
static CbmMvdDetector * Instance()
static CbmStsSetup * Instance()
static uint32_t GetUniqueAddress(uint32_t Sm, uint32_t Rpc, uint32_t Channel, uint32_t Side=0, uint32_t SmType=0, uint32_t RpcType=0)
static uint32_t GetAddress(int32_t layerId, int32_t moduleId, int32_t sectorId, int32_t rowId, int32_t columnId)
Return address from system ID, layer, module, sector, column and row IDs.
static std::vector< TString > CollectNodes(const TString &detector, const std::regex &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.
static std::unordered_map< uint32_t, std::string > Add()
Adds nodes for a given detector ID.
GeoNodeMap Build() const
Builds the geo-node map.
A builder for GeoNodeMap in CBM.
static std::unordered_map< uint32_t, std::string > Add()
Adds nodes for a given detector ID.
std::unordered_set< ECbmModuleId > fDetToBuildNodes
A list of detectors requested to build nodes.
A class to keep paths to nodes vs. hardware addresses for different detectors.