BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_TOF400_RUN6.c
Go to the documentation of this file.
1//**************************************************************************************
2
4{
5 // Load the necessary FairRoot libraries
6 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
7 bmnloadlibs(); // load libraries
8
9 // ------- Load media from media file --------------------------------
10 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
11 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
12 TString geoPath = gSystem->Getenv("VMCWORKDIR");
13 TString medFile = geoPath + "/geometry/media.geo";
14 geoFace->setMediaFile(medFile);
15 geoFace->readMedia();
16 gGeoMan = gGeoManager;
17
18 // ------- Geometry file name (output) -------------------------------
19 const TString geoDetectorName = "TOF400";
20 const TString geoDetectorVersion = "RUN6";
21 const TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
22
23 // ----------------- Get and create the required media --------------
24 FairGeoMedia* geoMedia = geoFace->getMedia();
25 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
26
27 // Air
28 FairGeoMedium* matAir = geoMedia->getMedium("air");
29 if (!matAir)
30 Fatal("Main", "FairMedium air not found");
31 geoBuild->createMedium(matAir);
32 TGeoMedium* medAir = gGeoMan->GetMedium("air");
33 if (!medAir)
34 Fatal("Main", "Medium air not found");
35
36 // Polypropylene
37 FairGeoMedium* matPprop = geoMedia->getMedium("polypropylene");
38 if (!matPprop)
39 Fatal("Main", "FairMedium polypropylene not found");
40 geoBuild->createMedium(matPprop);
41 TGeoMedium* medPprop = gGeoMan->GetMedium("polypropylene");
42 if (!medPprop)
43 Fatal("Main", "Medium polypropylene not found");
44
45 // lead
46 FairGeoMedium* matPb = geoMedia->getMedium("lead");
47 if (!matPb)
48 Fatal("Main", "FairMedium lead not found");
49 geoBuild->createMedium(matPb);
50 TGeoMedium* medPb = gGeoMan->GetMedium("lead");
51 if (!medPb)
52 Fatal("Main", "Medium lead not found");
53
54 // aluminium
55 FairGeoMedium* matAl = geoMedia->getMedium("aluminium");
56 if (!matAl)
57 Fatal("Main", "FairMedium aluminium not found");
58 geoBuild->createMedium(matAl);
59 TGeoMedium* medAl = gGeoMan->GetMedium("aluminium");
60 if (!medAl)
61 Fatal("Main", "Medium aluminium not found");
62
63 // RPCglass
64 FairGeoMedium* matGlass = geoMedia->getMedium("RPCglass");
65 if (!matGlass)
66 Fatal("Main", "FairMedium RPCglass not found");
67 geoBuild->createMedium(matGlass);
68 TGeoMedium* medGlass = gGeoMan->GetMedium("RPCglass");
69 if (!medGlass)
70 Fatal("Main", "Medium RPCglass not found");
71
72 // RPCgas
73 FairGeoMedium* matGas = geoMedia->getMedium("RPCgas");
74 if (!matGas)
75 Fatal("Main", "FairMedium RPCgas not found");
76 geoBuild->createMedium(matGas);
77 TGeoMedium* medGas = gGeoMan->GetMedium("RPCgas");
78 if (!medGas)
79 Fatal("Main", "Medium RPCgas not found");
80
81 // G10
82 FairGeoMedium* matG10 = geoMedia->getMedium("G10");
83 if (!matG10)
84 Fatal("Main", "FairMedium G10 not found");
85 geoBuild->createMedium(matG10);
86 TGeoMedium* medG10 = gGeoMan->GetMedium("G10");
87 if (!medG10)
88 Fatal("Main", "Medium G10 not found");
89
90 // ----------------------------------------- Create geometry and top volume
91 // -----------------------------------------------
92 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
93 gGeoMan->SetName(geoDetectorName + "_geom");
94 TGeoVolume* top = new TGeoVolumeAssembly("TOP"); // TOP VOLUME
95 top->SetMedium(medAir);
96 gGeoMan->SetTopVolume(top);
97 gGeoMan->SetTopVisible(1);
98 gGeoMan->SetVisLevel(7);
99
100 // --------------------------------------- Define TOP Geometry ------------------------------------
101 TGeoVolume* topTof = new TGeoVolumeAssembly(geoDetectorName);
102 topTof->SetMedium(medAir);
103
104 TGeoVolume* vDetector = new TGeoVolumeAssembly("tof1Detector");
105 vDetector->SetMedium(medAir);
106
107 const double DetXsize = 60.; // [cm]
108 const double DetYsize = 30.; // [cm]
109 const double DetZsize = 3.0; // [cm]
110 // --------------------- Create strip ------------------
111 const float stripGasX = 1., stripGasY = DetYsize, stripGasZ = 0.3; // [cm]
112 TGeoBBox* sStripGas = new TGeoBBox(stripGasX / 2., stripGasY / 2., stripGasZ / 2.);
113 sStripGas->SetName("StripGas");
114 TGeoVolume* vStripGas = new TGeoVolume("tof1StripActiveGasV", sStripGas, medGas);
115 vStripGas->SetLineColor(kRed);
116
117 // --------------------- Create Glass plates ------------------
118 const float detGlassX = DetXsize, detGlassY = DetYsize, detGlassZ = 0.618 / 2.; // [cm] 6.18 mm / 2 plate
119 TGeoBBox* sDetGlass = new TGeoBBox(detGlassX / 2., detGlassY / 2., detGlassZ / 2.);
120 sDetGlass->SetName("DetectorGlass");
121 TGeoVolume* vDetGlass = new TGeoVolume("tof1DetGlassV", sDetGlass, medGlass);
122 vDetGlass->SetLineColor(kYellow);
123
124 // --------------------- Create G10 plates ------------------
125 const float detPlateX = DetXsize, detPlateY = DetYsize, detPlateZ = 0.64 / 2.; // [cm] 6.4 mm / 2 plate
126 TGeoBBox* sDetPlate = new TGeoBBox(detPlateX / 2., detPlateY / 2., detPlateZ / 2.);
127 sDetPlate->SetName("DetectorPlate");
128 TGeoVolume* vDetPlate = new TGeoVolume("tof1DetPlateV", sDetPlate, medG10);
129 vDetPlate->SetLineColor(kBlue);
130
131 // --------------------------------------- Assemble detector
132
133 // Add strips
134 const int NStrips = 48; // 24 strips group
135 const double StripStep = 1.25; // [cm]
136 for (int i = 0; i < NStrips; i++) {
137 vDetector->AddNode(vStripGas, i + 1,
138 new TGeoTranslation("", -DetXsize / 2. + StripStep / 2. + i * StripStep, 0., 0.));
139 }
140
141 // Add Glass plates
142 vDetector->AddNode(vDetGlass, 1, new TGeoTranslation("", 0., 0., -stripGasZ / 2. - detGlassZ / 2.));
143 vDetector->AddNode(vDetGlass, 2, new TGeoTranslation("", 0., 0., +stripGasZ / 2. + detGlassZ / 2.));
144
145 // Add G10 plates
146 vDetector->AddNode(vDetPlate, 1, new TGeoTranslation("", 0., 0., -DetZsize / 2. + detPlateZ / 2.));
147 vDetector->AddNode(vDetPlate, 2, new TGeoTranslation("", 0., 0., +DetZsize / 2. - detPlateZ / 2.));
148
149 // -------------------------------------- Install Detectors
150 const double tofZgap = 0.86; // 8.6 mm between detectors
151 const double tofYoverlap = 3.0; // 30 mm detectors overlap at X direction
152
153 const double tofXgap = 0.; // [cm] RUN5, part1
154 // const double tofXgap = 2. * 24.4; // [cm] RUN5, part2
155 const double tofZ_1box = 454.8.; // [cm] :
156 const double tofZ_2box = 442.6.; // [cm] :
157
158 double tofX = tofXgap / 2. + DetXsize / 2.;
159 double tofZshift = tofZgap + DetZsize;
160
161 // first box
162 topTof->AddNode(vDetector, 1,
163 new TGeoTranslation("t1", +tofX + 55.2 + 27.17, -3.48 + 2 * DetYsize - 2 * tofYoverlap,
164 tofZ_1box + tofZshift)); // right side, x > 0
165 topTof->AddNode(vDetector, 2,
166 new TGeoTranslation("t1", +tofX + 55.2 + 27.17, -3.48 + DetYsize - tofYoverlap, tofZ_1box));
167 topTof->AddNode(vDetector, 3, new TGeoTranslation("t1", +tofX + 55.2 + 27.17, -3.48, tofZ_1box + tofZshift));
168 topTof->AddNode(vDetector, 4,
169 new TGeoTranslation("t1", +tofX + 55.2 + 27.17, -3.48 - DetYsize + tofYoverlap, tofZ_1box));
170 topTof->AddNode(
171 vDetector, 5,
172 new TGeoTranslation("t1", +tofX + 55.2 + 27.17, -3.48 - 2 * DetYsize + 2 * tofYoverlap, tofZ_1box + tofZshift));
173
174 // second box
175 topTof->AddNode(vDetector, 6,
176 new TGeoTranslation("t1", +tofX + 32.96, -3.48 + 2 * DetYsize - 2 * tofYoverlap,
177 tofZ_2box + tofZshift)); // right side, x > 0
178 topTof->AddNode(vDetector, 7, new TGeoTranslation("t1", +tofX + 32.96, -3.48 + DetYsize - tofYoverlap, tofZ_2box));
179 topTof->AddNode(vDetector, 8, new TGeoTranslation("t1", +tofX + 32.96, -3.48, tofZ_2box + tofZshift));
180 topTof->AddNode(vDetector, 9, new TGeoTranslation("t1", +tofX + 32.96, -3.48 - DetYsize + tofYoverlap, tofZ_2box));
181 topTof->AddNode(
182 vDetector, 10,
183 new TGeoTranslation("t1", +tofX + 32.96, -3.48 - 2 * DetYsize + 2 * tofYoverlap, tofZ_2box + tofZshift));
184
185 // topTof->AddNode(vDetector, 4, new TGeoTranslation("t1", -tofX, 0., tofZ + tofZshift)); // left side, x < 0
186 // topTof->AddNode(vDetector, 5, new TGeoTranslation("t1", -tofX, +DetYsize -tofYoverlap, tofZ - tofZshift));
187 // topTof->AddNode(vDetector, 6, new TGeoTranslation("t1", -tofX, -DetYsize +tofYoverlap, tofZ - tofZshift));
188
189 // ------------------ Adding the TOP Volume --------------------------
190 top->AddNode(topTof, 1, new TGeoTranslation("tw", 0., 0., 0.));
191
192 // --------------- Finish --------------------------------------------
194
195 gGeoMan->CloseGeometry();
196 gGeoMan->CheckOverlaps(0.001);
197 gGeoMan->PrintOverlaps();
198 gGeoMan->Test();
199
200 TFile* geoFile = new TFile(geoFileName, "RECREATE");
201 top->Write();
202 geoFile->Close();
203
204 top->Draw("ogl");
205 gGeoMan->Browse(new TBrowser);
206}
int i
Definition P4_F32vec4.h:22
constexpr Bool_t kTRUE
kRed
kBlue
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 void SetName(const char *name)
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
void MakeBMNROOT_TOFv3()