CbmRoot
CbmGeoSetupProvider.cxx
Go to the documentation of this file.
1 
7 
8 #include "FairLogger.h"
9 #include "FairModule.h"
10 #include "FairRunSim.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 //#include "CbmEcal.h"
24 #include "CbmPsdMC.h"
25 //#include "CbmShield.h"
26 #include "CbmPlatform.h"
27 
28 #include <boost/algorithm/string.hpp>
29 
31 
32 namespace { // anonymous namespace
36  std::vector<ECbmModuleId> GetModuleLoadingOrder() {
37  return {
42  // ECbmModuleId::kMvd, ECbmModuleId::kSts, ECbmModuleId::kRich, ECbmModuleId::kMuch, ECbmModuleId::kTrd, ECbmModuleId::kTof, ECbmModuleId::kEcal, ECbmModuleId::kPsd,
50  // ECbmModuleId::kHodo, ECbmModuleId::kShield, ECbmModuleId::kPlatform };
53  }
54 } // end anonymous namespace
55 
56 
58  std::string tag,
59  Bool_t active) {
60  CbmGeoSetupModule module = GetModuleByTag(moduleId, tag);
61  module.SetActive(active);
62  fSetup.GetModuleMap()[moduleId] = module;
63 }
64 
66  fSetup.GetModuleMap().erase(moduleId);
67 }
68 
69 void CbmGeoSetupProvider::SetFieldTag(std::string tag) {
70  CbmGeoSetupField field = GetFieldByTag(tag);
71 
72  // copy over the scale and position of the field previously set
73  field.SetScale(fSetup.GetField().GetScale());
75  fSetup.SetField(field);
76 }
77 
79  if (!fSetup.GetModuleMap().size()) {
80  LOG(error) << "-E- RegisterSetup: setup " << fSetup.GetName()
81  << " is empty!";
82  return;
83  }
84 
85  // --- Get the FairRunSim instance
86  FairRunSim* run = FairRunSim::Instance();
87  if (!run) {
88  LOG(error) << "-E- RegisterSetup: No FairRunSim instance!";
89  return;
90  }
91 
92  // register media
93  run->SetMaterials(fSetup.GetMedia().GetFilePath().c_str());
94 
95  for (ECbmModuleId moduleId : GetModuleLoadingOrder()) {
96  auto& moduleMap = fSetup.GetModuleMap();
97  if (moduleMap.find(moduleId) == moduleMap.end()) continue;
98 
99  auto& geoModule = fSetup.GetModuleMap()[moduleId];
100  std::string fileName = geoModule.GetFilePath();
101 
102  Bool_t isActive = geoModule.GetActive();
103  std::string geoTag = geoModule.GetTag();
104  std::string modulName = geoModule.GetName();
105 
106  std::vector<std::string> _geom;
107  std::vector<std::string> _tag;
108  boost::split(_geom, fileName, [](char c) { return c == ':'; });
109  boost::split(_tag, geoTag, [](char c) { return c == ':'; });
110  int counter {0};
111  for (auto& string : _geom) {
112 
113  LOG(info) << "-I- RegisterSetup: Registering " << modulName << " "
114  << _tag[counter]
115  << ((moduleId >= ECbmModuleId::kMvd
116  && moduleId <= ECbmModuleId::kPsd)
117  ? (isActive ? " -ACTIVE- " : " - INACTIVE- ")
118  : "")
119  << " using " << string;
120 
121  FairModule* fairModule = NULL;
122  switch (moduleId) {
123  case ECbmModuleId::kCave: fairModule = new CbmCave("CAVE"); break;
124  case ECbmModuleId::kMagnet: fairModule = new CbmMagnet("MAGNET"); break;
125  case ECbmModuleId::kPipe: {
126  std::string volname {"PIPE"};
127  volname += std::to_string(counter);
128  fairModule = new CbmPipe(volname.c_str());
129  break;
130  }
131  case ECbmModuleId::kTarget: fairModule = new CbmTarget(); break;
132  case ECbmModuleId::kMvd:
133  fairModule = new CbmMvd("MVD", isActive);
134  break;
135  case ECbmModuleId::kSts: fairModule = new CbmStsMC(isActive); break;
136  case ECbmModuleId::kRich:
137  fairModule = new CbmRich("RICH", isActive);
138  break;
139  case ECbmModuleId::kMuch:
140  fairModule = new CbmMuch("MUCH", isActive);
141  break;
142  case ECbmModuleId::kTrd:
143  fairModule = new CbmTrd("TRD", isActive);
144  break;
145  case ECbmModuleId::kTof:
146  fairModule = new CbmTof("TOF", isActive);
147  break;
148  // case ECbmModuleId::kEcal: fairModule = new CbmEcal("Ecal", isActive); break;
149  case ECbmModuleId::kPsd:
150  fairModule = new CbmPsdMC(isActive);
151  break;
152  // case ECbmModuleId::kShield: fairModule = new CbmShield("SHIELD"); break;
154  fairModule = new CbmPlatform("PLATFORM");
155  break;
156  case ECbmModuleId::kHodo: fairModule = new CbmStsMC(isActive); break;
157  default:
158  LOG(error) << "-E- RegisterSetup: Unknown fairModule ID " << moduleId;
159  break;
160  }
161  counter++;
162 
163  if (fairModule) {
164  if (moduleId == ECbmModuleId::kMvd)
165  fairModule->SetMotherVolume("pipevac1");
166  fairModule->SetGeometryFileName(string.c_str());
167  run->AddModule(fairModule);
168  }
169  }
170  }
171 }
172 
174 
176  std::string geoFilePath =
177  std::string(gSystem->Getenv("VMCWORKDIR")) + "/geometry/cave.geo";
178 
179  CbmGeoSetupModule module;
180  module.SetName("CAVE");
181  module.SetFilePath("cave.geo");
182  module.SetTag("default");
184 
185  return module;
186 }
CbmStsMC
Class for the MC transport of the CBM-STS.
Definition: CbmStsMC.h:33
split
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
Definition: ThermalParticleSystem.cxx:144
CbmCave.h
CbmGeoSetupField::GetMatrix
TGeoTranslation & GetMatrix()
Definition: CbmGeoSetupField.h:31
CbmGeoSetupProvider::fSetup
CbmGeoSetup fSetup
Definition: CbmGeoSetupProvider.h:90
CbmPlatform.h
CbmGeoSetupProvider::SetModuleTag
void SetModuleTag(ECbmModuleId moduleId, std::string tag, Bool_t active)
Loads the detector with a tag into setup, will invoke GetModuleByTag.
Definition: CbmGeoSetupProvider.cxx:57
CbmTof
Definition: CbmTof.h:35
ECbmModuleId::kMagnet
@ kMagnet
Magnet.
ClassImp
ClassImp(CbmGeoSetupProvider)
CbmGeoSetup::SetField
void SetField(CbmGeoSetupField value)
Definition: CbmGeoSetup.h:55
CbmTof.h
CbmGeoSetupField::SetMatrix
void SetMatrix(TGeoTranslation value)
Definition: CbmGeoSetupField.h:41
CbmPipe.h
CbmGeoSetupMedia::GetFilePath
std::string GetFilePath()
Definition: CbmGeoSetupMedia.h:26
CbmGeoSetupModule::SetTag
void SetTag(std::string value)
Definition: CbmGeoSetupModule.h:38
CbmGeoSetupProvider::GetDefaultCaveModule
CbmGeoSetupModule GetDefaultCaveModule()
Gets defauk cave if none was provided by the other means.
Definition: CbmGeoSetupProvider.cxx:175
CbmMvd.h
CbmRich
Defines the active detector RICH. Constructs the geometry and creates MCPoints.
Definition: CbmRich.h:38
ECbmModuleId::kMvd
@ kMvd
Micro-Vertex Detector.
ECbmModuleId
ECbmModuleId
Definition: CbmDefs.h:33
CbmGeoSetup::GetMedia
CbmGeoSetupMedia & GetMedia()
Definition: CbmGeoSetup.h:43
ECbmModuleId::kTof
@ kTof
Time-of-flight Detector.
CbmTarget
Class for constructing the geometry of the CBM target.
Definition: CbmTarget.h:31
CbmPipe
Definition: CbmPipe.h:9
ECbmModuleId::kTarget
@ kTarget
Target.
CbmStsMC.h
CbmTrd
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
Definition: CbmTrd.h:28
CbmGeoSetupModule::SetName
void SetName(std::string value)
Definition: CbmGeoSetupModule.h:39
CbmPsdMC.h
CbmGeoSetupField
Definition: CbmGeoSetupField.h:21
CbmGeoSetupModule::SetActive
void SetActive(Bool_t value)
Definition: CbmGeoSetupModule.h:46
CbmMuch.h
CbmGeoSetup::GetName
std::string GetName()
Definition: CbmGeoSetup.h:33
ECbmModuleId::kHodo
@ kHodo
Hodoscope (for test beam times)
CbmMuch
Definition: CbmMuch.h:27
ECbmModuleId::kCave
@ kCave
Cave.
CbmRich.h
Defines the active detector RICH. Constructs the geometry and creates MCPoints.
CbmGeoSetupField::SetScale
void SetScale(Double_t value)
Definition: CbmGeoSetupField.h:40
CbmCave
Definition: CbmCave.h:7
ECbmModuleId::kRich
@ kRich
Ring-Imaging Cherenkov Detector.
CbmGeoSetupProvider::GetFieldByTag
virtual CbmGeoSetupField GetFieldByTag(std::string tag)=0
Abstract method for constructing the field by tag.
CbmTarget.h
CbmGeoSetupProvider::SetFieldTag
void SetFieldTag(std::string tag)
Loads the field with a tag and adds it to the setup.
Definition: CbmGeoSetupProvider.cxx:69
CbmPsdMC
Class for the MC transport of the CBM-PSD.
Definition: CbmPsdMC.h:29
CbmGeoSetup
Data transfer object to represent the CBM Detector setup.
Definition: CbmGeoSetup.h:30
ECbmModuleId::kPipe
@ kPipe
Beam pipe.
ECbmModuleId::kTrd
@ kTrd
Transition Radiation Detector.
CbmTrd.h
Defines the active detector TRD. Constructs the geometry and registers MCPoints.
counter
int counter
Definition: CbmMvdSensorDigiToHitTask.cxx:72
CbmMvd
Definition: CbmMvd.h:39
CbmGeoSetupModule::SetModuleId
void SetModuleId(ECbmModuleId value)
Definition: CbmGeoSetupModule.h:37
CbmGeoSetupField::GetScale
Double_t GetScale()
Definition: CbmGeoSetupField.h:30
CbmGeoSetupModule::SetFilePath
void SetFilePath(std::string value)
Definition: CbmGeoSetupModule.h:43
CbmGeoSetupProvider::RemoveModule
void RemoveModule(ECbmModuleId moduleId)
Removes the module from setup.
Definition: CbmGeoSetupProvider.cxx:65
CbmMagnet.h
CbmGeoSetup::GetField
CbmGeoSetupField & GetField()
Definition: CbmGeoSetup.h:42
CbmGeoSetupModule
Definition: CbmGeoSetupModule.h:22
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmGeoSetupProvider::Reset
void Reset()
Resets the setup to default (empty)
Definition: CbmGeoSetupProvider.cxx:173
ECbmModuleId::kPsd
@ kPsd
Projectile spectator detector.
ECbmModuleId::kPlatform
@ kPlatform
RICH rail platform.
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmGeoSetupProvider.h
CbmMagnet
Definition: CbmMagnet.h:9
CbmGeoSetupProvider
Abstract interface class for providing the CBM detector setup description, module list,...
Definition: CbmGeoSetupProvider.h:26
CbmGeoSetup::GetModuleMap
std::map< ECbmModuleId, CbmGeoSetupModule > & GetModuleMap()
Definition: CbmGeoSetup.h:39
CbmGeoSetupProvider::RegisterSetup
void RegisterSetup()
Registers the previously loaded setup with FairRoot. Replaces the registerSetup.C macro.
Definition: CbmGeoSetupProvider.cxx:78
CbmGeoSetupProvider::GetModuleByTag
virtual CbmGeoSetupModule GetModuleByTag(ECbmModuleId moduleId, std::string tag)=0
Abstract method for constructing the module by id and tag.
CbmPlatform
Definition: CbmPlatform.h:9
CbmDefs.h