BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_BD_run8.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
55
58
60
62{
63
64 // ------- Load media from media file -----------------------------------
65 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
66 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
67 TString geoPath = gSystem->Getenv("VMCWORKDIR");
68 TString medFile = geoPath + "/geometry/media.geo";
69 geoFace->setMediaFile(medFile);
70 geoFace->readMedia();
72 // --------------------------------------------------------------------------
73
74 // ------- Geometry file name (output) ----------------------------------
75 const TString geoDetectorName = "BD";
76 const TString geoDetectorVersion = "run8_v1";
77 TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
78 // --------------------------------------------------------------------------
79
80 // ----------------- Get and create the required media -----------------
81 FairGeoMedia* geoMedia = geoFace->getMedia();
82 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
83
84 FairGeoMedium* mAir = geoMedia->getMedium("air");
85 if (!mAir)
86 Fatal("Main", "FairMedium air not found");
87 geoBuild->createMedium(mAir);
88 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
89 if (!pMedAir)
90 Fatal("Main", "Medium air not found");
91
92 FairGeoMedium* mBC408 = geoMedia->getMedium("BC408");
93 if (!mBC408)
94 Fatal("Main", "FairMedium BC408 not found");
95 geoBuild->createMedium(mBC408);
96 TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
97 if (!pMedBC408)
98 Fatal("Main", "Medium BC408 not found");
99
100 FairGeoMedium* miron = geoMedia->getMedium("iron");
101 if (!miron)
102 Fatal("Main", "FairMedium iron not found");
103 geoBuild->createMedium(miron);
104 TGeoMedium* pMediron = gGeoMan->GetMedium("iron");
105 if (!pMediron)
106 Fatal("Main", "Medium iron not found");
107
108 FairGeoMedium* maluminium = geoMedia->getMedium("aluminium");
109 if (!maluminium)
110 Fatal("Main", "FairMedium aluminium not found");
111 geoBuild->createMedium(maluminium);
112 TGeoMedium* pMedaluminium = gGeoMan->GetMedium("aluminium");
113 if (!pMedaluminium)
114 Fatal("Main", "Medium aluminium not found");
115
116 FairGeoMedium* mpolypropylene = geoMedia->getMedium("polypropylene");
117 if (!mpolypropylene)
118 Fatal("Main", "FairMedium polypropylene not found");
119 geoBuild->createMedium(mpolypropylene);
120 TGeoMedium* pMedpolypropylene = gGeoMan->GetMedium("polypropylene");
121 if (!pMedpolypropylene)
122 Fatal("Main", "Medium polypropylene not found");
123
124 FairGeoMedium* mlead = geoMedia->getMedium("lead");
125 if (!mlead)
126 Fatal("Main", "FairMedium lead not found");
127 geoBuild->createMedium(mlead);
128 TGeoMedium* pMedlead = gGeoMan->GetMedium("lead");
129 if (!pMedlead)
130 Fatal("Main", "Medium lead not found");
131
132 FairGeoMedium* mVac = geoMedia->getMedium("vacuum");
133 if (!mVac)
134 Fatal("Main", "FairMedium vacuum not found");
135 geoBuild->createMedium(mVac);
136 TGeoMedium* pMedVac = gGeoMan->GetMedium("vacuum");
137 if (!pMedVac)
138 Fatal("Main", "Medium vacuum not found");
139
140 // --------------------------------------------------------------------------
141
142 // -------------- Create geometry and top volume -------------------------
143 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
144 gGeoMan->SetName(geoDetectorName + "_geom");
145 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
146 top->SetMedium(pMedAir);
147 gGeoMan->SetTopVolume(top);
148
149 // --------------------------------------------------------------------------
150
151 TGeoTranslation* BD_Position = new TGeoTranslation("BD_Position", 0, 0, 0);
152
153 // Define TOP Geometry
154 TGeoVolume* BD = new TGeoVolumeAssembly("BD");
155 BD->SetMedium(pMedVac);
156
157 TGeoTranslation* strips_BD1Pos_trans =
158 new TGeoTranslation("strips_BD1Pos_trans", strip_BD_Xpos, strip_BD_Ypos, strip_BD_Zpos);
159 TGeoTranslation* tubefePos_trans = new TGeoTranslation("tubefePos_trans", tubeFe_Xpos, tubeFe_Ypos, tubeFe_Zpos);
160 TGeoTranslation* tubealPos_trans = new TGeoTranslation("tubefePos_trans", tubeAl_Xpos, tubeAl_Ypos, tubeAl_Zpos);
161 TGeoTranslation* Postubepb_trans = new TGeoTranslation("Postubepb_trans", 0.0, 0.0, -4);
162 TGeoTranslation* Seg_tube_trans = new TGeoTranslation("Seg_tube_trans", 0, 0, 4.6);
163
164 TGeoBBox* strip = new TGeoBBox("srtip", 0.7 / 2., 0.7 / 2., 15. / 2.);
165 TGeoTube* tubefeContainerS = new TGeoTube("tubefeContainerS", MinRadiusFe / 2, MaxRadiusFe / 2, ZLength_tubeFe / 2);
166 TGeoTube* tubealContainerS = new TGeoTube("tubealContainerS", MinRadiusAl / 2, MaxRadiusAl / 2, ZLength_tubeAl / 2);
167 TGeoTube* tubepbContainerS = new TGeoTube("tubepbContainerS", 7.6 / 2, 8 / 2, 18.8 / 2);
168 TGeoTubeSeg* Seg_tube = new TGeoTubeSeg("Seg_tube", Seg_tube_Min_dim / 2, Seg_tube_Max_dim / 2, Seg_tube_Thick / 2,
170
171 Double_t phi = 90 * TMath::DegToRad(), delta_phi = 360. / 40., dphi = delta_phi * TMath::DegToRad();
172
173 TGeoCombiTrans* combi[41];
174
175 for (Int_t i = 1; i < 41; i++) {
176 combi[i] = new TGeoCombiTrans(rr * TMath::Cos(dphi * (i + 0.5)), rr * TMath::Sin(dphi * (i + 0.5)),
177 strip_BD_Zpos, new TGeoRotation("rot", dphi1 * (i + 0.5), 0., 0.));
178 }
179
180 TGeoVolume* BD1ActiveVolumeV1 = new TGeoVolume("BD1ActiveVolumeV1", strip);
181 BD1ActiveVolumeV1->SetMedium(pMedBC408);
182 BD1ActiveVolumeV1->SetLineColor(kYellow - 10);
183
184 TGeoVolume* tubefeMat = new TGeoVolume("tubefeMat", tubefeContainerS);
185 tubefeMat->SetMedium(pMediron);
186 tubefeMat->SetLineColor(kOrange - 1);
187
188 TGeoVolume* tubealMat = new TGeoVolume("tubealMat", tubealContainerS);
189 tubealMat->SetMedium(pMedaluminium);
190 tubealMat->SetLineColor(kCyan - 10);
191
192 TGeoVolume* tubepb_prot = new TGeoVolume("tubepb_prot", tubepbContainerS);
193 tubepb_prot->SetMedium(pMedlead);
194 tubepb_prot->SetLineColor(kRed);
195
196 TGeoVolume* seg_tube_prot = new TGeoVolume("seg_tube_prot", Seg_tube);
197 seg_tube_prot->SetMedium(pMedlead);
198 seg_tube_prot->SetLineColor(kRed);
199
200 for (Int_t i = 1; i < 41; i++) {
201 BD->AddNode(BD1ActiveVolumeV1, i, combi[i]);
202 }
203
204 BD->AddNode(tubefeMat, 41, tubefePos_trans);
205 BD->AddNode(tubealMat, 42, tubealPos_trans);
206 BD->AddNode(tubepb_prot, 43, Postubepb_trans);
207 BD->AddNode(seg_tube_prot, 44, Seg_tube_trans);
208
209 // Adding volumes to the TOP Volume
210 top->AddNode(BD, 1, BD_Position);
211
213
214 // --------------- Finish -----------------------------------------------
215 gGeoMan->CloseGeometry();
216 gGeoMan->CheckOverlaps(0.001);
217 gGeoMan->PrintOverlaps();
218 gGeoMan->Test();
219
220 TFile* geoFile = new TFile(geoFileName, "RECREATE");
221 top->Write();
222 geoFile->Close();
223 top->Draw("ogl");
224 // top->Draw("");
225}
int i
Definition P4_F32vec4.h:22
int Int_t
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
kRed
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
const Double_t Seg_tube_Max_dim
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_rootgeom_BD_run8()
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)