BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_bd_root_v13.C
Go to the documentation of this file.
2#include "TGeoCone.h"
3#include "TGeoManager.h"
4#include "TGeoPara.h"
5#include "TGeoTrd2.h"
6#include "TGeoTube.h"
7
8#include <iomanip>
9#include <iostream>
10
11R__ADD_INCLUDE_PATH($VMCWORKDIR)
12#include "macro/run/bmnloadlibs.C"
13//---------------------------
14//---------------------------
15
17
20const Double_t strip_BD_Zpos = -2.5; // cm
21// const Double_t strip_BD_Zpos = -3.5; //cm
22
25const Double_t tubeFe_Zpos = -8.45; // cm
26// const Double_t tubeFe_Zpos = -9.45; //cm
27
30const Double_t tubeAl_Zpos = -14.3; // cm
31
32const Double_t roh_Xpos = 0.0;
33const Double_t roh_Ypos = 0.0;
34const Double_t roh_Zpos = -2.65; // cm
35
40
41const Double_t dphi1 = 360. / 40;
42const Double_t rr = 4.95;
43
46
49
52
54{
55
56 // ------- Load media from media file -----------------------------------
57 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
58 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
59 TString geoPath = gSystem->Getenv("VMCWORKDIR");
60 TString medFile = geoPath + "/geometry/media.geo";
61 geoFace->setMediaFile(medFile);
62 geoFace->readMedia();
64 // --------------------------------------------------------------------------
65
66 // ------- Geometry file name (output) ----------------------------------
67 const TString geoDetectorName = "geom_BD_det";
68 const TString geoDetectorVersion = "v2";
69 TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
70 // --------------------------------------------------------------------------
71
72 // ----------------- Get and create the required media -----------------
73 FairGeoMedia* geoMedia = geoFace->getMedia();
74 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
75
76 FairGeoMedium* mAir = geoMedia->getMedium("air");
77 if (!mAir)
78 Fatal("Main", "FairMedium air not found");
79 geoBuild->createMedium(mAir);
80 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
81 if (!pMedAir)
82 Fatal("Main", "Medium air not found");
83
84 FairGeoMedium* mBC408 = geoMedia->getMedium("BC408");
85 if (!mBC408)
86 Fatal("Main", "FairMedium BC408 not found");
87 geoBuild->createMedium(mBC408);
88 TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
89 if (!pMedBC408)
90 Fatal("Main", "Medium BC408 not found");
91
92 FairGeoMedium* miron = geoMedia->getMedium("iron");
93 if (!miron)
94 Fatal("Main", "FairMedium iron not found");
95 geoBuild->createMedium(miron);
96 TGeoMedium* pMediron = gGeoMan->GetMedium("iron");
97 if (!pMediron)
98 Fatal("Main", "Medium iron not found");
99
100 FairGeoMedium* maluminium = geoMedia->getMedium("aluminium");
101 if (!maluminium)
102 Fatal("Main", "FairMedium aluminium not found");
103 geoBuild->createMedium(maluminium);
104 TGeoMedium* pMedaluminium = gGeoMan->GetMedium("aluminium");
105 if (!pMedaluminium)
106 Fatal("Main", "Medium aluminium not found");
107
108 FairGeoMedium* mpolypropylene = geoMedia->getMedium("polypropylene");
109 if (!mpolypropylene)
110 Fatal("Main", "FairMedium polypropylene not found");
111 geoBuild->createMedium(mpolypropylene);
112 TGeoMedium* pMedpolypropylene = gGeoMan->GetMedium("polypropylene");
113 if (!pMedpolypropylene)
114 Fatal("Main", "Medium polypropylene not found");
115
116 // --------------------------------------------------------------------------
117
118 // -------------- Create geometry and top volume -------------------------
119 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
120 gGeoMan->SetName(geoDetectorName + "_geom");
121 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
122 top->SetMedium(pMedAir);
123 gGeoMan->SetTopVolume(top);
124
125 // --------------------------------------------------------------------------
126
127 TGeoTranslation* BD_Position = new TGeoTranslation("BD_Position", 0, 0, 0);
128
129 // Define TOP Geometry
130 TGeoVolume* BD = new TGeoVolumeAssembly("BD");
131 BD->SetMedium(pMedAir);
132
133 TGeoTranslation* strips_BD1Pos_trans =
134 new TGeoTranslation("strips_BD1Pos_trans", strip_BD_Xpos, strip_BD_Ypos, strip_BD_Zpos);
135 TGeoTranslation* tubefePos_trans = new TGeoTranslation("tubefePos_trans", tubeFe_Xpos, tubeFe_Ypos, tubeFe_Zpos);
136 TGeoTranslation* tubealPos_trans = new TGeoTranslation("tubefePos_trans", tubeAl_Xpos, tubeAl_Ypos, tubeAl_Zpos);
137 TGeoTranslation* tuberohPos_trans = new TGeoTranslation("tuberohPos_trans", roh_Xpos, roh_Ypos, roh_Zpos);
138
139 TGeoBBox* strip = new TGeoBBox("srtip", 0.7 / 2., 0.7 / 2., 15. / 2.);
140 TGeoTube* tubefeContainerS = new TGeoTube("tubefeContainerS", MinRadiusFe / 2, MaxRadiusFe / 2, ZLength_tubeFe / 2);
141 TGeoTube* tubealContainerS = new TGeoTube("tubealContainerS", MinRadiusAl / 2, MaxRadiusAl / 2, ZLength_tubeAl / 2);
142 TGeoTube* tuberohContainerS =
143 new TGeoTube("tuberohContainerS", MinRadiusRohacel / 2, MaxRadiusRohacel / 2, ZLength_roh / 2);
144
145 Double_t phi = 90 * TMath::DegToRad(), delta_phi = 360. / 40., dphi = delta_phi * TMath::DegToRad();
146
147 TGeoCombiTrans* combi1 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 10.5), rr * TMath::Sin(dphi * 10.5),
148 strip_BD_Zpos, new TGeoRotation("rot1", dphi1 * 10.5, 0., 0.));
149 TGeoCombiTrans* combi2 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 11.5), rr * TMath::Sin(dphi * 11.5),
150 strip_BD_Zpos, new TGeoRotation("rot2", dphi1 * 11.5, 0., 0.));
151 TGeoCombiTrans* combi3 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 12.5), rr * TMath::Sin(dphi * 12.5),
152 strip_BD_Zpos, new TGeoRotation("rot3", dphi1 * 12.5, 0., 0.));
153 TGeoCombiTrans* combi4 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 13.5), rr * TMath::Sin(dphi * 13.5),
154 strip_BD_Zpos, new TGeoRotation("rot4", dphi1 * 13.5, 0., 0.));
155 TGeoCombiTrans* combi5 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 14.5), rr * TMath::Sin(dphi * 14.5),
156 strip_BD_Zpos, new TGeoRotation("rot5", dphi1 * 14.5, 0., 0.));
157 TGeoCombiTrans* combi6 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 15.5), rr * TMath::Sin(dphi * 15.5),
158 strip_BD_Zpos, new TGeoRotation("rot6", dphi1 * 15.5, 0., 0.));
159 TGeoCombiTrans* combi7 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 16.5), rr * TMath::Sin(dphi * 16.5),
160 strip_BD_Zpos, new TGeoRotation("rot7", dphi1 * 16.5, 0., 0.));
161 TGeoCombiTrans* combi8 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 17.5), rr * TMath::Sin(dphi * 17.5),
162 strip_BD_Zpos, new TGeoRotation("rot8", dphi1 * 17.5, 0., 0.));
163 TGeoCombiTrans* combi9 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 18.5), rr * TMath::Sin(dphi * 18.5),
164 strip_BD_Zpos, new TGeoRotation("rot9", dphi1 * 18.5, 0., 0.));
165 TGeoCombiTrans* combi10 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 19.5), rr * TMath::Sin(dphi * 19.5),
166 strip_BD_Zpos, new TGeoRotation("rot10", dphi1 * 19.5, 0., 0.));
167 TGeoCombiTrans* combi11 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 20.5), rr * TMath::Sin(dphi * 20.5),
168 strip_BD_Zpos, new TGeoRotation("rot11", dphi1 * 20.5, 0., 0.));
169 TGeoCombiTrans* combi12 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 21.5), rr * TMath::Sin(dphi * 21.5),
170 strip_BD_Zpos, new TGeoRotation("rot12", dphi1 * 21.5, 0., 0.));
171 TGeoCombiTrans* combi13 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 22.5), rr * TMath::Sin(dphi * 22.5),
172 strip_BD_Zpos, new TGeoRotation("rot13", dphi1 * 22.5, 0., 0.));
173 TGeoCombiTrans* combi14 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 23.5), rr * TMath::Sin(dphi * 23.5),
174 strip_BD_Zpos, new TGeoRotation("rot14", dphi1 * 23.5, 0., 0.));
175 TGeoCombiTrans* combi15 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 24.5), rr * TMath::Sin(dphi * 24.5),
176 strip_BD_Zpos, new TGeoRotation("rot15", dphi1 * 24.5, 0., 0.));
177 TGeoCombiTrans* combi16 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 25.5), rr * TMath::Sin(dphi * 25.5),
178 strip_BD_Zpos, new TGeoRotation("rot16", dphi1 * 25.5, 0., 0.));
179 TGeoCombiTrans* combi17 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 26.5), rr * TMath::Sin(dphi * 26.5),
180 strip_BD_Zpos, new TGeoRotation("rot17", dphi1 * 26.5, 0., 0.));
181 TGeoCombiTrans* combi18 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 27.5), rr * TMath::Sin(dphi * 27.5),
182 strip_BD_Zpos, new TGeoRotation("rot18", dphi1 * 27.5, 0., 0.));
183 TGeoCombiTrans* combi19 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 28.5), rr * TMath::Sin(dphi * 28.5),
184 strip_BD_Zpos, new TGeoRotation("rot19", dphi1 * 28.5, 0., 0.));
185 TGeoCombiTrans* combi20 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 29.5), rr * TMath::Sin(dphi * 29.5),
186 strip_BD_Zpos, new TGeoRotation("rot20", dphi1 * 29.5, 0., 0.));
187 TGeoCombiTrans* combi21 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 30.5), rr * TMath::Sin(dphi * 30.5),
188 strip_BD_Zpos, new TGeoRotation("rot21", dphi1 * 30.5, 0., 0.));
189 TGeoCombiTrans* combi22 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 31.5), rr * TMath::Sin(dphi * 31.5),
190 strip_BD_Zpos, new TGeoRotation("rot22", dphi1 * 31.5, 0., 0.));
191 TGeoCombiTrans* combi23 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 32.5), rr * TMath::Sin(dphi * 32.5),
192 strip_BD_Zpos, new TGeoRotation("rot23", dphi1 * 32.5, 0., 0.));
193 TGeoCombiTrans* combi24 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 33.5), rr * TMath::Sin(dphi * 33.5),
194 strip_BD_Zpos, new TGeoRotation("rot24", dphi1 * 33.5, 0., 0.));
195 TGeoCombiTrans* combi25 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 34.5), rr * TMath::Sin(dphi * 34.5),
196 strip_BD_Zpos, new TGeoRotation("rot25", dphi1 * 34.5, 0., 0.));
197 TGeoCombiTrans* combi26 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 35.5), rr * TMath::Sin(dphi * 35.5),
198 strip_BD_Zpos, new TGeoRotation("rot26", dphi1 * 35.5, 0., 0.));
199 TGeoCombiTrans* combi27 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 36.5), rr * TMath::Sin(dphi * 36.5),
200 strip_BD_Zpos, new TGeoRotation("rot27", dphi1 * 36.5, 0., 0.));
201 TGeoCombiTrans* combi28 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 37.5), rr * TMath::Sin(dphi * 37.5),
202 strip_BD_Zpos, new TGeoRotation("rot28", dphi1 * 37.5, 0., 0.));
203 TGeoCombiTrans* combi29 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 38.5), rr * TMath::Sin(dphi * 38.5),
204 strip_BD_Zpos, new TGeoRotation("rot29", dphi1 * 38.5, 0., 0.));
205 TGeoCombiTrans* combi30 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 39.5), rr * TMath::Sin(dphi * 39.5),
206 strip_BD_Zpos, new TGeoRotation("rot30", dphi1 * 39.5, 0., 0.));
207 TGeoCombiTrans* combi31 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 40.5), rr * TMath::Sin(dphi * 40.5),
208 strip_BD_Zpos, new TGeoRotation("rot31", dphi1 * 40.5, 0., 0.));
209 TGeoCombiTrans* combi32 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 1.5), rr * TMath::Sin(dphi * 1.5),
210 strip_BD_Zpos, new TGeoRotation("rot32", dphi1 * 1.5, 0., 0.));
211 TGeoCombiTrans* combi33 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 2.5), rr * TMath::Sin(dphi * 2.5),
212 strip_BD_Zpos, new TGeoRotation("rot33", dphi1 * 2.5, 0., 0.));
213 TGeoCombiTrans* combi34 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 3.5), rr * TMath::Sin(dphi * 3.5),
214 strip_BD_Zpos, new TGeoRotation("rot34", dphi1 * 3.5, 0., 0.));
215 TGeoCombiTrans* combi35 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 4.5), rr * TMath::Sin(dphi * 4.5),
216 strip_BD_Zpos, new TGeoRotation("rot35", dphi1 * 4.5, 0., 0.));
217 TGeoCombiTrans* combi36 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 5.5), rr * TMath::Sin(dphi * 5.5),
218 strip_BD_Zpos, new TGeoRotation("rot36", dphi1 * 5.5, 0., 0.));
219 TGeoCombiTrans* combi37 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 6.5), rr * TMath::Sin(dphi * 6.5),
220 strip_BD_Zpos, new TGeoRotation("rot37", dphi1 * 6.5, 0., 0.));
221 TGeoCombiTrans* combi38 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 7.5), rr * TMath::Sin(dphi * 7.5),
222 strip_BD_Zpos, new TGeoRotation("rot38", dphi1 * 7.5, 0., 0.));
223 TGeoCombiTrans* combi39 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 8.5), rr * TMath::Sin(dphi * 8.5),
224 strip_BD_Zpos, new TGeoRotation("rot39", dphi1 * 8.5, 0., 0.));
225 TGeoCombiTrans* combi40 = new TGeoCombiTrans(rr * TMath::Cos(dphi * 9.5), rr * TMath::Sin(dphi * 9.5),
226 strip_BD_Zpos, new TGeoRotation("rot40", dphi1 * 9.5, 0., 0.));
227
228 TGeoVolume* BD1ActiveVolumeV1 = new TGeoVolume("BD1ActiveVolumeV1", strip);
229 BD1ActiveVolumeV1->SetMedium(pMedBC408);
230 BD1ActiveVolumeV1->SetLineColor(kYellow - 10);
231
232 TGeoVolume* tubefeActiveVolumeV = new TGeoVolume("tubefeActiveVolumeV", tubefeContainerS);
233 tubefeActiveVolumeV->SetMedium(pMediron);
234 tubefeActiveVolumeV->SetLineColor(kOrange - 1);
235
236 TGeoVolume* tubealActiveVolumeV = new TGeoVolume("tubealActiveVolumeV", tubealContainerS);
237 tubealActiveVolumeV->SetMedium(pMedaluminium);
238 tubealActiveVolumeV->SetLineColor(kCyan - 10);
239
240 TGeoVolume* tuberohActiveVolumeV = new TGeoVolume("tuberohActiveVolumeV", tuberohContainerS);
241 tuberohActiveVolumeV->SetMedium(pMedpolypropylene);
242 tuberohActiveVolumeV->SetLineColor(kGray);
243
244 // container1->AddNode(BD1Top, 1);
245
246 // BD1Top->AddNode(BD1ActiveVolumeV1, 1, new TGeoCombiTrans(t1, r1));
247
248 BD->AddNode(BD1ActiveVolumeV1, 1, combi1);
249 BD->AddNode(BD1ActiveVolumeV1, 2, combi2);
250 BD->AddNode(BD1ActiveVolumeV1, 3, combi3);
251 BD->AddNode(BD1ActiveVolumeV1, 4, combi4);
252 BD->AddNode(BD1ActiveVolumeV1, 5, combi5);
253 BD->AddNode(BD1ActiveVolumeV1, 6, combi6);
254 BD->AddNode(BD1ActiveVolumeV1, 7, combi7);
255 BD->AddNode(BD1ActiveVolumeV1, 8, combi8);
256 BD->AddNode(BD1ActiveVolumeV1, 9, combi9);
257 BD->AddNode(BD1ActiveVolumeV1, 10, combi10);
258 BD->AddNode(BD1ActiveVolumeV1, 11, combi11);
259 BD->AddNode(BD1ActiveVolumeV1, 12, combi12);
260 BD->AddNode(BD1ActiveVolumeV1, 13, combi13);
261 BD->AddNode(BD1ActiveVolumeV1, 14, combi14);
262 BD->AddNode(BD1ActiveVolumeV1, 15, combi15);
263 BD->AddNode(BD1ActiveVolumeV1, 16, combi16);
264 BD->AddNode(BD1ActiveVolumeV1, 17, combi17);
265 BD->AddNode(BD1ActiveVolumeV1, 18, combi18);
266 BD->AddNode(BD1ActiveVolumeV1, 19, combi19);
267 BD->AddNode(BD1ActiveVolumeV1, 20, combi20);
268 BD->AddNode(BD1ActiveVolumeV1, 21, combi21);
269 BD->AddNode(BD1ActiveVolumeV1, 22, combi22);
270 BD->AddNode(BD1ActiveVolumeV1, 23, combi23);
271 BD->AddNode(BD1ActiveVolumeV1, 24, combi24);
272 BD->AddNode(BD1ActiveVolumeV1, 25, combi25);
273 BD->AddNode(BD1ActiveVolumeV1, 26, combi26);
274 BD->AddNode(BD1ActiveVolumeV1, 27, combi27);
275 BD->AddNode(BD1ActiveVolumeV1, 28, combi28);
276 BD->AddNode(BD1ActiveVolumeV1, 29, combi29);
277 BD->AddNode(BD1ActiveVolumeV1, 30, combi30);
278 BD->AddNode(BD1ActiveVolumeV1, 31, combi31);
279 BD->AddNode(BD1ActiveVolumeV1, 32, combi32);
280 BD->AddNode(BD1ActiveVolumeV1, 33, combi33);
281 BD->AddNode(BD1ActiveVolumeV1, 34, combi34);
282 BD->AddNode(BD1ActiveVolumeV1, 35, combi35);
283 BD->AddNode(BD1ActiveVolumeV1, 36, combi36);
284 BD->AddNode(BD1ActiveVolumeV1, 37, combi37);
285 BD->AddNode(BD1ActiveVolumeV1, 38, combi38);
286 BD->AddNode(BD1ActiveVolumeV1, 39, combi39);
287 BD->AddNode(BD1ActiveVolumeV1, 40, combi40);
288
289 BD->AddNode(tubefeActiveVolumeV, 41, tubefePos_trans);
290 BD->AddNode(tubealActiveVolumeV, 42, tubealPos_trans);
291 BD->AddNode(tuberohActiveVolumeV, 43, tuberohPos_trans);
292
293 // Adding volumes to the TOP Volume
294 top->AddNode(BD, 1, BD_Position);
295
297
298 // --------------- Finish -----------------------------------------------
299 gGeoMan->CloseGeometry();
300 gGeoMan->CheckOverlaps(0.001);
301 gGeoMan->PrintOverlaps();
302 gGeoMan->Test();
303
304 TFile* geoFile = new TFile(geoFileName, "RECREATE");
305 top->Write();
306 geoFile->Close();
307 top->Draw("ogl");
308 // top->Draw("");
309}
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
kGray
kOrange
kCyan
kYellow
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
void Close(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
virtual void SetMedium(TGeoMedium *medium)
void SetLineColor(Color_t lcolor) override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TGeoManager * gGeoMan
const Double_t strip_BD_Xpos
const Double_t strip_BD_Ypos
const Double_t strip_BD_Zpos
const Double_t rr
const Double_t MaxRadiusFe
const Double_t MinRadiusAl
const Double_t ZLength_tubeFe
const Double_t MaxRadiusRohacel
const Double_t ZLength_tubeAl
const Double_t tubeAl_Zpos
const Double_t roh_Zpos
const Double_t MinRadiusFe
const Double_t ZLength_BDActiveVolume
const Double_t MaxRadiusAl
const Double_t roh_Ypos
const Double_t tubeFe_Ypos
const Double_t tubeAl_Ypos
const Double_t tubeFe_Xpos
const Double_t tubeAl_Xpos
const Double_t MinRadiusRohacel
const Double_t roh_Xpos
const Double_t tubeFe_Zpos
const Double_t ZLength_roh
const Double_t dphi1
void create_bd_root_v13()
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)