VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex06DetectorConstruction.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2007 - 2014 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 Ex06DetectorConstruction.cxx
11/// \brief Implementation of the Ex06DetectorConstruction class
12///
13/// Geant4 ExampleN03 adapted to Virtual Monte Carlo \n
14/// Id: ExN06DetectorConstruction.cc,v 1.14 2004/03/17 22:41:12 gum Exp
15/// GEANT4 tag Name: geant4-07-00-cand-01
16///
17/// \date 16/05/2005
18/// \author I. Hrivnacova; IPN, Orsay
19
20#include <Riostream.h>
21#include <TGeoManager.h>
22#include <TThread.h>
23#include <TVirtualMC.h>
24
26
27/// \cond CLASSIMP
29 /// \endcond
30
31 //_____________________________________________________________________________
33 : TObject(),
34 fWorldSize(1500), // 15*m
35 fExpHallSize(1000), // 10*m
36 fTankSize(500), // 5*m
37 fBubbleSize(50), // 0.5*m
38 fImedAir(-1),
39 fImedWater(-1)
40{
41 /// Default constuctor
42}
43
44//_____________________________________________________________________________
49
50//
51// public methods
52//
53
54//_____________________________________________________________________________
56{
57 /// Construct materials using TGeo modeller
58
59 // Create Root geometry manager
60 new TGeoManager("E06_geometry", "E06 VMC example geometry");
61
62 Double_t a; // Mass of a mole in g/mole
63 Double_t z; // Atomic number
64 Double_t density; // Material density in g/cm3
65
66 // Elements
67
68 TGeoElement* elH = new TGeoElement("Hydrogen", "H", z = 1, a = 1.01);
69 TGeoElement* elN = new TGeoElement("Nitrogen", "N", z = 7., a = 14.01);
70 TGeoElement* elO = new TGeoElement("Oxygen", "O", z = 8., a = 16.00);
71
72 // Materials
73
74 TGeoMixture* matAir = new TGeoMixture("Air", 2, density = 1.29e-03);
75 matAir->AddElement(elN, 0.7);
76 matAir->AddElement(elO, 0.3);
77
78 TGeoMixture* matH2O = new TGeoMixture("Water", 2, density = 1.000);
79 matH2O->AddElement(elH, 2);
80 matH2O->AddElement(elO, 1);
81
82 // Tracking media
83
84 Double_t param[20];
85 param[0] = 0; // isvol - Not used
86 param[1] = 2; // ifield - User defined magnetic field
87 param[2] = 10.; // fieldm - Maximum field value (in kiloGauss)
88 param[3] = -20.; // tmaxfd - Maximum angle due to field deflection
89 param[4] = -0.01; // stemax - Maximum displacement for multiple scat
90 param[5] = -.3; // deemax - Maximum fractional energy loss, DLS
91 param[6] = .001; // epsil - Tracking precision
92 param[7] = -.8; // stmin
93 for (Int_t i = 8; i < 20; ++i) param[i] = 0.;
94
95 fImedAir = 1;
96 new TGeoMedium("Air", fImedAir, matAir, param);
97
98 fImedWater = 2;
99 new TGeoMedium("Water", fImedWater, matH2O, param);
100}
101
102//_____________________________________________________________________________
104{
105 /// Contruct volumes using TGeo modeller
106
107 // The world
108 //
109 Double_t* ubuf = 0;
110
111 Double_t world[3];
112 world[0] = fWorldSize;
113 world[1] = fWorldSize;
114 world[2] = fWorldSize;
115 TGeoVolume* worldV = gGeoManager->Volume("WRLD", "BOX", fImedAir, world, 3);
116 gGeoManager->SetTopVolume(worldV);
117
118 // The experimental Hall
119 //
120 Double_t expHall[3];
121 expHall[0] = fExpHallSize;
122 expHall[1] = fExpHallSize;
123 expHall[2] = fExpHallSize;
124 gGeoManager->Volume("EXPH", "BOX", fImedAir, expHall, 3);
125
126 Double_t posX = 0.;
127 Double_t posY = 0.;
128 Double_t posZ = 0.;
129 gGeoManager->Node("EXPH", 1, "WRLD", posX, posY, posZ, 0, kTRUE, ubuf);
130
131 // The Water Tank
132 //
133 Double_t waterTank[3];
134 waterTank[0] = fTankSize;
135 waterTank[1] = fTankSize;
136 waterTank[2] = fTankSize;
137 gGeoManager->Volume("TANK", "BOX", fImedWater, waterTank, 3);
138 gGeoManager->Node("TANK", 1, "EXPH", posX, posY, posZ, 0, kTRUE, ubuf);
139
140 // The Air Bubble
141 //
142 Double_t bubbleAir[3];
143 bubbleAir[0] = fBubbleSize;
144 bubbleAir[1] = fBubbleSize;
145 bubbleAir[2] = fBubbleSize;
146 gGeoManager->Volume("BUBL", "BOX", fImedAir, bubbleAir, 3);
147
148 posX = 0.;
149 posY = 250.;
150 posZ = 0.;
151 gGeoManager->Node("BUBL", 1, "TANK", posX, posY, posZ, 0, kTRUE, ubuf);
152
153 // close geometry
154 gGeoManager->CloseGeometry();
155
156 // notify VMC about Root geometry
157 gMC->SetRootGeometry();
158}
159
160//_____________________________________________________________________________
162{
163 /// Define material optical properties
164
165 // ------------ Generate & Add Material Properties Table ------------
166 //
167
168 fImedAir = gMC->MediumId("Air");
169 fImedWater = gMC->MediumId("Water");
170
171 const Int_t nEntries = 32;
172 Bool_t spline = true;
173 Bool_t noSpline = false;
174
175 // clang-format off
176
177 Double_t photonEnergy[nEntries] = {
178 2.034e-09, 2.068e-09, 2.103e-09, 2.139e-09, 2.177e-09, 2.216e-09,
179 2.256e-09, 2.298e-09, 2.341e-09, 2.386e-09, 2.433e-09, 2.481e-09,
180 2.532e-09, 2.585e-09, 2.640e-09, 2.697e-09, 2.757e-09, 2.820e-09,
181 2.885e-09, 2.954e-09, 3.026e-09, 3.102e-09, 3.181e-09, 3.265e-09,
182 3.353e-09, 3.446e-09, 3.545e-09, 3.649e-09, 3.760e-09, 3.877e-09,
183 4.002e-09, 4.136e-09};
184
185 // Water
186 Double_t refractiveIndex1[nEntries] = {
187 1.3435, 1.344, 1.3445, 1.345, 1.3455, 1.346, 1.3465, 1.347,
188 1.3475, 1.348, 1.3485, 1.3492, 1.35, 1.3505, 1.351, 1.3518,
189 1.3522, 1.3530, 1.3535, 1.354, 1.3545, 1.355, 1.3555, 1.356,
190 1.3568, 1.3572, 1.358, 1.3585, 1.359, 1.3595, 1.36, 1.3608};
191
192 Double_t absorption1[nEntries] = {
193 3.448e02, 4.082e02, 6.329e02, 9.174e02, 12.346e02, 13.889e02,
194 15.152e02, 17.241e02, 18.868e02, 20.000e02, 26.316e02, 35.714e02,
195 45.455e02, 47.619e02, 52.632e02, 52.632e02, 55.556e02, 52.632e02,
196 52.632e02, 47.619e02, 45.455e02, 41.667e02, 37.037e02, 33.333e02,
197 30.000e02, 28.500e02, 27.000e02, 24.500e02, 22.000e02, 19.500e02,
198 17.500e02, 14.500e02};
199
200 // Added (for Geant3)
201 Double_t efficiency1[nEntries] = { 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
202 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
203 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00,
204 0.00 };
205
206 gMC->SetCerenkov(fImedWater, nEntries, photonEnergy, absorption1, efficiency1,
207 refractiveIndex1, spline, noSpline);
208
209 Double_t scintilFast[2] = { 1.00, 1.00,};
210 Double_t energyArray[2] = { 2.034e-09, 4.136e-09 };
211 Int_t lenArray = 2;
212
213 Double_t scintilSlow[nEntries] = {
214 0.01, 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00, 8.00, 9.00, 8.00,
215 7.00, 6.00, 4.00, 3.00, 2.00, 1.00, 0.01, 1.00, 2.00, 3.00, 4.00,
216 5.00, 6.00, 7.00, 8.00, 9.00, 8.00, 7.00, 6.00, 5.00, 4.00};
217
218 gMC->SetMaterialProperty(
219 fImedWater, "SCINTILLATIONCOMPONENT1", lenArray, energyArray, scintilFast,
220 false, spline);
221 gMC->SetMaterialProperty(
222 fImedWater, "SCINTILLATIONCOMPONENT2", nEntries, photonEnergy, scintilSlow,
223 false, spline);
224
225 gMC->SetMaterialProperty(fImedWater, "SCINTILLATIONYIELD", 50.e03); // 50./MeV
226 gMC->SetMaterialProperty(fImedWater, "RESOLUTIONSCALE", 1.0);
227 gMC->SetMaterialProperty(fImedWater, "SCINTILLATIONTIMECONSTANT1", 1.0e-09); // 1.*ns
228 gMC->SetMaterialProperty(fImedWater, "SCINTILLATIONTIMECONSTANT2", 10.0e-09); // 10.*ns
229 gMC->SetMaterialProperty(fImedWater, "SCINTILLATIONYIELD1", 0.8);
230 gMC->SetMaterialProperty(fImedWater, "SCINTILLATIONYIELD2", 0.2);
231
232 const Int_t nEntriesWater = 60;
233
234 Double_t energyWater[nEntriesWater] = {
235 1.56962e-09, 1.58974e-09, 1.61039e-09, 1.63157e-09, 1.65333e-09,
236 1.67567e-09, 1.69863e-09, 1.72222e-09, 1.74647e-09, 1.77142e-09,
237 1.7971e-09, 1.82352e-09, 1.85074e-09, 1.87878e-09, 1.90769e-09,
238 1.93749e-09, 1.96825e-09, 1.99999e-09, 2.03278e-09, 2.06666e-09,
239 2.10169e-09, 2.13793e-09, 2.17543e-09, 2.21428e-09, 2.25454e-09,
240 2.29629e-09, 2.33962e-09, 2.38461e-09, 2.43137e-09, 2.47999e-09,
241 2.53061e-09, 2.58333e-09, 2.63829e-09, 2.69565e-09, 2.75555e-09,
242 2.81817e-09, 2.88371e-09, 2.95237e-09, 3.02438e-09, 3.09999e-09,
243 3.17948e-09, 3.26315e-09, 3.35134e-09, 3.44444e-09, 3.54285e-09,
244 3.64705e-09, 3.75757e-09, 3.87499e-09, 3.99999e-09, 4.13332e-09,
245 4.27585e-09, 4.42856e-09, 4.59258e-09, 4.76922e-09, 4.95999e-09,
246 5.16665e-09, 5.39129e-09, 5.63635e-09, 5.90475e-09, 6.19998e-09};
247
248 // assume 100 times larger than the rayleigh scattering for now.
249 Double_t mieWater[nEntriesWater] = {
250 167024.4e02, 158726.7e02, 150742e02, 143062.5e02, 135680.2e02,
251 128587.4e02, 121776.3e02, 115239.5e02, 108969.5e02, 102958.8e02,
252 97200.35e02, 91686.86e02, 86411.33e02, 81366.79e02, 76546.42e02,
253 71943.46e02, 67551.29e02, 63363.36e02, 59373.25e02, 55574.61e02,
254 51961.24e02, 48527.00e02, 45265.87e02, 42171.94e02, 39239.39e02,
255 36462.50e02, 33835.68e02, 31353.41e02, 29010.30e02, 26801.03e02,
256 24720.42e02, 22763.36e02, 20924.88e02, 19200.07e02, 17584.16e02,
257 16072.45e02, 14660.38e02, 13343.46e02, 12117.33e02, 10977.70e02,
258 9920.416e02, 8941.407e02, 8036.711e02, 7202.470e02, 6434.927e02,
259 5730.429e02, 5085.425e02, 4496.467e02, 3960.210e02, 3473.413e02,
260 3032.937e02, 2635.746e02, 2278.907e02, 1959.588e02, 1675.064e02,
261 1422.710e02, 1200.004e02, 1004.528e02, 833.9666e02, 686.1063e02};
262
263 // gforward, gbackward, forward backward ratio
264 Double_t mieWaterConst[3] = { 0.99, 0.99, 0.8 };
265
266 gMC->SetMaterialProperty(
267 fImedWater, "MIEHG", nEntriesWater, energyWater, mieWater, false, true);
268 gMC->SetMaterialProperty(fImedWater, "MIEHG_FORWARD", mieWaterConst[0]);
269 gMC->SetMaterialProperty(fImedWater, "MIEHG_BACKWARD", mieWaterConst[1]);
270 gMC->SetMaterialProperty(fImedWater, "MIEHG_FORWARD_RATIO", mieWaterConst[2]);
271
272 // Set the Birks Constant for the Water scintillator
273 gMC->SetMaterialProperty(
274 fImedWater, "BIRKS_CONSTANT", 0.126e+02); // 0.126*mm/MeV
275
276 // Air
277
278 Double_t refractiveIndex2[nEntries] = {
279 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
280 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
281 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
282 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
283 1.0, 1.0, 1.0, 1.0};
284
285 gMC->SetMaterialProperty(
286 fImedAir, "RINDEX", nEntries, photonEnergy, refractiveIndex2);
287
288 // ------------- Surfaces --------------
289 //
290 // Water Tank
291 //
292 gMC->DefineOpSurface(
293 "WaterSurface", kDAVIS, kDielectric_LUTDAVIS, kRough_LUT, 1.0);
294 // gMC->DefineOpSurface(
295 // "WaterSurface", kUnified, kDielectric_dielectric, kGround, 1.0);
296 gMC->SetBorderSurface("WaterSurface", "TANK", 1, "EXPH", 1, "WaterSurface");
297 // the world copyNo is in VMC always 1
298
299 // Air Bubble
300 //
301 gMC->DefineOpSurface(
302 "AirSurface", kGlisur, kDielectric_dielectric, kPolished, 1.0);
303 gMC->SetSkinSurface("AirSurface", "BUBL", "AirSurface");
304
305 //
306 // Generate & Add Material Properties Table attached to the optical surfaces
307 //
308 const Int_t num = 2;
309 Double_t ephoton[num] = { 2.034e-09, 4.136e-09 };
310 // OpticalAirSurface
311 Double_t reflectivity[num] = { 0.3, 0.5 };
312 Double_t efficiency[num] = { 0.8, 1.0 };
313 gMC->SetMaterialProperty(
314 "AirSurface", "REFLECTIVITY", num, ephoton, reflectivity);
315 gMC->SetMaterialProperty(
316 "AirSurface", "EFFICIENCY", num, ephoton, efficiency);
317}
Definition of the Ex06DetectorConstruction class.
The detector construction (via TGeo )
Int_t fImedAir
The Air medium Id.
Double_t fExpHallSize
The experimental hall size.
Int_t fImedWater
The Water medium Id.
Double_t fWorldSize
The world size.
Double_t fTankSize
The tank size.
Double_t fBubbleSize
The bubble size.