BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_GasBeamProf_Run8.C
Go to the documentation of this file.
1/*
2 * Baranov D.
3 * 28.01.2025 (created)
4 *
5 * Use this macro to create ROOT geometry for the Gas Beam Profilometer
6 *
7 */
8
9// Detector position (x, y, z) --------------------------------------------------
12const Double_t ZDetectorPosition = +830.880;
13//------------------------------------------------------------------------------
14
15// GeoManager
17
18// media
25
26class FairGeoMedia;
27class FairGeoBuilder;
28
29// Function declarations
30TGeoVolume* CreateDetector(TString detector_name);
31
32void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
33{
34
35 // air medium
36 FairGeoMedium* mAir = geoMedia->getMedium("air");
37 if (!mAir)
38 Fatal("Main", "FairMedium air not found");
39 geoBuild->createMedium(mAir);
40 pMedAir = gGeoManager->GetMedium("air");
41 if (!pMedAir)
42 Fatal("Main", "Medium air not found");
43
44 // mylar medium
45 FairGeoMedium* mMylar = geoMedia->getMedium("mylar");
46 if (!mMylar)
47 Fatal("Main", "FairMedium mylar not found");
48 geoBuild->createMedium(mMylar);
49 pMedMylar = gGeoManager->GetMedium("mylar");
50 if (!pMedMylar)
51 Fatal("Main", "Medium mylar not found");
52
53 // fiberglass medium
54 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
55 if (!mFiberGlass)
56 Fatal("Main", "FairMedium fiberglass not found");
57 geoBuild->createMedium(mFiberGlass);
58 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
59 if (!pMedFiberGlass)
60 Fatal("Main", "Medium fiberglass not found");
61
62 // aluminium medium
63 FairGeoMedium* mAluminium = geoMedia->getMedium("aluminium");
64 if (!mAluminium)
65 Fatal("Main", "FairMedium aluminium not found");
66 geoBuild->createMedium(mAluminium);
67 pMedAluminium = gGeoManager->GetMedium("aluminium");
68 if (!pMedAluminium)
69 Fatal("Main", "Medium aluminium not found");
70
71 // arco27020 medium
72 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
73 if (!mArCO27030)
74 Fatal("Main", "FairMedium arco27030 not found");
75 geoBuild->createMedium(mArCO27030);
76 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
77 if (!pMedArCO27030)
78 Fatal("Main", "Medium arco27030 not found");
79
80 // ArC4H10_80_20 medium
81 FairGeoMedium* mArC4H10_80_20 = geoMedia->getMedium("ArC4H10_80_20");
82 if (!mArC4H10_80_20)
83 Fatal("Main", "FairMedium ArC4H10_80_20 not found");
84 geoBuild->createMedium(mArC4H10_80_20);
85 pMedArC4H10_80_20 = gGeoManager->GetMedium("ArC4H10_80_20");
87 Fatal("Main", "Medium ArC4H10_80_20 not found");
88}
89
91{
92
93 // ---- set working directory --------------------------------------------
94 TString gPath = gSystem->Getenv("VMCWORKDIR");
95
96 // ------- Geometry file name (output) ---------------------------------
97 const TString geoDetectorName = "GasBeamProf";
98 const TString geoDetectorVersion = "Run8";
99 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
100
101 // ---- global geometry parameters ---------------------------------------
102 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
103 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
104
105 // ------- Load media from media file ----------------------------------
106 TString medFile = gPath + "/geometry/media.geo";
107 geoFace->setMediaFile(medFile);
108 geoFace->readMedia();
109 FairGeoMedia* geoMedia = geoFace->getMedia();
110 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
111
112 DefineRequiredMedia(geoMedia, geoBuild);
113 // -------------------------------------------------------------------------
114
115 // -------------- Create geometry and top volume ------------------------
116 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
117 gGeoMan->SetName(geoDetectorName + "_geom");
118 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
119 top->SetMedium(pMedAir);
120 gGeoMan->SetTopVolume(top);
121 // gGeoMan->SetTopVisible(1);
122 // -------------------------------------------------------------------------
123
124 // Define TOP Geometry
125 TGeoVolume* GASBEAMPROF = new TGeoVolumeAssembly(geoDetectorName);
126 GASBEAMPROF->SetMedium(pMedAir);
127
128 TGeoVolume* detector = CreateDetector(TString("detector_GEMBeamProf"));
129
130 TGeoCombiTrans* detectorTransforms = new TGeoCombiTrans();
132
133 GASBEAMPROF->AddNode(detector, 0, detectorTransforms);
134
135 top->AddNode(GASBEAMPROF, 0);
137
138 // --------------- Finish -----------------------------------------------
139 gGeoMan->CloseGeometry();
140 gGeoMan->CheckOverlaps(0.0001);
141 gGeoMan->PrintOverlaps();
142 gGeoMan->Test();
143 // gGeoMan->RestoreMasterVolume();
144
145 TFile* geoFile = new TFile(geoFileName, "RECREATE");
146 top->Write();
147 geoFile->Close();
148 top->Draw("ogl");
149}
150//------------------------------------------------------------------------------
151
153{
154
155 TGeoVolume* detectorV = new TGeoVolumeAssembly(detector_name);
156 detectorV->SetMedium(pMedAir);
157
158 // gas ---------------------------------------------------------------------
159 Double_t gas_XSize = 20.0; // cm
160 Double_t gas_YSize = 20.0; // cm
161 Double_t gas_ZSize = 2.95; // cm
162
163 TGeoShape* gasS = new TGeoBBox("gasS", gas_XSize * 0.5, gas_YSize * 0.5, gas_ZSize * 0.5);
164
165 TGeoVolume* gasV = new TGeoVolume(TString("gasV") += TString("_") + detectorV->GetName(), gasS);
166
167 // volume medium
168 TGeoMedium* gasV_medium = pMedArC4H10_80_20;
169 if (gasV_medium) {
170 gasV->SetMedium(gasV_medium);
171 } else
172 Fatal("Main", "Invalid medium for gasV!");
173
174 // volume visual property (transparency)
175 gasV->SetLineColor(TColor::GetColor("#ff47ca"));
176 gasV->SetTransparency(50);
177
178 TGeoCombiTrans* gasV_transf[1];
179
180 gasV_transf[0] = new TGeoCombiTrans();
181 gasV_transf[0]->SetDx(0.0);
182 gasV_transf[0]->SetDy(0.0);
183 gasV_transf[0]->SetDz(0.0);
184
185 detectorV->AddNode(gasV, 0, gasV_transf[0]);
186 //--------------------------------------------------------------------------
187
188 // horizontal part of fiberglass frame --------------------------------------
189 Double_t horizFGFrame_XSize = 25.0; // cm
190 Double_t horizFGFrame_YSize = 2.5; // cm
191 Double_t horizFGFrame_ZSize = 2.95; // cm
192
193 TGeoShape* horizFGFrameS =
194 new TGeoBBox("horizFGFrameS", horizFGFrame_XSize * 0.5, horizFGFrame_YSize * 0.5, horizFGFrame_ZSize * 0.5);
195
196 TGeoVolume* horizFGFrameV =
197 new TGeoVolume(TString("horizFGFrameV") += TString("_") + detectorV->GetName(), horizFGFrameS);
198
199 // volume medium
200 TGeoMedium* horizFGFrameV_medium = pMedArC4H10_80_20;
201 if (horizFGFrameV_medium) {
202 horizFGFrameV->SetMedium(horizFGFrameV_medium);
203 } else
204 Fatal("Main", "Invalid medium for horizFGFrameV!");
205
206 // volume visual property (transparency)
207 horizFGFrameV->SetLineColor(TColor::GetColor("#ccffcc"));
208 horizFGFrameV->SetTransparency(50);
209
210 TGeoCombiTrans* horizFGFrameV_transf[2];
211
212 horizFGFrameV_transf[0] = new TGeoCombiTrans();
213 horizFGFrameV_transf[0]->SetDx(0.0);
214 horizFGFrameV_transf[0]->SetDy(gas_YSize * 0.5 + horizFGFrame_YSize * 0.5);
215 horizFGFrameV_transf[0]->SetDz(0.0);
216
217 horizFGFrameV_transf[1] = new TGeoCombiTrans();
218 horizFGFrameV_transf[1]->SetDx(0.0);
219 horizFGFrameV_transf[1]->SetDy(-(gas_YSize * 0.5 + horizFGFrame_YSize * 0.5));
220 horizFGFrameV_transf[1]->SetDz(0.0);
221
222 detectorV->AddNode(horizFGFrameV, 0, horizFGFrameV_transf[0]);
223 detectorV->AddNode(horizFGFrameV, 1, horizFGFrameV_transf[1]);
224 //--------------------------------------------------------------------------
225
226 // side part of fiberglass frame --------------------------------------------
227 Double_t sideFGFrame_XSize = 2.5; // cm
228 Double_t sideFGFrame_YSize = 20.0; // cm
229 Double_t sideFGFrame_ZSize = 2.95; // cm
230
231 TGeoShape* sideFGFrameS =
232 new TGeoBBox("sideFGFrameS", sideFGFrame_XSize * 0.5, sideFGFrame_YSize * 0.5, sideFGFrame_ZSize * 0.5);
233
234 TGeoVolume* sideFGFrameV =
235 new TGeoVolume(TString("sideFGFrameV") += TString("_") + detectorV->GetName(), sideFGFrameS);
236
237 // volume medium
238 TGeoMedium* sideFGFrameV_medium = pMedArC4H10_80_20;
239 if (sideFGFrameV_medium) {
240 sideFGFrameV->SetMedium(sideFGFrameV_medium);
241 } else
242 Fatal("Main", "Invalid medium for sideFGFrameV!");
243
244 // volume visual property (transparency)
245 sideFGFrameV->SetLineColor(TColor::GetColor("#ccffcc"));
246 sideFGFrameV->SetTransparency(50);
247
248 TGeoCombiTrans* sideFGFrameV_transf[2];
249
250 sideFGFrameV_transf[0] = new TGeoCombiTrans();
251 sideFGFrameV_transf[0]->SetDx(gas_XSize * 0.5 + sideFGFrame_XSize * 0.5);
252 sideFGFrameV_transf[0]->SetDy(0.0);
253 sideFGFrameV_transf[0]->SetDz(0.0);
254
255 sideFGFrameV_transf[1] = new TGeoCombiTrans();
256 sideFGFrameV_transf[1]->SetDx(-(gas_XSize * 0.5 + sideFGFrame_XSize * 0.5));
257 sideFGFrameV_transf[1]->SetDy(0.0);
258 sideFGFrameV_transf[1]->SetDz(0.0);
259
260 detectorV->AddNode(sideFGFrameV, 0, sideFGFrameV_transf[0]);
261 detectorV->AddNode(sideFGFrameV, 1, sideFGFrameV_transf[1]);
262 //--------------------------------------------------------------------------
263
264 // mylar film ---------------------------------------------------------------
265 Double_t mylarFilm_XSize = 24.0; // cm
266 Double_t mylarFilm_YSize = 24.0; // cm
267 Double_t mylarFilm_ZSize = 0.005; // cm
268
269 TGeoShape* mylarFilmS =
270 new TGeoBBox("mylarFilmS", mylarFilm_XSize * 0.5, mylarFilm_YSize * 0.5, mylarFilm_ZSize * 0.5);
271
272 TGeoVolume* mylarFilmV = new TGeoVolume(TString("mylarFilmV") += TString("_") + detectorV->GetName(), mylarFilmS);
273
274 // volume medium
275 TGeoMedium* mylarFilmV_medium = pMedMylar;
276 if (mylarFilmV_medium) {
277 mylarFilmV->SetMedium(mylarFilmV_medium);
278 } else
279 Fatal("Main", "Invalid medium for mylarFilmV!");
280
281 // volume visual property (transparency)
282 mylarFilmV->SetLineColor(TColor::GetColor("#00e6e6"));
283 mylarFilmV->SetTransparency(50);
284
285 TGeoCombiTrans* mylarFilmV_transf[2];
286
287 mylarFilmV_transf[0] = new TGeoCombiTrans();
288 mylarFilmV_transf[0]->SetDx(0.0);
289 mylarFilmV_transf[0]->SetDy(0.0);
290 mylarFilmV_transf[0]->SetDz(gas_ZSize * 0.5 + mylarFilm_ZSize * 0.5);
291
292 mylarFilmV_transf[1] = new TGeoCombiTrans();
293 mylarFilmV_transf[1]->SetDx(0.0);
294 mylarFilmV_transf[1]->SetDy(0.0);
295 mylarFilmV_transf[1]->SetDz(-(gas_ZSize * 0.5 + mylarFilm_ZSize * 0.5));
296
297 detectorV->AddNode(mylarFilmV, 0, mylarFilmV_transf[0]);
298 detectorV->AddNode(mylarFilmV, 1, mylarFilmV_transf[1]);
299 //--------------------------------------------------------------------------
300
301 // horizontal part of aluminium frame ---------------------------------------
302 Double_t horizAlumFrame_XSize = 27.0; // cm
303 Double_t horizAlumFrame_YSize = 2.0; // cm
304 Double_t horizAlumFrame_ZSize = 1.4; // cm
305
306 TGeoShape* horizAlumFrameS = new TGeoBBox("horizAlumFrameS", horizAlumFrame_XSize * 0.5, horizAlumFrame_YSize * 0.5,
307 horizAlumFrame_ZSize * 0.5);
308
309 TGeoVolume* horizAlumFrameV =
310 new TGeoVolume(TString("horizAlumFrameV") += TString("_") + detectorV->GetName(), horizAlumFrameS);
311
312 // volume medium
313 TGeoMedium* horizAlumFrameV_medium = pMedAluminium;
314 if (horizAlumFrameV_medium) {
315 horizAlumFrameV->SetMedium(horizAlumFrameV_medium);
316 } else
317 Fatal("Main", "Invalid medium for horizAlumFrameV!");
318
319 // volume visual property (transparency)
320 horizAlumFrameV->SetLineColor(TColor::GetColor("#99ff99"));
321 horizAlumFrameV->SetTransparency(50);
322
323 TGeoCombiTrans* horizAlumFrameV_transf[4];
324
325 horizAlumFrameV_transf[0] = new TGeoCombiTrans();
326 horizAlumFrameV_transf[0]->SetDx(-(horizAlumFrame_XSize - horizFGFrame_XSize) * 0.5);
327 horizAlumFrameV_transf[0]->SetDy((gas_YSize * 0.5 + horizFGFrame_YSize) - horizAlumFrame_YSize * 0.5);
328 horizAlumFrameV_transf[0]->SetDz(gas_ZSize * 0.5 + mylarFilm_ZSize + horizAlumFrame_ZSize * 0.5);
329
330 horizAlumFrameV_transf[1] = new TGeoCombiTrans();
331 horizAlumFrameV_transf[1]->SetDx(-(horizAlumFrame_XSize - horizFGFrame_XSize) * 0.5);
332 horizAlumFrameV_transf[1]->SetDy(-((gas_YSize * 0.5 + horizFGFrame_YSize) - horizAlumFrame_YSize * 0.5));
333 horizAlumFrameV_transf[1]->SetDz(gas_ZSize * 0.5 + mylarFilm_ZSize + horizAlumFrame_ZSize * 0.5);
334
335 horizAlumFrameV_transf[2] = new TGeoCombiTrans();
336 horizAlumFrameV_transf[2]->SetDx(-(horizAlumFrame_XSize - horizFGFrame_XSize) * 0.5);
337 horizAlumFrameV_transf[2]->SetDy((gas_YSize * 0.5 + horizFGFrame_YSize) - horizAlumFrame_YSize * 0.5);
338 horizAlumFrameV_transf[2]->SetDz(-(gas_ZSize * 0.5 + mylarFilm_ZSize + horizAlumFrame_ZSize * 0.5));
339
340 horizAlumFrameV_transf[3] = new TGeoCombiTrans();
341 horizAlumFrameV_transf[3]->SetDx(-(horizAlumFrame_XSize - horizFGFrame_XSize) * 0.5);
342 horizAlumFrameV_transf[3]->SetDy(-((gas_YSize * 0.5 + horizFGFrame_YSize) - horizAlumFrame_YSize * 0.5));
343 horizAlumFrameV_transf[3]->SetDz(-(gas_ZSize * 0.5 + mylarFilm_ZSize + horizAlumFrame_ZSize * 0.5));
344
345 detectorV->AddNode(horizAlumFrameV, 0, horizAlumFrameV_transf[0]);
346 detectorV->AddNode(horizAlumFrameV, 1, horizAlumFrameV_transf[1]);
347 detectorV->AddNode(horizAlumFrameV, 2, horizAlumFrameV_transf[2]);
348 detectorV->AddNode(horizAlumFrameV, 3, horizAlumFrameV_transf[3]);
349 //--------------------------------------------------------------------------
350
351 // side part of aluminium frame ---------------------------------------------
352 Double_t sideAlumFrame_XSize = 2.0; // cm
353 Double_t sideAlumFrame_YSize = 21.0; // cm
354 Double_t sideAlumFrame_ZSize = 1.4; // cm
355
356 TGeoShape* sideAlumFrameS =
357 new TGeoBBox("sideAlumFrameS", sideAlumFrame_XSize * 0.5, sideAlumFrame_YSize * 0.5, sideAlumFrame_ZSize * 0.5);
358
359 TGeoVolume* sideAlumFrameV =
360 new TGeoVolume(TString("sideAlumFrameV") += TString("_") + detectorV->GetName(), sideAlumFrameS);
361
362 // volume medium
363 TGeoMedium* sideAlumFrameV_medium = pMedAluminium;
364 if (sideAlumFrameV_medium) {
365 sideAlumFrameV->SetMedium(sideAlumFrameV_medium);
366 } else
367 Fatal("Main", "Invalid medium for sideAlumFrameV!");
368
369 // volume visual property (transparency)
370 sideAlumFrameV->SetLineColor(TColor::GetColor("#99ff99"));
371 sideAlumFrameV->SetTransparency(50);
372
373 TGeoCombiTrans* sideAlumFrameV_transf[4];
374
375 sideAlumFrameV_transf[0] = new TGeoCombiTrans();
376 sideAlumFrameV_transf[0]->SetDx((gas_XSize * 0.5 + sideFGFrame_XSize) - sideAlumFrame_XSize * 0.5);
377 sideAlumFrameV_transf[0]->SetDy(0.0);
378 sideAlumFrameV_transf[0]->SetDz(gas_ZSize * 0.5 + mylarFilm_ZSize + sideAlumFrame_ZSize * 0.5);
379
380 sideAlumFrameV_transf[1] = new TGeoCombiTrans();
381 sideAlumFrameV_transf[1]->SetDx(-((gas_XSize * 0.5 + sideFGFrame_XSize) - sideAlumFrame_XSize * 0.5));
382 sideAlumFrameV_transf[1]->SetDy(0.0);
383 sideAlumFrameV_transf[1]->SetDz(gas_ZSize * 0.5 + mylarFilm_ZSize + sideAlumFrame_ZSize * 0.5);
384
385 sideAlumFrameV_transf[2] = new TGeoCombiTrans();
386 sideAlumFrameV_transf[2]->SetDx((gas_XSize * 0.5 + sideFGFrame_XSize) - sideAlumFrame_XSize * 0.5);
387 sideAlumFrameV_transf[2]->SetDy(0.0);
388 sideAlumFrameV_transf[2]->SetDz(-(gas_ZSize * 0.5 + mylarFilm_ZSize + sideAlumFrame_ZSize * 0.5));
389
390 sideAlumFrameV_transf[3] = new TGeoCombiTrans();
391 sideAlumFrameV_transf[3]->SetDx(-((gas_XSize * 0.5 + sideFGFrame_XSize) - sideAlumFrame_XSize * 0.5));
392 sideAlumFrameV_transf[3]->SetDy(0.0);
393 sideAlumFrameV_transf[3]->SetDz(-(gas_ZSize * 0.5 + mylarFilm_ZSize + sideAlumFrame_ZSize * 0.5));
394
395 detectorV->AddNode(sideAlumFrameV, 0, sideAlumFrameV_transf[0]);
396 detectorV->AddNode(sideAlumFrameV, 1, sideAlumFrameV_transf[1]);
397 detectorV->AddNode(sideAlumFrameV, 2, sideAlumFrameV_transf[2]);
398 detectorV->AddNode(sideAlumFrameV, 3, sideAlumFrameV_transf[3]);
399 //--------------------------------------------------------------------------
400
401 // aluminium PCB plank ------------------------------------------------------
402 Double_t pcbPlank_XSize = 0.4; // cm
403 Double_t pcbPlank_YSize = 25.0; // cm
404 Double_t pcbPlank_ZSize = 5.8; // cm
405
406 TGeoShape* pcbPlankS = new TGeoBBox("pcbPlankS", pcbPlank_XSize * 0.5, pcbPlank_YSize * 0.5, pcbPlank_ZSize * 0.5);
407
408 TGeoVolume* pcbPlankV = new TGeoVolume(TString("pcbPlankV") += TString("_") + detectorV->GetName(), pcbPlankS);
409
410 // volume medium
411 TGeoMedium* pcbPlankV_medium = pMedAluminium;
412 if (pcbPlankV_medium) {
413 pcbPlankV->SetMedium(pcbPlankV_medium);
414 } else
415 Fatal("Main", "Invalid medium for pcbPlankV!");
416
417 // volume visual property (transparency)
418 pcbPlankV->SetLineColor(TColor::GetColor("#99ff99"));
419 pcbPlankV->SetTransparency(50);
420
421 TGeoCombiTrans* pcbPlankV_transf[1];
422
423 pcbPlankV_transf[0] = new TGeoCombiTrans();
424 pcbPlankV_transf[0]->SetDx(
425 -(horizAlumFrame_XSize * 0.5 + (horizAlumFrame_XSize - horizFGFrame_XSize) * 0.5 + pcbPlank_XSize * 0.5));
426 pcbPlankV_transf[0]->SetDy(0.0);
427 pcbPlankV_transf[0]->SetDz(0.0);
428
429 detectorV->AddNode(pcbPlankV, 0, pcbPlankV_transf[0]);
430 //--------------------------------------------------------------------------
431
432 return detectorV;
433}
434//------------------------------------------------------------------------------
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 SetDy(Double_t dy) override
void SetDx(Double_t dx) override
void SetTranslation(const TGeoTranslation &tr)
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)
TGeoMedium * pMedAir
TGeoManager * gGeoMan
TGeoMedium * pMedArCO27030
TGeoMedium * pMedFiberGlass
const Double_t ZDetectorPosition
TGeoMedium * pMedMylar
TGeoVolume * CreateDetector(TString detector_name)
void create_rootgeom_GasBeamProf_Run8()
const Double_t YDetectorPosition
TGeoMedium * pMedArC4H10_80_20
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
TGeoMedium * pMedAluminium
const Double_t XDetectorPosition