Geant4 Cross Reference |
>> 1 // This code implementation is the intellectual property of >> 2 // the GEANT4 collaboration. >> 3 // >> 4 // By copying, distributing or modifying the Program (or any work >> 5 // based on the Program) you indicate your acceptance of this statement, >> 6 // and all its terms. >> 7 // >> 8 // $Id: G4LogicalVolume.icc,v 1.4 2000/11/01 15:39:33 gcosmo Exp $ >> 9 // GEANT4 tag $Name: geant4-03-01 $ 1 // 10 // 2 // ******************************************* << 3 // * License and Disclaimer << 4 // * << 5 // * The Geant4 software is copyright of th << 6 // * the Geant4 Collaboration. It is provided << 7 // * conditions of the Geant4 Software License << 8 // * LICENSE and available at http://cern.ch/ << 9 // * include a list of copyright holders. << 10 // * << 11 // * Neither the authors of this software syst << 12 // * institutes,nor the agencies providing fin << 13 // * work make any representation or warran << 14 // * regarding this software system or assum << 15 // * use. Please see the license in the file << 16 // * for the full disclaimer and the limitatio << 17 // * << 18 // * This code implementation is the result << 19 // * technical work of the GEANT4 collaboratio << 20 // * By using, copying, modifying or distri << 21 // * any work based on the software) you ag << 22 // * use in resulting scientific publicati << 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* << 25 // 11 // 26 // class G4LogicalVolume inline implementation << 12 // class G4LogicalVolume Inline Implementation file 27 // 13 // 28 // 15.01.13 - G.Cosmo, A.Dotti: Modified for t << 14 // 10.20.97 - P. MoraDeFreitas : Added SetFastSimulation method. 29 // 10.20.97 - P. MoraDeFreitas : Added SetFast << 30 // 05.11.98 - M. Verderi: Add Get/Set methods 15 // 05.11.98 - M. Verderi: Add Get/Set methods for fBiasWeight 31 // 09.11.98 - J.Apostolakis: Changed Magnetic << 16 // 09.11.98 - J. Apostolakis: Changed MagneticField to FieldManager 32 // 12.02.99 - S.Giani: Added set/get methods f 17 // 12.02.99 - S.Giani: Added set/get methods for voxelization quality 33 // 18.04.01 - G.Cosmo: Migrated to STL vector << 18 34 // 17.05.02 - G.Cosmo: Added IsToOptimise() me << 35 // ------------------------------------------- << 36 << 37 // ******************************************* << 38 // GetName << 39 // ******************************************* << 40 // << 41 inline 19 inline 42 const G4String& G4LogicalVolume::GetName() con << 20 G4String G4LogicalVolume::GetName() const 43 { << 21 { 44 return fName; << 22 return fName; 45 } << 23 } 46 24 47 // ******************************************* << 48 // GetInstanceID << 49 // ******************************************* << 50 // << 51 inline 25 inline 52 G4int G4LogicalVolume::GetInstanceID() const << 26 void G4LogicalVolume::SetName(const G4String& pName) 53 { << 27 { 54 return instanceID; << 28 fName=pName; 55 } << 29 } 56 30 57 // ******************************************* << 58 // GetMasterFieldManager << 59 // ******************************************* << 60 // << 61 inline 31 inline 62 G4FieldManager* G4LogicalVolume::GetMasterFiel << 32 G4FieldManager* G4LogicalVolume::GetFieldManager() const 63 { << 33 { 64 return fFieldManager; << 34 return fFieldManager; 65 } << 35 } 66 36 67 // ******************************************* << 68 // GetNoDaughters << 69 // ******************************************* << 70 // << 71 inline 37 inline 72 std::size_t G4LogicalVolume::GetNoDaughters() << 38 G4int G4LogicalVolume::GetNoDaughters() const 73 { << 39 { 74 return fDaughters.size(); << 40 return fDaughters.entries(); 75 } << 41 } 76 42 77 // ******************************************* << 78 // GetDaughter << 79 // ******************************************* << 80 // << 81 inline 43 inline 82 G4VPhysicalVolume* G4LogicalVolume::GetDaughte << 44 G4VPhysicalVolume* G4LogicalVolume::GetDaughter(const G4int i) const 83 { << 45 { 84 return fDaughters[i]; << 46 return fDaughters(i); 85 } << 47 } 86 48 87 // ******************************************* << 88 // GetFastSimulationManager << 89 // ******************************************* << 90 // << 91 inline 49 inline 92 G4FastSimulationManager* G4LogicalVolume::GetF 50 G4FastSimulationManager* G4LogicalVolume::GetFastSimulationManager () const 93 { << 51 { 94 G4FastSimulationManager* fFSM = nullptr; << 52 return fFastSimulationManager; 95 if(fRegion != nullptr) fFSM = fRegion->GetFa << 53 } 96 return fFSM; << 54 >> 55 inline >> 56 void G4LogicalVolume::AddDaughter(G4VPhysicalVolume* pNewDaughter) >> 57 { >> 58 // manual resize operation to avoid Rogue grabbing RW_DEFAULT >> 59 >> 60 fDaughters.resize(fDaughters.entries()+1); >> 61 fDaughters.insert(pNewDaughter); >> 62 >> 63 // Propagates the mother's FastSimulationManager pointer. If we are in >> 64 // the World logical volume, propagates only if pointer != 0. >> 65 // (perhaps someone would like to parametrize all the World volume >> 66 // for a particle type, why not ?). >> 67 >> 68 G4VPhysicalVolume *myPhysical= pNewDaughter->GetMother(); >> 69 G4VPhysicalVolume *pMotherPhys; >> 70 G4LogicalVolume *pDaughterLogical; >> 71 >> 72 if( myPhysical !=0 ){ >> 73 pMotherPhys= myPhysical->GetMother(); >> 74 pDaughterLogical = pNewDaughter->GetLogicalVolume(); >> 75 >> 76 if( (pMotherPhys!=0) || >> 77 ( pMotherPhys==0) && (fFastSimulationManager!=0)) >> 78 { >> 79 if(pDaughterLogical->GetFastSimulationManager() != fFastSimulationManager) >> 80 pDaughterLogical->SetFastSimulationManager(fFastSimulationManager, >> 81 FALSE); >> 82 } >> 83 else >> 84 { >> 85 pDaughterLogical->SetFastSimulationManager(NULL,FALSE); >> 86 } >> 87 } >> 88 >> 89 >> 90 // Propagate the Field Manager, if the daughter has no field Manager. >> 91 >> 92 pDaughterLogical = pNewDaughter->GetLogicalVolume(); >> 93 G4FieldManager* pDaughterFieldManager = >> 94 pDaughterLogical->GetFieldManager(); >> 95 >> 96 if( pDaughterFieldManager == 0 ) >> 97 { >> 98 pDaughterLogical->SetFieldManager(fFieldManager, true); >> 99 } 97 } 100 } 98 101 99 // ******************************************* << 100 // IsDaughter << 101 // ******************************************* << 102 // << 103 inline 102 inline 104 G4bool G4LogicalVolume::IsDaughter(const G4VPh 103 G4bool G4LogicalVolume::IsDaughter(const G4VPhysicalVolume* p) const 105 { << 104 { 106 for (const auto & daughter : fDaughters) << 105 return fDaughters.contains(p); 107 { << 106 } 108 if (*daughter==*p) return true; << 109 } << 110 return false; << 111 } << 112 107 113 // ******************************************* << 114 // CharacteriseDaughters << 115 // ******************************************* << 116 // << 117 inline 108 inline 118 EVolume G4LogicalVolume::CharacteriseDaughters << 109 void G4LogicalVolume::RemoveDaughter(const G4VPhysicalVolume* p) 119 { << 110 { 120 return fDaughtersVolumeType; << 111 fDaughters.remove(p); 121 } << 112 fDaughters.resize(fDaughters.entries()); >> 113 } 122 114 123 // ******************************************* << 124 // DeduceDaughtersType << 125 // ******************************************* << 126 // << 127 inline 115 inline 128 EVolume G4LogicalVolume::DeduceDaughtersType() << 116 G4VSolid* G4LogicalVolume::GetSolid() const 129 { << 117 { 130 EVolume type= kNormal; << 118 return fSolid; 131 G4VPhysicalVolume* pVol; << 119 } 132 << 133 if ( GetNoDaughters() >= 1 ) << 134 { << 135 pVol = GetDaughter(0); << 136 type = pVol->VolumeType(); << 137 } << 138 return type; << 139 } << 140 120 141 // ******************************************* << 142 // GetMasterSolid << 143 // ******************************************* << 144 // << 145 inline 121 inline 146 G4VSolid* G4LogicalVolume::GetMasterSolid() co << 122 void G4LogicalVolume::SetSolid(G4VSolid *pSolid) 147 { << 123 { 148 return fSolid; << 124 assert(pSolid != 0); 149 } << 125 fSolid=pSolid; >> 126 } 150 127 151 // ******************************************* << 152 // GetMasterSensitiveDetector << 153 // ******************************************* << 154 // << 155 inline 128 inline 156 G4VSensitiveDetector* G4LogicalVolume::GetMast << 129 G4Material* G4LogicalVolume::GetMaterial() const 157 { << 130 { 158 return fSensitiveDetector; << 131 return fMaterial; 159 } << 132 } 160 133 161 // ******************************************* << 162 // GetUserLimits << 163 // ******************************************* << 164 // << 165 inline 134 inline 166 G4UserLimits* G4LogicalVolume::GetUserLimits() << 135 void G4LogicalVolume::SetMaterial(G4Material *pMaterial) 167 { << 136 { 168 if(fUserLimits != nullptr) return fUserLimit << 137 // assert(pMaterial != 0); 169 if(fRegion != nullptr) return fRegion->GetUs << 138 fMaterial=pMaterial; 170 return nullptr; << 139 } 171 } << 172 140 173 // ******************************************* << 174 // SetUserLimits << 175 // ******************************************* << 176 // << 177 inline 141 inline 178 void G4LogicalVolume::SetUserLimits(G4UserLimi << 142 G4VSensitiveDetector* G4LogicalVolume::GetSensitiveDetector() const 179 { << 143 { 180 fUserLimits = pULimits; << 144 return fSensitiveDetector; 181 } << 145 } 182 << 183 // ******************************************* << 184 // GetVoxelHeader << 185 // ******************************************* << 186 // << 187 inline << 188 G4SmartVoxelHeader* G4LogicalVolume::GetVoxelH << 189 { << 190 return fVoxel; << 191 } << 192 146 193 // ******************************************* << 194 // SetVoxelHeader << 195 // ******************************************* << 196 // << 197 inline << 198 void G4LogicalVolume::SetVoxelHeader(G4SmartVo << 199 { << 200 fVoxel = pVoxel; << 201 } << 202 << 203 // ******************************************* << 204 // GetSmartless << 205 // ******************************************* << 206 // << 207 inline 147 inline 208 G4double G4LogicalVolume::GetSmartless() const << 148 void G4LogicalVolume::SetSensitiveDetector(G4VSensitiveDetector *pSDetector) 209 { << 149 { 210 return fSmartless; << 150 fSensitiveDetector=pSDetector; 211 } << 151 } 212 152 213 // ******************************************* << 214 // SetSmartless << 215 // ******************************************* << 216 // << 217 inline 153 inline 218 void G4LogicalVolume::SetSmartless(G4double sm << 154 G4UserLimits* G4LogicalVolume::GetUserLimits() const 219 { << 155 { 220 fSmartless = smt; << 156 return fUserLimits; 221 } << 157 } 222 158 223 // ******************************************* << 224 // IsToOptimise << 225 // ******************************************* << 226 // << 227 inline 159 inline 228 G4bool G4LogicalVolume::IsToOptimise() const << 160 void G4LogicalVolume::SetUserLimits(G4UserLimits *pULimits) 229 { << 161 { 230 return fOptimise; << 162 fUserLimits=pULimits; 231 } << 163 } 232 164 233 // ******************************************* << 234 // SetOptimisation << 235 // ******************************************* << 236 // << 237 inline 165 inline 238 void G4LogicalVolume::SetOptimisation(G4bool o << 166 G4SmartVoxelHeader* G4LogicalVolume::GetVoxelHeader() const 239 { << 167 { 240 fOptimise = optim; << 168 return fVoxel; 241 } << 169 } 242 170 243 // ******************************************* << 244 // IsRootRegion << 245 // ******************************************* << 246 // << 247 inline 171 inline 248 G4bool G4LogicalVolume::IsRootRegion() const << 172 void G4LogicalVolume::SetVoxelHeader(G4SmartVoxelHeader *pVoxel) 249 { << 173 { 250 return fRootRegion; << 174 fVoxel=pVoxel; 251 } << 175 } 252 176 253 // ******************************************* << 254 // SetRegionRootFlag << 255 // ******************************************* << 256 // << 257 inline 177 inline 258 void G4LogicalVolume::SetRegionRootFlag(G4bool << 178 G4double G4LogicalVolume::GetSmartless() 259 { << 179 { 260 fRootRegion = rreg; << 180 return fSmartless; 261 } << 181 } 262 182 263 // ******************************************* << 264 // IsRegion << 265 // ******************************************* << 266 // << 267 inline 183 inline 268 G4bool G4LogicalVolume::IsRegion() const << 184 void G4LogicalVolume::SetSmartless(G4double s) 269 { << 185 { 270 G4bool reg = false; << 186 fSmartless=s; 271 if (fRegion != nullptr) reg = true; << 187 } 272 return reg; << 188 273 } << 274 << 275 // ******************************************* << 276 // SetRegion << 277 // ******************************************* << 278 // << 279 inline 189 inline 280 void G4LogicalVolume::SetRegion(G4Region* reg) << 190 G4bool G4LogicalVolume::operator == ( const G4LogicalVolume& lv) const 281 { << 191 { 282 fRegion = reg; << 192 return (this==&lv) ? true : false; 283 } << 193 } 284 194 285 // ******************************************* << 286 // GetRegion << 287 // ******************************************* << 288 // << 289 inline 195 inline 290 G4Region* G4LogicalVolume::GetRegion() const << 196 const G4VisAttributes* G4LogicalVolume::GetVisAttributes () const 291 { << 197 { 292 return fRegion; << 198 return fVisAttributes; 293 } << 199 } 294 200 295 // ******************************************* << 296 // PropagateRegion << 297 // ******************************************* << 298 // << 299 inline 201 inline 300 void G4LogicalVolume::PropagateRegion() << 202 void G4LogicalVolume::SetVisAttributes (const G4VisAttributes* pVA) 301 { << 203 { 302 fRegion->ScanVolumeTree(this, true); << 204 fVisAttributes = pVA; 303 } << 205 } 304 206 305 // ******************************************* << 306 // Lock << 307 // ******************************************* << 308 // << 309 inline 207 inline 310 void G4LogicalVolume::Lock() << 208 void G4LogicalVolume::SetVisAttributes (const G4VisAttributes& VA) 311 { << 209 { 312 fLock = true; << 210 fVisAttributes = &VA; 313 } << 211 } 314 212 315 // ******************************************* << 213 inline void 316 // Operator == << 214 G4LogicalVolume::BecomeEnvelopeForFastSimulation(G4FastSimulationManager* pPA) 317 // ******************************************* << 215 { 318 // << 216 SetFastSimulationManager(pPA,TRUE); 319 inline << 217 } 320 G4bool G4LogicalVolume::operator == ( const G4 << 321 { << 322 return this==&lv; << 323 } << 324 218 325 // ******************************************* << 326 // SetBiasWeight << 327 // ******************************************* << 328 // << 329 inline 219 inline 330 void G4LogicalVolume::SetBiasWeight(G4double w << 220 void G4LogicalVolume::SetBiasWeight(G4double w) 331 { << 221 { 332 fBiasWeight = weight; << 222 fBiasWeight = w; 333 } << 223 } 334 224 335 // ******************************************* << 336 // GetBiasWeight << 337 // ******************************************* << 338 // << 339 inline 225 inline 340 G4double G4LogicalVolume::GetBiasWeight() cons 226 G4double G4LogicalVolume::GetBiasWeight() const 341 { << 227 { 342 return fBiasWeight; << 228 return fBiasWeight; 343 } << 229 } 344 << 345 // ******************************************* << 346 // GetVisAttributes << 347 // ******************************************* << 348 // << 349 inline << 350 const G4VisAttributes* G4LogicalVolume::GetVis << 351 { << 352 return fVisAttributes.get(); << 353 } << 354 230