BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
create_bd_root_run6.C
Go to the documentation of this file.
2#include "TGeoCone.h"
3#include "TGeoManager.h"
4#include "TGeoPara.h"
5#include "TGeoTrd2.h"
6#include "TGeoTube.h"
7
8#include <iomanip>
9#include <iostream>
10
11R__ADD_INCLUDE_PATH($VMCWORKDIR)
12#include "macro/run/bmnloadlibs.C"
13//---------------------------
14//---------------------------
15
17
20const Double_t strip_BD_Zpos = -2.5; // cm
21// const Double_t strip_BD_Zpos = -3.5; //cm
22
25const Double_t tubeFe_Zpos = -8.45; // cm
26// const Double_t tubeFe_Zpos = -9.45; //cm
27
30const Double_t tubeAl_Zpos = -14.3; // cm
31
32const Double_t roh_Xpos = 0.0;
33const Double_t roh_Ypos = 0.0;
34const Double_t roh_Zpos = -2.65; // cm
35
40
41const Double_t dphi1 = 360. / 40;
42const Double_t rr = 4.95;
43
46
49
52
54{
55
56 // ------- Load media from media file -----------------------------------
57 FairGeoLoader* geoLoad = new FairGeoLoader("TGeo", "FairGeoLoader");
58 FairGeoInterface* geoFace = geoLoad->getGeoInterface();
59 TString geoPath = gSystem->Getenv("VMCWORKDIR");
60 TString medFile = geoPath + "/geometry/media.geo";
61 geoFace->setMediaFile(medFile);
62 geoFace->readMedia();
64 // --------------------------------------------------------------------------
65
66 // ------- Geometry file name (output) ----------------------------------
67 const TString geoDetectorName = "root_geom_BD";
68 const TString geoDetectorVersion = "for_run6";
69 TString geoFileName = geoPath + "/geometry/" + geoDetectorName + "_" + geoDetectorVersion + ".root";
70 // --------------------------------------------------------------------------
71
72 // ----------------- Get and create the required media -----------------
73 FairGeoMedia* geoMedia = geoFace->getMedia();
74 FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
75
76 FairGeoMedium* mAir = geoMedia->getMedium("air");
77 if (!mAir)
78 Fatal("Main", "FairMedium air not found");
79 geoBuild->createMedium(mAir);
80 TGeoMedium* pMedAir = gGeoMan->GetMedium("air");
81 if (!pMedAir)
82 Fatal("Main", "Medium air not found");
83
84 FairGeoMedium* mBC408 = geoMedia->getMedium("BC408");
85 if (!mBC408)
86 Fatal("Main", "FairMedium BC408 not found");
87 geoBuild->createMedium(mBC408);
88 TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
89 if (!pMedBC408)
90 Fatal("Main", "Medium BC408 not found");
91
92 FairGeoMedium* miron = geoMedia->getMedium("iron");
93 if (!miron)
94 Fatal("Main", "FairMedium iron not found");
95 geoBuild->createMedium(miron);
96 TGeoMedium* pMediron = gGeoMan->GetMedium("iron");
97 if (!pMediron)
98 Fatal("Main", "Medium iron not found");
99
100 FairGeoMedium* maluminium = geoMedia->getMedium("aluminium");
101 if (!maluminium)
102 Fatal("Main", "FairMedium aluminium not found");
103 geoBuild->createMedium(maluminium);
104 TGeoMedium* pMedaluminium = gGeoMan->GetMedium("aluminium");
105 if (!pMedaluminium)
106 Fatal("Main", "Medium aluminium not found");
107
108 FairGeoMedium* mpolypropylene = geoMedia->getMedium("polypropylene");
109 if (!mpolypropylene)
110 Fatal("Main", "FairMedium polypropylene not found");
111 geoBuild->createMedium(mpolypropylene);
112 TGeoMedium* pMedpolypropylene = gGeoMan->GetMedium("polypropylene");
113 if (!pMedpolypropylene)
114 Fatal("Main", "Medium polypropylene not found");
115
116 // --------------------------------------------------------------------------
117
118 // -------------- Create geometry and top volume -------------------------
119 gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
120 gGeoMan->SetName(geoDetectorName + "_geom");
121 TGeoVolume* top = new TGeoVolumeAssembly("TOP");
122 top->SetMedium(pMedAir);
123 gGeoMan->SetTopVolume(top);
124
125 // --------------------------------------------------------------------------
126
127 TGeoTranslation* BD_Position = new TGeoTranslation("BD_Position", 0, 0, 2.5);
128
129 // Define TOP Geometry
130 TGeoVolume* BD = new TGeoVolumeAssembly("BD");
131 BD->SetMedium(pMedAir);
132
133 TGeoTranslation* strips_BD1Pos_trans =
134 new TGeoTranslation("strips_BD1Pos_trans", strip_BD_Xpos, strip_BD_Ypos, strip_BD_Zpos);
135 TGeoTranslation* tubefePos_trans = new TGeoTranslation("tubefePos_trans", tubeFe_Xpos, tubeFe_Ypos, tubeFe_Zpos);
136 TGeoTranslation* tubealPos_trans = new TGeoTranslation("tubefePos_trans", tubeAl_Xpos, tubeAl_Ypos, tubeAl_Zpos);
137 TGeoTranslation* tuberohPos_trans = new TGeoTranslation("tuberohPos_trans", roh_Xpos, roh_Ypos, roh_Zpos);
138
139 TGeoBBox* strip = new TGeoBBox("srtip", 0.7 / 2., 0.7 / 2., 15. / 2.);
140 TGeoTube* tubefeContainerS = new TGeoTube("tubefeContainerS", MinRadiusFe / 2, MaxRadiusFe / 2, ZLength_tubeFe / 2);
141 TGeoTube* tubealContainerS = new TGeoTube("tubealContainerS", MinRadiusAl / 2, MaxRadiusAl / 2, ZLength_tubeAl / 2);
142 TGeoTube* tuberohContainerS =
143 new TGeoTube("tuberohContainerS", MinRadiusRohacel / 2, MaxRadiusRohacel / 2, ZLength_roh / 2);
144
145 Double_t phi = 90 * TMath::DegToRad(), delta_phi = 360. / 40., dphi = delta_phi * TMath::DegToRad();
146
147 TGeoCombiTrans* combi[41];
148
149 for (Int_t i = 1; i < 41; i++) {
150 combi[i] = new TGeoCombiTrans(rr * TMath::Cos(dphi * (i + 0.5)), rr * TMath::Sin(dphi * (i + 0.5)),
151 strip_BD_Zpos, new TGeoRotation("rot", dphi1 * (i + 0.5), 0., 0.));
152 }
153
154 TGeoVolume* BD1ActiveVolumeV1 = new TGeoVolume("BD1ActiveVolumeV1", strip);
155 BD1ActiveVolumeV1->SetMedium(pMedBC408);
156 BD1ActiveVolumeV1->SetLineColor(kYellow - 10);
157
158 TGeoVolume* tubefeMat = new TGeoVolume("tubefeMat", tubefeContainerS);
159 tubefeMat->SetMedium(pMediron);
160 tubefeMat->SetLineColor(kOrange - 1);
161
162 TGeoVolume* tubealMat = new TGeoVolume("tubealMat", tubealContainerS);
163 tubealMat->SetMedium(pMedaluminium);
164 tubealMat->SetLineColor(kCyan - 10);
165
166 TGeoVolume* tuberohMat = new TGeoVolume("tuberohMat", tuberohContainerS);
167 tuberohMat->SetMedium(pMedpolypropylene);
168 tuberohMat->SetLineColor(kGray);
169
170 // container1->AddNode(BD1Top, 1);
171
172 // BD1Top->AddNode(BD1ActiveVolumeV1, 1, new TGeoCombiTrans(t1, r1));
173
174 for (Int_t i = 1; i < 41; i++) {
175 BD->AddNode(BD1ActiveVolumeV1, i, combi[i]);
176 }
177
178 BD->AddNode(tubefeMat, 41, tubefePos_trans);
179 BD->AddNode(tubealMat, 42, tubealPos_trans);
180 BD->AddNode(tuberohMat, 43, tuberohPos_trans);
181
182 // Adding volumes to the TOP Volume
183 top->AddNode(BD, 1, BD_Position);
184
186
187 // --------------- Finish -----------------------------------------------
188 gGeoMan->CloseGeometry();
189 gGeoMan->CheckOverlaps(0.001);
190 gGeoMan->PrintOverlaps();
191 gGeoMan->Test();
192
193 TFile* geoFile = new TFile(geoFileName, "RECREATE");
194 top->Write();
195 geoFile->Close();
196 top->Draw("ogl");
197 // top->Draw("");
198}
int i
Definition P4_F32vec4.h:22
int Int_t
double Double_t
constexpr Bool_t kTRUE
#define R__ADD_INCLUDE_PATH(PATH)
kGray
kOrange
kCyan
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 Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TGeoManager * gGeoMan
const Double_t strip_BD_Xpos
const Double_t strip_BD_Ypos
const Double_t strip_BD_Zpos
const Double_t rr
const Double_t MaxRadiusFe
const Double_t MinRadiusAl
const Double_t ZLength_tubeFe
const Double_t MaxRadiusRohacel
const Double_t ZLength_tubeAl
const Double_t tubeAl_Zpos
const Double_t roh_Zpos
const Double_t MinRadiusFe
const Double_t ZLength_BDActiveVolume
const Double_t MaxRadiusAl
const Double_t roh_Ypos
void create_bd_root_run6()
const Double_t tubeFe_Ypos
const Double_t tubeAl_Ypos
const Double_t tubeFe_Xpos
const Double_t tubeAl_Xpos
const Double_t MinRadiusRohacel
const Double_t roh_Xpos
const Double_t tubeFe_Zpos
const Double_t ZLength_roh
const Double_t dphi1
constexpr Double_t DegToRad()
Double_t Cos(Double_t)
Double_t Sin(Double_t)