CbmRoot
Loading...
Searching...
No Matches
CbmSetup.h
Go to the documentation of this file.
1/* Copyright (C) 2013-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Florian Uhlig [committer] */
4
10#ifndef CBMSETUP_H
11#define CBMSETUP_H 1
12
13
14#include "CbmDefs.h"
16#include "CbmGeoSetupProvider.h"
18#include "CbmModuleList.h"
19
20#include <Logger.h>
21
22#include "TNamed.h"
23#include "TString.h"
24#include "TVector3.h"
25
26#include <map>
27
28class FairModule;
29class FairRunSim;
30class CbmFieldMap;
32
38
39// TODO: This class is a singleton, so it can be used when including
40// a ROOT macro from another one. Since this is the only reason,
41// the singleton nature shall be removed once not needed any longer.
42
43class CbmSetup : public TNamed {
44public:
47
48
53 virtual void Clear(Option_t* opt = "");
54
57 void LoadStoredSetup(CbmSetupStorable* setupIn);
58
64 void LoadSetup(const char* setupName) { fProvider->LoadSetup(setupName); }
65
70
73 std::string GetMediaFilePath() { return fProvider->GetSetup().GetMedia().GetFilePath(); }
74
77 void SetMediaFilePath(std::string filePath) { fProvider->GetSetup().GetMedia().SetFilePath(filePath); }
78
81
82
88 Bool_t GetGeoTag(ECbmModuleId moduleId, TString& tag);
89
90
96 Bool_t GetGeoFileName(ECbmModuleId moduleId, TString& fileName);
97
98
105 size_t GetHash();
106
107
111 Int_t GetNofModules() const { return fProvider->GetSetup().GetModuleMap().size(); }
112
113
115 static CbmSetup* Instance();
116
117
122 Bool_t IsActive(ECbmModuleId moduleId);
123
124
128 Bool_t IsEmpty() const { return (GetNofModules() == 0); }
129
130
132 virtual void Print(Option_t* /*opt*/ = "") const { LOG(info) << ToString(); }
133
134
138 void RemoveModule(ECbmModuleId moduleId);
139
140
150 void SetActive(ECbmModuleId moduleId, Bool_t active = kTRUE);
151
152
163 void SetField(const char* tag, Double_t scale = 1., Double_t xPos = 0., Double_t yPos = 0., Double_t zPos = 0.);
164
165
172 void SetFieldScale(Double_t scale) { fProvider->GetSetup().GetField().SetScale(scale); }
173
174
183 void SetModule(ECbmModuleId moduleId, const char* geoTag, Bool_t active = kTRUE);
184
185
187 std::string ToString() const;
188
189
193 void SetSetupSource(ECbmSetupSource setupSource);
194
195
198
199
205 {
206 delete fProvider;
207 fProvider = value;
208 };
209
210private:
212
214
215
217 CbmSetup() : TNamed("CBM Setup", "") {};
218
222
223
225};
226
227
228class CbmSetupStorable : public TNamed {
229public:
231 CbmSetupStorable() : TNamed("CBM Setup", "") {};
232
235
237 CbmSetupStorable(const CbmSetupStorable& rhs) : TNamed(rhs)
238 {
239 if (nullptr != rhs.fProviderRepo) {
241 fProviderRepo = new CbmGeoSetupRepoProvider(*(rhs.fProviderRepo));
242 }
243 else if (nullptr != fProviderDb) {
246 }
247 }
248
251 {
252 CbmGeoSetupProvider* ptrGenProv = rawSetup->GetProvider();
253 CbmGeoSetupRepoProvider* ptrRepoProv = dynamic_cast<CbmGeoSetupRepoProvider*>(ptrGenProv);
254 if (nullptr == ptrRepoProv) {
256 CbmGeoSetupDbProvider* ptrDbProv = dynamic_cast<CbmGeoSetupDbProvider*>(ptrGenProv);
257 if (nullptr != ptrDbProv) {
259 fProviderDb = new CbmGeoSetupDbProvider(*ptrDbProv);
260 }
261 }
262 else {
263 fProviderRepo = new CbmGeoSetupRepoProvider(*ptrRepoProv);
264 }
265 }
266
269
270private:
273
275};
276#endif /* CBMSETUP_H */
ECbmModuleId
Definition CbmDefs.h:39
ECbmSetupSource
Definition CbmSetup.h:34
@ kDb
Definition CbmSetup.h:36
@ kRepo
Definition CbmSetup.h:35
Setup provider with database functionality.
void SetScale(Double_t value)
std::string GetFilePath()
void SetFilePath(std::string value)
Abstract interface class for providing the CBM detector setup description, module list,...
CbmGeoSetup & GetSetup()
Direct access to underlying geometry setup representation. Allows for fine-tuning of parameters,...
void RegisterSetup()
Registers the previously loaded setup with FairRoot. Replaces the registerSetup.C macro.
virtual void LoadSetup(std::string setupTag, std::string revision="")=0
Abstract method to load the setup with a tag and revision version.
Setup provider with local (svn) repository functionality.
CbmGeoSetupField & GetField()
Definition CbmGeoSetup.h:44
CbmGeoSetupMedia & GetMedia()
Definition CbmGeoSetup.h:45
std::map< ECbmModuleId, CbmGeoSetupModule > & GetModuleMap()
Definition CbmGeoSetup.h:43
CbmSetupStorable(CbmSetup *rawSetup)
Definition CbmSetup.h:250
CbmSetupStorable(const CbmSetupStorable &rhs)
Definition CbmSetup.h:237
CbmGeoSetupDbProvider * fProviderDb
Definition CbmSetup.h:272
CbmGeoSetupRepoProvider * GetRepoProvPtr()
Definition CbmSetup.h:267
CbmGeoSetupRepoProvider * fProviderRepo
Definition CbmSetup.h:271
ClassDef(CbmSetupStorable, 1)
CbmGeoSetupDbProvider * GetDbProvPtr()
Definition CbmSetup.h:268
CbmSetup(const CbmSetup &)
std::string GetMediaFilePath()
Definition CbmSetup.h:73
void SetFieldScale(Double_t scale)
Definition CbmSetup.h:172
void SetActive(ECbmModuleId moduleId, Bool_t active=kTRUE)
Definition CbmSetup.cxx:185
Bool_t GetGeoFileName(ECbmModuleId moduleId, TString &fileName)
Definition CbmSetup.cxx:112
void SetMediaFilePath(std::string filePath)
Definition CbmSetup.h:77
void SetSetupSource(ECbmSetupSource setupSource)
Set the source the setup will be loaded from.
Definition CbmSetup.cxx:263
Bool_t IsActive(ECbmModuleId moduleId)
Definition CbmSetup.cxx:169
~CbmSetup()
Definition CbmSetup.h:46
Int_t GetNofModules() const
Definition CbmSetup.h:111
CbmSetup()
! Setup provider
Definition CbmSetup.h:217
virtual void Clear(Option_t *opt="")
Definition CbmSetup.cxx:42
virtual void Print(Option_t *="") const
Info to screen.
Definition CbmSetup.h:132
void RemoveModule(ECbmModuleId moduleId)
Definition CbmSetup.cxx:180
void SetModule(ECbmModuleId moduleId, const char *geoTag, Bool_t active=kTRUE)
Definition CbmSetup.cxx:218
size_t GetHash()
Definition CbmSetup.cxx:142
CbmGeoSetupProvider * fProvider
Definition CbmSetup.h:213
void LoadStoredSetup(CbmSetupStorable *setupIn)
Definition CbmSetup.cxx:46
CbmSetup operator=(const CbmSetup &)
std::string ToString() const
Info to string.
Definition CbmSetup.cxx:235
CbmFieldMap * CreateFieldMap()
Definition CbmSetup.cxx:66
Bool_t IsEmpty() const
Definition CbmSetup.h:128
ClassDef(CbmSetup, 3)
Bool_t GetGeoTag(ECbmModuleId moduleId, TString &tag)
Definition CbmSetup.cxx:127
static CbmSetup * Instance()
Definition CbmSetup.cxx:160
CbmGeoSetupProvider * GetProvider()
Get the geo setup provider.
Definition CbmSetup.h:197
void SetProvider(CbmGeoSetupProvider *value)
Set the geo setup provider.
Definition CbmSetup.h:204
void SetField(const char *tag, Double_t scale=1., Double_t xPos=0., Double_t yPos=0., Double_t zPos=0.)
Definition CbmSetup.cxx:203
void LoadSetup(const char *setupName)
Definition CbmSetup.h:64
static CbmSetup * fgInstance
Pointer to static instance.
Definition CbmSetup.h:211
void RegisterSetup()
Definition CbmSetup.h:69