BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_bd_root_run9.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//---------------------------
13//---------------------------
14
16
19const Double_t strip_BD_Zpos = -2.5; // cm
20// const Double_t strip_BD_Zpos = -3.5; //cm
21
24const Double_t tubeFe_Zpos = -8.45; // cm
25// const Double_t tubeFe_Zpos = -9.45; //cm
26
29const Double_t tubeAl_Zpos = -14.3; // cm
30
31const Double_t roh_Xpos = 0.0;
32const Double_t roh_Ypos = 0.0;
33const Double_t roh_Zpos = -2.65; // cm
34
39
40const Double_t dphi1 = 360. / 40;
41const Double_t rr = 4.95;
42
45
48
51
54
57
58// const Double_t Seg_tube_Thick = 1.0;
60
61const Double_t MaxRadiusOfDiv = 10.699;
63
65{
66
67 // ------- Load media from media file -----------------------------------
68 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
69 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
70 TString geoPath = gSystem->Getenv("VMCWORKDIR");
71 TString medFile = geoPath + "/geometry/media.geo";
72 geoFace->setMediaFile(medFile);
73 geoFace->readMedia();
75 // --------------------------------------------------------------------------
76
77 // ------- Geometry file name (output) ----------------------------------
78 const TString geoDetectorName = "BD";
79 const TString geoDetectorVersion = "run9";
80 TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
81 // --------------------------------------------------------------------------
82
83 // ----------------- Get and create the required media -----------------
84 FairGeoMedia* geoMedia = geoFace->getMedia();
85 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
86
87 FairGeoMedium* mAir = geoMedia->getMedium("air");
88 if (!mAir)
89 Fatal("Main", "FairMedium air not found");
90 geoBuild->createMedium(mAir);
91 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
92 if (!pMedAir)
93 Fatal("Main", "Medium air not found");
94
95 FairGeoMedium* mBC408 = geoMedia->getMedium("BC408");
96 if (!mBC408)
97 Fatal("Main", "FairMedium BC408 not found");
98 geoBuild->createMedium(mBC408);
99 TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
100 if (!pMedBC408)
101 Fatal("Main", "Medium BC408 not found");
102
103 FairGeoMedium* miron = geoMedia->getMedium("iron");
104 if (!miron)
105 Fatal("Main", "FairMedium iron not found");
106 geoBuild->createMedium(miron);
107 TGeoMedium* pMediron = gGeoMan->GetMedium("iron");
108 if (!pMediron)
109 Fatal("Main", "Medium iron not found");
110
111 FairGeoMedium* maluminium = geoMedia->getMedium("aluminium");
112 if (!maluminium)
113 Fatal("Main", "FairMedium aluminium not found");
114 geoBuild->createMedium(maluminium);
115 TGeoMedium* pMedaluminium = gGeoMan->GetMedium("aluminium");
116 if (!pMedaluminium)
117 Fatal("Main", "Medium aluminium not found");
118
119 FairGeoMedium* mpolypropylene = geoMedia->getMedium("polypropylene");
120 if (!mpolypropylene)
121 Fatal("Main", "FairMedium polypropylene not found");
122 geoBuild->createMedium(mpolypropylene);
123 TGeoMedium* pMedpolypropylene = gGeoMan->GetMedium("polypropylene");
124 if (!pMedpolypropylene)
125 Fatal("Main", "Medium polypropylene not found");
126
127 FairGeoMedium* mlead = geoMedia->getMedium("lead");
128 if (!mlead)
129 Fatal("Main", "FairMedium lead not found");
130 geoBuild->createMedium(mlead);
131 TGeoMedium* pMedlead = gGeoMan->GetMedium("lead");
132 if (!pMedlead)
133 Fatal("Main", "Medium lead not found");
134
135 FairGeoMedium* mVac = geoMedia->getMedium("vacuum");
136 if (!mVac)
137 Fatal("Main", "FairMedium vacuum not found");
138 geoBuild->createMedium(mVac);
139 TGeoMedium* pMedVac = gGeoMan->GetMedium("vacuum");
140 if (!pMedVac)
141 Fatal("Main", "Medium vacuum not found");
142
143 FairGeoMedium* mcopper = geoMedia->getMedium("copper");
144 if (!mcopper)
145 Fatal("Main", "FairMedium copper not found");
146 geoBuild->createMedium(mcopper);
147 TGeoMedium* pMedcopper = gGeoMan->GetMedium("copper");
148 if (!pMedcopper)
149 Fatal("Main", "Medium copper not found");
150
151 // --------------------------------------------------------------------------
152
153 // -------------- Create geometry and top volume -------------------------
154 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
155 gGeoMan->SetName(geoDetectorName + "_geom");
156 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
157 top->SetMedium(pMedAir);
158 gGeoMan->SetTopVolume(top);
159
160 // --------------------------------------------------------------------------
161
162 TGeoTranslation* BD_Position = new TGeoTranslation("BD_Position", 0, 0, 0);
163
164 // Define TOP Geometry
165 TGeoVolume* BD = new TGeoVolumeAssembly("BD");
166 BD->SetMedium(pMedVac);
167
168 TGeoTranslation* strips_BD1Pos_trans =
169 new TGeoTranslation("strips_BD1Pos_trans", strip_BD_Xpos, strip_BD_Ypos, strip_BD_Zpos);
170 TGeoTranslation* tubefePos_trans = new TGeoTranslation("tubefePos_trans", tubeFe_Xpos, tubeFe_Ypos, tubeFe_Zpos);
171 TGeoTranslation* tubealPos_trans = new TGeoTranslation("tubealPos_trans", tubeAl_Xpos, tubeAl_Ypos, tubeAl_Zpos);
172 TGeoTranslation* Postubepb_trans = new TGeoTranslation("Postubepb_trans", 0.0, 0.0, -4);
173 // TGeoTranslation *Seg_tube_trans = new TGeoTranslation("Seg_tube_trans", 0, 0, 4.6);
174
175 TGeoTranslation* trans_Pbring = new TGeoTranslation("trans_Pbring", 0, 0, 5.3);
176
177 TGeoTranslation* Seg_tube_trans = new TGeoTranslation("Seg_tube_trans", -12.5, 0, 5.6);
178 Seg_tube_trans->RegisterYourself();
179
180 TGeoTranslation* pos_trans1 = new TGeoTranslation("pos_trans1", 0, 0, 5.6);
181 pos_trans1->RegisterYourself();
182
183 TGeoTranslation* Postube1 = new TGeoTranslation("Postube1", 0.0, 0.0, -13);
184
185 TGeoBBox* strip = new TGeoBBox("srtip", 0.7 / 2., 0.7 / 2., 15. / 2.);
186 TGeoTube* tubefeContainerS = new TGeoTube("tubefeContainerS", MinRadiusFe / 2, MaxRadiusFe / 2, ZLength_tubeFe / 2);
187 TGeoTube* tubealContainerS = new TGeoTube("tubealContainerS", MinRadiusAl / 2, MaxRadiusAl / 2, ZLength_tubeAl / 2);
188 TGeoTube* tubepbContainerS = new TGeoTube("tubepbContainerS", 7.4 / 2, 8 / 2, 18.8 / 2);
189 // TGeoTubeSeg *Seg_tube = new TGeoTubeSeg("Seg_tube", Seg_tube_Min_dim/2, Seg_tube_Max_dim/2, Seg_tube_Thick/2,
190 // Seg_tube_Min_phi, Seg_tube_Max_phi);
191
192 TGeoBBox* Seg_tube = new TGeoBBox("Seg_tube", 25 / 2., 50 / 2., 0.5 / 2.);
193 TGeoTube* tube1 = new TGeoTube("tube1", MinRadiusFe / 2, 18. / 2, 1. / 2);
194 TGeoTube* tube22 = new TGeoTube("tube22", 0, 10.699 / 2, 5. / 2);
195
196 TGeoTube* PbRing = new TGeoTube("PbRing", 8.101 / 2, 10.69 / 2, 0.5 / 2);
197
198 TGeoCompositeShape* prot_form = new TGeoCompositeShape("prot_form", "Seg_tube:Seg_tube_trans - tube22:pos_trans1");
199
200 Double_t phi = 90 * TMath::DegToRad(), delta_phi = 360. / 40., dphi = delta_phi * TMath::DegToRad();
201
202 TGeoCombiTrans* combi[41];
203
204 for (Int_t i = 1; i < 41; i++) {
205 combi[i] = new TGeoCombiTrans(rr * TMath::Cos(dphi * (i + 0.5)), rr * TMath::Sin(dphi * (i + 0.5)),
206 strip_BD_Zpos, new TGeoRotation("rot", dphi1 * (i + 0.5), 0., 0.));
207 }
208
209 TGeoVolume* BD1ActiveVolumeV1 = new TGeoVolume("BD1ActiveVolumeV1", strip);
210 BD1ActiveVolumeV1->SetMedium(pMedBC408);
211 BD1ActiveVolumeV1->SetLineColor(kYellow - 10);
212
213 TGeoVolume* tubefeMat = new TGeoVolume("tubefeMat", tubefeContainerS);
214 tubefeMat->SetMedium(pMediron);
215 tubefeMat->SetLineColor(kOrange - 1);
216
217 TGeoVolume* tubealMat = new TGeoVolume("tubealMat", tubealContainerS);
218 tubealMat->SetMedium(pMedaluminium);
219 tubealMat->SetLineColor(kCyan - 10);
220
221 TGeoVolume* tubepb_prot = new TGeoVolume("tubepb_prot", tubepbContainerS);
222 tubepb_prot->SetMedium(pMedlead);
223 // tubepb_prot->SetMedium(pMedcopper);
224 tubepb_prot->SetLineColor(kGray);
225
226 TGeoVolume* seg_tube_prot = new TGeoVolume("seg_tube_prot", prot_form);
227 seg_tube_prot->SetMedium(pMedlead);
228 // seg_tube_prot->SetMedium(pMedcopper);
229 seg_tube_prot->SetLineColor(kGray);
230
231 TGeoVolume* tube1Mat = new TGeoVolume("tube1Mat", tube1);
232 tube1Mat->SetMedium(pMediron);
233 tube1Mat->SetLineColor(kOrange - 1);
234
235 TGeoVolume* Pbring_prot = new TGeoVolume("Pbring_prot", PbRing);
236 Pbring_prot->SetMedium(pMedlead);
237 // Pbring_prot->SetMedium(pMedcopper);
238 Pbring_prot->SetLineColor(kGray);
239
240 for (Int_t i = 1; i < 41; i++) {
241 BD->AddNode(BD1ActiveVolumeV1, i, combi[i]);
242 }
243
244 // BD->AddNode(tubefeMat, 41, tubefePos_trans);
245 // BD->AddNode(tubealMat, 42, tubealPos_trans);
246
247 BD->AddNode(Pbring_prot, 42, trans_Pbring);
248 BD->AddNode(tubepb_prot, 43, Postubepb_trans);
249 BD->AddNode(seg_tube_prot, 44);
250 BD->AddNode(tube1Mat, 45, Postube1);
251
252 // Adding volumes to the TOP Volume
253 top->AddNode(BD, 1, BD_Position);
254
256
257 // --------------- Finish -----------------------------------------------
258 gGeoMan->CloseGeometry();
259 gGeoMan->CheckOverlaps(0.001);
260 gGeoMan->PrintOverlaps();
261 gGeoMan->Test();
262
263 TFile* geoFile = new TFile(geoFileName, "RECREATE");
264 top->Write();
265 geoFile->Close();
266 top->Draw("ogl");
267 // top->Draw("");
268}
int i
Definition P4_F32vec4.h:22
int Int_t
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
virtual void RegisterYourself()
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
const Double_t Seg_tube_Max_dim
const Double_t MinRadiusOfDiv
const Double_t Seg_tube_Max_phi
const Double_t Seg_tube_Thick
const Double_t Seg_tube_Min_dim
const Double_t Seg_tube_Min_phi
void create_bd_root_run9()
const Double_t MaxRadiusOfDiv
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)