BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_bd64_root.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 = 0.0; // cm
20// const Double_t strip_BD_Zpos = -3.5; //cm
21
22// const Double_t dphi1 = 360./40;
23const Double_t rr = 7.55;
24
26{
27
28 // ------- Load media from media file -----------------------------------
29 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
30 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
31 TString geoPath = gSystem->Getenv("VMCWORKDIR");
32 TString medFile = geoPath + "/geometry/media.geo";
33 geoFace->setMediaFile(medFile);
34 geoFace->readMedia();
36 // --------------------------------------------------------------------------
37
38 // ------- Geometry file name (output) ----------------------------------
39 const TString geoDetectorName = "root_geom_BD64";
40 const TString geoDetectorVersion = "v1";
41 TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
42 // --------------------------------------------------------------------------
43
44 // ----------------- Get and create the required media -----------------
45 FairGeoMedia* geoMedia = geoFace->getMedia();
46 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
47
48 FairGeoMedium* mAir = geoMedia->getMedium("air");
49 if (!mAir)
50 Fatal("Main", "FairMedium air not found");
51 geoBuild->createMedium(mAir);
52 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
53 if (!pMedAir)
54 Fatal("Main", "Medium air not found");
55
56 FairGeoMedium* mBC408 = geoMedia->getMedium("BC408");
57 if (!mBC408)
58 Fatal("Main", "FairMedium BC408 not found");
59 geoBuild->createMedium(mBC408);
60 TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
61 if (!pMedBC408)
62 Fatal("Main", "Medium BC408 not found");
63
64 FairGeoMedium* miron = geoMedia->getMedium("iron");
65 if (!miron)
66 Fatal("Main", "FairMedium iron not found");
67 geoBuild->createMedium(miron);
68 TGeoMedium* pMediron = gGeoMan->GetMedium("iron");
69 if (!pMediron)
70 Fatal("Main", "Medium iron not found");
71
72 FairGeoMedium* maluminium = geoMedia->getMedium("aluminium");
73 if (!maluminium)
74 Fatal("Main", "FairMedium aluminium not found");
75 geoBuild->createMedium(maluminium);
76 TGeoMedium* pMedaluminium = gGeoMan->GetMedium("aluminium");
77 if (!pMedaluminium)
78 Fatal("Main", "Medium aluminium not found");
79
80 FairGeoMedium* mpolypropylene = geoMedia->getMedium("polypropylene");
81 if (!mpolypropylene)
82 Fatal("Main", "FairMedium polypropylene not found");
83 geoBuild->createMedium(mpolypropylene);
84 TGeoMedium* pMedpolypropylene = gGeoMan->GetMedium("polypropylene");
85 if (!pMedpolypropylene)
86 Fatal("Main", "Medium polypropylene not found");
87
88 FairGeoMedium* mlead = geoMedia->getMedium("lead");
89 if (!mlead)
90 Fatal("Main", "FairMedium lead not found");
91 geoBuild->createMedium(mlead);
92 TGeoMedium* pMedlead = gGeoMan->GetMedium("lead");
93 if (!pMedlead)
94 Fatal("Main", "Medium lead not found");
95
96 FairGeoMedium* mVac = geoMedia->getMedium("vacuum");
97 if (!mVac)
98 Fatal("Main", "FairMedium vacuum not found");
99 geoBuild->createMedium(mVac);
100 TGeoMedium* pMedVac = gGeoMan->GetMedium("vacuum");
101 if (!pMedVac)
102 Fatal("Main", "Medium vacuum not found");
103
104 FairGeoMedium* mcopper = geoMedia->getMedium("copper");
105 if (!mcopper)
106 Fatal("Main", "FairMedium copper not found");
107 geoBuild->createMedium(mcopper);
108 TGeoMedium* pMedcopper = gGeoMan->GetMedium("copper");
109 if (!pMedcopper)
110 Fatal("Main", "Medium copper not found");
111
112 // --------------------------------------------------------------------------
113
114 // -------------- Create geometry and top volume -------------------------
115 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
116 gGeoMan->SetName(geoDetectorName + "_geom");
117 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
118 top->SetMedium(pMedAir);
119 gGeoMan->SetTopVolume(top);
120
121 // --------------------------------------------------------------------------
122
123 TGeoTranslation* BD_Position = new TGeoTranslation("BD_Position", 0, 0, 2.75);
124
125 // Define TOP Geometry
126 TGeoVolume* BD = new TGeoVolumeAssembly("BD");
127 BD->SetMedium(pMedVac);
128
129 TGeoTranslation* strips_BD1Pos_trans = new TGeoTranslation("strips_BD1Pos_trans", 0, 0, 0);
130 TGeoTranslation* tubeCu_trans = new TGeoTranslation("tubeCu_trans", 0, 0, -0.8);
131 TGeoTranslation* tubeCu_2_trans = new TGeoTranslation("tubeCu_2_trans", 0, 0, -2);
132 // TGeoTranslation *tubeCu_2_trans = new TGeoTranslation("tubeCu_2_trans", 0, 0, -6);
133 TGeoTranslation* tubeCu_3_trans = new TGeoTranslation("tubeCu_3_trans", 0, 0, -5.2);
134 TGeoTranslation* tubeCu_4_trans = new TGeoTranslation("tubeCu_4_trans", 0, 0, 3.2);
135
136 TGeoTranslation* Seg_tube_trans = new TGeoTranslation("Seg_tube_trans", -14.5, 0, 3.2);
137 // TGeoTranslation *Seg_tube_trans = new TGeoTranslation("Seg_tube_trans", -25, 0, 2.5);
138 Seg_tube_trans->RegisterYourself();
139
140 TGeoTranslation* pos_trans1 = new TGeoTranslation("pos_trans1", 0, 0, 5);
141 pos_trans1->RegisterYourself();
142
143 TGeoTranslation* poss_trans = new TGeoTranslation("poss_trans", 14.5, 0, -4);
144
145 TGeoBBox* strip = new TGeoBBox("srtip", 0.505 / 2., 0.705 / 2., 5.7 / 2.);
146 TGeoTube* tubeCu = new TGeoTube("tubeCu", 12 / 2., 14 / 2., 8 / 2.);
147 // TGeoTube *tubeCu = new TGeoTube("tubeCu", 13.4/2., 14.4/2., 6.5/2.);
148
149 // TGeoTube *tubeCu_2 = new TGeoTube("tubeCu_2", 10.4/2., 11/2., 5/2.);
150 TGeoTube* tubeCu_2 = new TGeoTube("tubeCu_2", 12.4 / 2., 13.4 / 2., 6 / 2.);
151 // TGeoTube *tubeCu_2 = new TGeoTube("tubeCu_2", 10.4/2., 11/2., 10/2.);
152
153 TGeoTube* tubeCu_3 = new TGeoTube("tubeCu_3", 11 / 2., 16 / 2., 0.5 / 2.);
154 TGeoTube* tubeCu_4 = new TGeoTube("tubeCu_4", 14.4 / 2., 16 / 2., 0.5 / 2.);
155
156 // TGeoTube *tube22 = new TGeoTube("tube22", 0, 15.8/2, 10./2);
157 // TGeoBBox *Seg_tube = new TGeoBBox("Seg_tube", 20/2., 25/2., 0.5/2.);
158
159 TGeoBBox* tube22 = new TGeoBBox("tube22", 30 / 2., 30 / 2., 30 / 2.);
160 TGeoTube* Seg_tube = new TGeoTube("Seg_tube", 11 / 2., 12 / 2., 8 / 2.);
161
162 TGeoCompositeShape* prot_form = new TGeoCompositeShape("prot_form", "Seg_tube:Seg_tube_trans - tube22:pos_trans1");
163
164 Double_t phi = 90 * TMath::DegToRad(), delta_phi = 360. / 64., dphi = delta_phi * TMath::DegToRad();
165
166 TGeoCombiTrans* combi[65];
167
168 for (Int_t i = 1; i < 65; i++) {
169 combi[i] = new TGeoCombiTrans(rr * TMath::Cos(dphi * (i + 0.5)), rr * TMath::Sin(dphi * (i + 0.5)),
170 strip_BD_Zpos, new TGeoRotation("rot", delta_phi * (i + 0.5), 0., 0.));
171 }
172
173 TGeoVolume* BD1ActiveVolumeV1 = new TGeoVolume("BD1ActiveVolumeV1", strip);
174 BD1ActiveVolumeV1->SetMedium(pMedBC408);
175 BD1ActiveVolumeV1->SetLineColor(kCyan - 7);
176
177 TGeoVolume* tubeCuMat = new TGeoVolume("tubeCuMat", tubeCu);
178 tubeCuMat->SetMedium(pMedcopper);
179 tubeCuMat->SetLineColor(kOrange + 1);
180
181 TGeoVolume* tubeCuMat_2 = new TGeoVolume("tubeCuMat_2", tubeCu_2);
182 tubeCuMat_2->SetMedium(pMedcopper);
183 tubeCuMat_2->SetLineColor(kOrange + 1);
184
185 TGeoVolume* tubeCuMat_3 = new TGeoVolume("tubeCuMat_3", tubeCu_3);
186 tubeCuMat_3->SetMedium(pMedcopper);
187 tubeCuMat_3->SetLineColor(kRed);
188
189 TGeoVolume* tubeCuMat_4 = new TGeoVolume("tubeCuMat_4", tubeCu_4);
190 tubeCuMat_4->SetMedium(pMedcopper);
191 tubeCuMat_4->SetLineColor(kOrange + 1);
192
193 TGeoVolume* seg_tube_prot = new TGeoVolume("seg_tube_prot", prot_form);
194 seg_tube_prot->SetMedium(pMedcopper);
195 // seg_tube_prot->SetLineColor(kOrange+1);
196 seg_tube_prot->SetLineColor(kBlue);
197
198 for (Int_t i = 1; i < 65; i++) {
199 BD->AddNode(BD1ActiveVolumeV1, i, combi[i]);
200 }
201
202 BD->AddNode(tubeCuMat, 65, tubeCu_trans);
203 // BD->AddNode(tubeCuMat_2, 66, tubeCu_2_trans);
204 BD->AddNode(tubeCuMat_3, 67, tubeCu_3_trans);
205 BD->AddNode(tubeCuMat_4, 68, tubeCu_4_trans);
206 BD->AddNode(seg_tube_prot, 69, poss_trans);
207
208 // Adding volumes to the TOP Volume
209
210 top->AddNode(BD, 1, BD_Position);
212
213 // --------------- Finish -----------------------------------------------
214 gGeoMan->CloseGeometry();
215 gGeoMan->CheckOverlaps(0.001);
216 gGeoMan->PrintOverlaps();
217 gGeoMan->Test();
218
219 TFile* geoFile = new TFile(geoFileName, "RECREATE");
220 top->Write();
221 geoFile->Close();
222 top->Draw("ogl");
223 // top->Draw("");
224}
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
kBlue
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
void create_bd64_root()
const Double_t strip_BD_Zpos
const Double_t rr
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)