BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_TOF400_RUN7_SRC_v2.C
Go to the documentation of this file.
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6
7/*
8 * File: create_rootgeom_TOF400_RUN7_SRC_v2.C
9 * Author: mikhailr
10 *
11 * Created on February 7, 2020, 3:08 PM
12 */
13
14R__ADD_INCLUDE_PATH($VMCWORKDIR)
15#include "macro/run/bmnloadlibs.C"
16
17using namespace std;
18using namespace TMath;
19
21{
22 // Load the necessary FairRoot libraries
23 // gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
24 bmnloadlibs(); // load libraries
25
26 // ------- Load media from media file --------------------------------
27 TGeoManager* gGeoMan;
28 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
29 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
30 TString geoPath = gSystem->Getenv("VMCWORKDIR");
31 TString medFile = geoPath + "/geometry/media.geo";
32 geoFace->setMediaFile(medFile);
33 geoFace->readMedia();
34 gGeoMan = gGeoManager;
35
36 // ------- Geometry file name (output) -------------------------------
37 const TString geoDetectorName = "TOF400";
38 const TString geoDetectorVersion = "RUN7_SRC_AllignmentZY_v4";
39 const TString geoFileName = Form("%s_%s%s", geoDetectorName.Data(), geoDetectorVersion.Data(), ".root");
40
41 // ----------------- Get and create the required media --------------
42 FairGeoMedia* geoMedia = geoFace->getMedia();
43 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
44
45 // Air
46 FairGeoMedium* matAir = geoMedia->getMedium("air");
47 if (!matAir)
48 Fatal("Main", "FairMedium air not found");
49 geoBuild->createMedium(matAir);
50 TGeoMedium* medAir = gGeoMan->GetMedium("air");
51 if (!medAir)
52 Fatal("Main", "Medium air not found");
53
54 // Polypropylene
55 FairGeoMedium* matPprop = geoMedia->getMedium("polypropylene");
56 if (!matPprop)
57 Fatal("Main", "FairMedium polypropylene not found");
58 geoBuild->createMedium(matPprop);
59 TGeoMedium* medPprop = gGeoMan->GetMedium("polypropylene");
60 if (!medPprop)
61 Fatal("Main", "Medium polypropylene not found");
62
63 // lead
64 FairGeoMedium* matPb = geoMedia->getMedium("lead");
65 if (!matPb)
66 Fatal("Main", "FairMedium lead not found");
67 geoBuild->createMedium(matPb);
68 TGeoMedium* medPb = gGeoMan->GetMedium("lead");
69 if (!medPb)
70 Fatal("Main", "Medium lead not found");
71
72 // aluminium
73 FairGeoMedium* matAl = geoMedia->getMedium("aluminium");
74 if (!matAl)
75 Fatal("Main", "FairMedium aluminium not found");
76 geoBuild->createMedium(matAl);
77 TGeoMedium* medAl = gGeoMan->GetMedium("aluminium");
78 if (!medAl)
79 Fatal("Main", "Medium aluminium not found");
80
81 // RPCglass
82 FairGeoMedium* matGlass = geoMedia->getMedium("RPCglass");
83 if (!matGlass)
84 Fatal("Main", "FairMedium RPCglass not found");
85 geoBuild->createMedium(matGlass);
86 TGeoMedium* medGlass = gGeoMan->GetMedium("RPCglass");
87 if (!medGlass)
88 Fatal("Main", "Medium RPCglass not found");
89
90 // RPCgas
91 FairGeoMedium* matGas = geoMedia->getMedium("RPCgas");
92 if (!matGas)
93 Fatal("Main", "FairMedium RPCgas not found");
94 geoBuild->createMedium(matGas);
95 TGeoMedium* medGas = gGeoMan->GetMedium("RPCgas");
96 if (!medGas)
97 Fatal("Main", "Medium RPCgas not found");
98
99 // G10
100 FairGeoMedium* matG10 = geoMedia->getMedium("G10");
101 if (!matG10)
102 Fatal("Main", "FairMedium G10 not found");
103 geoBuild->createMedium(matG10);
104 TGeoMedium* medG10 = gGeoMan->GetMedium("G10");
105 if (!medG10)
106 Fatal("Main", "Medium G10 not found");
107
108 // ----------------------------------------- Create geometry and top volume
109 // -----------------------------------------------
110 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
111 gGeoMan->SetName(geoDetectorName + "_geom");
112 TGeoVolume* top = new TGeoVolumeAssembly("TOP"); // TOP VOLUME
113 top->SetMedium(medAir);
114 gGeoMan->SetTopVolume(top);
115 gGeoMan->SetTopVisible(1);
116 gGeoMan->SetVisLevel(7);
117
118 // --------------------------------------- Define TOP Geometry ------------------------------------
119 TGeoVolume* topTof = new TGeoVolumeAssembly(geoDetectorName);
120 topTof->SetMedium(medAir);
121
122 TGeoVolume* vDetector = new TGeoVolumeAssembly("tof1Detector");
123 vDetector->SetMedium(medAir);
124
125 const double DetXsize = 60.; // [cm]
126 const double DetYsize = 30.; // [cm]
127 const double DetZsize = 3.0; // [cm]
128 // --------------------- Create strip ------------------
129 const float stripGasX = 1., stripGasY = DetYsize, stripGasZ = 0.3; // [cm]
130 TGeoBBox* sStripGas = new TGeoBBox(stripGasX / 2., stripGasY / 2., stripGasZ / 2.);
131 sStripGas->SetName("StripGas");
132 TGeoVolume* vStripGas = new TGeoVolume("tof1StripActiveGasV", sStripGas, medGas);
133 vStripGas->SetLineColor(kRed);
134
135 // --------------------- Create Glass plates ------------------
136 const float detGlassX = DetXsize, detGlassY = DetYsize, detGlassZ = 0.618 / 2.; // [cm] 6.18 mm / 2 plate
137 TGeoBBox* sDetGlass = new TGeoBBox(detGlassX / 2., detGlassY / 2., detGlassZ / 2.);
138 sDetGlass->SetName("DetectorGlass");
139 TGeoVolume* vDetGlass = new TGeoVolume("tof1DetGlassV", sDetGlass, medGlass);
140 vDetGlass->SetLineColor(kYellow);
141
142 // --------------------- Create G10 plates ------------------
143 const float detPlateX = DetXsize, detPlateY = DetYsize, detPlateZ = 0.64 / 2.; // [cm] 6.4 mm / 2 plate
144 TGeoBBox* sDetPlate = new TGeoBBox(detPlateX / 2., detPlateY / 2., detPlateZ / 2.);
145 sDetPlate->SetName("DetectorPlate");
146 TGeoVolume* vDetPlate = new TGeoVolume("tof1DetPlateV", sDetPlate, medG10);
147 vDetPlate->SetLineColor(kBlue);
148
149 // --------------------------------------- Assemble detector
150
151 // Add strips
152 const int NStrips = 48; // 24 strips group
153 const double StripStep = 1.25; // [cm]
154 for (int i = 0; i < NStrips; i++) {
155 vDetector->AddNode(vStripGas, i + 1,
156 new TGeoTranslation("", -DetXsize / 2. + StripStep / 2. + i * StripStep, 0., 0.));
157 }
158
159 // Add Glass plates
160 vDetector->AddNode(vDetGlass, 1, new TGeoTranslation("", 0., 0., -stripGasZ / 2. - detGlassZ / 2.));
161 vDetector->AddNode(vDetGlass, 2, new TGeoTranslation("", 0., 0., +stripGasZ / 2. + detGlassZ / 2.));
162
163 // Add G10 plates
164 vDetector->AddNode(vDetPlate, 1, new TGeoTranslation("", 0., 0., -DetZsize / 2. + detPlateZ / 2.));
165 vDetector->AddNode(vDetPlate, 2, new TGeoTranslation("", 0., 0., +DetZsize / 2. - detPlateZ / 2.));
166
167 // -------------------------------------- Install Detectors
168 const double tofZgap = 0.9; // 9 mm between detectors
169 const double tofYoverlap = 3.0; // 30 mm detectors overlap at Y direction
170 double tofZshift = tofZgap + DetZsize;
171
172 /*
173 |--|
174 | |
175 |--| |__|
176 | |
177 |__| |--|
178 | | <----- Z
179 |--| |__|
180 | |
181 |__| |--|
182 | |
183 |__|
184 |
185 |
186 tofZ_Xbox is centr of the PRC
187 */
188
189 // 1 box
190 Double_t angleDegBox1 = 29.52;
191 const double tofZ_1box = -214.27; // [cm] :
192 double box1_x = 282.34; // [cm]
193 double box1_y = 0.44 - 2.3; // [cm]
194
195 TGeoRotation* geoRot = new TGeoRotation;
196 geoRot->RotateY(angleDegBox1);
197
198 TGeoCombiTrans* cR1 = new TGeoCombiTrans("", box1_x, 2. * DetYsize - 2 * tofYoverlap + box1_y, tofZ_1box, geoRot);
199 topTof->AddNode(vDetector, 1, cR1); // right side, x > 0
200
201 TGeoCombiTrans* cR2 = new TGeoCombiTrans("", box1_x + Sin(DegToRad() * angleDegBox1) * tofZshift,
202 1. * DetYsize - tofYoverlap + box1_y,
203 tofZ_1box + Cos(DegToRad() * angleDegBox1) * tofZshift, geoRot);
204 topTof->AddNode(vDetector, 2, cR2);
205
206 TGeoCombiTrans* cR3 = new TGeoCombiTrans("", box1_x, box1_y, tofZ_1box, geoRot);
207 topTof->AddNode(vDetector, 3, cR3);
208
209 TGeoCombiTrans* cR4 = new TGeoCombiTrans("", box1_x + Sin(DegToRad() * angleDegBox1) * tofZshift,
210 -1. * DetYsize + tofYoverlap + box1_y,
211 tofZ_1box + Cos(DegToRad() * angleDegBox1) * tofZshift, geoRot);
212 topTof->AddNode(vDetector, 4, cR4);
213
214 TGeoCombiTrans* cR5 = new TGeoCombiTrans("", box1_x, -2. * DetYsize + 2 * tofYoverlap + box1_y, tofZ_1box, geoRot);
215 topTof->AddNode(vDetector, 5, cR5);
216
217 // 2 box
218 Double_t angleDegBox2 = 29.52;
219 const double tofZ_2box = -195.52; // [cm] :
220 double box2_x = 226.9; // [cm]
221 double box2_y = 0.09 - 2.3; // [cm]
222
223 // Double_t angleDegBox2 = 0;
224 // const double tofZ_2box = 499.27; // [cm] :
225 // double box2_x = -28.34; // [cm]
226 // double box2_y = 0; // [cm]
227
228 TGeoRotation* geoRot2 = new TGeoRotation;
229 geoRot2->RotateY(angleDegBox2);
230
231 TGeoCombiTrans* cR6 = new TGeoCombiTrans("", box2_x, 2. * DetYsize - 2 * tofYoverlap + box2_y, tofZ_2box, geoRot2);
232 topTof->AddNode(vDetector, 6, cR6); // right side, x > 0
233
234 TGeoCombiTrans* cR7 = new TGeoCombiTrans("", box2_x + Sin(DegToRad() * angleDegBox2) * tofZshift,
235 1. * DetYsize - tofYoverlap + box2_y,
236 tofZ_2box + Cos(DegToRad() * angleDegBox2) * tofZshift, geoRot2);
237 topTof->AddNode(vDetector, 7, cR7);
238
239 TGeoCombiTrans* cR8 = new TGeoCombiTrans("", box2_x, 0 + box2_y, tofZ_2box, geoRot2);
240 topTof->AddNode(vDetector, 8, cR8);
241
242 TGeoCombiTrans* cR9 = new TGeoCombiTrans("", box2_x + Sin(DegToRad() * angleDegBox2) * tofZshift,
243 -1. * DetYsize + tofYoverlap + box2_y,
244 tofZ_2box + Cos(DegToRad() * angleDegBox2) * tofZshift, geoRot2);
245 topTof->AddNode(vDetector, 9, cR9);
246
247 TGeoCombiTrans* cR10 = new TGeoCombiTrans("", box2_x, -2 * DetYsize + 2 * tofYoverlap + box2_y, tofZ_2box, geoRot2);
248 topTof->AddNode(vDetector, 10, cR10);
249
250 // 3 box
251 Double_t angleDegBox3 = -28.45;
252 const double tofZ_3box = -194.78; // [cm] :
253 double box3_x = -227.6; // [cm]
254 double box3_y = -1.81 - 2.3; // [cm]
255
256 TGeoRotation* geoRot3 = new TGeoRotation;
257 geoRot3->RotateY(angleDegBox3);
258
259 TGeoCombiTrans* cR11 = new TGeoCombiTrans("", box3_x, 2. * DetYsize - 2 * tofYoverlap + box3_y, tofZ_3box, geoRot3);
260 topTof->AddNode(vDetector, 11, cR11); // right side, x > 0
261
262 TGeoCombiTrans* cR12 = new TGeoCombiTrans("", box3_x + Sin(DegToRad() * angleDegBox3) * tofZshift,
263 1. * DetYsize - tofYoverlap + box3_y,
264 tofZ_3box + Cos(DegToRad() * angleDegBox3) * tofZshift, geoRot3);
265 topTof->AddNode(vDetector, 12, cR12);
266
267 TGeoCombiTrans* cR13 = new TGeoCombiTrans("", box3_x, 0 + box3_y, tofZ_3box, geoRot3);
268 topTof->AddNode(vDetector, 13, cR13);
269
270 TGeoCombiTrans* cR14 = new TGeoCombiTrans("", box3_x + Sin(DegToRad() * angleDegBox3) * tofZshift,
271 -1. * DetYsize + tofYoverlap + box3_y,
272 tofZ_3box + Cos(DegToRad() * angleDegBox3) * tofZshift, geoRot3);
273 topTof->AddNode(vDetector, 14, cR14);
274
275 TGeoCombiTrans* cR15 = new TGeoCombiTrans("", box3_x, -2 * DetYsize + 2 * tofYoverlap + box3_y, tofZ_3box, geoRot3);
276 topTof->AddNode(vDetector, 15, cR15);
277
278 // 4 box
279 Double_t angleDegBox4 = -28.55;
280 const double tofZ_4box = -210.45; // [cm]
281 double box4_x = -284.6; // [cm]
282 double box4_y = -1.81 - 2.3; // [cm]
283
284 TGeoRotation* geoRot4 = new TGeoRotation;
285 geoRot4->RotateY(angleDegBox4);
286
287 TGeoCombiTrans* cR16 = new TGeoCombiTrans("", box4_x, 2. * DetYsize - 2 * tofYoverlap + box4_y, tofZ_4box, geoRot4);
288 topTof->AddNode(vDetector, 16, cR16); // right side, x > 0
289
290 TGeoCombiTrans* cR17 = new TGeoCombiTrans("", box4_x + Sin(DegToRad() * angleDegBox4) * tofZshift,
291 1. * DetYsize - tofYoverlap + box4_y,
292 tofZ_4box + Cos(DegToRad() * angleDegBox4) * tofZshift, geoRot4);
293 topTof->AddNode(vDetector, 17, cR17);
294
295 TGeoCombiTrans* cR18 = new TGeoCombiTrans("", box4_x, 0 + box4_y, tofZ_4box, geoRot4);
296 topTof->AddNode(vDetector, 18, cR18);
297
298 TGeoCombiTrans* cR19 = new TGeoCombiTrans("", box4_x + Sin(DegToRad() * angleDegBox4) * tofZshift,
299 -1. * DetYsize + tofYoverlap + box4_y,
300 tofZ_4box + Cos(DegToRad() * angleDegBox4) * tofZshift, geoRot4);
301 topTof->AddNode(vDetector, 19, cR19);
302
303 TGeoCombiTrans* cR20 =
304 new TGeoCombiTrans("", box4_x, -2. * DetYsize + 2 * tofYoverlap + box4_y, tofZ_4box, geoRot4);
305 topTof->AddNode(vDetector, 20, cR20);
306
307 // ------------------ Adding the TOP Volume --------------------------
308 top->AddNode(topTof, 1, new TGeoTranslation("tw", 0., 0., 0.));
309
310 // --------------- Finish --------------------------------------------
312
313 gGeoMan->CloseGeometry();
314 gGeoMan->CheckOverlaps(0.001);
315 gGeoMan->PrintOverlaps();
316 gGeoMan->Test();
317
318 TFile* geoFile = new TFile(geoFileName, "RECREATE");
319 top->Write();
320 geoFile->Close();
321
322 top->Draw("ogl");
323 gGeoMan->Browse(new TBrowser);
324}
int i
Definition P4_F32vec4.h:22
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
kRed
kBlue
kYellow
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
void Close(Option_t *option="") override
void RotateY(Double_t angle) 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 void SetName(const char *name)
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
const char * Data() const
void create_rootgeom_TOF400_RUN7_SRC_v2()
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)
Definition json.hpp:4446