BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_SiBT_Run8.C
Go to the documentation of this file.
1/*
2 * Use this macro to create the ROOT geometry of Silicon Beam Tracker (SiBT)
3 * for the RUN-8 configuration (3 stations)
4 *
5 * Author: Baranov D.
6 * Created": 14.11.2021
7 *
8 * WARNING: all units is in cm!!!
9 *
10 */
11
12#include "TGeoMatrix.h"
13#include "TGeoVolume.h"
14#include "TString.h"
15
16// Set Parameters of SiBT --------------------------------------------------------
17const Int_t NStations = 3; // stations in the detector
18const Int_t NMaxModules = 1; // max. number of modules in a station
19
20const Double_t XStationPositions[NStations] = {0.115 /*0*/, -0.295 /*1*/, 0.177 /*2*/}; // geometry center
21const Double_t YStationPositions[NStations] = {+0.089 /*0*/, -0.046 /*1*/, -0.012 /*2*/}; // geometry center
22const Double_t ZStationPositions[NStations] = {-283.427 /*0*/, -183.225 /*1*/,
23 -84.378 /*2*/}; // side which is the nearest to the beam
24// where -283.427 = -283.097 - 0.33; -183.225 = -183.115 - 0.11; -84.378 = -84.068 - 0.31; (S.Pyaydin's scheme)
25
26//(X-Y-Z)Shifts of modules in each station
28 {0.0}, // station 0
29 {0.0}, // station 1
30 {0.0} // station 2
31};
33 {0.0}, // station 0
34 {0.0}, // station 1
35 {0.0} // station 2
36};
38 {0.0}, // station 0
39 {0.0}, // station 1
40 {0.0} // station 2
41};
42
43// Rotations of stations around Z (deg.)
45 {-0.028}, // station 0
46 {-29.817}, // station 1
47 {-59.949} // station 2
48};
49
50// Sizes of elements (cm) -------------------------------------------------------
51
52// Sensor sizes
53const Double_t XSensSize = 6.08; // cm
54const Double_t YSensSize = 6.08; // cm
55const Double_t ZSensSize = 0.018; // cm
56//------------------------------------------------------------------------------
57
58// GeoManager
60
61// media
66
67class FairGeoMedia;
68class FairGeoBuilder;
69
70TGeoVolume* CreateStation(TString station_name);
71TGeoVolume* CreateModule(TString module_name);
72
73void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
74{
75
76 // air medium
77 FairGeoMedium* mAir = geoMedia->getMedium("air");
78 if (!mAir)
79 Fatal("Main", "FairMedium air not found");
80 geoBuild->createMedium(mAir);
81 pMedAir = gGeoManager->GetMedium("air");
82 if (!pMedAir)
83 Fatal("Main", "Medium air not found");
84
85 // carbon medium
86 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
87 if (!mCarbon)
88 Fatal("Main", "FairMedium carbon not found");
89 geoBuild->createMedium(mCarbon);
90 pMedCarbon = gGeoManager->GetMedium("carbon");
91 if (!pMedCarbon)
92 Fatal("Main", "Medium carbon not found");
93
94 // fiberglass medium
95 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
96 if (!mFiberGlass)
97 Fatal("Main", "FairMedium fiberglass not found");
98 geoBuild->createMedium(mFiberGlass);
99 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
100 if (!pMedFiberGlass)
101 Fatal("Main", "Medium fiberglass not found");
102
103 // silicon medium
104 FairGeoMedium* mSilicon = geoMedia->getMedium("silicon");
105 if (!mSilicon)
106 Fatal("Main", "FairMedium silicon not found");
107 geoBuild->createMedium(mSilicon);
108 pMedSilicon = gGeoManager->GetMedium("silicon");
109 if (!pMedSilicon)
110 Fatal("Main", "Medium silicon not found");
111}
112
114{
115
116 // ---- set working directory --------------------------------------------
117 TString gPath = gSystem->Getenv("VMCWORKDIR");
118
119 // ------- Geometry file name (output) ----------------------------------
120 const TString geoDetectorName = "SiBT";
121 const TString geoDetectorVersion = "Run8";
122 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
123
124 // ---- global geometry parameters ---------------------------------------
125 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
126 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
127
128 // ------- Load media from media file ----------------------------------
129 TString medFile = gPath + "/geometry/media.geo";
130 geoFace->setMediaFile(medFile);
131 geoFace->readMedia();
132 FairGeoMedia* geoMedia = geoFace->getMedia();
133 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
134
135 DefineRequiredMedia(geoMedia, geoBuild);
136 // -------------------------------------------------------------------------
137
138 // -------------- Create geometry and top volume ------------------------
139 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
140 gGeoMan->SetName(geoDetectorName + "_geom");
141 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
142 top->SetMedium(pMedAir);
143 gGeoMan->SetTopVolume(top);
144 // gGeoMan->SetTopVisible(1);
145 // -------------------------------------------------------------------------
146
147 // Define TOP Geometry
148 TGeoVolume* SiBT = new TGeoVolumeAssembly(geoDetectorName);
149 SiBT->SetMedium(pMedAir);
150
151 for (Int_t istation = 0; istation < NStations; ++istation) {
152 // for(Int_t istation = 0; istation < 3; ++istation) {
153
154 Int_t stationNum = istation; // station number
155
156 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
157
158 TGeoVolume* module0 = CreateModule(TString("module0_") + station->GetName());
159
160 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
161 module0_transform->RotateZ(ZStationRotations[stationNum][0]);
162 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
163 ZModuleShifts[stationNum][0] + 0.5 * ZSensSize);
164
165 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
166 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
167 ZStationPositions[stationNum]);
168
169 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
170
171 SiBT->AddNode(station, 0, station_transform);
172 }
173
174 top->AddNode(SiBT, 0);
176
177 // --------------- Finish -----------------------------------------------
178 gGeoMan->CloseGeometry();
179 gGeoMan->CheckOverlaps(0.0001);
180 gGeoMan->PrintOverlaps();
181 gGeoMan->Test();
182 // gGeoMan->RestoreMasterVolume();
183
184 TFile* geoFile = new TFile(geoFileName, "RECREATE");
185 top->Write();
186 geoFile->Close();
187 top->Draw("ogl");
188}
189
191{
192
193 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
194 stationA->SetMedium(pMedAir);
195
196 return stationA;
197}
198
200{
201
202 // shapes
203 TGeoShape* moduleS = new TGeoBBox(TString("moduleS") += TString("_") + module_name, XSensSize * 0.5,
204 YSensSize * 0.5, ZSensSize * 0.5);
205
206 // volumes
207 TGeoVolume* moduleV = new TGeoVolume(TString("SiBTSensor") += TString("_") + module_name, moduleS);
208
209 // medium
210 if (pMedSilicon) {
211 moduleV->SetMedium(pMedSilicon);
212 } else
213 Fatal("Main", "Invalid medium for moduleV volumes!");
214
215 // volume visual property
216 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
217 moduleV->SetTransparency(30);
218
219 return moduleV;
220}
221//------------------------------------------------------------------------------
int Int_t
double Double_t
constexpr Bool_t kTRUE
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void SetTranslation(const TGeoTranslation &tr)
void RotateZ(Double_t angle) override
void SetVisContainers(Bool_t flag=kTRUE) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
void Draw(Option_t *option="") override
void SetTransparency(Char_t transparency=0)
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
const char * GetName() const override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
static TString Itoa(Int_t value, Int_t base)
TGeoMedium * pMedAir
const Double_t YStationPositions[NStations]
TGeoMedium * pMedCarbon
TGeoManager * gGeoMan
const Int_t NMaxModules
const Double_t ZStationPositions[NStations]
const Int_t NStations
TGeoMedium * pMedFiberGlass
const Double_t XStationPositions[NStations]
const Double_t YSensSize
const Double_t ZSensSize
const Double_t XSensSize
const Double_t ZStationRotations[NStations][NMaxModules]
TGeoMedium * pMedSilicon
TGeoVolume * CreateModule(TString module_name)
void create_rootgeom_SiBT_Run8()
TGeoVolume * CreateStation(TString station_name)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)