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