Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4VDivisionParameterisation implementation << 23 // >> 24 // $Id: G4VDivisionParameterisation.cc,v 1.10 2004/05/17 07:20:42 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-07-01 $ >> 26 // >> 27 // class G4VDivisionParameterisation Implementation file 27 // 28 // 28 // 26.05.03 - P.Arce, Initial version 29 // 26.05.03 - P.Arce, Initial version 29 // 08.04.04 - I.Hrivnacova, Implemented reflec 30 // 08.04.04 - I.Hrivnacova, Implemented reflection 30 // 21.04.10 - M.Asai, Added gaps << 31 // ------------------------------------------- 31 // -------------------------------------------------------------------- 32 32 33 #include "G4VDivisionParameterisation.hh" 33 #include "G4VDivisionParameterisation.hh" 34 #include "G4VSolid.hh" 34 #include "G4VSolid.hh" 35 #include "G4VPhysicalVolume.hh" 35 #include "G4VPhysicalVolume.hh" 36 #include "G4RotationMatrix.hh" 36 #include "G4RotationMatrix.hh" 37 #include "G4ReflectedSolid.hh" 37 #include "G4ReflectedSolid.hh" 38 #include "G4GeometryTolerance.hh" << 39 #include "G4AutoDelete.hh" << 40 38 41 const G4int G4VDivisionParameterisation::verbo << 39 G4int G4VDivisionParameterisation::verbose = 5; 42 G4ThreadLocal G4RotationMatrix* G4VDivisionPar << 43 40 44 //-------------------------------------------- 41 //-------------------------------------------------------------------------- 45 G4VDivisionParameterisation:: 42 G4VDivisionParameterisation:: 46 G4VDivisionParameterisation( EAxis axis, G4int 43 G4VDivisionParameterisation( EAxis axis, G4int nDiv, 47 G4double step, G4 44 G4double step, G4double offset, 48 DivisionType divT 45 DivisionType divType, G4VSolid* motherSolid ) 49 : faxis(axis), fnDiv( nDiv), fwidth(step), f 46 : faxis(axis), fnDiv( nDiv), fwidth(step), foffset(offset), 50 fDivisionType(divType), fmotherSolid( moth << 47 fDivisionType(divType), fmotherSolid( motherSolid ), fReflectedSolid(false), >> 48 fDeleteSolid(false) 51 { 49 { 52 #ifdef G4DIVDEBUG 50 #ifdef G4DIVDEBUG 53 if (verbose >= 1) 51 if (verbose >= 1) 54 { 52 { 55 G4cout << " G4VDivisionParameterisation n 53 G4cout << " G4VDivisionParameterisation no divisions " << fnDiv 56 << " = " << nDiv << G4endl 54 << " = " << nDiv << G4endl 57 << " offset " << foffset << " = " < 55 << " offset " << foffset << " = " << offset << G4endl 58 << " step " << fwidth << " = " << s 56 << " step " << fwidth << " = " << step << G4endl; 59 } 57 } 60 #endif 58 #endif 61 kCarTolerance = G4GeometryTolerance::GetInst << 59 >> 60 theVoluFirstCopyNo = 1; 62 } 61 } 63 62 64 //-------------------------------------------- 63 //-------------------------------------------------------------------------- 65 G4VDivisionParameterisation::~G4VDivisionParam 64 G4VDivisionParameterisation::~G4VDivisionParameterisation() 66 { 65 { 67 if (fDeleteSolid) { delete fmotherSolid; } << 66 if (fDeleteSolid) delete fmotherSolid; 68 } 67 } 69 68 70 //-------------------------------------------- 69 //-------------------------------------------------------------------------- 71 G4VSolid* 70 G4VSolid* 72 G4VDivisionParameterisation:: 71 G4VDivisionParameterisation:: 73 ComputeSolid( const G4int i, G4VPhysicalVolume 72 ComputeSolid( const G4int i, G4VPhysicalVolume* pv ) 74 { 73 { 75 G4VSolid* solid = G4VPVParameterisation::Com 74 G4VSolid* solid = G4VPVParameterisation::ComputeSolid(i, pv); 76 if (solid->GetEntityType() == "G4ReflectedSo 75 if (solid->GetEntityType() == "G4ReflectedSolid") 77 { 76 { 78 solid = ((G4ReflectedSolid*)solid)->GetCon 77 solid = ((G4ReflectedSolid*)solid)->GetConstituentMovedSolid(); 79 } 78 } 80 return solid; 79 return solid; 81 } 80 } 82 81 83 //-------------------------------------------- 82 //-------------------------------------------------------------------------- 84 void 83 void 85 G4VDivisionParameterisation:: 84 G4VDivisionParameterisation:: 86 ChangeRotMatrix( G4VPhysicalVolume* physVol, G << 85 ChangeRotMatrix( G4VPhysicalVolume *physVol, G4double rotZ ) const 87 { 86 { 88 if (fRot == nullptr) << 87 G4RotationMatrix* rm = new G4RotationMatrix(); 89 { << 88 rm->rotateZ( rotZ ); 90 fRot = new G4RotationMatrix(); << 89 //----- set rotation 91 G4AutoDelete::Register(fRot); << 90 //----- delete first old rotation matrix 92 } << 91 G4RotationMatrix* rmold = physVol->GetRotation(); 93 fRot->rotateZ( rotZ ); << 92 delete rmold; 94 physVol->SetRotation(fRot); << 93 physVol->SetRotation(rm); 95 } 94 } 96 95 97 //-------------------------------------------- 96 //-------------------------------------------------------------------------- 98 G4int 97 G4int 99 G4VDivisionParameterisation:: 98 G4VDivisionParameterisation:: 100 CalculateNDiv( G4double motherDim, G4double wi 99 CalculateNDiv( G4double motherDim, G4double width, G4double offset ) const 101 { 100 { 102 #ifdef G4DIVDEBUG 101 #ifdef G4DIVDEBUG 103 G4cout << " G4VDivisionParameterisation::Cal 102 G4cout << " G4VDivisionParameterisation::CalculateNDiv: " 104 << ( motherDim - offset ) / width 103 << ( motherDim - offset ) / width 105 << " Motherdim: " << motherDim << ", 104 << " Motherdim: " << motherDim << ", Offset: " << offset 106 << ", Width: " << width << G4endl; 105 << ", Width: " << width << G4endl; 107 #endif 106 #endif 108 107 109 return G4int( ( motherDim - offset ) / width 108 return G4int( ( motherDim - offset ) / width ); 110 } 109 } 111 110 112 //-------------------------------------------- 111 //-------------------------------------------------------------------------- 113 G4double 112 G4double 114 G4VDivisionParameterisation:: 113 G4VDivisionParameterisation:: 115 CalculateWidth( G4double motherDim, G4int nDiv 114 CalculateWidth( G4double motherDim, G4int nDiv, G4double offset ) const 116 { 115 { 117 #ifdef G4DIVDEBUG 116 #ifdef G4DIVDEBUG 118 G4cout << " G4VDivisionParameterisation::Cal 117 G4cout << " G4VDivisionParameterisation::CalculateWidth: " 119 << ( motherDim - offset ) / nDiv 118 << ( motherDim - offset ) / nDiv 120 << ", Motherdim: " << motherDim << ", 119 << ", Motherdim: " << motherDim << ", Offset: " << offset 121 << ", Number of divisions: " << nDiv 120 << ", Number of divisions: " << nDiv << G4endl; 122 #endif 121 #endif 123 122 124 return ( motherDim - offset ) / nDiv; 123 return ( motherDim - offset ) / nDiv; 125 } 124 } 126 125 127 //-------------------------------------------- 126 //-------------------------------------------------------------------------- 128 void G4VDivisionParameterisation::CheckParamet 127 void G4VDivisionParameterisation::CheckParametersValidity() 129 { 128 { 130 G4double maxPar = GetMaxParameter(); 129 G4double maxPar = GetMaxParameter(); 131 CheckOffset( maxPar ); 130 CheckOffset( maxPar ); 132 CheckNDivAndWidth( maxPar ); 131 CheckNDivAndWidth( maxPar ); 133 } 132 } 134 133 135 //-------------------------------------------- 134 //-------------------------------------------------------------------------- 136 void G4VDivisionParameterisation::CheckOffset( 135 void G4VDivisionParameterisation::CheckOffset( G4double maxPar ) 137 { 136 { 138 if( foffset >= maxPar ) 137 if( foffset >= maxPar ) 139 { 138 { 140 std::ostringstream message; << 139 G4cerr << "ERROR - G4VDivisionParameterisation::CheckOffset()" << G4endl 141 message << "Configuration not supported." << 140 << " Division of solid " << fmotherSolid->GetName() 142 << "Division of solid " << fmother << 141 << " has too big offset = " << G4endl 143 << " has too big offset = " << G4e << 142 << " " << foffset << " > " << maxPar << " !" << G4endl; 144 << " " << foffset << " > " << 145 G4Exception("G4VDivisionParameterisation:: 143 G4Exception("G4VDivisionParameterisation::CheckOffset()", 146 "GeomDiv0001", FatalException, << 144 "IllegalConstruct", FatalException, >> 145 "Not supported configuration."); 147 } 146 } 148 } 147 } 149 148 150 //-------------------------------------------- 149 //-------------------------------------------------------------------------- 151 void G4VDivisionParameterisation::CheckNDivAnd 150 void G4VDivisionParameterisation::CheckNDivAndWidth( G4double maxPar ) 152 { 151 { 153 if( (fDivisionType == DivNDIVandWIDTH) 152 if( (fDivisionType == DivNDIVandWIDTH) 154 && (foffset + fwidth*fnDiv - maxPar > kC 153 && (foffset + fwidth*fnDiv - maxPar > kCarTolerance ) ) 155 { 154 { 156 std::ostringstream message; << 155 G4cerr << "ERROR - G4VDivisionParameterisation::CheckNDivAndWidth()" 157 message << "Configuration not supported." << 156 << G4endl 158 << "Division of solid " << fmother << 157 << " Division of solid " << fmotherSolid->GetName() 159 << " has too big offset + width*nDi 158 << " has too big offset + width*nDiv = " << G4endl 160 << " " << foffset + fwidth*f 159 << " " << foffset + fwidth*fnDiv << " > " 161 << foffset << ". Width = " 160 << foffset << ". Width = " 162 << G4endl 161 << G4endl 163 << " " << fwidth << ". nDiv << 162 << " " << fwidth << ". nDiv = " << fnDiv << " !" >> 163 << G4endl; 164 G4Exception("G4VDivisionParameterisation:: 164 G4Exception("G4VDivisionParameterisation::CheckNDivAndWidth()", 165 "GeomDiv0001", FatalException, << 165 "IllegalConstruct", FatalException, >> 166 "Not supported configuration."); 166 } 167 } 167 } 168 } 168 169 169 //-------------------------------------------- 170 //-------------------------------------------------------------------------- 170 G4double G4VDivisionParameterisation::OffsetZ( 171 G4double G4VDivisionParameterisation::OffsetZ() const 171 { 172 { 172 // take into account reflection in the offse 173 // take into account reflection in the offset 173 << 174 G4double offset = foffset; 174 G4double offset = foffset; 175 if (fReflectedSolid) << 175 if (fReflectedSolid) offset = GetMaxParameter() - fwidth*fnDiv - foffset; 176 { << 177 offset = GetMaxParameter() - fwidth*fnDiv << 178 } << 179 176 180 return offset; 177 return offset; 181 } 178 } 182 179 183 180 184 181