Index: fact/tools/pyscripts/pyfact/pyfact.py
===================================================================
--- fact/tools/pyscripts/pyfact/pyfact.py	(revision 13380)
+++ fact/tools/pyscripts/pyfact/pyfact.py	(revision 13382)
@@ -145,5 +145,5 @@
         self.trigger_type = c_ushort()
         #: 1D array with raw data
-        self.data  = np.zeros( self.npix * self.nroi, np.int16 )
+        self.data  = np.zeros( self.npix * self.nroi, np.int16 ).reshape(self.npix ,self.nroi)
         #: slice where drs readout started
         self.start_cells = np.zeros( self.npix, np.int16 )
@@ -171,7 +171,7 @@
         trigger_offset_mean = calib_file.GetN('TriggerOffsetMean')
 
-        self.blm = np.zeros(baseline_mean, np.float32)
-        self.gm  = np.zeros(gain_mean, np.float32)
-        self.tom = np.zeros(trigger_offset_mean, np.float32)
+        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
@@ -183,4 +183,9 @@
         calib_file.SetPtrAddress('TriggerOffsetMean', self.tom)
         calib_file.GetRow(0)
+        
+        # make calibration constants double, so we never need to roll
+        self.blm = np.hstack((self.blm, self.blm))
+        self.gm = np.hstack((self.gm, self.gm))
+        self.tom = np.hstack((self.tom, self.tom))
 
         self.v_bsl = np.zeros(self.npix)  # array of baseline values (all ZERO)
@@ -221,5 +226,8 @@
         
         """
-
+        blm = self.blm
+        gm = self.gm
+        tom = self.tom
+        
         to_mV = 2000./4096.
         #: 2D array with amplitude calibrated dat in mV
@@ -227,8 +235,8 @@
 
         # 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) )
+        #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
@@ -237,15 +245,16 @@
         
         for pixel in range( self.npix ):
+            #shortcuts 
+            sc = self.start_cells[pixel]
+            roi = self.nroi
             # rotate the pixel baseline mean to the Data startCell
-            #blm_pixel = np.roll( blm[pixel,:], -self.start_cells[pixel] )
-            blm_pixel = blm[pixel, self.start_cells[pixel]:self.start_cells[pixel]+self.nroi]
+            blm_pixel = blm[pixel,sc:sc+roi]
             # rotate the pixel gain mean to the Data startCell
-            #gm_pixel = np.roll( gm[pixel,:], -self.start_cells[pixel] )
-            gm_pixel = gm[pixel, self.start_cells[pixel]:self.start_cells[pixel]+self.nroi]
+            gm_pixel = gm[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:self.nroi ]
+            tom_pixel = tom[pixel,0:roi]
             
             acal_data[pixel,:] -= blm_pixel
