BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_SiBT_Run8_detailed.C
Go to the documentation of this file.
1/*
2 * Use this macro to create detailed ROOT geometry of Silicon Beam Tracker (SiBT)
3 * for the RUN-8 configuration (3 stations)
4 *
5 * Author: Baranov D.
6 * Created: 10.11.2022
7 *
8 *
9 * WARNING: all units is in cm!!!
10 *
11 */
12
13#include "TGeoMatrix.h"
14#include "TGeoVolume.h"
15#include "TString.h"
16
17// Set Parameters of SiBT --------------------------------------------------------
18const Int_t NStations = 3; // stations in the detector
19const Int_t NMaxModules = 1; // max. number of modules in a station
20
21const Double_t XStationPositions[NStations] = {0.115 /*0*/, -0.295 /*1*/, 0.177 /*2*/}; // geometry center
22const Double_t YStationPositions[NStations] = {+0.089 /*0*/, -0.046 /*1*/, -0.012 /*2*/}; // geometry center
23const Double_t ZStationPositions[NStations] = {-283.427 /*0*/, -183.225 /*1*/,
24 -84.378 /*2*/}; // side which is the nearest to the beam
25// where -283.427 = -283.097 - 0.33; -183.225 = -183.115 - 0.11; -84.378 = -84.068 - 0.31; (S.Pyaydin's scheme)
26
27//(X-Y-Z)Shifts of modules in each station
29 {0.0}, // station 0
30 {0.0}, // station 1
31 {0.0} // station 2
32};
34 {0.0}, // station 0
35 {0.0}, // station 1
36 {0.0} // station 2
37};
39 {0.0}, // station 0
40 {0.0}, // station 1
41 {0.0} // station 2
42};
43
44// Rotations of stations around Z (deg.)
46 {-0.028}, // station 0
47 {-29.817}, // station 1
48 {-59.949} // station 2
49};
50
51// Sizes of elements (cm) -------------------------------------------------------
52
53// Sensor sizes
54const Double_t XSensSize = 6.08; // cm
55const Double_t YSensSize = 6.08; // cm
56const Double_t ZSensSize = 0.018; // cm
57//------------------------------------------------------------------------------
58
59// GeoManager
61
62// media
69
70class FairGeoMedia;
71class FairGeoBuilder;
72
73TGeoVolume* CreateStation(TString station_name);
74TGeoVolume* CreateModule(TString module_name);
76
77void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
78{
79
80 // air medium
81 FairGeoMedium* mAir = geoMedia->getMedium("air");
82 if (!mAir)
83 Fatal("Main", "FairMedium air not found");
84 geoBuild->createMedium(mAir);
85 pMedAir = gGeoManager->GetMedium("air");
86 if (!pMedAir)
87 Fatal("Main", "Medium air not found");
88
89 // carbon medium
90 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
91 if (!mCarbon)
92 Fatal("Main", "FairMedium carbon not found");
93 geoBuild->createMedium(mCarbon);
94 pMedCarbon = gGeoManager->GetMedium("carbon");
95 if (!pMedCarbon)
96 Fatal("Main", "Medium carbon not found");
97
98 // fiberglass medium
99 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
100 if (!mFiberGlass)
101 Fatal("Main", "FairMedium fiberglass not found");
102 geoBuild->createMedium(mFiberGlass);
103 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
104 if (!pMedFiberGlass)
105 Fatal("Main", "Medium fiberglass not found");
106
107 // silicon medium
108 FairGeoMedium* mSilicon = geoMedia->getMedium("silicon");
109 if (!mSilicon)
110 Fatal("Main", "FairMedium silicon not found");
111 geoBuild->createMedium(mSilicon);
112 pMedSilicon = gGeoManager->GetMedium("silicon");
113 if (!pMedSilicon)
114 Fatal("Main", "Medium silicon not found");
115
116 // aluminium medium
117 FairGeoMedium* mAluminium = geoMedia->getMedium("aluminium");
118 if (!mAluminium)
119 Fatal("Main", "FairMedium aluminium not found");
120 geoBuild->createMedium(mAluminium);
121 pMedAluminium = gGeoManager->GetMedium("aluminium");
122 if (!pMedAluminium)
123 Fatal("Main", "Medium aluminium not found");
124
125 // steel medium
126 FairGeoMedium* mSteel = geoMedia->getMedium("steel");
127 if (!mSteel)
128 Fatal("Main", "FairMedium steel not found");
129 geoBuild->createMedium(mSteel);
130 pMedSteel = gGeoManager->GetMedium("steel");
131 if (!pMedSteel)
132 Fatal("Main", "Medium steel not found");
133}
134
136{
137
138 // ---- set working directory --------------------------------------------
139 TString gPath = gSystem->Getenv("VMCWORKDIR");
140
141 // ------- Geometry file name (output) ----------------------------------
142 const TString geoDetectorName = "SiBT";
143 const TString geoDetectorVersion = "Run8_detailed";
144 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
145
146 // ---- global geometry parameters ---------------------------------------
147 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
148 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
149
150 // ------- Load media from media file ----------------------------------
151 TString medFile = gPath + "/geometry/media.geo";
152 geoFace->setMediaFile(medFile);
153 geoFace->readMedia();
154 FairGeoMedia* geoMedia = geoFace->getMedia();
155 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
156
157 DefineRequiredMedia(geoMedia, geoBuild);
158 // -------------------------------------------------------------------------
159
160 // -------------- Create geometry and top volume ------------------------
161 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
162 gGeoMan->SetName(geoDetectorName + "_geom");
163 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
164 top->SetMedium(pMedAir);
165 gGeoMan->SetTopVolume(top);
166 // gGeoMan->SetTopVisible(1);
167 // -------------------------------------------------------------------------
168
169 // Define TOP Geometry
170 TGeoVolume* SiBT = new TGeoVolumeAssembly(geoDetectorName);
171 SiBT->SetMedium(pMedAir);
172
173 for (Int_t istation = 0; istation < NStations; ++istation) {
174 // for(Int_t istation = 0; istation < 1; ++istation) {
175
176 Int_t stationNum = istation; // station number
177
178 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10));
179
180 TGeoVolume* module0 = CreateModule(TString("module0_") + station->GetName());
181
182 TGeoVolume* vacuumTube = CreateVacuumTube(TString("vacuumTube_") + station->GetName());
183
184 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
185 module0_transform->RotateZ(ZStationRotations[stationNum][0]);
186 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
187 ZModuleShifts[stationNum][0] + 0.5 * ZSensSize);
188
189 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
190 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
191 ZStationPositions[stationNum]);
192
193 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
194 station->AddNode(vacuumTube, 0, new TGeoCombiTrans(*module0_transform));
195
196 SiBT->AddNode(station, 0, station_transform);
197 }
198
199 top->AddNode(SiBT, 0);
201
202 // --------------- Finish -----------------------------------------------
203 gGeoMan->CloseGeometry();
204 gGeoMan->CheckOverlaps(0.0001);
205 gGeoMan->PrintOverlaps();
206 gGeoMan->Test();
207 // gGeoMan->RestoreMasterVolume();
208
209 TFile* geoFile = new TFile(geoFileName, "RECREATE");
210 top->Write();
211 geoFile->Close();
212 top->Draw("ogl");
213}
214
216{
217
218 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
219 stationA->SetMedium(pMedAir);
220
221 return stationA;
222}
223
225{
226
227 // shapes
228 TGeoShape* moduleS = new TGeoBBox(TString("moduleS") += TString("_") + module_name, XSensSize * 0.5,
229 YSensSize * 0.5, ZSensSize * 0.5);
230
231 // volumes
232 TGeoVolume* moduleV = new TGeoVolume(TString("SiBTSensor") += TString("_") + module_name, moduleS);
233
234 // medium
235 if (pMedSilicon) {
236 moduleV->SetMedium(pMedSilicon);
237 } else
238 Fatal("Main", "Invalid medium for moduleV volumes!");
239
240 // volume visual property
241 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
242 moduleV->SetTransparency(30);
243
244 return moduleV;
245}
246
248{
249
250 // shapes
251 TGeoShape* vacTubeS =
252 new TGeoTube(TString("vacTubeS") += TString("_") + vacTube_name, 21.3 * 0.5, 21.9 * 0.5, 19.6 * 0.5);
253 TGeoShape* vacTubeHoleS =
254 new TGeoTube(TString("vacTubeHoleS") += TString("_") + vacTube_name, 0.0, 15.905 * 0.5, 10. * 0.5);
255
256 TGeoShape* sideTubeS =
257 new TGeoTube(TString("sideTubeS") += TString("_") + vacTube_name, 15.3 * 0.5, 15.9 * 0.5, 15.0 * 0.5);
258 TGeoShape* sideTubeCutS =
259 new TGeoTube(TString("sideTubeCutS") += TString("_") + vacTube_name, 0.0, 21.3 * 0.5, 19.6 * 0.5);
260
261 TGeoShape* vacTubeFlangeS =
262 new TGeoTube(TString("vacTubeFlangeS") += TString("_") + vacTube_name, 21.9 * 0.5, 24.0 * 0.5, 1.2 * 0.5);
263 TGeoShape* sideTubeFlangeS =
264 new TGeoTube(TString("sideTubeFlangeS") += TString("_") + vacTube_name, 15.9 * 0.5, 18.0 * 0.5, 1.2 * 0.5);
265
266 TGeoCombiTrans* vacTubeHole_transf = new TGeoCombiTrans();
267 vacTubeHole_transf->SetName(TString("vacTubeHole_transf") += TString("_") + vacTube_name);
268 vacTubeHole_transf->RotateY(90.0);
269 vacTubeHole_transf->SetDx(-10.0);
270 vacTubeHole_transf->SetDy(0.0);
271 vacTubeHole_transf->SetDz(0.0);
272 vacTubeHole_transf->RegisterYourself();
273
274 TGeoCompositeShape* vacTubeWithHoleS = new TGeoCompositeShape();
275 vacTubeWithHoleS->SetName(TString("vacTubeWithHoleS") += TString("_") + vacTube_name);
276 {
277 TString expression = "vacTubeS";
278 expression += TString("_") + vacTube_name;
279 expression += "-vacTubeHoleS";
280 expression += TString("_") + vacTube_name;
281 expression += ":vacTubeHole_transf";
282 expression += TString("_") + vacTube_name;
283 vacTubeWithHoleS->MakeNode(expression);
284 vacTubeWithHoleS->ComputeBBox(); // need to compute a bounding box
285 }
286
287 TGeoCombiTrans* sideTube_transf = new TGeoCombiTrans();
288 sideTube_transf->SetName(TString("sideTube_transf") += TString("_") + vacTube_name);
289 sideTube_transf->RotateY(90.0);
290 sideTube_transf->SetTranslation(-15.0 * 0.5, 0.0, 0.0);
291 sideTube_transf->RegisterYourself();
292
293 TGeoCompositeShape* sideTubeWithCutS = new TGeoCompositeShape();
294 sideTubeWithCutS->SetName(TString("sideTubeWithCutS") += TString("_") + vacTube_name);
295 {
296 TString expression = "sideTubeS";
297 expression += TString("_") + vacTube_name;
298 expression += ":sideTube_transf";
299 expression += TString("_") + vacTube_name;
300 expression += "-sideTubeCutS";
301 expression += TString("_") + vacTube_name;
302 sideTubeWithCutS->MakeNode(expression);
303 sideTubeWithCutS->ComputeBBox(); // need to compute a bounding box
304 }
305
306 // volumes
307 // frame volumes
308 TGeoVolumeAssembly* vacTubeBoxV = new TGeoVolumeAssembly(vacTube_name);
309 TGeoVolume* vacTubeWithHoleV =
310 new TGeoVolume(TString("vacTubeWithHoleV") += TString("_") + vacTube_name, vacTubeWithHoleS);
311 TGeoVolume* sideTubeWithCutV =
312 new TGeoVolume(TString("sideTubeWithCutV") += TString("_") + vacTube_name, sideTubeWithCutS);
313 TGeoVolume* vacTubeFlangeV =
314 new TGeoVolume(TString("vacTubeFlangeV") += TString("_") + vacTube_name, vacTubeFlangeS);
315 TGeoVolume* sideTubeFlangeV =
316 new TGeoVolume(TString("sideTubeFlangeV") += TString("_") + vacTube_name, sideTubeFlangeS);
317
318 // volume medium
319 TGeoMedium* vacTubeWithHoleV_medium = nullptr;
320 if (vacTube_name.Contains("station0") || vacTube_name.Contains("station1"))
321 vacTubeWithHoleV_medium = pMedSteel;
322 if (vacTube_name.Contains("station2"))
323 vacTubeWithHoleV_medium = pMedAluminium;
324 if (vacTubeWithHoleV_medium) {
325 vacTubeWithHoleV->SetMedium(vacTubeWithHoleV_medium);
326 sideTubeWithCutV->SetMedium(vacTubeWithHoleV_medium);
327 vacTubeFlangeV->SetMedium(vacTubeWithHoleV_medium);
328 sideTubeFlangeV->SetMedium(vacTubeWithHoleV_medium);
329 } else
330 Fatal("Main", "Invalid medium for vacTubeWithHoleV!");
331
332 // volume visual property (transparency)
333 vacTubeWithHoleV->SetLineColor(TColor::GetColor("#ffcccc"));
334 vacTubeWithHoleV->SetTransparency(0);
335 sideTubeWithCutV->SetLineColor(TColor::GetColor("#ffcccc"));
336 vacTubeFlangeV->SetLineColor(TColor::GetColor("#ffcccc"));
337 sideTubeFlangeV->SetLineColor(TColor::GetColor("#ffcccc"));
338
339 // part positions in the vacuum tube box
340 TGeoCombiTrans* vacTubeFlangeV_transf[2];
341
342 vacTubeFlangeV_transf[0] = new TGeoCombiTrans();
343 vacTubeFlangeV_transf[0]->SetTranslation(0.0, 0.0, -19.6 * 0.5 + 1.2 * 0.5);
344
345 vacTubeFlangeV_transf[1] = new TGeoCombiTrans();
346 vacTubeFlangeV_transf[1]->SetTranslation(0.0, 0.0, +19.6 * 0.5 - 1.2 * 0.5);
347
348 TGeoCombiTrans* sideTubeFlangeV_transf[1];
349
350 sideTubeFlangeV_transf[0] = new TGeoCombiTrans();
351 sideTubeFlangeV_transf[0]->RotateY(90.0);
352 sideTubeFlangeV_transf[0]->SetTranslation(-15.0 + 1.2 * 0.5, 0.0, 0.0);
353
354 vacTubeBoxV->AddNode(vacTubeWithHoleV, 0, new TGeoCombiTrans());
355 vacTubeBoxV->AddNode(sideTubeWithCutV, 0, new TGeoCombiTrans());
356 vacTubeBoxV->AddNode(vacTubeFlangeV, 0, vacTubeFlangeV_transf[0]);
357 vacTubeBoxV->AddNode(vacTubeFlangeV, 1, vacTubeFlangeV_transf[1]);
358 vacTubeBoxV->AddNode(sideTubeFlangeV, 0, sideTubeFlangeV_transf[0]);
359
360 return vacTubeBoxV;
361}
362//------------------------------------------------------------------------------
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 SetDz(Double_t dz) override
void RegisterYourself() override
void RotateY(Double_t angle) override
void SetDy(Double_t dy) override
void SetDx(Double_t dx) override
void SetTranslation(const TGeoTranslation &tr)
void RotateZ(Double_t angle) override
void ComputeBBox() override
void MakeNode(const char *expression)
TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="") 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 void SetName(const char *name)
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)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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
TGeoMedium * pMedSteel
TGeoMedium * pMedAluminium
const Double_t ZStationRotations[NStations][NMaxModules]
TGeoMedium * pMedSilicon
TGeoVolume * CreateModule(TString module_name)
void create_rootgeom_SiBT_Run8_detailed()
TGeoVolume * CreateVacuumTube(TString vacTube_name)
TGeoVolume * CreateStation(TString station_name)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)