ATLAS Offline Software
Functions
avgSim Namespace Reference

Functions

def tempCorr (Temp, Eg)
 
def averageData (m, lumi_df)
 
def main ()
 

Function Documentation

◆ averageData()

def avgSim.averageData (   m,
  lumi_df 
)

Definition at line 21 of file avgSim.py.

21 def averageData (m,lumi_df):
22 
23  #home directory definition
24  homeDirectory = os.path.expanduser('/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/')
25 
26  # Define path to folder
27  dataFolder = homeDirectory + "/IBLData/processedData/means_sim/"
28  inputFolder = homeDirectory + "/IBLData/processedData/"
29 
30  if not os.path.exists(dataFolder):
31  os.mkdir(dataFolder)
32 
33  # Time bins = every day
34  s_time = 1433310297
35  e_time = 1541545141
36  stepsize = 3600
37  nbins = int((e_time - s_time)/stepsize)
38  b = [s_time + stepsize*x for x in range(0,nbins)]
39 
40  output_dict = pd.DataFrame({})
41 
42  # Loop over lumi blocks
43  lumis = []
44  total_lumi = 0
45  for l in lumi_df["intlumi"]:
46  total_lumi += l/(10**9)
47  lumis += [ total_lumi ]
48 
49  print(total_lumi)
50  lumi_df["totlumi"] = lumis
51 
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]
57 
58  plt.scatter(times,output_dict["intlumi"],marker=".")
59  plt.title(m)
60  plt.savefig(dataFolder+"intlumi/"+m+"_time.png")
61  plt.close()
62 
63  # Jennet gets these from https://twiki.cern.ch/twiki/bin/viewauth/Atlas/PixelConditionsRUN2
64  voltage_settings = []
65 
66  volume = []
67  sensorSize_planar = 50*250*200*1E-12 #cm3
68  sensorSize_3D = 50*250*230*1E-12 #cm3
69 
70  sensorsPerModule = 336*80
71 
72  if m.endswith("M4"): # 3D module
73  for s in output_dict["start"]:
74  volume += [sensorSize_3D*sensorsPerModule*4]
75 
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]
81  else:
82  voltage_settings += [20.0]
83  continue
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]
89  else:
90  voltage_settings += [30.0]
91  continue
92  if m == "LI_S13_A_M4":
93  if s < time.mktime(datetime.date(2017,1,1).timetuple()):
94  voltage_settings += [15.0]
95  else:
96  voltage_settings += [40.0]
97  continue
98  if s < time.mktime(datetime.date(2017,1,1).timetuple()):
99  voltage_settings += [20.0]
100  else:
101  voltage_settings += [40.0]
102  else: # Planar module
103  for s in output_dict["start"]:
104  volume += [sensorSize_planar*sensorsPerModule*4]
105 
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]
112  else:
113  voltage_settings += [400.0]
114 
115  output_dict["HV_VSet"] = voltage_settings
116  output_dict["volume"] = volume
117 
118  dataTypes = ["PP4LV","TModule","ENV_TT","HV_VMeas","HV_IMeas"]
119 
120  for dataType in dataTypes:
121 
122  print ("Investigating " + dataType )
123 
124  if not os.path.exists(dataFolder+dataType):
125  os.mkdir(dataFolder+dataType)
126 
127  # DO THE AVERAGES
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]
132 
133  if dataType == "TModule" or dataType == "PP4LV" or dataType == "ENV_TT":
134  output_dict.fillna(method='ffill',inplace=True)
135 
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)
142 
143  output_dict.plot.scatter(x="intlumi",y=dataType,marker=".")
144  plt.title(m)
145  plt.savefig(dataFolder+dataType+"/"+m+".png")
146  plt.close()
147 
148  plt.scatter(times,output_dict[dataType],marker=".")
149  plt.title(m)
150  plt.savefig(dataFolder+dataType+"/"+m+"_time.png")
151  plt.close()
152 
153  # Take cooling pipe temp
154  output_dict['TModule'] = np.where(output_dict['TModule'] < -20, output_dict['ENV_TT'], output_dict['TModule'])
155 
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")
158  plt.legend()
159  plt.title(m)
160  plt.savefig(m+".png")
161  plt.close()
162 
163  saveFileName = dataFolder + m + "_nocuts.ssv"
164  if os.path.exists(saveFileName):
165  os.remove(saveFileName)
166  output_dict.to_csv(saveFileName,index=False)
167 
168  output_dict.dropna(inplace=True)
169 
170  # Veto
171  output_dict = output_dict[abs(output_dict["HV_VMeas"]-output_dict["HV_VSet"])<1.0]
172 
173  # Correct
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() ]
177 
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=".")
181  plt.title(m)
182  plt.savefig(dataFolder+"I_Eg1.12/"+m+".png")
183  plt.close()
184 
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=".")
188  plt.title(m)
189  plt.savefig(dataFolder+"I_Eg1.21/"+m+".png")
190  plt.close()
191 
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=".")
195  plt.title(m)
196  plt.savefig(dataFolder+"I_Eg1.30/"+m+".png")
197  plt.close()
198 
199  saveFileName = dataFolder + m + ".ssv"
200  if os.path.exists(saveFileName):
201  os.remove(saveFileName)
202  output_dict.to_csv(saveFileName,index=False)
203 
204 # Begin script

◆ main()

def avgSim.main ( )

Definition at line 205 of file avgSim.py.

205 def main():
206 
207  infile_lumi = "/eos/atlas/user/j/jdickins/Pixel/LeakageCurrent/IBLData/processedData/Lumi/runData.txt"
208  lumi_header=["run","fill","lb","start","len","0","1","lumiall","intlumi"]
209  lumi_df=pd.read_csv(infile_lumi, names=lumi_header, delimiter=' ', skiprows=0)
210 
211  input_module = sys.argv[1]
212  averageData(input_module,lumi_df)
213 

◆ tempCorr()

def avgSim.tempCorr (   Temp,
  Eg 
)

Definition at line 12 of file avgSim.py.

12 def tempCorr(Temp,Eg):
13 
14  kB = 8.617*pow(10,-5) # eV/K
15  Tref = 273.0 # Reference temperature in K
16  Temp = Temp + 273 # Convert to K
17 
18  return pow(1.0*Tref/Temp,2)*np.exp((-0.5*Eg/kB)*(1.0/Tref - 1.0/Temp))
19 
20 # Jennet shamelessly steals Nick's code for bookkeeping
avgSim.main
def main()
Definition: avgSim.py:205
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
avgSim.averageData
def averageData(m, lumi_df)
Definition: avgSim.py:21
avgSim.tempCorr
def tempCorr(Temp, Eg)
Definition: avgSim.py:12
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70