BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_VSP_Run9.C
Go to the documentation of this file.
1/* Macro for creation of ROOT geometry for VSP (Vertex Silicon Plane) for RUN-9;
2 * Basic configuration of VSP (one plane including 6 silicon modules);
3 *
4 * Author: Baranov D.
5 * Data: 25.04.2024 (created)
6 * Data: 09.06.2025 (updated) : positions according to measurement schemes
7 *
8 * WARNING: all units are in cm!!!
9 */
10
11using namespace TMath;
12
13// Set Parameters of VSP detector -----------------------------------------------
14const Int_t NStations = 1; // stations in the detector
15const Int_t NMaxModules = 6; // max. number of modules in a station
16
18
19//(X-Y-Z)Positions of stations (sensitive volumes)
22const Double_t ZStationPositions[NStations] = {0.0}; // the closest side to the target (frame or sensor)
23
24// shift of a module is its geometric center position
26 {+6.259 /*0*/, +0.312 /*1*/, -5.692 /*2*/,
27
28 +6.536 /*3*/, +0.516 /*4*/, -5.414 /*5*/},
29};
31 {+3.1385 /*0*/, +6.0655 /*1*/, +3.2225 /*2*/,
32
33 -3.056 /*3*/, -5.801 /*4*/, -2.976 /*5*/},
34};
36 {+8.4085 /*0*/, +8.298 /*1*/, +8.4435 /*2*/,
37
38 +6.991 /*3*/, +7.118 /*4*/, +6.979 /*5*/},
39};
40
46
50
51// Rotations of modules around y-axis by 180 deg.
53 {false /*0*/, false /*1*/, false /*2*/, false /*3*/, false /*4*/, false /*5*/},
54};
55
56// Rotations of modules around x-axis by 180 deg.
58 {false /*0*/, false /*1*/, false /*2*/, true /*3*/, true /*4*/, true /*5*/},
59};
60//------------------------------------------------------------------------------
61
62// Module parameters ------------------------------------------------------------
65Double_t ZModuleSize = 0.03; // 300 mkm
66
71
72// Sensor zones ------------------------------------
76//-------------------------------------------------
77
78// Module frames -----------------------------------
80//-------------------------------------------------
81//------------------------------------------------------------------------------
82
83// GeoManager --------------------------------------
85//-------------------------------------------------
86
87// media
93
94class FairGeoMedia;
95class FairGeoBuilder;
96
97// function declarations
98TGeoVolume* CreateStation(TString station_name);
99TGeoVolume* CreateModule(TString module_name);
100TGeoVolume* CreateModuleFrame(TString moduleFrame_name, ModuleFrameType type);
101
102void DefineRequiredMedia(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
103{
104
105 // air medium
106 FairGeoMedium* mAir = geoMedia->getMedium("air");
107 if (!mAir)
108 Fatal("Main", "FairMedium air not found");
109 geoBuild->createMedium(mAir);
110 pMedAir = gGeoManager->GetMedium("air");
111 if (!pMedAir)
112 Fatal("Main", "Medium air not found");
113
114 // carbon medium
115 FairGeoMedium* mCarbon = geoMedia->getMedium("carbon");
116 if (!mCarbon)
117 Fatal("Main", "FairMedium carbon not found");
118 geoBuild->createMedium(mCarbon);
119 pMedCarbon = gGeoManager->GetMedium("carbon");
120 if (!pMedCarbon)
121 Fatal("Main", "Medium carbon not found");
122
123 // fiberglass medium
124 FairGeoMedium* mFiberGlass = geoMedia->getMedium("fiberglass");
125 if (!mFiberGlass)
126 Fatal("Main", "FairMedium fiberglass not found");
127 geoBuild->createMedium(mFiberGlass);
128 pMedFiberGlass = gGeoManager->GetMedium("fiberglass");
129 if (!pMedFiberGlass)
130 Fatal("Main", "Medium fiberglass not found");
131
132 // copper medium
133 FairGeoMedium* mCopper = geoMedia->getMedium("copper");
134 if (!mCopper)
135 Fatal("Main", "FairMedium copper not found");
136 geoBuild->createMedium(mCopper);
137 pMedCopper = gGeoManager->GetMedium("copper");
138 if (!pMedCopper)
139 Fatal("Main", "Medium copper not found");
140
141 // silicon medium
142 FairGeoMedium* mSilicon = geoMedia->getMedium("silicon");
143 if (!mSilicon)
144 Fatal("Main", "FairMedium silicon not found");
145 geoBuild->createMedium(mSilicon);
146 pMedSilicon = gGeoManager->GetMedium("silicon");
147 if (!pMedSilicon)
148 Fatal("Main", "Medium silicon not found");
149}
150
152{
153 cout << "\n";
154 cout << "Module parameters information : -----------------------------"
155 << "\n";
156
157 cout << "-------------------------------------------------------------\n";
158}
159
161{
162 cout << "\n";
163 for (Int_t istation = 0; istation < NStations; ++istation) {
164 cout << "station " << istation << ":\n";
165 cout << " XStationPositions[" << istation << "] = " << XStationPositions[istation] << " cm\n";
166 cout << " YStationPositions[" << istation << "] = " << YStationPositions[istation] << " cm\n";
167 cout << " ZStationPositions[" << istation << "] = " << ZStationPositions[istation] << " cm\n";
168 cout << "\n";
169
170 for (Int_t imodule = 0; imodule < NModulesInStations[istation]; ++imodule) {
171 cout << " module " << imodule << ":\n";
172 cout << " XModuleShifts[" << istation << "][" << imodule << "] = " << XModuleShifts[istation][imodule]
173 << " cm\n";
174 cout << " YModuleShifts[" << istation << "][" << imodule << "] = " << YModuleShifts[istation][imodule]
175 << " cm\n";
176 cout << " ZModuleShifts[" << istation << "][" << imodule << "] = " << ZModuleShifts[istation][imodule]
177 << " cm\n";
178 cout << "\n";
179 cout << " ModulesYRotations[" << istation << "][" << imodule << "] = ";
180 if (ModulesYRotations[istation][imodule] == false)
181 cout << "not rotated around Y\n";
182 if (ModulesYRotations[istation][imodule] == true)
183 cout << "rotated around Y\n";
184 cout << " ModulesXRotations[" << istation << "][" << imodule << "] = ";
185 if (ModulesXRotations[istation][imodule] == false)
186 cout << "not rotated around X\n";
187 if (ModulesXRotations[istation][imodule] == true)
188 cout << "rotated around X\n";
189 cout << "\n";
190 }
191 cout << "-------------------------------------------------------------\n";
192 }
193 cout << "-------------------------------------------------------------\n";
194}
195//------------------------------------------------------------------------------
196
198{
199
200 // ---- set working directory --------------------------------------------
201 TString gPath = gSystem->Getenv("VMCWORKDIR");
202
203 // ------- Geometry file name (output) ----------------------------------
204 const TString geoDetectorName = "VSP";
205 const TString geoDetectorVersion = "Run9";
206 const TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
207
208 // ---- global geometry parameters ---------------------------------------
209 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
210 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
211
212 // ------- Load media from media file ----------------------------------
213 TString medFile = gPath + "/geometry/media.geo";
214 geoFace->setMediaFile(medFile);
215 geoFace->readMedia();
216 FairGeoMedia* geoMedia = geoFace->getMedia();
217 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
218
219 DefineRequiredMedia(geoMedia, geoBuild);
220 // -------------------------------------------------------------------------
221
222 // Print information about parameters of VSP
225
226 // -------------- Create geometry and top volume -------------------------
227 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
228 gGeoMan->SetName(geoDetectorName + "_geom");
229 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
230 top->SetMedium(pMedAir);
231 gGeoMan->SetTopVolume(top);
232 // gGeoMan->SetTopVisible(1);
233 // --------------------------------------------------------------------------
234
235 // Define TOP Geometry
236 TGeoVolume* VSP = new TGeoVolumeAssembly(geoDetectorName);
237 VSP->SetMedium(pMedAir);
238
239 // Let's create VSP stations filled with modules
240 for (Int_t istation = 0; istation < NStations; ++istation) {
241 // for(Int_t istation = 0; istation < 1; ++istation) {
242
243 TGeoVolume* station = CreateStation(TString("station") + TString::Itoa(istation, 10) + TString("_VSP"));
244
245 Int_t NModules = NModulesInStations[istation];
246
247 TGeoVolume* modules[NModules];
248 TGeoVolume* moduleFrames[NModules];
249
250 TGeoCombiTrans* modTransforms[NModules];
251 TGeoCombiTrans* modFrameTransform[NModules];
252
253 for (Int_t imodule = 0; imodule < NModules; ++imodule) {
254 // for(Int_t imodule = 0; imodule < 1; ++imodule) {
255
256 TString module_name = TString("module") + TString::Itoa(imodule, 10) + TString("_") + station->GetName();
257 modules[imodule] = CreateModule(module_name);
258
259 TString moduleFrame_name =
260 TString("moduleFrame") + TString::Itoa(imodule, 10) + TString("_") + station->GetName();
261 moduleFrames[imodule] = CreateModuleFrame(moduleFrame_name, ModulesFrameTypes[istation][imodule]);
262
263 modTransforms[imodule] = new TGeoCombiTrans();
264
265 if (ModulesYRotations[istation][imodule]) {
266 modTransforms[imodule]->RotateY(180.0);
267 }
268 if (ModulesXRotations[istation][imodule]) {
269 modTransforms[imodule]->RotateX(180.0);
270 }
271
272 modTransforms[imodule]->SetDx(XModuleShifts[istation][imodule]);
273 modTransforms[imodule]->SetDy(YModuleShifts[istation][imodule]);
274 Double_t z_module_shift =
275 ZModuleSize * 0.5; // To z-module position is at the beginning of the sensitive volume
276 modTransforms[imodule]->SetDz(ZModuleShifts[istation][imodule] + z_module_shift);
277
278 modFrameTransform[imodule] = new TGeoCombiTrans(*modTransforms[imodule]);
279 if (imodule < NModulesInStations[istation] / 2) { // modules of upper half-plane
280 modFrameTransform[imodule]->SetDz(modFrameTransform[imodule]->GetTranslation()[2]
281 + (ZModuleSize * 0.5 + ZModuleFrameSize * 0.5));
282 } else { // modules of lower half-plane
283 modFrameTransform[imodule]->SetDz(modFrameTransform[imodule]->GetTranslation()[2]
284 - (ZModuleSize * 0.5 + ZModuleFrameSize * 0.5));
285 }
286
287 station->AddNode(modules[imodule], 0, modTransforms[imodule]);
288 station->AddNode(moduleFrames[imodule], 0, modFrameTransform[imodule]);
289 }
290
291 TGeoCombiTrans* station_transform = new TGeoCombiTrans();
292 station_transform->SetTranslation(XStationPositions[istation], YStationPositions[istation],
293 ZStationPositions[istation]);
294
295 VSP->AddNode(station, 0, station_transform);
296 }
297
298 top->AddNode(VSP, 0);
300
301 // --------------- Finish -----------------------------------------------
302 gGeoMan->CloseGeometry();
303 gGeoMan->CheckOverlaps(0.0001);
304 gGeoMan->PrintOverlaps();
305 gGeoMan->Test();
306
307 TFile* geoFile = new TFile(geoFileName, "RECREATE");
308 top->Write();
309 geoFile->Close();
310 top->Draw("ogl");
311}
312//------------------------------------------------------------------------------
313
315{
316
317 TGeoVolume* stationA = new TGeoVolumeAssembly(station_name);
318 stationA->SetMedium(pMedAir);
319
320 return stationA;
321}
322//------------------------------------------------------------------------------
323
325{
326
327 // Shapes -------------------------------------------------------------------
328 TGeoShape* moduleS = new TGeoBBox(TString("moduleS") += TString("_") + module_name, XModuleSize * 0.5,
329 YModuleSize * 0.5, ZModuleSize * 0.5);
330 TGeoShape* sensorS = new TGeoBBox(TString("sensorS") += TString("_") + module_name, XSensorZoneSize * 0.5,
331 YSensorZoneSize * 0.5, ZSensorZoneSize * 0.5);
332 //--------------------------------------------------------------------------
333
334 // Volumes ------------------------------------------------------------------
335 TGeoVolume* moduleV = new TGeoVolume(TString("moduleV") += TString("_") + module_name, moduleS);
336 TGeoVolume* sensorV = new TGeoVolume(TString("sensorV") += TString("_") + module_name, sensorS);
337 //--------------------------------------------------------------------------
338
339 // Media for volumes --------------------------------------------------------
340 TGeoMedium* silicon_medium = pMedSilicon;
341 if (silicon_medium) {
342 moduleV->SetMedium(silicon_medium);
343 sensorV->SetMedium(silicon_medium);
344 } else
345 Fatal("Main", "Invalid medium for modules and sensors!");
346 //--------------------------------------------------------------------------
347
348 // Visual properties for volumes --------------------------------------------
349 moduleV->SetLineColor(TColor::GetColor("#ff47ca"));
350 sensorV->SetLineColor(TColor::GetColor("#e0b0ff"));
351 moduleV->SetTransparency(50);
352 //--------------------------------------------------------------------------
353
354 moduleV->AddNode(sensorV, 0, new TGeoTranslation());
355
356 return moduleV;
357}
358//------------------------------------------------------------------------------
359
361{
362
363 // Frame sizes --------------------------------------------------------------
364 Double_t longVSide = 0.0;
365 if (type == SIDE)
366 longVSide = 11.5; // side module
367 if (type == MIDDLE)
368 longVSide = 8.7; // middle module
369 Double_t slopeVSide = 0.95;
370 Double_t slopeHSide = 0.95;
371 Double_t shortVSide = 3.05;
372 Double_t longHSide = 8.3;
373 Double_t shortHSide = 6.4;
374 Double_t holeHSide = 6.0;
375 Double_t holeVSide = 6.9;
376 Double_t holeHMargin = 0.2;
377 Double_t holeVMargin = 0.2;
378 //--------------------------------------------------------------------------
379
380 // Shapes -------------------------------------------------------------------
381 TGeoShape* moduleFrameS = new TGeoXtru(2);
382 moduleFrameS->SetName(TString("moduleFrameS") += TString("_") + moduleFrame_name);
383 Double_t x_pos[16] = {
384 +shortHSide * 0.5 /*0*/,
385 +shortHSide * 0.5 /*1*/,
386 +shortHSide * 0.5 + slopeHSide /*2*/,
387 +shortHSide * 0.5 + slopeHSide /*3*/,
388 -(shortHSide * 0.5 + slopeHSide) /*4*/,
389 -(shortHSide * 0.5 + slopeHSide) /*5*/,
390 -shortHSide * 0.5 /*6*/,
391 -shortHSide * 0.5 /*7*/,
392 -0.0 /*8*/,
393 -0.0 /*9*/,
394 -holeHSide * 0.5 /*10*/,
395 -holeHSide * 0.5 /*11*/,
396 +holeHSide * 0.5 /*12*/,
397 +holeHSide * 0.5 /*13*/,
398 +0.0 /*14*/,
399 +0.0 /*15*/
400 };
401 Double_t y_pos[16] = {
402 -(YModuleSize * 0.5 + holeVMargin - 0.1) /*0*/,
403 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide /*1*/,
404 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide + slopeVSide /*2*/,
405 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide + slopeVSide + shortVSide /*3*/,
406 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide + slopeVSide + shortVSide /*4*/,
407 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide + slopeVSide /*5*/,
408 -(YModuleSize * 0.5 + holeVMargin - 0.1) + longVSide /*6*/,
409 -(YModuleSize * 0.5 + holeVMargin - 0.1) /*7*/,
410 -(YModuleSize * 0.5 + holeVMargin - 0.1) /*8*/,
411 -YModuleSize * 0.5 + 0.1 /*9*/,
412 -YModuleSize * 0.5 + 0.1 /*10*/,
413 +holeVSide * 0.5 /*11*/,
414 +holeVSide * 0.5 /*12*/,
415 -YModuleSize * 0.5 + 0.1 /*13*/,
416 -YModuleSize * 0.5 + 0.1 /*14*/,
417 -(YModuleSize * 0.5 + holeVMargin - 0.1) /*15*/
418 };
419 ((TGeoXtru*)moduleFrameS)->DefinePolygon(16, x_pos, y_pos);
420 ((TGeoXtru*)moduleFrameS)->DefineSection(0, -ZModuleFrameSize * 0.5);
421 ((TGeoXtru*)moduleFrameS)->DefineSection(1, +ZModuleFrameSize * 0.5);
422 //--------------------------------------------------------------------------
423
424 // Volumes ------------------------------------------------------------------
425 TGeoVolume* moduleFrameV = new TGeoVolume(TString("moduleFrameV") += TString("_") + moduleFrame_name, moduleFrameS);
426 //--------------------------------------------------------------------------
427
428 // Media for volumes --------------------------------------------------------
429 // TGeoMedium *carbon_medium = pMedCarbon;
430 TGeoMedium* fiberGlass_medium = pMedFiberGlass;
431 if (fiberGlass_medium) {
432 moduleFrameV->SetMedium(fiberGlass_medium);
433 } else
434 Fatal("Main", "Invalid medium for moduleFrameV!");
435 //--------------------------------------------------------------------------
436
437 // Visual properties for volumes --------------------------------------------
438 moduleFrameV->SetLineColor(TColor::GetColor("#cccccc"));
439 moduleFrameV->SetTransparency(0);
440 //--------------------------------------------------------------------------
441
442 return moduleFrameV;
443}
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 TSystem * gSystem
static Int_t GetColor(const char *hexcolor)
void Close(Option_t *option="") override
void SetDz(Double_t dz) override
void RotateY(Double_t angle) override
void SetDy(Double_t dy) override
void SetDx(Double_t dx) override
void RotateX(Double_t angle) 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 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)
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]
TGeoMedium * pMedCopper
const Int_t NModulesInStations[NStations]
const Bool_t ModulesYRotations[NStations][NMaxModules]
const Bool_t ModulesXRotations[NStations][NMaxModules]
const ModuleFrameType ModulesFrameTypes[NStations][NMaxModules]
ModuleFrameType
@ SIDE
Double_t YSensorZoneSize
Double_t ZSensorZoneSize
Double_t XSensorZoneSize
TGeoMedium * pMedSilicon
TGeoVolume * CreateModule(TString module_name)
TGeoVolume * CreateModuleFrame(TString moduleFrame_name, ModuleFrameType type)
void create_rootgeom_VSP_Run9()
TGeoVolume * CreateStation(TString station_name)
void PrintInfoAboutModuleParameters()
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
void PrintInformationAboutStations()