BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
create_rootgeom_CSC_Run8.C
Go to the documentation of this file.
1
/*
2
* Baranov D.
3
* 12.04.2021
4
* Use this macro to create ROOT geometry of CSC (Cathode
5
* Strip Chamber) detector for the RUN-8 configuration
6
*
7
* WARNING: all units is in cm!!!
8
*
9
*/
10
11
#include "
TGeoMatrix.h
"
12
#include "
TGeoVolume.h
"
13
#include "
TString.h
"
14
15
// Set Parameters of CSC --------------------------------------------------------
16
const
Int_t
NStations
= 4;
// stations in the detector
17
const
Int_t
NMaxModules
= 2;
// max. number of modules in a station
18
19
//(X-Y-Z)Positions of stations
20
const
Double_t
XStationPositions
[
NStations
] = {110.0
/*0*/
, -110.0
/*1*/
, 130.0
/*2*/
,
21
-130.0
/*3*/
};
// geometry center
22
const
Double_t
YStationPositions
[
NStations
] = {0.0
/*0*/
, 0.0
/*1*/
, 0.0
/*2*/
, 0.0
/*3*/
};
// geometry center
23
const
Double_t
ZStationPositions
[
NStations
] = {410.0
/*0*/
, 410.0
/*1*/
, 470.0
/*2*/
,
24
470.0
/*3*/
};
// outer side nearest to the target
25
26
//(X-Y-Z)Shifts of modules in each station
27
const
Double_t
XModuleShifts
[
NStations
][
NMaxModules
] = {
28
// centers of gas volume
29
{0.0, 0.0},
// station 0
30
{0.0, 0.0},
// station 1
31
{0.0, 0.0},
// station 2
32
{0.0, 0.0}
// station 3
33
};
34
const
Double_t
YModuleShifts
[
NStations
][
NMaxModules
] = {
35
// centers of gas volume
36
{27.1875, -27.1875},
// station 0
37
{27.1875, -27.1875},
// station 1
38
{27.1875, -27.1875},
// station 2
39
{27.1875, -27.1875}
// station 3
40
};
41
const
Double_t
ZModuleShifts
[
NStations
][
NMaxModules
] = {
42
// distances from st.side to mod.side
43
{1.25, 1.25},
// station 0
44
{1.25, 1.25},
// station 0
45
{1.25, 1.25},
// station 0
46
{1.25, 1.25}
// station 0
47
};
48
49
// Sizes of elements (cm) -------------------------------------------------------
50
51
// Gas volume sizes (module: half of station)
52
const
Double_t
XGasSize
= 113.0;
53
const
Double_t
YGasSize
= 54.375;
54
const
Double_t
ZGasSize
= 0.76;
55
56
// Sensitive volume sizes (module: half of station)
57
const
Double_t
XSensSize
= 112.9;
58
const
Double_t
YSensSize
= 53.25;
// 106.5*0.5
59
const
Double_t
ZSensSize
= 0.76;
60
//------------------------------------------------------------------------------
61
62
// GeoManager
63
TGeoManager
*
gGeoMan
= NULL;
64
65
// media
66
TGeoMedium
*
pMedAir
= 0;
67
TGeoMedium
*
pMedCarbon
= 0;
68
TGeoMedium
*
pMedFiberGlass
= 0;
69
TGeoMedium
*
pMedCopper
= 0;
70
TGeoMedium
*
pMedArCO27030
= 0;
71
TGeoMedium
*
pMedArgonIsobutane7525
= 0;
72
TGeoMedium
*
pMedRohacell
= 0;
73
74
class
FairGeoMedia;
75
class
FairGeoBuilder;
76
77
TGeoVolume
*
CreateStation
(
TString
station_name);
78
TGeoVolume
*
CreateModule
(
TString
module_name);
79
80
void
DefineRequiredMedia
(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
81
{
82
83
// air medium
84
FairGeoMedium* mAir = geoMedia->getMedium(
"air"
);
85
if
(!mAir)
86
Fatal
(
"Main"
,
"FairMedium air not found"
);
87
geoBuild->createMedium(mAir);
88
pMedAir
=
gGeoManager
->GetMedium(
"air"
);
89
if
(!
pMedAir
)
90
Fatal
(
"Main"
,
"Medium air not found"
);
91
92
// carbon medium
93
FairGeoMedium* mCarbon = geoMedia->getMedium(
"carbon"
);
94
if
(!mCarbon)
95
Fatal
(
"Main"
,
"FairMedium carbon not found"
);
96
geoBuild->createMedium(mCarbon);
97
pMedCarbon
=
gGeoManager
->GetMedium(
"carbon"
);
98
if
(!
pMedCarbon
)
99
Fatal
(
"Main"
,
"Medium carbon not found"
);
100
101
// fiberglass medium
102
FairGeoMedium* mFiberGlass = geoMedia->getMedium(
"fiberglass"
);
103
if
(!mFiberGlass)
104
Fatal
(
"Main"
,
"FairMedium fiberglass not found"
);
105
geoBuild->createMedium(mFiberGlass);
106
pMedFiberGlass
=
gGeoManager
->GetMedium(
"fiberglass"
);
107
if
(!
pMedFiberGlass
)
108
Fatal
(
"Main"
,
"Medium fiberglass not found"
);
109
110
// arco27020 medium
111
FairGeoMedium* mArCO27030 = geoMedia->getMedium(
"arco27030"
);
112
if
(!mArCO27030)
113
Fatal
(
"Main"
,
"FairMedium arco27030 not found"
);
114
geoBuild->createMedium(mArCO27030);
115
pMedArCO27030
=
gGeoManager
->GetMedium(
"arco27030"
);
116
if
(!
pMedArCO27030
)
117
Fatal
(
"Main"
,
"Medium arco27030 not found"
);
118
119
// ArgonIsobutane (75/25): Ar-iC4H10 medium
120
FairGeoMedium* mArgonIsobutane7525 = geoMedia->getMedium(
"ArgonIsobutane7525"
);
121
if
(!mArgonIsobutane7525)
122
Fatal
(
"Main"
,
"FairMedium ArgonIsobutane7525 not found"
);
123
geoBuild->createMedium(mArgonIsobutane7525);
124
pMedArgonIsobutane7525
=
gGeoManager
->GetMedium(
"ArgonIsobutane7525"
);
125
if
(!
pMedArgonIsobutane7525
)
126
Fatal
(
"Main"
,
"Medium ArgonIsobutane7525 not found"
);
127
128
// Rohacell medium
129
FairGeoMedium* mRohacell = geoMedia->getMedium(
"rohacellhf71"
);
130
if
(!mRohacell)
131
Fatal
(
"Main"
,
"FairMedium rohacellhf71 not found"
);
132
geoBuild->createMedium(mRohacell);
133
pMedRohacell
=
gGeoManager
->GetMedium(
"rohacellhf71"
);
134
if
(!
pMedRohacell
)
135
Fatal
(
"Main"
,
"Medium rohacellhf71 not found"
);
136
}
137
138
void
create_rootgeom_CSC_Run8
()
139
{
140
141
// ---- set working directory --------------------------------------------
142
TString
gPath =
gSystem
->Getenv(
"VMCWORKDIR"
);
143
144
// ------- Geometry file name (output) ----------------------------------
145
const
TString
geoDetectorName =
"CSC"
;
146
const
TString
geoDetectorVersion =
"Run8"
;
147
const
TString
geoFileName = gPath +
"/geometry/"
+ geoDetectorName +
"_"
+ geoDetectorVersion +
".root"
;
148
149
// ---- global geometry parameters ---------------------------------------
150
FairGeoLoader* geoLoad =
new
FairGeoLoader(
"TGeo"
,
"FairGeoLoader"
);
151
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
152
153
// ------- Load media from media file ----------------------------------
154
TString
medFile = gPath +
"/geometry/media.geo"
;
155
geoFace->setMediaFile(medFile);
156
geoFace->readMedia();
157
FairGeoMedia* geoMedia = geoFace->getMedia();
158
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
159
160
DefineRequiredMedia
(geoMedia, geoBuild);
161
// -------------------------------------------------------------------------
162
163
// -------------- Create geometry and top volume ------------------------
164
gGeoMan
= (
TGeoManager
*)
gROOT
->FindObject(
"FAIRGeom"
);
165
gGeoMan
->SetName(geoDetectorName +
"_geom"
);
166
TGeoVolume
* top =
new
TGeoVolumeAssembly
(
"TOP"
);
167
top->
SetMedium
(
pMedAir
);
168
gGeoMan
->SetTopVolume(top);
169
// gGeoMan->SetTopVisible(1);
170
// -------------------------------------------------------------------------
171
172
// Define TOP Geometry
173
TGeoVolume
* CSC =
new
TGeoVolumeAssembly
(geoDetectorName);
174
CSC->
SetMedium
(
pMedAir
);
175
176
for
(
Int_t
istation = 0; istation <
NStations
; ++istation) {
177
178
Int_t
stationNum = istation;
// station number
179
180
TGeoVolume
* station =
CreateStation
(
TString
(
"station"
) +
TString::Itoa
(stationNum, 10));
181
182
TGeoVolume
* module0 =
CreateModule
(
TString
(
"module0_"
) + station->
GetName
());
183
TGeoVolume
* module1 =
CreateModule
(
TString
(
"module1_"
) + station->
GetName
());
184
185
TGeoCombiTrans
* module0_transform =
new
TGeoCombiTrans
();
186
module0_transform->
SetTranslation
(
XModuleShifts
[stationNum][0],
YModuleShifts
[stationNum][0],
187
ZModuleShifts
[stationNum][0] + 0.5 *
ZGasSize
);
188
189
TGeoCombiTrans
* module1_transform =
new
TGeoCombiTrans
();
190
module1_transform->
RotateZ
(180);
191
module1_transform->
SetTranslation
(
XModuleShifts
[stationNum][1],
YModuleShifts
[stationNum][1],
192
ZModuleShifts
[stationNum][1] + 0.5 *
ZGasSize
);
193
194
TGeoCombiTrans
* station_transform =
new
TGeoCombiTrans
();
195
station_transform->
SetTranslation
(
XStationPositions
[stationNum],
YStationPositions
[stationNum],
196
ZStationPositions
[stationNum]);
197
198
station->
AddNode
(module0, 0,
new
TGeoCombiTrans
(*module0_transform));
199
station->
AddNode
(module1, 0,
new
TGeoCombiTrans
(*module1_transform));
200
201
CSC->
AddNode
(station, 0, station_transform);
202
}
203
204
top->
AddNode
(CSC, 0);
205
top->
SetVisContainers
(
kTRUE
);
206
207
// --------------- Finish -----------------------------------------------
208
gGeoMan
->CloseGeometry();
209
gGeoMan
->CheckOverlaps(0.0001);
210
gGeoMan
->PrintOverlaps();
211
gGeoMan
->Test();
212
// gGeoMan->RestoreMasterVolume();
213
214
TFile
* geoFile =
new
TFile
(geoFileName,
"RECREATE"
);
215
top->
Write
();
216
geoFile->
Close
();
217
top->
Draw
(
"ogl"
);
218
}
219
220
TGeoVolume
*
CreateStation
(
TString
station_name)
221
{
222
223
TGeoVolume
* stationA =
new
TGeoVolumeAssembly
(station_name);
224
stationA->
SetMedium
(
pMedAir
);
225
226
return
stationA;
227
}
228
229
TGeoVolume
*
CreateModule
(
TString
module_name)
230
{
231
232
// shapes
233
TGeoShape
* moduleS =
234
new
TGeoBBox
(
TString
(
"moduleS"
) +=
TString
(
"_"
) + module_name,
XGasSize
* 0.5,
YGasSize
* 0.5,
ZGasSize
* 0.5);
235
TGeoShape
* sensS =
236
new
TGeoBBox
(
TString
(
"sensS"
) +=
TString
(
"_"
) + module_name,
XSensSize
* 0.5,
YSensSize
* 0.5,
ZSensSize
* 0.5);
237
238
// volumes
239
TGeoVolume
* moduleV =
new
TGeoVolume
(
TString
(
"moduleV"
) +=
TString
(
"_"
) + module_name, moduleS);
240
TGeoVolume
* sensV =
new
TGeoVolume
(
TString
(
"CSCSensor"
) +=
TString
(
"_"
) + module_name, sensS);
241
242
// medium
243
if
(
pMedArgonIsobutane7525
) {
244
moduleV->
SetMedium
(
pMedArgonIsobutane7525
);
245
sensV->
SetMedium
(
pMedArgonIsobutane7525
);
246
}
else
247
Fatal
(
"Main"
,
"Invalid medium for moduleV and sensV volumes!"
);
248
249
// volume visual property (transparency)
250
moduleV->
SetLineColor
(
TColor::GetColor
(
"#47ffca"
));
251
moduleV->
SetTransparency
(30);
252
sensV->
SetLineColor
(
TColor::GetColor
(
"#ff47ca"
));
253
sensV->
SetTransparency
(30);
254
255
TGeoCombiTrans
* sensV_transf[1];
256
sensV_transf[0] =
new
TGeoCombiTrans
();
257
sensV_transf[0]->
SetDx
(0.0);
258
sensV_transf[0]->
SetDy
(-(
YGasSize
-
YSensSize
) * 0.5);
259
sensV_transf[0]->
SetDz
(0.0);
260
261
moduleV->
AddNode
(sensV, 0, sensV_transf[0]);
262
263
return
moduleV;
264
}
265
//------------------------------------------------------------------------------
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::SetDz
void SetDz(Double_t dz) override
TGeoCombiTrans::SetDy
void SetDy(Double_t dy) override
TGeoCombiTrans::SetDx
void SetDx(Double_t dx) override
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_CSC_Run8.C:66
YStationPositions
const Double_t YStationPositions[NStations]
Definition
create_rootgeom_CSC_Run8.C:22
pMedCarbon
TGeoMedium * pMedCarbon
Definition
create_rootgeom_CSC_Run8.C:67
gGeoMan
TGeoManager * gGeoMan
Definition
create_rootgeom_CSC_Run8.C:63
NMaxModules
const Int_t NMaxModules
Definition
create_rootgeom_CSC_Run8.C:17
ZStationPositions
const Double_t ZStationPositions[NStations]
Definition
create_rootgeom_CSC_Run8.C:23
pMedArCO27030
TGeoMedium * pMedArCO27030
Definition
create_rootgeom_CSC_Run8.C:70
NStations
const Int_t NStations
Definition
create_rootgeom_CSC_Run8.C:16
pMedFiberGlass
TGeoMedium * pMedFiberGlass
Definition
create_rootgeom_CSC_Run8.C:68
XStationPositions
const Double_t XStationPositions[NStations]
Definition
create_rootgeom_CSC_Run8.C:20
pMedCopper
TGeoMedium * pMedCopper
Definition
create_rootgeom_CSC_Run8.C:69
pMedRohacell
TGeoMedium * pMedRohacell
Definition
create_rootgeom_CSC_Run8.C:72
YSensSize
const Double_t YSensSize
Definition
create_rootgeom_CSC_Run8.C:58
ZSensSize
const Double_t ZSensSize
Definition
create_rootgeom_CSC_Run8.C:59
YGasSize
const Double_t YGasSize
Definition
create_rootgeom_CSC_Run8.C:53
XGasSize
const Double_t XGasSize
Definition
create_rootgeom_CSC_Run8.C:52
pMedArgonIsobutane7525
TGeoMedium * pMedArgonIsobutane7525
Definition
create_rootgeom_CSC_Run8.C:71
XSensSize
const Double_t XSensSize
Definition
create_rootgeom_CSC_Run8.C:57
ZGasSize
const Double_t ZGasSize
Definition
create_rootgeom_CSC_Run8.C:54
CreateModule
TGeoVolume * CreateModule(TString module_name)
Definition
create_rootgeom_CSC_Run8.C:229
create_rootgeom_CSC_Run8
void create_rootgeom_CSC_Run8()
Definition
create_rootgeom_CSC_Run8.C:138
CreateStation
TGeoVolume * CreateStation(TString station_name)
Definition
create_rootgeom_CSC_Run8.C:220
DefineRequiredMedia
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
Definition
create_rootgeom_CSC_Run8.C:80
macro
geometry
create_rootgeom_CSC_Run8.C
Generated on
for BmnRoot by
1.17.0