Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/exoticphysics/dmparticle/src/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 //
28 //
29 // $Id: DetectorConstruction.cc 68036 2013-03-13 14:13:45Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4Box.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "TargetSD.hh"
42 #include "G4SDManager.hh"
43 
44 #include "G4GeometryManager.hh"
45 
46 #include "G4UnitsTable.hh"
47 #include "G4NistManager.hh"
48 
49 #include "G4FieldManager.hh"
50 #include "G4ThreeVector.hh"
51 #include "G4RunManager.hh"
52 #include "G4SystemOfUnits.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fAbsorMaterial(nullptr),
59  fLogAbsor(nullptr),
60  fWorld(nullptr)
61 {
62  // default parameter values
63  fAbsorSizeZ = fAbsorSizeXY = 10 * cm;
65 
66  SetMaterial("G4_Al");
69 
70  // create commands for interactive definition of the detector
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  delete fDetectorMessenger;
79 }
80 
81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82 
84 {
85  if(fWorld) { return fWorld; }
86 
87  /**************************** World *****************************/
88  G4Box * sWorld = new G4Box("world",
89  fWorldSizeXY / 2, fWorldSizeXY / 2, fWorldSizeZ / 2);
90 
91  G4LogicalVolume * lWorld = new G4LogicalVolume(sWorld,
93  "world");
94 
95  fWorld = new G4PVPlacement(0, //no rotation
96  G4ThreeVector(), //at (0,0,0)
97  lWorld, //logical volume
98  "world", //name
99  0, //mother volume
100  false, //no boolean operation
101  0); //copy number
102 
103 
104  /************************** Absorber ***************************/
105 
106  G4Box * sAbsor = new G4Box("Absorber",
107  fAbsorSizeXY / 2, fAbsorSizeXY / 2, fAbsorSizeZ / 2);
108 
109  fLogAbsor = new G4LogicalVolume(sAbsor,
111  "Absorber");
112 
113  new G4PVPlacement(0, //no rotation
114  G4ThreeVector(), //at (0,0,0)
115  fLogAbsor, //logical volume
116  "Absorber", //name
117  lWorld, //mother volume
118  false, //no boolean operation
119  0); //copy number
120 
121  PrintParameters();
122 
123  /************ always return the World volume *****************/
124  return fWorld;
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
128 
130 {
131  G4cout << "\n---------------------------------------------------------\n";
132  G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeZ, "Length")
133  << " of " << fAbsorMaterial->GetName() << G4endl;
134  G4cout << "\n---------------------------------------------------------\n";
135 
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  if(value > 0.0) {
143  fAbsorSizeZ = value;
144  fWorldSizeZ = 1.2 * fAbsorSizeZ;
145  }
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 
151 {
152  if(value > 0.0)
153  {
154  fAbsorSizeXY = value;
155  fWorldSizeXY = 1.2 * fAbsorSizeXY;
156  }
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160 
161 void DetectorConstruction::SetMaterial(const G4String& namemat)
162 {
163  // search the material by its name
164 
166  if(!mat) {
167  G4cout << "!!! DetectorConstruction::SetMaterial: WARNING Material <"
168  << namemat << "> does not exist in DB" << G4endl;
169  return;
170  }
171  // new material is found out
172  if (mat != fAbsorMaterial) {
174  if(fLogAbsor) { fLogAbsor->SetMaterial(mat); }
176  }
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
182 {
183  auto sd = new TargetSD("Target");
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
CLHEP::Hep3Vector G4ThreeVector
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
const G4String & GetName() const
Definition: G4Material.hh:179
double G4double
Definition: G4Types.hh:76
const XML_Char int const XML_Char * value
Definition: expat.h:331
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
Float_t mat
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static G4NistManager * Instance()