diff --git a/scripts/checkShift.py b/scripts/checkShift.py index 40a4efa..9d929a6 100644 --- a/scripts/checkShift.py +++ b/scripts/checkShift.py @@ -2,8 +2,9 @@ import numpy as np from ROOT import TFile, TLorentzVector, TVector3, TRotation, TLorentzRotation, TMath, TH1D, TCanvas, TH2D, TObject, TF1 import matplotlib.pyplot as plt +import seaborn as sns import pandas as pd -import pickle + from checkPulseData import Table import os import math as m @@ -12,7 +13,7 @@ #Given the fitted parameters calculates the maximum point def GetMaximumPoint(t0, t0_err, tau, tau_err): - #The position of the maximum can be obtained from the functional for used for the fit + #The position of the maximum can be obtained from the functional form used for the fit t = t0 + (3 - m.sqrt(3))*tau t_err = m.sqrt(t0_err*t0_err + (3 - m.sqrt(3))*tau_err*(3 - m.sqrt(3))*tau_err) return t, t_err @@ -29,12 +30,18 @@ if __name__ == '__main__': + ''' + Autor: Michele Atzeni + Email: michele.atzeni@cern.ch + + Working in date 14.06.2017 + ''' parser = argparse.ArgumentParser(description = 'Configuration of the parameters for the SplitAndMerge') - parser.add_argument("-d", "--detector" , dest="detector" , help="Choose the detector to use ",choices=['TT','IT'], default = 'IT') - parser.add_argument("-l", "--layer" , dest="layer", help="Choose the layer to use",choices=['TTaU','T3X2'], default = 'T3X2') - parser.add_argument("-n", "--nstrips" , dest="nstrips", help="Choose the number of strips to use",choices=['3','5','7'], default = ['7']) + parser.add_argument("-d", "--detector" , dest="detector" , help="Choose the detector to use ",choices=['TT','IT'], default = 'TT') + parser.add_argument("-l", "--layer" , dest="layer", help="Choose the layer to use",choices=['TTaU','T3X2'], default = 'TTaU') + parser.add_argument("-n", "--nstrips" , dest="nstrips", help="Choose the number of strips to use",choices=['3','5','7'], default = ['5']) parser.add_argument("--Vred", action="store_true", help="exclude the 3 lowest Vbias") parser.add_argument("--VERB", action="store_true", help="VERBOsE") args = parser.parse_args() @@ -49,12 +56,20 @@ #Plotting options - plot1 = False + plot1 = True plot2 = True location = os.path.expandvars('$DISK/data/ST/Aging/') fileData = TFile(location+'CCEScan.root') - + + Outputfolder = os.path.expandvars('$DISK/')+'data/ST/graphics/{}/{}/Max_Evol_Plots/'.format(detector, layer) + + if not os.path.exists(Outputfolder) : + print "Creating the folder {}".format(Outputfolder) + raw_input("Ctrl-C to abort, return to continue") + os.makedirs(Outputfolder) + + #detector = 'TT' #layer = 'TTaU' #nstrips = [5]#[3, 5, 7] @@ -64,8 +79,9 @@ voltMapIT = [300., 200., 170., 140., 120., 105., 90., 75., 60., 40., 20.] voltMapTTred = [400., 350., 300., 250., 225., 200., 175., 150.] voltMapITred = [300., 200., 170., 140., 120., 105., 90., 75.] - - if(detector is 'TT'): + + + if(detector == 'TT'): if (Vred): voltMap = voltMapTTred else: @@ -75,7 +91,8 @@ voltMap = voltMapITred else: voltMap = voltMapIT - + + #Load Fills macros = os.path.expandvars('$CCEHOME/macros/CCEScan/') with open(macros + 'Fills.dat', 'rb') as f: @@ -130,7 +147,10 @@ #print (fileData, detector, layer, isect, ifill, calibstep, istrip) df = pd.DataFrame.from_dict(table) - + if not os.path.isfile('Shifts_{DET}.pkl'.format(DET=detector)): + import pickle + pickle.dump(df, open('Shifts_{DET}.pkl'.format(DET=detector), 'wb')) + #################### if(plot1 == True): @@ -141,23 +161,28 @@ for v in voltMap: - plt.errorbar(df1[(df1.Vbias == v)]['Fill'], df1[(df1.Vbias == v)]['x_max'], df1[(df1.Vbias == v)]['x_err'], fmt='-^',label=str(v)+' V') - + df1p = df1[(df1.Vbias == v)] + + plt.errorbar(x=df1p['Fill'].values , y=df1p['x_max'].values, yerr=df1p['x_err'].values, fmt='-^',label='{} V'.format(str(v))) + #plt.errorbar(x=[1,2,3,4,5,6], y=[1,2,3,4,5,6], yerr=[0.1,0.1,0.1,0.1,0.1,0.1], fmt='^',label='{} V'.format(str(v))) + #plt.plot(x=df1p['Fill'], y=df1p['x_max'],marker='.',label='{} V'.format(str(v)))#yerr=df1p['x_err'], plt.xlabel("Fill number") plt.ylabel('Time of the pulse shape maximum (ns)') - plt.title("Time evolution of max. position for sector {}".format(str(isect))) + plt.title("Time evolution of max. position for sector {} using nstrips={}".format(str(isect),istrip)) plt.legend(loc='upper left') - #plt.show() - plt.savefig('./Max_Evol_Plots/Max_Evol_{}_{}.pdf'.format(layer,str(isect))) + #plt.show() + plt.savefig(Outputfolder+'Max_Evol_{}_{}_{}.pdf'.format(layer,str(isect),istrip)) plt.clf() ##################### if(plot2): - - df1 = df[(df.Fill == 5162)] - df2 = df[(df.Fill == 5448)] + + first_fill = 5162#int(raw_input(">For the last plot choose the first fill (5162): ")) + second_fill = 5448#int(raw_input(">For the last plot choose the second fill (5448): ")) + df1 = df[(df.Fill == first_fill)] + df2 = df[(df.Fill == second_fill)] @@ -176,9 +201,9 @@ plt.xlabel("Sector") plt.ylabel('Time difference (ns)') - plt.title("Time difference of max. positions fill 5448-5162" ) + plt.title("Time difference of max. positions fill 5448-5162 using nstrips={}".format(istrip) ) plt.legend(loc='upper left') - plt.savefig('./Max_Evol_Plots/TimeDifferences_{}_HV.pdf'.format(layer)) + plt.savefig(Outputfolder+'TimeDifferences_fill{}_{}_HV_ns{}.pdf'.format(str(first_fill)+str(second_fill),layer,istrip)) plt.clf() diff --git a/scripts/runAllcheckShift.py b/scripts/runAllcheckShift.py new file mode 100644 index 0000000..55999c7 --- /dev/null +++ b/scripts/runAllcheckShift.py @@ -0,0 +1,35 @@ +import os +import sys + + + +if __name__ == '__main__': + + ''' + Autor: Michele Atzeni + Email: michele.atzeni@cern.ch + + Working in date 14.06.2017 + ''' + detDict = {"TT":{"layer":["TTaU"],"nstrips":['3','5','7']}, + "IT":{"layer":["T3X2"],"nstrips":['7']}, + } + + for idet in ["TT","IT"]: + print "======= Detector: {} =======".format(idet) + + for ilay in detDict[idet]["layer"]: + print "======= Layer: {} =======".format(ilay) + + for instrip in detDict[idet]["nstrips"]: + print "======= nStrips: {} =======".format(instrip) + + os.system('python -u checkShift.py -d {} -l {} -n {} --Vred'.format(idet,ilay,instrip)) + + + + + + + +