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 // G4ParameterisationTrd[X/Y/Z] implementation 26 // G4ParameterisationTrd[X/Y/Z] implementation 27 // 27 // 28 // 26.05.03 - P.Arce, Initial version 28 // 26.05.03 - P.Arce, Initial version 29 // 08.04.04 - I.Hrivnacova, Implemented reflec 29 // 08.04.04 - I.Hrivnacova, Implemented reflection 30 // 21.04.10 - M.Asai, Added gaps 30 // 21.04.10 - M.Asai, Added gaps 31 // ------------------------------------------- 31 // -------------------------------------------------------------------- 32 32 33 #include "G4ParameterisationTrd.hh" 33 #include "G4ParameterisationTrd.hh" 34 34 35 #include <iomanip> 35 #include <iomanip> 36 #include "G4ThreeVector.hh" 36 #include "G4ThreeVector.hh" 37 #include "G4RotationMatrix.hh" 37 #include "G4RotationMatrix.hh" 38 #include "G4VPhysicalVolume.hh" 38 #include "G4VPhysicalVolume.hh" 39 #include "G4LogicalVolume.hh" 39 #include "G4LogicalVolume.hh" 40 #include "G4ReflectedSolid.hh" 40 #include "G4ReflectedSolid.hh" 41 #include "G4Trd.hh" 41 #include "G4Trd.hh" 42 #include "G4Trap.hh" 42 #include "G4Trap.hh" 43 43 44 //-------------------------------------------- 44 //-------------------------------------------------------------------------- 45 G4VParameterisationTrd:: 45 G4VParameterisationTrd:: 46 G4VParameterisationTrd( EAxis axis, G4int nDiv 46 G4VParameterisationTrd( EAxis axis, G4int nDiv, G4double width, 47 G4double offset, G4VSo 47 G4double offset, G4VSolid* msolid, 48 DivisionType divType ) 48 DivisionType divType ) 49 : G4VDivisionParameterisation( axis, nDiv, 49 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid ) 50 { 50 { 51 auto msol = (G4Trd*)(msolid); << 51 G4Trd* msol = (G4Trd*)(msolid); 52 if (msolid->GetEntityType() == "G4ReflectedS 52 if (msolid->GetEntityType() == "G4ReflectedSolid") 53 { 53 { 54 // Get constituent solid 54 // Get constituent solid 55 G4VSolid* mConstituentSolid 55 G4VSolid* mConstituentSolid 56 = ((G4ReflectedSolid*)msolid)->GetConst 56 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid(); 57 msol = (G4Trd*)(mConstituentSolid); 57 msol = (G4Trd*)(mConstituentSolid); 58 58 59 // Create a new solid with inversed parame 59 // Create a new solid with inversed parameters 60 auto newSolid << 60 G4Trd* newSolid 61 = new G4Trd(msol->GetName(), 61 = new G4Trd(msol->GetName(), 62 msol->GetXHalfLength2(), mso 62 msol->GetXHalfLength2(), msol->GetXHalfLength1(), 63 msol->GetYHalfLength2(), mso 63 msol->GetYHalfLength2(), msol->GetYHalfLength1(), 64 msol->GetZHalfLength()); 64 msol->GetZHalfLength()); 65 msol = newSolid; 65 msol = newSolid; 66 fmotherSolid = newSolid; 66 fmotherSolid = newSolid; 67 fReflectedSolid = true; 67 fReflectedSolid = true; 68 fDeleteSolid = true; 68 fDeleteSolid = true; 69 } 69 } 70 } 70 } 71 71 72 //-------------------------------------------- 72 //------------------------------------------------------------------------ 73 G4VParameterisationTrd::~G4VParameterisationTr << 73 G4VParameterisationTrd::~G4VParameterisationTrd() >> 74 { >> 75 } 74 76 75 //-------------------------------------------- 77 //------------------------------------------------------------------------ 76 G4ParameterisationTrdX:: 78 G4ParameterisationTrdX:: 77 G4ParameterisationTrdX( EAxis axis, G4int nDiv 79 G4ParameterisationTrdX( EAxis axis, G4int nDiv, 78 G4double width, G4doub 80 G4double width, G4double offset, 79 G4VSolid* msolid, Divi 81 G4VSolid* msolid, DivisionType divType ) 80 : G4VParameterisationTrd( axis, nDiv, width 82 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType ) 81 { 83 { 82 CheckParametersValidity(); 84 CheckParametersValidity(); 83 SetType( "DivisionTrdX" ); 85 SetType( "DivisionTrdX" ); 84 86 85 auto msol = (G4Trd*)(fmotherSolid); << 87 G4Trd* msol = (G4Trd*)(fmotherSolid); 86 if( divType == DivWIDTH ) 88 if( divType == DivWIDTH ) 87 { 89 { 88 fnDiv = CalculateNDiv( msol->GetXHalfLengt 90 fnDiv = CalculateNDiv( msol->GetXHalfLength1()+msol->GetXHalfLength2(), 89 width, offset ); 91 width, offset ); 90 } 92 } 91 else if( divType == DivNDIV ) 93 else if( divType == DivNDIV ) 92 { 94 { 93 fwidth = CalculateWidth( msol->GetXHalfLen 95 fwidth = CalculateWidth( msol->GetXHalfLength1()+msol->GetXHalfLength2(), 94 nDiv, offset ); 96 nDiv, offset ); 95 } 97 } 96 98 97 #ifdef G4DIVDEBUG 99 #ifdef G4DIVDEBUG 98 if( verbose >= 1 ) 100 if( verbose >= 1 ) 99 { 101 { 100 G4cout << " G4ParameterisationTrdX - ## di 102 G4cout << " G4ParameterisationTrdX - ## divisions " << fnDiv << " = " 101 << nDiv << G4endl 103 << nDiv << G4endl 102 << " Offset " << foffset << " = " < 104 << " Offset " << foffset << " = " << offset << G4endl 103 << " Width " << fwidth << " = " << 105 << " Width " << fwidth << " = " << width << G4endl; 104 } 106 } 105 #endif 107 #endif 106 108 107 G4double mpDx1 = msol->GetXHalfLength1(); 109 G4double mpDx1 = msol->GetXHalfLength1(); 108 G4double mpDx2 = msol->GetXHalfLength2(); 110 G4double mpDx2 = msol->GetXHalfLength2(); 109 if( std::fabs(mpDx1 - mpDx2) > kCarTolerance 111 if( std::fabs(mpDx1 - mpDx2) > kCarTolerance ) 110 { 112 { 111 bDivInTrap = true; 113 bDivInTrap = true; 112 } 114 } 113 } 115 } 114 116 115 //-------------------------------------------- 117 //------------------------------------------------------------------------ 116 G4ParameterisationTrdX::~G4ParameterisationTrd 118 G4ParameterisationTrdX::~G4ParameterisationTrdX() 117 = default; << 119 { >> 120 } 118 121 119 //-------------------------------------------- 122 //------------------------------------------------------------------------ 120 G4double G4ParameterisationTrdX::GetMaxParamet 123 G4double G4ParameterisationTrdX::GetMaxParameter() const 121 { 124 { 122 auto msol = (G4Trd*)(fmotherSolid); << 125 G4Trd* msol = (G4Trd*)(fmotherSolid); 123 return (msol->GetXHalfLength1()+msol->GetXHa 126 return (msol->GetXHalfLength1()+msol->GetXHalfLength2()); 124 } 127 } 125 128 126 //-------------------------------------------- 129 //------------------------------------------------------------------------ 127 void 130 void 128 G4ParameterisationTrdX:: 131 G4ParameterisationTrdX:: 129 ComputeTransformation( const G4int copyNo, 132 ComputeTransformation( const G4int copyNo, 130 G4VPhysicalVolume *phys 133 G4VPhysicalVolume *physVol ) const 131 { 134 { 132 auto msol = (G4Trd*)(fmotherSolid ); << 135 G4Trd* msol = (G4Trd*)(fmotherSolid ); 133 G4double mdx = ( msol->GetXHalfLength1() + m 136 G4double mdx = ( msol->GetXHalfLength1() + msol->GetXHalfLength2() ) / 2.; 134 //----- translation 137 //----- translation 135 G4ThreeVector origin(0.,0.,0.); 138 G4ThreeVector origin(0.,0.,0.); 136 G4double posi; 139 G4double posi; 137 posi = -mdx + foffset + (copyNo+0.5)*fwidth; 140 posi = -mdx + foffset + (copyNo+0.5)*fwidth; 138 if( faxis == kXAxis ) 141 if( faxis == kXAxis ) 139 { 142 { 140 origin.setX( posi ); 143 origin.setX( posi ); 141 } 144 } 142 else 145 else 143 { 146 { 144 std::ostringstream message; 147 std::ostringstream message; 145 message << "Only axes along X are allowed 148 message << "Only axes along X are allowed ! Axis: " << faxis; 146 G4Exception("G4ParameterisationTrdX::Compu 149 G4Exception("G4ParameterisationTrdX::ComputeTransformation()", 147 "GeomDiv0002", FatalException, 150 "GeomDiv0002", FatalException, message); 148 } 151 } 149 152 150 #ifdef G4DIVDEBUG 153 #ifdef G4DIVDEBUG 151 if( verbose >= 2 ) 154 if( verbose >= 2 ) 152 { 155 { 153 G4cout << std::setprecision(8) 156 G4cout << std::setprecision(8) 154 << " G4ParameterisationTrdX::Comput 157 << " G4ParameterisationTrdX::ComputeTransformation() " 155 << copyNo << G4endl 158 << copyNo << G4endl 156 << " Position: " << origin << " - A 159 << " Position: " << origin << " - Axis: " << faxis << G4endl; 157 } 160 } 158 #endif 161 #endif 159 162 160 //----- set translation 163 //----- set translation 161 physVol->SetTranslation( origin ); 164 physVol->SetTranslation( origin ); 162 } 165 } 163 166 164 //-------------------------------------------- 167 //-------------------------------------------------------------------------- 165 void 168 void 166 G4ParameterisationTrdX:: 169 G4ParameterisationTrdX:: 167 ComputeDimensions( G4Trd& trd, [[maybe_unused] 170 ComputeDimensions( G4Trd& trd, [[maybe_unused]] const G4int copyNo, const G4VPhysicalVolume* ) const 168 { 171 { 169 auto msol = (G4Trd*)(fmotherSolid); << 172 G4Trd* msol = (G4Trd*)(fmotherSolid); 170 G4double pDy1 = msol->GetYHalfLength1(); 173 G4double pDy1 = msol->GetYHalfLength1(); 171 G4double pDy2 = msol->GetYHalfLength2(); 174 G4double pDy2 = msol->GetYHalfLength2(); 172 G4double pDz = msol->GetZHalfLength(); 175 G4double pDz = msol->GetZHalfLength(); 173 G4double pDx = fwidth/2. - fhgap; 176 G4double pDx = fwidth/2. - fhgap; 174 177 175 trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, 178 trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz ); 176 179 177 #ifdef G4DIVDEBUG 180 #ifdef G4DIVDEBUG 178 if( verbose >= 2 ) 181 if( verbose >= 2 ) 179 { 182 { 180 G4cout << " G4ParameterisationTrdX::Comput 183 G4cout << " G4ParameterisationTrdX::ComputeDimensions():" 181 << copyNo << G4endl; 184 << copyNo << G4endl; 182 trd.DumpInfo(); 185 trd.DumpInfo(); 183 } 186 } 184 #endif 187 #endif 185 } 188 } 186 189 187 //-------------------------------------------- 190 //-------------------------------------------------------------------------- 188 void 191 void 189 G4ParameterisationTrdX::ComputeDimensions( G4T 192 G4ParameterisationTrdX::ComputeDimensions( G4Trap& trap, const G4int copyNo, 190 con 193 const G4VPhysicalVolume* ) const 191 { 194 { 192 auto msol = (G4Trd*)(fmotherSolid); << 195 G4Trd* msol = (G4Trd*)(fmotherSolid); 193 G4double pDy1 = msol->GetYHalfLength1(); 196 G4double pDy1 = msol->GetYHalfLength1(); 194 G4double pDy2 = msol->GetYHalfLength2(); 197 G4double pDy2 = msol->GetYHalfLength2(); 195 G4double pDz = msol->GetZHalfLength(); 198 G4double pDz = msol->GetZHalfLength(); 196 //fwidth is at Z=0 199 //fwidth is at Z=0 197 G4double pDx1 = msol->GetXHalfLength1(); 200 G4double pDx1 = msol->GetXHalfLength1(); 198 G4double pDx2 = msol->GetXHalfLength2(); 201 G4double pDx2 = msol->GetXHalfLength2(); 199 // G4double pDxAVE = (pDx1+pDx2)/2.; 202 // G4double pDxAVE = (pDx1+pDx2)/2.; 200 G4double xChangeRatio = (pDx2-pDx1) / (pDx2+ 203 G4double xChangeRatio = (pDx2-pDx1) / (pDx2+pDx1); 201 G4double fWidChange = xChangeRatio*fwidth; 204 G4double fWidChange = xChangeRatio*fwidth; 202 G4double fWid1 = fwidth - fWidChange; 205 G4double fWid1 = fwidth - fWidChange; 203 G4double fWid2 = fwidth + fWidChange; 206 G4double fWid2 = fwidth + fWidChange; 204 G4double fOffsetChange = xChangeRatio*foffse 207 G4double fOffsetChange = xChangeRatio*foffset/2.; 205 G4double fOffset1 = foffset - fOffsetChange; 208 G4double fOffset1 = foffset - fOffsetChange; 206 G4double fOffset2 = foffset + fOffsetChange; 209 G4double fOffset2 = foffset + fOffsetChange; 207 G4double cxy1 = -pDx1+fOffset1 + (copyNo+0.5 210 G4double cxy1 = -pDx1+fOffset1 + (copyNo+0.5)*fWid1;// centre of the side at y=-pDy1 208 G4double cxy2 = -pDx2+fOffset2 + (copyNo+0.5 211 G4double cxy2 = -pDx2+fOffset2 + (copyNo+0.5)*fWid2;// centre of the side at y=+pDy1 209 G4double alp = std::atan( (cxy2-cxy1)/(pDz*2 212 G4double alp = std::atan( (cxy2-cxy1)/(pDz*2.) ); 210 213 211 pDx1 = fwidth/2. - fWidChange/2.; 214 pDx1 = fwidth/2. - fWidChange/2.; 212 pDx2 = fwidth/2. + fWidChange/2.; 215 pDx2 = fwidth/2. + fWidChange/2.; 213 216 214 217 215 trap.SetAllParameters ( pDz, 218 trap.SetAllParameters ( pDz, 216 alp, 219 alp, 217 0., 220 0., 218 pDy1, 221 pDy1, 219 pDx1, 222 pDx1, 220 pDx1, 223 pDx1, 221 0., 224 0., 222 pDy2, 225 pDy2, 223 pDx2 - fhgap, 226 pDx2 - fhgap, 224 pDx2 - fhgap * pDx2/pDx1, 227 pDx2 - fhgap * pDx2/pDx1, 225 0.); 228 0.); 226 229 227 #ifdef G4DIVDEBUG 230 #ifdef G4DIVDEBUG 228 if( verbose >= 2 ) 231 if( verbose >= 2 ) 229 { 232 { 230 G4cout << " G4ParameterisationTrdX::Comput 233 G4cout << " G4ParameterisationTrdX::ComputeDimensions():" 231 << copyNo << G4endl; 234 << copyNo << G4endl; 232 trap.DumpInfo(); 235 trap.DumpInfo(); 233 } 236 } 234 #endif 237 #endif 235 } 238 } 236 239 237 240 238 //-------------------------------------------- 241 //-------------------------------------------------------------------------- 239 G4ParameterisationTrdY:: 242 G4ParameterisationTrdY:: 240 G4ParameterisationTrdY( EAxis axis, G4int nDiv 243 G4ParameterisationTrdY( EAxis axis, G4int nDiv, 241 G4double width, G4doub 244 G4double width, G4double offset, 242 G4VSolid* msolid, Divi 245 G4VSolid* msolid, DivisionType divType) 243 : G4VParameterisationTrd( axis, nDiv, width, 246 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType ) 244 { 247 { 245 CheckParametersValidity(); 248 CheckParametersValidity(); 246 SetType( "DivisionTrdY" ); 249 SetType( "DivisionTrdY" ); 247 250 248 auto msol = (G4Trd*)(fmotherSolid); << 251 G4Trd* msol = (G4Trd*)(fmotherSolid); 249 if( divType == DivWIDTH ) 252 if( divType == DivWIDTH ) 250 { 253 { 251 fnDiv = CalculateNDiv( 2*msol->GetYHalfLen 254 fnDiv = CalculateNDiv( 2*msol->GetYHalfLength1(), 252 width, offset ); 255 width, offset ); 253 } 256 } 254 else if( divType == DivNDIV ) 257 else if( divType == DivNDIV ) 255 { 258 { 256 fwidth = CalculateWidth( 2*msol->GetYHalfL 259 fwidth = CalculateWidth( 2*msol->GetYHalfLength1(), 257 nDiv, offset ); 260 nDiv, offset ); 258 } 261 } 259 262 260 #ifdef G4DIVDEBUG 263 #ifdef G4DIVDEBUG 261 if( verbose >= 1 ) 264 if( verbose >= 1 ) 262 { 265 { 263 G4cout << " G4ParameterisationTrdY no div 266 G4cout << " G4ParameterisationTrdY no divisions " << fnDiv 264 << " = " << nDiv << G4endl 267 << " = " << nDiv << G4endl 265 << " Offset " << foffset << " = " 268 << " Offset " << foffset << " = " << offset << G4endl 266 << " width " << fwidth << " = " << 269 << " width " << fwidth << " = " << width << G4endl; 267 } 270 } 268 #endif 271 #endif 269 } 272 } 270 273 271 //-------------------------------------------- 274 //------------------------------------------------------------------------ 272 G4ParameterisationTrdY::~G4ParameterisationTrd << 275 G4ParameterisationTrdY::~G4ParameterisationTrdY() >> 276 { >> 277 } 273 278 274 //-------------------------------------------- 279 //------------------------------------------------------------------------ 275 G4double G4ParameterisationTrdY::GetMaxParamet 280 G4double G4ParameterisationTrdY::GetMaxParameter() const 276 { 281 { 277 auto msol = (G4Trd*)(fmotherSolid); << 282 G4Trd* msol = (G4Trd*)(fmotherSolid); 278 return (msol->GetYHalfLength1()+msol->GetYHa 283 return (msol->GetYHalfLength1()+msol->GetYHalfLength2()); 279 } 284 } 280 285 281 //-------------------------------------------- 286 //-------------------------------------------------------------------------- 282 void 287 void 283 G4ParameterisationTrdY:: 288 G4ParameterisationTrdY:: 284 ComputeTransformation( const G4int copyNo, G4V 289 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const 285 { 290 { 286 auto msol = (G4Trd*)(fmotherSolid ); << 291 G4Trd* msol = (G4Trd*)(fmotherSolid ); 287 G4double mdy = ( msol->GetYHalfLength1() + 292 G4double mdy = ( msol->GetYHalfLength1() + msol->GetYHalfLength2() ) / 2.; 288 293 289 //----- translation 294 //----- translation 290 G4ThreeVector origin(0.,0.,0.); 295 G4ThreeVector origin(0.,0.,0.); 291 G4double posi = -mdy + foffset + (copyNo+0.5 296 G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth; 292 297 293 if( faxis == kYAxis ) 298 if( faxis == kYAxis ) 294 { 299 { 295 origin.setY( posi ); 300 origin.setY( posi ); 296 } 301 } 297 else 302 else 298 { 303 { 299 std::ostringstream message; 304 std::ostringstream message; 300 message << "Only axes along Y are allowed 305 message << "Only axes along Y are allowed ! Axis: " << faxis; 301 G4Exception("G4ParameterisationTrdY::Compu 306 G4Exception("G4ParameterisationTrdY::ComputeTransformation()", 302 "GeomDiv0002", FatalException, 307 "GeomDiv0002", FatalException, message); 303 } 308 } 304 309 305 #ifdef G4DIVDEBUG 310 #ifdef G4DIVDEBUG 306 if( verbose >= 2 ) 311 if( verbose >= 2 ) 307 { 312 { 308 G4cout << std::setprecision(8) 313 G4cout << std::setprecision(8) 309 << " G4ParameterisationTrdY::Comput 314 << " G4ParameterisationTrdY::ComputeTransformation " << copyNo 310 << " pos " << origin << " rot mat " 315 << " pos " << origin << " rot mat " << " axis " << faxis << G4endl; 311 } 316 } 312 #endif 317 #endif 313 318 314 //----- set translation 319 //----- set translation 315 physVol->SetTranslation( origin ); 320 physVol->SetTranslation( origin ); 316 } 321 } 317 322 318 //-------------------------------------------- 323 //-------------------------------------------------------------------------- 319 void 324 void 320 G4ParameterisationTrdY:: 325 G4ParameterisationTrdY:: 321 ComputeDimensions(G4Trd& trd, const G4int, con 326 ComputeDimensions(G4Trd& trd, const G4int, const G4VPhysicalVolume*) const 322 { 327 { 323 //---- The division along Y of a Trd will re 328 //---- The division along Y of a Trd will result a Trd, only 324 //--- if Y at -Z and +Z are equal, else use 329 //--- if Y at -Z and +Z are equal, else use the G4Trap version 325 auto msol = (G4Trd*)(fmotherSolid); << 330 G4Trd* msol = (G4Trd*)(fmotherSolid); 326 331 327 G4double pDx1 = msol->GetXHalfLength1(); 332 G4double pDx1 = msol->GetXHalfLength1(); 328 G4double pDx2 = msol->GetXHalfLength2(); 333 G4double pDx2 = msol->GetXHalfLength2(); 329 G4double pDz = msol->GetZHalfLength(); 334 G4double pDz = msol->GetZHalfLength(); 330 G4double pDy = fwidth/2. - fhgap; 335 G4double pDy = fwidth/2. - fhgap; 331 336 332 trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, 337 trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, pDz ); 333 338 334 #ifdef G4DIVDEBUG 339 #ifdef G4DIVDEBUG 335 if( verbose >= 2 ) 340 if( verbose >= 2 ) 336 { 341 { 337 G4cout << " G4ParameterisationTrdY::Comput 342 G4cout << " G4ParameterisationTrdY::ComputeDimensions():" << G4endl; 338 trd.DumpInfo(); 343 trd.DumpInfo(); 339 } 344 } 340 #endif 345 #endif 341 } 346 } 342 347 343 //-------------------------------------------- 348 //-------------------------------------------------------------------------- 344 void 349 void 345 G4ParameterisationTrdY::ComputeDimensions( G4T 350 G4ParameterisationTrdY::ComputeDimensions( G4Trap& trap, const G4int copyNo, 346 con 351 const G4VPhysicalVolume* ) const 347 { 352 { 348 auto msol = (G4Trd*)(fmotherSolid); << 353 G4Trd* msol = (G4Trd*)(fmotherSolid); 349 G4double pDx1 = msol->GetXHalfLength1(); 354 G4double pDx1 = msol->GetXHalfLength1(); 350 G4double pDx2 = msol->GetXHalfLength2(); 355 G4double pDx2 = msol->GetXHalfLength2(); 351 G4double pDz = msol->GetZHalfLength(); 356 G4double pDz = msol->GetZHalfLength(); 352 //fwidth is at Z=0 357 //fwidth is at Z=0 353 G4double pDy1 = msol->GetYHalfLength1(); 358 G4double pDy1 = msol->GetYHalfLength1(); 354 G4double pDy2 = msol->GetYHalfLength2(); 359 G4double pDy2 = msol->GetYHalfLength2(); 355 // G4double pDxAVE = (pDy1+pDy2)/2.; 360 // G4double pDxAVE = (pDy1+pDy2)/2.; 356 G4double yChangeRatio = (pDy2-pDy1) / (pDy2+ 361 G4double yChangeRatio = (pDy2-pDy1) / (pDy2+pDy1); 357 G4double fWidChange = yChangeRatio*fwidth; 362 G4double fWidChange = yChangeRatio*fwidth; 358 G4double fWid1 = fwidth - fWidChange; 363 G4double fWid1 = fwidth - fWidChange; 359 G4double fWid2 = fwidth + fWidChange; 364 G4double fWid2 = fwidth + fWidChange; 360 G4double fOffsetChange = yChangeRatio*foffse 365 G4double fOffsetChange = yChangeRatio*foffset/2.; 361 G4double fOffset1 = foffset - fOffsetChange; 366 G4double fOffset1 = foffset - fOffsetChange; 362 G4double fOffset2 = foffset + fOffsetChange; 367 G4double fOffset2 = foffset + fOffsetChange; 363 G4double cyx1 = -pDy1+fOffset1 + (copyNo+0.5 368 G4double cyx1 = -pDy1+fOffset1 + (copyNo+0.5)*fWid1;// centre of the side at y=-pDy1 364 G4double cyx2 = -pDy2+fOffset2 + (copyNo+0.5 369 G4double cyx2 = -pDy2+fOffset2 + (copyNo+0.5)*fWid2;// centre of the side at y=+pDy1 365 G4double alp = std::atan( (cyx2-cyx1)/(pDz*2 370 G4double alp = std::atan( (cyx2-cyx1)/(pDz*2.) ); 366 371 367 pDy1 = fwidth/2. - fWidChange/2.; 372 pDy1 = fwidth/2. - fWidChange/2.; 368 pDy2 = fwidth/2. + fWidChange/2.; 373 pDy2 = fwidth/2. + fWidChange/2.; 369 374 370 375 371 trap.SetAllParameters ( pDz, 376 trap.SetAllParameters ( pDz, 372 alp, 377 alp, 373 90*CLHEP::deg, 378 90*CLHEP::deg, 374 pDy1, 379 pDy1, 375 pDx1, 380 pDx1, 376 pDx1, 381 pDx1, 377 0., 382 0., 378 pDy2, 383 pDy2, 379 pDx2 - fhgap, 384 pDx2 - fhgap, 380 pDx2 - fhgap * pDx2/pDx1, 385 pDx2 - fhgap * pDx2/pDx1, 381 0.); 386 0.); 382 387 383 #ifdef G4DIVDEBUG 388 #ifdef G4DIVDEBUG 384 if( verbose >= 2 ) 389 if( verbose >= 2 ) 385 { 390 { 386 G4cout << " G4ParameterisationTrdY::Comput 391 G4cout << " G4ParameterisationTrdY::ComputeDimensions():" 387 << copyNo << G4endl; 392 << copyNo << G4endl; 388 trap.DumpInfo(); 393 trap.DumpInfo(); 389 } 394 } 390 #endif 395 #endif 391 } 396 } 392 397 393 //-------------------------------------------- 398 //-------------------------------------------------------------------------- 394 G4ParameterisationTrdZ:: 399 G4ParameterisationTrdZ:: 395 G4ParameterisationTrdZ( EAxis axis, G4int nDiv 400 G4ParameterisationTrdZ( EAxis axis, G4int nDiv, 396 G4double width, G4doub 401 G4double width, G4double offset, 397 G4VSolid* msolid, Divi 402 G4VSolid* msolid, DivisionType divType ) 398 : G4VParameterisationTrd( axis, nDiv, width, 403 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType ) 399 { 404 { 400 CheckParametersValidity(); 405 CheckParametersValidity(); 401 SetType( "DivTrdZ" ); 406 SetType( "DivTrdZ" ); 402 407 403 auto msol = (G4Trd*)(fmotherSolid); << 408 G4Trd* msol = (G4Trd*)(fmotherSolid); 404 if( divType == DivWIDTH ) 409 if( divType == DivWIDTH ) 405 { 410 { 406 fnDiv = CalculateNDiv( 2*msol->GetZHalfLen 411 fnDiv = CalculateNDiv( 2*msol->GetZHalfLength(), 407 width, offset ); 412 width, offset ); 408 } 413 } 409 else if( divType == DivNDIV ) 414 else if( divType == DivNDIV ) 410 { 415 { 411 fwidth = CalculateWidth( 2*msol->GetZHalfL 416 fwidth = CalculateWidth( 2*msol->GetZHalfLength(), 412 nDiv, offset ); 417 nDiv, offset ); 413 } 418 } 414 419 415 #ifdef G4DIVDEBUG 420 #ifdef G4DIVDEBUG 416 if( verbose >= 1 ) 421 if( verbose >= 1 ) 417 { 422 { 418 G4cout << " G4ParameterisationTrdZ no divi 423 G4cout << " G4ParameterisationTrdZ no divisions " << fnDiv 419 << " = " << nDiv << G4endl 424 << " = " << nDiv << G4endl 420 << " Offset " << foffset << " = " < 425 << " Offset " << foffset << " = " << offset << G4endl 421 << " Width " << fwidth << " = " << 426 << " Width " << fwidth << " = " << width << G4endl; 422 } 427 } 423 #endif 428 #endif 424 } 429 } 425 430 426 //-------------------------------------------- 431 //------------------------------------------------------------------------ 427 G4ParameterisationTrdZ::~G4ParameterisationTrd << 432 G4ParameterisationTrdZ::~G4ParameterisationTrdZ() >> 433 { >> 434 } 428 435 429 //-------------------------------------------- 436 //------------------------------------------------------------------------ 430 G4double G4ParameterisationTrdZ::GetMaxParamet 437 G4double G4ParameterisationTrdZ::GetMaxParameter() const 431 { 438 { 432 auto msol = (G4Trd*)(fmotherSolid); << 439 G4Trd* msol = (G4Trd*)(fmotherSolid); 433 return 2*msol->GetZHalfLength(); 440 return 2*msol->GetZHalfLength(); 434 } 441 } 435 442 436 //-------------------------------------------- 443 //-------------------------------------------------------------------------- 437 void 444 void 438 G4ParameterisationTrdZ:: 445 G4ParameterisationTrdZ:: 439 ComputeTransformation(const G4int copyNo, G4VP 446 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const 440 { 447 { 441 auto msol = (G4Trd*)(fmotherSolid ); << 448 G4Trd* msol = (G4Trd*)(fmotherSolid ); 442 G4double mdz = msol->GetZHalfLength(); 449 G4double mdz = msol->GetZHalfLength(); 443 450 444 //----- translation 451 //----- translation 445 G4ThreeVector origin(0.,0.,0.); 452 G4ThreeVector origin(0.,0.,0.); 446 G4double posi = -mdz + OffsetZ() + (copyNo+0 453 G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth; 447 if( faxis == kZAxis ) 454 if( faxis == kZAxis ) 448 { 455 { 449 origin.setZ( posi ); 456 origin.setZ( posi ); 450 } 457 } 451 else 458 else 452 { 459 { 453 std::ostringstream message; 460 std::ostringstream message; 454 message << "Only axes along Z are allowed 461 message << "Only axes along Z are allowed ! Axis: " << faxis; 455 G4Exception("G4ParameterisationTrdZ::Compu 462 G4Exception("G4ParameterisationTrdZ::ComputeTransformation()", 456 "GeomDiv0002", FatalException, 463 "GeomDiv0002", FatalException, message); 457 } 464 } 458 465 459 #ifdef G4DIVDEBUG 466 #ifdef G4DIVDEBUG 460 if( verbose >= 1 ) 467 if( verbose >= 1 ) 461 { 468 { 462 G4cout << std::setprecision(8) << " G4Para 469 G4cout << std::setprecision(8) << " G4ParameterisationTrdZ: " 463 << copyNo << G4endl 470 << copyNo << G4endl 464 << " Position: " << origin << " - O 471 << " Position: " << origin << " - Offset: " << foffset 465 << " - Width: " << fwidth << " Axis 472 << " - Width: " << fwidth << " Axis " << faxis << G4endl; 466 } 473 } 467 #endif 474 #endif 468 475 469 //----- set translation 476 //----- set translation 470 physVol->SetTranslation( origin ); 477 physVol->SetTranslation( origin ); 471 } 478 } 472 479 473 //-------------------------------------------- 480 //-------------------------------------------------------------------------- 474 void 481 void 475 G4ParameterisationTrdZ:: 482 G4ParameterisationTrdZ:: 476 ComputeDimensions(G4Trd& trd, const G4int copy 483 ComputeDimensions(G4Trd& trd, const G4int copyNo, 477 const G4VPhysicalVolume*) co 484 const G4VPhysicalVolume*) const 478 { 485 { 479 //---- The division along Z of a Trd will re 486 //---- The division along Z of a Trd will result a Trd 480 auto msol = (G4Trd*)(fmotherSolid); << 487 G4Trd* msol = (G4Trd*)(fmotherSolid); 481 488 482 G4double pDx1 = msol->GetXHalfLength1(); 489 G4double pDx1 = msol->GetXHalfLength1(); 483 G4double DDx = (msol->GetXHalfLength2() - ms 490 G4double DDx = (msol->GetXHalfLength2() - msol->GetXHalfLength1() ); 484 G4double pDy1 = msol->GetYHalfLength1(); 491 G4double pDy1 = msol->GetYHalfLength1(); 485 G4double DDy = (msol->GetYHalfLength2() - ms 492 G4double DDy = (msol->GetYHalfLength2() - msol->GetYHalfLength1() ); 486 G4double pDz = fwidth/2. - fhgap; 493 G4double pDz = fwidth/2. - fhgap; 487 G4double zLength = 2*msol->GetZHalfLength(); 494 G4double zLength = 2*msol->GetZHalfLength(); 488 495 489 trd.SetAllParameters( pDx1+DDx*(OffsetZ()+co 496 trd.SetAllParameters( pDx1+DDx*(OffsetZ()+copyNo*fwidth+fhgap)/zLength, 490 pDx1+DDx*(OffsetZ()+(c 497 pDx1+DDx*(OffsetZ()+(copyNo+1)*fwidth-fhgap)/zLength, 491 pDy1+DDy*(OffsetZ()+co 498 pDy1+DDy*(OffsetZ()+copyNo*fwidth+fhgap)/zLength, 492 pDy1+DDy*(OffsetZ()+(c 499 pDy1+DDy*(OffsetZ()+(copyNo+1)*fwidth-fhgap)/zLength, 493 pDz ); 500 pDz ); 494 501 495 #ifdef G4DIVDEBUG 502 #ifdef G4DIVDEBUG 496 if( verbose >= 1 ) 503 if( verbose >= 1 ) 497 { 504 { 498 G4cout << " G4ParameterisationTrdZ::Comput 505 G4cout << " G4ParameterisationTrdZ::ComputeDimensions()" 499 << " - Mother TRD " << G4endl; 506 << " - Mother TRD " << G4endl; 500 msol->DumpInfo(); 507 msol->DumpInfo(); 501 G4cout << " - Parameterised TRD: " 508 G4cout << " - Parameterised TRD: " 502 << copyNo << G4endl; 509 << copyNo << G4endl; 503 trd.DumpInfo(); 510 trd.DumpInfo(); 504 } 511 } 505 #endif 512 #endif 506 } 513 } 507 514