[1316] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: ExDivTesterPolyhedra.cc,v 1.3 2006/06/29 18:20:24 gunter Exp $ |
---|
[1347] | 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
[1316] | 29 | // |
---|
| 30 | // class ExDivTesterPolyhedra Implementation file |
---|
| 31 | // |
---|
| 32 | // 26.05.03 - P.Arce Initial version |
---|
| 33 | // ******************************************************************** |
---|
| 34 | |
---|
| 35 | #include "ExDivTesterPolyhedra.hh" |
---|
| 36 | #include "G4Polyhedra.hh" |
---|
| 37 | |
---|
| 38 | #include "G4ThreeVector.hh" |
---|
| 39 | #include "Randomize.hh" |
---|
| 40 | #include <fstream> |
---|
| 41 | #include "G4PVPlacement.hh" |
---|
| 42 | |
---|
| 43 | //-------------------------------------------------------------------------- |
---|
| 44 | ExDivTesterPolyhedra:: |
---|
| 45 | ExDivTesterPolyhedra( PVType& pvtype, PlaceType& postype, |
---|
| 46 | std::vector<G4String>& extraPars ) |
---|
| 47 | : ExVDivTester( pvtype, postype, extraPars ) |
---|
| 48 | { |
---|
| 49 | //----- Get the axis of division |
---|
| 50 | theAxis.push_back( kRho ); |
---|
| 51 | theAxis.push_back( kPhi ); |
---|
| 52 | theAxis.push_back( kZAxis ); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | //-------------------------------------------------------------------------- |
---|
| 56 | void ExDivTesterPolyhedra::GenerateScanPoints() |
---|
| 57 | { |
---|
| 58 | std::ofstream fout("points.lis"); |
---|
| 59 | G4int ii; |
---|
| 60 | |
---|
| 61 | G4int nPointsPerDiv = 2; |
---|
| 62 | numberOfPoints = theNDiv * nPointsPerDiv; |
---|
| 63 | // For division along X |
---|
| 64 | G4ThreeVector centre(0.,0.,-2*theWorldLengthXY); |
---|
| 65 | for( ii = 0; ii < numberOfPoints; ii++ ) |
---|
| 66 | { |
---|
| 67 | // any Z, any Y |
---|
| 68 | G4ThreeVector pR( 0., theWorldLengthXY/100., theWorldLengthXY/100. ); |
---|
| 69 | G4double X = -theWorldLengthXY + (ii+0.001) * 2*theWorldLengthXY/numberOfPoints; |
---|
| 70 | pR.setX( X ); |
---|
| 71 | pR += centre; |
---|
| 72 | fout << pR.x() << " " << pR.y() << " " << pR.z() << G4endl; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // For division along Y |
---|
| 76 | centre = G4ThreeVector(0.,0.,0.); |
---|
| 77 | for( ii = 0; ii < numberOfPoints; ii++ ) |
---|
| 78 | { |
---|
| 79 | // any X, any Z |
---|
| 80 | G4ThreeVector pR( theWorldLengthXY/100., 0., theWorldLengthXY/100. ); |
---|
| 81 | G4double Y = -theWorldLengthXY + (ii+0.001) * 2*theWorldLengthXY/numberOfPoints; |
---|
| 82 | pR.setY( Y ); |
---|
| 83 | pR += centre; |
---|
| 84 | fout << pR.x() << " " << pR.y() << " " << pR.z() << G4endl; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | // For division along Z |
---|
| 88 | centre = G4ThreeVector(0.,0.,2*theWorldLengthXY); |
---|
| 89 | for( ii = 0; ii < numberOfPoints; ii++ ) |
---|
| 90 | { |
---|
| 91 | // any X, any Y |
---|
| 92 | G4ThreeVector pR( theWorldLengthXY/100., 0., theWorldLengthXY/100. ); |
---|
| 93 | G4double Z = -theWorldLengthXY + (ii+0.001) * 2*theWorldLengthXY/numberOfPoints; |
---|
| 94 | pR.setZ( Z ); |
---|
| 95 | pR += centre; |
---|
| 96 | fout << pR.x() << " " << pR.y() << " " << pR.z() << G4endl; |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | //-------------------------------------------------------------------------- |
---|
| 101 | void ExDivTesterPolyhedra::BuildParentSolids() |
---|
| 102 | { |
---|
| 103 | G4int numSides = 3; |
---|
| 104 | G4int numZPlanes = 4; |
---|
| 105 | G4double* zPlane1 = new G4double[numZPlanes]; |
---|
| 106 | zPlane1[0]=-theWorldLengthXY; |
---|
| 107 | zPlane1[1]=-0.25*theWorldLengthXY; |
---|
| 108 | zPlane1[2]= 0.5*theWorldLengthXY; |
---|
| 109 | zPlane1[3]= theWorldLengthXY; |
---|
| 110 | G4double* rInner1 = new G4double[numZPlanes]; |
---|
| 111 | rInner1[0]=0./2.; |
---|
| 112 | rInner1[1]=0.1*theWorldLengthXY/2.; |
---|
| 113 | rInner1[2]=0.3*theWorldLengthXY/2.; |
---|
| 114 | rInner1[3]=0.4*theWorldLengthXY/2.; |
---|
| 115 | G4double* rOuter1 = new G4double[numZPlanes]; |
---|
| 116 | rOuter1[0]=0.2*theWorldLengthXY/2.; |
---|
| 117 | rOuter1[1]=0.4*theWorldLengthXY/2.; |
---|
| 118 | rOuter1[2]=0.6*theWorldLengthXY/2.; |
---|
| 119 | rOuter1[3]=0.9*theWorldLengthXY/2.; |
---|
| 120 | G4double* zPlane2 = new G4double[numZPlanes]; |
---|
| 121 | zPlane2[0]=-theWorldLengthXY; |
---|
| 122 | zPlane2[1]=-0.25*theWorldLengthXY; |
---|
| 123 | zPlane2[2]= 0.5*theWorldLengthXY; |
---|
| 124 | zPlane2[3]= theWorldLengthXY; |
---|
| 125 | G4double* rInner2 = new G4double[numZPlanes]; |
---|
| 126 | rInner2[0]=0./2.; |
---|
| 127 | rInner2[1]=0.1*theWorldLengthXY/2.; |
---|
| 128 | rInner2[2]=0.3*theWorldLengthXY/2.; |
---|
| 129 | rInner2[3]=0.4*theWorldLengthXY/2.; |
---|
| 130 | G4double* rOuter2 = new G4double[numZPlanes]; |
---|
| 131 | rOuter2[0]=0.2*theWorldLengthXY/2.; |
---|
| 132 | rOuter2[1]=0.4*theWorldLengthXY/2.; |
---|
| 133 | rOuter2[2]=0.6*theWorldLengthXY/2.; |
---|
| 134 | rOuter2[3]=0.9*theWorldLengthXY/2.; |
---|
| 135 | G4double* zPlane3 = new G4double[numZPlanes]; |
---|
| 136 | zPlane3[0]=-theWorldLengthXY; |
---|
| 137 | zPlane3[1]=-0.25*theWorldLengthXY; |
---|
| 138 | zPlane3[2]= 0.5*theWorldLengthXY; |
---|
| 139 | zPlane3[3]= theWorldLengthXY; |
---|
| 140 | G4double* rInner3 = new G4double[numZPlanes]; |
---|
| 141 | rInner3[0]=0./2.; |
---|
| 142 | rInner3[1]=0.1*theWorldLengthXY/2.; |
---|
| 143 | rInner3[2]=0.2*theWorldLengthXY/2.; |
---|
| 144 | rInner3[3]=0.4*theWorldLengthXY/2.; |
---|
| 145 | G4double* rOuter3 = new G4double[numZPlanes]; |
---|
| 146 | rOuter3[0]=0.2*theWorldLengthXY/2.; |
---|
| 147 | rOuter3[1]=0.4*theWorldLengthXY/2.; |
---|
| 148 | rOuter3[2]=0.6*theWorldLengthXY/2.; |
---|
| 149 | rOuter3[3]=0.9*theWorldLengthXY/2.; |
---|
| 150 | theParentSolids.push_back( new G4Polyhedra("parent_1", theStartPhi, theDeltaPhi, |
---|
| 151 | numSides, numZPlanes, zPlane1, rInner1, rOuter1 ) ); |
---|
| 152 | theParentSolids.push_back( new G4Polyhedra("parent_2", theStartPhi, theDeltaPhi, |
---|
| 153 | numSides, numZPlanes, zPlane2, rInner2, rOuter2 ) ); |
---|
| 154 | theParentSolids.push_back( new G4Polyhedra("parent_3", theStartPhi, theDeltaPhi, |
---|
| 155 | numSides, numZPlanes, zPlane3, rInner3, rOuter3 ) ); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | //-------------------------------------------------------------------------- |
---|
| 159 | void ExDivTesterPolyhedra::BuildChildrenSolids() |
---|
| 160 | { |
---|
| 161 | G4int numSides = 3; |
---|
| 162 | G4int numZPlanes = 4; |
---|
| 163 | G4double* zPlane1 = new G4double[numZPlanes]; |
---|
| 164 | zPlane1[0]=-theWorldLengthXY; |
---|
| 165 | zPlane1[1]=-0.25*theWorldLengthXY; |
---|
| 166 | zPlane1[2]= 0.5*theWorldLengthXY; |
---|
| 167 | zPlane1[3]= theWorldLengthXY; |
---|
| 168 | G4double* rInner1 = new G4double[numZPlanes]; |
---|
| 169 | rInner1[0]=0./2.; |
---|
| 170 | rInner1[1]=0.1*theWorldLengthXY/2.; |
---|
| 171 | rInner1[2]=0.2*theWorldLengthXY/2.; |
---|
| 172 | rInner1[3]=0.4*theWorldLengthXY/2.; |
---|
| 173 | G4double* rOuter1 = new G4double[numZPlanes]; |
---|
| 174 | rOuter1[0]=0.2*theWorldLengthXY/2.; |
---|
| 175 | rOuter1[1]=0.4*theWorldLengthXY/2.; |
---|
| 176 | rOuter1[2]=0.6*theWorldLengthXY/2.; |
---|
| 177 | rOuter1[3]=0.9*theWorldLengthXY/2.; |
---|
| 178 | G4double* zPlane2 = new G4double[numZPlanes]; |
---|
| 179 | zPlane2[0]=-theWorldLengthXY; |
---|
| 180 | zPlane2[1]=-0.25*theWorldLengthXY; |
---|
| 181 | zPlane2[2]= 0.5*theWorldLengthXY; |
---|
| 182 | zPlane2[3]= theWorldLengthXY; |
---|
| 183 | G4double* rInner2 = new G4double[numZPlanes]; |
---|
| 184 | rInner2[0]=0./2.; |
---|
| 185 | rInner2[1]=0.1*theWorldLengthXY/2.; |
---|
| 186 | rInner2[2]=0.2*theWorldLengthXY/2.; |
---|
| 187 | rInner2[3]=0.4*theWorldLengthXY/2.; |
---|
| 188 | G4double* rOuter2 = new G4double[numZPlanes]; |
---|
| 189 | rOuter2[0]=0.2*theWorldLengthXY/2.; |
---|
| 190 | rOuter2[1]=0.4*theWorldLengthXY/2.; |
---|
| 191 | rOuter2[2]=0.6*theWorldLengthXY/2.; |
---|
| 192 | rOuter2[3]=0.9*theWorldLengthXY/2.; |
---|
| 193 | G4double* zPlane3 = new G4double[numZPlanes]; |
---|
| 194 | zPlane3[0]=-theWorldLengthXY; |
---|
| 195 | zPlane3[1]=-0.25*theWorldLengthXY; |
---|
| 196 | zPlane3[2]= 0.5*theWorldLengthXY; |
---|
| 197 | zPlane3[3]= theWorldLengthXY; |
---|
| 198 | G4double* rInner3 = new G4double[numZPlanes]; |
---|
| 199 | rInner3[0]=0./2.; |
---|
| 200 | rInner3[1]=0.1*theWorldLengthXY/2.; |
---|
| 201 | rInner3[2]=0.2*theWorldLengthXY/2.; |
---|
| 202 | rInner3[3]=0.4*theWorldLengthXY/2.; |
---|
| 203 | G4double* rOuter3 = new G4double[numZPlanes]; |
---|
| 204 | rOuter3[0]=0.2*theWorldLengthXY/2.; |
---|
| 205 | rOuter3[1]=0.4*theWorldLengthXY/2.; |
---|
| 206 | rOuter3[2]=0.6*theWorldLengthXY/2.; |
---|
| 207 | rOuter3[3]=0.9*theWorldLengthXY/2.; |
---|
| 208 | |
---|
| 209 | G4Polyhedra* msol = (G4Polyhedra*)theParentSolids[0]; |
---|
| 210 | G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); |
---|
| 211 | G4double rMax = origparamMother->Rmax[0] - origparamMother->Rmin[0]; |
---|
| 212 | msol = (G4Polyhedra*)theParentSolids[1]; |
---|
| 213 | G4double phiMax = msol->GetEndPhi() - msol->GetStartPhi(); |
---|
| 214 | msol = (G4Polyhedra*)theParentSolids[2]; |
---|
| 215 | origparamMother = msol->GetOriginalParameters(); |
---|
| 216 | G4double zMax = origparamMother->Z_values[origparamMother->Num_z_planes-1] - origparamMother->Z_values[0]; |
---|
| 217 | |
---|
| 218 | theWidths.push_back( rMax / theNDiv ); |
---|
| 219 | theWidths.push_back( phiMax / theNDiv ); |
---|
| 220 | theWidths.push_back( zMax / theNDiv ); |
---|
| 221 | |
---|
| 222 | theChildSolids.push_back( new G4Polyhedra("child_1", theStartPhi, theDeltaPhi, |
---|
| 223 | numSides, numZPlanes, zPlane1, rInner1, rOuter1 ) ); |
---|
| 224 | theChildSolids.push_back( new G4Polyhedra("child_2", theStartPhi, theWidths[0], |
---|
| 225 | numSides, numZPlanes, zPlane2, rInner2, rOuter2 ) ); |
---|
| 226 | theChildSolids.push_back( new G4Polyhedra("child_3", theStartPhi, theDeltaPhi, |
---|
| 227 | numSides, numZPlanes, zPlane3, rInner3, rOuter3 ) ); |
---|
| 228 | } |
---|
| 229 | |
---|