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,v 1.12.2.1 2008/09/02 12:18:55 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-01-patch-03 $ >> 29 // >> 30 // class G4VDivisionParameterisation Implementation file 27 // 31 // 28 // 26.05.03 - P.Arce, Initial version 32 // 26.05.03 - P.Arce, Initial version 29 // 08.04.04 - I.Hrivnacova, Implemented reflec 33 // 08.04.04 - I.Hrivnacova, Implemented reflection 30 // 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" << 40 42 41 const G4int G4VDivisionParameterisation::verbo << 43 G4int G4VDivisionParameterisation::verbose = 5; 42 G4ThreadLocal G4RotationMatrix* G4VDivisionPar << 43 44 44 //-------------------------------------------- 45 //-------------------------------------------------------------------------- 45 G4VDivisionParameterisation:: 46 G4VDivisionParameterisation:: 46 G4VDivisionParameterisation( EAxis axis, G4int 47 G4VDivisionParameterisation( EAxis axis, G4int nDiv, 47 G4double step, G4 48 G4double step, G4double offset, 48 DivisionType divT 49 DivisionType divType, G4VSolid* motherSolid ) 49 : faxis(axis), fnDiv( nDiv), fwidth(step), f 50 : faxis(axis), fnDiv( nDiv), fwidth(step), foffset(offset), 50 fDivisionType(divType), fmotherSolid( moth << 51 fDivisionType(divType), fmotherSolid( motherSolid ), fReflectedSolid(false), >> 52 fDeleteSolid(false) 51 { 53 { 52 #ifdef G4DIVDEBUG 54 #ifdef G4DIVDEBUG 53 if (verbose >= 1) 55 if (verbose >= 1) 54 { 56 { 55 G4cout << " G4VDivisionParameterisation n 57 G4cout << " G4VDivisionParameterisation no divisions " << fnDiv 56 << " = " << nDiv << G4endl 58 << " = " << nDiv << G4endl 57 << " offset " << foffset << " = " < 59 << " offset " << foffset << " = " << offset << G4endl 58 << " step " << fwidth << " = " << s 60 << " step " << fwidth << " = " << step << G4endl; 59 } 61 } 60 #endif 62 #endif >> 63 >> 64 theVoluFirstCopyNo = 1; 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 G4RotationMatrix* rm = new G4RotationMatrix(); 89 { << 93 rm->rotateZ( rotZ ); 90 fRot = new G4RotationMatrix(); << 94 //----- set rotation 91 G4AutoDelete::Register(fRot); << 95 //----- delete first old rotation matrix 92 } << 96 G4RotationMatrix* rmold = physVol->GetRotation(); 93 fRot->rotateZ( rotZ ); << 97 delete rmold; 94 physVol->SetRotation(fRot); << 98 physVol->SetRotation(rm); 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 G4cerr << "ERROR - G4VDivisionParameterisation::CheckOffset()" << G4endl 141 message << "Configuration not supported." << 145 << " Division of solid " << fmotherSolid->GetName() 142 << "Division of solid " << fmother << 146 << " has too big offset = " << G4endl 143 << " has too big offset = " << G4e << 147 << " " << foffset << " > " << maxPar << " !" << G4endl; 144 << " " << foffset << " > " << 145 G4Exception("G4VDivisionParameterisation:: 148 G4Exception("G4VDivisionParameterisation::CheckOffset()", 146 "GeomDiv0001", FatalException, << 149 "IllegalConstruct", FatalException, >> 150 "Not supported configuration."); 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 G4cerr << "ERROR - G4VDivisionParameterisation::CheckNDivAndWidth()" 157 message << "Configuration not supported." << 161 << 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 << maxPar << ". Width = " 162 << G4endl 166 << G4endl 163 << " " << fwidth << ". nDiv << 167 << " " << fwidth << ". nDiv = " << fnDiv << " !" >> 168 << G4endl; 164 G4Exception("G4VDivisionParameterisation:: 169 G4Exception("G4VDivisionParameterisation::CheckNDivAndWidth()", 165 "GeomDiv0001", FatalException, << 170 "IllegalConstruct", FatalException, >> 171 "Not supported configuration."); 166 } 172 } 167 } 173 } 168 174 169 //-------------------------------------------- 175 //-------------------------------------------------------------------------- 170 G4double G4VDivisionParameterisation::OffsetZ( 176 G4double G4VDivisionParameterisation::OffsetZ() const 171 { 177 { 172 // take into account reflection in the offse 178 // take into account reflection in the offset 173 << 174 G4double offset = foffset; 179 G4double offset = foffset; 175 if (fReflectedSolid) << 180 if (fReflectedSolid) offset = GetMaxParameter() - fwidth*fnDiv - foffset; 176 { << 177 offset = GetMaxParameter() - fwidth*fnDiv << 178 } << 179 181 180 return offset; 182 return offset; 181 } 183 } 182 184 183 185 184 186