CbmRoot
Loading...
Searching...
No Matches
CbmGeoSetupProvider.cxx
Go to the documentation of this file.
1/* Copyright (C) 2019-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Evgeny Lavrik, Florian Uhlig [committer] */
4
10#include "CbmGeoSetupProvider.h"
11
12#include "CbmCave.h"
13#include "CbmDefs.h"
14#include "CbmMagnet.h"
15#include "CbmMuch.h"
16#include "CbmMvd.h"
17#include "CbmPipe.h"
18#include "CbmRich.h"
19#include "CbmStsMC.h"
20#include "CbmTarget.h"
21#include "CbmTof.h"
22#include "CbmTrd.h"
23
24#include "FairModule.h"
25#include "FairRunSim.h"
26#include <Logger.h>
27//#include "CbmEcal.h"
28#include "CbmFsdMC.h"
29#include "CbmPsdMC.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 {
45 return {
47 // ECbmModuleId::kMvd, ECbmModuleId::kSts, ECbmModuleId::kRich, ECbmModuleId::kMuch, ECbmModuleId::kTrd, ECbmModuleId::kTof, ECbmModuleId::kEcal, ECbmModuleId::kPsd,
50 // ECbmModuleId::kHodo, ECbmModuleId::kShield, ECbmModuleId::kPlatform };
52 }
53} // end anonymous namespace
54
55
56void CbmGeoSetupProvider::SetModuleTag(ECbmModuleId moduleId, std::string tag, Bool_t active)
57{
58 CbmGeoSetupModule module = GetModuleByTag(moduleId, tag);
59 module.SetActive(active);
60 fSetup.GetModuleMap()[moduleId] = module;
61}
62
64
66{
68
69 // copy over the scale and position of the field previously set
72 fSetup.SetField(field);
73}
74
76{
77 if (!fSetup.GetModuleMap().size()) {
78 LOG(error) << "-E- RegisterSetup: setup " << fSetup.GetName() << " is empty!";
79 return;
80 }
81
82 // --- Get the FairRunSim instance
83 FairRunSim* run = FairRunSim::Instance();
84 if (!run) {
85 LOG(error) << "-E- RegisterSetup: No FairRunSim instance!";
86 return;
87 }
88
89 // register media
90 run->SetMaterials(fSetup.GetMedia().GetFilePath().c_str());
91
92 for (ECbmModuleId moduleId : GetModuleLoadingOrder()) {
93 auto& moduleMap = fSetup.GetModuleMap();
94 if (moduleMap.find(moduleId) == moduleMap.end()) continue;
95
96 auto& geoModule = fSetup.GetModuleMap()[moduleId];
97 std::string fileName = geoModule.GetFilePath();
98
99 Bool_t isActive = geoModule.GetActive();
100 std::string geoTag = geoModule.GetTag();
101 std::string modulName = geoModule.GetName();
102
103 std::vector<std::string> _geom;
104 std::vector<std::string> _tag;
105 boost::split(_geom, fileName, [](char c) { return c == ':'; });
106 boost::split(_tag, geoTag, [](char c) { return c == ':'; });
107 int counter {0};
108 for (auto& string : _geom) {
109
110 LOG(info) << "-I- RegisterSetup: Registering " << modulName << " " << _tag[counter]
111 << ((moduleId >= ECbmModuleId::kMvd && moduleId <= ECbmModuleId::kNofSystems)
112 ? (isActive ? " -ACTIVE- " : " - INACTIVE- ")
113 : "")
114 << " using " << string;
115
116 FairModule* fairModule = NULL;
117 switch (moduleId) {
118 case ECbmModuleId::kCave: fairModule = new CbmCave("CAVE"); break;
119 case ECbmModuleId::kMagnet: fairModule = new CbmMagnet("MAGNET"); break;
120 case ECbmModuleId::kBmon: fairModule = new CbmBmon("BMON"); break;
121 case ECbmModuleId::kPipe: {
122 std::string volname {"PIPE"};
123 volname += std::to_string(counter);
124 fairModule = new CbmPipe(volname.c_str());
125 break;
126 }
127 case ECbmModuleId::kTarget: fairModule = new CbmTarget(); break;
128 case ECbmModuleId::kMvd: fairModule = new CbmMvd("MVD", isActive); break;
129 case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
130 case ECbmModuleId::kRich: fairModule = new CbmRich("RICH", isActive); break;
131 case ECbmModuleId::kMuch: fairModule = new CbmMuch("MUCH", isActive); break;
132 case ECbmModuleId::kTrd: fairModule = new CbmTrd("TRD", isActive); break;
134 fairModule = new CbmTof("TOF", isActive);
135 break;
136 // case ECbmModuleId::kEcal: fairModule = new CbmEcal("Ecal", isActive); break;
137 case ECbmModuleId::kPsd: fairModule = new CbmPsdMC(isActive); break;
139 fairModule = new CbmFsdMC(isActive);
140 break;
141 // case ECbmModuleId::kShield: fairModule = new CbmShield("SHIELD"); break;
142 case ECbmModuleId::kPlatform: fairModule = new CbmPlatform("PLATFORM"); break;
143 case ECbmModuleId::kHodo: fairModule = new CbmStsMC(isActive); break;
144 default: LOG(error) << "-E- RegisterSetup: Unknown fairModule ID " << moduleId; break;
145 }
146 counter++;
147
148 if (fairModule) {
149 if (moduleId == ECbmModuleId::kMvd) fairModule->SetMotherVolume("pipevac1");
150 fairModule->SetGeometryFileName(string.c_str());
151 run->AddModule(fairModule);
152 }
153 }
154 }
155}
156
158
160{
161 std::string geoFilePath = std::string(gSystem->Getenv("VMCWORKDIR")) + "/geometry/cave.geo";
162
163 CbmGeoSetupModule module;
164 module.SetName("CAVE");
165 module.SetFilePath("cave.geo");
166 module.SetTag("default");
167 module.SetModuleId(ECbmModuleId::kCave);
168
169 return module;
170}
ECbmModuleId
Definition CbmDefs.h:39
@ kMvd
Micro-Vertex Detector.
@ kPipe
Beam pipe.
@ kHodo
Hodoscope (for test beam times)
@ kTrd
Transition Radiation Detector.
@ kMagnet
Magnet.
@ kTof
Time-of-flight Detector.
@ kTarget
Target.
@ kPsd
Projectile spectator detector.
@ kSts
Silicon Tracking System.
@ kPlatform
RICH rail platform.
@ kMuch
Muon detection system.
@ kFsd
Forward spectator detector.
@ kNofSystems
For loops over active systems.
@ kRich
Ring-Imaging Cherenkov Detector.
ClassImp(CbmGeoSetupProvider)
Defines the active detector RICH. Constructs the geometry and creates MCPoints.
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
Class for the MC transport of the CBM-FSD.
Definition CbmFsdMC.h:32
TGeoTranslation & GetMatrix()
void SetMatrix(TGeoTranslation value)
void SetScale(Double_t value)
std::string GetFilePath()
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
std::string GetName()
Definition CbmGeoSetup.h:37
void SetField(CbmGeoSetupField value)
Definition CbmGeoSetup.h:55
CbmGeoSetupField & GetField()
Definition CbmGeoSetup.h:44
CbmGeoSetupMedia & GetMedia()
Definition CbmGeoSetup.h:45
std::map< ECbmModuleId, CbmGeoSetupModule > & GetModuleMap()
Definition CbmGeoSetup.h:43
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