Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file.
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$
30 //
32 //
33 // DetectorConstruction
34 //
35 // Created: 31.01.2003 V.Ivanchenko
36 //
37 // Modified:
38 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
39 //
41 //
42 
43 #include "DetectorConstruction.hh"
44 #include "DetectorMessenger.hh"
45 
46 #include "G4Tubs.hh"
47 #include "G4LogicalVolume.hh"
48 #include "G4PVPlacement.hh"
49 
50 #include "G4RunManager.hh"
51 
52 #include "G4GeometryManager.hh"
53 #include "G4PhysicalVolumeStore.hh"
54 #include "G4LogicalVolumeStore.hh"
55 #include "G4SolidStore.hh"
56 
57 #include "G4VisAttributes.hh"
58 #include "G4Colour.hh"
59 
60 #include "G4UnitsTable.hh"
61 #include "G4ios.hh"
62 
63 #include "TargetSD.hh"
64 #include "CheckVolumeSD.hh"
65 #include "G4SDManager.hh"
66 #include "HistoManager.hh"
67 #include "G4NistManager.hh"
68 
69 #include "G4PhysicalConstants.hh"
70 #include "G4SystemOfUnits.hh"
71 
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 {
77  fLogicTarget = 0;
78  fLogicCheck = 0;
79  fLogicWorld = 0;
80  fDetectorMessenger = new DetectorMessenger(this);
81 
82  fRadius = 10.*cm;
83 
84  fTargetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
85  fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
86 
87  // Prepare sensitive detectors
88  fCheckSD = new CheckVolumeSD("checkSD");
89  (G4SDManager::GetSDMpointer())->AddNewDetector( fCheckSD );
90  fTargetSD = new TargetSD("targetSD");
91  (G4SDManager::GetSDMpointer())->AddNewDetector( fTargetSD );
92 }
93 
94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
95 
97 {
98  delete fDetectorMessenger;
99 }
100 
102 {
103  // Cleanup old geometry
104 
109 
110  // Sizes
111  G4double checkR = fRadius + mm;
112  G4double worldR = fRadius + cm;
113  G4double targetZ = HistoManager::GetPointer()->Length()*0.5;
114  G4double checkZ = targetZ + mm;
115  G4double worldZ = targetZ + cm;
116 
118  G4double sliceZ = targetZ/G4double(nSlices);
119 
120  //
121  // World
122  //
123  G4Tubs* solidW = new G4Tubs("World",0.,worldR,worldZ,0.,twopi);
124  fLogicWorld = new G4LogicalVolume( solidW,fWorldMaterial,"World");
126  fLogicWorld,"World",0,false,0);
127  //
128  // Check volume
129  //
130  G4Tubs* solidC = new G4Tubs("Check",0.,checkR,checkZ,0.,twopi);
131  fLogicCheck = new G4LogicalVolume( solidC,fWorldMaterial,"Check");
132  // G4VPhysicalVolume* physC =
133  new G4PVPlacement(0,G4ThreeVector(),fLogicCheck,"Check",fLogicWorld,false,0);
134  fLogicCheck->SetSensitiveDetector(fCheckSD);
135 
136  //
137  // Target volume
138  //
139  G4Tubs* solidA = new G4Tubs("Target",0.,fRadius,sliceZ,0.,twopi);
140  fLogicTarget = new G4LogicalVolume( solidA,fTargetMaterial,"Target");
141  fLogicTarget->SetSensitiveDetector(fTargetSD);
142 
143  G4double z = sliceZ - targetZ;
144 
145  for(G4int i=0; i<nSlices; i++) {
146  // physC =
147  new G4PVPlacement(0,G4ThreeVector(0.0,0.0,z),fLogicTarget,"Target",fLogicCheck,false,i);
148  z += 2.0*sliceZ;
149  }
150  G4cout << "### Target consist of " << nSlices
151  << " of " << fTargetMaterial->GetName()
152  << " disks with R(mm)= " << fRadius/mm
153  << " Width(mm)= " << 2.0*sliceZ/mm
154  << " Total Length(mm)= " << 2.0*targetZ/mm
155  << " ###" << G4endl;
156 
157  // colors
159  fLogicWorld->SetVisAttributes(&zero);
160 
161  G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3));
162  fLogicCheck->SetVisAttributes(&regWcolor);
163 
164  G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7));
165  fLogicTarget->SetVisAttributes(&regCcolor);
166 
167  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
168 
169  return world;
170 }
171 
172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
173 
175 {
176  // search the material by its name
178 
179  if (material && material != fTargetMaterial) {
180  fTargetMaterial = material;
181  if(fLogicTarget) { fLogicTarget->SetMaterial(fTargetMaterial); }
183  }
184 }
185 
186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
187 
189 {
190  // search the material by its name
192 
193  if (material && material != fWorldMaterial) {
194  fWorldMaterial = material;
195  if(fLogicWorld) { fLogicWorld->SetMaterial(fWorldMaterial); }
197  }
198 }
199 
200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
201 
203 {
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
208 
210 {
211  if(val > 0.0) {
212  fRadius = val;
214  }
215 }
216 
217 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......