| 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 | // $Id: DetectorConstruction.cc,v 1.6 2006/10/04 09:56:03 vnivanch Exp $
|
|---|
| 27 | // GEANT4 tag $Name: $
|
|---|
| 28 | //
|
|---|
| 29 | /////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | //
|
|---|
| 31 | // DetectorConstruction
|
|---|
| 32 | //
|
|---|
| 33 | // Created: 31.01.2003 V.Ivanchenko
|
|---|
| 34 | //
|
|---|
| 35 | // Modified:
|
|---|
| 36 | // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko)
|
|---|
| 37 | //
|
|---|
| 38 | ////////////////////////////////////////////////////////////////////////
|
|---|
| 39 | //
|
|---|
| 40 |
|
|---|
| 41 | #include "DetectorConstruction.hh"
|
|---|
| 42 | #include "DetectorMessenger.hh"
|
|---|
| 43 |
|
|---|
| 44 | #include "G4Tubs.hh"
|
|---|
| 45 | #include "G4LogicalVolume.hh"
|
|---|
| 46 | #include "G4PVPlacement.hh"
|
|---|
| 47 |
|
|---|
| 48 | #include "G4RunManager.hh"
|
|---|
| 49 |
|
|---|
| 50 | #include "G4GeometryManager.hh"
|
|---|
| 51 | #include "G4PhysicalVolumeStore.hh"
|
|---|
| 52 | #include "G4LogicalVolumeStore.hh"
|
|---|
| 53 | #include "G4SolidStore.hh"
|
|---|
| 54 |
|
|---|
| 55 | #include "G4VisAttributes.hh"
|
|---|
| 56 | #include "G4Colour.hh"
|
|---|
| 57 |
|
|---|
| 58 | #include "G4UnitsTable.hh"
|
|---|
| 59 | #include "G4ios.hh"
|
|---|
| 60 |
|
|---|
| 61 | #include "TargetSD.hh"
|
|---|
| 62 | #include "CheckVolumeSD.hh"
|
|---|
| 63 | #include "G4SDManager.hh"
|
|---|
| 64 | #include "HistoManager.hh"
|
|---|
| 65 | #include "G4NistManager.hh"
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 69 |
|
|---|
| 70 | DetectorConstruction::DetectorConstruction()
|
|---|
| 71 | {
|
|---|
| 72 | logicTarget = 0;
|
|---|
| 73 | logicCheck = 0;
|
|---|
| 74 | logicWorld = 0;
|
|---|
| 75 | detectorMessenger = new DetectorMessenger(this);
|
|---|
| 76 |
|
|---|
| 77 | radius = 10.*cm;
|
|---|
| 78 |
|
|---|
| 79 | targetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
|
|---|
| 80 | worldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
|
|---|
| 81 |
|
|---|
| 82 | // Prepare sensitive detectors
|
|---|
| 83 | checkSD = new CheckVolumeSD("checkSD");
|
|---|
| 84 | (G4SDManager::GetSDMpointer())->AddNewDetector( checkSD );
|
|---|
| 85 | targetSD = new TargetSD("targetSD");
|
|---|
| 86 | (G4SDManager::GetSDMpointer())->AddNewDetector( targetSD );
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 90 |
|
|---|
| 91 | DetectorConstruction::~DetectorConstruction()
|
|---|
| 92 | {
|
|---|
| 93 | delete detectorMessenger;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | G4VPhysicalVolume* DetectorConstruction::Construct()
|
|---|
| 97 | {
|
|---|
| 98 | // Cleanup old geometry
|
|---|
| 99 |
|
|---|
| 100 | G4GeometryManager::GetInstance()->OpenGeometry();
|
|---|
| 101 | G4PhysicalVolumeStore::GetInstance()->Clean();
|
|---|
| 102 | G4LogicalVolumeStore::GetInstance()->Clean();
|
|---|
| 103 | G4SolidStore::GetInstance()->Clean();
|
|---|
| 104 |
|
|---|
| 105 | // Sizes
|
|---|
| 106 | G4double checkR = radius + mm;
|
|---|
| 107 | G4double worldR = radius + cm;
|
|---|
| 108 | G4double targetZ = HistoManager::GetPointer()->Length()*0.5;
|
|---|
| 109 | G4double checkZ = targetZ + mm;
|
|---|
| 110 | G4double worldZ = targetZ + cm;
|
|---|
| 111 |
|
|---|
| 112 | G4int nSlices = HistoManager::GetPointer()->NumberOfSlices();
|
|---|
| 113 | G4double sliceZ = targetZ/G4double(nSlices);
|
|---|
| 114 |
|
|---|
| 115 | //
|
|---|
| 116 | // World
|
|---|
| 117 | //
|
|---|
| 118 | G4Tubs* solidW = new G4Tubs("World",0.,worldR,worldZ,0.,twopi);
|
|---|
| 119 | logicWorld = new G4LogicalVolume( solidW,worldMaterial,"World");
|
|---|
| 120 | G4VPhysicalVolume* world = new G4PVPlacement(0,G4ThreeVector(),
|
|---|
| 121 | logicWorld,"World",0,false,0);
|
|---|
| 122 | //
|
|---|
| 123 | // Check volume
|
|---|
| 124 | //
|
|---|
| 125 | G4Tubs* solidC = new G4Tubs("Check",0.,checkR,checkZ,0.,twopi);
|
|---|
| 126 | logicCheck = new G4LogicalVolume( solidC,worldMaterial,"World");
|
|---|
| 127 | // G4VPhysicalVolume* physC =
|
|---|
| 128 | new G4PVPlacement(0,G4ThreeVector(),logicCheck,"World",logicWorld,false,0);
|
|---|
| 129 | logicCheck->SetSensitiveDetector(checkSD);
|
|---|
| 130 |
|
|---|
| 131 | //
|
|---|
| 132 | // Target volume
|
|---|
| 133 | //
|
|---|
| 134 | G4Tubs* solidA = new G4Tubs("Target",0.,radius,sliceZ,0.,twopi);
|
|---|
| 135 | logicTarget = new G4LogicalVolume( solidA,targetMaterial,"Target");
|
|---|
| 136 | logicTarget->SetSensitiveDetector(targetSD);
|
|---|
| 137 |
|
|---|
| 138 | G4double z = sliceZ - targetZ;
|
|---|
| 139 |
|
|---|
| 140 | for(G4int i=0; i<nSlices; i++) {
|
|---|
| 141 | // physC =
|
|---|
| 142 | new G4PVPlacement(0,G4ThreeVector(0.0,0.0,z),logicTarget,"Target",logicCheck,false,i);
|
|---|
| 143 | z += 2.0*sliceZ;
|
|---|
| 144 | }
|
|---|
| 145 | G4cout << "### Target consist of " << nSlices
|
|---|
| 146 | << " of " << targetMaterial->GetName()
|
|---|
| 147 | << " disks with R(mm)= " << radius/mm
|
|---|
| 148 | << " Width(mm)= " << 2.0*sliceZ/mm
|
|---|
| 149 | << " Total Length(mm)= " << 2.0*targetZ/mm
|
|---|
| 150 | << " ###" << G4endl;
|
|---|
| 151 |
|
|---|
| 152 | // colors
|
|---|
| 153 | logicWorld->SetVisAttributes(G4VisAttributes::Invisible);
|
|---|
| 154 |
|
|---|
| 155 | G4VisAttributes* regWcolor = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3));
|
|---|
| 156 | logicCheck->SetVisAttributes(regWcolor);
|
|---|
| 157 |
|
|---|
| 158 | G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
|
|---|
| 159 | logicTarget->SetVisAttributes(regCcolor);
|
|---|
| 160 |
|
|---|
| 161 | G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
|---|
| 162 |
|
|---|
| 163 | return world;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 167 |
|
|---|
| 168 | void DetectorConstruction::SetTargetMaterial(const G4String& mat)
|
|---|
| 169 | {
|
|---|
| 170 | // search the material by its name
|
|---|
| 171 | G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat);
|
|---|
| 172 |
|
|---|
| 173 | if (material && material != targetMaterial) {
|
|---|
| 174 | HistoManager::GetPointer()->SetTargetMaterial(material);
|
|---|
| 175 | targetMaterial = material;
|
|---|
| 176 | if(logicTarget) logicTarget->SetMaterial(targetMaterial);
|
|---|
| 177 | G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
|---|
| 178 | }
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 182 |
|
|---|
| 183 | void DetectorConstruction::SetWorldMaterial(const G4String& mat)
|
|---|
| 184 | {
|
|---|
| 185 | // search the material by its name
|
|---|
| 186 | G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(mat);
|
|---|
| 187 |
|
|---|
| 188 | if (material && material != worldMaterial) {
|
|---|
| 189 | worldMaterial = material;
|
|---|
| 190 | if(logicWorld) logicWorld->SetMaterial(worldMaterial);
|
|---|
| 191 | G4RunManager::GetRunManager()->PhysicsHasBeenModified();
|
|---|
| 192 | }
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 196 |
|
|---|
| 197 | void DetectorConstruction::UpdateGeometry()
|
|---|
| 198 | {
|
|---|
| 199 | G4RunManager::GetRunManager()->DefineWorldVolume(Construct());
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|
| 202 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|
| 203 |
|
|---|
| 204 | void DetectorConstruction::SetTargetRadius(G4double val)
|
|---|
| 205 | {
|
|---|
| 206 | if(val > 0.0) {
|
|---|
| 207 | radius = val;
|
|---|
| 208 | G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
|---|
| 209 | }
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
|---|