VMC Examples Version 6.6
Loading...
Searching...
No Matches
DetectorConstruction.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2007 - 2016 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
10/// \file ExGarfield/src/DetectorConstruction.cxx
11/// \brief Implementation of the ExGarfield::DetectorConstruction class
12///
13/// Garfield garfieldpp example adapted to Virtual Monte Carlo.
14///
15/// \date 28/10/2015
16/// \author I. Hrivnacova; IPN, Orsay
17
18#include <Riostream.h>
19#include <TGeoBBox.h>
20#include <TGeoElement.h>
21#include <TGeoManager.h>
22#include <TGeoMaterial.h>
23#include <TGeoTube.h>
24#include <TGeoVolume.h>
25#include <TList.h>
26#include <TThread.h>
27#include <TVirtualMC.h>
28
29#include "DetectorConstruction.h"
30
31using namespace std;
32
33/// \cond CLASSIMP
35 /// \endcond
36
37 namespace VMC
38{
39 namespace ExGarfield
40 {
41
42 //_____________________________________________________________________________
44 {
45 /// Default constuctor
46 }
47
48 //_____________________________________________________________________________
50 {
51 /// Destructor
52 }
53
54 //
55 // public methods
56 //
57
58 //_____________________________________________________________________________
60 {
61 /// Construct geometry using TGeo modeller
62
63 // Create Root geometry manager
64 new TGeoManager("Garfield_geometry", "ExGarfield VMC example geometry");
65
66 // Elements
67 //
68 Double_t z, a;
69 TGeoElement* elH = new TGeoElement("Hydrogen", "H", z = 1., a = 1.01);
70 TGeoElement* elC = new TGeoElement("Carbon", "C", z = 6., a = 12.01);
71 TGeoElement* elN = new TGeoElement("Nitrogen", "N", z = 7., a = 14.01);
72 TGeoElement* elO = new TGeoElement("Oxygen", "O", z = 8., a = 16.00);
73 TGeoElement* elAr = new TGeoElement("Argon", "Ar", z = 18., a = 39.94);
74 // TGeoElement* elW = new TGeoElement("Tungsten", "W", z = 74., a =
75 // 183.84); TGeoElement* elPb = new TGeoElement("Lead", "Pb", z = 82., a
76 // = 207.22);
77
78 // Materials
79 //
80
81 // Al
82 Double_t density;
83 TGeoMaterial* matAl =
84 new TGeoMaterial("Al", a = 26.98, z = 13., density = 2.699);
85
86 // W
87 TGeoMaterial* matW =
88 new TGeoMaterial("Tungsten", a = 183.85, z = 74., density = 19.30);
89
90 // Pb
91 TGeoMaterial* matPb =
92 new TGeoMaterial("Lead", a = 207.22, z = 82., density = 11.35);
93
94 // Air
95 TGeoMixture* matAir = new TGeoMixture("AirA", 4, density = 1.205e-03);
96 matAir->AddElement(elC, 0.0001);
97 matAir->AddElement(elN, 0.7553);
98 matAir->AddElement(elO, 0.2318);
99 matAir->AddElement(elAr, 0.0128);
100
101 // ArCO2_70_30
102 TGeoMixture* matArCO2 = new TGeoMixture("ArCO2", 3, density = 1.822e-03);
103 matArCO2->AddElement(elAr, 0.7000);
104 matArCO2->AddElement(elC, 0.0819);
105 matArCO2->AddElement(elO, 0.2181);
106
107 // Kapton
108 TGeoMixture* matKapton = new TGeoMixture("Kapton", 4, density = 1.413);
109 matKapton->AddElement(elO, 0.2092);
110 matKapton->AddElement(elC, 0.6911);
111 matKapton->AddElement(elN, 0.0733);
112 matKapton->AddElement(elH, 0.0264);
113
114 // Tracking medias (defaut parameters)
115 //
116
117 // Paremeters for tracking media
118 Double_t param[20];
119 param[0] = 0; // isvol - Not used
120 param[1] = 2; // ifield - User defined magnetic field
121 param[2] = 10.; // fieldm - Maximum field value (in kiloGauss)
122 param[3] = -20.; // tmaxfd - Maximum angle due to field deflection
123 param[4] = -0.01; // stemax - Maximum displacement for multiple scat
124 param[5] = -.3; // deemax - Maximum fractional energy loss, DLS
125 param[6] = .001; // epsil - Tracking precision
126 param[7] = -.8; // stmin
127 for (Int_t i = 8; i < 20; ++i) param[i] = 0.;
128
129 Int_t mediumId = 0;
130 TGeoMedium* medAl = new TGeoMedium("Al", ++mediumId, matAl, param);
131 TGeoMedium* medW = new TGeoMedium("W", ++mediumId, matW, param);
132 TGeoMedium* medPb = new TGeoMedium("Pb", ++mediumId, matPb, param);
133 TGeoMedium* medAir = new TGeoMedium("AirA", ++mediumId, matAir, param);
134 TGeoMedium* medArCO2 = new TGeoMedium("ArCO2", ++mediumId, matArCO2, param);
135
136 TGeoMedium* defaultMedium = medAir;
137 TGeoMedium* absorberMedium = medPb;
138 TGeoMedium* gasMedium = medArCO2;
139 TGeoMedium* cathodeMedium = medAl;
140 TGeoMedium* wireMedium = medW;
141
142 // Volumes
143 //
144
145 // Geometry parameters
146 Double_t mm = 0.1; // milimeter -> cm
147 Double_t um = 1.e-4; // micrometer -> cm
148 Double_t worldSizeXYZ = 1000 * mm;
149 Double_t absorberThicknessZ = 10. * mm;
150 Double_t absorberThicknessXY = 100. * mm;
151 Double_t wireRadius = 0.025 * mm;
152 Double_t tubeRadius = 15 * mm;
153 Double_t tubeHalfLength = 100 * mm;
154 Double_t tubeThickness = 500 * um;
155
156 //
157 // World
158 //
159 TGeoShape* worldS = new TGeoBBox("World", // its name
160 0.5 * worldSizeXYZ, 0.5 * worldSizeXYZ,
161 0.5 * worldSizeXYZ); // its size
162
163 TGeoVolume* worldLV = new TGeoVolume("World", worldS, defaultMedium);
164
165 gGeoManager->SetTopVolume(worldLV);
166
167 //
168 // Absorber
169 //
170 TGeoShape* absorberS = new TGeoBBox("Absorber", // its name
171 0.5 * absorberThicknessXY, 0.5 * absorberThicknessXY,
172 0.5 * absorberThicknessZ); // its size
173
174 TGeoVolume* absorberLV =
175 new TGeoVolume("Absorber", absorberS, absorberMedium);
176
177 Double_t xpos = 0;
178 Double_t ypos = 0;
179 Double_t zpos = absorberThicknessZ / 2;
180 worldLV->AddNode(absorberLV, 1, new TGeoTranslation(xpos, ypos, zpos));
181
182 //
183 // Drift tube
184 //
185 TGeoShape* tubeS =
186 new TGeoTube("Tube", 0, tubeRadius, tubeHalfLength + tubeThickness);
187
188 TGeoVolume* tubeLV = new TGeoVolume("Tube", tubeS, cathodeMedium);
189
190 TGeoRotation* rotY = new TGeoRotation();
191 rotY->RotateY(-90.);
192 ypos = -0.2 * tubeRadius;
193 zpos = absorberThicknessZ + tubeRadius;
194 worldLV->AddNode(tubeLV, 1, new TGeoCombiTrans(xpos, ypos, zpos, rotY));
195
196 //
197 // Drift Tube Gas
198 //
199 TGeoShape* gasS = new TGeoTube(
200 "Gas", wireRadius, tubeRadius - tubeThickness, tubeHalfLength);
201
202 TGeoVolume* gasLV = new TGeoVolume("Gas", gasS, gasMedium);
203
204 ypos = 0.;
205 zpos = 0.;
206 tubeLV->AddNode(gasLV, 1, new TGeoTranslation(xpos, ypos, zpos));
207
208 //
209 // Wire
210 //
211 TGeoShape* wireS = new TGeoTube("Wire", 0, wireRadius, tubeHalfLength);
212
213 TGeoVolume* wireLV = new TGeoVolume("Wire", wireS, wireMedium);
214
215 ypos = 0.;
216 zpos = 0.;
217 tubeLV->AddNode(wireLV, 1, new TGeoTranslation(xpos, ypos, zpos));
218
219 // close geometry
220 gGeoManager->CloseGeometry();
221
222 // write geometry
223 gGeoManager->Export("geometry.root");
224
225 // notify VMC about Root geometry
226 gMC->SetRootGeometry();
227 }
228
229 } // namespace ExGarfield
230}
The detector construction (via TGeo )