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