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