CbmRoot
Loading...
Searching...
No Matches
RichGeoMaterials.h
Go to the documentation of this file.
1/* Copyright (C) 2022-2024 UGiessen/GSI, Giessen/Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Semen Lebedev [committer], Simon Neuhaus */
4
5#ifndef RICH_GEO_MATERIALS
6#define RICH_GEO_MATERIALS
7
8#include "FairGeoBuilder.h"
9#include "FairGeoInterface.h"
10#include "FairGeoLoader.h"
11#include "FairGeoMedia.h"
12#include "FairGeoMedium.h"
13#include "Logger.h"
14
15#include "TGeoManager.h"
16#include "TGeoMedium.h"
17#include "TSystem.h"
18
19#include <map>
20#include <string>
21
22
24public:
25 void Init()
26 {
27 LOG(info) << "RichGeoMaterials init materials";
28
29 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
30 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
31 std::string mediaPath = std::string(gSystem->Getenv("VMCWORKDIR")) + "/geometry/media.geo";
32 geoFace->setMediaFile(mediaPath.c_str());
33 geoFace->readMedia();
34
35 fGeoMedia = geoFace->getMedia();
36 fGeoBuild = geoLoad->getGeoBuilder();
37
38 fMediums["aluminium"] = InitMedium("aluminium");
39 fMediums["CsI"] = InitMedium("CsI");
40 fMediums["RICHgas_CO2_dis"] = InitMedium("RICHgas_CO2_dis");
41 fMediums["vacuum"] = InitMedium("vacuum");
42 fMediums["RICHglass"] = InitMedium("RICHglass");
43 fMediums["kapton"] = InitMedium("kapton");
44 fMediums["iron"] = InitMedium("iron");
45 fMediums["RICHgas_CO2_dis+"] = InitMedium("RICHgas_CO2_dis+");
46 fMediums["Polycarbonat"] = InitMedium("RICH_Polycarbonat");
47 fMediums["carbon"] = InitMedium("carbon");
48 }
49
50 TGeoMedium* GetMedium(const std::string& name)
51 {
52 if (fMediums.find(name) == fMediums.end()) LOG(fatal) << "RichGeoMaterials::GetMedium " << name << " not found";
53 return fMediums[name];
54 }
55
56private:
57 std::map<std::string, TGeoMedium*> fMediums;
58
59 FairGeoMedia* fGeoMedia = nullptr;
60 FairGeoBuilder* fGeoBuild = nullptr;
61
62 TGeoMedium* InitMedium(const std::string& name)
63 {
64 FairGeoMedium* fairMedium = fGeoMedia->getMedium(name.c_str());
65 if (fairMedium == nullptr) LOG(fatal) << "RichGeoMaterials FairMedium " << name << " not found";
66 fGeoBuild->createMedium(fairMedium);
67 TGeoMedium* rootMedium = gGeoManager->GetMedium(name.c_str());
68 if (rootMedium == nullptr) LOG(fatal) << "RichGeoMaterials Medium " << name << " not found";
69 return rootMedium;
70 }
71};
72
73#endif
TGeoMedium * GetMedium(const std::string &name)
FairGeoMedia * fGeoMedia
TGeoMedium * InitMedium(const std::string &name)
std::map< std::string, TGeoMedium * > fMediums
FairGeoBuilder * fGeoBuild