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