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