BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_GEMS_Run9.C
Go to the documentation of this file.
1/*
2 * Basic ROOT geometry for the configuration of GEM detector in RUN-9
3 * (only sensor volumes)
4 *
5 * Author: Baranov D.
6 * Date: 07.04.2025 (created)
7 * 22.04.2025 (st.3 z-pos. corrected)
8 */
9
10// Set Parameters of GEMS -------------------------------------------------------
11const Int_t NStations = 8; // stations in the detector
12const Int_t NMaxModules = 4; // max. number of modules in a station
13
14// X-position of the hole center for the plane closest to the target (in a station)
16 +1.419, // 0 st. (M15)
17 +2.529, // 1 st. (M10)
18 +3.408, // 2 st. (M14)
19 +4.697, // 3 st. (M8)
20 +6.335, // 4 st. (M16)
21 +8.213, // 5 st. (M7)
22 +9.784, // 6 st. (M12)
23 +50.494 // 7 st. (small GEM)
24};
25
26// Y-position of the hole center for the plane closest to the target (in a station)
28 -0.032, // 0 st. (M15)
29 +0.123, // 1 st. (M10)
30 +0.026, // 2 st. (M14)
31 -0.013, // 3 st. (M8),
32 -0.026, // 4 st. (M16)
33 +0.058, // 5 st. (M7)
34 -0.048, // 6 st. (M12)
35 -0.186 // 7 st. (small GEM)
36};
37
38// Z-position of gas volume for the plane closest to the target (in a station)
40 +61.107, // 0 st. (M15)
41 +92.313, // 1 st. (M10)
42 +123.541, // 2 st. (M14)
43 +154.778, // 3 st. (M8)
44 +185.458, // 4 st. (M16)
45 +217.141, // 5 st. (M7)
46 +248.367, // 6 st. (M12)
47 +792.532 // 7 st. (small GEM)
48};
49
50// Shifts for the second plane in a station relative to the closest half-plane
52 +0.111, // 0 st. (M6)
53 +0.142, // 1 st. (M13)
54 +0.081, // 2 st. (M11)
55 +0.100, // 3 st. (M18)
56 +0.092, // 4 st. (M5)
57 +0.113, // 5 st. (M17)
58 +0.155, // 6 st. (M9)
59 +0.0 // 7 st. (small GEM)
60};
62 +0.008, // 0 st. (M6)
63 -0.100, // 1 st. (M13)
64 +0.048, // 2 st. (M11)
65 +0.042, // 3 st. (M18)
66 +0.109, // 4 st. (M5)
67 -0.089, // 5 st. (M17)
68 +0.168, // 6 st. (M9)
69 +0.0 // 7 st. (small GEM)
70};
72 +4.691, // 0 st. (M6)
73 +4.158, // 1 st. (M13)
74 +4.672, // 2 st. (M11)
75 +4.124, // 3 st. (M18)
76 +4.683, // 4 st. (M5)
77 +3.995, // 5 st. (M17)
78 +4.063, // 6 st. (M9)
79 +0.0 // 7 st. (small GEM)
80};
81
82//(X-Y-Z)Shifts of modules in each station
84 {163.2 * 0.25 + xShift[0], -163.2 * 0.25 + xShift[0], // 0 st. (upper h. plane)
85 163.2 * 0.25, -163.2 * 0.25}, // 0 st. (lower h. plane)
86
87 {163.2 * 0.25, -163.2 * 0.25, // 1 st. (upper h. plane)
88 163.2 * 0.25 + xShift[1], -163.2 * 0.25 + xShift[1]}, // 1 st. (lower h. plane)
89
90 {163.2 * 0.25 + xShift[2], -163.2 * 0.25 + xShift[2], // 2 st. (upper h. plane)
91 163.2 * 0.25, -163.2 * 0.25}, // 2 st. (lower h. plane)
92
93 {163.2 * 0.25, -163.2 * 0.25, // 3 st. (upper h. plane)
94 163.2 * 0.25 + xShift[3], -163.2 * 0.25 + xShift[3]}, // 3 st. (lower h. plane)
95
96 {163.2 * 0.25 + xShift[4], -163.2 * 0.25 + xShift[4], // 4 st. (upper h. plane)
97 163.2 * 0.25, -163.2 * 0.25}, // 4 st. (lower h. plane)
98
99 {163.2 * 0.25, -163.2 * 0.25, // 5 st. (upper h. plane)
100 163.2 * 0.25 + xShift[5], -163.2 * 0.25 + xShift[5]}, // 5 st. (lower h. plane)
101
102 {163.2 * 0.25 + xShift[6], -163.2 * 0.25 + xShift[6], // 6 st. (upper h. plane)
103 163.2 * 0.25, -163.2 * 0.25}, // 6 st. (lower h. plane)
104
105 {0.0} // 7 st.
106};
108 {+22.5 + yShift[0], +22.5 + yShift[0], // 0 st. (upper h. plane)
109 -19.5, -19.5}, // 0 st. (lower h. plane)
110
111 {+22.5, +22.5, // 1 st. (upper h. plane)
112 -19.5 + yShift[1], -19.5 + yShift[1]}, // 1 st. (lower h. plane)
113
114 {+22.5 + yShift[2], +22.5 + yShift[2], // 2 st. (upper h. plane)
115 -19.5, -19.5}, // 2 st. (lower h. plane)
116
117 {+22.5, +22.5, // 3 st. (upper h. plane)
118 -19.5 + yShift[3], -19.5 + yShift[3]}, // 3 st. (lower h. plane)
119
120 {+22.5 + yShift[4], +22.5 + yShift[4], // 4 st. (upper h. plane)
121 -19.5, -19.5}, // 4 st. (lower h. plane)
122
123 {+22.5, +22.5, // 5 st. (upper h. plane)
124 -19.5 + yShift[5], -19.5 + yShift[5]}, // 5 st. (lower h. plane)
125
126 {+22.5 + yShift[6], +22.5 + yShift[6], // 6 st. (upper h. plane)
127 -19.5, -19.5}, // 6 st. (lower h. plane)
128
129 {0.0} // 7 st.
130};
132 {zShift[0], zShift[0], 0.0, 0.0}, // 0 st.
133 {0.0, 0.0, zShift[1], zShift[1]}, // 1 st.
134 {zShift[2], zShift[2], 0.0, 0.0}, // 2 st.
135 {0.0, 0.0, zShift[3], zShift[3]}, // 3 st.
136 {zShift[4], zShift[4], 0.0, 0.0}, // 4 st.
137 {0.0, 0.0, zShift[5], zShift[5]}, // 5 st.
138 {zShift[6], zShift[6], 0.0, 0.0}, // 6 st.
139 {0.0} // 7 st.
140};
141
142/*
143 * Basic station:
144 *
145 * -------------------- --------------------
146 * | | |
147 * | module 0 | module 1 | ^ beam direction (Z)
148 * | | | /
149 * | ------------|-------------- | /
150 * | / | / | /
151 * | / | / |/
152 * -----------------------------------------
153 * | \ | \ |
154 * | \ | \ |
155 * | \___________|______________\ |
156 * | | |
157 * | | |
158 * | module 2 | module 3 |
159 * -----------------------------------------
160 *
161 */
162
163// rotations of stations around y-axis by 180 deg.
164const Bool_t YStationRotations[NStations] = {true /*0*/, false /*1*/, true /*2*/, false /*3*/,
165 true /*4*/, false /*5*/, true /*6*/, false /*7*/};
166
167// rotations of stations around x-axis by 180 deg.
168const Bool_t XStationRotations[NStations] = {false /*0*/, false /*1*/, false /*2*/, false /*3*/,
169 false /*4*/, false /*5*/, false /*6*/, false /*7*/};
170
171// GEM plane sizes (163x45 type) ------------------------------------------------
172const Double_t XModuleSize_Station163x45 = 163.2 * 0.5; // 81.6
174const Double_t ZModuleSize_Station163x45 = 0.9; // sensitive volume
175const Double_t ZGEMSize_Station163x45 = 3.9; // common thickness of GEM (including sens. vol)
176//------------------------------------------------------------------------------
177
178// GEM plane sizes (163x39 type) ------------------------------------------------
179const Double_t XModuleSize_Station163x39 = 163.2 * 0.5; // 81.6
181const Double_t ZModuleSize_Station163x39 = 0.9; // sensitive volume
182const Double_t ZGEMSize_Station163x39 = 3.9; // common thickness of GEM (including sens. vol)
183//------------------------------------------------------------------------------
184
185// GEM plane sizes (10x10 type) -------------------------------------------------
188const Double_t ZModuleSize_Station10x10 = 0.9; // sensitive volume
189//------------------------------------------------------------------------------
190
191// GeoManager
193
194// media
198
199class FairGeoMedia;
200class FairGeoBuilder;
201
202TGeoVolume* CreateStation(TString station_name);
203
205 Double_t xsize,
206 Double_t ysize,
207 Double_t zsize,
208 Double_t hole_radius);
209
211 Double_t xsize,
212 Double_t ysize,
213 Double_t zsize,
214 Double_t hole_radius);
215
216TGeoVolume* CreateModule_Station10x10(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize);
217
218void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
219{
220 // air medium
221 FairGeoMedium* mAir = geoMedia->getMedium("air");
222 if (!mAir)
223 Fatal("Main", "FairMedium air not found");
224 geoBuild->createMedium(mAir);
225 pMedAir = gGeoManager->GetMedium("air");
226 if (!pMedAir)
227 Fatal("Main", "Medium air not found");
228
229 // arco27020 medium
230 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
231 if (!mArCO27030)
232 Fatal("Main", "FairMedium arco27030 not found");
233 geoBuild->createMedium(mArCO27030);
234 pMedArCO27030 = gGeoManager->GetMedium("arco27030");
235 if (!pMedArCO27030)
236 Fatal("Main", "Medium arco27030 not found");
237
238 // ArC4H10_80_20 medium
239 FairGeoMedium* mArC4H10_80_20 = geoMedia->getMedium("ArC4H10_80_20");
240 if (!mArC4H10_80_20)
241 Fatal("Main", "FairMedium ArC4H10_80_20 not found");
242 geoBuild->createMedium(mArC4H10_80_20);
243 pMedArC4H10_80_20 = gGeoManager->GetMedium("ArC4H10_80_20");
245 Fatal("Main", "Medium ArC4H10_80_20 not found");
246}
247
249{
250 // ---- set working directory --------------------------------------------
251 TString gPath = gSystem->Getenv("VMCWORKDIR");
252
253 // ------- Geometry file name (output) ---------------------------------
254 const TString geoDetectorName = "GEMS";
255 const TString geoDetectorVersion = "Run9";
256 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
257
258 // ---- global geometry parameters ---------------------------------------
259 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
260 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
261
262 // ------- Load media from media file ----------------------------------
263 TString medFile = gPath + "/geometry/media.geo";
264 geoFace->setMediaFile(medFile);
265 geoFace->readMedia();
266 FairGeoMedia* geoMedia = geoFace->getMedia();
267 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
268
269 DefineRequiredMedia(geoMedia, geoBuild);
270 // -------------------------------------------------------------------------
271
272 // -------------- Create geometry and top volume ------------------------
273 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
274 gGeoMan->SetName(geoDetectorName + "_geom");
275 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
276 top->SetMedium(pMedAir);
277 gGeoMan->SetTopVolume(top);
278 // gGeoMan->SetTopVisible(1);
279 // -------------------------------------------------------------------------
280
281 // Define TOP Geometry
282 TGeoVolume* GEMS = new TGeoVolumeAssembly(geoDetectorName);
283 GEMS->SetMedium(pMedAir);
284
285 for (Int_t istation = 0; istation < NStations; ++istation) {
286 // for(Int_t istation = 0; istation < 1; ++istation) {
287
288 Int_t stationNum = istation;
289 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(stationNum, 10) + TString("_GEM"));
290
291 if (istation < 7) { // big GEMs
292 // upper module
293 TGeoVolume* module0 =
296 // upper module
297 TGeoVolume* module1 =
300 // lower module
301 TGeoVolume* module2 =
304 // lower module
305 TGeoVolume* module3 =
308
309 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
310 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
311 ZModuleShifts[stationNum][0] + ZModuleSize_Station163x45 * 0.5);
312
313 TGeoCombiTrans* module1_transform = new TGeoCombiTrans();
314 module1_transform->RotateY(180.0);
315 module1_transform->SetTranslation(XModuleShifts[stationNum][1], YModuleShifts[stationNum][1],
316 ZModuleShifts[stationNum][1] + ZModuleSize_Station163x45 * 0.5);
317
318 TGeoCombiTrans* module2_transform = new TGeoCombiTrans();
319 module2_transform->RotateX(180.0);
320 module2_transform->SetTranslation(XModuleShifts[stationNum][2], YModuleShifts[stationNum][2],
321 ZModuleShifts[stationNum][2] + ZModuleSize_Station163x39 * 0.5);
322
323 TGeoCombiTrans* module3_transform = new TGeoCombiTrans();
324 module3_transform->RotateX(180.0);
325 module3_transform->RotateY(180.0);
326 module3_transform->SetTranslation(XModuleShifts[stationNum][3], YModuleShifts[stationNum][3],
327 ZModuleShifts[stationNum][3] + ZModuleSize_Station163x39 * 0.5);
328
329 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
330 station->AddNode(module1, 0, new TGeoCombiTrans(*module1_transform));
331 station->AddNode(module2, 0, new TGeoCombiTrans(*module2_transform));
332 station->AddNode(module3, 0, new TGeoCombiTrans(*module3_transform));
333 }
334
335 if (istation == 7) { // small GEM
336 TGeoVolume* module0 =
337 CreateModule_Station10x10(TString("Sensor_module0_") + station->GetName(), XModuleSize_Station10x10,
339
340 TGeoCombiTrans* module0_transform = new TGeoCombiTrans();
341 module0_transform->SetTranslation(XModuleShifts[stationNum][0], YModuleShifts[stationNum][0],
342 ZModuleShifts[stationNum][0] + ZModuleSize_Station10x10 * 0.5);
343
344 station->AddNode(module0, 0, new TGeoCombiTrans(*module0_transform));
345 }
346
347 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
348 station_transform->SetTranslation(XStationPositions[stationNum], YStationPositions[stationNum],
349 ZStationPositions[stationNum]);
350
351 GEMS->AddNode(station, 0, station_transform);
352 }
353
354 top->AddNode(GEMS, 0);
356
357 // --------------- Finish -----------------------------------------------
358 gGeoMan->CloseGeometry();
359 gGeoMan->CheckOverlaps(0.0001);
360 gGeoMan->PrintOverlaps();
361 gGeoMan->Test();
362 // gGeoMan->RestoreMasterVolume();
363
364 TFile* geoFile = new TFile(geoFileName, "RECREATE");
365 top->Write();
366 geoFile->Close();
367 top->Draw("ogl");
368}
369//------------------------------------------------------------------------------
370
372{
373 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
374 stationA->SetMedium(pMedAir);
375
376 return stationA;
377}
378
380 Double_t xsize,
381 Double_t ysize,
382 Double_t zsize,
383 Double_t hole_radius)
384{
385 gRandom->SetSeed(0);
386 Int_t uniqueId = gRandom->Integer(100000);
387
388 // module shapes
389 TGeoShape* module_partS =
390 new TGeoBBox(TString("module_partS_") + TString::Itoa(uniqueId, 10), xsize * 0.5, ysize * 0.5, zsize * 0.5);
391 TGeoShape* holeS =
392 new TGeoTube(TString("holeS_") + TString::Itoa(uniqueId, 10), 0.0, hole_radius, zsize * 0.5 + 0.01);
393
394 TGeoTranslation* hole_module_trans = new TGeoTranslation(
395 TString("hole_module_trans_") + TString::Itoa(uniqueId, 10), -xsize * 0.5, -ysize * 0.5, 0.0);
396
397 hole_module_trans->RegisterYourself();
398
399 TString bool_expression_module = TString(module_partS->GetName()) + TString(" - ") + TString(holeS->GetName())
400 + TString(":") + TString(hole_module_trans->GetName());
401 TGeoCompositeShape* moduleS = new TGeoCompositeShape(bool_expression_module);
402
403 // module volume
404 TGeoVolume* moduleV = new TGeoVolume(module_name, moduleS);
405
406 // medium
409 else
410 Fatal("Main", "Invalid medium for sensitive modules!");
411
412 // visual parameters
413 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
414 moduleV->SetTransparency(20);
415
416 return moduleV;
417}
418//------------------------------------------------------------------------------
419
421 Double_t xsize,
422 Double_t ysize,
423 Double_t zsize,
424 Double_t hole_radius)
425{
426 return CreateModule_Station163x45(module_name, xsize, ysize, zsize, hole_radius);
427}
428//------------------------------------------------------------------------------
429
431{
432 // module shape
433 TGeoShape* moduleS = new TGeoBBox("moduleS", xsize * 0.5, ysize * 0.5, zsize * 0.5);
434
435 // module volume
436 TGeoVolume* moduleV = new TGeoVolume(module_name, moduleS);
437
438 // medium
441 else
442 Fatal("Main", "Invalid medium for sensitive modules!");
443
444 // visual parameters
445 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
446 moduleV->SetTransparency(20);
447
448 return moduleV;
449}
450//------------------------------------------------------------------------------
bool Bool_t
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 TRandom * gRandom
R__EXTERN TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void RotateY(Double_t angle) override
void RotateX(Double_t angle) override
void SetTranslation(const TGeoTranslation &tr)
virtual void RegisterYourself()
const char * GetName() const 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]
const Double_t ZModuleSize_Station163x45
const Double_t YModuleSize_Station163x45
TGeoManager * gGeoMan
const Int_t NMaxModules
const Double_t ZStationPositions[NStations]
TGeoMedium * pMedArCO27030
const Int_t NStations
const Double_t XModuleSize_Station163x45
const Double_t XStationPositions[NStations]
const Double_t yShift[NStations]
const Double_t xShift[NStations]
const Bool_t XStationRotations[NStations]
const Double_t zShift[NStations]
const Bool_t YStationRotations[NStations]
const Double_t ZModuleSize_Station10x10
const Double_t XModuleSize_Station10x10
const Double_t YModuleSize_Station10x10
const Double_t XModuleSize_Station163x39
const Double_t YModuleSize_Station163x39
const Double_t ZGEMSize_Station163x39
const Double_t ZModuleSize_Station163x39
const Double_t ZGEMSize_Station163x45
TGeoMedium * pMedArC4H10_80_20
TGeoVolume * CreateModule_Station10x10(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize)
void create_rootgeom_GEMS_Run9()
TGeoVolume * CreateStation(TString station_name)
TGeoVolume * CreateModule_Station163x45(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize, Double_t hole_radius)
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
TGeoVolume * CreateModule_Station163x39(TString module_name, Double_t xsize, Double_t ysize, Double_t zsize, Double_t hole_radius)