#!/usr/bin/env python import sys import time from BCALModule import SubDetector def main(): start = time.time() sides, quadrants = option_handler(sys.argv) if '--mppc-bias-on' in sys.argv: for s in sides: sd = SubDetector(s,sim=False) for q in quadrants: sd.quadrant[q].turn_mppc_bias_on() if '--mppc-bias-off' in sys.argv: for s in sides: sd = SubDetector(s,sim=False) for q in quadrants: sd.quadrant[q].turn_mppc_bias_off() if '--mppc-lv-on' in sys.argv: for s in sides: sd = SubDetector(s,sim=False) sd.turn_mppc_lv_on() if '--mppc-lv-off' in sys.argv: for s in sides: sd = SubDetector(s,sim=False) sd.turn_mppc_lv_off() end = time.time() print "All done!\nElapsed time: %f (min)" % (float(end-start)/60.0) def option_handler(argv): sides=['U','D'] quadrants = range(1,5) if len(argv) > 1: if '-s' in argv: try: s = argv[argv.index('-s')+1] except IndexError: print "Error: missing side (U or D) after [-s] option" sys.exit(1) if s in sides: sides = s else: print "Error: side must be U or D" sys.exit(1) if '-q' in argv: try: q = int(argv[argv.index('-q')+1]) except IndexError: print "Error: missing quadrant (1 to 4) after [-q] option" sys.exit(1) if q in quadrants: quadrants = (q,) else: print "Error: quadrant must be an integer in [1,4]" sys.exit(1) if '-h' in argv or '--help' in argv: print''' %s [option value] options: -s < U | D >: Select side U for upstream or D for downstream. If this option is not given, it will run through both sides. -q < number >: Select quadrant with number in {1,...,4}. If this option is not given, it will run through all quadrants. --mppc-bias-on: Turn mppc bias on, on the selected side and quadrant. --mppc-bias-off: Turn mppc bias off, on the selected side and quadrant. -h,--help: Show this help. Example: %s -s U -q 1 --mppc-bias-on Autor: Orlando Soto, May, 2014 '''%(argv[0], argv[0]) sys.exit(0) return sides,quadrants if __name__=="__main__": main()