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 - 2015 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 TR/src/DetectorConstruction.cxx
11/// \brief Implementation of the DetectorConstruction class
12///
13/// \date 18/12/2015
14/// \author I. Hrivnacova; IPN, Orsay
15
16#include "DetectorConstruction.h"
17
18#include <Riostream.h>
19#include <TGeoBBox.h>
20#include <TGeoElement.h>
21#include <TGeoManager.h>
22#include <TGeoMaterial.h>
23#include <TGeoVolume.h>
24#include <TVirtualMC.h>
25
26using namespace std;
27
28/// \cond CLASSIMP
30 /// \endcond
31
32 namespace VMC
33{
34 namespace TR
35 {
36
37 //_____________________________________________________________________________
39 {
40 /// Default constuctor
41 }
42
43 //_____________________________________________________________________________
45 {
46 /// Destructor
47 }
48
49 //
50 // public methods
51 //
52
53 //_____________________________________________________________________________
55 {
56 // Geometry parameters
57 //
58
59 // Create Root geometry manager
60 new TGeoManager("TR_geometry", "TR VMC example geometry");
61
62 cout << "DetectorSimpleALICE setup" << endl;
63
64 Double_t cm = 1.0;
65 Double_t mm = 0.1; // milimeter -> cm
66 Double_t micrometer = 1.0e-04; // micrometer -> cm
67 Double_t worldSizeZ = 400. * cm;
68 Double_t worldSizeR = 20. * cm;
69
70 // Radiator and detector parameters
71
72 Double_t radThickness = 0.020 * mm;
73 Double_t gasGap = 0.250 * mm;
74 Double_t foilGasRatio = radThickness / (radThickness + gasGap);
75 Int_t foilNumber = 220;
76
77 Double_t absorberThickness = 38.3 * mm;
78 Double_t absorberRadius = 100. * mm;
79
80 Double_t windowThick = 51.0 * micrometer;
81 Double_t electrodeThick = 10.0 * micrometer;
82 Double_t gapThick = 10.0 * cm;
83 Double_t detGap = 0.01 * mm;
84
85 Double_t startZ = 100.0 * mm;
86
87 // Materials
88 //
89 TString name; // Material name
90 Double_t a; // Mass of a mole in g/mole
91 Double_t z; // Atomic number
92 Double_t density; // Material density in g/cm3
93 Double_t fractionmass; // Fraction mass
94
95 // Elements
96 TGeoElement* elH = new TGeoElement("Hydrogen", "H", z = 1, a = 1.01);
97 TGeoElement* elC = new TGeoElement("Carbon", "C", z = 6., a = 12.01);
98 TGeoElement* elN = new TGeoElement("Nitrogen", "N", z = 7., a = 14.01);
99 TGeoElement* elO = new TGeoElement("Oxygen", "O", z = 8., a = 16.00);
100 TGeoElement* elAr = new TGeoElement("Argon", "Ar", z = 18., a = 39.94);
101
102 // Dry Air (average composition with Ar), STP
103 TGeoMixture* matAir = new TGeoMixture("Air", 3, density = 1.2928e-03);
104 matAir->AddElement(elN, fractionmass = 0.7557);
105 matAir->AddElement(elO, fractionmass = 0.2315);
106 matAir->AddElement(elAr, fractionmass = 0.0128);
107
108 // Mylar
109 TGeoMixture* matMylar = new TGeoMixture("Mylar", 3, density = 1.39);
110 matMylar->AddElement(elO, 2);
111 matMylar->AddElement(elC, 5);
112 matMylar->AddElement(elH, 4);
113
114 // Xenon as detector gas, STP
115 TGeoMaterial* matXe =
116 new TGeoMaterial("Xenon", a = 131.29, z = 54., density = 5.858e-06);
117
118 // Carbon dioxide, STP
119 TGeoMixture* matCO2 = new TGeoMixture("CO2", 2, density = 1.977e-06);
120 matCO2->AddElement(elC, 1);
121 matCO2->AddElement(elO, 2);
122
123 // 85% Xe + 15% CO2, STP
124 TGeoMixture* matXe15CO2 = new TGeoMixture("Xe15CO2", 2, density = 4.9e-03);
125 matXe15CO2->AddElement(matXe, fractionmass = 0.979);
126 matXe15CO2->AddElement(matCO2, fractionmass = 0.021);
127
128 Double_t foilDensity = matMylar->GetDensity();
129 Double_t gasDensity = matAir->GetDensity();
130 Double_t totDensity =
131 foilDensity * foilGasRatio + gasDensity * (1.0 - foilGasRatio);
132
133 Double_t fractionFoil = foilDensity * foilGasRatio / totDensity;
134 Double_t fractionGas = gasDensity * (1.0 - foilGasRatio) / totDensity;
135
136 TGeoMixture* matRadiator = new TGeoMixture("radiatorMat", 2, totDensity);
137 matRadiator->AddElement(matMylar, fractionFoil);
138 matRadiator->AddElement(matAir, fractionGas);
139
140 // Tracking medias (defaut parameters)
141 //
142
143 // Paremeters for tracking media
144 Double_t param[20];
145 param[0] = 0; // isvol - Not used
146 param[1] = 2; // ifield - User defined magnetic field
147 param[2] = 10.; // fieldm - Maximum field value (in kiloGauss)
148 param[3] = -20.; // tmaxfd - Maximum angle due to field deflection
149 param[4] = -0.01; // stemax - Maximum displacement for multiple scat
150 param[5] = -.3; // deemax - Maximum fractional energy loss, DLS
151 param[6] = .001; // epsil - Tracking precision
152 param[7] = -.8; // stmin
153 for (Int_t i = 8; i < 20; ++i) param[i] = 0.;
154
155 Int_t mediumId = 0;
156 TGeoMedium* medAir = new TGeoMedium("Air", ++mediumId, matAir, param);
157 TGeoMedium* medXe15CO2 =
158 new TGeoMedium("Xe15CO2", ++mediumId, matXe15CO2, param);
159 TGeoMedium* medRadiator =
160 new TGeoMedium("Radiator", ++mediumId, matRadiator, param);
161
162 TGeoMedium* worldMedium = medAir;
163 TGeoMedium* absorberMedium = medXe15CO2;
164 TGeoMedium* radiatorMedium = medRadiator;
165
166 // Volumes
167 //
168
169 TGeoShape* solidWorld =
170 new TGeoBBox("World", worldSizeR, worldSizeR, worldSizeZ / 2.);
171
172 TGeoVolume* logicWorld = new TGeoVolume("World", solidWorld, worldMedium);
173
174 gGeoManager->SetTopVolume(logicWorld);
175
176 // TR radiator envelope
177
178 Double_t radThick = foilNumber * (radThickness + gasGap) - gasGap + detGap;
179 Double_t radZ = startZ + 0.5 * radThick;
180
181 TGeoShape* solidRadiator = new TGeoBBox(
182 "Radiator", 1.1 * absorberRadius, 1.1 * absorberRadius, 0.5 * radThick);
183
184 TGeoVolume* logicRadiator =
185 new TGeoVolume("Radiator", solidRadiator, radiatorMedium);
186
187 logicWorld->AddNode(logicRadiator, 1, new TGeoTranslation(0, 0, radZ));
188
189 // Print radiator description
190 // These values should be set via /mcDet/setRadiator command
191 //
192 cout << "Radiator volume: " << logicRadiator->GetName() << endl;
193 cout << "Foil material: " << matMylar->GetName() << endl;
194 cout << "Gas material: " << matAir->GetName() << endl;
195 cout << "Foil thickness: " << radThickness << endl;
196 cout << "Gas thickness: " << gasGap << endl;
197 cout << "Foild number: " << foilNumber << endl;
198
199 // create region for window inside windowR for
200
201 // G4Region* radRegion = new G4Region("XTRradiator");
202 // radRegion->AddRootLogicalVolume(logicRadiator);
203
204 // Absorber
205
206 TGeoShape* solidAbsorber = new TGeoBBox(
207 "Absorber", absorberRadius, absorberRadius, absorberThickness / 2.);
208
209 TGeoVolume* logicAbsorber =
210 new TGeoVolume("Absorber", solidAbsorber, absorberMedium);
211
212 Double_t windowZ = startZ + radThick + windowThick / 2. + 15.0 * mm;
213 Double_t gapZ = windowZ + windowThick / 2. + gapThick / 2. + 0.01 * mm;
214 Double_t electrodeZ =
215 gapZ + gapThick / 2. + electrodeThick / 2. + 0.01 * mm;
216 Double_t absorberZ =
217 electrodeZ + electrodeThick / 2. + absorberThickness / 2. + 0.01 * mm;
218
219 logicWorld->AddNode(
220 logicAbsorber, 1, new TGeoTranslation(0., 0., absorberZ));
221
222 // G4Region* regGasDet = new G4Region("XTRdEdxDetector");
223 // regGasDet->AddRootLogicalVolume(logicAbsorber);
224
225 // close geometry
226 gGeoManager->CloseGeometry();
227
228 // notify VMC about Root geometry
229 gMC->SetRootGeometry();
230
231 // Sensitive Detectors: Absorber
232
233 // SensitiveDetector* sd = new SensitiveDetector("SensitiveDetector");
234 // G4SDManager::GetSDMpointer()->AddNewDetector(sd );
235 // logicAbsorber->SetSensitiveDetector(sd);
236
237 // Print geometry parameters
238
239 cout << "\n The WORLD is made of " << worldSizeZ / mm << "mm of "
240 << worldMedium->GetName();
241 cout << ", the transverse size (R) of the world is " << worldSizeR / mm
242 << " mm. " << endl;
243 cout << " The ABSORBER is made of " << absorberThickness / mm << "mm of "
244 << absorberMedium->GetName();
245 cout << ", the transverse size (R) is " << absorberRadius / mm << " mm. "
246 << endl;
247 cout << " Z position of the (middle of the) absorber " << absorberZ / mm
248 << " mm." << endl;
249
250 cout << "radZ = " << radZ / mm << " mm" << endl;
251 cout << "startZ = " << startZ / mm << " mm" << endl;
252
253 cout << "fRadThick = " << radThick / mm << " mm" << endl;
254 cout << "fFoilNumber = " << foilNumber << endl;
255 cout << "fRadiatorMat = " << radiatorMedium->GetMaterial()->GetName()
256 << endl;
257 cout << "WorldMaterial = " << worldMedium->GetMaterial()->GetName() << endl;
258 cout << endl;
259 }
260
261 } // namespace TR
262}
The detector construction (via TGeo )