Functions | Variables
makePolycone Namespace Reference

Functions

def usage ()
 
def ReadPoints (fileName)
 
def FindRadius (z, points)
 
def FindRange (inner, outer, step)
 
def SegmentIsOK (p1, p2, middle, thres)
 

Variables

string vectorName = "polyconeShape"
 
float boundaryStep = 0.3
 
float precision = 0.3
 
float minimumSegment = 0.5
 
 innerPoints = ReadPoints(args[0])
 
 outerPoints = ReadPoints(args[1])
 
list boundary = []
 
 z = boundaryStep*iZ
 
 inner = FindRadius(z,innerPoints)
 
 outer = FindRadius(z,outerPoints)
 
list savedPoints = [boundary[0]]
 
list runningPoints = []
 

Function Documentation

def makePolycone.FindRadius (   z,
  points 
)

Definition at line 84 of file makePolycone.py.

84 def FindRadius(z,points):
85  radii=[]
86  there=points[-1]
87  for here in points:
88  if ((there[0] <= z and z < here[0])
89  or (here[0] <= z and z < there[0])):
90  r = (here[1]-there[1])/(here[0]-there[0])*(z-there[0]) + there[1]
91  radii.append(r)
92  there = here
93  if len(radii) == 0: return 0.0
94  average = reduce(lambda x, y: x+y, radii)/len(radii)
95  r = 0.0
96  for p in radii:
97  r = r + abs(p-average)
98  return r/len(radii)
99 
100 # Find the total range along the vertical axis of the cryostat that
101 # needs to be used to define the polycone.
static std::string reduce(const std::string &str, const std::string &fill=" ", const std::string &whitespace=" \t")
Definition: doxyindexer.cpp:63
def FindRadius(z, points)
Definition: makePolycone.py:84
T abs(T value)
def makePolycone.FindRange (   inner,
  outer,
  step 
)

Definition at line 102 of file makePolycone.py.

102 def FindRange(inner,outer,step):
103  minZ = min(innerPoints[0][0],outerPoints[0][0])
104  maxZ = max(innerPoints[0][0],outerPoints[0][0])
105  for p in inner:
106  minZ = min(p[0], minZ)
107  maxZ = max(p[0], maxZ)
108  for p in outer:
109  minZ = min(p[0], minZ)
110  maxZ = max(p[0], maxZ)
111  return xrange(int(minZ/step)-1, int(maxZ/step)+2)
112 
113 # Check to see if a new polycone segment needs to be started.
def FindRange(inner, outer, step)
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
def makePolycone.ReadPoints (   fileName)

Definition at line 68 of file makePolycone.py.

68 def ReadPoints(fileName):
69  print "// Filename: ", fileName
70  points = []
71  for line in open(fileName):
72  if line[0] == "/":
73  print line.rstrip()
74  continue
75  if len(line) < 5: continue
76  spl = line.split()
77  points.append([float(spl[0]),float(spl[1])])
78  return points
79 
80 # Find the radius of the cryostat at a particular vertical position.
81 # This is called "z" since it's going to be used to buill a G4Polycone
82 # along the Z axis. In the Z axis here is equivalent to the X axis in
83 # the input file.
int open(const char *, int)
Opens a file descriptor.
def ReadPoints(fileName)
Definition: makePolycone.py:68
def makePolycone.SegmentIsOK (   p1,
  p2,
  middle,
  thres 
)

Definition at line 114 of file makePolycone.py.

114 def SegmentIsOK(p1,p2,middle,thres):
115  if abs(p1[0]-p2[0]) < minimumSegment: return True;
116  maxThres = 0.0
117  for p in middle:
118  r1 = (p[0]-p2[0])*(p1[1]-p2[1])/(p1[0]-p2[0]) + p2[1]
119  r2 = (p[0]-p2[0])*(p1[2]-p2[2])/(p1[0]-p2[0]) + p2[2]
120  maxThres = max(maxThres, abs(r1-p[1]))
121  maxThres = max(maxThres, abs(r2-p[2]))
122  if maxThres > thres: return False;
123  return True
124 
T abs(T value)
def SegmentIsOK(p1, p2, middle, thres)
static int max(int a, int b)
def makePolycone.usage ( )

Definition at line 7 of file makePolycone.py.

7 def usage():
8  print """
9  makePolycone <inner-surface.txt> <outer-surface.txt>
10 
11  Outputs text to the standard output that is suitable to be included
12  into a C++ source file defining the inner and outer surfaces of a
13  G4Polycone.
14 
15  --vector-name <name>
16  The name of a vector to be used in the include file.
17 
18  --step
19  The step size along the Z axis to use while building the
20  polycone. This can be small (but it will make this run slowly),
21  since only the steps where the precision is bad will be saved.
22 
23  --precision
24  Set the maximum distance the wall of the cryostat can be from the
25  interpolated line.
26  """
27 
28 try:
29  options, args = getopt.gnu_getopt(sys.argv[1:],
30  "h",
31  ["vector-name=",
32  "precision=",
33  "step=",
34  "minimum-segment=",
35  "help"])
36 except:
37  usage()
38  print "ERROR: Invalid option."
39  sys.exit(1)
40 

Variable Documentation

list makePolycone.boundary = []

Definition at line 151 of file makePolycone.py.

makePolycone.boundaryStep = 0.3

Definition at line 47 of file makePolycone.py.

makePolycone.inner = FindRadius(z,innerPoints)

Definition at line 154 of file makePolycone.py.

makePolycone.innerPoints = ReadPoints(args[0])

Definition at line 144 of file makePolycone.py.

makePolycone.minimumSegment = 0.5

Definition at line 49 of file makePolycone.py.

makePolycone.outer = FindRadius(z,outerPoints)

Definition at line 155 of file makePolycone.py.

makePolycone.outerPoints = ReadPoints(args[1])

Definition at line 146 of file makePolycone.py.

makePolycone.precision = 0.3

Definition at line 48 of file makePolycone.py.

list makePolycone.runningPoints = []

Definition at line 163 of file makePolycone.py.

list makePolycone.savedPoints = [boundary[0]]

Definition at line 162 of file makePolycone.py.

makePolycone.vectorName = "polyconeShape"

Definition at line 46 of file makePolycone.py.

makePolycone.z = boundaryStep*iZ

Definition at line 153 of file makePolycone.py.