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