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] [ 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 ]

Diff markup

Differences between /examples/basic/B1/src/DetectorConstruction.cc (Version 11.3.0) and /examples/basic/B1/src/DetectorConstruction.cc (Version 11.1.2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 /// \file B1/src/DetectorConstruction.cc           27 /// \file B1/src/DetectorConstruction.cc
 28 /// \brief Implementation of the B1::DetectorC     28 /// \brief Implementation of the B1::DetectorConstruction class
 29                                                    29 
 30 #include "DetectorConstruction.hh"                 30 #include "DetectorConstruction.hh"
 31                                                    31 
                                                   >>  32 #include "G4RunManager.hh"
                                                   >>  33 #include "G4NistManager.hh"
 32 #include "G4Box.hh"                                34 #include "G4Box.hh"
 33 #include "G4Cons.hh"                               35 #include "G4Cons.hh"
                                                   >>  36 #include "G4Orb.hh"
                                                   >>  37 #include "G4Sphere.hh"
                                                   >>  38 #include "G4Trd.hh"
 34 #include "G4LogicalVolume.hh"                      39 #include "G4LogicalVolume.hh"
 35 #include "G4NistManager.hh"                    << 
 36 #include "G4PVPlacement.hh"                        40 #include "G4PVPlacement.hh"
 37 #include "G4SystemOfUnits.hh"                      41 #include "G4SystemOfUnits.hh"
 38 #include "G4Trd.hh"                            << 
 39                                                    42 
 40 namespace B1                                       43 namespace B1
 41 {                                                  44 {
 42                                                    45 
 43 //....oooOO0OOooo........oooOO0OOooo........oo     46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 44                                                    47 
 45 G4VPhysicalVolume* DetectorConstruction::Const     48 G4VPhysicalVolume* DetectorConstruction::Construct()
 46 {                                                  49 {
 47   // Get nist material manager                     50   // Get nist material manager
 48   G4NistManager* nist = G4NistManager::Instanc     51   G4NistManager* nist = G4NistManager::Instance();
 49                                                    52 
 50   // Envelope parameters                           53   // Envelope parameters
 51   //                                               54   //
 52   G4double env_sizeXY = 20 * cm, env_sizeZ = 3 <<  55   G4double env_sizeXY = 20*cm, env_sizeZ = 30*cm;
 53   G4Material* env_mat = nist->FindOrBuildMater     56   G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
 54                                                    57 
 55   // Option to switch on/off checking of volum     58   // Option to switch on/off checking of volumes overlaps
 56   //                                               59   //
 57   G4bool checkOverlaps = true;                     60   G4bool checkOverlaps = true;
 58                                                    61 
 59   //                                               62   //
 60   // World                                         63   // World
 61   //                                               64   //
 62   G4double world_sizeXY = 1.2 * env_sizeXY;    <<  65   G4double world_sizeXY = 1.2*env_sizeXY;
 63   G4double world_sizeZ = 1.2 * env_sizeZ;      <<  66   G4double world_sizeZ  = 1.2*env_sizeZ;
 64   G4Material* world_mat = nist->FindOrBuildMat     67   G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
 65                                                    68 
 66   auto solidWorld =                            <<  69   auto solidWorld = new G4Box("World",                           // its name
 67     new G4Box("World",  // its name            <<  70     0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ);  // its size
 68               0.5 * world_sizeXY, 0.5 * world_ << 
 69                                                    71 
 70   auto logicWorld = new G4LogicalVolume(solidW     72   auto logicWorld = new G4LogicalVolume(solidWorld,  // its solid
 71                                         world_ <<  73     world_mat,                                       // its material
 72                                         "World <<  74     "World");                                        // its name
 73                                                    75 
 74   auto physWorld = new G4PVPlacement(nullptr,      76   auto physWorld = new G4PVPlacement(nullptr,  // no rotation
 75                                      G4ThreeVe <<  77     G4ThreeVector(),                           // at (0,0,0)
 76                                      logicWorl <<  78     logicWorld,                                // its logical volume
 77                                      "World",  <<  79     "World",                                   // its name
 78                                      nullptr,  <<  80     nullptr,                                   // its mother  volume
 79                                      false,  / <<  81     false,                                     // no boolean operation
 80                                      0,  // co <<  82     0,                                         // copy number
 81                                      checkOver <<  83     checkOverlaps);                            // overlaps checking
 82                                                    84 
 83   //                                               85   //
 84   // Envelope                                      86   // Envelope
 85   //                                               87   //
 86   auto solidEnv = new G4Box("Envelope",  // it <<  88   auto solidEnv = new G4Box("Envelope",                    // its name
 87                             0.5 * env_sizeXY,  <<  89     0.5 * env_sizeXY, 0.5 * env_sizeXY, 0.5 * env_sizeZ);  // its size
 88                                                    90 
 89   auto logicEnv = new G4LogicalVolume(solidEnv     91   auto logicEnv = new G4LogicalVolume(solidEnv,  // its solid
 90                                       env_mat, <<  92     env_mat,                                     // its material
 91                                       "Envelop <<  93     "Envelope");                                 // its name
 92                                                    94 
 93   new G4PVPlacement(nullptr,  // no rotation       95   new G4PVPlacement(nullptr,  // no rotation
 94                     G4ThreeVector(),  // at (0 <<  96     G4ThreeVector(),          // at (0,0,0)
 95                     logicEnv,  // its logical  <<  97     logicEnv,                 // its logical volume
 96                     "Envelope",  // its name   <<  98     "Envelope",               // its name
 97                     logicWorld,  // its mother <<  99     logicWorld,               // its mother  volume
 98                     false,  // no boolean oper << 100     false,                    // no boolean operation
 99                     0,  // copy number         << 101     0,                        // copy number
100                     checkOverlaps);  // overla << 102     checkOverlaps);           // overlaps checking
101                                                   103 
102   //                                              104   //
103   // Shape 1                                      105   // Shape 1
104   //                                              106   //
105   G4Material* shape1_mat = nist->FindOrBuildMa    107   G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE");
106   G4ThreeVector pos1 = G4ThreeVector(0, 2 * cm << 108   G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm);
107                                                   109 
108   // Conical section shape                        110   // Conical section shape
109   G4double shape1_rmina = 0. * cm, shape1_rmax << 111   G4double shape1_rmina =  0.*cm, shape1_rmaxa = 2.*cm;
110   G4double shape1_rminb = 0. * cm, shape1_rmax << 112   G4double shape1_rminb =  0.*cm, shape1_rmaxb = 4.*cm;
111   G4double shape1_hz = 3. * cm;                << 113   G4double shape1_hz = 3.*cm;
112   G4double shape1_phimin = 0. * deg, shape1_ph << 114   G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
113   auto solidShape1 = new G4Cons("Shape1", shap    115   auto solidShape1 = new G4Cons("Shape1", shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb,
114                                 shape1_hz, sha << 116     shape1_hz, shape1_phimin, shape1_phimax);
115                                                   117 
116   auto logicShape1 = new G4LogicalVolume(solid    118   auto logicShape1 = new G4LogicalVolume(solidShape1,  // its solid
117                                          shape << 119     shape1_mat,                                        // its material
118                                          "Shap << 120     "Shape1");                                         // its name
119                                                   121 
120   new G4PVPlacement(nullptr,  // no rotation      122   new G4PVPlacement(nullptr,  // no rotation
121                     pos1,  // at position      << 123     pos1,                     // at position
122                     logicShape1,  // its logic << 124     logicShape1,              // its logical volume
123                     "Shape1",  // its name     << 125     "Shape1",                 // its name
124                     logicEnv,  // its mother   << 126     logicEnv,                 // its mother  volume
125                     false,  // no boolean oper << 127     false,                    // no boolean operation
126                     0,  // copy number         << 128     0,                        // copy number
127                     checkOverlaps);  // overla << 129     checkOverlaps);           // overlaps checking
128                                                   130 
129   //                                              131   //
130   // Shape 2                                      132   // Shape 2
131   //                                              133   //
132   G4Material* shape2_mat = nist->FindOrBuildMa    134   G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU");
133   G4ThreeVector pos2 = G4ThreeVector(0, -1 * c << 135   G4ThreeVector pos2 = G4ThreeVector(0, -1*cm, 7*cm);
134                                                   136 
135   // Trapezoid shape                              137   // Trapezoid shape
136   G4double shape2_dxa = 12 * cm, shape2_dxb =  << 138   G4double shape2_dxa = 12*cm, shape2_dxb = 12*cm;
137   G4double shape2_dya = 10 * cm, shape2_dyb =  << 139   G4double shape2_dya = 10*cm, shape2_dyb = 16*cm;
138   G4double shape2_dz = 6 * cm;                 << 140   G4double shape2_dz  = 6*cm;
139   auto solidShape2 =                           << 141   auto solidShape2 = new G4Trd("Shape2",  // its name
140     new G4Trd("Shape2",  // its name           << 142     0.5 * shape2_dxa, 0.5 * shape2_dxb, 0.5 * shape2_dya, 0.5 * shape2_dyb,
141               0.5 * shape2_dxa, 0.5 * shape2_d << 143     0.5 * shape2_dz);  // its size
142               0.5 * shape2_dz);  // its size   << 
143                                                   144 
144   auto logicShape2 = new G4LogicalVolume(solid    145   auto logicShape2 = new G4LogicalVolume(solidShape2,  // its solid
145                                          shape << 146     shape2_mat,                                        // its material
146                                          "Shap << 147     "Shape2");                                         // its name
147                                                   148 
148   new G4PVPlacement(nullptr,  // no rotation      149   new G4PVPlacement(nullptr,  // no rotation
149                     pos2,  // at position      << 150     pos2,                     // at position
150                     logicShape2,  // its logic << 151     logicShape2,              // its logical volume
151                     "Shape2",  // its name     << 152     "Shape2",                 // its name
152                     logicEnv,  // its mother   << 153     logicEnv,                 // its mother  volume
153                     false,  // no boolean oper << 154     false,                    // no boolean operation
154                     0,  // copy number         << 155     0,                        // copy number
155                     checkOverlaps);  // overla << 156     checkOverlaps);           // overlaps checking
156                                                   157 
157   // Set Shape2 as scoring volume                 158   // Set Shape2 as scoring volume
158   //                                              159   //
159   fScoringVolume = logicShape2;                   160   fScoringVolume = logicShape2;
160                                                   161 
161   //                                              162   //
162   // always return the physical World          << 163   //always return the physical World
163   //                                              164   //
164   return physWorld;                               165   return physWorld;
165 }                                                 166 }
166                                                   167 
167 //....oooOO0OOooo........oooOO0OOooo........oo    168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168                                                   169 
169 }  // namespace B1                             << 170 }
170                                                   171