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