BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_rootgeom_MWPC_RunSRCSpring2018.C
Go to the documentation of this file.
1#include "TFile.h"
2#include "TGeoBBox.h"
3#include "TGeoManager.h"
4#include "TGeoMatrix.h"
5#include "TGeoShape.h"
6#include "TGeoVolume.h"
7#include "TMath.h"
8#include "TString.h"
9// #include "BmnMwpcGeometry.h"
10
11using namespace TMath;
12
15{
16
17 BmnMwpcGeometry* mwpcGeo = new BmnMwpcGeometry();
18
19 // Number of active planes with wires
20 const Int_t NofPlanes = mwpcGeo->GetNPlanes();
21 const Double_t Zshift = -574.144 - 71.047;
22 // Detector's position
23 const Double_t MWPC0_Xpos = -0.24;
24 const Double_t MWPC0_Ypos = -3.342;
25 const Double_t MWPC0_Zpos = -206.042 + Zshift;
26
27 const Double_t MWPC1_Xpos = -0.109;
28 const Double_t MWPC1_Ypos = -3.601;
29 const Double_t MWPC1_Zpos = -107.363 + Zshift;
30
31 const Double_t MWPC2_Xpos = 0.271;
32 const Double_t MWPC2_Ypos = 6.038;
33 const Double_t MWPC2_Zpos = 287.858 + Zshift;
34
35 const Double_t MWPC3_Xpos = 0.234;
36 const Double_t MWPC3_Ypos = 6.14;
37 const Double_t MWPC3_Zpos = 437.568 + Zshift;
38
39 // 2
40 // A______B
41 // / \ |\
42 // 3 / \ | \ 1
43 // / \ | \ */
44 // \ \ | /
45 // 4 \ \ | / 0
46 // \______\|/
47 // C
48 // 5
49
50 // X
51 // _____ <----1----> _____ <-2-> _____
52 // | | | | | | |
53 // | | | | | | |
54 // | | | | | | |
55 // | | | | | | |
56 // |_____|_____|_____|_____|_____|_____|
57 // X'
58 //
59 // 1 - GapWireOnePlane
60 // 2 - GapWireTwoPlanes
61
62 //
63 // | | | | | | | |
64 // | | | | | | | |
65 // |2.1338 |1.0015 |1.0015 |1.0015 |1.0015 |1.0015 |2.1328 |
66 //
67 //
68 // E__D__________F
69 // \ | /
70 // \| /
71 // G______H/
72 //
73 // Detector's construct parameters
74 const Double_t ABsize = mwpcGeo->GetPlaneWidth(); // cm
75 const Double_t BCsize = mwpcGeo->GetPlaneHeight(); // cm
76 const Double_t GapZsize = mwpcGeo->GetPlaneStep(); // cm
77
78 const Double_t XSizeOfActiveVolume = ABsize;
79 const Double_t YSizeOfActiveVolume = BCsize;
80 const Double_t ZSizeOfActiveVolume = GapZsize * NofPlanes; // cm
81
82 // FIXME!!! make sure! sizes of frame
83 // const Double_t ZLengthChamber = ZSizeOfActiveVolume + 1.0;
84 const Double_t ZLengthChamber = 9.2741;
85 const Double_t CopperLayer = 0.005;
86 const Double_t G10Layer = 0.15;
87
88 // shell parameters
89 const Double_t DGsize = 23;
90 const Double_t GHsize = 24.9;
91 const Double_t EFsize = 51.56;
92 const Double_t AluminiumLayer = 0.2;
93
94 // ------- Load media from media file -----------------------------------
95 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
96 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
97 TString geoPath = TString(gSystem->Getenv("VMCWORKDIR")) + "/geometry/";
98 TString medFile = geoPath + "media.geo";
99 geoFace->setMediaFile(medFile);
100 geoFace->readMedia();
102 // --------------------------------------------------------------------------
103
104 // ------- Geometry file name (output) ----------------------------------
105 const TString geoDetectorName = "MWPC";
106 const TString geoDetectorVersion = "RunSRCSpring2018";
107 TString geoFileName = geoPath + geoDetectorName + "_" + geoDetectorVersion + ".root";
108 // --------------------------------------------------------------------------
109
110 // ----------------- Get and create the required media -----------------
111 FairGeoMedia* geoMedia = geoFace->getMedia();
112 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
113
114 FairGeoMedium* mAir = geoMedia->getMedium("air");
115 if (!mAir)
116 Fatal("Main", "FairMedium air not found");
117 geoBuild->createMedium(mAir);
118 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
119 if (!pMedAir)
120 Fatal("Main", "Medium air not found");
121
122 FairGeoMedium* mArCO27030 = geoMedia->getMedium("arco27030");
123 if (!mArCO27030)
124 Fatal("Main", "FairMedium arco27030 not found");
125 geoBuild->createMedium(mArCO27030);
126 TGeoMedium* pMedArCO27030 = gGeoMan->GetMedium("arco27030");
127 if (!pMedArCO27030)
128 Fatal("Main", "Medium arco27030 not found");
129
130 FairGeoMedium* mAluminium = geoMedia->getMedium("aluminium");
131 if (!mAluminium)
132 Fatal("Main", "FairMedium aluminium not found");
133 geoBuild->createMedium(mAluminium);
134 TGeoMedium* pMedAluminium = gGeoMan->GetMedium("aluminium");
135 if (!pMedAluminium)
136 Fatal("Main", "Medium aluminium not found");
137
138 FairGeoMedium* mG10 = geoMedia->getMedium("G10");
139 if (!mG10)
140 Fatal("Main", "FairMedium G10 not found");
141 geoBuild->createMedium(mG10);
142 TGeoMedium* pMedG10 = gGeoMan->GetMedium("G10");
143 if (!pMedG10)
144 Fatal("Main", "Medium G10 not found");
145
146 FairGeoMedium* mCopper = geoMedia->getMedium("copper");
147 if (!mCopper)
148 Fatal("Main", "FairMedium copper not found");
149 geoBuild->createMedium(mCopper);
150 TGeoMedium* pMedCopper = gGeoMan->GetMedium("copper");
151 if (!pMedCopper)
152 Fatal("Main", "Medium copper not found");
153
154 // --------------------------------------------------------------------------
155
156 // -------------- Create geometry and top volume -------------------------
157 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
158 gGeoMan->SetName(geoDetectorName + "_geom");
159 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
160 top->SetMedium(pMedAir);
161 gGeoMan->SetTopVolume(top);
162 // gGeoMan->SetTopVisible(1);
163 // --------------------------------------------------------------------------
164
165 // Define TOP Geometry
166 TGeoVolume* MWPC = new TGeoVolumeAssembly(geoDetectorName);
167 MWPC->SetMedium(pMedAir);
168 MWPC->SetTransparency(50);
169
170 // Transformations (translations, rotations and scales)
171 TGeoTranslation* DetPos0_trans = new TGeoTranslation("DetPos0_trans", MWPC0_Xpos, MWPC0_Ypos, MWPC0_Zpos);
172 TGeoTranslation* DetPos1_trans = new TGeoTranslation("DetPos1_trans", MWPC1_Xpos, MWPC1_Ypos, MWPC1_Zpos);
173 TGeoTranslation* DetPos2_trans = new TGeoTranslation("DetPos2_trans", MWPC2_Xpos, MWPC2_Ypos, MWPC2_Zpos);
174 TGeoTranslation* DetPos3_trans = new TGeoTranslation("DetPos3_trans", MWPC3_Xpos, MWPC3_Ypos, MWPC3_Zpos);
175 // Solids (shapes)
176 // hexagon which contains active wire planes
177 TGeoPgon* MWPCContainerS = new TGeoPgon("MWPCContainerS", 0, 360, NofPlanes, 2);
178 MWPCContainerS->DefineSection(0, -ZLengthChamber / 2.0 - AluminiumLayer / 2. - CopperLayer - G10Layer, 0.0,
179 YSizeOfActiveVolume / 2.0 + DGsize + 0.5);
180 MWPCContainerS->DefineSection(1, ZLengthChamber / 2.0 + AluminiumLayer / 2. + CopperLayer + G10Layer, 0.0,
181 YSizeOfActiveVolume / 2.0 + DGsize + 0.5);
182
183 // active wire plane
184 TGeoBBox* MWPCActivePlaneS =
185 new TGeoBBox("MWPCActivePlaneS", XSizeOfActiveVolume / 2.0, YSizeOfActiveVolume / 2.0, 0.1);
186
187 // aluminum plates
188 TGeoTrap* MWPCAlumPlateS = new TGeoTrap("MWPCAluminiumPlateS", AluminiumLayer / 2.0, 0, 0, DGsize / 2.0,
189 GHsize / 2.0, EFsize / 2.0, 0, DGsize / 2.0, GHsize / 2.0, EFsize / 2.0, 0);
190 TGeoTrap* MWPCAlumCoverS =
191 new TGeoTrap("MWPCAluminiumCoverS", ZLengthChamber / 2.0, 0, 0, AluminiumLayer / 2.0, EFsize / 2.0,
192 EFsize / 2.0, 0, AluminiumLayer / 2.0, EFsize / 2.0, EFsize / 2.0, 0);
193
194 // G10 plates
195 TGeoPgon* MWPCG10PlateS = new TGeoPgon("MWPCG10PlateS", 0, 360, NofPlanes, 2);
196 MWPCG10PlateS->DefineSection(0, -G10Layer / 2., 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
197 MWPCG10PlateS->DefineSection(1, G10Layer / 2., 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
198
199 // copper plates
200 TGeoPgon* MWPCCopperPlateS = new TGeoPgon("MWPCCopperPlateS", 0, 360, NofPlanes, 2);
201 MWPCCopperPlateS->DefineSection(0, -CopperLayer / 2., 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
202 MWPCCopperPlateS->DefineSection(1, CopperLayer / 2., 0.0, YSizeOfActiveVolume / 2.0 + 1.0);
203
204 // Volumes
205 TGeoVolume* MWPCContainerV = new TGeoVolume("MWPCContainerV", MWPCContainerS);
206 MWPCContainerV->SetMedium(pMedAir);
207 MWPCContainerV->SetVisibility(kTRUE);
208 MWPCContainerV->SetTransparency(50);
209
210 TGeoVolume* MWPCActivePlaneV = new TGeoVolume("MWPCActivePlaneV", MWPCActivePlaneS);
211 MWPCActivePlaneV->SetMedium(pMedArCO27030);
212 MWPCActivePlaneV->SetLineColor(kBlue);
213 MWPCActivePlaneV->SetTransparency(80);
214
215 TGeoVolume* MWPCAlumPlateV = new TGeoVolume("MWPCAluminiumPlateV", MWPCAlumPlateS);
216 MWPCAlumPlateV->SetMedium(pMedAluminium);
217 MWPCAlumPlateV->SetLineColor(43);
218 MWPCAlumPlateV->SetTransparency(60);
219
220 TGeoVolume* MWPCAlumCoverV = new TGeoVolume("MWPCAluminiumCoverV", MWPCAlumCoverS);
221 MWPCAlumCoverV->SetMedium(pMedAluminium);
222 MWPCAlumCoverV->SetLineColor(43);
223 MWPCAlumCoverV->SetTransparency(60);
224
225 TGeoVolume* MWPCG10PlateV = new TGeoVolume("MWPCG10PlateV", MWPCG10PlateS);
226 MWPCG10PlateV->SetMedium(pMedG10);
227 MWPCG10PlateV->SetVisibility(kTRUE);
228 MWPCG10PlateV->SetLineColor(43);
229 MWPCG10PlateV->SetTransparency(5);
230
231 TGeoVolume* MWPCCopperPlateV = new TGeoVolume("MWPCCopperPlateV", MWPCCopperPlateS);
232 MWPCCopperPlateV->SetMedium(pMedCopper);
233 MWPCCopperPlateV->SetVisibility(kTRUE);
234 MWPCCopperPlateV->SetLineColor(43);
235 MWPCCopperPlateV->SetTransparency(20);
236
237 for (Int_t iPlane = 1; iPlane <= NofPlanes; ++iPlane) {
238 TGeoTranslation t0(0.0, 0.0, GapZsize * (iPlane - (NofPlanes + 1) / 2.0));
239 TGeoRotation r0("r0", 0.0, 0.0, (iPlane - 1) * 60.0);
240 MWPCContainerV->AddNode(MWPCActivePlaneV, iPlane - 1, new TGeoCombiTrans(t0, r0));
241 }
242
243 Double_t Y = YSizeOfActiveVolume / 2.0 + DGsize / 2.0 + 0.1;
244 Double_t Y1 = Y + AluminiumLayer / 2. + DGsize / 2. + 0.2;
245
246 for (Int_t iAlPlate = 1; iAlPlate <= 6; ++iAlPlate) {
247
248 TGeoTranslation t0(-Y * sin((iAlPlate - 1) * M_PI / 3.0), Y * cos((iAlPlate - 1) * M_PI / 3.0),
249 ZLengthChamber / 2.0);
250 TGeoRotation r0("r0", 0.0, 0.0, (iAlPlate - 1) * 60.0);
251 MWPCContainerV->AddNode(MWPCAlumPlateV, 0, new TGeoCombiTrans(t0, r0));
252
253 TGeoTranslation t1(-Y * sin((iAlPlate - 1) * M_PI / 3.0), Y * cos((iAlPlate - 1) * M_PI / 3.0),
254 -ZLengthChamber / 2.0);
255 TGeoRotation r1("r1", 0.0, 0.0, (iAlPlate - 1) * 60.0);
256 MWPCContainerV->AddNode(MWPCAlumPlateV, 0, new TGeoCombiTrans(t1, r1));
257
258 TGeoTranslation t2(-Y1 * sin((iAlPlate - 1) * M_PI / 3.0), Y1 * cos((iAlPlate - 1) * M_PI / 3.0), 0);
259 TGeoRotation r2("r2", 0.0, 0.0, (iAlPlate - 1) * 60.0);
260 MWPCContainerV->AddNode(MWPCAlumCoverV, 0, new TGeoCombiTrans(t2, r2));
261 }
262
263 for (Int_t iSide = 0; iSide <= 1; ++iSide) {
264
265 TGeoTranslation t0(0.0, 0.0, (1 - 2 * iSide) * (ZLengthChamber / 2.0 + AluminiumLayer / 2. + G10Layer / 2.));
266 TGeoRotation r0("r0", 0.0, 0.0, 0.0);
267 MWPCContainerV->AddNode(MWPCG10PlateV, 0, new TGeoCombiTrans(t0, r0));
268
270 0.0, 0.0, (1 - 2 * iSide) * (ZLengthChamber / 2.0 + AluminiumLayer / 2. + G10Layer + CopperLayer / 2.));
271 TGeoRotation r1("r1", 0.0, 0.0, 0.0);
272 MWPCContainerV->AddNode(MWPCCopperPlateV, 0, new TGeoCombiTrans(t1, r1));
273 }
274
275 MWPC->AddNode(MWPCContainerV, 0, DetPos0_trans);
276 MWPC->AddNode(MWPCContainerV, 0, DetPos1_trans);
277 MWPC->AddNode(MWPCContainerV, 0, DetPos2_trans);
278 MWPC->AddNode(MWPCContainerV, 0, DetPos3_trans);
279 // MWPC->AddNode(MWPCTextPlaneV, 0, DetPosTest_trans);
280 // Adding volumes to the TOP Volume
281 top->AddNode(MWPC, 0);
282
284
285 // --------------- Finish -----------------------------------------------
286 gGeoMan->CloseGeometry();
287 gGeoMan->CheckOverlaps(0.001);
288 gGeoMan->PrintOverlaps();
289 gGeoMan->Test();
290
291 TFile* geoFile = new TFile(geoFileName, "RECREATE");
292 top->Write();
293 geoFile->Close();
294 top->Draw("ogl");
295}
#define M_PI
int Int_t
double Double_t
constexpr Bool_t kTRUE
kBlue
void Fatal(const char *location, const char *msgfmt,...)
R__EXTERN TGeoManager * gGeoManager
#define gROOT
R__EXTERN TSystem * gSystem
Double_t GetPlaneWidth()
Double_t GetPlaneStep()
Double_t GetPlaneHeight()
void Close(Option_t *option="") override
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
void SetVisContainers(Bool_t flag=kTRUE) override
void SetVisibility(Bool_t vis=kTRUE) override
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
void Draw(Option_t *option="") override
void SetTransparency(Char_t transparency=0)
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)
RVec< PromoteType< T > > cos(const RVec< T > &v)
RVec< PromoteType< T > > sin(const RVec< T > &v)
void create_rootgeom_MWPC_RunSRCSpring2018()