Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/exoticphysics/monopole/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 104872 2017-06-23 14:19:16Z 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 "G4UniformMagField.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4UserLimits.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 
49 #include "G4UnitsTable.hh"
50 #include "G4NistManager.hh"
51 
52 #include "G4MonopoleFieldSetup.hh"
53 //#include "G4FieldManager.hh"
54 //#include "G4TransportationManager.hh"
55 #include "G4ThreeVector.hh"
56 #include "G4RunManager.hh"
57 #include "G4SystemOfUnits.hh"
58 
60 #include "G4AutoDelete.hh"
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
66  fWorldMaterial(0),
67  fAbsorMaterial(0),
68  fLogAbsor(0),
69  fMonFieldSetup(0),
70  fZMagFieldValue(0.),
71  fDetectorMessenger(0)
72 {
73  // default parameter values
74  fAbsorSizeX = fAbsorSizeYZ = 10 * cm;
76  fMaxStepSize = 5 * mm;
77 
78  // fMonFieldSetup = G4MonopoleFieldSetup::GetMonopoleFieldSetup();
80 
81  SetMaterial("G4_Al");
84 
85  // create commands for interactive definition of the detector
87 }
88 
89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
90 
92 {
93  delete fDetectorMessenger;
94  // delete fMonFieldSetup;
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
105 
106  /**************************** World *****************************/
107  G4Box * sWorld = new G4Box("world",
108  fWorldSizeX / 2, fWorldSizeYZ / 2, fWorldSizeYZ / 2);
109 
110  G4LogicalVolume * lWorld = new G4LogicalVolume(sWorld,
112  "world");
113 
114  G4VPhysicalVolume * pWorld = new G4PVPlacement(0, //no rotation
115  G4ThreeVector(), //at (0,0,0)
116  lWorld, //logical volume
117  "world", //name
118  0, //mother volume
119  false, //no boolean operation
120  0); //copy number
121 
122 
123  /************************** Absorber ***************************/
124  G4Box * sAbsor = new G4Box("Absorber",
125  fAbsorSizeX / 2, fAbsorSizeYZ / 2, fAbsorSizeYZ / 2);
126 
127  fLogAbsor = new G4LogicalVolume(sAbsor,
129  "Absorber");
130 
131  new G4PVPlacement(0, //no rotation
132  G4ThreeVector(), //at (0,0,0)
133  fLogAbsor, //logical volume
134  "Absorber", //name
135  lWorld, //mother volume
136  false, //no boolean operation
137  0); //copy number
139 
140  PrintParameters();
141 
142  /************ always return the World volume *****************/
143  return pWorld;
144 }
145 
146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
147 
149 {
150  G4cout << "\n---------------------------------------------------------\n";
151  G4cout << "---> The Absorber is " << G4BestUnit(fAbsorSizeX, "Length")
152  << " of " << fAbsorMaterial->GetName() << G4endl;
153  G4cout << "\n---------------------------------------------------------\n";
154 
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158 
160 {
161  if(value > 0.0) {
162  fAbsorSizeX = value;
163  fWorldSizeX = 1.2 * fAbsorSizeX;
165  }
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {
172  if(value > 0.0) {
173  fAbsorSizeYZ = value;
174  fWorldSizeYZ = 1.2 * fAbsorSizeYZ;
176  }
177 }
178 
179 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
180 
181 void DetectorConstruction::SetMaterial(const G4String& namemat)
182 {
183  // search the material by its name
185  if(!mat) {
186  G4cout << "!!! DetectorConstruction::SetMaterial: WARNING Material <"
187  << namemat << "> does not exist in DB" << G4endl;
188  return;
189  }
190  // new material is found out
191  if (mat != fAbsorMaterial) {
193  if(fLogAbsor) { fLogAbsor->SetMaterial(mat); }
195  }
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199 
200 
201 // void DetectorConstruction::SetMagField(G4double fieldValue)
202 // {
203 // fMonFieldSetup->SetMagField(fieldValue);
204 
205 // //apply a global uniform magnetic field along Z axis
206 // G4FieldManager * fieldMgr =
207 // G4TransportationManager::GetTransportationManager()->GetFieldManager();
208 
209 // if (fMagField) { delete fMagField; } //delete the existing magn field
210 
211 // if (fieldValue != 0.) // create a new one if non nul
212 // {
213 // fMagField = new G4UniformMagField(G4ThreeVector(0., 0., fieldValue));
214 // fieldMgr->SetDetectorField(fMagField);
215 // fieldMgr->CreateChordFinder(fMagField);
216 // }
217 // else
218 // {
219 // fMagField = 0;
220 // fieldMgr->SetDetectorField(fMagField);
221 // }
222 // }
223 
224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
225 
227 {
228 
229  // Define magnetic field
230  bool bNewFieldValue = false;
231  if ( fFieldMessenger.Get() != 0 ) {
233  if(fieldSet.z()!=fZMagFieldValue) bNewFieldValue = true;
234  }
235  else bNewFieldValue = true;
236 
237  // Monopole particule specific magnetic field
238  if(bNewFieldValue&&fZMagFieldValue!=0.)
240 
241  if ( bNewFieldValue ) {
242  // Create global magnetic field messenger.
243  // Uniform magnetic field is then created automatically if
244  // the field value is not zero.
245 
246  if(fZMagFieldValue!=0.)
247  {
248  G4ThreeVector fieldValue = G4ThreeVector(0.,0.,fZMagFieldValue);
250  new G4GlobalMagFieldMessenger(fieldValue);
251  msg->SetVerboseLevel(1);
253  fFieldMessenger.Put( msg );
254  }
255  }
256 
257 }
258 
259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
260 
262 {
263  fMaxStepSize = step;
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
272 }
273 
274 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
void SetVerboseLevel(G4int verboseLevel)
double z() const
void SetMagField(G4double v, bool checkIfAlreadyDefined=false)
void Register(T *inst)
Definition: G4AutoDelete.hh:65
const G4String & GetName() const
Definition: G4Material.hh:179
double G4double
Definition: G4Types.hh:76
G4ThreeVector GetFieldValue() const
const XML_Char int const XML_Char * value
Definition: expat.h:331
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
value_type & Get() const
Definition: G4Cache.hh:314
Float_t mat
void OpenGeometry(G4VPhysicalVolume *vol=0)
void GeometryHasBeenModified(G4bool prop=true)
void Put(const value_type &val) const
Definition: G4Cache.hh:318
void SetUserLimits(G4UserLimits *pULimits)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4SolidStore * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void PhysicsHasBeenModified()
G4Cache< G4GlobalMagFieldMessenger * > fFieldMessenger
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()
Definition of the G4MonopoleFieldSetup class.