BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_TOF400_RUN7_SRC.C
Go to the documentation of this file.
1
2/*
3 * File: create_rootgeom_TOF400_RUN7_SRC.C
4 * Author: mikhailr
5 *
6 * Created on January 18, 2018, 12:19 PM
7 */
8R__ADD_INCLUDE_PATH($VMCWORKDIR)
9#include "macro/run/bmnloadlibs.C"
10
11using namespace std;
12
14{
15 // Load the necessary FairRoot libraries
16 // gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
17 bmnloadlibs(); // load libraries
18
19 // ------- Load media from media file --------------------------------
20 TGeoManager* gGeoMan;
21 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
22 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
23 TString geoPath = gSystem->Getenv("VMCWORKDIR");
24 TString medFile = geoPath + "/geometry/media.geo";
25 geoFace->setMediaFile(medFile);
26 geoFace->readMedia();
27 gGeoMan = gGeoManager;
28
29 // ------- Geometry file name (output) -------------------------------
30 const TString geoDetectorName = "TOF400";
31 const TString geoDetectorVersion = "RUN7_SRC_AllignmentZY";
32 const TString geoFileName = Form("%s_%s%s", geoDetectorName.Data(), geoDetectorVersion.Data(), ".root");
33
34 // ----------------- Get and create the required media --------------
35 FairGeoMedia* geoMedia = geoFace->getMedia();
36 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
37
38 // Air
39 FairGeoMedium* matAir = geoMedia->getMedium("air");
40 if (!matAir)
41 Fatal("Main", "FairMedium air not found");
42 geoBuild->createMedium(matAir);
43 TGeoMedium* medAir = gGeoMan->GetMedium("air");
44 if (!medAir)
45 Fatal("Main", "Medium air not found");
46
47 // Polypropylene
48 FairGeoMedium* matPprop = geoMedia->getMedium("polypropylene");
49 if (!matPprop)
50 Fatal("Main", "FairMedium polypropylene not found");
51 geoBuild->createMedium(matPprop);
52 TGeoMedium* medPprop = gGeoMan->GetMedium("polypropylene");
53 if (!medPprop)
54 Fatal("Main", "Medium polypropylene not found");
55
56 // lead
57 FairGeoMedium* matPb = geoMedia->getMedium("lead");
58 if (!matPb)
59 Fatal("Main", "FairMedium lead not found");
60 geoBuild->createMedium(matPb);
61 TGeoMedium* medPb = gGeoMan->GetMedium("lead");
62 if (!medPb)
63 Fatal("Main", "Medium lead not found");
64
65 // aluminium
66 FairGeoMedium* matAl = geoMedia->getMedium("aluminium");
67 if (!matAl)
68 Fatal("Main", "FairMedium aluminium not found");
69 geoBuild->createMedium(matAl);
70 TGeoMedium* medAl = gGeoMan->GetMedium("aluminium");
71 if (!medAl)
72 Fatal("Main", "Medium aluminium not found");
73
74 // RPCglass
75 FairGeoMedium* matGlass = geoMedia->getMedium("RPCglass");
76 if (!matGlass)
77 Fatal("Main", "FairMedium RPCglass not found");
78 geoBuild->createMedium(matGlass);
79 TGeoMedium* medGlass = gGeoMan->GetMedium("RPCglass");
80 if (!medGlass)
81 Fatal("Main", "Medium RPCglass not found");
82
83 // RPCgas
84 FairGeoMedium* matGas = geoMedia->getMedium("RPCgas");
85 if (!matGas)
86 Fatal("Main", "FairMedium RPCgas not found");
87 geoBuild->createMedium(matGas);
88 TGeoMedium* medGas = gGeoMan->GetMedium("RPCgas");
89 if (!medGas)
90 Fatal("Main", "Medium RPCgas not found");
91
92 // G10
93 FairGeoMedium* matG10 = geoMedia->getMedium("G10");
94 if (!matG10)
95 Fatal("Main", "FairMedium G10 not found");
96 geoBuild->createMedium(matG10);
97 TGeoMedium* medG10 = gGeoMan->GetMedium("G10");
98 if (!medG10)
99 Fatal("Main", "Medium G10 not found");
100
101 // ----------------------------------------- Create geometry and top volume
102 // -----------------------------------------------
103 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
104 gGeoMan->SetName(geoDetectorName + "_geom");
105 TGeoVolume* top = new TGeoVolumeAssembly("TOP"); // TOP VOLUME
106 top->SetMedium(medAir);
107 gGeoMan->SetTopVolume(top);
108 gGeoMan->SetTopVisible(1);
109 gGeoMan->SetVisLevel(7);
110
111 // --------------------------------------- Define TOP Geometry ------------------------------------
112 TGeoVolume* topTof = new TGeoVolumeAssembly(geoDetectorName);
113 topTof->SetMedium(medAir);
114
115 TGeoVolume* vDetector = new TGeoVolumeAssembly("tof1Detector");
116 vDetector->SetMedium(medAir);
117
118 const double DetXsize = 60.; // [cm]
119 const double DetYsize = 30.; // [cm]
120 const double DetZsize = 3.0; // [cm]
121 // --------------------- Create strip ------------------
122 const float stripGasX = 1., stripGasY = DetYsize, stripGasZ = 0.3; // [cm]
123 TGeoBBox* sStripGas = new TGeoBBox(stripGasX / 2., stripGasY / 2., stripGasZ / 2.);
124 sStripGas->SetName("StripGas");
125 TGeoVolume* vStripGas = new TGeoVolume("tof1StripActiveGasV", sStripGas, medGas);
126 vStripGas->SetLineColor(kRed);
127
128 // --------------------- Create Glass plates ------------------
129 const float detGlassX = DetXsize, detGlassY = DetYsize, detGlassZ = 0.618 / 2.; // [cm] 6.18 mm / 2 plate
130 TGeoBBox* sDetGlass = new TGeoBBox(detGlassX / 2., detGlassY / 2., detGlassZ / 2.);
131 sDetGlass->SetName("DetectorGlass");
132 TGeoVolume* vDetGlass = new TGeoVolume("tof1DetGlassV", sDetGlass, medGlass);
133 vDetGlass->SetLineColor(kYellow);
134
135 // --------------------- Create G10 plates ------------------
136 const float detPlateX = DetXsize, detPlateY = DetYsize, detPlateZ = 0.64 / 2.; // [cm] 6.4 mm / 2 plate
137 TGeoBBox* sDetPlate = new TGeoBBox(detPlateX / 2., detPlateY / 2., detPlateZ / 2.);
138 sDetPlate->SetName("DetectorPlate");
139 TGeoVolume* vDetPlate = new TGeoVolume("tof1DetPlateV", sDetPlate, medG10);
140 vDetPlate->SetLineColor(kBlue);
141
142 // --------------------------------------- Assemble detector
143
144 // Add strips
145 const int NStrips = 48; // 24 strips group
146 const double StripStep = 1.25; // [cm]
147 for (int i = 0; i < NStrips; i++) {
148 vDetector->AddNode(vStripGas, i + 1,
149 new TGeoTranslation("", -DetXsize / 2. + StripStep / 2. + i * StripStep, 0., 0.));
150 }
151
152 // Add Glass plates
153 vDetector->AddNode(vDetGlass, 1, new TGeoTranslation("", 0., 0., -stripGasZ / 2. - detGlassZ / 2.));
154 vDetector->AddNode(vDetGlass, 2, new TGeoTranslation("", 0., 0., +stripGasZ / 2. + detGlassZ / 2.));
155
156 // Add G10 plates
157 vDetector->AddNode(vDetPlate, 1, new TGeoTranslation("", 0., 0., -DetZsize / 2. + detPlateZ / 2.));
158 vDetector->AddNode(vDetPlate, 2, new TGeoTranslation("", 0., 0., +DetZsize / 2. - detPlateZ / 2.));
159
160 // -------------------------------------- Install Detectors
161 const double tofZgap = 0.86; // 8.6 mm between detectors
162 const double tofYoverlap = 3.0; // 30 mm detectors overlap at X direction
163
164 const double tofXgap = 0.; // [cm] RUN5, part1
165 // const double tofXgap = 2. * 24.4; // [cm] RUN5, part2
166 const double tofZ_1box = -234.705; // [cm] :
167 const double tofZ_2box = -217.27; // [cm] :
168 const double tofZ_3box = -217.27; // [cm] :
169 const double tofZ_4box = -234.705; // [cm] :
170
171 double tofX = tofXgap / 2. + DetXsize / 2.;
172 double tofZshift = -1. * (tofZgap + DetZsize);
173 double tofYshift = -2.9; //[cm] base on BM@N alignment
174 double box1_x = 277.299; // [cm]
175 double box2_x = 222.701; // [cm]
176 double box3_x = -222.701; // [cm]
177 double box4_x = -277.299; // [cm]
178
179 Double_t angleDegBox1_2 = 30., angleDegBox3_4 = -30.;
180
181 TGeoRotation* geoRot = new TGeoRotation;
182 geoRot->RotateY(angleDegBox1_2);
183
184 // 1 box
185 // topTof->AddNode(vDetector, 1, new TGeoTranslation("t1", box1_x, 2. * DetYsize - 2 * tofYoverlap, tofZ_1box
186 // + tofZshift)); // right side, x > 0
187 TGeoCombiTrans* cR1 =
188 new TGeoCombiTrans("", box1_x, 2. * DetYsize - 2 * tofYoverlap + tofYshift, tofZ_1box + tofZshift, geoRot);
189 topTof->AddNode(vDetector, 1, cR1); // right side, x > 0
190
191 TGeoCombiTrans* cR2 = new TGeoCombiTrans("", box1_x, 1. * DetYsize - tofYoverlap + tofYshift, tofZ_1box, geoRot);
192 topTof->AddNode(vDetector, 2, cR2);
193
194 TGeoCombiTrans* cR3 = new TGeoCombiTrans("", box1_x, 0 + tofYshift, tofZ_1box + tofZshift, geoRot);
195 topTof->AddNode(vDetector, 3, cR3);
196
197 TGeoCombiTrans* cR4 = new TGeoCombiTrans("", box1_x, -1. * DetYsize + tofYoverlap + tofYshift, tofZ_1box, geoRot);
198 topTof->AddNode(vDetector, 4, cR4);
199
200 TGeoCombiTrans* cR5 =
201 new TGeoCombiTrans("", box1_x, -2. * DetYsize + 2 * tofYoverlap + tofYshift, tofZ_1box + tofZshift, geoRot);
202 topTof->AddNode(vDetector, 5, cR5);
203
204 // 2 box
205 TGeoCombiTrans* cR6 =
206 new TGeoCombiTrans("", box2_x, 2. * DetYsize - 2 * tofYoverlap + tofYshift, tofZ_2box + tofZshift, geoRot);
207 topTof->AddNode(vDetector, 6, cR6); // right side, x > 0
208
209 TGeoCombiTrans* cR7 = new TGeoCombiTrans("", box2_x, 1. * DetYsize - tofYoverlap + tofYshift, tofZ_2box, geoRot);
210 topTof->AddNode(vDetector, 7, cR7);
211
212 TGeoCombiTrans* cR8 = new TGeoCombiTrans("", box2_x, 0 + tofYshift, tofZ_2box + tofZshift, geoRot);
213 topTof->AddNode(vDetector, 8, cR8);
214
215 TGeoCombiTrans* cR9 = new TGeoCombiTrans("", box2_x, -1. * DetYsize + tofYoverlap + tofYshift, tofZ_2box, geoRot);
216 topTof->AddNode(vDetector, 9, cR9);
217
218 TGeoCombiTrans* cR10 =
219 new TGeoCombiTrans("", box2_x, -2 * DetYsize + 2 * tofYoverlap + tofYshift, tofZ_2box + tofZshift, geoRot);
220 topTof->AddNode(vDetector, 10, cR10);
221
222 TGeoRotation* geoRot2 = new TGeoRotation;
223 geoRot2->RotateY(angleDegBox3_4);
224 // 3 box
225 TGeoCombiTrans* cR11 =
226 new TGeoCombiTrans("", box3_x, 2. * DetYsize - 2 * tofYoverlap + tofYshift, tofZ_2box + tofZshift, geoRot2);
227 topTof->AddNode(vDetector, 11, cR11); // right side, x > 0
228
229 TGeoCombiTrans* cR12 = new TGeoCombiTrans("", box3_x, 1. * DetYsize - tofYoverlap + tofYshift, tofZ_2box, geoRot2);
230 topTof->AddNode(vDetector, 12, cR12);
231
232 TGeoCombiTrans* cR13 = new TGeoCombiTrans("", box3_x, 0 + tofYshift, tofZ_2box + tofZshift, geoRot2);
233 topTof->AddNode(vDetector, 13, cR13);
234
235 TGeoCombiTrans* cR14 = new TGeoCombiTrans("", box3_x, -1. * DetYsize + tofYoverlap + tofYshift, tofZ_2box, geoRot2);
236 topTof->AddNode(vDetector, 14, cR14);
237
238 TGeoCombiTrans* cR15 =
239 new TGeoCombiTrans("", box3_x, -2 * DetYsize + 2 * tofYoverlap + tofYshift, tofZ_2box + tofZshift, geoRot2);
240 topTof->AddNode(vDetector, 15, cR15);
241
242 // 4 box
243 TGeoCombiTrans* cR16 =
244 new TGeoCombiTrans("", box4_x, 2. * DetYsize - 2 * tofYoverlap + tofYshift, tofZ_1box + tofZshift, geoRot2);
245 topTof->AddNode(vDetector, 16, cR16); // right side, x > 0
246
247 TGeoCombiTrans* cR17 = new TGeoCombiTrans("", box4_x, 1. * DetYsize - tofYoverlap + tofYshift, tofZ_1box, geoRot2);
248 topTof->AddNode(vDetector, 17, cR17);
249
250 TGeoCombiTrans* cR18 = new TGeoCombiTrans("", box4_x, 0 + tofYshift, tofZ_1box + tofZshift, geoRot2);
251 topTof->AddNode(vDetector, 18, cR18);
252
253 TGeoCombiTrans* cR19 = new TGeoCombiTrans("", box4_x, -1. * DetYsize + tofYoverlap + tofYshift, tofZ_1box, geoRot2);
254 topTof->AddNode(vDetector, 19, cR19);
255
256 TGeoCombiTrans* cR20 =
257 new TGeoCombiTrans("", box4_x, -2. * DetYsize + 2 * tofYoverlap + tofYshift, tofZ_1box + tofZshift, geoRot2);
258 topTof->AddNode(vDetector, 20, cR20);
259
260 // ------------------ Adding the TOP Volume --------------------------
261 top->AddNode(topTof, 1, new TGeoTranslation("tw", 0., 0., 0.));
262
263 // --------------- Finish --------------------------------------------
265
266 gGeoMan->CloseGeometry();
267 gGeoMan->CheckOverlaps(0.001);
268 gGeoMan->PrintOverlaps();
269 gGeoMan->Test();
270
271 TFile* geoFile = new TFile(geoFileName, "RECREATE");
272 top->Write();
273 geoFile->Close();
274
275 top->Draw("ogl");
276 gGeoMan->Browse(new TBrowser);
277}
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()
Definition json.hpp:4446