BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
create_rootgeom_SiBT_Run8.C
Go to the documentation of this file.
1
/*
2
* Use this macro to create the ROOT geometry of Silicon Beam Tracker (SiBT)
3
* for the RUN-8 configuration (3 stations)
4
*
5
* Author: Baranov D.
6
* Created": 14.11.2021
7
*
8
* WARNING: all units is in cm!!!
9
*
10
*/
11
12
#include "
TGeoMatrix.h
"
13
#include "
TGeoVolume.h
"
14
#include "
TString.h
"
15
16
// Set Parameters of SiBT --------------------------------------------------------
17
const
Int_t
NStations
= 3;
// stations in the detector
18
const
Int_t
NMaxModules
= 1;
// max. number of modules in a station
19
20
const
Double_t
XStationPositions
[
NStations
] = {0.115
/*0*/
, -0.295
/*1*/
, 0.177
/*2*/
};
// geometry center
21
const
Double_t
YStationPositions
[
NStations
] = {+0.089
/*0*/
, -0.046
/*1*/
, -0.012
/*2*/
};
// geometry center
22
const
Double_t
ZStationPositions
[
NStations
] = {-283.427
/*0*/
, -183.225
/*1*/
,
23
-84.378
/*2*/
};
// side which is the nearest to the beam
24
// where -283.427 = -283.097 - 0.33; -183.225 = -183.115 - 0.11; -84.378 = -84.068 - 0.31; (S.Pyaydin's scheme)
25
26
//(X-Y-Z)Shifts of modules in each station
27
const
Double_t
XModuleShifts
[
NStations
][
NMaxModules
] = {
28
{0.0},
// station 0
29
{0.0},
// station 1
30
{0.0}
// station 2
31
};
32
const
Double_t
YModuleShifts
[
NStations
][
NMaxModules
] = {
33
{0.0},
// station 0
34
{0.0},
// station 1
35
{0.0}
// station 2
36
};
37
const
Double_t
ZModuleShifts
[
NStations
][
NMaxModules
] = {
38
{0.0},
// station 0
39
{0.0},
// station 1
40
{0.0}
// station 2
41
};
42
43
// Rotations of stations around Z (deg.)
44
const
Double_t
ZStationRotations
[
NStations
][
NMaxModules
] = {
45
{-0.028},
// station 0
46
{-29.817},
// station 1
47
{-59.949}
// station 2
48
};
49
50
// Sizes of elements (cm) -------------------------------------------------------
51
52
// Sensor sizes
53
const
Double_t
XSensSize
= 6.08;
// cm
54
const
Double_t
YSensSize
= 6.08;
// cm
55
const
Double_t
ZSensSize
= 0.018;
// cm
56
//------------------------------------------------------------------------------
57
58
// GeoManager
59
TGeoManager
*
gGeoMan
= NULL;
60
61
// media
62
TGeoMedium
*
pMedAir
= 0;
63
TGeoMedium
*
pMedCarbon
= 0;
64
TGeoMedium
*
pMedFiberGlass
= 0;
65
TGeoMedium
*
pMedSilicon
= 0;
66
67
class
FairGeoMedia;
68
class
FairGeoBuilder;
69
70
TGeoVolume
*
CreateStation
(
TString
station_name);
71
TGeoVolume
*
CreateModule
(
TString
module_name);
72
73
void
DefineRequiredMedia
(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
74
{
75
76
// air medium
77
FairGeoMedium* mAir = geoMedia->getMedium(
"air"
);
78
if
(!mAir)
79
Fatal
(
"Main"
,
"FairMedium air not found"
);
80
geoBuild->createMedium(mAir);
81
pMedAir
=
gGeoManager
->GetMedium(
"air"
);
82
if
(!
pMedAir
)
83
Fatal
(
"Main"
,
"Medium air not found"
);
84
85
// carbon medium
86
FairGeoMedium* mCarbon = geoMedia->getMedium(
"carbon"
);
87
if
(!mCarbon)
88
Fatal
(
"Main"
,
"FairMedium carbon not found"
);
89
geoBuild->createMedium(mCarbon);
90
pMedCarbon
=
gGeoManager
->GetMedium(
"carbon"
);
91
if
(!
pMedCarbon
)
92
Fatal
(
"Main"
,
"Medium carbon not found"
);
93
94
// fiberglass medium
95
FairGeoMedium* mFiberGlass = geoMedia->getMedium(
"fiberglass"
);
96
if
(!mFiberGlass)
97
Fatal
(
"Main"
,
"FairMedium fiberglass not found"
);
98
geoBuild->createMedium(mFiberGlass);
99
pMedFiberGlass
=
gGeoManager
->GetMedium(
"fiberglass"
);
100
if
(!
pMedFiberGlass
)
101
Fatal
(
"Main"
,
"Medium fiberglass not found"
);
102
103
// silicon medium
104
FairGeoMedium* mSilicon = geoMedia->getMedium(
"silicon"
);
105
if
(!mSilicon)
106
Fatal
(
"Main"
,
"FairMedium silicon not found"
);
107
geoBuild->createMedium(mSilicon);
108
pMedSilicon
=
gGeoManager
->GetMedium(
"silicon"
);
109
if
(!
pMedSilicon
)
110
Fatal
(
"Main"
,
"Medium silicon not found"
);
111
}
112
113
void
create_rootgeom_SiBT_Run8
()
114
{
115
116
// ---- set working directory --------------------------------------------
117
TString
gPath =
gSystem
->Getenv(
"VMCWORKDIR"
);
118
119
// ------- Geometry file name (output) ----------------------------------
120
const
TString
geoDetectorName =
"SiBT"
;
121
const
TString
geoDetectorVersion =
"Run8"
;
122
const
TString
geoFileName = gPath +
"/geometry/"
+ geoDetectorName +
"_"
+ geoDetectorVersion +
".root"
;
123
124
// ---- global geometry parameters ---------------------------------------
125
FairGeoLoader* geoLoad =
new
FairGeoLoader(
"TGeo"
,
"FairGeoLoader"
);
126
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
127
128
// ------- Load media from media file ----------------------------------
129
TString
medFile = gPath +
"/geometry/media.geo"
;
130
geoFace->setMediaFile(medFile);
131
geoFace->readMedia();
132
FairGeoMedia* geoMedia = geoFace->getMedia();
133
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
134
135
DefineRequiredMedia
(geoMedia, geoBuild);
136
// -------------------------------------------------------------------------
137
138
// -------------- Create geometry and top volume ------------------------
139
gGeoMan
= (
TGeoManager
*)
gROOT
->FindObject(
"FAIRGeom"
);
140
gGeoMan
->SetName(geoDetectorName +
"_geom"
);
141
TGeoVolume
* top =
new
TGeoVolumeAssembly
(
"TOP"
);
142
top->
SetMedium
(
pMedAir
);
143
gGeoMan
->SetTopVolume(top);
144
// gGeoMan->SetTopVisible(1);
145
// -------------------------------------------------------------------------
146
147
// Define TOP Geometry
148
TGeoVolume
* SiBT =
new
TGeoVolumeAssembly
(geoDetectorName);
149
SiBT->
SetMedium
(
pMedAir
);
150
151
for
(
Int_t
istation = 0; istation <
NStations
; ++istation) {
152
// for(Int_t istation = 0; istation < 3; ++istation) {
153
154
Int_t
stationNum = istation;
// station number
155
156
TGeoVolume
* station =
CreateStation
(
TString
(
"station"
) +
TString::Itoa
(stationNum, 10));
157
158
TGeoVolume
* module0 =
CreateModule
(
TString
(
"module0_"
) + station->
GetName
());
159
160
TGeoCombiTrans
* module0_transform =
new
TGeoCombiTrans
();
161
module0_transform->
RotateZ
(
ZStationRotations
[stationNum][0]);
162
module0_transform->
SetTranslation
(
XModuleShifts
[stationNum][0],
YModuleShifts
[stationNum][0],
163
ZModuleShifts
[stationNum][0] + 0.5 *
ZSensSize
);
164
165
TGeoCombiTrans
* station_transform =
new
TGeoCombiTrans
();
166
station_transform->
SetTranslation
(
XStationPositions
[stationNum],
YStationPositions
[stationNum],
167
ZStationPositions
[stationNum]);
168
169
station->
AddNode
(module0, 0,
new
TGeoCombiTrans
(*module0_transform));
170
171
SiBT->
AddNode
(station, 0, station_transform);
172
}
173
174
top->
AddNode
(SiBT, 0);
175
top->
SetVisContainers
(
kTRUE
);
176
177
// --------------- Finish -----------------------------------------------
178
gGeoMan
->CloseGeometry();
179
gGeoMan
->CheckOverlaps(0.0001);
180
gGeoMan
->PrintOverlaps();
181
gGeoMan
->Test();
182
// gGeoMan->RestoreMasterVolume();
183
184
TFile
* geoFile =
new
TFile
(geoFileName,
"RECREATE"
);
185
top->
Write
();
186
geoFile->
Close
();
187
top->
Draw
(
"ogl"
);
188
}
189
190
TGeoVolume
*
CreateStation
(
TString
station_name)
191
{
192
193
TGeoVolume
* stationA =
new
TGeoVolumeAssembly
(station_name);
194
stationA->
SetMedium
(
pMedAir
);
195
196
return
stationA;
197
}
198
199
TGeoVolume
*
CreateModule
(
TString
module_name)
200
{
201
202
// shapes
203
TGeoShape
* moduleS =
new
TGeoBBox
(
TString
(
"moduleS"
) +=
TString
(
"_"
) + module_name,
XSensSize
* 0.5,
204
YSensSize
* 0.5,
ZSensSize
* 0.5);
205
206
// volumes
207
TGeoVolume
* moduleV =
new
TGeoVolume
(
TString
(
"SiBTSensor"
) +=
TString
(
"_"
) + module_name, moduleS);
208
209
// medium
210
if
(
pMedSilicon
) {
211
moduleV->
SetMedium
(
pMedSilicon
);
212
}
else
213
Fatal
(
"Main"
,
"Invalid medium for moduleV volumes!"
);
214
215
// volume visual property
216
moduleV->
SetLineColor
(
TColor::GetColor
(
"#ff47ca"
));
217
moduleV->
SetTransparency
(30);
218
219
return
moduleV;
220
}
221
//------------------------------------------------------------------------------
Int_t
int Int_t
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
Fatal
void Fatal(const char *location, const char *msgfmt,...)
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TGeoMatrix.h
TGeoVolume.h
gROOT
#define gROOT
TString.h
gSystem
R__EXTERN TSystem * gSystem
TColor::GetColor
static Int_t GetColor(const char *hexcolor)
TFile
TFile::Close
void Close(Option_t *option="") override
TGeoBBox
TGeoCombiTrans
TGeoCombiTrans::SetTranslation
void SetTranslation(const TGeoTranslation &tr)
TGeoCombiTrans::RotateZ
void RotateZ(Double_t angle) override
TGeoManager
TGeoMedium
TGeoShape
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::Draw
void Draw(Option_t *option="") override
TGeoVolume::SetTransparency
void SetTransparency(Char_t transparency=0)
TGeoVolume::SetMedium
virtual void SetMedium(TGeoMedium *medium)
TGeoVolume::SetLineColor
void SetLineColor(Color_t lcolor) override
TNamed::GetName
const char * GetName() const override
TObject::Write
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TString
TString::Itoa
static TString Itoa(Int_t value, Int_t base)
pMedAir
TGeoMedium * pMedAir
Definition
create_rootgeom_SiBT_Run8.C:62
YStationPositions
const Double_t YStationPositions[NStations]
Definition
create_rootgeom_SiBT_Run8.C:21
pMedCarbon
TGeoMedium * pMedCarbon
Definition
create_rootgeom_SiBT_Run8.C:63
gGeoMan
TGeoManager * gGeoMan
Definition
create_rootgeom_SiBT_Run8.C:59
NMaxModules
const Int_t NMaxModules
Definition
create_rootgeom_SiBT_Run8.C:18
ZStationPositions
const Double_t ZStationPositions[NStations]
Definition
create_rootgeom_SiBT_Run8.C:22
NStations
const Int_t NStations
Definition
create_rootgeom_SiBT_Run8.C:17
pMedFiberGlass
TGeoMedium * pMedFiberGlass
Definition
create_rootgeom_SiBT_Run8.C:64
XStationPositions
const Double_t XStationPositions[NStations]
Definition
create_rootgeom_SiBT_Run8.C:20
YSensSize
const Double_t YSensSize
Definition
create_rootgeom_SiBT_Run8.C:54
ZSensSize
const Double_t ZSensSize
Definition
create_rootgeom_SiBT_Run8.C:55
XSensSize
const Double_t XSensSize
Definition
create_rootgeom_SiBT_Run8.C:53
ZStationRotations
const Double_t ZStationRotations[NStations][NMaxModules]
Definition
create_rootgeom_SiBT_Run8.C:44
CreateModule
TGeoVolume * CreateModule(TString module_name)
Definition
create_rootgeom_SiBT_Run8.C:199
create_rootgeom_SiBT_Run8
void create_rootgeom_SiBT_Run8()
Definition
create_rootgeom_SiBT_Run8.C:113
pMedSilicon
TGeoMedium * pMedSilicon
Definition
create_rootgeom_SiBT_Run8.C:65
CreateStation
TGeoVolume * CreateStation(TString station_name)
Definition
create_rootgeom_SiBT_Run8.C:190
DefineRequiredMedia
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
Definition
create_rootgeom_SiBT_Run8.C:73
install
macro
geometry
create_rootgeom_SiBT_Run8.C
Generated on
for BmnRoot by
1.17.0