Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-16 08:30:50

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file DetectorConstruction.cc
0027 /// \brief Implementation of the VtkVis::DetectorConstruction class
0028 
0029 #include "DetectorConstruction.hh"
0030 
0031 #include "G4Box.hh"
0032 #include "G4LogicalVolume.hh"
0033 #include "G4NistManager.hh"
0034 #include "G4PVPlacement.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4SubtractionSolid.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4Tubs.hh"
0039 
0040 #include <cmath>
0041 
0042 namespace VtkVis
0043 {
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 G4VPhysicalVolume* DetectorConstruction::Construct()
0048 {
0049   // Get nist material manager
0050   G4NistManager* nist = G4NistManager::Instance();
0051 
0052   // Envelope parameters
0053   //
0054   G4double env_sizeXY = 10 * m, env_sizeZ = 10 * m;
0055   G4Material* env_mat = nist->FindOrBuildMaterial("G4_Galactic");
0056 
0057   // Option to switch on/off checking of volumes overlaps
0058   //
0059   G4bool checkOverlaps = true;
0060 
0061   //
0062   // World
0063   //
0064   G4double world_sizeXY = 1.2 * env_sizeXY;
0065   G4double world_sizeZ = 1.2 * env_sizeZ;
0066   G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
0067 
0068   auto solidWorld =
0069     new G4Box("World",  // its name
0070               0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ);  // its size
0071 
0072   auto logicWorld = new G4LogicalVolume(solidWorld,  // its solid
0073                                         world_mat,  // its material
0074                                         "World");  // its name
0075 
0076   auto physWorld = new G4PVPlacement(nullptr,  // no rotation
0077                                      G4ThreeVector(),  // at (0,0,0)
0078                                      logicWorld,  // its logical volume
0079                                      "World",  // its name
0080                                      nullptr,  // its mother  volume
0081                                      false,  // no boolean operation
0082                                      0,  // copy number
0083                                      checkOverlaps);  // overlaps checking
0084 
0085   //
0086   // Envelope
0087   //
0088   auto solidEnv = new G4Box("Envelope",  // its name
0089                             0.5 * env_sizeXY, 0.5 * env_sizeXY, 0.5 * env_sizeZ);  // its size
0090 
0091   auto logicEnv = new G4LogicalVolume(solidEnv,  // its solid
0092                                       env_mat,  // its material
0093                                       "Envelope");  // its name
0094 
0095   new G4PVPlacement(nullptr,  // no rotation
0096                     G4ThreeVector(),  // at (0,0,0)
0097                     logicEnv,  // its logical volume
0098                     "Envelope",  // its name
0099                     logicWorld,  // its mother  volume
0100                     false,  // no boolean operation
0101                     0,  // copy number
0102                     checkOverlaps);  // overlaps checking
0103 
0104   auto dumpPos = G4ThreeVector(0, 0, 0);
0105   auto dumpMat = nist->FindOrBuildMaterial("G4_CONCRETE");
0106   auto dumpShape1 = new G4Box("dumpShape1", 1 * m, 1 * m, 0.5 * m);
0107 
0108   auto dumpCutoutPos = G4ThreeVector(0, 0, -5.1 * cm);
0109   auto dumpCutoutShape = new G4Tubs("DumpCutoutShape", 0 * cm, 10 * cm, 90 / 2 * cm, 0, 2 * M_PI);
0110 
0111   auto dumpShape2 =
0112     new G4SubtractionSolid("dumpShape2", dumpShape1, dumpCutoutShape, 0, dumpCutoutPos);
0113 
0114   auto dumpLogical = new G4LogicalVolume(dumpShape2,
0115                                          dumpMat,  // its material
0116                                          "dump");
0117   // its name
0118   new G4PVPlacement(nullptr,  // no rotation
0119                     dumpPos,  // at position
0120                     dumpLogical,  // its logical volume
0121                     "dump",  // its name
0122                     logicEnv,  // its mother  volume
0123                     false,  // no boolean operation
0124                     0,  // copy number
0125                     checkOverlaps);  // overlaps checking
0126 
0127   fScoringVolume = dumpLogical;
0128 
0129   //
0130   // always return the physical World
0131   //
0132   return physWorld;
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0136 
0137 }  // namespace VtkVis