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