Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:09:02

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 //
0027 /// @file DetectorConstruction.hh
0028 /// @brief Define geometry
0029 
0030 #include "DetectorConstruction.hh"
0031 
0032 #include "VoxelParam.hh"
0033 #include "VoxelSD.hh"
0034 
0035 #include "G4Box.hh"
0036 #include "G4LogicalVolume.hh"
0037 #include "G4NistManager.hh"
0038 #include "G4PVParameterised.hh"
0039 #include "G4PVPlacement.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "G4VisAttributes.hh"
0042 
0043 typedef G4LogicalVolume G4LV;
0044 typedef G4PVPlacement G4PVP;
0045 typedef G4VisAttributes G4VA;
0046 
0047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0048 DetectorConstruction::DetectorConstruction() : flv_voxel(NULL) {}
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 DetectorConstruction::~DetectorConstruction() {}
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0054 G4VPhysicalVolume* DetectorConstruction::Construct()
0055 {
0056   G4NistManager* nistManager = G4NistManager::Instance();
0057   G4VisAttributes* va;
0058 
0059   // world volume
0060   const G4double DXYZ_WORLD = 200. * cm;
0061   G4Box* sld_world = new G4Box("world", DXYZ_WORLD / 2., DXYZ_WORLD / 2., DXYZ_WORLD / 2.);
0062 
0063   G4Material* vacuum = nistManager->FindOrBuildMaterial("G4_Galactic");
0064   G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
0065   G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA", lv_world, 0, false, 0);
0066   // vis. attributes
0067   va = new G4VA(G4Color(1., 1., 1.));
0068   va->SetVisibility(false);
0069   lv_world->SetVisAttributes(va);
0070 
0071   // water phantom
0072   const G4double DXY_PHANTOM = 20. * cm;
0073   const G4double DZ_PHANTOM = 50. * cm;
0074 
0075   G4Box* sld_phantom = new G4Box("phantom", DXY_PHANTOM / 2., DXY_PHANTOM / 2., DZ_PHANTOM / 2.);
0076 
0077   G4Material* water = nistManager->FindOrBuildMaterial("G4_WATER");
0078   G4LV* lv_phantom = new G4LogicalVolume(sld_phantom, water, "phantom");
0079 
0080   va = new G4VA(G4Color(0., 1., 1.));
0081   lv_phantom->SetVisAttributes(va);
0082 
0083   new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
0084 
0085   // voxel planes
0086   const G4double DXY_VXP = 20. * cm;
0087   const G4double DZ_VXP = 1. * mm;
0088 
0089   G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP / 2., DXY_VXP / 2., DZ_VXP / 2.);
0090   G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
0091 
0092   va = new G4VA(G4Color(1., 0., 0.));
0093   va->SetVisibility(false);
0094   lv_vxp->SetVisAttributes(va);
0095 
0096   for (G4int iz = 0; iz < 500; iz++) {
0097     G4double z0 = -DZ_PHANTOM / 2. + (iz + 0.5) * DZ_VXP;
0098     new G4PVP(0, G4ThreeVector(0., 0., z0), lv_vxp, "vxplane", lv_phantom, false, 1000 + iz);
0099   }
0100 
0101   // voxel parameterized
0102   G4Box* sld_voxel = new G4Box("voxel", 1., 1., 1.);  // dummy
0103   flv_voxel = new G4LV(sld_voxel, water, "voxel");
0104 
0105   va = new G4VA(G4Color(0., 1., 1.));
0106   va->SetVisibility(false);
0107   flv_voxel->SetVisAttributes(va);
0108 
0109   const G4int nvoxels = 100 * 100;
0110   new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels, new VoxelParam());
0111 
0112   return world;
0113 }
0114 
0115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0116 void DetectorConstruction::ConstructSDandField()
0117 {
0118   flv_voxel->SetSensitiveDetector(new VoxelSD("voxel"));
0119 }