Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:04

0001 #! /usr/bin/env python
0002 
0003 from __future__ import print_function
0004 import sys
0005 import material
0006 
0007 def usage():
0008   print("""Usage:
0009     dump.py DIRECTION
0010 
0011 Read a list of detectors from standard input and dump their coordinate along DIRECTION.
0012 """)
0013 
0014 def dump():
0015   if (len(sys.argv) < 2) or (sys.argv[1] not in material.Element.directions):
0016     usage()
0017     sys.exit(1)
0018   dir = material.Element.directions[sys.argv[1]]
0019 
0020   elements  = material.parse(sys.stdin)
0021   if len(elements) == 0:
0022     sys.exit(1)
0023 
0024   positions = set()
0025   for element in elements:
0026     positions.add(element.position[dir])
0027   positions = sorted(positions)
0028   for position in positions:
0029     print(position)
0030 
0031 
0032 if __name__ == "__main__":
0033   dump()