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 // G4ParameterisationPolycone[Rho/Phi/Z] imple 26 // G4ParameterisationPolycone[Rho/Phi/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 //-------------------------------------------- 30 //--------------------------------------------------------------------- 31 31 32 #include "G4ParameterisationPolycone.hh" 32 #include "G4ParameterisationPolycone.hh" 33 33 34 #include <iomanip> 34 #include <iomanip> 35 #include "G4ThreeVector.hh" 35 #include "G4ThreeVector.hh" 36 #include "G4RotationMatrix.hh" 36 #include "G4RotationMatrix.hh" 37 #include "G4VPhysicalVolume.hh" 37 #include "G4VPhysicalVolume.hh" 38 #include "G4LogicalVolume.hh" 38 #include "G4LogicalVolume.hh" 39 #include "G4ReflectedSolid.hh" 39 #include "G4ReflectedSolid.hh" 40 40 41 //-------------------------------------------- 41 //----------------------------------------------------------------------- 42 G4VParameterisationPolycone:: 42 G4VParameterisationPolycone:: 43 G4VParameterisationPolycone( EAxis axis, G4int 43 G4VParameterisationPolycone( EAxis axis, G4int nDiv, G4double width, 44 G4double offset, 44 G4double offset, G4VSolid* msolid, 45 DivisionType divT 45 DivisionType divType ) 46 : G4VDivisionParameterisation( axis, nDiv, 46 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid ) 47 { 47 { 48 /*#ifdef G4MULTITHREADED 48 /*#ifdef G4MULTITHREADED 49 std::ostringstream message; 49 std::ostringstream message; 50 message << "Divisions for G4Polycone curren 50 message << "Divisions for G4Polycone currently NOT supported in MT-mode." 51 << G4endl 51 << G4endl 52 << "Sorry! Solid: " << msolid->GetN 52 << "Sorry! Solid: " << msolid->GetName(); 53 G4Exception("G4VParameterisationPolycone::G 53 G4Exception("G4VParameterisationPolycone::G4VParameterisationPolycone()", 54 "GeomDiv0001", FatalException, 54 "GeomDiv0001", FatalException, message); 55 #endif */ 55 #endif */ 56 auto msol = (G4Polycone*)(msolid); 56 auto msol = (G4Polycone*)(msolid); 57 if (msolid->GetEntityType() == "G4ReflectedS 57 if (msolid->GetEntityType() == "G4ReflectedSolid") 58 { 58 { 59 // Get constituent solid 59 // Get constituent solid 60 // 60 // 61 G4VSolid* mConstituentSolid 61 G4VSolid* mConstituentSolid 62 = ((G4ReflectedSolid*)msolid)->GetConst 62 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid(); 63 msol = (G4Polycone*)(mConstituentSolid); 63 msol = (G4Polycone*)(mConstituentSolid); 64 64 65 // Get parameters 65 // Get parameters 66 // 66 // 67 G4int nofZplanes = msol->GetOriginalPara 67 G4int nofZplanes = msol->GetOriginalParameters()->Num_z_planes; 68 G4double* zValues = msol->GetOriginalPara 68 G4double* zValues = msol->GetOriginalParameters()->Z_values; 69 G4double* rminValues = msol->GetOriginalP 69 G4double* rminValues = msol->GetOriginalParameters()->Rmin; 70 G4double* rmaxValues = msol->GetOriginalP 70 G4double* rmaxValues = msol->GetOriginalParameters()->Rmax; 71 71 72 // Invert z values 72 // Invert z values 73 // 73 // 74 auto zValuesRefl = new G4double[nofZplanes 74 auto zValuesRefl = new G4double[nofZplanes]; 75 for (G4int i=0; i<nofZplanes; ++i) { zVal 75 for (G4int i=0; i<nofZplanes; ++i) { zValuesRefl[i] = - zValues[i]; } 76 76 77 auto newSolid 77 auto newSolid 78 = new G4Polycone(msol->GetName(), 78 = new G4Polycone(msol->GetName(), 79 msol->GetStartPhi(), 79 msol->GetStartPhi(), 80 msol->GetEndPhi() - mso 80 msol->GetEndPhi() - msol->GetStartPhi(), 81 nofZplanes, zValuesRefl 81 nofZplanes, zValuesRefl, rminValues, rmaxValues); 82 82 83 delete [] zValuesRefl; 83 delete [] zValuesRefl; 84 84 85 msol = newSolid; 85 msol = newSolid; 86 fmotherSolid = newSolid; 86 fmotherSolid = newSolid; 87 fReflectedSolid = true; 87 fReflectedSolid = true; 88 fDeleteSolid = true; 88 fDeleteSolid = true; 89 } 89 } 90 } 90 } 91 91 92 //-------------------------------------------- 92 //--------------------------------------------------------------------- 93 G4VParameterisationPolycone::~G4VParameterisat 93 G4VParameterisationPolycone::~G4VParameterisationPolycone() = default; 94 94 95 //-------------------------------------------- 95 //--------------------------------------------------------------------- 96 G4ParameterisationPolyconeRho:: 96 G4ParameterisationPolyconeRho:: 97 G4ParameterisationPolyconeRho( EAxis axis, G4i 97 G4ParameterisationPolyconeRho( EAxis axis, G4int nDiv, 98 G4double width, 98 G4double width, G4double offset, 99 G4VSolid* msoli 99 G4VSolid* msolid, DivisionType divType ) 100 : G4VParameterisationPolycone( axis, nDiv, 100 : G4VParameterisationPolycone( axis, nDiv, width, offset, msolid, divType ) 101 { 101 { 102 CheckParametersValidity(); 102 CheckParametersValidity(); 103 SetType( "DivisionPolyconeRho" ); 103 SetType( "DivisionPolyconeRho" ); 104 104 105 auto msol = (G4Polycone*)(fmotherSolid); 105 auto msol = (G4Polycone*)(fmotherSolid); 106 G4PolyconeHistorical* origparamMother = msol 106 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 107 107 108 if( divType == DivWIDTH ) 108 if( divType == DivWIDTH ) 109 { 109 { 110 fnDiv = CalculateNDiv( origparamMother->Rm 110 fnDiv = CalculateNDiv( origparamMother->Rmax[0] 111 - origparamMother->Rm 111 - origparamMother->Rmin[0], width, offset ); 112 } 112 } 113 else if( divType == DivNDIV ) 113 else if( divType == DivNDIV ) 114 { 114 { 115 fwidth = CalculateWidth( origparamMother-> 115 fwidth = CalculateWidth( origparamMother->Rmax[0] 116 - origparamMother-> 116 - origparamMother->Rmin[0], nDiv, offset ); 117 } 117 } 118 118 119 #ifdef G4DIVDEBUG 119 #ifdef G4DIVDEBUG 120 if( verbose >= -1 ) 120 if( verbose >= -1 ) 121 { 121 { 122 G4cout << " G4ParameterisationPolyconeRho 122 G4cout << " G4ParameterisationPolyconeRho - # divisions " << fnDiv 123 << " = " << nDiv << G4endl 123 << " = " << nDiv << G4endl 124 << " Offset " << foffset << " = " < 124 << " Offset " << foffset << " = " << offset << G4endl 125 << " Width " << fwidth << " = " << 125 << " Width " << fwidth << " = " << width << G4endl; 126 } 126 } 127 #endif 127 #endif 128 } 128 } 129 129 130 //-------------------------------------------- 130 //--------------------------------------------------------------------- 131 G4ParameterisationPolyconeRho::~G4Parameterisa 131 G4ParameterisationPolyconeRho::~G4ParameterisationPolyconeRho() = default; 132 132 133 //-------------------------------------------- 133 //--------------------------------------------------------------------- 134 void G4ParameterisationPolyconeRho::CheckParam 134 void G4ParameterisationPolyconeRho::CheckParametersValidity() 135 { 135 { 136 G4VDivisionParameterisation::CheckParameters 136 G4VDivisionParameterisation::CheckParametersValidity(); 137 137 138 auto msol = (G4Polycone*)(fmotherSolid); 138 auto msol = (G4Polycone*)(fmotherSolid); 139 139 140 if( fDivisionType == DivNDIVandWIDTH || fDiv 140 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 141 { 141 { 142 std::ostringstream message; 142 std::ostringstream message; 143 message << "In solid " << msol->GetName() 143 message << "In solid " << msol->GetName() << G4endl 144 << "Division along R will be done 144 << "Division along R will be done with a width " 145 << "different for each solid secti 145 << "different for each solid section." << G4endl 146 << "WIDTH will not be used !"; 146 << "WIDTH will not be used !"; 147 G4Exception("G4VParameterisationPolycone:: 147 G4Exception("G4VParameterisationPolycone::CheckParametersValidity()", 148 "GeomDiv1001", JustWarning, me 148 "GeomDiv1001", JustWarning, message); 149 } 149 } 150 if( foffset != 0. ) 150 if( foffset != 0. ) 151 { 151 { 152 std::ostringstream message; 152 std::ostringstream message; 153 message << "In solid " << msol->GetName() 153 message << "In solid " << msol->GetName() << G4endl 154 << "Division along R will be done 154 << "Division along R will be done with a width " 155 << "different for each solid secti 155 << "different for each solid section." << G4endl 156 << "OFFSET will not be used !"; 156 << "OFFSET will not be used !"; 157 G4Exception("G4VParameterisationPolycone:: 157 G4Exception("G4VParameterisationPolycone::CheckParametersValidity()", 158 "GeomDiv1001", JustWarning, me 158 "GeomDiv1001", JustWarning, message); 159 } 159 } 160 } 160 } 161 161 162 //-------------------------------------------- 162 //------------------------------------------------------------------------ 163 G4double G4ParameterisationPolyconeRho::GetMax 163 G4double G4ParameterisationPolyconeRho::GetMaxParameter() const 164 { 164 { 165 auto msol = (G4Polycone*)(fmotherSolid); 165 auto msol = (G4Polycone*)(fmotherSolid); 166 G4PolyconeHistorical* original_pars = msol-> 166 G4PolyconeHistorical* original_pars = msol->GetOriginalParameters(); 167 return original_pars->Rmax[0] - original_par 167 return original_pars->Rmax[0] - original_pars->Rmin[0]; 168 } 168 } 169 169 170 170 171 //-------------------------------------------- 171 //--------------------------------------------------------------------- 172 void 172 void 173 G4ParameterisationPolyconeRho:: 173 G4ParameterisationPolyconeRho:: 174 ComputeTransformation( const G4int, G4VPhysica 174 ComputeTransformation( const G4int, G4VPhysicalVolume* physVol ) const 175 { 175 { 176 //----- translation 176 //----- translation 177 G4ThreeVector origin(0.,0.,0.); 177 G4ThreeVector origin(0.,0.,0.); 178 //----- set translation 178 //----- set translation 179 physVol->SetTranslation( origin ); 179 physVol->SetTranslation( origin ); 180 180 181 //----- calculate rotation matrix: unit 181 //----- calculate rotation matrix: unit 182 182 183 #ifdef G4DIVDEBUG 183 #ifdef G4DIVDEBUG 184 if( verbose >= 2 ) 184 if( verbose >= 2 ) 185 { 185 { 186 G4cout << " G4ParameterisationPolyconeRho 186 G4cout << " G4ParameterisationPolyconeRho " << G4endl 187 << " foffset: " << foffset 187 << " foffset: " << foffset 188 << " - fwidth: " << fwidth << G4end 188 << " - fwidth: " << fwidth << G4endl; 189 } 189 } 190 #endif 190 #endif 191 191 192 ChangeRotMatrix( physVol ); 192 ChangeRotMatrix( physVol ); 193 193 194 #ifdef G4DIVDEBUG 194 #ifdef G4DIVDEBUG 195 if( verbose >= 2 ) 195 if( verbose >= 2 ) 196 { 196 { 197 G4cout << std::setprecision(8) << " G4Para 197 G4cout << std::setprecision(8) << " G4ParameterisationPolyconeRho " 198 << G4endl 198 << G4endl 199 << " Position: (0,0,0)" 199 << " Position: (0,0,0)" 200 << " - Width: " << fwidth/CLHEP::de 200 << " - Width: " << fwidth/CLHEP::deg 201 << " - Axis: " << faxis << G4endl; 201 << " - Axis: " << faxis << G4endl; 202 } 202 } 203 #endif 203 #endif 204 } 204 } 205 205 206 //-------------------------------------------- 206 //--------------------------------------------------------------------- 207 void 207 void 208 G4ParameterisationPolyconeRho:: 208 G4ParameterisationPolyconeRho:: 209 ComputeDimensions( G4Polycone& pcone, const G4 209 ComputeDimensions( G4Polycone& pcone, const G4int copyNo, 210 const G4VPhysicalVolume* ) 210 const G4VPhysicalVolume* ) const 211 { 211 { 212 auto msol = (G4Polycone*)(fmotherSolid); 212 auto msol = (G4Polycone*)(fmotherSolid); 213 213 214 G4PolyconeHistorical* origparamMother = msol 214 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 215 G4PolyconeHistorical origparam( *origparamMo 215 G4PolyconeHistorical origparam( *origparamMother ); 216 G4int nZplanes = origparamMother->Num_z_plan 216 G4int nZplanes = origparamMother->Num_z_planes; 217 217 218 G4double width = 0.; 218 G4double width = 0.; 219 for( G4int ii = 0; ii < nZplanes; ++ii ) 219 for( G4int ii = 0; ii < nZplanes; ++ii ) 220 { 220 { 221 width = CalculateWidth( origparamMother->R 221 width = CalculateWidth( origparamMother->Rmax[ii] 222 - origparamMother->R 222 - origparamMother->Rmin[ii], fnDiv, foffset ); 223 origparam.Rmin[ii] = origparamMother->Rmin 223 origparam.Rmin[ii] = origparamMother->Rmin[ii]+foffset+width*copyNo; 224 origparam.Rmax[ii] = origparamMother->Rmin 224 origparam.Rmax[ii] = origparamMother->Rmin[ii]+foffset+width*(copyNo+1); 225 } 225 } 226 226 227 pcone.SetOriginalParameters(&origparam); // 227 pcone.SetOriginalParameters(&origparam); // copy values & transfer pointers 228 pcone.Reset(); // 228 pcone.Reset(); // reset to new solid parameters 229 229 230 #ifdef G4DIVDEBUG 230 #ifdef G4DIVDEBUG 231 if( verbose >= -2 ) 231 if( verbose >= -2 ) 232 { 232 { 233 G4cout << "G4ParameterisationPolyconeRho:: 233 G4cout << "G4ParameterisationPolyconeRho::ComputeDimensions()" << G4endl 234 << "-- Parametrised pcone copy-numb 234 << "-- Parametrised pcone copy-number: " << copyNo << G4endl; 235 pcone.DumpInfo(); 235 pcone.DumpInfo(); 236 } 236 } 237 #endif 237 #endif 238 } 238 } 239 239 240 //-------------------------------------------- 240 //--------------------------------------------------------------------- 241 G4ParameterisationPolyconePhi:: 241 G4ParameterisationPolyconePhi:: 242 G4ParameterisationPolyconePhi( EAxis axis, G4i 242 G4ParameterisationPolyconePhi( EAxis axis, G4int nDiv, 243 G4double width, 243 G4double width, G4double offset, 244 G4VSolid* msoli 244 G4VSolid* msolid, DivisionType divType ) 245 : G4VParameterisationPolycone( axis, nDiv, 245 : G4VParameterisationPolycone( axis, nDiv, width, offset, msolid, divType ) 246 { 246 { 247 CheckParametersValidity(); 247 CheckParametersValidity(); 248 SetType( "DivisionPolyconePhi" ); 248 SetType( "DivisionPolyconePhi" ); 249 249 250 auto msol = (G4Polycone*)(fmotherSolid); 250 auto msol = (G4Polycone*)(fmotherSolid); 251 G4double deltaPhi = msol->GetEndPhi() - msol 251 G4double deltaPhi = msol->GetEndPhi() - msol->GetStartPhi(); 252 252 253 if( divType == DivWIDTH ) 253 if( divType == DivWIDTH ) 254 { 254 { 255 fnDiv = CalculateNDiv( deltaPhi, width, of 255 fnDiv = CalculateNDiv( deltaPhi, width, offset ); 256 } 256 } 257 else if( divType == DivNDIV ) 257 else if( divType == DivNDIV ) 258 { 258 { 259 fwidth = CalculateWidth( deltaPhi, nDiv, o 259 fwidth = CalculateWidth( deltaPhi, nDiv, offset ); 260 } 260 } 261 261 262 #ifdef G4DIVDEBUG 262 #ifdef G4DIVDEBUG 263 if( verbose >= 1 ) 263 if( verbose >= 1 ) 264 { 264 { 265 G4cout << " G4ParameterisationPolyconePhi 265 G4cout << " G4ParameterisationPolyconePhi - # divisions " << fnDiv 266 << " = " << nDiv << G4endl 266 << " = " << nDiv << G4endl 267 << " Offset " << foffset/CLHEP::deg 267 << " Offset " << foffset/CLHEP::deg << " = " << offset/CLHEP::deg << G4endl 268 << " Width " << fwidth/CLHEP::deg < 268 << " Width " << fwidth/CLHEP::deg << " = " << width/CLHEP::deg << G4endl; 269 } 269 } 270 #endif 270 #endif 271 } 271 } 272 272 273 //-------------------------------------------- 273 //--------------------------------------------------------------------- 274 G4ParameterisationPolyconePhi::~G4Parameterisa 274 G4ParameterisationPolyconePhi::~G4ParameterisationPolyconePhi() = default; 275 275 276 //-------------------------------------------- 276 //------------------------------------------------------------------------ 277 G4double G4ParameterisationPolyconePhi::GetMax 277 G4double G4ParameterisationPolyconePhi::GetMaxParameter() const 278 { 278 { 279 auto msol = (G4Polycone*)(fmotherSolid); 279 auto msol = (G4Polycone*)(fmotherSolid); 280 return msol->GetEndPhi() - msol->GetStartPhi 280 return msol->GetEndPhi() - msol->GetStartPhi(); 281 } 281 } 282 282 283 //-------------------------------------------- 283 //--------------------------------------------------------------------- 284 void 284 void 285 G4ParameterisationPolyconePhi:: 285 G4ParameterisationPolyconePhi:: 286 ComputeTransformation( const G4int copyNo, G4V 286 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const 287 { 287 { 288 //----- translation 288 //----- translation 289 G4ThreeVector origin(0.,0.,0.); 289 G4ThreeVector origin(0.,0.,0.); 290 //----- set translation 290 //----- set translation 291 physVol->SetTranslation( origin ); 291 physVol->SetTranslation( origin ); 292 292 293 //----- calculate rotation matrix (so that a 293 //----- calculate rotation matrix (so that all volumes point to the centre) 294 G4double posi = foffset + copyNo*fwidth; 294 G4double posi = foffset + copyNo*fwidth; 295 295 296 #ifdef G4DIVDEBUG 296 #ifdef G4DIVDEBUG 297 if( verbose >= 2 ) 297 if( verbose >= 2 ) 298 { 298 { 299 G4cout << " G4ParameterisationPolyconePhi 299 G4cout << " G4ParameterisationPolyconePhi - position: " << posi/CLHEP::deg 300 << G4endl 300 << G4endl 301 << " copyNo: " << copyNo << " - fof 301 << " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg 302 << " - fwidth: " << fwidth/CLHEP::d 302 << " - fwidth: " << fwidth/CLHEP::deg << G4endl; 303 } 303 } 304 #endif 304 #endif 305 305 306 ChangeRotMatrix( physVol, -posi ); 306 ChangeRotMatrix( physVol, -posi ); 307 307 308 #ifdef G4DIVDEBUG 308 #ifdef G4DIVDEBUG 309 if( verbose >= 2 ) 309 if( verbose >= 2 ) 310 { 310 { 311 G4cout << std::setprecision(8) << " G4Para 311 G4cout << std::setprecision(8) << " G4ParameterisationPolyconePhi " 312 << copyNo << G4endl 312 << copyNo << G4endl 313 << " Position: (0,0,0) - Width: " << fwid 313 << " Position: (0,0,0) - Width: " << fwidth 314 << " - Axis: " << faxis << G4endl; 314 << " - Axis: " << faxis << G4endl; 315 } 315 } 316 #endif 316 #endif 317 } 317 } 318 318 319 //-------------------------------------------- 319 //--------------------------------------------------------------------- 320 void 320 void 321 G4ParameterisationPolyconePhi:: 321 G4ParameterisationPolyconePhi:: 322 ComputeDimensions( G4Polycone& pcone, const G4 322 ComputeDimensions( G4Polycone& pcone, const G4int, 323 const G4VPhysicalVolume* ) 323 const G4VPhysicalVolume* ) const 324 { 324 { 325 auto msol = (G4Polycone*)(fmotherSolid); 325 auto msol = (G4Polycone*)(fmotherSolid); 326 326 327 G4PolyconeHistorical* origparamMother = msol 327 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 328 G4PolyconeHistorical origparam( *origparamMo 328 G4PolyconeHistorical origparam( *origparamMother ); 329 origparam.Start_angle = origparamMother->Sta 329 origparam.Start_angle = origparamMother->Start_angle; 330 origparam.Opening_angle = fwidth; 330 origparam.Opening_angle = fwidth; 331 331 332 pcone.SetOriginalParameters(&origparam); // 332 pcone.SetOriginalParameters(&origparam); // copy values & transfer pointers 333 pcone.Reset(); // 333 pcone.Reset(); // reset to new solid parameters 334 334 335 #ifdef G4DIVDEBUG 335 #ifdef G4DIVDEBUG 336 if( verbose >= 2 ) 336 if( verbose >= 2 ) 337 { 337 { 338 G4cout << "G4ParameterisationPolyconePhi:: 338 G4cout << "G4ParameterisationPolyconePhi::ComputeDimensions():" << G4endl; 339 pcone.DumpInfo(); 339 pcone.DumpInfo(); 340 } 340 } 341 #endif 341 #endif 342 } 342 } 343 343 344 //-------------------------------------------- 344 //--------------------------------------------------------------------- 345 G4ParameterisationPolyconeZ:: 345 G4ParameterisationPolyconeZ:: 346 G4ParameterisationPolyconeZ( EAxis axis, G4int 346 G4ParameterisationPolyconeZ( EAxis axis, G4int nDiv, 347 G4double width, G 347 G4double width, G4double offset, 348 G4VSolid* msolid, 348 G4VSolid* msolid, DivisionType divType) 349 : G4VParameterisationPolycone( axis, nDiv, w 349 : G4VParameterisationPolycone( axis, nDiv, width, offset, msolid, divType ), 350 fOrigParamMother(((G4Polycone*)fmotherSoli 350 fOrigParamMother(((G4Polycone*)fmotherSolid)->GetOriginalParameters()) 351 { 351 { 352 352 353 CheckParametersValidity(); 353 CheckParametersValidity(); 354 SetType( "DivisionPolyconeZ" ); 354 SetType( "DivisionPolyconeZ" ); 355 355 356 if( divType == DivWIDTH ) 356 if( divType == DivWIDTH ) 357 { 357 { 358 fnDiv = 358 fnDiv = 359 CalculateNDiv( fOrigParamMother->Z_value 359 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 360 - fOrigParamMother->Z_val 360 - fOrigParamMother->Z_values[0] , width, offset ); 361 } 361 } 362 else if( divType == DivNDIV ) 362 else if( divType == DivNDIV ) 363 { 363 { 364 fwidth = 364 fwidth = 365 CalculateNDiv( fOrigParamMother->Z_value 365 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 366 - fOrigParamMother->Z_val 366 - fOrigParamMother->Z_values[0] , nDiv, offset ); 367 } 367 } 368 368 369 #ifdef G4DIVDEBUG 369 #ifdef G4DIVDEBUG 370 if( verbose >= 1 ) 370 if( verbose >= 1 ) 371 { 371 { 372 G4cout << " G4ParameterisationPolyconeZ - 372 G4cout << " G4ParameterisationPolyconeZ - # divisions " << fnDiv << " = " 373 << nDiv << G4endl 373 << nDiv << G4endl 374 << " Offset " << foffset << " = " < 374 << " Offset " << foffset << " = " << offset << G4endl 375 << " Width " << fwidth << " = " << 375 << " Width " << fwidth << " = " << width << G4endl; 376 } 376 } 377 #endif 377 #endif 378 } 378 } 379 379 380 //-------------------------------------------- 380 //--------------------------------------------------------------------- 381 G4ParameterisationPolyconeZ::~G4Parameterisati 381 G4ParameterisationPolyconeZ::~G4ParameterisationPolyconeZ() = default; 382 382 383 //-------------------------------------------- 383 //------------------------------------------------------------------------ 384 G4double G4ParameterisationPolyconeZ::GetR(G4d 384 G4double G4ParameterisationPolyconeZ::GetR(G4double z, 385 G4d 385 G4double z1, G4double r1, 386 G4d 386 G4double z2, G4double r2) const 387 { 387 { 388 // Linear parameterisation: 388 // Linear parameterisation: 389 // r = az + b 389 // r = az + b 390 // a = (r1 - r2)/(z1-z2) 390 // a = (r1 - r2)/(z1-z2) 391 // b = r1 - a*z1 391 // b = r1 - a*z1 392 392 393 return (r1-r2)/(z1-z2)*z + ( r1 - (r1-r2)/(z 393 return (r1-r2)/(z1-z2)*z + ( r1 - (r1-r2)/(z1-z2)*z1 ) ; 394 } 394 } 395 395 396 //-------------------------------------------- 396 //------------------------------------------------------------------------ 397 G4double G4ParameterisationPolyconeZ::GetRmin( 397 G4double G4ParameterisationPolyconeZ::GetRmin(G4double z, G4int nseg) const 398 { 398 { 399 // Get Rmin in the given z position for the gi 399 // Get Rmin in the given z position for the given polycone segment 400 400 401 return GetR(z, 401 return GetR(z, 402 fOrigParamMother->Z_values[nseg] 402 fOrigParamMother->Z_values[nseg], 403 fOrigParamMother->Rmin[nseg], 403 fOrigParamMother->Rmin[nseg], 404 fOrigParamMother->Z_values[nseg+ 404 fOrigParamMother->Z_values[nseg+1], 405 fOrigParamMother->Rmin[nseg+1]); 405 fOrigParamMother->Rmin[nseg+1]); 406 } 406 } 407 407 408 //-------------------------------------------- 408 //------------------------------------------------------------------------ 409 G4double G4ParameterisationPolyconeZ::GetRmax( 409 G4double G4ParameterisationPolyconeZ::GetRmax(G4double z, G4int nseg) const 410 { 410 { 411 // Get Rmax in the given z position for the gi 411 // Get Rmax in the given z position for the given polycone segment 412 412 413 return GetR(z, 413 return GetR(z, 414 fOrigParamMother->Z_values[nseg] 414 fOrigParamMother->Z_values[nseg], 415 fOrigParamMother->Rmax[nseg], 415 fOrigParamMother->Rmax[nseg], 416 fOrigParamMother->Z_values[nseg+ 416 fOrigParamMother->Z_values[nseg+1], 417 fOrigParamMother->Rmax[nseg+1]); 417 fOrigParamMother->Rmax[nseg+1]); 418 } 418 } 419 419 420 //-------------------------------------------- 420 //------------------------------------------------------------------------ 421 G4double G4ParameterisationPolyconeZ::GetMaxPa 421 G4double G4ParameterisationPolyconeZ::GetMaxParameter() const 422 { 422 { 423 return std::abs (fOrigParamMother->Z_values[ 423 return std::abs (fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 424 -fOrigParamMother->Z_values[ 424 -fOrigParamMother->Z_values[0]); 425 } 425 } 426 426 427 //-------------------------------------------- 427 //--------------------------------------------------------------------- 428 void G4ParameterisationPolyconeZ::CheckParamet 428 void G4ParameterisationPolyconeZ::CheckParametersValidity() 429 { 429 { 430 G4VDivisionParameterisation::CheckParameters 430 G4VDivisionParameterisation::CheckParametersValidity(); 431 431 432 // Division will be following the mother pol 432 // Division will be following the mother polycone segments 433 // 433 // 434 if( fDivisionType == DivNDIV ) 434 if( fDivisionType == DivNDIV ) 435 { 435 { 436 if( fnDiv > fOrigParamMother->Num_z_planes 436 if( fnDiv > fOrigParamMother->Num_z_planes-1 ) 437 { 437 { 438 std::ostringstream error; 438 std::ostringstream error; 439 error << "Configuration not supported." 439 error << "Configuration not supported." << G4endl 440 << "Division along Z will be done 440 << "Division along Z will be done by splitting in the defined" 441 << G4endl 441 << G4endl 442 << "Z planes, i.e, the number of 442 << "Z planes, i.e, the number of division would be: " 443 << fOrigParamMother->Num_z_planes 443 << fOrigParamMother->Num_z_planes-1 444 << ", instead of: " << fnDiv << " 444 << ", instead of: " << fnDiv << " !"; 445 G4Exception("G4ParameterisationPolyconeZ 445 G4Exception("G4ParameterisationPolyconeZ::CheckParametersValidity()", 446 "GeomDiv0001", FatalExceptio 446 "GeomDiv0001", FatalException, error); 447 } 447 } 448 } 448 } 449 449 450 // Division will be done within one polycone 450 // Division will be done within one polycone segment 451 // with applying given width and offset 451 // with applying given width and offset 452 // 452 // 453 if( fDivisionType == DivNDIVandWIDTH || fDiv 453 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 454 { 454 { 455 // Check if divided region does not span o 455 // Check if divided region does not span over more 456 // than one z segment 456 // than one z segment 457 457 458 G4int isegstart = -1; // number of the se 458 G4int isegstart = -1; // number of the segment containing start position 459 G4int isegend = -1; // number of the se 459 G4int isegend = -1; // number of the segment containing end position 460 460 461 if ( !fReflectedSolid ) 461 if ( !fReflectedSolid ) 462 { 462 { 463 // The start/end position of the divided 463 // The start/end position of the divided region 464 // 464 // 465 G4double zstart 465 G4double zstart 466 = fOrigParamMother->Z_values[0] + foff 466 = fOrigParamMother->Z_values[0] + foffset; 467 G4double zend 467 G4double zend 468 = fOrigParamMother->Z_values[0] + foff 468 = fOrigParamMother->Z_values[0] + foffset + fnDiv* fwidth; 469 469 470 G4int counter = 0; 470 G4int counter = 0; 471 while ( isegend < 0 && counter < fOrigPa 471 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) 472 { 472 { 473 // first segment 473 // first segment 474 if ( zstart >= fOrigParamMother->Z_val 474 if ( zstart >= fOrigParamMother->Z_values[counter] && 475 zstart < fOrigParamMother->Z_val 475 zstart < fOrigParamMother->Z_values[counter+1] ) 476 { 476 { 477 isegstart = counter; 477 isegstart = counter; 478 } 478 } 479 // last segment 479 // last segment 480 if ( zend > fOrigParamMother->Z_value 480 if ( zend > fOrigParamMother->Z_values[counter] && 481 zend <= fOrigParamMother->Z_value 481 zend <= fOrigParamMother->Z_values[counter+1] ) 482 { 482 { 483 isegend = counter; 483 isegend = counter; 484 } 484 } 485 ++counter; 485 ++counter; 486 } // Loop checking, 06.08.2015, G.Cosmo 486 } // Loop checking, 06.08.2015, G.Cosmo 487 } 487 } 488 else 488 else 489 { 489 { 490 // The start/end position of the divided 490 // The start/end position of the divided region 491 // 491 // 492 G4double zstart 492 G4double zstart 493 = fOrigParamMother->Z_values[0] - foff 493 = fOrigParamMother->Z_values[0] - foffset; 494 G4double zend 494 G4double zend 495 = fOrigParamMother->Z_values[0] - ( fo 495 = fOrigParamMother->Z_values[0] - ( foffset + fnDiv* fwidth); 496 496 497 G4int counter = 0; 497 G4int counter = 0; 498 while ( isegend < 0 && counter < fOrigPa 498 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) 499 { 499 { 500 // first segment 500 // first segment 501 if ( zstart <= fOrigParamMother->Z_val 501 if ( zstart <= fOrigParamMother->Z_values[counter] && 502 zstart > fOrigParamMother->Z_val 502 zstart > fOrigParamMother->Z_values[counter+1] ) 503 { 503 { 504 isegstart = counter; 504 isegstart = counter; 505 } 505 } 506 // last segment 506 // last segment 507 if ( zend < fOrigParamMother->Z_value 507 if ( zend < fOrigParamMother->Z_values[counter] && 508 zend >= fOrigParamMother->Z_value 508 zend >= fOrigParamMother->Z_values[counter+1] ) 509 { 509 { 510 isegend = counter; 510 isegend = counter; 511 } 511 } 512 ++counter; 512 ++counter; 513 } // Loop checking, 06.08.2015, G.Cosmo 513 } // Loop checking, 06.08.2015, G.Cosmo 514 } 514 } 515 515 516 516 517 if ( isegstart != isegend ) 517 if ( isegstart != isegend ) 518 { 518 { 519 std::ostringstream message; 519 std::ostringstream message; 520 message << "Condiguration not supported. 520 message << "Condiguration not supported." << G4endl 521 << "Division with user defined w 521 << "Division with user defined width." << G4endl 522 << "Solid " << fmotherSolid->Get 522 << "Solid " << fmotherSolid->GetName() << G4endl 523 << "Divided region is not betwee 523 << "Divided region is not between two z planes."; 524 G4Exception("G4ParameterisationPolyconeZ 524 G4Exception("G4ParameterisationPolyconeZ::CheckParametersValidity()", 525 "GeomDiv0001", FatalExceptio 525 "GeomDiv0001", FatalException, message); 526 } 526 } 527 527 528 fNSegment = isegstart; 528 fNSegment = isegstart; 529 } 529 } 530 } 530 } 531 531 532 //-------------------------------------------- 532 //--------------------------------------------------------------------- 533 void 533 void 534 G4ParameterisationPolyconeZ:: 534 G4ParameterisationPolyconeZ:: 535 ComputeTransformation( const G4int copyNo, G4V 535 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const 536 { 536 { 537 G4double posi = 0.; 537 G4double posi = 0.; 538 if ( fDivisionType == DivNDIV ) 538 if ( fDivisionType == DivNDIV ) 539 { 539 { 540 // The position of the centre of copyNo-th 540 // The position of the centre of copyNo-th mother polycone segment 541 // 541 // 542 posi = ( fOrigParamMother->Z_values[copyNo 542 posi = ( fOrigParamMother->Z_values[copyNo] 543 + fOrigParamMother->Z_valu 543 + fOrigParamMother->Z_values[copyNo+1])/2; 544 physVol->SetTranslation( G4ThreeVector(0, 544 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 545 } 545 } 546 546 547 if ( fDivisionType == DivNDIVandWIDTH || fDi 547 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 548 { 548 { 549 // The position of the centre of copyNo-th 549 // The position of the centre of copyNo-th division 550 // 550 // 551 posi = fOrigParamMother->Z_values[0]; 551 posi = fOrigParamMother->Z_values[0]; 552 552 553 if ( !fReflectedSolid ) 553 if ( !fReflectedSolid ) 554 posi += foffset + (2*copyNo + 1) * fwidt 554 posi += foffset + (2*copyNo + 1) * fwidth/2.; 555 else 555 else 556 posi -= foffset + (2*copyNo + 1) * fwidt 556 posi -= foffset + (2*copyNo + 1) * fwidth/2.; 557 557 558 physVol->SetTranslation( G4ThreeVector(0, 558 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 559 } 559 } 560 560 561 //----- calculate rotation matrix: unit 561 //----- calculate rotation matrix: unit 562 562 563 #ifdef G4DIVDEBUG 563 #ifdef G4DIVDEBUG 564 if( verbose >= 2 ) 564 if( verbose >= 2 ) 565 { 565 { 566 G4cout << " G4ParameterisationPolyconeZ - 566 G4cout << " G4ParameterisationPolyconeZ - position: " << posi << G4endl 567 << " copyNo: " << copyNo << " - fof 567 << " copyNo: " << copyNo << " - foffset: " << foffset/CLHEP::deg 568 << " - fwidth: " << fwidth/CLHEP::d 568 << " - fwidth: " << fwidth/CLHEP::deg << G4endl; 569 } 569 } 570 #endif 570 #endif 571 571 572 ChangeRotMatrix( physVol ); 572 ChangeRotMatrix( physVol ); 573 573 574 #ifdef G4DIVDEBUG 574 #ifdef G4DIVDEBUG 575 if( verbose >= 2 ) 575 if( verbose >= 2 ) 576 { 576 { 577 G4cout << std::setprecision(8) << " G4Para 577 G4cout << std::setprecision(8) << " G4ParameterisationPolyconeZ " 578 << copyNo << G4endl 578 << copyNo << G4endl 579 << " Position: (0,0,0) - Width: " < 579 << " Position: (0,0,0) - Width: " << fwidth 580 << " - Axis: " << faxis << G4endl; 580 << " - Axis: " << faxis << G4endl; 581 } 581 } 582 #endif 582 #endif 583 } 583 } 584 584 585 //-------------------------------------------- 585 //--------------------------------------------------------------------- 586 void 586 void 587 G4ParameterisationPolyconeZ:: 587 G4ParameterisationPolyconeZ:: 588 ComputeDimensions( G4Polycone& pcone, const G4 588 ComputeDimensions( G4Polycone& pcone, const G4int copyNo, 589 const G4VPhysicalVolume* ) 589 const G4VPhysicalVolume* ) const 590 { 590 { 591 591 592 // Define division solid 592 // Define division solid 593 // 593 // 594 G4PolyconeHistorical origparam; 594 G4PolyconeHistorical origparam; 595 G4int nz = 2; 595 G4int nz = 2; 596 origparam.Num_z_planes = nz; 596 origparam.Num_z_planes = nz; 597 origparam.Start_angle = fOrigParamMother->St 597 origparam.Start_angle = fOrigParamMother->Start_angle; 598 origparam.Opening_angle = fOrigParamMother-> 598 origparam.Opening_angle = fOrigParamMother->Opening_angle; 599 599 600 // Define division solid z sections 600 // Define division solid z sections 601 // 601 // 602 origparam.Z_values = new G4double[nz]; 602 origparam.Z_values = new G4double[nz]; 603 origparam.Rmin = new G4double[nz]; 603 origparam.Rmin = new G4double[nz]; 604 origparam.Rmax = new G4double[nz]; 604 origparam.Rmax = new G4double[nz]; 605 605 606 if ( fDivisionType == DivNDIV ) 606 if ( fDivisionType == DivNDIV ) 607 { 607 { 608 // The position of the centre of copyNo-th 608 // The position of the centre of copyNo-th mother polycone segment 609 G4double posi = (fOrigParamMother->Z_value 609 G4double posi = (fOrigParamMother->Z_values[copyNo] 610 + fOrigParamMother->Z_value 610 + fOrigParamMother->Z_values[copyNo+1])/2; 611 611 612 origparam.Z_values[0] = fOrigParamMother-> 612 origparam.Z_values[0] = fOrigParamMother->Z_values[copyNo] - posi; 613 origparam.Z_values[1] = fOrigParamMother-> 613 origparam.Z_values[1] = fOrigParamMother->Z_values[copyNo+1] - posi; 614 origparam.Rmin[0] = fOrigParamMother->Rmin 614 origparam.Rmin[0] = fOrigParamMother->Rmin[copyNo]; 615 origparam.Rmin[1] = fOrigParamMother->Rmin 615 origparam.Rmin[1] = fOrigParamMother->Rmin[copyNo+1]; 616 origparam.Rmax[0] = fOrigParamMother->Rmax 616 origparam.Rmax[0] = fOrigParamMother->Rmax[copyNo]; 617 origparam.Rmax[1] = fOrigParamMother->Rmax 617 origparam.Rmax[1] = fOrigParamMother->Rmax[copyNo+1]; 618 } 618 } 619 619 620 if ( fDivisionType == DivNDIVandWIDTH || fDi 620 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 621 { 621 { 622 if ( !fReflectedSolid ) 622 if ( !fReflectedSolid ) 623 { 623 { 624 origparam.Z_values[0] = - fwidth/2.; 624 origparam.Z_values[0] = - fwidth/2.; 625 origparam.Z_values[1] = fwidth/2.; 625 origparam.Z_values[1] = fwidth/2.; 626 626 627 // The position of the centre of copyNo- 627 // The position of the centre of copyNo-th division 628 // 628 // 629 G4double posi = fOrigParamMother->Z_valu 629 G4double posi = fOrigParamMother->Z_values[0] 630 + foffset + (2*copyNo + 1) 630 + foffset + (2*copyNo + 1) * fwidth/2.; 631 631 632 // The first and last z sides z values 632 // The first and last z sides z values 633 // 633 // 634 G4double zstart = posi - fwidth/2.; 634 G4double zstart = posi - fwidth/2.; 635 G4double zend = posi + fwidth/2.; 635 G4double zend = posi + fwidth/2.; 636 origparam.Rmin[0] = GetRmin(zstart, fNSe 636 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 637 origparam.Rmax[0] = GetRmax(zstart, fNSe 637 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 638 origparam.Rmin[1] = GetRmin(zend, fNSegm 638 origparam.Rmin[1] = GetRmin(zend, fNSegment); 639 origparam.Rmax[1] = GetRmax(zend, fNSegm 639 origparam.Rmax[1] = GetRmax(zend, fNSegment); 640 } 640 } 641 else 641 else 642 { 642 { 643 origparam.Z_values[0] = fwidth/2.; 643 origparam.Z_values[0] = fwidth/2.; 644 origparam.Z_values[1] = - fwidth/2.; 644 origparam.Z_values[1] = - fwidth/2.; 645 645 646 // The position of the centre of copyNo- 646 // The position of the centre of copyNo-th division 647 // 647 // 648 G4double posi = fOrigParamMother->Z_valu 648 G4double posi = fOrigParamMother->Z_values[0] 649 - ( foffset + (2*copyNo + 649 - ( foffset + (2*copyNo + 1) * fwidth/2.); 650 650 651 // The first and last z sides z values 651 // The first and last z sides z values 652 // 652 // 653 G4double zstart = posi + fwidth/2.; 653 G4double zstart = posi + fwidth/2.; 654 G4double zend = posi - fwidth/2.; 654 G4double zend = posi - fwidth/2.; 655 origparam.Rmin[0] = GetRmin(zstart, fNSe 655 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 656 origparam.Rmax[0] = GetRmax(zstart, fNSe 656 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 657 origparam.Rmin[1] = GetRmin(zend, fNSegm 657 origparam.Rmin[1] = GetRmin(zend, fNSegment); 658 origparam.Rmax[1] = GetRmax(zend, fNSegm 658 origparam.Rmax[1] = GetRmax(zend, fNSegment); 659 } 659 } 660 660 661 // It can happen due to rounding errors 661 // It can happen due to rounding errors 662 // 662 // 663 if ( origparam.Rmin[0] < 0.0 ) origpara 663 if ( origparam.Rmin[0] < 0.0 ) origparam.Rmin[0] = 0.0; 664 if ( origparam.Rmin[nz-1] < 0.0 ) origpara 664 if ( origparam.Rmin[nz-1] < 0.0 ) origparam.Rmin[1] = 0.0; 665 } 665 } 666 666 667 pcone.SetOriginalParameters(&origparam); // 667 pcone.SetOriginalParameters(&origparam); // copy values & transfer pointers 668 pcone.Reset(); // 668 pcone.Reset(); // reset to new solid parameters 669 669 670 #ifdef G4DIVDEBUG 670 #ifdef G4DIVDEBUG 671 if( verbose >= 2 ) 671 if( verbose >= 2 ) 672 { 672 { 673 G4cout << "G4ParameterisationPolyconeZ::Co 673 G4cout << "G4ParameterisationPolyconeZ::ComputeDimensions()" << G4endl 674 << "-- Parametrised pcone copy-numb 674 << "-- Parametrised pcone copy-number: " << copyNo << G4endl; 675 pcone.DumpInfo(); 675 pcone.DumpInfo(); 676 } 676 } 677 #endif 677 #endif 678 } 678 } 679 679