Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
ExN02DetectorConstruction.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 //
30 // $Id: ExN02DetectorConstruction.cc 78055 2013-12-03 08:27:48Z gcosmo $
31 //
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
38 #include "ExN02MagneticField.hh"
39 #include "ExN02TrackerSD.hh"
40 
41 #include "G4Material.hh"
42 #include "G4Box.hh"
43 #include "G4LogicalVolume.hh"
44 #include "G4PVPlacement.hh"
45 #include "G4PVParameterised.hh"
46 #include "G4SDManager.hh"
47 #include "G4GeometryTolerance.hh"
48 #include "G4GeometryManager.hh"
49 
50 #include "G4UserLimits.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 #include "G4VisAttributes.hh"
54 #include "G4Colour.hh"
55 
56 #include "G4ios.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 :solidWorld(0), logicWorld(0), physiWorld(0),
62  solidTarget(0), logicTarget(0), physiTarget(0),
63  solidTracker(0),logicTracker(0),physiTracker(0),
64  solidChamber(0),logicChamber(0),physiChamber(0),
65  TargetMater(0), ChamberMater(0),chamberParam(0),
66  stepLimit(0), fpMagField(0),
67  fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
68  NbOfChambers(0) , ChamberWidth(0.), ChamberSpacing(0.)
69 {
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  delete fpMagField;
79  delete stepLimit;
80  delete chamberParam;
81  delete detectorMessenger;
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88 //--------- Material definition ---------
89 
90  G4double a, z;
91  G4double density, temperature, pressure;
92  G4int nel;
93 
94  //Air
95  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
96  G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole);
97 
98  G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
99  Air->AddElement(N, 70*perCent);
100  Air->AddElement(O, 30*perCent);
101 
102  //Lead
103  G4Material* Pb =
104  new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
105 
106  //Xenon gas
107  G4Material* Xenon =
108  new G4Material("XenonGas", z=54., a=131.29*g/mole, density= 5.458*mg/cm3,
109  kStateGas, temperature= 293.15*kelvin, pressure= 1*atmosphere);
110 
111  // Print all the materials defined.
112  //
113  G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
114  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
115 
116 //--------- Sizes of the principal geometrical components (solids) ---------
117 
118  NbOfChambers = 5;
119  ChamberWidth = 20*cm;
120  ChamberSpacing = 80*cm;
121 
122  fTrackerLength = (NbOfChambers+1)*ChamberSpacing; // Full length of Tracker
123  fTargetLength = 5.0 * cm; // Full length of Target
124 
125  TargetMater = Pb;
126  ChamberMater = Xenon;
127 
129 
130  G4double targetSize = 0.5*fTargetLength; // Half length of the Target
131  G4double trackerSize = 0.5*fTrackerLength; // Half length of the Tracker
132 
133 //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
134 
135  //------------------------------
136  // World
137  //------------------------------
138 
139  G4double HalfWorldLength = 0.5*fWorldLength;
140 
142  G4cout << "Computed tolerance = "
144  << " mm" << G4endl;
145 
146  solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
147  logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
148 
149  // Must place the World Physical volume unrotated at (0,0,0).
150  //
151  physiWorld = new G4PVPlacement(0, // no rotation
152  G4ThreeVector(), // at (0,0,0)
153  logicWorld, // its logical volume
154  "World", // its name
155  0, // its mother volume
156  false, // no boolean operations
157  0); // copy number
158 
159  //------------------------------
160  // Target
161  //------------------------------
162 
163  G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetSize+trackerSize));
164 
165  solidTarget = new G4Box("target",targetSize,targetSize,targetSize);
166  logicTarget = new G4LogicalVolume(solidTarget,TargetMater,"Target",0,0,0);
167  physiTarget = new G4PVPlacement(0, // no rotation
168  positionTarget, // at (x,y,z)
169  logicTarget, // its logical volume
170  "Target", // its name
171  logicWorld, // its mother volume
172  false, // no boolean operations
173  0); // copy number
174 
175  G4cout << "Target is " << fTargetLength/cm << " cm of "
176  << TargetMater->GetName() << G4endl;
177 
178  //------------------------------
179  // Tracker
180  //------------------------------
181 
182  G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
183 
184  solidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
185  logicTracker = new G4LogicalVolume(solidTracker , Air, "Tracker",0,0,0);
186  physiTracker = new G4PVPlacement(0, // no rotation
187  positionTracker, // at (x,y,z)
188  logicTracker, // its logical volume
189  "Tracker", // its name
190  logicWorld, // its mother volume
191  false, // no boolean operations
192  0); // copy number
193 
194  //------------------------------
195  // Tracker segments
196  //------------------------------
197  //
198  // An example of Parameterised volumes
199  // dummy values for G4Box -- modified by parameterised volume
200 
201  solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
202  logicChamber = new G4LogicalVolume(solidChamber,ChamberMater,"Chamber",0,0,0);
203 
204  G4double firstPosition = -trackerSize + 0.5*ChamberWidth;
205  G4double firstLength = fTrackerLength/10;
206  G4double lastLength = fTrackerLength;
207 
209  NbOfChambers, // NoChambers
210  firstPosition, // Z of center of first
211  ChamberSpacing, // Z spacing of centers
212  ChamberWidth, // Width Chamber
213  firstLength, // lengthInitial
214  lastLength); // lengthFinal
215 
216  // dummy value : kZAxis -- modified by parameterised volume
217  //
219  "Chamber", // their name
220  logicChamber, // their logical volume
221  logicTracker, // Mother logical volume
222  kZAxis, // Are placed along this axis
223  NbOfChambers, // Number of chambers
224  chamberParam); // The parametrisation
225 
226  G4cout << "There are " << NbOfChambers << " chambers in the tracker region. "
227  << "The chambers are " << ChamberWidth/mm << " mm of "
228  << ChamberMater->GetName() << "\n The distance between chamber is "
229  << ChamberSpacing/cm << " cm" << G4endl;
230 
231  //------------------------------------------------
232  // Sensitive detectors
233  //------------------------------------------------
234 
236 
237  G4String trackerChamberSDname = "ExN02/TrackerChamberSD";
238  ExN02TrackerSD* aTrackerSD = new ExN02TrackerSD( trackerChamberSDname );
239  SDman->AddNewDetector( aTrackerSD );
240  logicChamber->SetSensitiveDetector( aTrackerSD );
241 
242 //--------- Visualization attributes -------------------------------
243 
244  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
245  logicWorld ->SetVisAttributes(BoxVisAtt);
246  logicTarget ->SetVisAttributes(BoxVisAtt);
247  logicTracker->SetVisAttributes(BoxVisAtt);
248 
249  G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
250  logicChamber->SetVisAttributes(ChamberVisAtt);
251 
252 //--------- example of User Limits -------------------------------
253 
254  // below is an example of how to set tracking constraints in a given
255  // logical volume(see also in N02PhysicsList how to setup the processes
256  // G4StepLimiter or G4UserSpecialCuts).
257 
258  // Sets a max Step length in the tracker region, with G4StepLimiter
259  //
260  G4double maxStep = 0.5*ChamberWidth;
261  stepLimit = new G4UserLimits(maxStep);
263 
264  // Set additional contraints on the track, with G4UserSpecialCuts
265  //
266  // G4double maxLength = 2*fTrackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
267  // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
268  // minEkin));
269 
270  return physiWorld;
271 }
272 
273 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
274 
276 {
277  // search the material by its name
278  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
279  if (pttoMaterial)
280  {TargetMater = pttoMaterial;
281  logicTarget->SetMaterial(pttoMaterial);
282  G4cout << "\n----> The target is " << fTargetLength/cm << " cm of "
283  << materialName << G4endl;
284  }
285 }
286 
287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
288 
290 {
291  // search the material by its name
292  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
293  if (pttoMaterial)
294  {ChamberMater = pttoMaterial;
295  logicChamber->SetMaterial(pttoMaterial);
296  G4cout << "\n----> The chambers are " << ChamberWidth/cm << " cm of "
297  << materialName << G4endl;
298  }
299 }
300 
301 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
302 
304 {
305  fpMagField->SetMagFieldValue(fieldValue);
306 }
307 
308 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
309 
311 {
312  if ((stepLimit)&&(maxStep>0.)) stepLimit->SetMaxAllowedStep(maxStep);
313 }
314 
315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static constexpr double kelvin
Definition: G4SIunits.hh:281
static constexpr double atmosphere
Definition: G4SIunits.hh:237
CLHEP::Hep3Vector G4ThreeVector
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:593
static constexpr double mm
Definition: G4SIunits.hh:115
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
Double_t z
static constexpr double perCent
Definition: G4SIunits.hh:332
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:608
ExN02DetectorMessenger * detectorMessenger
const G4String & GetName() const
Definition: G4Material.hh:179
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
**D E S C R I P T I O N
static constexpr double mg
Definition: G4SIunits.hh:184
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
void SetVisAttributes(const G4VisAttributes *pVA)
void SetWorldMaximumExtent(G4double worldExtent)
void SetUserLimits(G4UserLimits *pULimits)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
G4VPVParameterisation * chamberParam
static constexpr double cm
Definition: G4SIunits.hh:119
G4GLOB_DLL std::ostream G4cout
void SetMaterial(G4Material *pMaterial)
void SetMagFieldValue(G4double fieldValue)
static G4GeometryTolerance * GetInstance()
static constexpr double mole
Definition: G4SIunits.hh:286
virtual void SetMaxAllowedStep(G4double ustepMax)
static constexpr double cm3
Definition: G4SIunits.hh:121
G4double GetSurfaceTolerance() const
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)