BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
create_rootgeom_ECAL_v2.C
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* File: create_rootgeom_ECAL_v2.C
4
* Last modified: 09-08-2019 by Petr Alekseev <pnaleks@gmail.com>
5
*
6
* Example of use:
7
* root -l '$VMCWORKDIR/macro/geometry/create_rootgeom_ECAL_v2.C(7,4)'
8
* This will generate root geometry file
9
* $VMCWORKDIR/geometry/ECAL_v2_run7_pos4.root
10
******************************************************************************/
11
12
#include "../run/bmnloadlibs.C"
13
#include "
TFile.h
"
14
#include "
TGeoManager.h
"
15
#include "
TGeoMedium.h
"
16
#include "
TGeoVolume.h
"
17
18
//________________________________________________________________________________
19
// ECAL = 8x7x9x215
20
// ECAL = 8 SuperModules
21
// SuperModule = 7 Modules
22
// Module = 9 ADCmodules
23
// ADCmodule = X:4cm x Y:4cm x Z:215 layers * (0.045 Pb + 0.15 Sci)
24
// front steel cover ---PIPEC FIXME
25
// ADCmodules == modules in the code
26
27
//________________________________________________________________________________
28
// ECAL Position and rotation in BM@N
29
Double_t
ecalX
= -175;
//-175; //-55 //ecalX = -167.18
30
Double_t
ecalY
= 12.4;
// 12.4; //12.4 //ecalY = 13.155;
31
Double_t
ecalZ
= 283.1;
// 283.1; //283.1 //ecalZ = 263.437;
32
Double_t
rotationAngle
= -20;
//-20; //10; //rotationAngle = -15.;
33
34
void
SetEcalPosition
(
Int_t
run,
Int_t
pos)
35
{
36
if
(run == 7) {
37
switch
(pos) {
38
case
1:
39
ecalX
= -44;
40
ecalY
= 12.4;
41
ecalZ
= 843.1;
42
rotationAngle
= 0;
43
return
;
44
case
2:
45
ecalX
= -175;
46
ecalY
= 12.4;
47
ecalZ
= 883.1;
48
rotationAngle
= -10;
49
return
;
50
case
3:
51
ecalX
= -175;
52
ecalY
= 12.4;
53
ecalZ
= 283.1;
54
rotationAngle
= -10;
55
return
;
56
case
4:
57
ecalX
= -55;
58
ecalY
= 12.4;
59
ecalZ
= 283.1;
60
rotationAngle
= -10;
61
return
;
62
case
5:
63
ecalX
= -175;
64
ecalY
= 12.4;
65
ecalZ
= 283.1;
66
rotationAngle
= -20;
67
return
;
68
}
69
}
70
Fatal
(
"Main"
,
"ECAL run %d position %d is not defined in "
__FILE__, run, pos);
71
}
72
73
//________________________________________________________________________________
74
// ECAL Parameters
75
int
Xmodules
= 24;
// X modules = ADCmodules
76
int
Ymodules
= 21;
77
int
Zlayers
= 215;
78
Double_t
thickPb
= 0.030;
// lead
79
Double_t
thickSci
= 0.15;
// scintilator
80
Double_t
thickSteel
= 0.2;
// front cover FIXME
81
Double_t
thickPaint
= 0.0075;
// paint
82
Double_t
thickPbSciPaint
=
thickPaint
+
thickPb
+
thickPaint
+
thickSci
;
83
Double_t
modwidth
= 4;
84
Double_t
modheight
= 4;
85
Double_t
modlength
=
thickSteel
+
thickPbSciPaint
*
Zlayers
;
86
87
// media ============================================
88
struct
89
{
90
TGeoMedium
*
vacuum
= 0;
91
TGeoMedium
*
air
= 0;
92
TGeoMedium
*
iron
= 0;
93
TGeoMedium
*
lead
= 0;
94
TGeoMedium
*
scint
= 0;
95
TGeoMedium
*
steel
= 0;
96
TGeoMedium
*
tyvec
= 0;
97
TGeoMedium
*
slot
= 0;
98
TGeoMedium
*
TiO2
= 0;
99
}
mMed
;
100
101
TGeoMedium
*
DefineMedia
(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild,
const
char
* name)
102
{
103
FairGeoMedium* pFairGeoMedium = geoMedia->getMedium(name);
104
if
(!pFairGeoMedium)
105
Fatal
(
"Main"
,
"FairMedium %s not found"
, name);
106
geoBuild->createMedium(pFairGeoMedium);
107
TGeoMedium
* pTGeoMedium =
gGeoManager
->GetMedium(name);
108
if
(!pTGeoMedium)
109
Fatal
(
"Main"
,
"Medium %s not found"
, name);
110
return
pTGeoMedium;
111
}
112
113
void
DefineRequiredMedia
(FairGeoMedia* geoMedia, FairGeoBuilder* geoBuild)
114
{
115
116
mMed
.vacuum =
DefineMedia
(geoMedia, geoBuild,
"vacuum"
);
117
// mMed.air = DefineMedia(geoMedia, geoBuild, "air");
118
// mMed.iron = DefineMedia(geoMedia, geoBuild, "iron");
119
// mMed.tyvec = DefineMedia(geoMedia, geoBuild, "tyvec_ZDC");
120
mMed
.lead =
DefineMedia
(geoMedia, geoBuild,
"lead"
);
121
// mMed.scint = DefineMedia(geoMedia, geoBuild, "polystyrene"); // medium polystyrene (Scint.)
122
mMed
.scint =
DefineMedia
(geoMedia, geoBuild,
"FscScint"
);
// medium FscScint (Scint.)
123
// mMed.slot = DefineMedia(geoMedia, geoBuild, "plasticWLS_ZDC"); // medium plastic (slot)
124
// mMed.steel = DefineMedia(geoMedia, geoBuild, "steel");
125
mMed
.steel =
DefineMedia
(geoMedia, geoBuild,
"steel"
);
126
mMed
.TiO2 =
DefineMedia
(geoMedia, geoBuild,
"TiO2"
);
127
128
}
// DefineRequiredMedia
129
130
///
131
/// \param[in] run BMN run number (only run 7 is currently supported)
132
/// \param[in] pos ECAL position in the run (five positions for run 7 are defined)
133
///
134
void
create_rootgeom_ECAL_v2
(
Int_t
run,
Int_t
pos)
135
{
136
137
bmnloadlibs();
// load libraries
138
139
// ---- set working directory --------------------------------------------
140
TString
gPath =
gSystem
->Getenv(
"VMCWORKDIR"
);
141
142
// ---- Geometry file name (output) ----------------------------------------
143
const
TString
geoDetectorName =
"ECAL"
;
144
const
TString
geoDetectorVersion =
"v2"
;
145
TString
geoFileName;
146
geoFileName.
Form
(
"%s/geometry/%s_%s_run%d_pos%d.root"
, gPath.
Data
(), geoDetectorName.
Data
(),
147
geoDetectorVersion.
Data
(), run, pos);
148
cout << geoFileName << endl;
149
150
SetEcalPosition
(run, pos);
151
// TGeoRotation *rot = new TGeoRotation("rot1", rotationAngle, 0., 0.);
152
// TGeoRotation *rot = new TGeoRotation("rot1", 0., rotationAngle, 0.);
153
// TGeoRotation *rot = new TGeoRotation("rot1", 0., 0., rotationAngle);
154
155
TGeoRotation
* rot =
new
TGeoRotation
(
"rot1"
, 0., 0., 0.);
156
rot->
Print
();
157
rot->
RotateY
(
rotationAngle
);
158
159
TGeoCombiTrans
* combi1 =
new
TGeoCombiTrans
(
ecalX
,
ecalY
,
ecalZ
, rot);
160
161
// ---- global geometry parameters ---------------------------------------
162
FairGeoLoader* geoLoad =
new
FairGeoLoader(
"TGeo"
,
"FairGeoLoader"
);
163
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
164
165
// ------- Load media from media file ----------------------------------
166
TString
medFile = gPath +
"/geometry/media.geo"
;
167
geoFace->setMediaFile(medFile);
168
geoFace->readMedia();
169
FairGeoMedia* geoMedia = geoFace->getMedia();
170
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
171
geoMedia->list();
172
geoMedia->print();
173
DefineRequiredMedia
(geoMedia, geoBuild);
174
175
// ------------------------ VOLUMES ----------------------------------------
176
177
// -------------- Create geometry and global top volume -----------------
178
179
TGeoVolume
* top =
new
TGeoVolumeAssembly
(
"TOP"
);
180
top->
SetMedium
(
mMed
.air);
// ??? it was vacuum ???
181
// top->SetLineColor(kBlue);
182
// top->SetVisibility(kTRUE);
183
// top->SetTransparency(100);
184
185
gGeoManager
= (
TGeoManager
*)
gROOT
->FindObject(
"FAIRGeom"
);
186
gGeoManager
->SetName(geoDetectorName +
"_geom"
);
187
gGeoManager
->SetTopVolume(top);
188
// gGeoManager->SetTopVisible(1);
189
190
TGeoVolume
* ecal =
191
gGeoManager
->MakeBox(
"ecal"
,
mMed
.vacuum,
Xmodules
*
modwidth
/ 2,
Ymodules
*
modheight
/ 2,
modlength
/ 2);
192
// ecal->SetVisibility(kTRUE);
193
// ecal->SetTransparency(100);
194
// combi1->RotateY(rotationAngle);
195
top->
AddNode
(ecal, 0, combi1);
196
197
TGeoVolume
* module =
gGeoManager
->MakeBox(
"mod"
,
mMed
.vacuum,
modwidth
/ 2,
modheight
/ 2,
modlength
/ 2);
198
// module->SetVisibility(kTRUE);
199
// module->SetTransparency(100);
200
// module->SetLineColor(kRed);
201
// module->SetLineWidth(0);
202
203
TGeoVolume
* layerPb =
gGeoManager
->MakeBox(
"layPb"
,
mMed
.lead,
modwidth
/ 2,
modheight
/ 2,
thickPb
/ 2);
204
// layerPb->SetVisibility(kTRUE);
205
// layerPb->SetLineColor(kBlue);
206
// layerPb->SetLineWidth(0);
207
// layerPb->SetTransparency(100);
208
209
TGeoVolume
* layerPaint =
gGeoManager
->MakeBox(
"layPaint"
,
mMed
.TiO2,
modwidth
/ 2,
modheight
/ 2,
thickPaint
/ 2);
210
// layerPaint->SetVisibility(kTRUE);
211
// layerPaint->SetLineColor(kWhite);
212
// layerPaint->SetLineWidth(0);
213
// layerPaint->SetTransparency(100);
214
215
TGeoVolume
* layerSci =
gGeoManager
->MakeBox(
"laySci"
,
mMed
.scint,
modwidth
/ 2,
modheight
/ 2,
thickSci
/ 2);
216
// layerSci->SetLineColor(kWhite+1);
217
// layerSci->SetTransparency(100);
218
219
TGeoVolume
* covSteel =
gGeoManager
->MakeBox(
"covSteel"
,
mMed
.air,
modwidth
/ 2,
modheight
/ 2,
220
thickSteel
/ 2);
// ??? should be steel ???
221
// covSteel->SetVisibility(kTRUE);
222
// covSteel->SetLineColor(kWhite);
223
// covSteel->SetTransparency(100);
224
225
// ------------------ STRUCTURE -------------------------------------------
226
module
->AddNode(covSteel, 0, new TGeoTranslation(0, 0, thickSteel / 2 - modlength / 2));
227
Double_t
z;
228
// Zlayers = 1;
229
Int_t
nlay;
230
for
(
int
zlayer = 0; zlayer <
Zlayers
; zlayer++) {
231
z =
thickSteel
+
thickPbSciPaint
* zlayer;
232
// TString layerNamePb = TString::Format("layerPb%d",zlayer);
233
// TString layerNameSci = TString::Format("layerSci%d",zlayer);
234
module
->AddNode(layerPaint, nlay, new TGeoTranslation(0, 0, z + thickPaint / 2 - modlength / 2));
235
module
->AddNode(layerPb, nlay, new TGeoTranslation(0, 0, z + thickPaint + thickPb / 2 - modlength / 2));
236
module
->AddNode(layerPaint, nlay,
237
new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint / 2 - modlength / 2));
238
module
->AddNode(
239
layerSci, zlayer,
240
new TGeoTranslation(0, 0, z + thickPaint + thickPb + thickPaint + thickSci / 2 - modlength / 2));
241
}
242
243
int
nmod = 0;
244
// Xmodules = 1;
245
// Ymodules = 1;
246
Double_t
x0 =
modwidth
*
Xmodules
/ 2 -
modwidth
/ 2;
247
Double_t
y0 =
modheight
*
Ymodules
/ 2 -
modheight
/ 2;
248
for
(
int
xmod = 0; xmod <
Xmodules
; xmod++) {
249
for
(
int
ymod = 0; ymod <
Ymodules
; ymod++) {
250
TString
moduleName =
TString::Format
(
"mod_X:%d_Y:%d"
, xmod, ymod);
251
module
->SetName(moduleName);
252
cout << module->
GetName
() << endl;
253
ecal->
AddNode
(module, nmod++,
new
TGeoTranslation
(x0 -
modwidth
* xmod, -y0 +
modheight
* ymod, 0));
254
}
// ymod
255
}
// xmod
256
257
top->
SetVisContainers
(
kTRUE
);
258
gGeoManager
->CloseGeometry();
259
gGeoManager
->CheckOverlaps(0.001);
260
gGeoManager
->PrintOverlaps();
261
gGeoManager
->Test();
262
// gGeoMan->SetVisLevel(3);
263
// gGeoMan->SetVisOption(1);
264
TFile
* geoFile =
new
TFile
(geoFileName,
"RECREATE"
);
265
top->
Write
();
266
geoFile->
Close
();
267
// top->Draw("ogl");
268
}
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
TGeoCombiTrans
TGeoManager
TGeoMatrix::Print
void Print(Option_t *option="") const override
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)
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::Data
const char * Data() const
TString::Format
static TString Format(const char *fmt,...)
TString::Form
void Form(const char *fmt,...)
Xmodules
int Xmodules
Definition
create_rootgeom_ECAL_v2.C:75
thickPaint
Double_t thickPaint
Definition
create_rootgeom_ECAL_v2.C:81
modheight
Double_t modheight
Definition
create_rootgeom_ECAL_v2.C:84
thickPb
Double_t thickPb
Definition
create_rootgeom_ECAL_v2.C:78
thickSci
Double_t thickSci
Definition
create_rootgeom_ECAL_v2.C:79
Ymodules
int Ymodules
Definition
create_rootgeom_ECAL_v2.C:76
Zlayers
int Zlayers
Definition
create_rootgeom_ECAL_v2.C:77
modwidth
Double_t modwidth
Definition
create_rootgeom_ECAL_v2.C:83
rotationAngle
Double_t rotationAngle
Definition
create_rootgeom_ECAL_v2.C:32
thickPbSciPaint
Double_t thickPbSciPaint
Definition
create_rootgeom_ECAL_v2.C:82
ecalX
Double_t ecalX
Definition
create_rootgeom_ECAL_v2.C:29
modlength
Double_t modlength
Definition
create_rootgeom_ECAL_v2.C:85
thickSteel
Double_t thickSteel
Definition
create_rootgeom_ECAL_v2.C:80
ecalZ
Double_t ecalZ
Definition
create_rootgeom_ECAL_v2.C:31
ecalY
Double_t ecalY
Definition
create_rootgeom_ECAL_v2.C:30
DefineMedia
TGeoMedium * DefineMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild, const char *name)
Definition
create_rootgeom_ECAL_v2.C:101
iron
TGeoMedium * iron
Definition
create_rootgeom_ECAL_v2.C:92
tyvec
TGeoMedium * tyvec
Definition
create_rootgeom_ECAL_v2.C:96
lead
TGeoMedium * lead
Definition
create_rootgeom_ECAL_v2.C:93
steel
TGeoMedium * steel
Definition
create_rootgeom_ECAL_v2.C:95
SetEcalPosition
void SetEcalPosition(Int_t run, Int_t pos)
Definition
create_rootgeom_ECAL_v2.C:34
TiO2
TGeoMedium * TiO2
Definition
create_rootgeom_ECAL_v2.C:98
DefineRequiredMedia
void DefineRequiredMedia(FairGeoMedia *geoMedia, FairGeoBuilder *geoBuild)
Definition
create_rootgeom_ECAL_v2.C:113
mMed
struct @320007130027150254226344315006374143022050372350 mMed
air
TGeoMedium * air
Definition
create_rootgeom_ECAL_v2.C:91
create_rootgeom_ECAL_v2
void create_rootgeom_ECAL_v2(Int_t run, Int_t pos)
Definition
create_rootgeom_ECAL_v2.C:134
vacuum
TGeoMedium * vacuum
Definition
create_rootgeom_ECAL_v2.C:90
scint
TGeoMedium * scint
Definition
create_rootgeom_ECAL_v2.C:94
install
macro
geometry
create_rootgeom_ECAL_v2.C
Generated on
for BmnRoot by
1.17.0