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