24 homeDirectory = os.path.expanduser(
'/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
27 dataFolder = homeDirectory +
"/IBLData/processedData/means_dat/"
28 inputFolder = homeDirectory +
"/IBLData/processedData/"
30 if not os.path.exists(dataFolder):
34 b = lumi_df[
"start"].drop_duplicates()
36 output_dict = pd.DataFrame({})
41 for l
in lumi_df[
"intlumi"]:
42 total_lumi += l/(10**9)
43 lumis += [ total_lumi ]
46 lumi_df[
"totlumi"] = lumis
50 output_dict[
"start"] = b
51 output_dict[
"intlumi"] = lumi_df[
"totlumi"]
52 output_dict.fillna(method=
'ffill',inplace=
True)
53 times = [datetime.datetime.utcfromtimestamp(s)
for s
in b]
55 plt.scatter(times,output_dict[
"intlumi"],marker=
".")
57 plt.savefig(dataFolder+
"intlumi/"+m+
"_time.png")
64 sensorSize_planar = 50*250*200*1E-12
65 sensorSize_3D = 50*250*230*1E-12
67 sensorsPerModule = 336*80
70 for s
in output_dict[
"start"]:
71 volume += [sensorSize_3D*sensorsPerModule*4]
73 if m ==
"LI_S11_A_M4":
74 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
75 voltage_settings += [20.0]
76 elif s < time.mktime(datetime.date(2018,1,1).timetuple()):
77 voltage_settings += [30.0]
79 voltage_settings += [20.0]
81 if m ==
"LI_S12_A_M4":
82 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
83 voltage_settings += [20.0]
84 elif s < time.mktime(datetime.date(2018,1,1).timetuple()):
85 voltage_settings += [21.0]
87 voltage_settings += [30.0]
89 if m ==
"LI_S13_A_M4":
90 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
91 voltage_settings += [15.0]
93 voltage_settings += [40.0]
95 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
96 voltage_settings += [20.0]
98 voltage_settings += [40.0]
100 for s
in output_dict[
"start"]:
101 volume += [sensorSize_planar*sensorsPerModule*4]
103 if s < time.mktime(datetime.date(2016,9,16).timetuple()):
104 voltage_settings += [80.0]
105 elif s < time.mktime(datetime.date(2017,1,1).timetuple()):
106 voltage_settings += [150.0]
107 elif s < time.mktime(datetime.date(2017,11,7).timetuple()):
108 voltage_settings += [350.0]
110 voltage_settings += [400.0]
112 output_dict[
"HV_VSet"] = voltage_settings
113 output_dict[
"volume"] = volume
115 dataTypes = [
"PP4LV",
"TModule",
"ENV_TT",
"HV_VMeas",
"HV_IMeas"]
117 for dataType
in dataTypes:
119 print (
"Investigating " + dataType )
121 if not os.path.exists(dataFolder+dataType):
122 os.mkdir(dataFolder+dataType)
125 infile = inputFolder + dataType +
"/" + m +
".ssv"
126 meas_header=[
"module_name",
"measurement_date",
"measurement_time",
"unix-timestamp",dataType]
127 meas_dict = pd.read_csv(infile, names=meas_header, delimiter=
' ', skiprows=1)
128 output_dict[dataType] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
130 if dataType ==
"TModule" or dataType ==
"PP4LV" or dataType ==
"ENV_TT":
131 output_dict.fillna(method=
'ffill',inplace=
True)
133 if dataType ==
"HV_VMeas":
134 output_dict[
"HV_VMeas_0"] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
135 output_dict.fillna(method=
'ffill',inplace=
True)
136 output_dict[
"HV_VMeas_1"] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
137 output_dict.fillna(method=
'bfill',inplace=
True)
138 output_dict[
"HV_VMeas"] = output_dict[[
"HV_VMeas_0",
"HV_VMeas_1"]].
mean(axis=1)
140 output_dict.plot.scatter(x=
"intlumi",y=dataType,marker=
".")
142 plt.savefig(dataFolder+dataType+
"/"+m+
".png")
145 plt.scatter(times,output_dict[dataType],marker=
".")
147 plt.savefig(dataFolder+dataType+
"/"+m+
"_time.png")
153 plt.scatter(times,output_dict[
"TModule"],marker=
".",s=1,label=
"TModule")
154 plt.scatter(times,output_dict[
"ENV_TT"],marker=
".",s=1,label=
"ENV_TT")
157 plt.savefig(m+
".png")
160 saveFileName = dataFolder + m +
"_nocuts.ssv"
161 if os.path.exists(saveFileName):
162 os.remove(saveFileName)
163 output_dict.to_csv(saveFileName,index=
False)
165 output_dict.dropna(inplace=
True)
168 output_dict = output_dict[abs(output_dict[
"HV_VMeas"]-output_dict[
"HV_VSet"])<1.0]
171 output_dict[
"I_Eg1.12"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.12) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
172 output_dict[
"I_Eg1.21"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.21) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
173 output_dict[
"I_Eg1.30"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.30) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
175 if not os.path.exists(dataFolder+
"I_Eg1.12"):
176 os.mkdir(dataFolder+
"I_Eg1.12")
177 output_dict.plot.scatter(
"intlumi",
"I_Eg1.12",marker=
".")
179 plt.savefig(dataFolder+
"I_Eg1.12/"+m+
".png")
182 if not os.path.exists(dataFolder+
"I_Eg1.21"):
183 os.mkdir(dataFolder+
"I_Eg1.21")
184 output_dict.plot.scatter(
"intlumi",
"I_Eg1.21",marker=
".")
186 plt.savefig(dataFolder+
"I_Eg1.21/"+m+
".png")
189 if not os.path.exists(dataFolder+
"I_Eg1.30"):
190 os.mkdir(dataFolder+
"I_Eg1.30")
191 output_dict.plot.scatter(
"intlumi",
"I_Eg1.30",marker=
".")
193 plt.savefig(dataFolder+
"I_Eg1.30/"+m+
".png")
196 saveFileName = dataFolder + m +
".ssv"
197 if os.path.exists(saveFileName):
198 os.remove(saveFileName)
199 output_dict.to_csv(saveFileName,index=
False)