Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-27 03:18:08

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