BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C
Go to the documentation of this file.
1
//---------------------------
2
// M.Golubeva (INR RAS), May 2016
3
//---------------------------
4
5
#include "
../profiling/bmnloadlibs.C
"
6
#include "
TFile.h
"
7
#include "
TGeoManager.h
"
8
#include "
TGeoMedium.h
"
9
#include "
TGeoVolume.h
"
10
11
// Detector's position
12
// const Double_t WALL_Xpos = 0.0;
13
// const Double_t WALL_Ypos = 0.0;
14
// const Double_t WALL_Zpos = 950.;//cm to WALL surface
15
// const Double_t WALL_center_Zpos = 950.5;//9.505 m (950+0.5);//cm
16
// const Double_t WALL_Zpos = 900.;//cm to WALL surface
17
// const Double_t WALL_center_Zpos = 900.01;//9.001 m (900+0.01);//cm
18
// const Double_t WALL_Zpos = 878.1;//cm to WALL surface
19
// const Double_t WALL_center_Zpos = 878.11;//8.7811 m (878.1+0.01);//cm//vac
20
// const Double_t WALL_center_Zpos = 878.3;//8.783 m (878.1+0.2);//cm//sc
21
22
// Detector's construct parameters ===================
23
24
// Global dimensions for WALL in cm
25
Double_t
Wall_X_size
= 77.5;
// 155/2
26
Double_t
Wall_Y_size
= 52.5;
// 105/2
27
// Double_t Wall_Z_size = 0.01; //0.02/2.//vac
28
Double_t
Wall_Z_size
= 0.00001;
// 0.02/2.//vac
29
30
// media ============================================
31
TGeoMedium
*
pMedVacuum
= 0;
32
TGeoMedium
*
pMedAir
= 0;
33
TGeoMedium
*
pMedScint
= 0;
34
35
class
FairGeoMedia;
36
class
FairGeoBuilder;
37
38
void
DefineRequiredMedia
(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
39
{
40
// vacuum medium
41
FairGeoMedium* mVacuum = geoMedia->getMedium(
"vacuum"
);
42
if
(!mVacuum)
43
Fatal
(
"Main"
,
"FairMedium vacuum not found"
);
44
geoBuild->createMedium(mVacuum);
45
pMedVacuum
=
gGeoManager
->GetMedium(
"vacuum"
);
46
if
(!
pMedVacuum
)
47
Fatal
(
"Main"
,
"Medium vacuum not found"
);
48
49
// air medium
50
FairGeoMedium* mAir = geoMedia->getMedium(
"air"
);
51
if
(!mAir)
52
Fatal
(
"Main"
,
"FairMedium air not found"
);
53
geoBuild->createMedium(mAir);
54
pMedAir
=
gGeoManager
->GetMedium(
"air"
);
55
if
(!
pMedAir
)
56
Fatal
(
"Main"
,
"Medium air not found"
);
57
58
// medium polystyrene (Scint.)
59
FairGeoMedium* mPolystyrene = geoMedia->getMedium(
"polystyrene"
);
60
if
(!mPolystyrene)
61
Fatal
(
"Main"
,
"FairMedium polystyrene not found"
);
62
geoBuild->createMedium(mPolystyrene);
63
pMedScint
=
gGeoManager
->GetMedium(
"polystyrene"
);
64
if
(!
pMedScint
)
65
Fatal
(
"Main"
,
"Medium polystyrene not found"
);
66
/*
67
// medium FscScint (Scint.)
68
FairGeoMedium* mPolystyrene = geoMedia->getMedium("FscScint");
69
if ( ! mPolystyrene ) Fatal("Main", "FairMedium FscScint not found");
70
geoBuild->createMedium(mPolystyrene);
71
pMedScint = gGeoManager->GetMedium("FscScint");
72
if ( ! pMedScint ) Fatal("Main", "Medium FscScint not found");
73
*/
74
}
// DefineRequiredMedia
75
76
void
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm
(
Double_t
WALL_Xpos = 0,
77
Double_t
WALL_Ypos = 0,
78
Double_t
WALL_Zpos = 900,
79
Double_t
rotY = 0)
80
{
81
82
// Load necessary libraries
83
// gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
84
bmnloadlibs
();
// load libraries
85
86
// ---- set working directory --------------------------------------------
87
TString
gPath =
gSystem
->Getenv(
"VMCWORKDIR"
);
88
89
// ------- Geometry file name (output) ---------------------------------
90
const
TString
geoDetectorName =
"wall_vacuum_zdc_155x105cm"
;
91
const
TString
geoDetectorVersion =
"v1"
;
92
// TString geoFileName = gPath + "/geometry/" + geoDetectorName + geoDetectorVersion + ".root";
93
// Double_t WALL_center_Zpos = WALL_Zpos + Wall_Z_size;;//8.7811 m (878.1+0.01);//cm//vac
94
Double_t
WALL_center_Zpos = WALL_Zpos;
// cm//vac
95
/*
96
TString sXshift = "";
97
TString sYshift = "";
98
TString sZshift = "";
99
Int_t Xshift = Int_t(WALL_Xpos*10.); //mm
100
Int_t Yshift = Int_t(WALL_Ypos*10.); //mm
101
Int_t Zshift = Int_t(WALL_Zpos*10.); //mm
102
sXshift += Xshift;
103
sYshift += Yshift;
104
sZshift += Zshift;
105
*/
106
107
TString
sXshift_1 =
""
;
108
TString
sXshift_2 =
""
;
109
TString
sXshift_3 =
""
;
110
111
TString
sYshift_0 =
"-"
;
112
TString
sYshift_1 =
""
;
113
TString
sYshift_2 =
""
;
114
// TString sYshift_3 = "";
115
116
TString
sZshift_1 =
""
;
117
TString
sZshift_2 =
""
;
118
119
TString
sRotY_1 =
""
;
120
TString
sRotY_2 =
""
;
121
122
Int_t
Xshift_1 =
Int_t
(WALL_Xpos);
// cm
123
// Int_t Xshift_2 = Int_t(0.1+10*(WALL_Xpos-Int_t(WALL_Xpos))); //cm
124
// Int_t Xshift_2 = Int_t(0.5+100*(WALL_Xpos-Int_t(WALL_Xpos))); //cm
125
// Int_t Xshift_2 = Int_t(0.5+100*(TMath::Abs(WALL_Xpos)-Int_t(TMath::Abs(WALL_Xpos)))); //cm
126
// Int_t Xshift_2 = Int_t(100*(WALL_Xpos-Int_t(WALL_Xpos))); //cm
127
// Int_t Xshift_2 = 0; //cm
128
Int_t
Xshift_2 =
Int_t
(100 * (WALL_Xpos -
Int_t
(WALL_Xpos))) + 1;
// cm
129
// Int_t Xshift_3 = Int_t(100*(WALL_Xpos-Int_t(WALL_Xpos)))+1; //cm
130
sXshift_1 += Xshift_1;
131
sXshift_2 += Xshift_2;
132
// sXshift_3 += Xshift_3;
133
134
Int_t
Yshift_1 =
Int_t
(WALL_Ypos);
// cm
135
// Int_t Yshift_2 = Int_t(100*(WALL_Ypos-Int_t(WALL_Ypos)))+1; //cm
136
// Int_t Yshift_2 = Int_t(100*(WALL_Ypos-Int_t(WALL_Ypos))); //cm
137
Int_t
Yshift_2 =
TMath::Abs
(
Int_t
(10 * (WALL_Ypos)));
// cm
138
// Int_t Yshift_2 = Int_t(0.5+100*(TMath::Abs(ZDC_Ypos)-Int_t(TMath::Abs(ZDC_Ypos)))); //cm
139
sYshift_1 += Yshift_1;
140
sYshift_2 += Yshift_2;
141
142
Int_t
Zshift_1 =
Int_t
(WALL_Zpos);
// cm
143
// Int_t Zshift_2 = Int_t(100*(WALL_Zpos-Int_t(WALL_Zpos))); //cm
144
// Int_t Zshift_2 = Int_t(100*(WALL_Zpos-Int_t(WALL_Zpos)))+1; //cm
145
// Int_t Zshift_2 = Int_t(10*(WALL_Zpos-Int_t(WALL_Zpos)))+1; //cm
146
Int_t
Zshift_2 =
Int_t
(10 * (WALL_Zpos -
Int_t
(WALL_Zpos)));
// cm
147
// Int_t Zshift_2 = Int_t(10*(WALL_Zpos-Int_t(WALL_Zpos)))+1; //cm
148
sZshift_1 += Zshift_1;
149
sZshift_2 += Zshift_2;
150
cout <<
"Zshift_1,Zshift_2 "
<< Zshift_1 <<
" "
<< 10 * (WALL_Zpos -
Int_t
(WALL_Zpos)) <<
" "
<< Zshift_2 << endl;
151
152
Int_t
rotY_1 =
Int_t
(rotY);
// 2 from 2.9
153
Int_t
rotY_2 =
Int_t
(100 * (rotY -
Int_t
(rotY)));
// 9 from 2.9
154
// Int_t rotY_2 = Int_t(100*(rotY-Int_t(rotY)))+1;//9 from 2.9
155
sRotY_1 += rotY_1;
156
sRotY_2 += rotY_2;
157
158
// TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + "Zpos_" + sZshift + "mm" + "_" + "Xshift_" +
159
// sXshift + "mm" + "_" + "Yshift_" + sYshift + "mm" + "_" + geoDetectorVersion + ".root"; TString geoFileName =
160
// gPath + "/geometry/" + geoDetectorName + "_" + "Zpos_" + sZshift_1 + "." + sZshift_2 + "cm" + "_" + "Xshift_" +
161
// sXshift_1 + "." + sXshift_2 + "cm" + "_" + "Yshift_" + sYshift_1 + "." + sYshift_2 + "cm" + "_" + "rotationY_" +
162
// sRotY_1 + "." + sRotY_2 + "deg_" + geoDetectorVersion + ".root";
163
TString
geoFileName = gPath +
"/geometry/"
+ geoDetectorName +
"_"
+
"Zpos_"
+ sZshift_1 +
"."
+ sZshift_2 +
"cm"
164
+
"_"
+
"Xshift_"
+ sXshift_1 +
"."
+ sXshift_2 +
"cm"
+
"_"
+
"Yshift_"
+ sYshift_0
165
+ sYshift_1 +
"."
+ sYshift_2 +
"cm"
+
"_"
+
"rotationY_"
+ sRotY_1 +
"."
+ sRotY_2 +
"deg_"
166
+ geoDetectorVersion +
".root"
;
167
// TString geoFileName = gPath + "/geometry/" + geoDetectorName + "_" + "Zpos_" + sZshift_1 + "." + sZshift_2 + "cm"
168
// + "_" + "Xshift_" + sXshift_1 + "." + sXshift_2 + sXshift_3 + "cm" + "_" + "Yshift_" + sYshift_1 + "." +
169
// sYshift_2 + "cm" + "_" + "rotationY_" + sRotY_1 + "." + sRotY_2 + "deg_" + geoDetectorVersion + ".root";
170
// -------------------------------------------------------------------------
171
172
// ---- global geometry parameters ---------------------------------------
173
FairGeoLoader* geoLoad =
new
FairGeoLoader(
"TGeo"
,
"FairGeoLoader"
);
174
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
175
176
// ------- Load media from media file ----------------------------------
177
TString
medFile = gPath +
"/geometry/media.geo"
;
178
geoFace->setMediaFile(medFile);
179
geoFace->readMedia();
180
FairGeoMedia* geoMedia = geoFace->getMedia();
181
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
182
// geoMedia->list();
183
// geoMedia->print();
184
DefineRequiredMedia
(geoMedia, geoBuild);
185
// -------------------------------------------------------------------------
186
187
// -------------- Create geometry and global top volume ------------------------
188
gGeoManager
= (
TGeoManager
*)
gROOT
->FindObject(
"FAIRGeom"
);
189
gGeoManager
->SetName(geoDetectorName +
"_geom"
);
190
TGeoVolume
* top =
new
TGeoVolumeAssembly
(
"TOP"
);
191
top->
SetMedium
(
pMedAir
);
192
// top->SetMedium(pMedVacuum);
193
gGeoManager
->SetTopVolume(top);
194
// gGeoMan->SetTopVisible(1);
195
// --------------------------------------------------------------------------
196
197
// Define WALL Geometry
198
// TString wall_common_name = "WALL_common";
199
TString
wall_common_name =
"ZDC_common"
;
200
TGeoVolume
* ZDC_common =
new
TGeoVolumeAssembly
(wall_common_name);
201
ZDC_common->
SetMedium
(
pMedAir
);
202
// ZDC_common->SetMedium(pMedVacuum);
203
204
TString
wall_name =
"zdc01"
;
205
// TGeoTube *WALLS = new TGeoTube(wall_name, Wall_inner_radius, Wall_outer_radius, Wall_Z_size);
206
TGeoBBox
* WALLS =
new
TGeoBBox
(wall_name,
Wall_X_size
,
Wall_Y_size
,
Wall_Z_size
);
207
TGeoVolume
* WALLV =
new
TGeoVolume
(wall_name, WALLS);
208
// WALLV->SetMedium(pMedAir);
209
WALLV->
SetMedium
(
pMedVacuum
);
210
// WALLV->SetMedium(pMedScint);
211
212
TString
wallSensitive_name =
"zdc01s"
;
213
// TGeoTube *wallSensitiveVolumeS = new TGeoTube(wallSensitive_name, Wall_inner_radius, Wall_outer_radius,
214
// Wall_Z_size);
215
TGeoBBox
* wallSensitiveVolumeS =
new
TGeoBBox
(wallSensitive_name,
Wall_X_size
,
Wall_Y_size
,
Wall_Z_size
);
216
TGeoVolume
* wallSensitiveVolumeV =
new
TGeoVolume
(wallSensitive_name, wallSensitiveVolumeS);
217
// wallSensitiveVolumeV->SetMedium(pMedScint);
218
wallSensitiveVolumeV->
SetMedium
(
pMedVacuum
);
219
220
// insert wallSensitiveVolumeV into WALLV
221
TGeoTranslation
* wall_position =
new
TGeoTranslation
(0., 0., 0.);
222
WALLV->
AddNode
(wallSensitiveVolumeV, 1, wall_position);
223
224
// Adding the wall mother volume to the global TOP Volume
225
// TGeoTranslation *wallWALL = new TGeoTranslation("wallWALL",WALL_Xpos, WALL_Ypos, WALL_center_Zpos);
226
227
TGeoRotation
* rot =
new
TGeoRotation
(
"rot"
);
228
rot->
RotateY
(rotY);
229
TGeoCombiTrans
* wallWALL =
new
TGeoCombiTrans
(
"wallWALL"
, WALL_Xpos, WALL_Ypos, WALL_center_Zpos, rot);
230
ZDC_common->
AddNode
(WALLV, 1, wallWALL);
// WALL right
231
232
/*
233
TGeoRotation *rotWALL = new TGeoRotation();
234
rotWALL->RotateY(30.);
235
TGeoCombiTrans *wallWALL2 = new TGeoCombiTrans(WALL_Xpos, WALL_Ypos, -WALL_center_Zpos, rotWALL);
236
WALL_common->AddNode(WALLV, 2, wallWALL2);//WALL left
237
*/
238
239
// top->AddNode(WALL_common, 0);
240
top->
AddNode
(ZDC_common, 0);
241
242
top->
SetVisContainers
(
kTRUE
);
243
244
// --------------- Finish ----------------------------------------------
245
gGeoManager
->CloseGeometry();
246
gGeoManager
->CheckOverlaps(0.001);
247
gGeoManager
->PrintOverlaps();
248
249
gGeoManager
->Test();
250
251
TFile
* geoFile =
new
TFile
(geoFileName,
"RECREATE"
);
252
top->
Write
();
253
geoFile->
Close
();
254
255
// TString gdmlname = gPath + "/geometry/tpc_v7.gdml";
256
// gGeoManager->Export(gdmlname);
257
258
// top->Draw("ogl");
259
// TGLViewer *v = (TGLViewer*)gPad->GetViewer3D();
260
// v->SetStyle(TGLRnrCtx::kOutline);
261
// top->Draw("");
262
263
}
// create_rootgeom_zdc_v1
Int_t
int Int_t
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TFile.h
TGeoManager.h
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TGeoMedium.h
TGeoVolume.h
gROOT
#define gROOT
gSystem
R__EXTERN TSystem * gSystem
TFile
TFile::Close
void Close(Option_t *option="") override
TGeoBBox
TGeoCombiTrans
TGeoManager
TGeoMedium
TGeoRotation
TGeoRotation::RotateY
void RotateY(Double_t angle) override
TGeoTranslation
TGeoVolumeAssembly
TGeoVolume
TGeoVolume::SetVisContainers
void SetVisContainers(Bool_t flag=kTRUE) override
TGeoVolume::AddNode
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
TGeoVolume::SetMedium
virtual void SetMedium(TGeoMedium *medium)
TObject::Write
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TString
pMedAir
TGeoMedium * pMedAir
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:32
pMedScint
TGeoMedium * pMedScint
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:33
pMedVacuum
TGeoMedium * pMedVacuum
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:31
Wall_Z_size
Double_t Wall_Z_size
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:28
Wall_Y_size
Double_t Wall_Y_size
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:26
Wall_X_size
Double_t Wall_X_size
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:25
bmnloadlibs
void bmnloadlibs()
Definition
bmnloadlibs.C:4
DefineRequiredMedia
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:38
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm
void create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm(Double_t WALL_Xpos=0, Double_t WALL_Ypos=0, Double_t WALL_Zpos=900, Double_t rotY=0)
Definition
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C:76
bmnloadlibs.C
TMath::Abs
Double_t Abs(Double_t d)
macro
geometry
create_rootgeom_wall_oldnames_vacuum_zdc_155x105cm.C
Generated on
for BmnRoot by
1.17.0