CbmRoot
Loading...
Searching...
No Matches
CbmGeoSetupProvider.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Evgeny Lavrik, Florian Uhlig [committer] */
4
9
10#include "CbmGeoSetupProvider.h"
11
12#include "CbmCave.h"
13#include "CbmDefs.h"
14#include "CbmFsdMC.h"
15#include "CbmMagnet.h"
16#include "CbmMuch.h"
17#include "CbmMust.h"
18#include "CbmMvd.h"
19#include "CbmPipe.h"
20#include "CbmPsdMC.h"
21#include "CbmRich.h"
22#include "CbmStsMC.h"
23#include "CbmTarget.h"
24#include "CbmTof.h"
25#include "CbmTrd.h"
26#include "FairModule.h"
27#include "FairRunSim.h"
28
29#include <Logger.h>
30//#include "CbmShield.h"
31#include "CbmBmon.h"
32#include "CbmPlatform.h"
33
34#include <boost/algorithm/string.hpp>
35
37
38namespace
39{ // anonymous namespace
43 std::vector<ECbmModuleId> GetModuleLoadingOrder()
44 {
49 }
50} // end anonymous namespace
51
52
53void CbmGeoSetupProvider::SetModuleTag(ECbmModuleId moduleId, std::string tag, Bool_t active)
54{
55 CbmGeoSetupModule module = GetModuleByTag(moduleId, tag);
56 module.SetActive(active);
57 fSetup.GetModuleMap()[moduleId] = module;
58}
59
60void CbmGeoSetupProvider::RemoveModule(ECbmModuleId moduleId) { fSetup.GetModuleMap().erase(moduleId); }
61
63{
65
66 // copy over the scale and position of the field previously set
67 field.SetScale(fSetup.GetField().GetScale());
68 field.SetMatrix(fSetup.GetField().GetMatrix());
69 fSetup.SetField(field);
70}
71
73{
74 if (!fSetup.GetModuleMap().size()) {
75 LOG(error) << "-E- RegisterSetup: setup " << fSetup.GetName() << " is empty!";
76 return;
77 }
78
79 // --- Get the FairRunSim instance
80 FairRunSim* run = FairRunSim::Instance();
81 if (!run) {
82 LOG(error) << "-E- RegisterSetup: No FairRunSim instance!";
83 return;
84 }
85
86 // register media
87 run->SetMaterials(fSetup.GetMedia().GetFilePath().c_str());
88
89 for (ECbmModuleId moduleId : GetModuleLoadingOrder()) {
90 auto& moduleMap = fSetup.GetModuleMap();
91 if (moduleMap.find(moduleId) == moduleMap.end()) continue;
92
93 auto& geoModule = fSetup.GetModuleMap()[moduleId];
94 std::string fileName = geoModule.GetFilePath();
95
96 Bool_t isActive = geoModule.GetActive();
97 std::string geoTag = geoModule.GetTag();
98 std::string modulName = geoModule.GetName();
99
100 std::vector<std::string> _geom;
101 std::vector<std::string> _tag;
102 boost::split(_geom, fileName, [](char c) { return c == ':'; });
103 boost::split(_tag, geoTag, [](char c) { return c == ':'; });
104 int counter{0};
105 for (auto& string : _geom) {
106
107 LOG(info) << "-I- RegisterSetup: Registering " << modulName << " " << _tag[counter]
108 << ((moduleId >= ECbmModuleId::kMvd && moduleId <= ECbmModuleId::kNofSystems)
109 ? (isActive ? " -ACTIVE- " : " - INACTIVE- ")
110 : "")
111 << " using " << string;
112
113 FairModule* fairModule = NULL;
114 switch (moduleId) {
115 case ECbmModuleId::kCave: fairModule = new CbmCave("CAVE"); break;
116 case ECbmModuleId::kMagnet: fairModule = new CbmMagnet("MAGNET"); break;
117 case ECbmModuleId::kBmon: fairModule = new CbmBmon("BMON"); break;
118 case ECbmModuleId::kPipe: {
119 std::string volname{"PIPE"};
120 volname += std::to_string(counter);
121 fairModule = new CbmPipe(volname.c_str());
122 break;
123 }
124 case ECbmModuleId::kTarget: fairModule = new CbmTarget(); break;
125 case ECbmModuleId::kMvd: fairModule = new CbmMvd("MVD", isActive); break;
126 case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
127 case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive); break;
128 case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive); break;
129 case ECbmModuleId::kMust: fairModule = new CbmMust("MUST", isActive); break;
130 case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive); break;
131 case ECbmModuleId::kTof: fairModule = new CbmTof("TOF", isActive); break;
132 case ECbmModuleId::kPsd: fairModule = new CbmPsdMC(isActive); break;
133 case ECbmModuleId::kFsd: fairModule = new CbmFsdMC(isActive); break;
134 case ECbmModuleId::kPlatform: fairModule = new CbmPlatform("PLATFORM"); break;
135 case ECbmModuleId::kHodo: fairModule = new CbmStsMC(isActive); break;
136 default: LOG(error) << "-E- RegisterSetup: Unknown fairModule ID " << moduleId; break;
137 }
138 counter++;
139
140 if (fairModule) {
141 if (moduleId == ECbmModuleId::kMvd) fairModule->SetMotherVolume("pipevac1");
142 if (strstr(fSetup.GetTag().data(), "mcbm") != NULL) {
143 fairModule->SetMotherVolume("cave");
144 };
145 fairModule->SetGeometryFileName(string.c_str());
146 run->AddModule(fairModule);
147 }
148 }
149 }
150}
151
153
155{
156 std::string geoFilePath = std::string(gSystem->Getenv("VMCWORKDIR")) + "/geometry/cave.geo";
157
158 CbmGeoSetupModule module;
159 module.SetName("CAVE");
160 module.SetFilePath("cave.geo");
161 module.SetTag("default");
162 module.SetModuleId(ECbmModuleId::kCave);
163
164 return module;
165}
ECbmModuleId
Enumerator for module Identifiers.
Definition CbmDefs.h:45
@ kMvd
Micro-Vertex Detector.
Definition CbmDefs.h:47
@ kPipe
Beam pipe.
Definition CbmDefs.h:63
@ kHodo
Hodoscope (for test beam times)
Definition CbmDefs.h:55
@ kCave
Cave.
Definition CbmDefs.h:66
@ kTrd
Transition Radiation Detector.
Definition CbmDefs.h:51
@ kMagnet
Magnet.
Definition CbmDefs.h:61
@ kTof
Time-of-flight Detector.
Definition CbmDefs.h:52
@ kTarget
Target.
Definition CbmDefs.h:62
@ kPsd
Projectile spectator detector.
Definition CbmDefs.h:54
@ kSts
Silicon Tracking System.
Definition CbmDefs.h:48
@ kMust
MuSt detection system.
Definition CbmDefs.h:53
@ kPlatform
RICH rail platform.
Definition CbmDefs.h:65
@ kMuch
Muon detection system.
Definition CbmDefs.h:50
@ kFsd
Forward spectator detector.
Definition CbmDefs.h:59
@ kBmon
Bmon Counter.
Definition CbmDefs.h:57
@ kNofSystems
For loops over active systems.
Definition CbmDefs.h:60
@ kRich
Ring-Imaging Cherenkov Detector.
Definition CbmDefs.h:49
ClassImp(CbmGeoSetupProvider)
Defines the active detector RICH. Constructs the geometry and creates MCPoints.
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
bool Bool_t
Class for the MC transport of the CBM-FSD.
Definition CbmFsdMC.h:32
void SetMatrix(TGeoTranslation value)
void SetScale(Double_t value)
Abstract interface class for providing the CBM detector setup description, module list,...
virtual CbmGeoSetupModule GetModuleByTag(ECbmModuleId moduleId, std::string tag)=0
Abstract method for constructing the module by id and tag.
CbmGeoSetupModule GetDefaultCaveModule()
Gets defauk cave if none was provided by the other means.
void Reset()
Resets the setup to default (empty)
void SetModuleTag(ECbmModuleId moduleId, std::string tag, Bool_t active)
Loads the detector with a tag into setup, will invoke GetModuleByTag.
void SetFieldTag(std::string tag)
Loads the field with a tag and adds it to the setup.
void RemoveModule(ECbmModuleId moduleId)
Removes the module from setup.
void RegisterSetup()
Registers the previously loaded setup with FairRoot. Replaces the registerSetup.C macro.
virtual CbmGeoSetupField GetFieldByTag(std::string tag)=0
Abstract method for constructing the field by tag.
Data transfer object to represent the CBM Detector setup.
Definition CbmGeoSetup.h:34
Class for the MC transport of the CBM-PSD.
Definition CbmPsdMC.h:34
Defines the active detector RICH. Constructs the geometry and creates MCPoints.
Definition CbmRich.h:40
Class for the MC transport of the CBM-STS.
Definition CbmStsMC.h:40
Class for constructing the geometry of the CBM target.
Definition CbmTarget.h:37
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
Definition CbmTrd.h:34