Changeset 13384 for fact/tools/pyscripts/pyfact/pyfact.py
- Timestamp:
- 04/18/12 21:03:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/pyfact.py
r13383 r13384 167 167 self.calib_file = calib_file 168 168 169 baseline_mean = calib_file.GetN('BaselineMean')170 gain_mean = calib_file.GetN('GainMean')169 baseline_mean = calib_file.GetN('BaselineMean') 170 gain_mean = calib_file.GetN('GainMean') 171 171 trigger_offset_mean = calib_file.GetN('TriggerOffsetMean') 172 172 173 self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , baseline_mean/self.npix) 174 self.gm = np.zeros(gain_mean, np.float32).reshape(self.npix , gain_mean/self.npix) 175 self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , trigger_offset_mean/self.npix) 176 177 self.Nblm = baseline_mean / self.npix 178 self.Ngm = gain_mean / self.npix 173 self.Nblm = baseline_mean / self.npix 174 self.Ngm = gain_mean / self.npix 179 175 self.Ntom = trigger_offset_mean / self.npix 176 177 self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , self.Nblm) 178 self.gm = np.zeros(gain_mean, np.float32).reshape(self.npix , self.Ngm) 179 self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , self.Ntom) 180 180 181 181 calib_file.SetPtrAddress('BaselineMean', self.blm) … … 201 201 def next(self): 202 202 """ used by __iter__ """ 203 204 203 if self.data_file.GetNextRow() == False: 205 204 raise StopIteration … … 211 210 if self.return_dict: 212 211 return self.__dict__ 213 212 else: 214 213 return self.acal_data, self.start_cells, self.trigger_type.value 215 214 216 215 def next_event(self): 217 216 """ load the next event from disk and calibrate it 218 219 """ 220 217 """ 221 218 self.data_file.GetNextRow() 222 219 self.calibrate_drs_amplitude() … … 226 223 227 224 """ 225 # shortcuts 228 226 blm = self.blm 229 gm = self.gm227 gm = self.gm 230 228 tom = self.tom 231 229 … … 234 232 acal_data = self.data * to_mV # convert ADC counts to mV 235 233 236 # make 2D arrays: row = pixel, col = drs_slice237 #acal_data = np.reshape(acal_data, (self.npix, self.nroi) )238 #blm = np.reshape(self.blm, (self.npix, self.Nblm) )239 #tom = np.reshape(self.tom, (self.npix, self.Ntom) )240 #gm = np.reshape(self.gm, (self.npix, self.Ngm) )241 242 # double the calibration constants243 blm = np.hstack((blm,blm))244 gm = np.hstack((gm,gm))245 234 246 235 for pixel in range( self.npix ): … … 249 238 roi = self.nroi 250 239 # rotate the pixel baseline mean to the Data startCell 251 #blm_pixel = blm[pixel,sc:sc+roi] 252 # rotate the pixel gain mean to the Data startCell 253 #gm_pixel = gm[pixel,sc:sc+roi] 240 acal_data[pixel,:] -= blm[pixel,sc:sc+roi] 254 241 # the 'trigger offset mean' does not need to be rolled 255 242 # on the contrary, it seems there is an offset in the DRS data, 256 243 # which is related to its distance to the startCell, not to its 257 244 # distance to the beginning of the physical pipeline in the DRS chip 258 #tom_pixel = tom[pixel,0:roi]259 260 #acal_data[pixel,:] -= blm_pixel261 #acal_data[pixel,:] -= tom_pixel262 #acal_data[pixel,:] /= gm_pixel263 acal_data[pixel,:] -= blm[pixel,sc:sc+roi]264 245 acal_data[pixel,:] -= tom[pixel,0:roi] 246 # rotate the pixel gain mean to the Data startCell 265 247 acal_data[pixel,:] /= gm[pixel,sc:sc+roi] 266 248 249 267 250 self.acal_data = acal_data * 1907.35 268 251 269 #print 'blm _pyfact', blm[0,0:20] 270 #t = np.roll( blm[0,:], -self.start_cells[0] ) 271 #print 'blm _pyfact', t[0:20] 272 #print 'start_pyfact: ', self.start_cells[0] 273 #print 'acal _pyfact: ', self.acal_data[0,0:10] 274 #t = np.roll( gm[0,:], -self.start_cells[0] ) 275 #print 'gm _pyfact: ', t[0:10] 276 #self.user_action_calib( self.acal_data, 277 # np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi) 252 self.user_action_calib( self.acal_data, 253 np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi) 278 254 279 255
Note:
See TracChangeset
for help on using the changeset viewer.