Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file biasing/B03/src/B03ImportanceDetecto << 27 /// \brief Implementation of the B03Importance << 28 // << 29 // 26 // >> 27 // $Id: B03ImportanceDetectorConstruction.cc,v 1.8 2006/06/29 16:35:17 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01 $ 30 // 29 // 31 30 >> 31 #include "globals.hh" >> 32 #include "G4Types.hh" >> 33 #include <sstream> >> 34 32 #include "B03ImportanceDetectorConstruction.hh 35 #include "B03ImportanceDetectorConstruction.hh" 33 36 34 #include "G4LogicalVolume.hh" << 35 #include "G4Material.hh" 37 #include "G4Material.hh" 36 #include "G4PVPlacement.hh" << 37 #include "G4PhysicalConstants.hh" << 38 #include "G4SystemOfUnits.hh" << 39 #include "G4ThreeVector.hh" << 40 #include "G4Tubs.hh" 38 #include "G4Tubs.hh" 41 #include "globals.hh" << 39 #include "G4LogicalVolume.hh" 42 << 40 #include "G4ThreeVector.hh" 43 #include <sstream> << 41 #include "G4PVPlacement.hh" 44 << 45 // For Primitive Scorers << 46 #include "G4MultiFunctionalDetector.hh" << 47 #include "G4PSNofCollision.hh" << 48 #include "G4PSPopulation.hh" << 49 #include "G4PSTrackCounter.hh" << 50 #include "G4PSTrackLength.hh" << 51 #include "G4SDManager.hh" << 52 #include "G4SDParticleFilter.hh" << 53 42 54 //....oooOO0OOooo........oooOO0OOooo........oo << 55 43 56 B03ImportanceDetectorConstruction::B03Importan << 44 B03ImportanceDetectorConstruction::B03ImportanceDetectorConstruction() 57 : G4VUserParallelWorld(worldName), fLogicalV << 58 { 45 { 59 // Construct(); << 46 Construct(); 60 } 47 } 61 48 62 //....oooOO0OOooo........oooOO0OOooo........oo << 63 << 64 B03ImportanceDetectorConstruction::~B03Importa 49 B03ImportanceDetectorConstruction::~B03ImportanceDetectorConstruction() 65 { << 50 {;} 66 fLogicalVolumeVector.clear(); << 67 } << 68 << 69 //....oooOO0OOooo........oooOO0OOooo........oo << 70 51 71 void B03ImportanceDetectorConstruction::Constr 52 void B03ImportanceDetectorConstruction::Construct() 72 { << 53 { 73 G4cout << " constructing parallel world " << << 54 G4String name; >> 55 G4double A, density, temperature, pressure; >> 56 G4int z; 74 57 75 G4Material* dummyMat = 0; << 58 G4Material *Galactic = >> 59 new G4Material(name="Galactic", z=1, A=1.01*g/mole, density, >> 60 kStateGas,temperature,pressure); 76 61 77 // GetWorld methods create a clone of the ma << 78 // via the transportation manager << 79 fGhostWorld = GetWorld(); << 80 G4cout << " B03ImportanceDetectorConstructio << 81 << G4endl; << 82 G4LogicalVolume* worldLogical = fGhostWorld- << 83 fLogicalVolumeVector.push_back(worldLogical) << 84 << 85 G4String name("none"); << 86 // fPVolumeStore.AddPVolume(G4GeometryCell( << 87 fPVolumeStore.AddPVolume(G4GeometryCell(*fGh << 88 62 89 // creating 18 slobs of 10 cm thicknes << 90 63 91 G4double innerRadiusShield = 0 * cm; << 64 ////////////////////////////////// 92 G4double outerRadiusShield = 100 * cm; << 65 // parallel world cylinder volume 93 G4double heightShield = 5 * cm; << 66 ////////////////////////////////// 94 G4double startAngleShield = 0 * deg; << 67 95 G4double spanningAngleShield = 360 * deg; << 68 // parallel world solid larger than in the mass geometry >> 69 >> 70 G4double innerRadiusCylinder = 0*cm; >> 71 G4double outerRadiusCylinder = 110*cm; >> 72 G4double hightCylinder = 110*cm; >> 73 G4double startAngleCylinder = 0*deg; >> 74 G4double spanningAngleCylinder = 360*deg; >> 75 >> 76 G4Tubs *worldCylinder = new G4Tubs("worldCylinder", >> 77 innerRadiusCylinder, >> 78 outerRadiusCylinder, >> 79 hightCylinder, >> 80 startAngleCylinder, >> 81 spanningAngleCylinder); 96 82 97 G4Tubs* aShield = new G4Tubs("aShield", inne << 83 // logical world 98 startAngleShiel << 99 84 >> 85 G4LogicalVolume *worldCylinder_log = >> 86 new G4LogicalVolume(worldCylinder, Galactic, "worldCylinder_log"); >> 87 >> 88 name = "parallelWorld"; >> 89 fWorldVolume = new >> 90 G4PVPlacement(0, G4ThreeVector(0,0,0), worldCylinder_log, >> 91 name, 0, false, 0); >> 92 >> 93 fPVolumeStore.AddPVolume(G4GeometryCell(*fWorldVolume, 0)); >> 94 >> 95 >> 96 >> 97 >> 98 // creating 18 slobs of 10 cm thicknes >> 99 >> 100 G4double innerRadiusShield = 0*cm; >> 101 G4double outerRadiusShield = 100*cm; >> 102 G4double hightShield = 5*cm; >> 103 G4double startAngleShield = 0*deg; >> 104 G4double spanningAngleShield = 360*deg; >> 105 >> 106 G4Tubs *aShield = new G4Tubs("aShield", >> 107 innerRadiusShield, >> 108 outerRadiusShield, >> 109 hightShield, >> 110 startAngleShield, >> 111 spanningAngleShield); >> 112 100 // logical parallel cells 113 // logical parallel cells 101 114 102 G4LogicalVolume* aShield_log_imp = new G4Log << 115 G4LogicalVolume *aShield_log = 103 fLogicalVolumeVector.push_back(aShield_log_i << 116 new G4LogicalVolume(aShield, Galactic, "aShield_log"); 104 117 105 // physical parallel cells 118 // physical parallel cells 106 119 107 G4int i = 1; 120 G4int i = 1; 108 G4double startz = -85 * cm; << 121 G4double startz = -85*cm; 109 // for (i=1; i<=18; ++i) { << 122 for (i=1; i<=18; ++i) { 110 for (i = 1; i <= 18; i++) { << 123 111 name = GetCellName(i); 124 name = GetCellName(i); 112 << 125 113 G4double pos_x = 0 * cm; << 126 G4double pos_x = 0*cm; 114 G4double pos_y = 0 * cm; << 127 G4double pos_y = 0*cm; 115 G4double pos_z = startz + (i - 1) * (2 * h << 128 G4double pos_z = startz + (i-1) * (2*hightShield); 116 G4VPhysicalVolume* pvol = new G4PVPlacemen << 129 G4VPhysicalVolume *pvol = 117 << 130 new G4PVPlacement(0, 118 // 0); << 131 G4ThreeVector(pos_x, pos_y, pos_z), 119 G4GeometryCell cell(*pvol, i); << 132 aShield_log, 120 // G4GeometryCell cell(*pvol, 0); << 133 name, >> 134 worldCylinder_log, >> 135 false, >> 136 0); >> 137 G4GeometryCell cell(*pvol, 0); 121 fPVolumeStore.AddPVolume(cell); 138 fPVolumeStore.AddPVolume(cell); 122 } 139 } 123 140 124 // filling the rest of the world volumr behi 141 // filling the rest of the world volumr behind the concrete with 125 // another slob which should get the same im << 142 // another slob which should get the same importance value as the 126 // last slob 143 // last slob 127 innerRadiusShield = 0 * cm; << 144 innerRadiusShield = 0*cm; 128 // outerRadiusShield = 110*cm; exceeds worl << 145 outerRadiusShield = 110*cm; 129 outerRadiusShield = 100 * cm; << 146 hightShield = 10*cm; 130 // heightShield = 10*cm; << 147 startAngleShield = 0*deg; 131 heightShield = 5 * cm; << 148 spanningAngleShield = 360*deg; 132 startAngleShield = 0 * deg; << 149 133 spanningAngleShield = 360 * deg; << 150 G4Tubs *aRest = new G4Tubs("Rest", 134 << 151 innerRadiusShield, 135 G4Tubs* aRest = new G4Tubs("Rest", innerRadi << 152 outerRadiusShield, 136 startAngleShield, << 153 hightShield, 137 << 154 startAngleShield, 138 G4LogicalVolume* aRest_log = new G4LogicalVo << 155 spanningAngleShield); 139 << 156 140 fLogicalVolumeVector.push_back(aRest_log); << 157 G4LogicalVolume *aRest_log = 141 << 158 new G4LogicalVolume(aRest, Galactic, "aRest_log"); 142 name = GetCellName(19); 159 name = GetCellName(19); 143 << 160 144 G4double pos_x = 0 * cm; << 161 G4double pos_x = 0*cm; 145 G4double pos_y = 0 * cm; << 162 G4double pos_y = 0*cm; 146 // G4double pos_z = 100*cm; << 163 G4double pos_z = 100*cm; 147 G4double pos_z = 95 * cm; << 164 G4VPhysicalVolume *pvol = 148 G4VPhysicalVolume* pvol = new G4PVPlacement( << 165 new G4PVPlacement(0, 149 << 166 G4ThreeVector(pos_x, pos_y, pos_z), 150 // 0); << 167 aRest_log, 151 G4GeometryCell cell(*pvol, 19); << 168 name, 152 // G4GeometryCell cell(*pvol, 0); << 169 worldCylinder_log, >> 170 false, >> 171 0); >> 172 G4GeometryCell cell(*pvol, 0); 153 fPVolumeStore.AddPVolume(cell); 173 fPVolumeStore.AddPVolume(cell); 154 << 174 155 SetSensitive(); << 156 } 175 } 157 176 158 //....oooOO0OOooo........oooOO0OOooo........oo << 177 const G4VPhysicalVolume &B03ImportanceDetectorConstruction:: 159 << 178 GetPhysicalVolumeByName(const G4String& name) const { 160 const G4VPhysicalVolume& << 161 B03ImportanceDetectorConstruction::GetPhysical << 162 { << 163 return *fPVolumeStore.GetPVolume(name); 179 return *fPVolumeStore.GetPVolume(name); 164 } 180 } 165 181 166 //....oooOO0OOooo........oooOO0OOooo........oo << 167 182 168 G4String B03ImportanceDetectorConstruction::Li << 183 G4String B03ImportanceDetectorConstruction::ListPhysNamesAsG4String(){ 169 { << 170 G4String names(fPVolumeStore.GetPNames()); 184 G4String names(fPVolumeStore.GetPNames()); 171 return names; 185 return names; 172 } 186 } 173 187 174 //....oooOO0OOooo........oooOO0OOooo........oo << 175 188 176 G4String B03ImportanceDetectorConstruction::Ge << 189 G4String B03ImportanceDetectorConstruction::GetCellName(G4int i) { 177 { << 178 std::ostringstream os; 190 std::ostringstream os; 179 os << "cell_"; 191 os << "cell_"; 180 if (i < 10) { << 192 if (i<10) { 181 os << "0"; 193 os << "0"; 182 } 194 } 183 os << i; << 195 os << i >> 196 << '\0'; 184 G4String name = os.str(); 197 G4String name = os.str(); 185 return name; 198 return name; 186 } 199 } 187 200 188 //....oooOO0OOooo........oooOO0OOooo........oo << 201 G4GeometryCell B03ImportanceDetectorConstruction::GetGeometryCell(G4int i){ 189 << 190 G4GeometryCell B03ImportanceDetectorConstructi << 191 { << 192 G4String name(GetCellName(i)); 202 G4String name(GetCellName(i)); 193 const G4VPhysicalVolume* p = 0; << 203 const G4VPhysicalVolume *p=0; 194 p = fPVolumeStore.GetPVolume(name); 204 p = fPVolumeStore.GetPVolume(name); 195 if (p) { 205 if (p) { 196 return G4GeometryCell(*p, 0); << 206 return G4GeometryCell(*p,0); 197 } 207 } 198 else { 208 else { 199 G4cout << "B03ImportanceDetectorConstructi << 209 G4cout << "B03ImportanceDetectorConstruction::GetGeometryCell: couldn't get G4GeometryCell" << G4endl; 200 << " couldn't get G4GeometryCell" < << 210 return G4GeometryCell(*fWorldVolume,-2); 201 return G4GeometryCell(*fGhostWorld, -2); << 202 } 211 } 203 } 212 } 204 213 205 //....oooOO0OOooo........oooOO0OOooo........oo << 206 << 207 G4VPhysicalVolume& B03ImportanceDetectorConstr << 208 { << 209 return *fGhostWorld; << 210 } << 211 << 212 //....oooOO0OOooo........oooOO0OOooo........oo << 213 << 214 G4VPhysicalVolume* B03ImportanceDetectorConstr << 215 { << 216 return fGhostWorld; << 217 } << 218 << 219 //....oooOO0OOooo........oooOO0OOooo........oo << 220 << 221 void B03ImportanceDetectorConstruction::SetSen << 222 { << 223 // ---------------------------------------- << 224 // The collection names of defined Primiti << 225 // 0 ConcreteSD/Collisions << 226 // 1 ConcreteSD/CollWeight << 227 // 2 ConcreteSD/Population << 228 // 3 ConcreteSD/TrackEnter << 229 // 4 ConcreteSD/SL << 230 // 5 ConcreteSD/SLW << 231 // 6 ConcreteSD/SLWE << 232 // 7 ConcreteSD/SLW_V << 233 // 8 ConcreteSD/SLWE_V << 234 // ---------------------------------------- << 235 << 236 // now moved to ConstructSD() << 237 } << 238 << 239 //....oooOO0OOooo........oooOO0OOooo........oo << 240 void B03ImportanceDetectorConstruction::Constr << 241 { << 242 G4SDManager* SDman = G4SDManager::GetSDMpoin << 243 // << 244 // Sensitive Detector Name << 245 G4String concreteSDname = "ConcreteSD"; << 246 << 247 //------------------------ << 248 // MultiFunctionalDetector << 249 //------------------------ << 250 // << 251 // Define MultiFunctionalDetector with name. << 252 G4MultiFunctionalDetector* MFDet = new G4Mul << 253 SDman->AddNewDetector(MFDet); // Register S << 254 << 255 G4String fltName, particleName; << 256 G4SDParticleFilter* neutronFilter = << 257 new G4SDParticleFilter(fltName = "neutronF << 258 << 259 MFDet->SetFilter(neutronFilter); << 260 << 261 for (std::vector<G4LogicalVolume*>::iterator << 262 it != fLogicalVolumeVector.end(); it++) << 263 { << 264 // (*it)->SetSensitiveDetector(MFDet) << 265 SetSensitiveDetector((*it)->GetName(), MFD << 266 } << 267 214 268 G4String psName; << 215 G4VPhysicalVolume &B03ImportanceDetectorConstruction::GetWorldVolume() const{ 269 G4PSNofCollision* scorer0 = new G4PSNofColli << 216 return *fWorldVolume; 270 MFDet->RegisterPrimitive(scorer0); << 271 << 272 G4PSNofCollision* scorer1 = new G4PSNofColli << 273 scorer1->Weighted(true); << 274 MFDet->RegisterPrimitive(scorer1); << 275 << 276 G4PSPopulation* scorer2 = new G4PSPopulation << 277 MFDet->RegisterPrimitive(scorer2); << 278 << 279 G4PSTrackCounter* scorer3 = new G4PSTrackCou << 280 MFDet->RegisterPrimitive(scorer3); << 281 << 282 G4PSTrackLength* scorer4 = new G4PSTrackLeng << 283 MFDet->RegisterPrimitive(scorer4); << 284 << 285 G4PSTrackLength* scorer5 = new G4PSTrackLeng << 286 scorer5->Weighted(true); << 287 MFDet->RegisterPrimitive(scorer5); << 288 << 289 G4PSTrackLength* scorer6 = new G4PSTrackLeng << 290 scorer6->Weighted(true); << 291 scorer6->MultiplyKineticEnergy(true); << 292 MFDet->RegisterPrimitive(scorer6); << 293 << 294 G4PSTrackLength* scorer7 = new G4PSTrackLeng << 295 scorer7->Weighted(true); << 296 scorer7->DivideByVelocity(true); << 297 MFDet->RegisterPrimitive(scorer7); << 298 << 299 G4PSTrackLength* scorer8 = new G4PSTrackLeng << 300 scorer8->Weighted(true); << 301 scorer8->MultiplyKineticEnergy(true); << 302 scorer8->DivideByVelocity(true); << 303 MFDet->RegisterPrimitive(scorer8); << 304 } 217 } 305 218 306 //....oooOO0OOooo........oooOO0OOooo........oo << 307 219