Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/hadronic/Hadr02/src/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 //
26 /// \file hadronic/Hadr02/src/DetectorConstruction.cc
27 /// \brief Implementation of the DetectorConstruction class
28 //
29 // $Id: DetectorConstruction.cc 77519 2013-11-25 10:54:57Z gcosmo $
30 //
31 /////////////////////////////////////////////////////////////////////////
32 //
33 // DetectorConstruction
34 //
35 // Created: 31.01.2003 V.Ivanchenko
36 //
37 // Modified:
38 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko)
39 //
40 ////////////////////////////////////////////////////////////////////////
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 "G4SDManager.hh"
65 #include "HistoManager.hh"
66 #include "G4NistManager.hh"
67 
68 #include "G4PhysicalConstants.hh"
69 #include "G4SystemOfUnits.hh"
70 
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  logicTarget = 0;
77  logicCheck = 0;
78  logicWorld = 0;
79  detectorMessenger = new DetectorMessenger(this);
80 
81  radius = 10.*cm;
82 
83  targetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
84  worldMaterial =
87 
88  // Prepare sensitive detectors
89  targetSD = new TargetSD("targetSD");
90  (G4SDManager::GetSDMpointer())->AddNewDetector( targetSD );
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
97  delete detectorMessenger;
98 }
99 
101 {
102  // Cleanup old geometry
107 
108  // Sizes
109  G4double checkR = radius + mm;
110  G4double worldR = radius + cm;
111  G4double targetZ = HistoManager::GetPointer()->Length()*0.5;
112  G4double checkZ = targetZ + mm;
113  G4double worldZ = targetZ + cm;
114 
116  G4double sliceZ = targetZ/G4double(nSlices);
117 
118  //
119  // World
120  G4Tubs* solidW = new G4Tubs("World",0.,worldR,worldZ,0.,twopi);
121  logicWorld = new G4LogicalVolume( solidW,worldMaterial,"World");
123  logicWorld,"World",0,false,0);
124  //
125  // Check volume
126  //
127  G4Tubs* solidC = new G4Tubs("Check",0.,checkR,checkZ,0.,twopi);
128  logicCheck = new G4LogicalVolume( solidC,worldMaterial,"World");
129  // G4VPhysicalVolume* physC =
130  new G4PVPlacement(0,G4ThreeVector(),logicCheck,"World",logicWorld,false,0);
131 
132  //
133  // Target volume
134  //
135  G4Tubs* solidA = new G4Tubs("Target",0.,radius,sliceZ,0.,twopi);
136  logicTarget = new G4LogicalVolume( solidA,targetMaterial,"Target");
137  logicTarget->SetSensitiveDetector(targetSD);
138 
139  G4double z = sliceZ - targetZ;
140 
141  for(G4int i=0; i<nSlices; i++) {
142  // physC =
143  new G4PVPlacement(0,G4ThreeVector(0.0,0.0,z),logicTarget,
144  "Target",logicCheck,false,i);
145  z += 2.0*sliceZ;
146  }
147  G4cout << "### Target consist of " << nSlices
148  << " of " << targetMaterial->GetName()
149  << " disks with R(mm)= " << radius/mm
150  << " Width(mm)= " << 2.0*sliceZ/mm
151  << " Total Length(mm)= " << 2.0*targetZ/mm
152  << " ###" << G4endl;
153 
154  // colors
156  logicWorld->SetVisAttributes(&zero);
157 
158  G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 0.3));
159  logicCheck->SetVisAttributes(&regWcolor);
160 
161  G4VisAttributes regCcolor(G4Colour(0., 0.3, 0.7));
162  logicTarget->SetVisAttributes(&regCcolor);
163 
164  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
165 
166  return world;
167 }
168 
169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
170 
172 {
173  // search the material by its name
175 
176  if (material && material != targetMaterial) {
178  targetMaterial = material;
179  if(logicTarget) { logicTarget->SetMaterial(targetMaterial); }
181  }
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 
187 {
188  // search the material by its name
190 
191  if (material && material != worldMaterial) {
192  worldMaterial = material;
193  if(logicWorld) { logicWorld->SetMaterial(worldMaterial); }
195  }
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
199 
201 {
202  if(val > 0.0) {
203  radius = val;
205  }
206 }
207 
208 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GeometryHasBeenModified(G4bool prop=true)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
const G4String & GetName() const
Definition: G4Material.hh:176
Definition: G4Tubs.hh:84
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
static void Clean()
Definition: G4SolidStore.cc:79
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
string material
Definition: eplot.py:19
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
void SetTargetMaterial(const G4Material *mat)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)