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 // G4GDMLParameterisation implementation << 26 // $Id: G4GDMLParameterisation.cc 77556 2013-11-26 08:56:14Z gcosmo $ 27 // 27 // 28 // Author: Zoltan Torzsok, November 2007 << 28 // class G4GDMLParameterisation Implementation 29 // ------------------------------------------- << 29 // >> 30 // History: >> 31 // - Created. Zoltan Torzsok, November 2007 >> 32 // ------------------------------------------------------------------------- 30 33 31 #include "G4GDMLParameterisation.hh" 34 #include "G4GDMLParameterisation.hh" 32 #include "G4PolyconeHistorical.hh" 35 #include "G4PolyconeHistorical.hh" 33 #include "G4PolyhedraHistorical.hh" 36 #include "G4PolyhedraHistorical.hh" 34 37 35 // ------------------------------------------- << 36 G4int G4GDMLParameterisation::GetSize() const 38 G4int G4GDMLParameterisation::GetSize() const 37 { 39 { 38 return (G4int) parameterList.size(); << 40 return (G4int)parameterList.size(); 39 } 41 } 40 42 41 // ------------------------------------------- << 42 void G4GDMLParameterisation::AddParameter(cons 43 void G4GDMLParameterisation::AddParameter(const PARAMETER& newParameter) 43 { 44 { 44 parameterList.push_back(newParameter); << 45 parameterList.push_back(newParameter); 45 } 46 } 46 47 47 // ------------------------------------------- << 48 void G4GDMLParameterisation:: 48 void G4GDMLParameterisation::ComputeTransforma << 49 ComputeTransformation(const G4int index,G4VPhysicalVolume* physvol) const 49 const G4int index, G4VPhysicalVolume* physvo << 50 { 50 { 51 physvol->SetTranslation(parameterList[index] << 51 physvol->SetTranslation(parameterList[index].position); 52 physvol->SetRotation(parameterList[index].pR << 52 physvol->SetRotation(parameterList[index].pRot); 53 } 53 } 54 54 55 // ------------------------------------------- << 55 void G4GDMLParameterisation:: 56 void G4GDMLParameterisation::ComputeDimensions << 56 ComputeDimensions(G4Box& box,const G4int index,const G4VPhysicalVolume*) const 57 << 58 { 57 { 59 box.SetXHalfLength(parameterList[index].dime << 58 box.SetXHalfLength(parameterList[index].dimension[0]); 60 box.SetYHalfLength(parameterList[index].dime << 59 box.SetYHalfLength(parameterList[index].dimension[1]); 61 box.SetZHalfLength(parameterList[index].dime << 60 box.SetZHalfLength(parameterList[index].dimension[2]); 62 } 61 } 63 62 64 // ------------------------------------------- << 63 void G4GDMLParameterisation:: 65 void G4GDMLParameterisation::ComputeDimensions << 64 ComputeDimensions(G4Trd& trd,const G4int index,const G4VPhysicalVolume*) const 66 << 67 { 65 { 68 trd.SetXHalfLength1(parameterList[index].dim << 66 trd.SetXHalfLength1(parameterList[index].dimension[0]); 69 trd.SetXHalfLength2(parameterList[index].dim << 67 trd.SetXHalfLength2(parameterList[index].dimension[1]); 70 trd.SetYHalfLength1(parameterList[index].dim << 68 trd.SetYHalfLength1(parameterList[index].dimension[2]); 71 trd.SetYHalfLength2(parameterList[index].dim << 69 trd.SetYHalfLength2(parameterList[index].dimension[3]); 72 trd.SetZHalfLength(parameterList[index].dime << 70 trd.SetZHalfLength(parameterList[index].dimension[4]); 73 } 71 } 74 72 75 // ------------------------------------------- << 73 void G4GDMLParameterisation:: 76 void G4GDMLParameterisation::ComputeDimensions << 74 ComputeDimensions(G4Trap& trap,const G4int index,const G4VPhysicalVolume*) const 77 << 78 { 75 { 79 trap.SetAllParameters(parameterList[index].d << 76 trap.SetAllParameters(parameterList[index].dimension[0], // Dz 80 parameterList[index].d << 77 parameterList[index].dimension[1], // Theta 81 parameterList[index].d << 78 parameterList[index].dimension[2], // Phi 82 parameterList[index].d << 79 parameterList[index].dimension[3], // Dy1 83 parameterList[index].d << 80 parameterList[index].dimension[4], // Dx1 84 parameterList[index].d << 81 parameterList[index].dimension[5], // Dx2 85 parameterList[index].d << 82 parameterList[index].dimension[6], // pAlp1, 86 parameterList[index].d << 83 parameterList[index].dimension[7], // pDy2, 87 parameterList[index].d << 84 parameterList[index].dimension[8], // pDx3, 88 parameterList[index].d << 85 parameterList[index].dimension[9], // pDx4, 89 parameterList[index].d << 86 parameterList[index].dimension[10]); // pAlp2 90 } 87 } 91 88 92 // ------------------------------------------- << 89 void G4GDMLParameterisation:: 93 void G4GDMLParameterisation::ComputeDimensions << 90 ComputeDimensions(G4Tubs& tubs,const G4int index,const G4VPhysicalVolume*) const 94 << 95 { 91 { 96 tubs.SetInnerRadius(parameterList[index].dim << 92 tubs.SetInnerRadius(parameterList[index].dimension[0]); 97 tubs.SetOuterRadius(parameterList[index].dim << 93 tubs.SetOuterRadius(parameterList[index].dimension[1]); 98 tubs.SetZHalfLength(parameterList[index].dim << 94 tubs.SetZHalfLength(parameterList[index].dimension[2]); 99 tubs.SetStartPhiAngle(parameterList[index].d << 95 tubs.SetStartPhiAngle(parameterList[index].dimension[3]); 100 tubs.SetDeltaPhiAngle(parameterList[index].d << 96 tubs.SetDeltaPhiAngle(parameterList[index].dimension[4]); 101 } 97 } 102 98 103 // ------------------------------------------- << 99 void G4GDMLParameterisation:: 104 void G4GDMLParameterisation::ComputeDimensions << 100 ComputeDimensions(G4Cons& cons,const G4int index,const G4VPhysicalVolume*) const 105 << 106 { 101 { 107 cons.SetInnerRadiusMinusZ(parameterList[inde << 102 cons.SetInnerRadiusMinusZ(parameterList[index].dimension[0]); 108 cons.SetOuterRadiusMinusZ(parameterList[inde << 103 cons.SetOuterRadiusMinusZ(parameterList[index].dimension[1]); 109 cons.SetInnerRadiusPlusZ(parameterList[index << 104 cons.SetInnerRadiusPlusZ(parameterList[index].dimension[2]); 110 cons.SetOuterRadiusPlusZ(parameterList[index << 105 cons.SetOuterRadiusPlusZ(parameterList[index].dimension[3]); 111 cons.SetZHalfLength(parameterList[index].dim << 106 cons.SetZHalfLength(parameterList[index].dimension[4]); 112 cons.SetStartPhiAngle(parameterList[index].d << 107 cons.SetStartPhiAngle(parameterList[index].dimension[5]); 113 cons.SetDeltaPhiAngle(parameterList[index].d << 108 cons.SetDeltaPhiAngle(parameterList[index].dimension[6]); 114 } 109 } 115 110 116 // ------------------------------------------- << 111 void G4GDMLParameterisation:: 117 void G4GDMLParameterisation::ComputeDimensions << 112 ComputeDimensions(G4Sphere& sphere,const G4int index,const G4VPhysicalVolume*) const 118 << 119 << 120 { 113 { 121 sphere.SetInnerRadius(parameterList[index].d << 114 sphere.SetInnerRadius(parameterList[index].dimension[0]); 122 sphere.SetOuterRadius(parameterList[index].d << 115 sphere.SetOuterRadius(parameterList[index].dimension[1]); 123 sphere.SetStartPhiAngle(parameterList[index] << 116 sphere.SetStartPhiAngle(parameterList[index].dimension[2]); 124 sphere.SetDeltaPhiAngle(parameterList[index] << 117 sphere.SetDeltaPhiAngle(parameterList[index].dimension[3]); 125 sphere.SetStartThetaAngle(parameterList[inde << 118 sphere.SetStartThetaAngle(parameterList[index].dimension[4]); 126 sphere.SetDeltaThetaAngle(parameterList[inde << 119 sphere.SetDeltaThetaAngle(parameterList[index].dimension[5]); 127 } 120 } 128 121 129 // ------------------------------------------- << 122 void G4GDMLParameterisation:: 130 void G4GDMLParameterisation::ComputeDimensions << 123 ComputeDimensions(G4Orb& orb,const G4int index,const G4VPhysicalVolume*) const 131 << 132 { 124 { 133 orb.SetRadius(parameterList[index].dimension << 125 orb.SetRadius(parameterList[index].dimension[0]); 134 } 126 } 135 127 136 // ------------------------------------------- << 128 void G4GDMLParameterisation:: 137 void G4GDMLParameterisation::ComputeDimensions << 129 ComputeDimensions(G4Ellipsoid& ellipsoid,const G4int index,const G4VPhysicalVolume*) const 138 << 139 << 140 { 130 { 141 ellipsoid.SetSemiAxis(parameterList[index].d << 131 ellipsoid.SetSemiAxis(parameterList[index].dimension[0], 142 parameterList[index].d << 132 parameterList[index].dimension[1], 143 parameterList[index].d << 133 parameterList[index].dimension[2]); 144 ellipsoid.SetZCuts(parameterList[index].dime << 134 ellipsoid.SetZCuts(parameterList[index].dimension[3], 145 parameterList[index].dime << 135 parameterList[index].dimension[4]); 146 } 136 } 147 137 148 // ------------------------------------------- << 138 void G4GDMLParameterisation:: 149 void G4GDMLParameterisation::ComputeDimensions << 139 ComputeDimensions(G4Torus& torus,const G4int index,const G4VPhysicalVolume*) const 150 << 151 << 152 { 140 { 153 torus.SetAllParameters(parameterList[index]. << 141 torus.SetAllParameters(parameterList[index].dimension[0], // pRmin 154 parameterList[index]. << 142 parameterList[index].dimension[1], // pRmax 155 parameterList[index]. << 143 parameterList[index].dimension[2], // pRtor 156 parameterList[index]. << 144 parameterList[index].dimension[3], // pSPhi 157 parameterList[index]. << 145 parameterList[index].dimension[4]); // pDPhi 158 } 146 } 159 147 160 // ------------------------------------------- << 148 void G4GDMLParameterisation:: 161 void G4GDMLParameterisation::ComputeDimensions << 149 ComputeDimensions(G4Para& para,const G4int index,const G4VPhysicalVolume*) const 162 << 163 { 150 { 164 para.SetXHalfLength(parameterList[index].dim << 151 para.SetXHalfLength(parameterList[index].dimension[0]); 165 para.SetYHalfLength(parameterList[index].dim << 152 para.SetYHalfLength(parameterList[index].dimension[1]); 166 para.SetZHalfLength(parameterList[index].dim << 153 para.SetZHalfLength(parameterList[index].dimension[2]); 167 para.SetAlpha(parameterList[index].dimension << 154 para.SetAlpha(parameterList[index].dimension[3]); 168 para.SetTanAlpha(std::tan(parameterList[inde << 155 para.SetTanAlpha(std::tan(parameterList[index].dimension[3])); 169 para.SetThetaAndPhi(parameterList[index].dim << 156 para.SetThetaAndPhi(parameterList[index].dimension[4],parameterList[index].dimension[5]); 170 parameterList[index].dim << 171 } 157 } 172 158 173 // ------------------------------------------- << 159 void G4GDMLParameterisation:: 174 void G4GDMLParameterisation::ComputeDimensions << 160 ComputeDimensions(G4Hype& hype,const G4int index,const G4VPhysicalVolume*) const 175 << 176 { 161 { 177 hype.SetInnerRadius(parameterList[index].dim << 162 hype.SetInnerRadius(parameterList[index].dimension[0]); 178 hype.SetOuterRadius(parameterList[index].dim << 163 hype.SetOuterRadius(parameterList[index].dimension[1]); 179 hype.SetZHalfLength(parameterList[index].dim << 164 hype.SetZHalfLength(parameterList[index].dimension[4]); 180 hype.SetInnerStereo(parameterList[index].dim << 165 hype.SetInnerStereo(parameterList[index].dimension[2]); 181 hype.SetOuterStereo(parameterList[index].dim << 166 hype.SetOuterStereo(parameterList[index].dimension[3]); 182 } 167 } 183 168 184 // ------------------------------------------- << 169 void G4GDMLParameterisation:: 185 void G4GDMLParameterisation::ComputeDimensions << 170 ComputeDimensions(G4Polycone& pcone,const G4int index,const G4VPhysicalVolume*) const 186 << 187 << 188 { 171 { 189 G4PolyconeHistorical origparam(*(pcone.GetOr << 172 190 origparam.Start_angle = parameterList[inde << 173 G4PolyconeHistorical origparam( *(pcone.GetOriginalParameters()) ); 191 origparam.Opening_angle = parameterList[inde << 174 origparam.Start_angle = parameterList[index].dimension[0]; 192 origparam.Num_z_planes = (G4int) parameterL << 175 origparam.Opening_angle = parameterList[index].dimension[1]; 193 G4int nZplanes = origparam.Num_z_pl << 176 origparam.Num_z_planes = (G4int) parameterList[index].dimension[2]; 194 << 177 G4int nZplanes = origparam.Num_z_planes; 195 for(G4int ii = 0; ii < nZplanes; ++ii) << 178 196 { << 179 for( G4int ii = 0; ii < nZplanes; ii++ ) 197 origparam.Rmin[ii] = parameterList[ind << 180 { 198 origparam.Rmax[ii] = parameterList[ind << 181 origparam.Rmin[ii] = parameterList[index].dimension[3+ii*3] ; 199 origparam.Z_values[ii] = parameterList[ind << 182 origparam.Rmax[ii] = parameterList[index].dimension[4+ii*3] ; 200 } << 183 origparam.Z_values[ii] = parameterList[index].dimension[5+ii*3] ; >> 184 } 201 185 202 pcone.SetOriginalParameters(&origparam); // << 186 pcone.SetOriginalParameters(&origparam); // copy values & transfer pointers 203 pcone.Reset(); // << 187 pcone.Reset(); // reset to new solid parameters >> 188 204 } 189 } 205 190 206 // ------------------------------------------- << 191 void G4GDMLParameterisation:: 207 void G4GDMLParameterisation::ComputeDimensions << 192 ComputeDimensions(G4Polyhedra& polyhedra,const G4int index,const G4VPhysicalVolume*) const 208 << 193 { 209 << 194 G4PolyhedraHistorical origparam( *(polyhedra.GetOriginalParameters()) ); 210 { << 195 origparam.Start_angle = parameterList[index].dimension[0]; 211 G4PolyhedraHistorical origparam(*(polyhedra. << 196 origparam.Opening_angle = parameterList[index].dimension[1]; 212 origparam.Start_angle = parameterList[inde << 197 origparam.Num_z_planes = (G4int) parameterList[index].dimension[2]; 213 origparam.Opening_angle = parameterList[inde << 198 origparam.numSide = (G4int) parameterList[index].dimension[3]; 214 origparam.Num_z_planes = (G4int) parameterL << 199 215 origparam.numSide = (G4int) parameterL << 200 G4int nZplanes = origparam.Num_z_planes; 216 << 201 217 G4int nZplanes = origparam.Num_z_planes; << 202 for( G4int ii = 0; ii < nZplanes; ii++ ) 218 << 203 { 219 for(G4int ii = 0; ii < nZplanes; ++ii) << 204 220 { << 205 origparam.Rmin[ii] = parameterList[index].dimension[4+ii*3] ; 221 origparam.Rmin[ii] = parameterList[ind << 206 origparam.Rmax[ii] = parameterList[index].dimension[5+ii*3] ; 222 origparam.Rmax[ii] = parameterList[ind << 207 origparam.Z_values[ii] = parameterList[index].dimension[6+ii*3] ; 223 origparam.Z_values[ii] = parameterList[ind << 208 224 } 209 } 225 polyhedra.SetOriginalParameters( << 210 polyhedra.SetOriginalParameters(&origparam); // copy values & transfer pointers 226 &origparam); // copy values & transfe << 211 polyhedra.Reset(); // reset to new solid parameters 227 polyhedra.Reset(); // reset to new solid pa << 228 } 212 } 229 213