CbmRoot
Loading...
Searching...
No Matches
CbmGeoHelper.cxx
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#include "CbmGeoHelper.h"
11
12#include <Logger.h>
13
14#include <TGeoManager.h>
15#include <TGeoNode.h>
16#include <TString.h>
17
18#include <iomanip>
19#include <limits>
20#include <regex>
21#include <set>
22#include <string>
23
24using cbm::GeoHelper;
25
26// ---------------------------------------------------------------------------------------------------------------------
27//
28std::vector<TString> GeoHelper::CollectNodes(const TString& detector, const std::regex& component, const TString& path,
29 TGeoNode* pNode)
30{
31 std::vector<TString> vPaths;
32
33 if (!pNode) {
34 return vPaths;
35 }
36
37 TString nodePath = path + (path.IsNull() ? "" : "/") + pNode->GetName();
38 std::string nodeName{pNode->GetName()};
39 std::smatch sMatch;
40 if (std::regex_search(nodeName, sMatch, component)) {
41 if (nodePath.Contains(detector, TString::kIgnoreCase)) {
42 vPaths.push_back(nodePath);
43 }
44 }
45
46 for (int iNode = 0; iNode < pNode->GetNdaughters(); ++iNode) {
47 TGeoNode* pDaughter = pNode->GetDaughter(iNode);
48 auto daughterPaths = CollectNodes(detector, component, nodePath, pDaughter);
49 vPaths.insert(vPaths.end(), daughterPaths.begin(), daughterPaths.end());
50 }
51
52 return vPaths;
53}
A multi-purpose class to access the geometrical information stored in a TGeoManager (source)
static std::vector< TString > CollectNodes(const TString &detector, const std::regex &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.
A class providing a uniformed access to geometrical information for different detector subsystems.
static std::vector< TString > CollectNodes(const TString &detector, const std::regex &component, const TString &path, TGeoNode *pNode)
Collects paths of the components.