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 // G4ParameterisationCons[Rho/Phi/Z] implement << 26 // >> 27 // $Id: G4ParameterisationCons.cc,v 1.11 2010-11-10 09:15:58 gcosmo Exp $ >> 28 // GEANT4 tag $Name: not supported by cvs2svn $ >> 29 // >> 30 // class G4ParameterisationCons 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 "G4ParameterisationCons.hh" 37 #include "G4ParameterisationCons.hh" 34 38 35 #include <iomanip> 39 #include <iomanip> 36 #include "G4ThreeVector.hh" 40 #include "G4ThreeVector.hh" 37 #include "G4RotationMatrix.hh" 41 #include "G4RotationMatrix.hh" 38 #include "G4VPhysicalVolume.hh" 42 #include "G4VPhysicalVolume.hh" 39 #include "G4LogicalVolume.hh" 43 #include "G4LogicalVolume.hh" 40 #include "G4ReflectedSolid.hh" 44 #include "G4ReflectedSolid.hh" 41 #include "G4Cons.hh" 45 #include "G4Cons.hh" 42 46 43 //-------------------------------------------- 47 //-------------------------------------------------------------------------- 44 G4VParameterisationCons:: 48 G4VParameterisationCons:: 45 G4VParameterisationCons( EAxis axis, G4int nDi 49 G4VParameterisationCons( EAxis axis, G4int nDiv, G4double width, 46 G4double offset, G4VSo 50 G4double offset, G4VSolid* msolid, 47 DivisionType divType ) 51 DivisionType divType ) 48 : G4VDivisionParameterisation( axis, nDiv, 52 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid ) 49 { 53 { 50 auto msol = (G4Cons*)(msolid); << 54 G4Cons* msol = (G4Cons*)(msolid); 51 if (msolid->GetEntityType() == "G4ReflectedS 55 if (msolid->GetEntityType() == "G4ReflectedSolid") 52 { 56 { 53 // Get constituent solid 57 // Get constituent solid 54 G4VSolid* mConstituentSolid 58 G4VSolid* mConstituentSolid 55 = ((G4ReflectedSolid*)msolid)->GetConst 59 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid(); 56 msol = (G4Cons*)(mConstituentSolid); 60 msol = (G4Cons*)(mConstituentSolid); 57 61 58 // Create a new solid with inversed parame 62 // Create a new solid with inversed parameters 59 auto newSolid << 63 G4Cons* newSolid 60 = new G4Cons(msol->GetName(), 64 = new G4Cons(msol->GetName(), 61 msol->GetInnerRadiusPlusZ() 65 msol->GetInnerRadiusPlusZ(), msol->GetOuterRadiusPlusZ(), 62 msol->GetInnerRadiusMinusZ( 66 msol->GetInnerRadiusMinusZ(), msol->GetOuterRadiusMinusZ(), 63 msol->GetZHalfLength(), 67 msol->GetZHalfLength(), 64 msol->GetStartPhiAngle(), m 68 msol->GetStartPhiAngle(), msol->GetDeltaPhiAngle()); 65 msol = newSolid; 69 msol = newSolid; 66 fmotherSolid = newSolid; 70 fmotherSolid = newSolid; 67 fReflectedSolid = true; 71 fReflectedSolid = true; 68 fDeleteSolid = true; 72 fDeleteSolid = true; 69 } 73 } 70 } 74 } 71 75 72 //-------------------------------------------- 76 //------------------------------------------------------------------------ 73 G4VParameterisationCons::~G4VParameterisationC << 77 G4VParameterisationCons::~G4VParameterisationCons() >> 78 { >> 79 } 74 80 75 //-------------------------------------------- 81 //-------------------------------------------------------------------------- 76 G4ParameterisationConsRho:: 82 G4ParameterisationConsRho:: 77 G4ParameterisationConsRho( EAxis axis, G4int n 83 G4ParameterisationConsRho( EAxis axis, G4int nDiv, 78 G4double width, G4d 84 G4double width, G4double offset, 79 G4VSolid* msolid, D 85 G4VSolid* msolid, DivisionType divType ) 80 : G4VParameterisationCons( axis, nDiv, widt 86 : G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType ) 81 { 87 { 82 CheckParametersValidity(); 88 CheckParametersValidity(); 83 SetType( "DivisionConsRho" ); 89 SetType( "DivisionConsRho" ); 84 90 85 auto msol = (G4Cons*)(fmotherSolid); << 91 G4Cons* msol = (G4Cons*)(fmotherSolid); 86 if( msol->GetInnerRadiusPlusZ() == 0. ) 92 if( msol->GetInnerRadiusPlusZ() == 0. ) 87 { 93 { 88 std::ostringstream message; 94 std::ostringstream message; 89 message << "OuterRadiusMinusZ = 0" << G4en 95 message << "OuterRadiusMinusZ = 0" << G4endl 90 << "Width is calculated as that of 96 << "Width is calculated as that of OuterRadiusMinusZ !"; 91 G4Exception("G4ParameterisationConsRho::G4 97 G4Exception("G4ParameterisationConsRho::G4ParameterisationConsRho()", 92 "GeomDiv1001", JustWarning, me 98 "GeomDiv1001", JustWarning, message); 93 } 99 } 94 100 95 if( divType == DivWIDTH ) 101 if( divType == DivWIDTH ) 96 { 102 { 97 fnDiv = CalculateNDiv( msol->GetOuterRadiu 103 fnDiv = CalculateNDiv( msol->GetOuterRadiusMinusZ() 98 - msol->GetInnerRadiu 104 - msol->GetInnerRadiusMinusZ(), width, offset ); 99 } 105 } 100 else if( divType == DivNDIV ) 106 else if( divType == DivNDIV ) 101 { 107 { 102 auto mconsol = (G4Cons*)(msolid); << 108 G4Cons* msol = (G4Cons*)(msolid); 103 fwidth = CalculateWidth( mconsol->GetOuter << 109 fwidth = CalculateWidth( msol->GetOuterRadiusMinusZ() 104 - mconsol->GetInner << 110 - msol->GetInnerRadiusMinusZ(), nDiv, offset ); 105 } 111 } 106 112 107 #ifdef G4DIVDEBUG 113 #ifdef G4DIVDEBUG 108 if( verbose >= 1 ) 114 if( verbose >= 1 ) 109 { 115 { 110 G4cout << " G4ParameterisationConsRho - no 116 G4cout << " G4ParameterisationConsRho - no divisions " << fnDiv << " = " 111 << nDiv << G4endl 117 << nDiv << G4endl 112 << " Offset " << foffset << " = " < 118 << " Offset " << foffset << " = " << offset 113 << " - Width " << fwidth << " = " < 119 << " - Width " << fwidth << " = " << width << G4endl; 114 } 120 } 115 #endif 121 #endif 116 } 122 } 117 123 118 //-------------------------------------------- 124 //-------------------------------------------------------------------------- 119 G4ParameterisationConsRho::~G4Parameterisation << 125 G4ParameterisationConsRho::~G4ParameterisationConsRho() >> 126 { >> 127 } 120 128 121 //-------------------------------------------- 129 //------------------------------------------------------------------------ 122 G4double G4ParameterisationConsRho::GetMaxPara 130 G4double G4ParameterisationConsRho::GetMaxParameter() const 123 { 131 { 124 auto msol = (G4Cons*)(fmotherSolid); << 132 G4Cons* msol = (G4Cons*)(fmotherSolid); 125 return msol->GetOuterRadiusMinusZ() - msol-> 133 return msol->GetOuterRadiusMinusZ() - msol->GetInnerRadiusMinusZ(); 126 } 134 } 127 135 128 //-------------------------------------------- 136 //-------------------------------------------------------------------------- 129 void 137 void 130 G4ParameterisationConsRho:: 138 G4ParameterisationConsRho:: 131 ComputeTransformation( const G4int, G4VPhysica 139 ComputeTransformation( const G4int, G4VPhysicalVolume *physVol ) const 132 { 140 { 133 //----- translation 141 //----- translation 134 G4ThreeVector origin(0.,0.,0.); 142 G4ThreeVector origin(0.,0.,0.); 135 //----- set translation 143 //----- set translation 136 physVol->SetTranslation( origin ); 144 physVol->SetTranslation( origin ); 137 145 138 //----- calculate rotation matrix: unit 146 //----- calculate rotation matrix: unit 139 147 140 #ifdef G4DIVDEBUG 148 #ifdef G4DIVDEBUG 141 if( verbose >= 2 ) 149 if( verbose >= 2 ) 142 { 150 { 143 G4cout << " G4ParameterisationConsRho " < 151 G4cout << " G4ParameterisationConsRho " << G4endl 144 << " Offset: " << foffset 152 << " Offset: " << foffset 145 << " - Width: " << fwidth << G4endl 153 << " - Width: " << fwidth << G4endl; 146 } 154 } 147 #endif 155 #endif 148 156 149 ChangeRotMatrix( physVol ); 157 ChangeRotMatrix( physVol ); 150 158 151 #ifdef G4DIVDEBUG 159 #ifdef G4DIVDEBUG 152 if( verbose >= 2 ) 160 if( verbose >= 2 ) 153 { 161 { 154 G4cout << std::setprecision(8) << " G4Para 162 G4cout << std::setprecision(8) << " G4ParameterisationConsRho" << G4endl 155 << " Position: " << origin << " - W 163 << " Position: " << origin << " - Width: " << fwidth 156 << " - Axis: " << faxis << G4endl; 164 << " - Axis: " << faxis << G4endl; 157 } 165 } 158 #endif 166 #endif 159 } 167 } 160 168 161 //-------------------------------------------- 169 //-------------------------------------------------------------------------- 162 void 170 void 163 G4ParameterisationConsRho:: 171 G4ParameterisationConsRho:: 164 ComputeDimensions( G4Cons& cons, const G4int c 172 ComputeDimensions( G4Cons& cons, const G4int copyNo, 165 const G4VPhysicalVolume* ) 173 const G4VPhysicalVolume* ) const 166 { 174 { 167 auto msol = (G4Cons*)(fmotherSolid); << 175 G4Cons* msol = (G4Cons*)(fmotherSolid); 168 176 169 G4double pRMin1 = msol->GetInnerRadiusMinusZ << 177 G4double pRMin1 = msol->GetInnerRadiusMinusZ() + foffset + fwidth * copyNo; 170 G4double pRMax1 = msol->GetInnerRadiusMinusZ << 178 G4double pRMax1 = msol->GetInnerRadiusMinusZ() + foffset + fwidth * (copyNo+1); 171 179 172 //width at Z Plus 180 //width at Z Plus 173 //- G4double fwidthPlus = 181 //- G4double fwidthPlus = 174 // fwidth * ( msol->GetOuterRadiusPlusZ()/ 182 // fwidth * ( msol->GetOuterRadiusPlusZ()/ msol->GetInnerRadiusPlusZ()) 175 //- / ( msol->GetOuterRadiusMinusZ() 183 //- / ( msol->GetOuterRadiusMinusZ() - msol->GetInnerRadiusMinusZ()); 176 G4double fwidthPlus = CalculateWidth( msol-> 184 G4double fwidthPlus = CalculateWidth( msol->GetOuterRadiusPlusZ() 177 - msol->GetInnerRad 185 - msol->GetInnerRadiusPlusZ(), fnDiv, foffset ); 178 G4double pRMin2 = msol->GetInnerRadiusPlusZ( 186 G4double pRMin2 = msol->GetInnerRadiusPlusZ() 179 + foffset + fwidthPlus * cop 187 + foffset + fwidthPlus * copyNo; 180 G4double pRMax2 = msol->GetInnerRadiusPlusZ( 188 G4double pRMax2 = msol->GetInnerRadiusPlusZ() 181 + foffset + fwidthPlus * (co 189 + foffset + fwidthPlus * (copyNo+1); 182 G4double pDz = msol->GetZHalfLength(); 190 G4double pDz = msol->GetZHalfLength(); 183 191 184 G4double d_half_gap = fhgap * pRMax2 / pRMax 192 G4double d_half_gap = fhgap * pRMax2 / pRMax1; 185 //- already rotated double pSR = foffset + 193 //- already rotated double pSR = foffset + copyNo*fwidth; 186 G4double pSPhi = msol->GetStartPhiAngle(); 194 G4double pSPhi = msol->GetStartPhiAngle(); 187 G4double pDPhi = msol->GetDeltaPhiAngle();; 195 G4double pDPhi = msol->GetDeltaPhiAngle();; 188 196 189 cons.SetInnerRadiusMinusZ( pRMin1 + fhgap ); 197 cons.SetInnerRadiusMinusZ( pRMin1 + fhgap ); 190 cons.SetOuterRadiusMinusZ( pRMax1 - fhgap ); 198 cons.SetOuterRadiusMinusZ( pRMax1 - fhgap ); 191 cons.SetInnerRadiusPlusZ( pRMin2 + d_half_ga 199 cons.SetInnerRadiusPlusZ( pRMin2 + d_half_gap ); 192 cons.SetOuterRadiusPlusZ( pRMax2 - d_half_ga 200 cons.SetOuterRadiusPlusZ( pRMax2 - d_half_gap ); 193 cons.SetZHalfLength( pDz ); 201 cons.SetZHalfLength( pDz ); 194 cons.SetStartPhiAngle( pSPhi, false ); 202 cons.SetStartPhiAngle( pSPhi, false ); 195 cons.SetDeltaPhiAngle( pDPhi ); 203 cons.SetDeltaPhiAngle( pDPhi ); 196 204 197 #ifdef G4DIVDEBUG 205 #ifdef G4DIVDEBUG 198 if( verbose >= 2 ) 206 if( verbose >= 2 ) 199 { 207 { 200 G4cout << " G4ParameterisationConsRho::Com 208 G4cout << " G4ParameterisationConsRho::ComputeDimensions()" << G4endl 201 << " pRMin: " << pRMin1 << " - pRMa 209 << " pRMin: " << pRMin1 << " - pRMax: " << pRMax1 << G4endl; 202 if( verbose >= 4 ) cons.DumpInfo(); 210 if( verbose >= 4 ) cons.DumpInfo(); 203 } 211 } 204 #endif 212 #endif 205 } 213 } 206 214 207 //-------------------------------------------- 215 //-------------------------------------------------------------------------- 208 G4ParameterisationConsPhi:: 216 G4ParameterisationConsPhi:: 209 G4ParameterisationConsPhi( EAxis axis, G4int n 217 G4ParameterisationConsPhi( EAxis axis, G4int nDiv, 210 G4double width, G4d 218 G4double width, G4double offset, 211 G4VSolid* msolid, D 219 G4VSolid* msolid, DivisionType divType ) 212 : G4VParameterisationCons( axis, nDiv, widt 220 : G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType ) 213 { 221 { 214 CheckParametersValidity(); 222 CheckParametersValidity(); 215 SetType( "DivisionConsPhi" ); 223 SetType( "DivisionConsPhi" ); 216 224 217 auto msol = (G4Cons*)(fmotherSolid); << 225 G4Cons* msol = (G4Cons*)(fmotherSolid); 218 if( divType == DivWIDTH ) 226 if( divType == DivWIDTH ) 219 { 227 { 220 fnDiv = CalculateNDiv( msol->GetDeltaPhiAn 228 fnDiv = CalculateNDiv( msol->GetDeltaPhiAngle(), width, offset ); 221 } 229 } 222 else if( divType == DivNDIV ) 230 else if( divType == DivNDIV ) 223 { 231 { 224 fwidth = CalculateWidth( msol->GetDeltaPhi 232 fwidth = CalculateWidth( msol->GetDeltaPhiAngle(), nDiv, offset ); 225 } 233 } 226 234 227 #ifdef G4DIVDEBUG 235 #ifdef G4DIVDEBUG 228 if( verbose >= 1 ) 236 if( verbose >= 1 ) 229 { 237 { 230 G4cout << " G4ParameterisationConsPhi no d 238 G4cout << " G4ParameterisationConsPhi no divisions " << fnDiv << " = " 231 << nDiv << G4endl 239 << nDiv << G4endl 232 << " Offset " << foffset << " = " < 240 << " Offset " << foffset << " = " << offset << G4endl 233 << " Width " << fwidth << " = " << 241 << " Width " << fwidth << " = " << width << G4endl; 234 } 242 } 235 #endif 243 #endif 236 } 244 } 237 245 238 //-------------------------------------------- 246 //-------------------------------------------------------------------------- 239 G4ParameterisationConsPhi::~G4Parameterisation << 247 G4ParameterisationConsPhi::~G4ParameterisationConsPhi() >> 248 { >> 249 } 240 250 241 //-------------------------------------------- 251 //------------------------------------------------------------------------ 242 G4double G4ParameterisationConsPhi::GetMaxPara 252 G4double G4ParameterisationConsPhi::GetMaxParameter() const 243 { 253 { 244 auto msol = (G4Cons*)(fmotherSolid); << 254 G4Cons* msol = (G4Cons*)(fmotherSolid); 245 return msol->GetDeltaPhiAngle(); 255 return msol->GetDeltaPhiAngle(); 246 } 256 } 247 257 248 //-------------------------------------------- 258 //-------------------------------------------------------------------------- 249 void 259 void 250 G4ParameterisationConsPhi:: 260 G4ParameterisationConsPhi:: 251 ComputeTransformation( const G4int copyNo, G4V 261 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const 252 { 262 { 253 //----- translation 263 //----- translation 254 G4ThreeVector origin(0.,0.,0.); 264 G4ThreeVector origin(0.,0.,0.); 255 //----- set translation 265 //----- set translation 256 physVol->SetTranslation( origin ); 266 physVol->SetTranslation( origin ); 257 267 258 //----- calculate rotation matrix (so that a 268 //----- calculate rotation matrix (so that all volumes point to the centre) 259 G4double posi = foffset + copyNo*fwidth; 269 G4double posi = foffset + copyNo*fwidth; 260 270 261 #ifdef G4DIVDEBUG 271 #ifdef G4DIVDEBUG 262 if( verbose >= 2 ) 272 if( verbose >= 2 ) 263 { 273 { 264 G4cout << " G4ParameterisationConsPhi - po << 274 G4cout << " G4ParameterisationConsPhi - position: " << posi/deg << G4endl 265 << " Origin: " << origin << " copyN 275 << " Origin: " << origin << " copyNo: " << copyNo 266 << " - foffset: " << foffset/CLHEP: << 276 << " - foffset: " << foffset/deg 267 << " - fwidth: " << fwidth/CLHEP::d << 277 << " - fwidth: " << fwidth/deg << G4endl 268 << " - Axis: " << faxis << G4endl; 278 << " - Axis: " << faxis << G4endl; 269 } 279 } 270 #endif 280 #endif 271 281 272 ChangeRotMatrix( physVol, -posi ); 282 ChangeRotMatrix( physVol, -posi ); 273 } 283 } 274 284 275 //-------------------------------------------- 285 //-------------------------------------------------------------------------- 276 void 286 void 277 G4ParameterisationConsPhi:: 287 G4ParameterisationConsPhi:: 278 ComputeDimensions( G4Cons& cons, const G4int, 288 ComputeDimensions( G4Cons& cons, const G4int, 279 const G4VPhysicalVolume* ) 289 const G4VPhysicalVolume* ) const 280 { 290 { 281 auto msol = (G4Cons*)(fmotherSolid); << 291 G4Cons* msol = (G4Cons*)(fmotherSolid); 282 292 283 G4double pRMin1 = msol->GetInnerRadiusMinusZ 293 G4double pRMin1 = msol->GetInnerRadiusMinusZ(); 284 G4double pRMax1 = msol->GetOuterRadiusMinusZ 294 G4double pRMax1 = msol->GetOuterRadiusMinusZ(); 285 G4double pRMin2 = msol->GetInnerRadiusPlusZ( 295 G4double pRMin2 = msol->GetInnerRadiusPlusZ(); 286 G4double pRMax2 = msol->GetOuterRadiusPlusZ( 296 G4double pRMax2 = msol->GetOuterRadiusPlusZ(); 287 G4double pDz = msol->GetZHalfLength(); 297 G4double pDz = msol->GetZHalfLength(); 288 298 289 //- already rotated double pSPhi = foffset 299 //- already rotated double pSPhi = foffset + copyNo*fwidth; 290 G4double pSPhi = foffset + msol->GetStartPhi 300 G4double pSPhi = foffset + msol->GetStartPhiAngle() + fhgap; 291 G4double pDPhi = fwidth - 2.*fhgap; 301 G4double pDPhi = fwidth - 2.*fhgap; 292 302 293 cons.SetInnerRadiusMinusZ( pRMin1 ); 303 cons.SetInnerRadiusMinusZ( pRMin1 ); 294 cons.SetOuterRadiusMinusZ( pRMax1 ); 304 cons.SetOuterRadiusMinusZ( pRMax1 ); 295 cons.SetInnerRadiusPlusZ( pRMin2 ); 305 cons.SetInnerRadiusPlusZ( pRMin2 ); 296 cons.SetOuterRadiusPlusZ( pRMax2 ); 306 cons.SetOuterRadiusPlusZ( pRMax2 ); 297 cons.SetZHalfLength( pDz ); 307 cons.SetZHalfLength( pDz ); 298 cons.SetStartPhiAngle( pSPhi, false ); 308 cons.SetStartPhiAngle( pSPhi, false ); 299 cons.SetDeltaPhiAngle( pDPhi ); 309 cons.SetDeltaPhiAngle( pDPhi ); 300 310 301 #ifdef G4DIVDEBUG 311 #ifdef G4DIVDEBUG 302 if( verbose >= 2 ) 312 if( verbose >= 2 ) 303 { 313 { 304 G4cout << " G4ParameterisationConsPhi::Com 314 G4cout << " G4ParameterisationConsPhi::ComputeDimensions" << G4endl 305 << " pSPhi: " << pSPhi << " - pDPhi 315 << " pSPhi: " << pSPhi << " - pDPhi: " << pDPhi << G4endl; 306 if( verbose >= 4 ) cons.DumpInfo(); 316 if( verbose >= 4 ) cons.DumpInfo(); 307 } 317 } 308 #endif 318 #endif 309 } 319 } 310 320 311 //-------------------------------------------- 321 //-------------------------------------------------------------------------- 312 G4ParameterisationConsZ:: 322 G4ParameterisationConsZ:: 313 G4ParameterisationConsZ( EAxis axis, G4int nDi 323 G4ParameterisationConsZ( EAxis axis, G4int nDiv, 314 G4double width, G4dou 324 G4double width, G4double offset, 315 G4VSolid* msolid, Div 325 G4VSolid* msolid, DivisionType divType ) 316 : G4VParameterisationCons( axis, nDiv, widt 326 : G4VParameterisationCons( axis, nDiv, width, offset, msolid, divType ) 317 { 327 { 318 CheckParametersValidity(); 328 CheckParametersValidity(); 319 SetType( "DivisionConsZ" ); 329 SetType( "DivisionConsZ" ); 320 330 321 auto msol = (G4Cons*)(fmotherSolid); << 331 G4Cons* msol = (G4Cons*)(fmotherSolid); 322 if( divType == DivWIDTH ) 332 if( divType == DivWIDTH ) 323 { 333 { 324 fnDiv = CalculateNDiv( 2*msol->GetZHalfLen 334 fnDiv = CalculateNDiv( 2*msol->GetZHalfLength(), width, offset ); 325 } 335 } 326 else if( divType == DivNDIV ) 336 else if( divType == DivNDIV ) 327 { 337 { 328 fwidth = CalculateWidth( 2*msol->GetZHalfL 338 fwidth = CalculateWidth( 2*msol->GetZHalfLength(), nDiv, offset ); 329 } 339 } 330 340 331 #ifdef G4DIVDEBUG 341 #ifdef G4DIVDEBUG 332 if( verbose >= 1 ) 342 if( verbose >= 1 ) 333 { 343 { 334 G4cout << " G4ParameterisationConsZ: # div 344 G4cout << " G4ParameterisationConsZ: # divisions " << fnDiv << " = " 335 << nDiv << G4endl 345 << nDiv << G4endl 336 << " Offset " << foffset << " = " < 346 << " Offset " << foffset << " = " << offset << G4endl 337 << " Width " << fwidth << " = " << 347 << " Width " << fwidth << " = " << width << G4endl 338 << " - Axis: " << faxis << G4endl; 348 << " - Axis: " << faxis << G4endl; 339 } 349 } 340 #endif 350 #endif 341 } 351 } 342 352 343 //-------------------------------------------- 353 //-------------------------------------------------------------------------- 344 G4ParameterisationConsZ::~G4ParameterisationCo << 354 G4ParameterisationConsZ::~G4ParameterisationConsZ() >> 355 { >> 356 } 345 357 346 //-------------------------------------------- 358 //------------------------------------------------------------------------ 347 G4double G4ParameterisationConsZ::GetMaxParame 359 G4double G4ParameterisationConsZ::GetMaxParameter() const 348 { 360 { 349 auto msol = (G4Cons*)(fmotherSolid); << 361 G4Cons* msol = (G4Cons*)(fmotherSolid); 350 return 2*msol->GetZHalfLength(); 362 return 2*msol->GetZHalfLength(); 351 } 363 } 352 364 353 //-------------------------------------------- 365 //-------------------------------------------------------------------------- 354 void 366 void 355 G4ParameterisationConsZ:: 367 G4ParameterisationConsZ:: 356 ComputeTransformation( const G4int copyNo, G4V 368 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const 357 { 369 { 358 //----- set translation: along Z axis 370 //----- set translation: along Z axis 359 auto motherCons = (G4Cons*)(GetMotherSolid() << 371 G4Cons* motherCons = (G4Cons*)(GetMotherSolid()); 360 G4double posi = - motherCons->GetZHalfLength 372 G4double posi = - motherCons->GetZHalfLength() + OffsetZ() 361 + fwidth/2 + copyNo*fwidth; 373 + fwidth/2 + copyNo*fwidth; 362 G4ThreeVector origin(0.,0.,posi); 374 G4ThreeVector origin(0.,0.,posi); 363 physVol->SetTranslation( origin ); 375 physVol->SetTranslation( origin ); 364 376 365 //----- calculate rotation matrix: unit 377 //----- calculate rotation matrix: unit 366 378 367 #ifdef G4DIVDEBUG 379 #ifdef G4DIVDEBUG 368 if( verbose >= 2 ) 380 if( verbose >= 2 ) 369 { 381 { 370 G4cout << " G4ParameterisationConsZ::Compu 382 G4cout << " G4ParameterisationConsZ::ComputeTransformation()" << G4endl 371 << " Origin: " << origin << " - cop 383 << " Origin: " << origin << " - copyNo: " << copyNo << G4endl 372 << " foffset: " << foffset << " - f 384 << " foffset: " << foffset << " - fwidth: " << fwidth 373 << G4endl; 385 << G4endl; 374 } 386 } 375 #endif 387 #endif 376 388 377 ChangeRotMatrix( physVol ); 389 ChangeRotMatrix( physVol ); 378 } 390 } 379 391 380 392 381 //-------------------------------------------- 393 //-------------------------------------------------------------------------- 382 void 394 void 383 G4ParameterisationConsZ:: 395 G4ParameterisationConsZ:: 384 ComputeDimensions( G4Cons& cons, const G4int c 396 ComputeDimensions( G4Cons& cons, const G4int copyNo, 385 const G4VPhysicalVolume* ) 397 const G4VPhysicalVolume* ) const 386 { 398 { 387 auto msol = (G4Cons*)(fmotherSolid); << 399 G4Cons* msol = (G4Cons*)(fmotherSolid); 388 400 389 G4double mHalfLength = msol->GetZHalfLength( 401 G4double mHalfLength = msol->GetZHalfLength() - fhgap; 390 G4double aRInner = (msol->GetInnerRadiusPlus 402 G4double aRInner = (msol->GetInnerRadiusPlusZ() 391 - msol->GetInnerRadiusMinus 403 - msol->GetInnerRadiusMinusZ()) / (2*mHalfLength); 392 G4double bRInner = (msol->GetInnerRadiusPlus 404 G4double bRInner = (msol->GetInnerRadiusPlusZ() 393 + msol->GetInnerRadiusMinus 405 + msol->GetInnerRadiusMinusZ()) / 2; 394 G4double aROuter = (msol->GetOuterRadiusPlus 406 G4double aROuter = (msol->GetOuterRadiusPlusZ() 395 - msol->GetOuterRadiusMinus 407 - msol->GetOuterRadiusMinusZ()) / (2*mHalfLength); 396 G4double bROuter = (msol->GetOuterRadiusPlus 408 G4double bROuter = (msol->GetOuterRadiusPlusZ() 397 + msol->GetOuterRadiusMinus 409 + msol->GetOuterRadiusMinusZ()) / 2; 398 G4double xMinusZ = -mHalfLength + OffsetZ() 410 G4double xMinusZ = -mHalfLength + OffsetZ() + fwidth*copyNo + fhgap; 399 G4double xPlusZ = -mHalfLength + OffsetZ() 411 G4double xPlusZ = -mHalfLength + OffsetZ() + fwidth*(copyNo+1) - fhgap; 400 cons.SetInnerRadiusMinusZ( aRInner * xMinusZ 412 cons.SetInnerRadiusMinusZ( aRInner * xMinusZ + bRInner ); 401 cons.SetOuterRadiusMinusZ( aROuter * xMinusZ 413 cons.SetOuterRadiusMinusZ( aROuter * xMinusZ + bROuter ); 402 cons.SetInnerRadiusPlusZ( aRInner * xPlusZ + 414 cons.SetInnerRadiusPlusZ( aRInner * xPlusZ + bRInner ); 403 cons.SetOuterRadiusPlusZ( aROuter * xPlusZ + 415 cons.SetOuterRadiusPlusZ( aROuter * xPlusZ + bROuter ); 404 416 405 G4double pDz = fwidth / 2. - fhgap; 417 G4double pDz = fwidth / 2. - fhgap; 406 G4double pSPhi = msol->GetStartPhiAngle(); 418 G4double pSPhi = msol->GetStartPhiAngle(); 407 G4double pDPhi = msol->GetDeltaPhiAngle(); 419 G4double pDPhi = msol->GetDeltaPhiAngle(); 408 420 409 cons.SetZHalfLength( pDz ); 421 cons.SetZHalfLength( pDz ); 410 cons.SetStartPhiAngle( pSPhi, false ); 422 cons.SetStartPhiAngle( pSPhi, false ); 411 cons.SetDeltaPhiAngle( pDPhi ); 423 cons.SetDeltaPhiAngle( pDPhi ); 412 424 413 #ifdef G4DIVDEBUG 425 #ifdef G4DIVDEBUG 414 if( verbose >= 2 ) 426 if( verbose >= 2 ) 415 { 427 { 416 G4cout << " G4ParameterisationConsZ::Compu 428 G4cout << " G4ParameterisationConsZ::ComputeDimensions()" << G4endl 417 << " pDz: " << pDz << G4endl; 429 << " pDz: " << pDz << G4endl; 418 if( verbose >= 4 ) cons.DumpInfo(); 430 if( verbose >= 4 ) cons.DumpInfo(); 419 } 431 } 420 #endif 432 #endif 421 433 422 } 434 } 423 435