ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.cc
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 //
29 
30 #include "G4Box.hh"
31 #include "G4LogicalVolume.hh"
32 #include "G4NistManager.hh"
33 #include "G4PVParameterised.hh"
34 #include "G4PVPlacement.hh"
35 #include "G4SystemOfUnits.hh"
36 #include "G4VisAttributes.hh"
37 #include "DetectorConstruction.hh"
38 #include "VoxelParam.hh"
39 #include "VoxelSD.hh"
40 
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47  : flv_voxel(NULL)
48 {
49 }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 {
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 {
59  G4NistManager* nistManager = G4NistManager::Instance();
60  G4VisAttributes* va;
61 
62  // world volume
63  const G4double DXYZ_WORLD = 200.*cm;
64  G4Box* sld_world = new G4Box("world",
65  DXYZ_WORLD/2., DXYZ_WORLD/2., DXYZ_WORLD/2.);
66 
67  G4Material* vacuum = nistManager-> FindOrBuildMaterial("G4_Galactic");
68  G4LV* lv_world = new G4LogicalVolume(sld_world, vacuum, "world");
69  G4PVP* world = new G4PVPlacement(0, G4ThreeVector(), "AREA",
70  lv_world, 0, false, 0);
71  // vis. attributes
72  va = new G4VA(G4Color(1.,1.,1.));
73  va-> SetVisibility(false);
74  lv_world-> SetVisAttributes(va);
75 
76  // water phantom
77  const G4double DXY_PHANTOM = 20.*cm;
78  const G4double DZ_PHANTOM = 50.*cm;
79 
80  G4Box* sld_phantom = new G4Box("phantom",
81  DXY_PHANTOM/2., DXY_PHANTOM/2., DZ_PHANTOM/2.);
82 
83  G4Material* water = nistManager-> FindOrBuildMaterial("G4_WATER");
84  G4LV* lv_phantom = new G4LogicalVolume(sld_phantom,
85  water, "phantom");
86 
87  va = new G4VA(G4Color(0.,1.,1.));
88  lv_phantom-> SetVisAttributes(va);
89 
90  new G4PVP(0, G4ThreeVector(), lv_phantom, "phantom", lv_world, false, 0);
91 
92  // voxel planes
93  const G4double DXY_VXP = 20.*cm;
94  const G4double DZ_VXP = 1.*mm;
95 
96  G4Box* sld_vxp = new G4Box("vxplane", DXY_VXP/2., DXY_VXP/2., DZ_VXP/2.);
97  G4LV* lv_vxp = new G4LV(sld_vxp, water, "vxplane");
98 
99  va = new G4VA(G4Color(1.,0.,0.));
100  va-> SetVisibility(false);
101  lv_vxp-> SetVisAttributes(va);
102 
103  for (G4int iz =0; iz < 500; iz++) {
104  G4double z0 = -DZ_PHANTOM/2. + (iz+0.5)*DZ_VXP;
105  new G4PVP(0, G4ThreeVector(0.,0.,z0),
106  lv_vxp, "vxplane", lv_phantom, false, 1000+iz);
107  }
108 
109  // voxel parameterized
110  G4Box* sld_voxel = new G4Box("voxel",1.,1.,1.); // dummy
111  flv_voxel = new G4LV(sld_voxel, water, "voxel");
112 
113  va = new G4VA(G4Color(0.,1.,1.));
114  va-> SetVisibility(false);
115  flv_voxel-> SetVisAttributes(va);
116 
117  const G4int nvoxels = 100*100;
118  new G4PVParameterised("voxle", flv_voxel, lv_vxp, kUndefined, nvoxels,
119  new VoxelParam());
120 
121  return world;
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 {
127  flv_voxel-> SetSensitiveDetector(new VoxelSD("voxel"));
128 }