Index: fact/tools/pyscripts/pyfact/pyfact.py
===================================================================
--- fact/tools/pyscripts/pyfact/pyfact.py	(revision 13383)
+++ fact/tools/pyscripts/pyfact/pyfact.py	(revision 13384)
@@ -167,15 +167,15 @@
         self.calib_file = calib_file
         
-        baseline_mean = calib_file.GetN('BaselineMean')
-        gain_mean = calib_file.GetN('GainMean')
+        baseline_mean       = calib_file.GetN('BaselineMean')
+        gain_mean           = calib_file.GetN('GainMean')
         trigger_offset_mean = calib_file.GetN('TriggerOffsetMean')
 
-        self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , baseline_mean/self.npix)
-        self.gm  = np.zeros(gain_mean, np.float32).reshape(self.npix , gain_mean/self.npix)
-        self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , trigger_offset_mean/self.npix)
-
-        self.Nblm = baseline_mean / self.npix
-        self.Ngm  = gain_mean / self.npix
+        self.Nblm  = baseline_mean       / self.npix
+        self.Ngm   = gain_mean           / self.npix
         self.Ntom  = trigger_offset_mean / self.npix
+
+        self.blm = np.zeros(baseline_mean, np.float32).reshape(self.npix , self.Nblm)
+        self.gm  = np.zeros(gain_mean, np.float32).reshape(self.npix , self.Ngm)
+        self.tom = np.zeros(trigger_offset_mean, np.float32).reshape(self.npix , self.Ntom)
 
         calib_file.SetPtrAddress('BaselineMean', self.blm)
@@ -201,5 +201,4 @@
     def next(self):
         """ used by __iter__ """
-
         if self.data_file.GetNextRow() == False:
             raise StopIteration
@@ -211,12 +210,10 @@
         if self.return_dict:
             return self.__dict__
-            else:
+        else:
             return self.acal_data, self.start_cells, self.trigger_type.value
 
     def next_event(self):
         """ load the next event from disk and calibrate it
-        
-        """
-
+        """
         self.data_file.GetNextRow()
         self.calibrate_drs_amplitude()
@@ -226,6 +223,7 @@
         
         """
+        # shortcuts
         blm = self.blm
-        gm = self.gm
+        gm  = self.gm
         tom = self.tom
         
@@ -234,13 +232,4 @@
         acal_data = self.data * to_mV  # convert ADC counts to mV
 
-        # make 2D arrays: row = pixel, col = drs_slice
-        #acal_data = np.reshape(acal_data, (self.npix, self.nroi) )
-        #blm = np.reshape(self.blm, (self.npix, self.Nblm) )
-        #tom = np.reshape(self.tom, (self.npix, self.Ntom) )
-        #gm  = np.reshape(self.gm,  (self.npix, self.Ngm) )
-        
-        # double the calibration constants
-        blm = np.hstack((blm,blm))
-        gm = np.hstack((gm,gm))
         
         for pixel in range( self.npix ):
@@ -249,31 +238,18 @@
             roi = self.nroi
             # rotate the pixel baseline mean to the Data startCell
-            #blm_pixel = blm[pixel,sc:sc+roi]
-            # rotate the pixel gain mean to the Data startCell
-            #gm_pixel = gm[pixel,sc:sc+roi]
+            acal_data[pixel,:] -= blm[pixel,sc:sc+roi]
             # the 'trigger offset mean' does not need to be rolled
             # on the contrary, it seems there is an offset in the DRS data,
             # which is related to its distance to the startCell, not to its 
             # distance to the beginning of the physical pipeline in the DRS chip
-            #tom_pixel = tom[pixel,0:roi]
-            
-            #acal_data[pixel,:] -= blm_pixel
-            #acal_data[pixel,:] -= tom_pixel
-            #acal_data[pixel,:] /= gm_pixel
-            acal_data[pixel,:] -= blm[pixel,sc:sc+roi]
             acal_data[pixel,:] -= tom[pixel,0:roi]
+            # rotate the pixel gain mean to the Data startCell
             acal_data[pixel,:] /= gm[pixel,sc:sc+roi]
             
+            
         self.acal_data = acal_data * 1907.35
         
-        #print 'blm _pyfact', blm[0,0:20] 
-        #t = np.roll( blm[0,:], -self.start_cells[0] )
-        #print 'blm _pyfact', t[0:20]
-        #print 'start_pyfact: ', self.start_cells[0]
-        #print 'acal _pyfact: ', self.acal_data[0,0:10] 
-        #t = np.roll( gm[0,:], -self.start_cells[0] )
-        #print 'gm _pyfact: ', t[0:10] 
-        #self.user_action_calib( self.acal_data, 
-        #    np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi)
+        self.user_action_calib( self.acal_data, 
+            np.reshape(self.data, (self.npix, self.nroi) ), blm, tom, gm, self.start_cells, self.nroi)
 
         
