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 // G4VDivisionParameterisation implementation << 26 // >> 27 // $Id: G4VDivisionParameterisation.cc 92625 2015-09-09 12:34:07Z gcosmo $ >> 28 // >> 29 // class G4VDivisionParameterisation Implementation file 27 // 30 // 28 // 26.05.03 - P.Arce, Initial version 31 // 26.05.03 - P.Arce, Initial version 29 // 08.04.04 - I.Hrivnacova, Implemented reflec 32 // 08.04.04 - I.Hrivnacova, Implemented reflection 30 // 21.04.10 - M.Asai, Added gaps 33 // 21.04.10 - M.Asai, Added gaps 31 // ------------------------------------------- 34 // -------------------------------------------------------------------- 32 35 33 #include "G4VDivisionParameterisation.hh" 36 #include "G4VDivisionParameterisation.hh" 34 #include "G4VSolid.hh" 37 #include "G4VSolid.hh" 35 #include "G4VPhysicalVolume.hh" 38 #include "G4VPhysicalVolume.hh" 36 #include "G4RotationMatrix.hh" 39 #include "G4RotationMatrix.hh" 37 #include "G4ReflectedSolid.hh" 40 #include "G4ReflectedSolid.hh" 38 #include "G4GeometryTolerance.hh" 41 #include "G4GeometryTolerance.hh" 39 #include "G4AutoDelete.hh" 42 #include "G4AutoDelete.hh" 40 43 41 const G4int G4VDivisionParameterisation::verbo 44 const G4int G4VDivisionParameterisation::verbose = 5; 42 G4ThreadLocal G4RotationMatrix* G4VDivisionPar << 45 G4ThreadLocal G4RotationMatrix* G4VDivisionParameterisation::fRot = 0; 43 46 44 //-------------------------------------------- 47 //-------------------------------------------------------------------------- 45 G4VDivisionParameterisation:: 48 G4VDivisionParameterisation:: 46 G4VDivisionParameterisation( EAxis axis, G4int 49 G4VDivisionParameterisation( EAxis axis, G4int nDiv, 47 G4double step, G4 50 G4double step, G4double offset, 48 DivisionType divT 51 DivisionType divType, G4VSolid* motherSolid ) 49 : faxis(axis), fnDiv( nDiv), fwidth(step), f 52 : faxis(axis), fnDiv( nDiv), fwidth(step), foffset(offset), 50 fDivisionType(divType), fmotherSolid( moth << 53 fDivisionType(divType), fmotherSolid( motherSolid ), fReflectedSolid(false), >> 54 fDeleteSolid(false), theVoluFirstCopyNo(1), fhgap(0.) 51 { 55 { 52 #ifdef G4DIVDEBUG 56 #ifdef G4DIVDEBUG 53 if (verbose >= 1) 57 if (verbose >= 1) 54 { 58 { 55 G4cout << " G4VDivisionParameterisation n 59 G4cout << " G4VDivisionParameterisation no divisions " << fnDiv 56 << " = " << nDiv << G4endl 60 << " = " << nDiv << G4endl 57 << " offset " << foffset << " = " < 61 << " offset " << foffset << " = " << offset << G4endl 58 << " step " << fwidth << " = " << s 62 << " step " << fwidth << " = " << step << G4endl; 59 } 63 } 60 #endif 64 #endif 61 kCarTolerance = G4GeometryTolerance::GetInst 65 kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance(); 62 } 66 } 63 67 64 //-------------------------------------------- 68 //-------------------------------------------------------------------------- 65 G4VDivisionParameterisation::~G4VDivisionParam 69 G4VDivisionParameterisation::~G4VDivisionParameterisation() 66 { 70 { 67 if (fDeleteSolid) { delete fmotherSolid; } << 71 if (fDeleteSolid) delete fmotherSolid; 68 } 72 } 69 73 70 //-------------------------------------------- 74 //-------------------------------------------------------------------------- 71 G4VSolid* 75 G4VSolid* 72 G4VDivisionParameterisation:: 76 G4VDivisionParameterisation:: 73 ComputeSolid( const G4int i, G4VPhysicalVolume 77 ComputeSolid( const G4int i, G4VPhysicalVolume* pv ) 74 { 78 { 75 G4VSolid* solid = G4VPVParameterisation::Com 79 G4VSolid* solid = G4VPVParameterisation::ComputeSolid(i, pv); 76 if (solid->GetEntityType() == "G4ReflectedSo 80 if (solid->GetEntityType() == "G4ReflectedSolid") 77 { 81 { 78 solid = ((G4ReflectedSolid*)solid)->GetCon 82 solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid(); 79 } 83 } 80 return solid; 84 return solid; 81 } 85 } 82 86 83 //-------------------------------------------- 87 //-------------------------------------------------------------------------- 84 void 88 void 85 G4VDivisionParameterisation:: 89 G4VDivisionParameterisation:: 86 ChangeRotMatrix( G4VPhysicalVolume* physVol, G << 90 ChangeRotMatrix( G4VPhysicalVolume *physVol, G4double rotZ ) const 87 { 91 { 88 if (fRot == nullptr) << 92 if (!fRot) 89 { 93 { 90 fRot = new G4RotationMatrix(); 94 fRot = new G4RotationMatrix(); 91 G4AutoDelete::Register(fRot); 95 G4AutoDelete::Register(fRot); 92 } 96 } 93 fRot->rotateZ( rotZ ); 97 fRot->rotateZ( rotZ ); 94 physVol->SetRotation(fRot); 98 physVol->SetRotation(fRot); 95 } 99 } 96 100 97 //-------------------------------------------- 101 //-------------------------------------------------------------------------- 98 G4int 102 G4int 99 G4VDivisionParameterisation:: 103 G4VDivisionParameterisation:: 100 CalculateNDiv( G4double motherDim, G4double wi 104 CalculateNDiv( G4double motherDim, G4double width, G4double offset ) const 101 { 105 { 102 #ifdef G4DIVDEBUG 106 #ifdef G4DIVDEBUG 103 G4cout << " G4VDivisionParameterisation::Cal 107 G4cout << " G4VDivisionParameterisation::CalculateNDiv: " 104 << ( motherDim - offset ) / width 108 << ( motherDim - offset ) / width 105 << " Motherdim: " << motherDim << ", 109 << " Motherdim: " << motherDim << ", Offset: " << offset 106 << ", Width: " << width << G4endl; 110 << ", Width: " << width << G4endl; 107 #endif 111 #endif 108 112 109 return G4int( ( motherDim - offset ) / width 113 return G4int( ( motherDim - offset ) / width ); 110 } 114 } 111 115 112 //-------------------------------------------- 116 //-------------------------------------------------------------------------- 113 G4double 117 G4double 114 G4VDivisionParameterisation:: 118 G4VDivisionParameterisation:: 115 CalculateWidth( G4double motherDim, G4int nDiv 119 CalculateWidth( G4double motherDim, G4int nDiv, G4double offset ) const 116 { 120 { 117 #ifdef G4DIVDEBUG 121 #ifdef G4DIVDEBUG 118 G4cout << " G4VDivisionParameterisation::Cal 122 G4cout << " G4VDivisionParameterisation::CalculateWidth: " 119 << ( motherDim - offset ) / nDiv 123 << ( motherDim - offset ) / nDiv 120 << ", Motherdim: " << motherDim << ", 124 << ", Motherdim: " << motherDim << ", Offset: " << offset 121 << ", Number of divisions: " << nDiv 125 << ", Number of divisions: " << nDiv << G4endl; 122 #endif 126 #endif 123 127 124 return ( motherDim - offset ) / nDiv; 128 return ( motherDim - offset ) / nDiv; 125 } 129 } 126 130 127 //-------------------------------------------- 131 //-------------------------------------------------------------------------- 128 void G4VDivisionParameterisation::CheckParamet 132 void G4VDivisionParameterisation::CheckParametersValidity() 129 { 133 { 130 G4double maxPar = GetMaxParameter(); 134 G4double maxPar = GetMaxParameter(); 131 CheckOffset( maxPar ); 135 CheckOffset( maxPar ); 132 CheckNDivAndWidth( maxPar ); 136 CheckNDivAndWidth( maxPar ); 133 } 137 } 134 138 135 //-------------------------------------------- 139 //-------------------------------------------------------------------------- 136 void G4VDivisionParameterisation::CheckOffset( 140 void G4VDivisionParameterisation::CheckOffset( G4double maxPar ) 137 { 141 { 138 if( foffset >= maxPar ) 142 if( foffset >= maxPar ) 139 { 143 { 140 std::ostringstream message; 144 std::ostringstream message; 141 message << "Configuration not supported." 145 message << "Configuration not supported." << G4endl 142 << "Division of solid " << fmother 146 << "Division of solid " << fmotherSolid->GetName() 143 << " has too big offset = " << G4e 147 << " has too big offset = " << G4endl 144 << " " << foffset << " > " 148 << " " << foffset << " > " << maxPar << " !"; 145 G4Exception("G4VDivisionParameterisation:: 149 G4Exception("G4VDivisionParameterisation::CheckOffset()", 146 "GeomDiv0001", FatalException, 150 "GeomDiv0001", FatalException, message); 147 } 151 } 148 } 152 } 149 153 150 //-------------------------------------------- 154 //-------------------------------------------------------------------------- 151 void G4VDivisionParameterisation::CheckNDivAnd 155 void G4VDivisionParameterisation::CheckNDivAndWidth( G4double maxPar ) 152 { 156 { 153 if( (fDivisionType == DivNDIVandWIDTH) 157 if( (fDivisionType == DivNDIVandWIDTH) 154 && (foffset + fwidth*fnDiv - maxPar > kC 158 && (foffset + fwidth*fnDiv - maxPar > kCarTolerance ) ) 155 { 159 { 156 std::ostringstream message; 160 std::ostringstream message; 157 message << "Configuration not supported." 161 message << "Configuration not supported." << G4endl 158 << "Division of solid " << fmother 162 << "Division of solid " << fmotherSolid->GetName() 159 << " has too big offset + width*nDi 163 << " has too big offset + width*nDiv = " << G4endl 160 << " " << foffset + fwidth*f 164 << " " << foffset + fwidth*fnDiv << " > " 161 << foffset << ". Width = " 165 << foffset << ". Width = " 162 << G4endl 166 << G4endl 163 << " " << fwidth << ". nDiv 167 << " " << fwidth << ". nDiv = " << fnDiv << " !"; 164 G4Exception("G4VDivisionParameterisation:: 168 G4Exception("G4VDivisionParameterisation::CheckNDivAndWidth()", 165 "GeomDiv0001", FatalException, 169 "GeomDiv0001", FatalException, message); 166 } 170 } 167 } 171 } 168 172 169 //-------------------------------------------- 173 //-------------------------------------------------------------------------- 170 G4double G4VDivisionParameterisation::OffsetZ( 174 G4double G4VDivisionParameterisation::OffsetZ() const 171 { 175 { 172 // take into account reflection in the offse 176 // take into account reflection in the offset 173 << 174 G4double offset = foffset; 177 G4double offset = foffset; 175 if (fReflectedSolid) << 178 if (fReflectedSolid) offset = GetMaxParameter() - fwidth*fnDiv - foffset; 176 { << 177 offset = GetMaxParameter() - fwidth*fnDiv << 178 } << 179 179 180 return offset; 180 return offset; 181 } 181 } 182 182 183 183 184 184