24 homeDirectory = os.path.expanduser(
'/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
27 dataFolder = homeDirectory +
"/IBLData/processedData/means_sim/"
28 inputFolder = homeDirectory +
"/IBLData/processedData/"
30 if not os.path.exists(dataFolder):
37 nbins =
int((e_time - s_time)/stepsize)
38 b = [s_time + stepsize*x
for x
in range(0,nbins)]
40 output_dict = pd.DataFrame({})
45 for l
in lumi_df[
"intlumi"]:
46 total_lumi += l/(10**9)
47 lumis += [ total_lumi ]
50 lumi_df[
"totlumi"] = lumis
52 tmp_dict = lumi_df.groupby(pd.cut(lumi_df[
"start"],bins=b),as_index=
False).
mean()
53 tmp_dict.fillna(method=
'ffill',inplace=
True)
54 output_dict[
"start"] = b
55 output_dict[
"intlumi"] = tmp_dict[
"totlumi"]
56 times = [datetime.datetime.utcfromtimestamp(s)
for s
in b]
58 plt.scatter(times,output_dict[
"intlumi"],marker=
".")
60 plt.savefig(dataFolder+
"intlumi/"+m+
"_time.png")
67 sensorSize_planar = 50*250*200*1E-12
68 sensorSize_3D = 50*250*230*1E-12
70 sensorsPerModule = 336*80
73 for s
in output_dict[
"start"]:
74 volume += [sensorSize_3D*sensorsPerModule*4]
76 if m ==
"LI_S11_A_M4":
77 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
78 voltage_settings += [20.0]
79 elif s < time.mktime(datetime.date(2018,1,1).timetuple()):
80 voltage_settings += [30.0]
82 voltage_settings += [20.0]
84 if m ==
"LI_S12_A_M4":
85 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
86 voltage_settings += [20.0]
87 elif s < time.mktime(datetime.date(2018,1,1).timetuple()):
88 voltage_settings += [21.0]
90 voltage_settings += [30.0]
92 if m ==
"LI_S13_A_M4":
93 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
94 voltage_settings += [15.0]
96 voltage_settings += [40.0]
98 if s < time.mktime(datetime.date(2017,1,1).timetuple()):
99 voltage_settings += [20.0]
101 voltage_settings += [40.0]
103 for s
in output_dict[
"start"]:
104 volume += [sensorSize_planar*sensorsPerModule*4]
106 if s < time.mktime(datetime.date(2016,9,16).timetuple()):
107 voltage_settings += [80.0]
108 elif s < time.mktime(datetime.date(2017,1,1).timetuple()):
109 voltage_settings += [150.0]
110 elif s < time.mktime(datetime.date(2017,11,7).timetuple()):
111 voltage_settings += [350.0]
113 voltage_settings += [400.0]
115 output_dict[
"HV_VSet"] = voltage_settings
116 output_dict[
"volume"] = volume
118 dataTypes = [
"PP4LV",
"TModule",
"ENV_TT",
"HV_VMeas",
"HV_IMeas"]
120 for dataType
in dataTypes:
122 print (
"Investigating " + dataType )
124 if not os.path.exists(dataFolder+dataType):
125 os.mkdir(dataFolder+dataType)
128 infile = inputFolder + dataType +
"/" + m +
".ssv"
129 meas_header=[
"module_name",
"measurement_date",
"measurement_time",
"unix-timestamp",dataType]
130 meas_dict = pd.read_csv(infile, names=meas_header, delimiter=
' ', skiprows=1)
131 output_dict[dataType] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
133 if dataType ==
"TModule" or dataType ==
"PP4LV" or dataType ==
"ENV_TT":
134 output_dict.fillna(method=
'ffill',inplace=
True)
136 if dataType ==
"HV_VMeas":
137 output_dict[
"HV_VMeas_0"] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
138 output_dict.fillna(method=
'ffill',inplace=
True)
139 output_dict[
"HV_VMeas_1"] = meas_dict.groupby(pd.cut(meas_dict[
"unix-timestamp"],bins=b),as_index=
False).
mean()[dataType]
140 output_dict.fillna(method=
'bfill',inplace=
True)
141 output_dict[
"HV_VMeas"] = output_dict[[
"HV_VMeas_0",
"HV_VMeas_1"]].
mean(axis=1)
143 output_dict.plot.scatter(x=
"intlumi",y=dataType,marker=
".")
145 plt.savefig(dataFolder+dataType+
"/"+m+
".png")
148 plt.scatter(times,output_dict[dataType],marker=
".")
150 plt.savefig(dataFolder+dataType+
"/"+m+
"_time.png")
154 output_dict[
'TModule'] = np.where(output_dict[
'TModule'] < -20, output_dict[
'ENV_TT'], output_dict[
'TModule'])
156 plt.scatter(times,output_dict[
"TModule"],marker=
".",s=1,label=
"TModule")
157 plt.scatter(times,output_dict[
"ENV_TT"],marker=
".",s=1,label=
"ENV_TT")
160 plt.savefig(m+
".png")
163 saveFileName = dataFolder + m +
"_nocuts.ssv"
164 if os.path.exists(saveFileName):
165 os.remove(saveFileName)
166 output_dict.to_csv(saveFileName,index=
False)
168 output_dict.dropna(inplace=
True)
171 output_dict = output_dict[abs(output_dict[
"HV_VMeas"]-output_dict[
"HV_VSet"])<1.0]
174 output_dict[
"I_Eg1.12"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.12) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
175 output_dict[
"I_Eg1.21"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.21) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
176 output_dict[
"I_Eg1.30"] = [ row[
"HV_IMeas"] *
tempCorr(row[
"TModule"],1.30) / row[
"volume"]
for i, row
in output_dict.iterrows() ]
178 if not os.path.exists(dataFolder+
"I_Eg1.12"):
179 os.mkdir(dataFolder+
"I_Eg1.12")
180 output_dict.plot.scatter(
"intlumi",
"I_Eg1.12",marker=
".")
182 plt.savefig(dataFolder+
"I_Eg1.12/"+m+
".png")
185 if not os.path.exists(dataFolder+
"I_Eg1.21"):
186 os.mkdir(dataFolder+
"I_Eg1.21")
187 output_dict.plot.scatter(
"intlumi",
"I_Eg1.21",marker=
".")
189 plt.savefig(dataFolder+
"I_Eg1.21/"+m+
".png")
192 if not os.path.exists(dataFolder+
"I_Eg1.30"):
193 os.mkdir(dataFolder+
"I_Eg1.30")
194 output_dict.plot.scatter(
"intlumi",
"I_Eg1.30",marker=
".")
196 plt.savefig(dataFolder+
"I_Eg1.30/"+m+
".png")
199 saveFileName = dataFolder + m +
".ssv"
200 if os.path.exists(saveFileName):
201 os.remove(saveFileName)
202 output_dict.to_csv(saveFileName,index=
False)