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