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