BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
create_rootgeom_MWPC_SCAN.C
Go to the documentation of this file.
1
#include "
TFile.h
"
2
#include "
TGeoBBox.h
"
3
#include "
TGeoManager.h
"
4
#include "
TGeoShape.h
"
5
#include "
TMath.h
"
6
#include "
TString.h
"
7
8
using namespace
TMath
;
9
10
TGeoManager
*
gGeoMan
= NULL;
11
12
// Number of active planes with wires
13
const
Int_t
NofPlanes
= 20;
14
15
// Detector's position
16
const
Double_t
MWPC1_Xpos
= 0.0;
17
const
Double_t
MWPC1_Ypos
= 0.0;
18
const
Double_t
MWPC1_Zpos
= 0.0;
19
20
// Detector's construct parameters
21
const
Double_t
GapZsize
= 1.0;
// cm
22
const
Double_t
GapWireOnePlane
= 0.25;
// cm
23
const
Double_t
GapWireTwoPlanes
=
GapWireOnePlane
/ 2.0;
// cm // 0.125
24
25
const
Double_t
XSizeOfActiveVolume
= 450;
26
const
Double_t
YSizeOfActiveVolume
= 100;
27
const
Double_t
ZSizeOfActiveVolume
= 250;
28
29
void
create_rootgeom_MWPC_SCAN
()
30
{
31
32
// Load the necessary FairRoot libraries
33
gROOT
->LoadMacro(
"$VMCWORKDIR/macro/run/bmnloadlibs.C"
);
34
bmnloadlibs();
// load libraries
35
36
// ------- Load media from media file -----------------------------------
37
FairGeoLoader* geoLoad =
new
FairGeoLoader(
"TGeo"
,
"FairGeoLoader"
);
38
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
39
TString
geoPath =
TString
(
gSystem
->Getenv(
"VMCWORKDIR"
)) +
"/geometry/"
;
40
TString
medFile = geoPath +
"media.geo"
;
41
geoFace->setMediaFile(medFile);
42
geoFace->readMedia();
43
gGeoMan
=
gGeoManager
;
44
// --------------------------------------------------------------------------
45
46
// ------- Geometry file name (output) ----------------------------------
47
const
TString
geoDetectorName =
"mwpc_scan"
;
48
const
TString
geoDetectorVersion =
"v1"
;
49
TString
geoFileName = geoPath + geoDetectorName +
"_"
+ geoDetectorVersion +
".root"
;
50
// --------------------------------------------------------------------------
51
52
// ----------------- Get and create the required media -----------------
53
FairGeoMedia* geoMedia = geoFace->getMedia();
54
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
55
56
FairGeoMedium* mAir = geoMedia->getMedium(
"air"
);
57
if
(!mAir)
58
Fatal
(
"Main"
,
"FairMedium air not found"
);
59
geoBuild->createMedium(mAir);
60
TGeoMedium
* pMedAir =
gGeoMan
->GetMedium(
"air"
);
61
if
(!pMedAir)
62
Fatal
(
"Main"
,
"Medium air not found"
);
63
64
FairGeoMedium* mArCO27030 = geoMedia->getMedium(
"arco27030"
);
65
if
(!mArCO27030)
66
Fatal
(
"Main"
,
"FairMedium arco27030 not found"
);
67
geoBuild->createMedium(mArCO27030);
68
TGeoMedium
* pMedArCO27030 =
gGeoMan
->GetMedium(
"arco27030"
);
69
if
(!pMedArCO27030)
70
Fatal
(
"Main"
,
"Medium arco27030 not found"
);
71
72
// --------------------------------------------------------------------------
73
74
// -------------- Create geometry and top volume -------------------------
75
gGeoMan
= (
TGeoManager
*)
gROOT
->FindObject(
"FAIRGeom"
);
76
gGeoMan
->SetName(geoDetectorName +
"_geom"
);
77
TGeoVolume
* top =
new
TGeoVolumeAssembly
(
"TOP"
);
78
top->
SetMedium
(pMedAir);
79
gGeoMan
->SetTopVolume(top);
80
// gGeoMan->SetTopVisible(1);
81
// --------------------------------------------------------------------------
82
83
// Define TOP Geometry
84
TGeoVolume
* MWPC1Top =
new
TGeoVolumeAssembly
(geoDetectorName);
85
MWPC1Top->
SetMedium
(pMedAir);
86
87
// Transformations (translations, rotations and scales)
88
TGeoTranslation
* DetPos_trans =
new
TGeoTranslation
(
"DetPos_trans"
,
MWPC1_Xpos
,
MWPC1_Ypos
,
MWPC1_Zpos
);
89
90
// Solids (shapes)
91
92
// TGeoBBox *MWPC1ContainerS = new TGeoBBox("MWPC1ContainerS", XSizeOfActiveVolume / 2.0 + 1.0,
93
// YSizeOfActiveVolume / 2.0 + 1.0, 0.005 + 0.01);
94
TGeoBBox
* MWPC1ActivePlaneS =
95
new
TGeoBBox
(
"MWPC1ActivePlaneS"
,
XSizeOfActiveVolume
/ 2.0,
YSizeOfActiveVolume
/ 2.0, 0.005);
96
97
// Volumes
98
// TGeoVolume *MWPC1ContainerV = new TGeoVolume("MWPC1ContainerV", MWPC1ContainerS);
99
// MWPC1ContainerV->SetMedium(pMedAir);
100
// MWPC1ContainerV->SetVisibility(kTRUE);
101
102
TGeoVolume
* MWPC1ActivePlaneV =
new
TGeoVolume
(
"MWPC1ActivePlaneV"
, MWPC1ActivePlaneS);
103
MWPC1ActivePlaneV->
SetMedium
(pMedArCO27030);
104
MWPC1ActivePlaneV->
SetLineColor
(
kBlue
);
105
106
// Adding volumes to the TOP Volume
107
top->
AddNode
(MWPC1Top, 1, DetPos_trans);
108
// MWPC1Top->AddNode(MWPC1ContainerV, 1);
109
const
Float_t
a = 10.0;
// cm
110
const
Float_t
b = 300.0;
// cm
111
for
(
Int_t
iPlane = 1; iPlane <=
NofPlanes
; ++iPlane) {
112
TGeoTranslation
t1(0.0, 0.0, (b - a) /
NofPlanes
* (iPlane - 1));
113
TGeoRotation
r1(
"r1"
, 0.0, 0.0, 0.0);
114
MWPC1Top->
AddNode
(MWPC1ActivePlaneV, iPlane,
new
TGeoCombiTrans
(t1, r1));
115
// MWPC1ContainerV->AddNode(MWPC1ActivePlaneV, iPlane, new TGeoCombiTrans(t1, r1));
116
}
117
118
top->
SetVisContainers
(
kTRUE
);
119
120
// --------------- Finish -----------------------------------------------
121
gGeoMan
->CloseGeometry();
122
gGeoMan
->CheckOverlaps(0.001);
123
gGeoMan
->PrintOverlaps();
124
gGeoMan
->Test();
125
126
TFile
* geoFile =
new
TFile
(geoFileName,
"RECREATE"
);
127
top->
Write
();
128
geoFile->
Close
();
129
top->
Draw
(
"ogl"
);
130
}
Int_t
int Int_t
Float_t
float Float_t
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
kBlue
kBlue
Fatal
void Fatal(const char *location, const char *msgfmt,...)
TFile.h
TGeoBBox.h
TGeoManager.h
gGeoManager
R__EXTERN TGeoManager * gGeoManager
TGeoShape.h
TMath.h
gROOT
#define gROOT
TString.h
gSystem
R__EXTERN TSystem * gSystem
TFile
TFile::Close
void Close(Option_t *option="") override
TGeoBBox
TGeoCombiTrans
TGeoManager
TGeoMedium
TGeoRotation
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::Draw
void Draw(Option_t *option="") override
TGeoVolume::SetMedium
virtual void SetMedium(TGeoMedium *medium)
TGeoVolume::SetLineColor
void SetLineColor(Color_t lcolor) override
TObject::Write
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TString
gGeoMan
TGeoManager * gGeoMan
Definition
create_rootgeom_MWPC_SCAN.C:10
XSizeOfActiveVolume
const Double_t XSizeOfActiveVolume
Definition
create_rootgeom_MWPC_SCAN.C:25
GapWireOnePlane
const Double_t GapWireOnePlane
Definition
create_rootgeom_MWPC_SCAN.C:22
YSizeOfActiveVolume
const Double_t YSizeOfActiveVolume
Definition
create_rootgeom_MWPC_SCAN.C:26
ZSizeOfActiveVolume
const Double_t ZSizeOfActiveVolume
Definition
create_rootgeom_MWPC_SCAN.C:27
NofPlanes
const Int_t NofPlanes
Definition
create_rootgeom_MWPC_SCAN.C:13
MWPC1_Ypos
const Double_t MWPC1_Ypos
Definition
create_rootgeom_MWPC_SCAN.C:17
MWPC1_Xpos
const Double_t MWPC1_Xpos
Definition
create_rootgeom_MWPC_SCAN.C:16
GapZsize
const Double_t GapZsize
Definition
create_rootgeom_MWPC_SCAN.C:21
MWPC1_Zpos
const Double_t MWPC1_Zpos
Definition
create_rootgeom_MWPC_SCAN.C:18
GapWireTwoPlanes
const Double_t GapWireTwoPlanes
Definition
create_rootgeom_MWPC_SCAN.C:23
create_rootgeom_MWPC_SCAN
void create_rootgeom_MWPC_SCAN()
Definition
create_rootgeom_MWPC_SCAN.C:29
TMath
macro
geometry
create_rootgeom_MWPC_SCAN.C
Generated on
for BmnRoot by
1.17.0