diff --git a/scripts/checkPulseData.py b/scripts/checkPulseData.py index ff9b3bc..7bd16a8 100644 --- a/scripts/checkPulseData.py +++ b/scripts/checkPulseData.py @@ -3,6 +3,7 @@ import os import string import numpy as np +import pandas as pd import ROOT as r location = os.path.expandvars('$DISK/data/ST/Aging/') @@ -95,6 +96,8 @@ + + if __name__ == '__main__': if 'VERB' in sys.argv: @@ -130,11 +133,19 @@ warning = warning.format(LAY=layer) not_found = StringTemplate('{LAY}/{SEC} on fill {FILL}: calibration step {CS} not found for ns={NS}') not_found = not_found.format(LAY=layer) + + # Init data frame + data_frame = pd.DataFrame(columns=['Detector', + 'Sector', + 'Fill', + 'N strips', + 'V bias', + 'MPVs']) # Loop on data - for ns in nstrips: - for fill in fills: - for sector in sectors: + for fill in fills: + for sector in sectors: + for ns in nstrips: # Loop on voltages for vstep in range(11): pulse = [] @@ -152,13 +163,23 @@ SEC=sector, CS=cstep)) pulse.append(None) - pulse = build_pulse(pulse) - if monotonic(pulse): - pulse = [round(v,2) for v in pulse] - print(warning.format(NS=ns, - FILL=fill, - SEC=sector, - V=vmap[vstep], - PULSE=pulse)) + #pulse = build_pulse(pulse) + if monotonic(build_pulse(pulse)): + # Append this occurrence to the data frame + # Probably it would be faster to do as suggested here: + # http://stackoverflow.com/a/17496530/3324012 + data_frame.loc[len(data_frame)] = [detector, + sector, + fill, + ns, + vmap[vstep], + pulse] + if VERBOSE: + pulse = [round(v,2) for v in pulse] + print(warning.format(NS=ns, + FILL=fill, + SEC=sector, + V=vmap[vstep], + PULSE=pulse)) # datafile.Close()