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 26 /// \file biasing/B03/src/B03ImportanceDetectorConstruction.cc 27 /// \brief Implementation of the B03Importance 27 /// \brief Implementation of the B03ImportanceDetectorConstruction class 28 // 28 // 29 // 29 // 30 // 30 // 31 31 >> 32 #include "globals.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" >> 38 #include "G4Tubs.hh" >> 39 #include "G4LogicalVolume.hh" >> 40 #include "G4ThreeVector.hh" 36 #include "G4PVPlacement.hh" 41 #include "G4PVPlacement.hh" 37 #include "G4PhysicalConstants.hh" 42 #include "G4PhysicalConstants.hh" 38 #include "G4SystemOfUnits.hh" 43 #include "G4SystemOfUnits.hh" 39 #include "G4ThreeVector.hh" << 40 #include "G4Tubs.hh" << 41 #include "globals.hh" << 42 << 43 #include <sstream> << 44 44 45 // For Primitive Scorers 45 // For Primitive Scorers >> 46 #include "G4SDManager.hh" 46 #include "G4MultiFunctionalDetector.hh" 47 #include "G4MultiFunctionalDetector.hh" >> 48 #include "G4SDParticleFilter.hh" 47 #include "G4PSNofCollision.hh" 49 #include "G4PSNofCollision.hh" 48 #include "G4PSPopulation.hh" 50 #include "G4PSPopulation.hh" 49 #include "G4PSTrackCounter.hh" 51 #include "G4PSTrackCounter.hh" 50 #include "G4PSTrackLength.hh" 52 #include "G4PSTrackLength.hh" 51 #include "G4SDManager.hh" << 52 #include "G4SDParticleFilter.hh" << 53 53 54 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 55 56 B03ImportanceDetectorConstruction::B03Importan << 56 B03ImportanceDetectorConstruction:: 57 : G4VUserParallelWorld(worldName), fLogicalV << 57 B03ImportanceDetectorConstruction(G4String worldName) >> 58 :G4VUserParallelWorld(worldName),fLogicalVolumeVector() 58 { 59 { 59 // Construct(); 60 // Construct(); 60 } 61 } 61 62 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 64 64 B03ImportanceDetectorConstruction::~B03Importa 65 B03ImportanceDetectorConstruction::~B03ImportanceDetectorConstruction() 65 { 66 { 66 fLogicalVolumeVector.clear(); 67 fLogicalVolumeVector.clear(); 67 } 68 } 68 69 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 71 71 void B03ImportanceDetectorConstruction::Constr 72 void B03ImportanceDetectorConstruction::Construct() 72 { << 73 { 73 G4cout << " constructing parallel world " << 74 G4cout << " constructing parallel world " << G4endl; 74 75 75 G4Material* dummyMat = 0; << 76 G4Material* dummyMat = 0; 76 77 77 // GetWorld methods create a clone of the ma << 78 //GetWorld methods create a clone of the mass world to the parallel world (!) 78 // via the transportation manager << 79 // via the transportation manager 79 fGhostWorld = GetWorld(); 80 fGhostWorld = GetWorld(); 80 G4cout << " B03ImportanceDetectorConstructio << 81 G4cout << " B03ImportanceDetectorConstruction:: ghostWorldName = " 81 << G4endl; << 82 << fGhostWorld->GetName() << G4endl; 82 G4LogicalVolume* worldLogical = fGhostWorld- 83 G4LogicalVolume* worldLogical = fGhostWorld->GetLogicalVolume(); 83 fLogicalVolumeVector.push_back(worldLogical) 84 fLogicalVolumeVector.push_back(worldLogical); 84 85 85 G4String name("none"); 86 G4String name("none"); 86 // fPVolumeStore.AddPVolume(G4GeometryCell( 87 // fPVolumeStore.AddPVolume(G4GeometryCell(*pWorldVolume, 0)); 87 fPVolumeStore.AddPVolume(G4GeometryCell(*fGh 88 fPVolumeStore.AddPVolume(G4GeometryCell(*fGhostWorld, 0)); 88 89 89 // creating 18 slobs of 10 cm thicknes 90 // creating 18 slobs of 10 cm thicknes 90 91 91 G4double innerRadiusShield = 0 * cm; << 92 G4double innerRadiusShield = 0*cm; 92 G4double outerRadiusShield = 100 * cm; << 93 G4double outerRadiusShield = 100*cm; 93 G4double heightShield = 5 * cm; << 94 G4double heightShield = 5*cm; 94 G4double startAngleShield = 0 * deg; << 95 G4double startAngleShield = 0*deg; 95 G4double spanningAngleShield = 360 * deg; << 96 G4double spanningAngleShield = 360*deg; 96 << 97 97 G4Tubs* aShield = new G4Tubs("aShield", inne << 98 G4Tubs *aShield = new G4Tubs("aShield", 98 startAngleShiel << 99 innerRadiusShield, 99 << 100 outerRadiusShield, >> 101 heightShield, >> 102 startAngleShield, >> 103 spanningAngleShield); >> 104 100 // logical parallel cells 105 // logical parallel cells 101 106 102 G4LogicalVolume* aShield_log_imp = new G4Log << 107 G4LogicalVolume *aShield_log_imp = >> 108 new G4LogicalVolume(aShield, dummyMat, "aShield_log_imp"); 103 fLogicalVolumeVector.push_back(aShield_log_i 109 fLogicalVolumeVector.push_back(aShield_log_imp); 104 110 105 // physical parallel cells 111 // physical parallel cells 106 112 107 G4int i = 1; 113 G4int i = 1; 108 G4double startz = -85 * cm; << 114 G4double startz = -85*cm; 109 // for (i=1; i<=18; ++i) { 115 // for (i=1; i<=18; ++i) { 110 for (i = 1; i <= 18; i++) { << 116 for (i=1; i<=18; i++) { >> 117 111 name = GetCellName(i); 118 name = GetCellName(i); 112 << 119 113 G4double pos_x = 0 * cm; << 120 G4double pos_x = 0*cm; 114 G4double pos_y = 0 * cm; << 121 G4double pos_y = 0*cm; 115 G4double pos_z = startz + (i - 1) * (2 * h << 122 G4double pos_z = startz + (i-1) * (2*heightShield); 116 G4VPhysicalVolume* pvol = new G4PVPlacemen << 123 G4VPhysicalVolume *pvol = 117 << 124 new G4PVPlacement(0, >> 125 G4ThreeVector(pos_x, pos_y, pos_z), >> 126 aShield_log_imp, >> 127 name, >> 128 worldLogical, >> 129 false, >> 130 i); 118 // 0); 131 // 0); 119 G4GeometryCell cell(*pvol, i); 132 G4GeometryCell cell(*pvol, i); 120 // G4GeometryCell cell(*pvol, 0); 133 // G4GeometryCell cell(*pvol, 0); 121 fPVolumeStore.AddPVolume(cell); 134 fPVolumeStore.AddPVolume(cell); 122 } 135 } 123 136 124 // filling the rest of the world volumr behi 137 // filling the rest of the world volumr behind the concrete with 125 // another slob which should get the same im << 138 // another slob which should get the same importance value as the 126 // last slob 139 // last slob 127 innerRadiusShield = 0 * cm; << 140 innerRadiusShield = 0*cm; 128 // outerRadiusShield = 110*cm; exceeds worl 141 // outerRadiusShield = 110*cm; exceeds world volume!!!! 129 outerRadiusShield = 100 * cm; << 142 outerRadiusShield = 100*cm; 130 // heightShield = 10*cm; 143 // heightShield = 10*cm; 131 heightShield = 5 * cm; << 144 heightShield = 5*cm; 132 startAngleShield = 0 * deg; << 145 startAngleShield = 0*deg; 133 spanningAngleShield = 360 * deg; << 146 spanningAngleShield = 360*deg; 134 << 147 135 G4Tubs* aRest = new G4Tubs("Rest", innerRadi << 148 G4Tubs *aRest = new G4Tubs("Rest", 136 startAngleShield, << 149 innerRadiusShield, 137 << 150 outerRadiusShield, 138 G4LogicalVolume* aRest_log = new G4LogicalVo << 151 heightShield, >> 152 startAngleShield, >> 153 spanningAngleShield); >> 154 >> 155 G4LogicalVolume *aRest_log = >> 156 new G4LogicalVolume(aRest, dummyMat, "aRest_log"); 139 157 140 fLogicalVolumeVector.push_back(aRest_log); 158 fLogicalVolumeVector.push_back(aRest_log); 141 159 142 name = GetCellName(19); 160 name = GetCellName(19); 143 << 161 144 G4double pos_x = 0 * cm; << 162 G4double pos_x = 0*cm; 145 G4double pos_y = 0 * cm; << 163 G4double pos_y = 0*cm; 146 // G4double pos_z = 100*cm; 164 // G4double pos_z = 100*cm; 147 G4double pos_z = 95 * cm; << 165 G4double pos_z = 95*cm; 148 G4VPhysicalVolume* pvol = new G4PVPlacement( << 166 G4VPhysicalVolume *pvol = 149 << 167 new G4PVPlacement(0, >> 168 G4ThreeVector(pos_x, pos_y, pos_z), >> 169 aRest_log, >> 170 name, >> 171 worldLogical, >> 172 false, >> 173 19); 150 // 0); 174 // 0); 151 G4GeometryCell cell(*pvol, 19); 175 G4GeometryCell cell(*pvol, 19); 152 // G4GeometryCell cell(*pvol, 0); 176 // G4GeometryCell cell(*pvol, 0); 153 fPVolumeStore.AddPVolume(cell); 177 fPVolumeStore.AddPVolume(cell); 154 178 155 SetSensitive(); 179 SetSensitive(); >> 180 156 } 181 } 157 182 158 //....oooOO0OOooo........oooOO0OOooo........oo 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 184 160 const G4VPhysicalVolume& << 185 const G4VPhysicalVolume &B03ImportanceDetectorConstruction:: 161 B03ImportanceDetectorConstruction::GetPhysical << 186 GetPhysicalVolumeByName(const G4String& name) const { 162 { << 163 return *fPVolumeStore.GetPVolume(name); 187 return *fPVolumeStore.GetPVolume(name); 164 } 188 } 165 189 166 //....oooOO0OOooo........oooOO0OOooo........oo 190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 167 191 168 G4String B03ImportanceDetectorConstruction::Li << 192 G4String B03ImportanceDetectorConstruction::ListPhysNamesAsG4String(){ 169 { << 170 G4String names(fPVolumeStore.GetPNames()); 193 G4String names(fPVolumeStore.GetPNames()); 171 return names; 194 return names; 172 } 195 } 173 196 174 //....oooOO0OOooo........oooOO0OOooo........oo 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 175 198 176 G4String B03ImportanceDetectorConstruction::Ge << 199 G4String B03ImportanceDetectorConstruction::GetCellName(G4int i) { 177 { << 178 std::ostringstream os; 200 std::ostringstream os; 179 os << "cell_"; 201 os << "cell_"; 180 if (i < 10) { << 202 if (i<10) { 181 os << "0"; 203 os << "0"; 182 } 204 } 183 os << i; 205 os << i; 184 G4String name = os.str(); 206 G4String name = os.str(); 185 return name; 207 return name; 186 } 208 } 187 209 188 //....oooOO0OOooo........oooOO0OOooo........oo 210 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 189 211 190 G4GeometryCell B03ImportanceDetectorConstructi << 212 G4GeometryCell B03ImportanceDetectorConstruction::GetGeometryCell(G4int i){ 191 { << 192 G4String name(GetCellName(i)); 213 G4String name(GetCellName(i)); 193 const G4VPhysicalVolume* p = 0; << 214 const G4VPhysicalVolume *p=0; 194 p = fPVolumeStore.GetPVolume(name); 215 p = fPVolumeStore.GetPVolume(name); 195 if (p) { 216 if (p) { 196 return G4GeometryCell(*p, 0); << 217 return G4GeometryCell(*p,0); 197 } 218 } 198 else { 219 else { 199 G4cout << "B03ImportanceDetectorConstructi 220 G4cout << "B03ImportanceDetectorConstruction::GetGeometryCell: " << G4endl 200 << " couldn't get G4GeometryCell" < 221 << " couldn't get G4GeometryCell" << G4endl; 201 return G4GeometryCell(*fGhostWorld, -2); << 222 return G4GeometryCell(*fGhostWorld,-2); 202 } 223 } 203 } 224 } 204 225 205 //....oooOO0OOooo........oooOO0OOooo........oo 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 206 227 207 G4VPhysicalVolume& B03ImportanceDetectorConstr << 228 G4VPhysicalVolume &B03ImportanceDetectorConstruction:: 208 { << 229 GetWorldVolumeAddress() const{ 209 return *fGhostWorld; << 230 return *fGhostWorld; 210 } 231 } 211 232 212 //....oooOO0OOooo........oooOO0OOooo........oo 233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 213 234 214 G4VPhysicalVolume* B03ImportanceDetectorConstr << 235 G4VPhysicalVolume *B03ImportanceDetectorConstruction::GetWorldVolume() { 215 { << 216 return fGhostWorld; 236 return fGhostWorld; 217 } 237 } 218 238 219 //....oooOO0OOooo........oooOO0OOooo........oo 239 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 220 240 221 void B03ImportanceDetectorConstruction::SetSen << 241 void B03ImportanceDetectorConstruction::SetSensitive(){ 222 { << 242 223 // ---------------------------------------- 243 // ------------------------------------------------- 224 // The collection names of defined Primiti 244 // The collection names of defined Primitives are 225 // 0 ConcreteSD/Collisions 245 // 0 ConcreteSD/Collisions 226 // 1 ConcreteSD/CollWeight 246 // 1 ConcreteSD/CollWeight 227 // 2 ConcreteSD/Population 247 // 2 ConcreteSD/Population 228 // 3 ConcreteSD/TrackEnter 248 // 3 ConcreteSD/TrackEnter 229 // 4 ConcreteSD/SL 249 // 4 ConcreteSD/SL 230 // 5 ConcreteSD/SLW 250 // 5 ConcreteSD/SLW 231 // 6 ConcreteSD/SLWE 251 // 6 ConcreteSD/SLWE 232 // 7 ConcreteSD/SLW_V 252 // 7 ConcreteSD/SLW_V 233 // 8 ConcreteSD/SLWE_V 253 // 8 ConcreteSD/SLWE_V 234 // ---------------------------------------- 254 // ------------------------------------------------- 235 255 236 // now moved to ConstructSD() << 256 //now moved to ConstructSD() >> 257 237 } 258 } 238 259 239 //....oooOO0OOooo........oooOO0OOooo........oo 260 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 240 void B03ImportanceDetectorConstruction::Constr 261 void B03ImportanceDetectorConstruction::ConstructSD() 241 { 262 { >> 263 242 G4SDManager* SDman = G4SDManager::GetSDMpoin 264 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 243 // 265 // 244 // Sensitive Detector Name 266 // Sensitive Detector Name 245 G4String concreteSDname = "ConcreteSD"; 267 G4String concreteSDname = "ConcreteSD"; 246 268 247 //------------------------ 269 //------------------------ 248 // MultiFunctionalDetector 270 // MultiFunctionalDetector 249 //------------------------ 271 //------------------------ 250 // 272 // 251 // Define MultiFunctionalDetector with name. 273 // Define MultiFunctionalDetector with name. 252 G4MultiFunctionalDetector* MFDet = new G4Mul << 274 G4MultiFunctionalDetector* MFDet = 253 SDman->AddNewDetector(MFDet); // Register S << 275 new G4MultiFunctionalDetector(concreteSDname); 254 << 276 SDman->AddNewDetector( MFDet ); // Register SD to SDManager 255 G4String fltName, particleName; << 277 256 G4SDParticleFilter* neutronFilter = << 278 G4String fltName,particleName; 257 new G4SDParticleFilter(fltName = "neutronF << 279 G4SDParticleFilter* neutronFilter = >> 280 new G4SDParticleFilter(fltName="neutronFilter", particleName="neutron"); 258 281 259 MFDet->SetFilter(neutronFilter); 282 MFDet->SetFilter(neutronFilter); 260 283 261 for (std::vector<G4LogicalVolume*>::iterator << 284 for (std::vector<G4LogicalVolume *>::iterator it = 262 it != fLogicalVolumeVector.end(); it++) << 285 fLogicalVolumeVector.begin(); 263 { << 286 it != fLogicalVolumeVector.end(); it++){ 264 // (*it)->SetSensitiveDetector(MFDet) 287 // (*it)->SetSensitiveDetector(MFDet); 265 SetSensitiveDetector((*it)->GetName(), MFD 288 SetSensitiveDetector((*it)->GetName(), MFDet); 266 } 289 } 267 290 268 G4String psName; 291 G4String psName; 269 G4PSNofCollision* scorer0 = new G4PSNofColli << 292 G4PSNofCollision* scorer0 = new G4PSNofCollision(psName="Collisions"); 270 MFDet->RegisterPrimitive(scorer0); 293 MFDet->RegisterPrimitive(scorer0); 271 294 272 G4PSNofCollision* scorer1 = new G4PSNofColli << 295 G4PSNofCollision* scorer1 = new G4PSNofCollision(psName="CollWeight"); 273 scorer1->Weighted(true); 296 scorer1->Weighted(true); 274 MFDet->RegisterPrimitive(scorer1); 297 MFDet->RegisterPrimitive(scorer1); 275 298 276 G4PSPopulation* scorer2 = new G4PSPopulation << 299 G4PSPopulation* scorer2 = new G4PSPopulation(psName="Population"); 277 MFDet->RegisterPrimitive(scorer2); 300 MFDet->RegisterPrimitive(scorer2); 278 301 279 G4PSTrackCounter* scorer3 = new G4PSTrackCou << 302 G4PSTrackCounter* scorer3 = >> 303 new G4PSTrackCounter(psName="TrackEnter",fCurrent_In); 280 MFDet->RegisterPrimitive(scorer3); 304 MFDet->RegisterPrimitive(scorer3); 281 305 282 G4PSTrackLength* scorer4 = new G4PSTrackLeng << 306 G4PSTrackLength* scorer4 = new G4PSTrackLength(psName="SL"); 283 MFDet->RegisterPrimitive(scorer4); 307 MFDet->RegisterPrimitive(scorer4); 284 308 285 G4PSTrackLength* scorer5 = new G4PSTrackLeng << 309 G4PSTrackLength* scorer5 = new G4PSTrackLength(psName="SLW"); 286 scorer5->Weighted(true); 310 scorer5->Weighted(true); 287 MFDet->RegisterPrimitive(scorer5); 311 MFDet->RegisterPrimitive(scorer5); 288 312 289 G4PSTrackLength* scorer6 = new G4PSTrackLeng << 313 G4PSTrackLength* scorer6 = new G4PSTrackLength(psName="SLWE"); 290 scorer6->Weighted(true); 314 scorer6->Weighted(true); 291 scorer6->MultiplyKineticEnergy(true); 315 scorer6->MultiplyKineticEnergy(true); 292 MFDet->RegisterPrimitive(scorer6); 316 MFDet->RegisterPrimitive(scorer6); 293 317 294 G4PSTrackLength* scorer7 = new G4PSTrackLeng << 318 G4PSTrackLength* scorer7 = new G4PSTrackLength(psName="SLW_V"); 295 scorer7->Weighted(true); 319 scorer7->Weighted(true); 296 scorer7->DivideByVelocity(true); 320 scorer7->DivideByVelocity(true); 297 MFDet->RegisterPrimitive(scorer7); 321 MFDet->RegisterPrimitive(scorer7); 298 322 299 G4PSTrackLength* scorer8 = new G4PSTrackLeng << 323 G4PSTrackLength* scorer8 = new G4PSTrackLength(psName="SLWE_V"); 300 scorer8->Weighted(true); 324 scorer8->Weighted(true); 301 scorer8->MultiplyKineticEnergy(true); 325 scorer8->MultiplyKineticEnergy(true); 302 scorer8->DivideByVelocity(true); 326 scorer8->DivideByVelocity(true); 303 MFDet->RegisterPrimitive(scorer8); 327 MFDet->RegisterPrimitive(scorer8); 304 } 328 } 305 329 306 //....oooOO0OOooo........oooOO0OOooo........oo 330 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 307 331