VMC Examples Version 6.6
Loading...
Searching...
No Matches
Ex03DetectorConstructionOld.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Virtual Monte Carlo examples
3// Copyright (C) 2014 - 2018 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 Ex03DetectorConstructionOld.cxx
11/// \brief Implementation of the Ex03DetectorConstructionOld class
12///
13/// Geant4 ExampleN03 adapted to Virtual Monte Carlo \n
14/// Id: ExN03DetectorConstruction.cc,v 1.11 2002/01/09 17:24:12 ranjard Exp \n
15/// GEANT4 tag $Name: $
16///
17/// 11/12/2008:
18/// Added new material (Mylar)according to:
19/// Id: ExN03DetectorConstruction.cc,v 1.24 2008/08/12 20:00:03 gum Exp
20/// GEANT4 tag Name: geant4-09-01-ref-09
21///
22/// \date 06/03/2002
23/// \author I. Hrivnacova; IPN, Orsay
24
25#include <Riostream.h>
26#include <TVirtualMC.h>
27
28#include "Ex03DetectorConstructionOld.h"
29
30using namespace std;
31
32/// \cond CLASSIMP
34 /// \endcond
35
36 //_____________________________________________________________________________
38 : TObject(),
39 fNbOfLayers(0),
40 fWorldSizeX(0.),
41 fWorldSizeYZ(0.),
42 fCalorSizeYZ(0.),
43 fCalorThickness(0.),
44 fLayerThickness(0.),
45 fAbsorberThickness(0.),
46 fGapThickness(0.),
47 fDefaultMaterial("Galactic"),
48 fAbsorberMaterial("Lead"),
49 fGapMaterial("liquidArgon")
50{
51 /// Default constuctor
52
53 // default parameter values of the calorimeter (in cm)
54 fAbsorberThickness = 1.;
55 fGapThickness = 0.5;
56 fNbOfLayers = 10;
57 fCalorSizeYZ = 10.;
58
59 ComputeCalorParameters();
60}
61
62//_____________________________________________________________________________
67
68//
69// private methods
70//
71
72//_____________________________________________________________________________
83
84//
85// public methods
86//
87
88//_____________________________________________________________________________
90{
91 /// Construct materials using VMC functions
92
93 //
94 // Tracking medias (defaut parameters)
95 //
96
97 Int_t ifield = 2; // User defined magnetic field
98 Double_t fieldm = 10.; // Maximum field value (in kiloGauss)
99 Double_t epsil = .001; // Tracking precision,
100 Double_t stemax = -0.01; // Maximum displacement for multiple scat
101 Double_t tmaxfd = -20.; // Maximum angle due to field deflection
102 Double_t deemax = -.3; // Maximum fractional energy loss, DLS
103 Double_t stmin = -.8;
104
105 // stemax = 1.0; // Maximum step limit
106
107 //--------- Material definition ---------
108
109 TString name;
110 Double_t a;
111 Double_t z;
112 Double_t density;
113 Double_t radl;
114 Double_t absl;
115 Float_t* ubuf = 0;
116
117 //
118 // define simple materials
119 //
120
121 name = "Aluminium";
122 a = 26.98;
123 z = 13.;
124 density = 2.700;
125 radl = 8.893;
126 absl = 0.1;
127 Int_t imat;
128 gMC->Material(imat, name.Data(), a, z, density, radl, absl, ubuf, 0);
129 Int_t mediumId;
130 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
131 deemax, epsil, stmin, ubuf, 0);
132
133 name = "liquidArgon";
134 a = 39.95;
135 z = 18.;
136 density = 1.390;
137 radl = 14.064;
138 absl = 0.1;
139 gMC->Material(imat, name.Data(), a, z, density, radl, absl, ubuf, 0);
140 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
141 deemax, epsil, stmin, ubuf, 0);
142
143 name = "Lead";
144 a = 207.19;
145 z = 82.;
146 density = 11.35;
147 radl = 0.5612;
148 absl = 0.1;
149 gMC->Material(imat, name.Data(), a, z, density, radl, absl, ubuf, 0);
150 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
151 deemax, epsil, stmin, ubuf, 0);
152
153 //
154 // define a material from elements. case 1: chemical molecule
155 //
156
157 name = "Water";
158 Double_t aw2[2] = { 1.01, 16.00 };
159 Double_t zw2[2] = { 1.0, 8.0 };
160 Double_t ww2[2] = { 2., 1. };
161 density = 1.000;
162 gMC->Mixture(imat, name.Data(), aw2, zw2, density, -2, ww2);
163 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
164 deemax, epsil, stmin, ubuf, 0);
165
166 name = "Scintillator";
167 Double_t as2[2] = { 1.01, 12.01 };
168 Double_t zs2[2] = { 1.0, 6.0 };
169 Double_t ws2[2] = { 10., 9. };
170 density = 1.032;
171 gMC->Mixture(imat, name.Data(), as2, zs2, density, -2, ws2);
172 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
173 deemax, epsil, stmin, ubuf, 0);
174
175 name = "Mylar";
176 Double_t am2[3] = { 12.01, 1.01, 16.00 };
177 Double_t zm2[3] = { 6.0, 1.0, 8.0 };
178 Double_t wm2[3] = { 10., 8., 4. };
179 density = 1.397;
180 gMC->Mixture(imat, name.Data(), am2, zm2, density, -3, wm2);
181 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
182 deemax, epsil, stmin, ubuf, 0);
183
184 name = "quartz";
185 Double_t aq2[2] = { 28.09, 16.00 };
186 Double_t zq2[2] = { 14.0, 8.0 };
187 Double_t wq2[2] = { 1., 2. };
188 density = 2.200;
189 gMC->Mixture(imat, name.Data(), aq2, zq2, density, -2, wq2);
190 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
191 deemax, epsil, stmin, ubuf, 0);
192
193 //
194 // define a material from elements. case 2: mixture by fractional mass
195 //
196
197 name = "Air";
198 Double_t aa2[2] = { 14.01, 16.00 };
199 Double_t za2[2] = { 7.0, 8.0 };
200 Double_t wa2[2] = { 0.7, 0.3 };
201 density = 1.29e-03;
202 gMC->Mixture(imat, name.Data(), aa2, za2, density, 2, wa2);
203 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
204 deemax, epsil, stmin, ubuf, 0);
205
206 //
207 // !! NOT SUPPORTED BY VMC
208 //
209 // define a material from elements and/or others materials (mixture of
210 // mixtures)
211 //
212 // density = 0.200*g/cm3;
213 // G4Material* Aerog = new G4Material(name="Aerogel", density, ncomponents=3);
214 // Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent);
215 // Aerog->AddMaterial(H2O , fractionmass=37.4*perCent);
216 // Aerog->AddElement (C , fractionmass= 0.1*perCent);
217
218 //
219 // !! NOT SUPPORTED BY VMC
220 //
221 // examples of gas in non STP conditions
222 //
223 //
224 // density = 27.*mg/cm3;
225 // pressure = 50.*atmosphere;
226 // temperature = 325.*kelvin;
227 // G4Material* CO2 = new G4Material(name="CarbonicGas", density,
228 // ncomponents=2,
229 // kStateGas,temperature,pressure);
230 // CO2->AddElement(C, natoms=1);
231 // CO2->AddElement(O, natoms=2);
232 //
233 //
234 // !! NOT SUPPORTED BY VMC
235 //
236 // density = 0.3*mg/cm3;
237 // pressure = 2.*atmosphere;
238 // temperature = 500.*kelvin;
239 // G4Material* steam = new G4Material(name="WaterSteam", density,
240 // ncomponents=1,
241 // kStateGas,temperature,pressure);
242 // steam->AddMaterial(H2O, fractionmass=1.);
243
244 name = "Galactic";
245 a = 1.e-16;
246 z = 1.e-16;
247 density = 1.e-16;
248 radl = 1.e16;
249 absl = 1.e16; //??
250 gMC->Material(imat, name.Data(), a, z, density, radl, absl, ubuf, 0);
251 gMC->Medium(mediumId, name.Data(), imat, 0, ifield, fieldm, tmaxfd, stemax,
252 deemax, epsil, stmin, ubuf, 0);
253}
254
255//_____________________________________________________________________________
257{
258 /// Contruct volumes using VMC functions
259
260 // Complete the Calor parameters definition
262
263 //
264 // World
265 //
266
267 Double_t world[3];
268 world[0] = fWorldSizeX / 2.;
269 world[1] = fWorldSizeYZ / 2.;
270 world[2] = fWorldSizeYZ / 2.;
271 gMC->Gsvolu("WRLD", "BOX", gMC->MediumId(fDefaultMaterial.Data()), world, 3);
272
273 //
274 // Calorimeter
275 //
276 if (fCalorThickness > 0.) {
277
278 Double_t calo[3];
279 calo[0] = fCalorThickness / 2.;
280 calo[1] = fCalorSizeYZ / 2.;
281 calo[2] = fCalorSizeYZ / 2.;
282 gMC->Gsvolu("CALO", "BOX", gMC->MediumId(fDefaultMaterial.Data()), calo, 3);
283
284 Double_t posX = 0.;
285 Double_t posY = 0.;
286 Double_t posZ = 0.;
287 gMC->Gspos("CALO", 1, "WRLD", posX, posY, posZ, 0, "ONLY");
288
289 // Divide calorimeter along X axis to place layers
290 //
291 gMC->Gsdvn("CELL", "CALO", fNbOfLayers, 1);
292
293 //
294 // Layer
295 //
296 Double_t layer[3];
297 layer[0] = fLayerThickness / 2.;
298 layer[1] = fCalorSizeYZ / 2.;
299 layer[2] = fCalorSizeYZ / 2.;
300 gMC->Gsvolu(
301 "LAYE", "BOX", gMC->MediumId(fDefaultMaterial.Data()), layer, 3);
302
303 posX = 0.;
304 posY = 0.;
305 posZ = 0.;
306 gMC->Gspos("LAYE", 1, "CELL", posX, posY, posZ, 0, "ONLY");
307 }
308
309 //
310 // Absorber
311 //
312
313 if (fAbsorberThickness > 0.) {
314
315 Double_t abso[3];
316 abso[0] = fAbsorberThickness / 2;
317 abso[1] = fCalorSizeYZ / 2.;
318 abso[2] = fCalorSizeYZ / 2.;
319 gMC->Gsvolu(
320 "ABSO", "BOX", gMC->MediumId(fAbsorberMaterial.Data()), abso, 3);
321
322 Double_t posX = -fGapThickness / 2.;
323 Double_t posY = 0.;
324 Double_t posZ = 0.;
325 gMC->Gspos("ABSO", 1, "LAYE", posX, posY, posZ, 0, "ONLY");
326 }
327
328 //
329 // Gap
330 //
331
332 if (fGapThickness > 0.) {
333
334 Double_t gap[3];
335 gap[0] = fGapThickness / 2;
336 gap[1] = fCalorSizeYZ / 2.;
337 gap[2] = fCalorSizeYZ / 2.;
338 gMC->Gsvolu("GAPX", "BOX", gMC->MediumId(fGapMaterial.Data()), gap, 3);
339
340 Double_t posX = fAbsorberThickness / 2.;
341 Double_t posY = 0.;
342 Double_t posZ = 0.;
343 gMC->Gspos("GAPX", 1, "LAYE", posX, posY, posZ, 0, "ONLY");
344 }
345
346 /*
347 //
348 // Visualization attributes
349 //
350 logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
351 G4VisAttributes* simpleBoxVisAtt= new
352 G4VisAttributes(G4Colour(1.0,1.0,1.0));
353 simpleBoxVisAtt->SetVisibility(true);
354 logicCalor->SetVisAttributes(simpleBoxVisAtt);
355 */
356
358}
359
360//_____________________________________________________________________________
362{
363 /// Print calorimeter parameters
364
365 cout << "\n------------------------------------------------------------"
366 << "\n---> The calorimeter is " << fNbOfLayers << " layers of: [ "
367 << fAbsorberThickness << "cm of " << fAbsorberMaterial << " + "
368 << fGapThickness << "cm of " << fGapMaterial << " ] "
369 << "\n------------------------------------------------------------\n";
370}
371
372//_____________________________________________________________________________
374{
375 /// Set the number of layers.
376 /// \param value The new number of calorimeter layers
377
378 fNbOfLayers = value;
379}
380
381//_____________________________________________________________________________
383 const TString& materialName)
384{
385 /// Set default material
386 /// \param materialName The new default material name.
387
388 fDefaultMaterial = materialName;
389}
390
391//_____________________________________________________________________________
393 const TString& materialName)
394{
395 /// Set absorer material
396 /// \param materialName The new absorber material name.
397
398 fAbsorberMaterial = materialName;
399}
400
401//_____________________________________________________________________________
402void Ex03DetectorConstructionOld::SetGapMaterial(const TString& materialName)
403{
404 /// Set gap material
405 /// \param materialName The new gap material name.
406
407 fGapMaterial = materialName;
408}
409
410//_____________________________________________________________________________
412{
413 /// Change the transverse size and recompute the calorimeter parameters
414 /// \param value The new calorimeter tranverse size
415
416 fCalorSizeYZ = value;
417}
418
419//_____________________________________________________________________________
421{
422 /// Change the absorber thickness and recompute the calorimeter parameters
423 /// \param value The new absorber thickness
424
425 fAbsorberThickness = value;
426}
427
428//_____________________________________________________________________________
430{
431 /// Change the gap thickness and recompute the calorimeter parameters
432 /// \param value The new gap thickness
433
434 fGapThickness = value;
435}
436
437/*
438//_____________________________________________________________________________
439void Ex03DetectorConstructionOld::UpdateGeometry()
440{
441// Not available in VMC
442}
443*/
The old detector construction (via VMC functions)
Int_t fNbOfLayers
The number of calorimeter layers.
TString fGapMaterial
The gap material name.
Double_t fWorldSizeYZ
The world size y,z component.
Double_t fCalorSizeYZ
The calorimeter size y,z component.
TString fDefaultMaterial
The default material name.
void SetGapMaterial(const TString &materialName)
TString fAbsorberMaterial
The absorber material name.
void SetAbsorberMaterial(const TString &materialName)
Double_t fWorldSizeX
The world size x component.
Double_t fAbsorberThickness
The absorber thickness.
Double_t fCalorThickness
The calorimeter thickness.
void SetDefaultMaterial(const TString &materialName)
Double_t fLayerThickness
The calorimeter layer thickness.
Double_t fGapThickness
The gap thickness.