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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 //
  2 // ********************************************************************
  3 // * License and Disclaimer                                           *
  4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.                             *
 10 // *                                                                  *
 11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                                                  *
 18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // ********************************************************************
 25 //
 26 /// \file MoviesDetectorConstruction.cc
 27 /// \brief Implementation of the MoviesDetectorConstruction class
 28 //
 29 
 30 #include "MoviesDetectorConstruction.hh"
 31 
 32 #include "G4Box.hh"
 33 #include "G4LogicalVolume.hh"
 34 #include "G4Material.hh"
 35 #include "G4NistManager.hh"
 36 #include "G4PVPlacement.hh"
 37 #include "G4PVReplica.hh"
 38 #include "G4PhysicalConstants.hh"
 39 #include "G4SystemOfUnits.hh"
 40 #include "G4VisAttributes.hh"
 41 
 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 43 
 44 G4VPhysicalVolume* MoviesDetectorConstruction::Construct()
 45 {
 46   // Define materials
 47   DefineMaterials();
 48 
 49   // Define volumes
 50   return DefineVolumes();
 51 }
 52 
 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 54 
 55 void MoviesDetectorConstruction::DefineMaterials()
 56 {
 57   auto nistManager = G4NistManager::Instance();
 58 
 59   // Lead material defined using NIST Manager
 60   nistManager->FindOrBuildMaterial("G4_Pb");
 61 
 62   // Liquid argon material
 63   G4double a;  // mass of a mole;
 64   G4double z;  // z=mean number of protons;
 65   G4double density;
 66   new G4Material("liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
 67   // The argon by NIST Manager is a gas with a different density
 68 
 69   // Vacuum
 70   nistManager->FindOrBuildMaterial("G4_Galactic");
 71 
 72   // Print materials
 73   G4cout << *(G4Material::GetMaterialTable()) << G4endl;
 74 }
 75 
 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 77 
 78 G4VPhysicalVolume* MoviesDetectorConstruction::DefineVolumes()
 79 {
 80   // Geometry parameters
 81   const G4bool checkOverlaps = true;
 82 
 83   // A generous world
 84   const G4double worldSizeXY = 1. * m;
 85   const G4double worldSizeZ = 1. * m;
 86 
 87   // Lead-argon calorimeter
 88   G4int nofLayers = 10;
 89   G4double absoThickness = 10. * mm;
 90   G4double gapThickness = 5. * mm;
 91   G4double calorSizeXY = 10. * cm;
 92 
 93   auto layerThickness = absoThickness + gapThickness;
 94   auto calorThickness = nofLayers * layerThickness;
 95 
 96   // Get materials
 97   auto defaultMaterial = G4Material::GetMaterial("G4_Galactic");
 98   auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
 99   auto gapMaterial = G4Material::GetMaterial("liquidArgon");
100 
101   // World
102   auto worldS = new G4Box("World", worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2);
103 
104   auto worldLV = new G4LogicalVolume(worldS,  // its solid
105                                      defaultMaterial,  // its material
106                                      "World");  // its name
107 
108   auto worldPV = new G4PVPlacement(0,  // no rotation
109                                    G4ThreeVector(),  // at (0,0,0)
110                                    worldLV,  // its logical volume
111                                    "World",  // its name
112                                    0,  // its mother  volume
113                                    false,  // no boolean operation
114                                    0,  // copy number
115                                    checkOverlaps);  // checking overlaps
116 
117   // Calorimeter
118 
119   auto calorimeterS =
120     new G4Box("Calorimeter", calorSizeXY / 2, calorSizeXY / 2, calorThickness / 2);
121 
122   auto calorLV = new G4LogicalVolume(calorimeterS,  // its solid
123                                      defaultMaterial,  // its material
124                                      "Calorimeter");  // its name
125 
126   new G4PVPlacement(0,  // no rotation
127                     G4ThreeVector(),  // at (0,0,0)
128                     calorLV,  // its logical volume
129                     "Calorimeter",  // its name
130                     worldLV,  // its mother  volume
131                     false,  // no boolean operation
132                     0,  // copy number
133                     checkOverlaps);  // checking overlaps
134 
135   // Layer
136 
137   auto layerS = new G4Box("Layer",  // its name
138                           calorSizeXY / 2, calorSizeXY / 2, layerThickness / 2);  // its size
139 
140   auto layerLV = new G4LogicalVolume(layerS,  // its solid
141                                      defaultMaterial,  // its material
142                                      "Layer");  // its name
143 
144   new G4PVReplica("Layer",  // its name
145                   layerLV,  // its logical volume
146                   calorLV,  // its mother
147                   kZAxis,  // axis of replication
148                   nofLayers,  // number of replica
149                   layerThickness);  // witdth of replica
150 
151   // Absorber
152 
153   auto absorberS = new G4Box("Abso",  // its name
154                              calorSizeXY / 2, calorSizeXY / 2, absoThickness / 2);  // its size
155 
156   auto absorberLV = new G4LogicalVolume(absorberS,  // its solid
157                                         absorberMaterial,  // its material
158                                         "Abso");  // its name
159 
160   new G4PVPlacement(0,  // no rotation
161                     G4ThreeVector(0., 0., -gapThickness / 2),  // its position
162                     absorberLV,  // its logical volume
163                     "Abso",  // its name
164                     layerLV,  // its mother  volume
165                     false,  // no boolean operation
166                     0,  // copy number
167                     checkOverlaps);  // checking overlaps
168 
169   // Gap
170 
171   auto gapS = new G4Box("Gap",  // its name
172                         calorSizeXY / 2, calorSizeXY / 2, gapThickness / 2);  // its size
173 
174   auto gapLV = new G4LogicalVolume(gapS,  // its solid
175                                    gapMaterial,  // its material
176                                    "Gap");  // its name
177 
178   new G4PVPlacement(0,  // no rotation
179                     G4ThreeVector(0., 0., absoThickness / 2),  // its position
180                     gapLV,  // its logical volume
181                     "Gap",  // its name
182                     layerLV,  // its mother  volume
183                     false,  // no boolean operation
184                     0,  // copy number
185                     checkOverlaps);  // checking overlaps
186 
187   // Visualization attributes
188   worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
189 
190   return worldPV;
191 }
192