''' Author: Federica Lionetto Date: January 5th, 2015 Description: Automated measurement for focusing. After the measurement, the position of the laser along x and z is reset. Parameters: - <firstx>, the first x position; - <lastx>, the last x position; - <stepx>, the step size along x; - <firstz>, the first z position; - <lastz>, the last z position; - <stepz>, the step size along z. How to run it: python Focusing.py --fx <firstx> --lx <lastx> --sx <stepx> --fz <firstz> --lz <lastz> --sz <stepz> --date <yyyymmdd> ''' import argparse import subprocess import os parser = argparse.ArgumentParser(description='Define the parameters of the automated measurement for focusing.') parser.add_argument('--fx',type=int,help='first x position') parser.add_argument('--lx',type=int,help='last x position') parser.add_argument('--sx',type=int,help='step size along x') parser.add_argument('--fz',type=int,help='first z position') parser.add_argument('--lz',type=int,help='last z position') parser.add_argument('--sz',type=int,help='step size along z') parser.add_argument('--date',type=int,help='date according to the yyyymmdd format') args = parser.parse_args() # Parameters and configuration. firstx = args.fx lastx = args.lx stepx = args.sx firstz = args.fz lastz = args.lz stepz = args.sz yyyymmdd = args.date nevents = 10000 folder = '/home/hep/flionett/TestStand/Data' filename = '' config = '/home/hep/flionett/TestStand/Repository/Software/AutomatedMeasurements/FocusingConfig' print 'First x position: %i steps' % firstx print 'Last x position: %i steps' % lastx print 'Step size along x: %i steps' % stepx print 'First z position: %i steps' % firstz print 'Last z position: %i steps' % lastz print 'Step size along z: %i steps' % stepz print 'Number of events per DAQ: %i' % nevents # Number of scanned x positions. stepsx = (lastx-firstx)/stepx+1 print 'Number of scanned x positions: %i' % stepsx # Number of scanned z positions. stepsz = (lastz-firstz)/stepz+1 print 'Number of scanned z positions: %i' % stepsz for posz in range(firstz,lastz+stepz,stepz) : for posx in range(firstx,lastx+stepx,stepx) : filename = folder+"/Hans410/Test/"+str(yyyymmdd)+"-216-"+str(posx)+"x-"+str(posz)+"z-las.ali" command = "echo alibava-gui --no-gui --nevts="+str(nevents)+" --out="+filename+" --laser "+config # command = "echo test"+str(posz)+"z"+str(posx)+"x" subprocess.call(command,shell=True)